aboutsummaryrefslogtreecommitdiff
path: root/lib/ffmpeg/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffmpeg/libavcodec')
-rw-r--r--lib/ffmpeg/libavcodec/4xm.c41
-rw-r--r--lib/ffmpeg/libavcodec/8bps.c2
-rw-r--r--lib/ffmpeg/libavcodec/8svx.c6
-rw-r--r--lib/ffmpeg/libavcodec/Makefile66
-rw-r--r--lib/ffmpeg/libavcodec/a64colors.h (renamed from lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.h)36
-rw-r--r--lib/ffmpeg/libavcodec/a64enc.h55
-rw-r--r--lib/ffmpeg/libavcodec/a64multienc.c389
-rw-r--r--lib/ffmpeg/libavcodec/a64tables.h150
-rw-r--r--lib/ffmpeg/libavcodec/aac.h4
-rw-r--r--lib/ffmpeg/libavcodec/aac_adtstoasc_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/aac_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/aac_tablegen_decl.h6
-rw-r--r--lib/ffmpeg/libavcodec/aacadtsdec.h4
-rw-r--r--lib/ffmpeg/libavcodec/aaccoder.c150
-rw-r--r--lib/ffmpeg/libavcodec/aacdec.c544
-rw-r--r--lib/ffmpeg/libavcodec/aacdectab.h15
-rw-r--r--lib/ffmpeg/libavcodec/aacenc.c67
-rw-r--r--lib/ffmpeg/libavcodec/aacpsy.c389
-rw-r--r--lib/ffmpeg/libavcodec/aacsbr.c13
-rw-r--r--lib/ffmpeg/libavcodec/aasc.c2
-rw-r--r--lib/ffmpeg/libavcodec/ac3.c46
-rw-r--r--lib/ffmpeg/libavcodec/ac3.h21
-rw-r--r--lib/ffmpeg/libavcodec/ac3_parser.c31
-rw-r--r--lib/ffmpeg/libavcodec/ac3_parser.h15
-rw-r--r--lib/ffmpeg/libavcodec/ac3dec.c30
-rw-r--r--lib/ffmpeg/libavcodec/ac3dec.h18
-rw-r--r--lib/ffmpeg/libavcodec/ac3dec_data.c6
-rw-r--r--lib/ffmpeg/libavcodec/ac3dec_data.h1
-rw-r--r--lib/ffmpeg/libavcodec/ac3enc.c2567
-rw-r--r--lib/ffmpeg/libavcodec/ac3enc_fixed.c440
-rw-r--r--lib/ffmpeg/libavcodec/ac3enc_fixed.h59
-rw-r--r--lib/ffmpeg/libavcodec/ac3enc_float.c124
-rw-r--r--lib/ffmpeg/libavcodec/ac3enc_float.h (renamed from lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.h)32
-rw-r--r--lib/ffmpeg/libavcodec/ac3tab.c32
-rw-r--r--lib/ffmpeg/libavcodec/ac3tab.h7
-rw-r--r--lib/ffmpeg/libavcodec/acelp_filters.h6
-rw-r--r--lib/ffmpeg/libavcodec/acelp_pitch_delay.h4
-rw-r--r--lib/ffmpeg/libavcodec/acelp_vectors.h6
-rw-r--r--lib/ffmpeg/libavcodec/adpcm.c106
-rw-r--r--lib/ffmpeg/libavcodec/adxdec.c4
-rw-r--r--lib/ffmpeg/libavcodec/adxenc.c4
-rw-r--r--lib/ffmpeg/libavcodec/alac.c40
-rw-r--r--lib/ffmpeg/libavcodec/alacenc.c32
-rw-r--r--lib/ffmpeg/libavcodec/allcodecs.c39
-rw-r--r--lib/ffmpeg/libavcodec/alsdec.c157
-rw-r--r--lib/ffmpeg/libavcodec/amr.h68
-rw-r--r--lib/ffmpeg/libavcodec/amrnbdec.c46
-rw-r--r--lib/ffmpeg/libavcodec/amrwbdata.h1890
-rw-r--r--lib/ffmpeg/libavcodec/amrwbdec.c1237
-rw-r--r--lib/ffmpeg/libavcodec/anm.c2
-rw-r--r--lib/ffmpeg/libavcodec/ansi.c435
-rw-r--r--lib/ffmpeg/libavcodec/apedec.c4
-rw-r--r--lib/ffmpeg/libavcodec/arm/Makefile12
-rw-r--r--lib/ffmpeg/libavcodec/arm/asm-offsets.h21
-rw-r--r--lib/ffmpeg/libavcodec/arm/asm.S12
-rw-r--r--lib/ffmpeg/libavcodec/arm/dcadsp_init_arm.c2
-rw-r--r--lib/ffmpeg/libavcodec/arm/dcadsp_neon.S5
-rw-r--r--lib/ffmpeg/libavcodec/arm/dsputil_init_arm.c5
-rw-r--r--lib/ffmpeg/libavcodec/arm/dsputil_init_neon.c15
-rw-r--r--lib/ffmpeg/libavcodec/arm/dsputil_init_vfp.c7
-rw-r--r--lib/ffmpeg/libavcodec/arm/dsputil_iwmmxt.c8
-rw-r--r--lib/ffmpeg/libavcodec/arm/dsputil_neon.S425
-rw-r--r--lib/ffmpeg/libavcodec/arm/dsputil_vfp.S84
-rw-r--r--lib/ffmpeg/libavcodec/arm/fft_init_arm.c2
-rw-r--r--lib/ffmpeg/libavcodec/arm/fft_neon.S3
-rw-r--r--lib/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c48
-rw-r--r--lib/ffmpeg/libavcodec/arm/fmtconvert_neon.S391
-rw-r--r--lib/ffmpeg/libavcodec/arm/fmtconvert_vfp.S77
-rw-r--r--lib/ffmpeg/libavcodec/arm/h264dsp_init_arm.c9
-rw-r--r--lib/ffmpeg/libavcodec/arm/h264dsp_neon.S12
-rw-r--r--lib/ffmpeg/libavcodec/arm/h264idct_neon.S212
-rw-r--r--lib/ffmpeg/libavcodec/arm/h264pred_neon.S4
-rw-r--r--lib/ffmpeg/libavcodec/arm/mpegvideo_iwmmxt.c3
-rw-r--r--lib/ffmpeg/libavcodec/arm/mpegvideo_neon.S13
-rw-r--r--lib/ffmpeg/libavcodec/arm/synth_filter_neon.S8
-rw-r--r--lib/ffmpeg/libavcodec/ass.c124
-rw-r--r--lib/ffmpeg/libavcodec/ass.h77
-rw-r--r--lib/ffmpeg/libavcodec/assdec.c62
-rw-r--r--lib/ffmpeg/libavcodec/assenc.c67
-rw-r--r--lib/ffmpeg/libavcodec/asv1.c8
-rw-r--r--lib/ffmpeg/libavcodec/atrac.c8
-rw-r--r--lib/ffmpeg/libavcodec/atrac.h4
-rw-r--r--lib/ffmpeg/libavcodec/atrac1.c8
-rw-r--r--lib/ffmpeg/libavcodec/atrac3.c28
-rw-r--r--lib/ffmpeg/libavcodec/audioconvert.c182
-rw-r--r--lib/ffmpeg/libavcodec/audioconvert.h49
-rw-r--r--lib/ffmpeg/libavcodec/aura.c2
-rw-r--r--lib/ffmpeg/libavcodec/avcodec.h401
-rw-r--r--lib/ffmpeg/libavcodec/avpacket.c18
-rw-r--r--lib/ffmpeg/libavcodec/avs.c2
-rw-r--r--lib/ffmpeg/libavcodec/bethsoftvideo.c2
-rw-r--r--lib/ffmpeg/libavcodec/bfi.c13
-rw-r--r--lib/ffmpeg/libavcodec/bgmc.c19
-rw-r--r--lib/ffmpeg/libavcodec/bgmc.h8
-rw-r--r--lib/ffmpeg/libavcodec/bink.c11
-rw-r--r--lib/ffmpeg/libavcodec/binkaudio.c17
-rw-r--r--lib/ffmpeg/libavcodec/bmp.c3
-rw-r--r--lib/ffmpeg/libavcodec/bmpenc.c44
-rw-r--r--lib/ffmpeg/libavcodec/c93.c2
-rw-r--r--lib/ffmpeg/libavcodec/cavs.c43
-rw-r--r--lib/ffmpeg/libavcodec/cavs.h2
-rw-r--r--lib/ffmpeg/libavcodec/cavs_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/cavsdec.c4
-rw-r--r--lib/ffmpeg/libavcodec/cavsdsp.c10
-rw-r--r--lib/ffmpeg/libavcodec/cavsdsp.h41
-rw-r--r--lib/ffmpeg/libavcodec/cdgraphics.c2
-rw-r--r--lib/ffmpeg/libavcodec/celp_filters.h6
-rw-r--r--lib/ffmpeg/libavcodec/cga_data.c278
-rw-r--r--lib/ffmpeg/libavcodec/cga_data.h20
-rw-r--r--lib/ffmpeg/libavcodec/chomp_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/cinepak.c2
-rw-r--r--lib/ffmpeg/libavcodec/cljr.c9
-rw-r--r--lib/ffmpeg/libavcodec/cook.c4
-rw-r--r--lib/ffmpeg/libavcodec/cscd.c31
-rw-r--r--lib/ffmpeg/libavcodec/cyuv.c4
-rw-r--r--lib/ffmpeg/libavcodec/dca.c184
-rw-r--r--lib/ffmpeg/libavcodec/dca_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/dcadata.h12288
-rw-r--r--lib/ffmpeg/libavcodec/dcadsp.c6
-rw-r--r--lib/ffmpeg/libavcodec/dcadsp.h2
-rw-r--r--lib/ffmpeg/libavcodec/dct-test.c25
-rw-r--r--lib/ffmpeg/libavcodec/dirac.c3
-rw-r--r--lib/ffmpeg/libavcodec/dirac_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/dnxhd_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/dnxhddec.c16
-rw-r--r--lib/ffmpeg/libavcodec/dnxhdenc.c16
-rw-r--r--lib/ffmpeg/libavcodec/dpcm.c4
-rw-r--r--lib/ffmpeg/libavcodec/dpx.c10
-rw-r--r--lib/ffmpeg/libavcodec/dsicinav.c6
-rw-r--r--lib/ffmpeg/libavcodec/dsputil.c200
-rw-r--r--lib/ffmpeg/libavcodec/dsputil.h108
-rw-r--r--lib/ffmpeg/libavcodec/dump_extradata_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/dv.c16
-rw-r--r--lib/ffmpeg/libavcodec/dvbsub.c2
-rw-r--r--lib/ffmpeg/libavcodec/dvbsub_parser.c10
-rw-r--r--lib/ffmpeg/libavcodec/dvbsubdec.c31
-rw-r--r--lib/ffmpeg/libavcodec/dvdata.c14
-rw-r--r--lib/ffmpeg/libavcodec/dvdsub_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/dvdsubdec.c20
-rw-r--r--lib/ffmpeg/libavcodec/dvdsubenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/dwt.c4
-rw-r--r--lib/ffmpeg/libavcodec/dwt.h2
-rw-r--r--lib/ffmpeg/libavcodec/dxa.c2
-rw-r--r--lib/ffmpeg/libavcodec/dxva2_h264.c2
-rw-r--r--lib/ffmpeg/libavcodec/dxva2_mpeg2.c2
-rw-r--r--lib/ffmpeg/libavcodec/dxva2_vc1.c4
-rw-r--r--lib/ffmpeg/libavcodec/eacmv.c12
-rw-r--r--lib/ffmpeg/libavcodec/eamad.c5
-rw-r--r--lib/ffmpeg/libavcodec/eatgq.c2
-rw-r--r--lib/ffmpeg/libavcodec/eatgv.c5
-rw-r--r--lib/ffmpeg/libavcodec/eatqi.c2
-rw-r--r--lib/ffmpeg/libavcodec/escape124.c11
-rw-r--r--lib/ffmpeg/libavcodec/fft-test.c29
-rw-r--r--lib/ffmpeg/libavcodec/fft.c7
-rw-r--r--lib/ffmpeg/libavcodec/fft.h2
-rw-r--r--lib/ffmpeg/libavcodec/ffv1.c931
-rw-r--r--lib/ffmpeg/libavcodec/flac.c108
-rw-r--r--lib/ffmpeg/libavcodec/flac.h17
-rw-r--r--lib/ffmpeg/libavcodec/flac_parser.c682
-rw-r--r--lib/ffmpeg/libavcodec/flacdec.c238
-rw-r--r--lib/ffmpeg/libavcodec/flacenc.c1128
-rw-r--r--lib/ffmpeg/libavcodec/flashsv.c2
-rw-r--r--lib/ffmpeg/libavcodec/flashsvenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/flicvideo.c23
-rw-r--r--lib/ffmpeg/libavcodec/flvdec.c5
-rw-r--r--lib/ffmpeg/libavcodec/flvenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/fmtconvert.c68
-rw-r--r--lib/ffmpeg/libavcodec/fmtconvert.h79
-rw-r--r--lib/ffmpeg/libavcodec/fraps.c15
-rw-r--r--lib/ffmpeg/libavcodec/frwu.c2
-rw-r--r--lib/ffmpeg/libavcodec/g722.c583
-rw-r--r--lib/ffmpeg/libavcodec/g726.c19
-rw-r--r--lib/ffmpeg/libavcodec/g729dec.c2
-rw-r--r--lib/ffmpeg/libavcodec/get_bits.h552
-rw-r--r--lib/ffmpeg/libavcodec/gif.c4
-rw-r--r--lib/ffmpeg/libavcodec/gifdec.c39
-rw-r--r--lib/ffmpeg/libavcodec/gsmdec.c221
-rw-r--r--lib/ffmpeg/libavcodec/gsmdec_data.c94
-rw-r--r--lib/ffmpeg/libavcodec/gsmdec_data.h (renamed from lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.h)35
-rw-r--r--lib/ffmpeg/libavcodec/gsmdec_template.c150
-rw-r--r--lib/ffmpeg/libavcodec/h261_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/h261dec.c6
-rw-r--r--lib/ffmpeg/libavcodec/h261enc.c2
-rw-r--r--lib/ffmpeg/libavcodec/h263_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/h263dec.c12
-rw-r--r--lib/ffmpeg/libavcodec/h264.c244
-rw-r--r--lib/ffmpeg/libavcodec/h264.h36
-rw-r--r--lib/ffmpeg/libavcodec/h264_cabac.c74
-rw-r--r--lib/ffmpeg/libavcodec/h264_cavlc.c67
-rw-r--r--lib/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/h264_parser.c10
-rw-r--r--lib/ffmpeg/libavcodec/h264_ps.c20
-rw-r--r--lib/ffmpeg/libavcodec/h264dsp.c1
-rw-r--r--lib/ffmpeg/libavcodec/h264dsp.h6
-rw-r--r--lib/ffmpeg/libavcodec/h264dspenc.c78
-rw-r--r--lib/ffmpeg/libavcodec/h264enc.c260
-rw-r--r--lib/ffmpeg/libavcodec/h264idct.c107
-rw-r--r--lib/ffmpeg/libavcodec/h264pred.c75
-rw-r--r--lib/ffmpeg/libavcodec/h264pred.h22
-rw-r--r--lib/ffmpeg/libavcodec/huffyuv.c8
-rw-r--r--lib/ffmpeg/libavcodec/idcinvideo.c2
-rw-r--r--lib/ffmpeg/libavcodec/iff.c10
-rw-r--r--lib/ffmpeg/libavcodec/iirfilter.c245
-rw-r--r--lib/ffmpeg/libavcodec/iirfilter.h29
-rw-r--r--lib/ffmpeg/libavcodec/imc.c17
-rw-r--r--lib/ffmpeg/libavcodec/imgconvert.c493
-rw-r--r--lib/ffmpeg/libavcodec/imgconvert.h6
-rw-r--r--lib/ffmpeg/libavcodec/imx_dump_header_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/indeo2.c2
-rw-r--r--lib/ffmpeg/libavcodec/indeo3.c5
-rw-r--r--lib/ffmpeg/libavcodec/indeo5.c34
-rw-r--r--lib/ffmpeg/libavcodec/intelh263dec.c2
-rw-r--r--lib/ffmpeg/libavcodec/interplayvideo.c6
-rw-r--r--lib/ffmpeg/libavcodec/inverse.c1
-rw-r--r--lib/ffmpeg/libavcodec/ituh263dec.c8
-rw-r--r--lib/ffmpeg/libavcodec/ituh263enc.c4
-rw-r--r--lib/ffmpeg/libavcodec/ivi_common.c4
-rw-r--r--lib/ffmpeg/libavcodec/ivi_common.h58
-rw-r--r--lib/ffmpeg/libavcodec/ivi_dsp.h80
-rw-r--r--lib/ffmpeg/libavcodec/jpeglsdec.c2
-rw-r--r--lib/ffmpeg/libavcodec/jpeglsenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/kgv1dec.c5
-rw-r--r--lib/ffmpeg/libavcodec/kmvc.c2
-rw-r--r--lib/ffmpeg/libavcodec/lagarith.c522
-rw-r--r--lib/ffmpeg/libavcodec/lagarithrac.c58
-rw-r--r--lib/ffmpeg/libavcodec/lagarithrac.h116
-rw-r--r--lib/ffmpeg/libavcodec/latm_parser.c66
-rw-r--r--lib/ffmpeg/libavcodec/latmaac.c391
-rw-r--r--lib/ffmpeg/libavcodec/lcldec.c4
-rw-r--r--lib/ffmpeg/libavcodec/lclenc.c15
-rw-r--r--lib/ffmpeg/libavcodec/libavcodec.v6
-rw-r--r--lib/ffmpeg/libavcodec/libdiracdec.c7
-rw-r--r--lib/ffmpeg/libavcodec/libdiracenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/libfaac.c12
-rw-r--r--lib/ffmpeg/libavcodec/libfaad.c333
-rw-r--r--lib/ffmpeg/libavcodec/libgsm.c14
-rw-r--r--lib/ffmpeg/libavcodec/libmp3lame.c9
-rw-r--r--lib/ffmpeg/libavcodec/libopencore-amr.c10
-rw-r--r--lib/ffmpeg/libavcodec/libopenjpeg.c5
-rw-r--r--lib/ffmpeg/libavcodec/libschroedingerdec.c7
-rw-r--r--lib/ffmpeg/libavcodec/libschroedingerenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/libspeexdec.c4
-rw-r--r--lib/ffmpeg/libavcodec/libtheoraenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/libvorbis.c35
-rw-r--r--lib/ffmpeg/libavcodec/libvpxdec.c5
-rw-r--r--lib/ffmpeg/libavcodec/libvpxenc.c29
-rw-r--r--lib/ffmpeg/libavcodec/libx264.c21
-rw-r--r--lib/ffmpeg/libavcodec/libxavs.c351
-rw-r--r--lib/ffmpeg/libavcodec/libxvidff.c45
-rw-r--r--lib/ffmpeg/libavcodec/ljpegenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/loco.c2
-rw-r--r--lib/ffmpeg/libavcodec/lpc.c69
-rw-r--r--lib/ffmpeg/libavcodec/lpc.h49
-rw-r--r--lib/ffmpeg/libavcodec/lsp.c34
-rw-r--r--lib/ffmpeg/libavcodec/lsp.h24
-rw-r--r--lib/ffmpeg/libavcodec/mace.c6
-rw-r--r--lib/ffmpeg/libavcodec/mdec.c6
-rw-r--r--lib/ffmpeg/libavcodec/mimic.c2
-rw-r--r--lib/ffmpeg/libavcodec/mips/mathops.h4
-rw-r--r--lib/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c113
-rw-r--r--lib/ffmpeg/libavcodec/mjpeg_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/mjpega_dump_header_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/mjpegbdec.c2
-rw-r--r--lib/ffmpeg/libavcodec/mjpegdec.c119
-rw-r--r--lib/ffmpeg/libavcodec/mjpegdec.h2
-rw-r--r--lib/ffmpeg/libavcodec/mjpegenc.c4
-rw-r--r--lib/ffmpeg/libavcodec/mlp_parser.c6
-rw-r--r--lib/ffmpeg/libavcodec/mlpdec.c10
-rw-r--r--lib/ffmpeg/libavcodec/mmvideo.c22
-rw-r--r--lib/ffmpeg/libavcodec/motion-test.c6
-rw-r--r--lib/ffmpeg/libavcodec/motionpixels.c2
-rw-r--r--lib/ffmpeg/libavcodec/movsub_bsf.c4
-rw-r--r--lib/ffmpeg/libavcodec/mp3_header_compress_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/mp3_header_decompress_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/mpc.c14
-rw-r--r--lib/ffmpeg/libavcodec/mpc.h2
-rw-r--r--lib/ffmpeg/libavcodec/mpc7.c8
-rw-r--r--lib/ffmpeg/libavcodec/mpc8.c15
-rw-r--r--lib/ffmpeg/libavcodec/mpeg12.c93
-rw-r--r--lib/ffmpeg/libavcodec/mpeg12.h8
-rw-r--r--lib/ffmpeg/libavcodec/mpeg12enc.c6
-rw-r--r--lib/ffmpeg/libavcodec/mpeg4video_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/mpeg4videodec.c15
-rw-r--r--lib/ffmpeg/libavcodec/mpeg4videoenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/mpegaudio.h6
-rw-r--r--lib/ffmpeg/libavcodec/mpegaudio_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/mpegaudiodec.c38
-rw-r--r--lib/ffmpeg/libavcodec/mpegaudiodec_float.c25
-rw-r--r--lib/ffmpeg/libavcodec/mpegaudiodecheader.c12
-rw-r--r--lib/ffmpeg/libavcodec/mpegaudioenc.c10
-rw-r--r--lib/ffmpeg/libavcodec/mpegvideo.c26
-rw-r--r--lib/ffmpeg/libavcodec/mpegvideo.h29
-rw-r--r--lib/ffmpeg/libavcodec/mpegvideo_common.h28
-rw-r--r--lib/ffmpeg/libavcodec/mpegvideo_enc.c48
-rw-r--r--lib/ffmpeg/libavcodec/mpegvideo_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/mpegvideo_xvmc.c2
-rw-r--r--lib/ffmpeg/libavcodec/msgsmdec.c (renamed from lib/ffmpeg/libavcodec/h264_parser.h)36
-rw-r--r--lib/ffmpeg/libavcodec/msgsmdec.h (renamed from lib/ffmpeg/libavcodec/iff.h)14
-rw-r--r--lib/ffmpeg/libavcodec/msmpeg4.c21
-rw-r--r--lib/ffmpeg/libavcodec/msrle.c2
-rw-r--r--lib/ffmpeg/libavcodec/msrledec.c61
-rw-r--r--lib/ffmpeg/libavcodec/msvideo1.c2
-rw-r--r--lib/ffmpeg/libavcodec/nellymoserdec.c23
-rw-r--r--lib/ffmpeg/libavcodec/nellymoserenc.c11
-rw-r--r--lib/ffmpeg/libavcodec/noise_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/nuv.c8
-rw-r--r--lib/ffmpeg/libavcodec/opt.c450
-rw-r--r--lib/ffmpeg/libavcodec/opt.h168
-rw-r--r--lib/ffmpeg/libavcodec/options.c43
-rw-r--r--lib/ffmpeg/libavcodec/pamenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/parser.c6
-rw-r--r--lib/ffmpeg/libavcodec/pcm-mpeg.c55
-rw-r--r--lib/ffmpeg/libavcodec/pcm.c135
-rw-r--r--lib/ffmpeg/libavcodec/pcx.c5
-rw-r--r--lib/ffmpeg/libavcodec/pcxenc.c4
-rw-r--r--lib/ffmpeg/libavcodec/pgssubdec.c59
-rw-r--r--lib/ffmpeg/libavcodec/pictordec.c7
-rw-r--r--lib/ffmpeg/libavcodec/png.c4
-rw-r--r--lib/ffmpeg/libavcodec/png.h6
-rw-r--r--lib/ffmpeg/libavcodec/pngdec.c11
-rw-r--r--lib/ffmpeg/libavcodec/pngenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/pnm.c9
-rw-r--r--lib/ffmpeg/libavcodec/pnm_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/pnmdec.c10
-rw-r--r--lib/ffmpeg/libavcodec/pnmenc.c8
-rw-r--r--lib/ffmpeg/libavcodec/ppc/Makefile4
-rw-r--r--lib/ffmpeg/libavcodec/ppc/check_altivec.c87
-rw-r--r--lib/ffmpeg/libavcodec/ppc/dsputil_altivec.c12
-rw-r--r--lib/ffmpeg/libavcodec/ppc/dsputil_altivec.h2
-rw-r--r--lib/ffmpeg/libavcodec/ppc/dsputil_ppc.c18
-rw-r--r--lib/ffmpeg/libavcodec/ppc/fft_altivec_s.S3
-rw-r--r--lib/ffmpeg/libavcodec/ppc/float_altivec.c136
-rw-r--r--lib/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c142
-rw-r--r--lib/ffmpeg/libavcodec/ppc/h264_altivec.c5
-rw-r--r--lib/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c3
-rw-r--r--lib/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c3
-rw-r--r--lib/ffmpeg/libavcodec/psymodel.c7
-rw-r--r--lib/ffmpeg/libavcodec/psymodel.h4
-rw-r--r--lib/ffmpeg/libavcodec/ptx.c5
-rw-r--r--lib/ffmpeg/libavcodec/qcelpdec.c4
-rw-r--r--lib/ffmpeg/libavcodec/qdm2.c30
-rw-r--r--lib/ffmpeg/libavcodec/qdrw.c2
-rw-r--r--lib/ffmpeg/libavcodec/qpeg.c2
-rw-r--r--lib/ffmpeg/libavcodec/qtrle.c2
-rw-r--r--lib/ffmpeg/libavcodec/qtrleenc.c5
-rw-r--r--lib/ffmpeg/libavcodec/r210dec.c30
-rw-r--r--lib/ffmpeg/libavcodec/ra144.c4
-rw-r--r--lib/ffmpeg/libavcodec/ra144.h6
-rw-r--r--lib/ffmpeg/libavcodec/ra144dec.c4
-rw-r--r--lib/ffmpeg/libavcodec/ra144enc.c22
-rw-r--r--lib/ffmpeg/libavcodec/ra288.c4
-rw-r--r--lib/ffmpeg/libavcodec/ratecontrol.c6
-rw-r--r--lib/ffmpeg/libavcodec/rawdec.c32
-rw-r--r--lib/ffmpeg/libavcodec/rawenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/rdft.c2
-rw-r--r--lib/ffmpeg/libavcodec/remove_extradata_bsf.c2
-rw-r--r--lib/ffmpeg/libavcodec/resample.c35
-rw-r--r--lib/ffmpeg/libavcodec/rl2.c11
-rw-r--r--lib/ffmpeg/libavcodec/roqaudioenc.c8
-rw-r--r--lib/ffmpeg/libavcodec/roqvideo.c5
-rw-r--r--lib/ffmpeg/libavcodec/roqvideodec.c2
-rw-r--r--lib/ffmpeg/libavcodec/roqvideoenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/rpza.c2
-rw-r--r--lib/ffmpeg/libavcodec/rv10.c17
-rw-r--r--lib/ffmpeg/libavcodec/rv10enc.c2
-rw-r--r--lib/ffmpeg/libavcodec/rv20enc.c4
-rw-r--r--lib/ffmpeg/libavcodec/rv30.c2
-rw-r--r--lib/ffmpeg/libavcodec/rv34.c6
-rw-r--r--lib/ffmpeg/libavcodec/rv40.c6
-rw-r--r--lib/ffmpeg/libavcodec/sgidec.c5
-rw-r--r--lib/ffmpeg/libavcodec/sgienc.c2
-rw-r--r--lib/ffmpeg/libavcodec/shorten.c6
-rw-r--r--lib/ffmpeg/libavcodec/sipr.c34
-rw-r--r--lib/ffmpeg/libavcodec/smacker.c6
-rw-r--r--lib/ffmpeg/libavcodec/smc.c2
-rw-r--r--lib/ffmpeg/libavcodec/snow.c6
-rw-r--r--lib/ffmpeg/libavcodec/sonic.c8
-rw-r--r--lib/ffmpeg/libavcodec/sp5xdec.c100
-rw-r--r--lib/ffmpeg/libavcodec/srtdec.c241
-rw-r--r--lib/ffmpeg/libavcodec/sunrast.c5
-rw-r--r--lib/ffmpeg/libavcodec/svq1dec.c2
-rw-r--r--lib/ffmpeg/libavcodec/svq1enc.c2
-rw-r--r--lib/ffmpeg/libavcodec/svq3.c55
-rw-r--r--lib/ffmpeg/libavcodec/synth_filter.c6
-rw-r--r--lib/ffmpeg/libavcodec/synth_filter.h2
-rw-r--r--lib/ffmpeg/libavcodec/targa.c14
-rw-r--r--lib/ffmpeg/libavcodec/targa.h (renamed from lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.h)28
-rw-r--r--lib/ffmpeg/libavcodec/targaenc.c27
-rw-r--r--lib/ffmpeg/libavcodec/tiertexseqv.c2
-rw-r--r--lib/ffmpeg/libavcodec/tiff.c24
-rw-r--r--lib/ffmpeg/libavcodec/tiffenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/tmv.c18
-rw-r--r--lib/ffmpeg/libavcodec/truemotion1.c63
-rw-r--r--lib/ffmpeg/libavcodec/truemotion2.c19
-rw-r--r--lib/ffmpeg/libavcodec/truespeech.c18
-rw-r--r--lib/ffmpeg/libavcodec/truespeech_data.h12
-rw-r--r--lib/ffmpeg/libavcodec/tscc.c2
-rw-r--r--lib/ffmpeg/libavcodec/tta.c14
-rw-r--r--lib/ffmpeg/libavcodec/twinvq.c9
-rw-r--r--lib/ffmpeg/libavcodec/txd.c5
-rw-r--r--lib/ffmpeg/libavcodec/ulti.c2
-rw-r--r--lib/ffmpeg/libavcodec/utils.c255
-rw-r--r--lib/ffmpeg/libavcodec/v210dec.c2
-rw-r--r--lib/ffmpeg/libavcodec/v210enc.c2
-rw-r--r--lib/ffmpeg/libavcodec/v210x.c2
-rw-r--r--lib/ffmpeg/libavcodec/vaapi.c2
-rw-r--r--lib/ffmpeg/libavcodec/vaapi_h264.c8
-rw-r--r--lib/ffmpeg/libavcodec/vaapi_mpeg2.c6
-rw-r--r--lib/ffmpeg/libavcodec/vaapi_mpeg4.c8
-rw-r--r--lib/ffmpeg/libavcodec/vaapi_vc1.c8
-rw-r--r--lib/ffmpeg/libavcodec/vb.c2
-rw-r--r--lib/ffmpeg/libavcodec/vc1.c29
-rw-r--r--lib/ffmpeg/libavcodec/vc1.h3
-rw-r--r--lib/ffmpeg/libavcodec/vc1_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/vc1dec.c31
-rw-r--r--lib/ffmpeg/libavcodec/vc1dsp.c4
-rw-r--r--lib/ffmpeg/libavcodec/vcr1.c4
-rw-r--r--lib/ffmpeg/libavcodec/vmdav.c6
-rw-r--r--lib/ffmpeg/libavcodec/vmnc.c2
-rw-r--r--lib/ffmpeg/libavcodec/vorbis_dec.c114
-rw-r--r--lib/ffmpeg/libavcodec/vorbis_enc.c31
-rw-r--r--lib/ffmpeg/libavcodec/vp3.c46
-rw-r--r--lib/ffmpeg/libavcodec/vp3_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/vp5.c12
-rw-r--r--lib/ffmpeg/libavcodec/vp56.c12
-rw-r--r--lib/ffmpeg/libavcodec/vp56.h147
-rw-r--r--lib/ffmpeg/libavcodec/vp56dsp.c5
-rw-r--r--lib/ffmpeg/libavcodec/vp56dsp.h8
-rw-r--r--lib/ffmpeg/libavcodec/vp56rac.c47
-rw-r--r--lib/ffmpeg/libavcodec/vp6.c28
-rw-r--r--lib/ffmpeg/libavcodec/vp6dsp.c2
-rw-r--r--lib/ffmpeg/libavcodec/vp8.c1214
-rw-r--r--lib/ffmpeg/libavcodec/vp8_parser.c2
-rw-r--r--lib/ffmpeg/libavcodec/vp8data.h66
-rw-r--r--lib/ffmpeg/libavcodec/vp8dsp.c181
-rw-r--r--lib/ffmpeg/libavcodec/vp8dsp.h27
-rw-r--r--lib/ffmpeg/libavcodec/vqavideo.c5
-rw-r--r--lib/ffmpeg/libavcodec/wavpack.c330
-rw-r--r--lib/ffmpeg/libavcodec/wma.c9
-rw-r--r--lib/ffmpeg/libavcodec/wma.h2
-rw-r--r--lib/ffmpeg/libavcodec/wmadec.c39
-rw-r--r--lib/ffmpeg/libavcodec/wmaenc.c12
-rw-r--r--lib/ffmpeg/libavcodec/wmaprodec.c157
-rw-r--r--lib/ffmpeg/libavcodec/wmavoice.c18
-rw-r--r--lib/ffmpeg/libavcodec/wmv2.c6
-rw-r--r--lib/ffmpeg/libavcodec/wmv2dec.c4
-rw-r--r--lib/ffmpeg/libavcodec/wmv2enc.c2
-rw-r--r--lib/ffmpeg/libavcodec/wnv1.c2
-rw-r--r--lib/ffmpeg/libavcodec/ws-snd1.c11
-rw-r--r--lib/ffmpeg/libavcodec/x86/Makefile32
-rw-r--r--lib/ffmpeg/libavcodec/x86/cavsdsp_mmx.c16
-rw-r--r--lib/ffmpeg/libavcodec/x86/cpuid.c135
-rw-r--r--lib/ffmpeg/libavcodec/x86/dct32_sse.c4
-rw-r--r--lib/ffmpeg/libavcodec/x86/deinterlace.asm83
-rw-r--r--lib/ffmpeg/libavcodec/x86/dnxhd_mmx.c12
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_h264_template_mmx.c304
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c208
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_mmx.c855
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_mmx.h65
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_mmx_avg_template.c2
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_mmx_qns_template.c4
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_mmx_rnd_template.c16
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputil_yasm.asm629
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputilenc_mmx.c340
-rw-r--r--lib/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm342
-rw-r--r--lib/ffmpeg/libavcodec/x86/fdct_mmx.c6
-rw-r--r--lib/ffmpeg/libavcodec/x86/fft.c13
-rw-r--r--lib/ffmpeg/libavcodec/x86/fft_3dn2.c4
-rw-r--r--lib/ffmpeg/libavcodec/x86/fft_mmx.asm242
-rw-r--r--lib/ffmpeg/libavcodec/x86/fft_sse.c111
-rw-r--r--lib/ffmpeg/libavcodec/x86/fmtconvert.asm91
-rw-r--r--lib/ffmpeg/libavcodec/x86/fmtconvert_mmx.c266
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_chromamc.asm669
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_deblock.asm (renamed from lib/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm)264
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_idct.asm1010
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_idct_sse2.asm54
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_intrapred.asm2211
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_intrapred_init.c233
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_qpel_mmx.c1201
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264_weight.asm375
-rw-r--r--lib/ffmpeg/libavcodec/x86/h264dsp_mmx.c2617
-rw-r--r--lib/ffmpeg/libavcodec/x86/idct_mmx.c445
-rw-r--r--lib/ffmpeg/libavcodec/x86/idct_sse2_xvid.c16
-rw-r--r--lib/ffmpeg/libavcodec/x86/lpc_mmx.c57
-rw-r--r--lib/ffmpeg/libavcodec/x86/mmx.h267
-rw-r--r--lib/ffmpeg/libavcodec/x86/motion_est_mmx.c49
-rw-r--r--lib/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c5
-rw-r--r--lib/ffmpeg/libavcodec/x86/mpegvideo_mmx.c27
-rw-r--r--lib/ffmpeg/libavcodec/x86/mpegvideo_mmx_template.c8
-rw-r--r--lib/ffmpeg/libavcodec/x86/rv40dsp_mmx.c61
-rw-r--r--lib/ffmpeg/libavcodec/x86/simple_idct_mmx.c18
-rw-r--r--lib/ffmpeg/libavcodec/x86/snowdsp_mmx.c11
-rw-r--r--lib/ffmpeg/libavcodec/x86/vc1dsp_mmx.c30
-rw-r--r--lib/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm6
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp3dsp.asm618
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.c436
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.c187
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp56_arith.h54
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp56dsp.asm173
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp56dsp_init.c48
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.c108
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.c98
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp8dsp-init.c118
-rw-r--r--lib/ffmpeg/libavcodec/x86/vp8dsp.asm1931
-rw-r--r--lib/ffmpeg/libavcodec/x86/x86inc.asm35
-rw-r--r--lib/ffmpeg/libavcodec/x86/x86util.asm20
-rw-r--r--lib/ffmpeg/libavcodec/xan.c187
-rw-r--r--lib/ffmpeg/libavcodec/xl.c2
-rw-r--r--lib/ffmpeg/libavcodec/xsubdec.c5
-rw-r--r--lib/ffmpeg/libavcodec/xsubenc.c2
-rw-r--r--lib/ffmpeg/libavcodec/yop.c5
-rw-r--r--lib/ffmpeg/libavcodec/zmbv.c2
-rw-r--r--lib/ffmpeg/libavcodec/zmbvenc.c2
513 files changed, 36851 insertions, 21637 deletions
diff --git a/lib/ffmpeg/libavcodec/4xm.c b/lib/ffmpeg/libavcodec/4xm.c
index b6a97aa187..97436ce187 100644
--- a/lib/ffmpeg/libavcodec/4xm.c
+++ b/lib/ffmpeg/libavcodec/4xm.c
@@ -260,6 +260,23 @@ static void init_mv(FourXContext *f){
}
}
+#if HAVE_BIGENDIAN
+#define LE_CENTRIC_MUL(dst, src, scale, dc) \
+ { \
+ unsigned tmpval = AV_RN32(src); \
+ tmpval = (tmpval << 16) | (tmpval >> 16); \
+ tmpval = tmpval * (scale) + (dc); \
+ tmpval = (tmpval << 16) | (tmpval >> 16); \
+ AV_WN32A(dst, tmpval); \
+ }
+#else
+#define LE_CENTRIC_MUL(dst, src, scale, dc) \
+ { \
+ unsigned tmpval = AV_RN32(src) * (scale) + (dc); \
+ AV_WN32A(dst, tmpval); \
+ }
+#endif
+
static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){
int i;
dc*= 0x10001;
@@ -274,25 +291,25 @@ static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stri
break;
case 1:
for(i=0; i<h; i++){
- ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
+ LE_CENTRIC_MUL(dst, src, scale, dc);
if(scale) src += stride;
dst += stride;
}
break;
case 2:
for(i=0; i<h; i++){
- ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
- ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc;
+ LE_CENTRIC_MUL(dst, src, scale, dc);
+ LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc);
if(scale) src += stride;
dst += stride;
}
break;
case 3:
for(i=0; i<h; i++){
- ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
- ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc;
- ((uint32_t*)dst)[2] = scale*((uint32_t*)src)[2] + dc;
- ((uint32_t*)dst)[3] = scale*((uint32_t*)src)[3] + dc;
+ LE_CENTRIC_MUL(dst, src, scale, dc);
+ LE_CENTRIC_MUL(dst + 2, src + 2, scale, dc);
+ LE_CENTRIC_MUL(dst + 4, src + 4, scale, dc);
+ LE_CENTRIC_MUL(dst + 6, src + 6, scale, dc);
if(scale) src += stride;
dst += stride;
}
@@ -774,6 +791,14 @@ static int decode_frame(AVCodecContext *avctx,
if(decode_i_frame(f, buf, frame_size) < 0)
return -1;
}else if(frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")){
+ if(!f->last_picture.data[0]){
+ f->last_picture.reference= 1;
+ if(avctx->get_buffer(avctx, &f->last_picture) < 0){
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return -1;
+ }
+ }
+
p->pict_type= FF_P_TYPE;
if(decode_p_frame(f, buf, frame_size) < 0)
return -1;
@@ -840,7 +865,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec fourxm_decoder = {
+AVCodec ff_fourxm_decoder = {
"4xm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_4XM,
diff --git a/lib/ffmpeg/libavcodec/8bps.c b/lib/ffmpeg/libavcodec/8bps.c
index 292c739c11..4757057876 100644
--- a/lib/ffmpeg/libavcodec/8bps.c
+++ b/lib/ffmpeg/libavcodec/8bps.c
@@ -219,7 +219,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
-AVCodec eightbps_decoder = {
+AVCodec ff_eightbps_decoder = {
"8bps",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_8BPS,
diff --git a/lib/ffmpeg/libavcodec/8svx.c b/lib/ffmpeg/libavcodec/8svx.c
index 6e09b11e03..3f7d3efc76 100644
--- a/lib/ffmpeg/libavcodec/8svx.c
+++ b/lib/ffmpeg/libavcodec/8svx.c
@@ -88,11 +88,11 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
default:
return -1;
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
-AVCodec eightsvx_fib_decoder = {
+AVCodec ff_eightsvx_fib_decoder = {
.name = "8svx_fib",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_8SVX_FIB,
@@ -102,7 +102,7 @@ AVCodec eightsvx_fib_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
};
-AVCodec eightsvx_exp_decoder = {
+AVCodec ff_eightsvx_exp_decoder = {
.name = "8svx_exp",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_8SVX_EXP,
diff --git a/lib/ffmpeg/libavcodec/Makefile b/lib/ffmpeg/libavcodec/Makefile
index dafd1f0831..6a0a05b870 100644
--- a/lib/ffmpeg/libavcodec/Makefile
+++ b/lib/ffmpeg/libavcodec/Makefile
@@ -1,7 +1,7 @@
include $(SUBDIR)../config.mak
NAME = avcodec
-FFLIBS = avutil
+FFLIBS = avcore avutil
HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
@@ -12,6 +12,7 @@ OBJS = allcodecs.o \
bitstream_filter.o \
dsputil.o \
faanidct.o \
+ fmtconvert.o \
imgconvert.o \
jrevdct.o \
opt.o \
@@ -32,7 +33,9 @@ OBJS-$(CONFIG_DXVA2) += dxva2.o
FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o
OBJS-$(CONFIG_FFT) += avfft.o fft.o $(FFT-OBJS-yes)
OBJS-$(CONFIG_GOLOMB) += golomb.o
-OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o h264pred.o
+OBJS-$(CONFIG_H264DSP) += h264dsp.o h264idct.o
+OBJS-$(CONFIG_H264PRED) += h264pred.o
+OBJS-$(CONFIG_HUFFMAN) += huffman.o
OBJS-$(CONFIG_LPC) += lpc.o
OBJS-$(CONFIG_LSP) += lsp.o
OBJS-$(CONFIG_MDCT) += mdct.o
@@ -42,6 +45,8 @@ OBJS-$(CONFIG_VAAPI) += vaapi.o
OBJS-$(CONFIG_VDPAU) += vdpau.o
# decoders/encoders/hardware accelerators
+OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
+OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \
aacadtsdec.o mpeg4audio.o
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
@@ -50,7 +55,8 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
mpeg4audio.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o
-OBJS-$(CONFIG_AC3_ENCODER) += ac3enc.o ac3tab.o ac3.o
+OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o
+OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3.o
OBJS-$(CONFIG_ALAC_DECODER) += alac.o
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o
OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
@@ -58,9 +64,16 @@ OBJS-$(CONFIG_AMRNB_DECODER) += amrnbdec.o celp_filters.o \
celp_math.o acelp_filters.o \
acelp_vectors.o \
acelp_pitch_delay.o
+OBJS-$(CONFIG_AMRWB_DECODER) += amrwbdec.o celp_filters.o \
+ celp_math.o acelp_filters.o \
+ acelp_vectors.o \
+ acelp_pitch_delay.o lsp.o
OBJS-$(CONFIG_AMV_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o
OBJS-$(CONFIG_ANM_DECODER) += anm.o
+OBJS-$(CONFIG_ANSI_DECODER) += ansi.o cga_data.o
OBJS-$(CONFIG_APE_DECODER) += apedec.o
+OBJS-$(CONFIG_ASS_DECODER) += assdec.o ass.o
+OBJS-$(CONFIG_ASS_ENCODER) += assenc.o ass.o
OBJS-$(CONFIG_ASV1_DECODER) += asv1.o mpeg12data.o
OBJS-$(CONFIG_ASV1_ENCODER) += asv1.o mpeg12data.o
OBJS-$(CONFIG_ASV2_DECODER) += asv1.o mpeg12data.o
@@ -127,12 +140,12 @@ OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o
OBJS-$(CONFIG_FLIC_DECODER) += flicvideo.o
OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o
-OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o huffman.o
+OBJS-$(CONFIG_FRAPS_DECODER) += fraps.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_GSM_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
+OBJS-$(CONFIG_GSM_MS_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261.o \
mpegvideo.o error_resilience.o
OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261.o \
@@ -155,7 +168,6 @@ OBJS-$(CONFIG_H264_DECODER) += h264.o \
h264_refs.o h264_cavlc.o h264_cabac.o\
mpegvideo.o error_resilience.o
OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
-OBJS-$(CONFIG_H264_ENCODER) += h264enc.o h264dspenc.o
OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o
@@ -173,6 +185,7 @@ OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o \
OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o
OBJS-$(CONFIG_KGV1_DECODER) += kgv1dec.o
OBJS-$(CONFIG_KMVC_DECODER) += kmvc.o
+OBJS-$(CONFIG_LAGARITH_DECODER) += lagarith.o lagarithrac.o
OBJS-$(CONFIG_LJPEG_ENCODER) += ljpegenc.o mjpegenc.o mjpeg.o \
mpegvideo_enc.o motion_est.o \
ratecontrol.o mpeg12data.o \
@@ -284,6 +297,7 @@ OBJS-$(CONFIG_QDRAW_DECODER) += qdrw.o
OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o
OBJS-$(CONFIG_QTRLE_DECODER) += qtrle.o
OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o
+OBJS-$(CONFIG_R10K_DECODER) += r210dec.o
OBJS-$(CONFIG_R210_DECODER) += r210dec.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
@@ -325,6 +339,7 @@ OBJS-$(CONFIG_SONIC_DECODER) += sonic.o
OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o
OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o
OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o h263.o \
mpegvideo.o error_resilience.o
@@ -375,11 +390,10 @@ 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 cabac.o
+ vp3dsp.o vp56rac.o
OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.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
+ vp3dsp.o vp6dsp.o vp56rac.o
+OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o
@@ -425,6 +439,7 @@ OBJS-$(CONFIG_PCM_F64BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_F64BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_F64LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_F64LE_ENCODER) += pcm.o
+OBJS-$(CONFIG_PCM_LXF_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_MULAW_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_DECODER) += pcm.o
@@ -471,6 +486,8 @@ OBJS-$(CONFIG_ADPCM_EA_R1_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_EA_R2_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_EA_R3_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER) += adpcm.o
+OBJS-$(CONFIG_ADPCM_G722_DECODER) += g722.o
+OBJS-$(CONFIG_ADPCM_G722_ENCODER) += g722.o
OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o
@@ -509,25 +526,28 @@ OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o
OBJS-$(CONFIG_IFF_DEMUXER) += iff.o
OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o \
flacdec.o flacdata.o flac.o
-OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o
+OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \
- flacdec.o flacdata.o flac.o
+ flacdec.o flacdata.o flac.o \
+ mpegaudiodata.o
OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
+OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MPEGTS_MUXER) += mpegvideo.o mpeg4audio.o
+OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_OGG_DEMUXER) += flacdec.o flacdata.o flac.o \
dirac.o mpeg12data.o
OBJS-$(CONFIG_OGG_MUXER) += xiph.o flacdec.o flacdata.o flac.o
-OBJS-$(CONFIG_RTP_MUXER) += mpegvideo.o
+OBJS-$(CONFIG_RTP_MUXER) += mpegvideo.o xiph.o
+OBJS-$(CONFIG_SPDIF_DEMUXER) += aacadtsdec.o mpeg4audio.o
OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \
- flacdec.o flacdata.o flac.o
+ flacdec.o flacdata.o flac.o \
+ mpegaudiodata.o
# external codec libraries
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
@@ -549,6 +569,7 @@ 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_LIBXAVS_ENCODER) += libxavs.o
OBJS-$(CONFIG_LIBXVID) += libxvidff.o libxvid_rc.o
# parsers
@@ -562,6 +583,7 @@ OBJS-$(CONFIG_DIRAC_PARSER) += dirac_parser.o
OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o
OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o
OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o
+OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \
@@ -570,7 +592,7 @@ 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_AAC_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 \
@@ -596,6 +618,7 @@ 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
OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o
+OBJS-$(CONFIG_MJPEG2JPEG_BSF) += mjpeg2jpeg_bsf.o mjpeg.o
OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o
OBJS-$(CONFIG_MOV2TEXTSUB_BSF) += movsub_bsf.o
OBJS-$(CONFIG_MP3_HEADER_COMPRESS_BSF) += mp3_header_compress_bsf.o
@@ -611,6 +634,12 @@ OBJS-$(HAVE_W32THREADS) += w32thread.o
OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \
+# inverse.o contains the ff_inverse table definition, which is used by
+# the FASTDIV macro (from libavutil); since referencing the external
+# table has a negative effect on performance, copy it in libavcodec as
+# well.
+OBJS-$(!CONFIG_SMALL) += inverse.o
+
-include $(SUBDIR)$(ARCH)/Makefile
SKIPHEADERS = %_tablegen.h
@@ -625,7 +654,6 @@ SKIPHEADERS += mpegaudio3.h
EXAMPLES = api
TESTPROGS = cabac dct eval fft h264 iirfilter rangecoder snow
-TESTPROGS-$(ARCH_X86) += x86/cpuid
TESTPROGS-$(HAVE_MMX) += motion
TESTOBJS = dctref.o
diff --git a/lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.h b/lib/ffmpeg/libavcodec/a64colors.h
index 743bc4361d..a9cdb6fa76 100644
--- a/lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.h
+++ b/lib/ffmpeg/libavcodec/a64colors.h
@@ -1,6 +1,6 @@
/*
- * vp6dsp MMX function declarations
- * Copyright (c) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
+ * a64 video encoder - c64 colors in rgb (Pepto)
+ * Copyright (c) 2009 Tobias Bindhammer
*
* This file is part of FFmpeg.
*
@@ -19,12 +19,34 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_X86_VP6DSP_MMX_H
-#define AVCODEC_X86_VP6DSP_MMX_H
+/**
+ * @file
+ * a64 video encoder - c64 colors in rgb
+ */
+
+#ifndef AVCODEC_A64COLORS_H
+#define AVCODEC_A64COLORS_H
#include <stdint.h>
-void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights);
+/* c64 palette in RGB */
+static const uint8_t a64_palette[16][3] = {
+ {0x00, 0x00, 0x00},
+ {0xff, 0xff, 0xff},
+ {0x68, 0x37, 0x2b},
+ {0x70, 0xa4, 0xb2},
+ {0x6f, 0x3d, 0x86},
+ {0x58, 0x8d, 0x43},
+ {0x35, 0x28, 0x79},
+ {0xb8, 0xc7, 0x6f},
+ {0x6f, 0x4f, 0x25},
+ {0x43, 0x39, 0x00},
+ {0x9a, 0x67, 0x59},
+ {0x44, 0x44, 0x44},
+ {0x6c, 0x6c, 0x6c},
+ {0x9a, 0xd2, 0x84},
+ {0x6c, 0x5e, 0xb5},
+ {0x95, 0x95, 0x95},
+};
-#endif /* AVCODEC_X86_VP6DSP_MMX_H */
+#endif /* AVCODEC_A64COLORS_H */
diff --git a/lib/ffmpeg/libavcodec/a64enc.h b/lib/ffmpeg/libavcodec/a64enc.h
new file mode 100644
index 0000000000..fb559ba82b
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/a64enc.h
@@ -0,0 +1,55 @@
+/*
+ * a64 video encoder - basic headers
+ * Copyright (c) 2009 Tobias Bindhammer
+ *
+ * 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
+ * a64 video encoder - basic headers
+ */
+
+#ifndef AVCODEC_A64ENC_H
+#define AVCODEC_A64ENC_H
+
+#include "libavutil/lfg.h"
+#include "avcodec.h"
+
+#define C64XRES 320
+#define C64YRES 200
+
+typedef struct A64Context {
+ /* general variables */
+ AVFrame picture;
+
+ /* variables for multicolor modes */
+ AVLFG randctx;
+ int mc_lifetime;
+ int mc_use_5col;
+ int mc_frame_counter;
+ int *mc_meta_charset;
+ int *mc_charmap;
+ int *mc_best_cb;
+ int mc_luma_vals[5];
+ uint8_t *mc_charset;
+ uint8_t *mc_colram;
+ uint8_t *mc_palette;
+ int mc_pal_size;
+} A64Context;
+
+#endif /* AVCODEC_A64ENC_H */
diff --git a/lib/ffmpeg/libavcodec/a64multienc.c b/lib/ffmpeg/libavcodec/a64multienc.c
new file mode 100644
index 0000000000..aed28ad280
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/a64multienc.c
@@ -0,0 +1,389 @@
+/*
+ * a64 video encoder - multicolor modes
+ * Copyright (c) 2009 Tobias Bindhammer
+ *
+ * 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
+ * a64 video encoder - multicolor modes
+ */
+
+#include "a64enc.h"
+#include "a64colors.h"
+#include "a64tables.h"
+#include "elbg.h"
+#include "libavutil/intreadwrite.h"
+
+#define DITHERSTEPS 8
+#define CHARSET_CHARS 256
+#define INTERLACED 1
+#define CROP_SCREENS 1
+
+/* gray gradient */
+static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
+
+/* other possible gradients - to be tested */
+//static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7};
+//static const int mc_colors[5]={0x0,0x9,0x8,0xa,0x3};
+
+static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
+{
+ int blockx, blocky, x, y;
+ int luma = 0;
+ int height = FFMIN(avctx->height, C64YRES);
+ int width = FFMIN(avctx->width , C64XRES);
+ uint8_t *src = p->data[0];
+
+ for (blocky = 0; blocky < C64YRES; blocky += 8) {
+ for (blockx = 0; blockx < C64XRES; blockx += 8) {
+ for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
+ for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {
+ if(x < width && y < height) {
+ /* build average over 2 pixels */
+ luma = (src[(x + 0 + y * p->linesize[0])] +
+ src[(x + 1 + y * p->linesize[0])]) / 2;
+ /* write blocks as linear data now so they are suitable for elbg */
+ dest[0] = luma;
+ }
+ dest++;
+ }
+ }
+ }
+ }
+}
+
+static void render_charset(AVCodecContext *avctx, uint8_t *charset,
+ uint8_t *colrammap)
+{
+ A64Context *c = avctx->priv_data;
+ uint8_t row1, row2;
+ int charpos, x, y;
+ int a, b;
+ uint8_t pix;
+ int lowdiff, highdiff;
+ int *best_cb = c->mc_best_cb;
+ static uint8_t index1[256];
+ static uint8_t index2[256];
+ static uint8_t dither[256];
+ int i;
+ int distance;
+
+ /* generate lookup-tables for dither and index before looping */
+ i = 0;
+ for (a=0; a < 256; a++) {
+ if(i < c->mc_pal_size -1 && a == c->mc_luma_vals[i + 1]) {
+ distance = c->mc_luma_vals[i + 1] - c->mc_luma_vals[i];
+ for(b = 0; b <= distance; b++) {
+ dither[c->mc_luma_vals[i] + b] = b * (DITHERSTEPS - 1) / distance;
+ }
+ i++;
+ }
+ if(i >= c->mc_pal_size - 1) dither[a] = 0;
+ index1[a] = i;
+ index2[a] = FFMIN(i + 1, c->mc_pal_size - 1);
+ }
+
+ /* and render charset */
+ for (charpos = 0; charpos < CHARSET_CHARS; charpos++) {
+ lowdiff = 0;
+ highdiff = 0;
+ for (y = 0; y < 8; y++) {
+ row1 = 0; row2 = 0;
+ for (x = 0; x < 4; x++) {
+ pix = best_cb[y * 4 + x];
+
+ /* accumulate error for brightest/darkest color */
+ if (index1[pix] >= 3)
+ highdiff += pix - c->mc_luma_vals[3];
+ if (index1[pix] < 1)
+ lowdiff += c->mc_luma_vals[1] - pix;
+
+ row1 <<= 2;
+
+ if (INTERLACED) {
+ row2 <<= 2;
+ if (interlaced_dither_patterns[dither[pix]][(y & 3) * 2 + 0][x & 3])
+ row1 |= 3-(index2[pix] & 3);
+ else
+ row1 |= 3-(index1[pix] & 3);
+
+ if (interlaced_dither_patterns[dither[pix]][(y & 3) * 2 + 1][x & 3])
+ row2 |= 3-(index2[pix] & 3);
+ else
+ row2 |= 3-(index1[pix] & 3);
+ }
+ else {
+ if (multi_dither_patterns[dither[pix]][(y & 3)][x & 3])
+ row1 |= 3-(index2[pix] & 3);
+ else
+ row1 |= 3-(index1[pix] & 3);
+ }
+ }
+ charset[y+0x000] = row1;
+ if (INTERLACED) charset[y+0x800] = row2;
+ }
+ /* do we need to adjust pixels? */
+ if (highdiff > 0 && lowdiff > 0 && c->mc_use_5col) {
+ if (lowdiff > highdiff) {
+ for (x = 0; x < 32; x++)
+ best_cb[x] = FFMIN(c->mc_luma_vals[3], best_cb[x]);
+ } else {
+ for (x = 0; x < 32; x++)
+ best_cb[x] = FFMAX(c->mc_luma_vals[1], best_cb[x]);
+ }
+ charpos--; /* redo now adjusted char */
+ /* no adjustment needed, all fine */
+ } else {
+ /* advance pointers */
+ best_cb += 32;
+ charset += 8;
+
+ /* remember colorram value */
+ colrammap[charpos] = (highdiff > 0);
+ }
+ }
+}
+
+static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
+{
+ A64Context *c = avctx->priv_data;
+ av_free(c->mc_meta_charset);
+ av_free(c->mc_best_cb);
+ av_free(c->mc_charset);
+ av_free(c->mc_charmap);
+ av_free(c->mc_colram);
+ return 0;
+}
+
+static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
+{
+ A64Context *c = avctx->priv_data;
+ int a;
+ av_lfg_init(&c->randctx, 1);
+
+ if (avctx->global_quality < 1) {
+ c->mc_lifetime = 4;
+ } else {
+ c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA;
+ }
+
+ av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime);
+
+ c->mc_frame_counter = 0;
+ c->mc_use_5col = avctx->codec->id == CODEC_ID_A64_MULTI5;
+ c->mc_pal_size = 4 + c->mc_use_5col;
+
+ /* precalc luma values for later use */
+ for (a = 0; a < c->mc_pal_size; a++) {
+ c->mc_luma_vals[a]=a64_palette[mc_colors[a]][0] * 0.30 +
+ a64_palette[mc_colors[a]][1] * 0.59 +
+ a64_palette[mc_colors[a]][2] * 0.11;
+ }
+
+ if (!(c->mc_meta_charset = av_malloc(32000 * c->mc_lifetime * sizeof(int))) ||
+ !(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) ||
+ !(c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int))) ||
+ !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
+ !(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
+ return AVERROR(ENOMEM);
+ }
+
+ /* set up extradata */
+ if (!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n");
+ return AVERROR(ENOMEM);
+ }
+ avctx->extradata_size = 8 * 4;
+ AV_WB32(avctx->extradata, c->mc_lifetime);
+ AV_WB32(avctx->extradata + 16, INTERLACED);
+
+ avcodec_get_frame_defaults(&c->picture);
+ avctx->coded_frame = &c->picture;
+ avctx->coded_frame->pict_type = FF_I_TYPE;
+ avctx->coded_frame->key_frame = 1;
+ if (!avctx->codec_tag)
+ avctx->codec_tag = AV_RL32("a64m");
+
+ return 0;
+}
+
+static void a64_compress_colram(unsigned char *buf, int *charmap, uint8_t *colram)
+{
+ int a;
+ uint8_t temp;
+ /* only needs to be done in 5col mode */
+ /* XXX could be squeezed to 0x80 bytes */
+ for (a = 0; a < 256; a++) {
+ temp = colram[charmap[a + 0x000]] << 0;
+ temp |= colram[charmap[a + 0x100]] << 1;
+ temp |= colram[charmap[a + 0x200]] << 2;
+ if (a < 0xe8) temp |= colram[charmap[a + 0x300]] << 3;
+ buf[a] = temp << 2;
+ }
+}
+
+static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf,
+ int buf_size, void *data)
+{
+ A64Context *c = avctx->priv_data;
+ AVFrame *pict = data;
+ AVFrame *const p = (AVFrame *) & c->picture;
+
+ int frame;
+ int x, y;
+ int b_height;
+ int b_width;
+
+ int req_size;
+ int num_frames = c->mc_lifetime;
+
+ int *charmap = c->mc_charmap;
+ uint8_t *colram = c->mc_colram;
+ uint8_t *charset = c->mc_charset;
+ int *meta = c->mc_meta_charset;
+ int *best_cb = c->mc_best_cb;
+
+ int charset_size = 0x800 * (INTERLACED + 1);
+ int colram_size = 0x100 * c->mc_use_5col;
+ int screen_size;
+
+ if(CROP_SCREENS) {
+ b_height = FFMIN(avctx->height,C64YRES) >> 3;
+ b_width = FFMIN(avctx->width ,C64XRES) >> 3;
+ screen_size = b_width * b_height;
+ } else {
+ b_height = C64YRES >> 3;
+ b_width = C64XRES >> 3;
+ screen_size = 0x400;
+ }
+
+ /* no data, means end encoding asap */
+ if (!data) {
+ /* all done, end encoding */
+ if (!c->mc_lifetime) return 0;
+ /* no more frames in queue, prepare to flush remaining frames */
+ if (!c->mc_frame_counter) {
+ num_frames = c->mc_lifetime;
+ c->mc_lifetime = 0;
+ }
+ /* still frames in queue so limit lifetime to remaining frames */
+ else c->mc_lifetime = c->mc_frame_counter;
+ /* still new data available */
+ } else {
+ /* fill up mc_meta_charset with data until lifetime exceeds */
+ if (c->mc_frame_counter < c->mc_lifetime) {
+ *p = *pict;
+ p->pict_type = FF_I_TYPE;
+ p->key_frame = 1;
+ to_meta_with_crop(avctx, p, meta + 32000 * c->mc_frame_counter);
+ c->mc_frame_counter++;
+ /* lifetime is not reached so wait for next frame first */
+ return 0;
+ }
+ }
+
+ /* lifetime reached so now convert X frames at once */
+ if (c->mc_frame_counter == c->mc_lifetime) {
+ req_size = 0;
+ /* any frames to encode? */
+ if (c->mc_lifetime) {
+ /* calc optimal new charset + charmaps */
+ ff_init_elbg(meta, 32, 1000 * c->mc_lifetime, best_cb, CHARSET_CHARS, 50, charmap, &c->randctx);
+ ff_do_elbg (meta, 32, 1000 * c->mc_lifetime, best_cb, CHARSET_CHARS, 50, charmap, &c->randctx);
+
+ /* create colorram map and a c64 readable charset */
+ render_charset(avctx, charset, colram);
+
+ /* copy charset to buf */
+ memcpy(buf,charset, charset_size);
+
+ /* advance pointers */
+ buf += charset_size;
+ charset += charset_size;
+ req_size += charset_size;
+ }
+ /* no charset so clean buf */
+ else memset(buf, 0, charset_size);
+
+ /* write x frames to buf */
+ for (frame = 0; frame < c->mc_lifetime; frame++) {
+ /* copy charmap to buf. buf is uchar*, charmap is int*, so no memcpy here, sorry */
+ for (y = 0; y < b_height; y++) {
+ for (x = 0; x < b_width; x++) {
+ buf[y * b_width + x] = charmap[y * b_width + x];
+ }
+ }
+ /* advance pointers */
+ buf += screen_size;
+ req_size += screen_size;
+
+ /* compress and copy colram to buf */
+ if (c->mc_use_5col) {
+ a64_compress_colram(buf, charmap, colram);
+ /* advance pointers */
+ buf += colram_size;
+ req_size += colram_size;
+ }
+
+ /* advance to next charmap */
+ charmap += 1000;
+ }
+
+ AV_WB32(avctx->extradata + 4, c->mc_frame_counter);
+ AV_WB32(avctx->extradata + 8, charset_size);
+ AV_WB32(avctx->extradata + 12, screen_size + colram_size);
+
+ /* reset counter */
+ c->mc_frame_counter = 0;
+
+ if (req_size > buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "buf size too small (need %d, got %d)\n", req_size, buf_size);
+ return -1;
+ }
+ return req_size;
+ }
+ return 0;
+}
+
+AVCodec ff_a64multi_encoder = {
+ .name = "a64multi",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_A64_MULTI,
+ .priv_data_size = sizeof(A64Context),
+ .init = a64multi_init_encoder,
+ .encode = a64multi_encode_frame,
+ .close = a64multi_close_encoder,
+ .pix_fmts = (const enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64"),
+ .capabilities = CODEC_CAP_DELAY,
+};
+
+AVCodec ff_a64multi5_encoder = {
+ .name = "a64multi5",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_A64_MULTI5,
+ .priv_data_size = sizeof(A64Context),
+ .init = a64multi_init_encoder,
+ .encode = a64multi_encode_frame,
+ .close = a64multi_close_encoder,
+ .pix_fmts = (const enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64, extended with 5th color (colram)"),
+ .capabilities = CODEC_CAP_DELAY,
+};
diff --git a/lib/ffmpeg/libavcodec/a64tables.h b/lib/ffmpeg/libavcodec/a64tables.h
new file mode 100644
index 0000000000..a955ef4caa
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/a64tables.h
@@ -0,0 +1,150 @@
+/*
+ * a64 video encoder - tables used by a64 encoders
+ * Copyright (c) 2009 Tobias Bindhammer
+ *
+ * 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
+ * a64 video encoder - tables used by a64 encoders
+ */
+
+#ifndef AVCODEC_A64TABLES_H
+#define AVCODEC_A64TABLES_H
+
+#include <stdint.h>
+
+/**
+ * dither patterns used vor rendering the multicolor charset
+ */
+
+static const uint8_t multi_dither_patterns[9][4][4] = {
+ {
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0}
+ },
+ {
+ {1, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 1, 0},
+ {0, 0, 0, 0}
+ },
+ {
+ {1, 0, 0, 0},
+ {0, 0, 1, 0},
+ {0, 1, 0, 0},
+ {0, 0, 0, 1}
+ },
+ {
+ {1, 0, 0, 0},
+ {0, 1, 0, 1},
+ {0, 0, 1, 0},
+ {0, 1, 0, 1}
+ },
+ {
+ {1, 0, 1, 0},
+ {0, 1, 0, 1},
+ {1, 0, 1, 0},
+ {0, 1, 0, 1}
+ },
+ {
+ {1, 1, 1, 0},
+ {0, 1, 0, 1},
+ {1, 0, 1, 1},
+ {0, 1, 0, 1}
+ },
+ {
+ {0, 1, 1, 1},
+ {1, 1, 0, 1},
+ {1, 0, 1, 1},
+ {1, 1, 1, 0}
+ },
+ {
+ {0, 1, 1, 1},
+ {1, 1, 1, 1},
+ {1, 1, 0, 1},
+ {1, 1, 1, 1}
+ },
+ {
+ {1, 1, 1, 1},
+ {1, 1, 1, 1},
+ {1, 1, 1, 1},
+ {1, 1, 1, 1}
+ },
+};
+
+static const uint8_t interlaced_dither_patterns[9][8][4] = {
+ {
+ {0, 0, 0, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 0, 0, 0},
+ },
+ {
+ {1, 0, 1, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 0, 0, 0},
+ {1, 0, 1, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 0, 0, 0},
+ },
+ {
+ {1, 0, 1, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 1, 0, 1},
+ {1, 0, 1, 0}, {0, 0, 0, 0},
+ {0, 0, 0, 0}, {0, 1, 0, 1},
+ },
+ {
+ {1, 0, 1, 0}, {0, 1, 0, 1},
+ {0, 1, 0, 1}, {0, 0, 0, 0},
+ {1, 0, 1, 0}, {0, 1, 0, 1},
+ {0, 1, 0, 1}, {0, 0, 0, 0},
+ },
+ {
+ {1, 0, 1, 0}, {0, 1, 0, 1},
+ {0, 1, 0, 1}, {1, 0, 1, 0},
+ {1, 0, 1, 0}, {0, 1, 0, 1},
+ {0, 1, 0, 1}, {1, 0, 1, 0},
+ },
+ {
+ {1, 0, 1, 0}, {0, 1, 0, 1},
+ {1, 1, 1, 1}, {1, 0, 1, 0},
+ {1, 0, 1, 0}, {0, 1, 0, 1},
+ {1, 1, 1, 1}, {1, 0, 1, 0},
+ },
+ {
+ {1, 0, 1, 0}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {0, 1, 0, 1},
+ {1, 0, 1, 0}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {0, 1, 0, 1},
+ },
+ {
+ {1, 1, 1, 1}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {0, 1, 0, 1},
+ {1, 1, 1, 1}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {0, 1, 0, 1},
+ },
+ {
+ {1, 1, 1, 1}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {1, 1, 1, 1},
+ {1, 1, 1, 1}, {1, 1, 1, 1},
+ }
+};
+
+#endif /* AVCODEC_A64TABLES_H */
diff --git a/lib/ffmpeg/libavcodec/aac.h b/lib/ffmpeg/libavcodec/aac.h
index 94f578ff38..cff476a6eb 100644
--- a/lib/ffmpeg/libavcodec/aac.h
+++ b/lib/ffmpeg/libavcodec/aac.h
@@ -35,6 +35,7 @@
#include "fft.h"
#include "mpeg4audio.h"
#include "sbr.h"
+#include "fmtconvert.h"
#include <stdint.h>
@@ -251,7 +252,6 @@ typedef struct {
*/
ChannelElement *che[4][MAX_ELEM_ID];
ChannelElement *tag_che_map[4][MAX_ELEM_ID];
- uint8_t tags_seen_this_frame[4][MAX_ELEM_ID];
int tags_mapped;
/** @} */
@@ -269,6 +269,7 @@ typedef struct {
FFTContext mdct;
FFTContext mdct_small;
DSPContext dsp;
+ FmtConvertContext fmt_conv;
int random_state;
/** @} */
@@ -277,7 +278,6 @@ typedef struct {
* @{
*/
float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output).
- float add_bias; ///< offset for dsp.float_to_int16
float sf_scale; ///< Pre-scale for correct IMDCT and dsp.float_to_int16.
int sf_offset; ///< offset into pow2sf_tab as appropriate for dsp.float_to_int16
/** @} */
diff --git a/lib/ffmpeg/libavcodec/aac_adtstoasc_bsf.c b/lib/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
index 9b615e65d3..6558c0280f 100644
--- a/lib/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
+++ b/lib/ffmpeg/libavcodec/aac_adtstoasc_bsf.c
@@ -107,7 +107,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
return 0;
}
-AVBitStreamFilter aac_adtstoasc_bsf = {
+AVBitStreamFilter ff_aac_adtstoasc_bsf = {
"aac_adtstoasc",
sizeof(AACBSFContext),
aac_adtstoasc_filter,
diff --git a/lib/ffmpeg/libavcodec/aac_parser.c b/lib/ffmpeg/libavcodec/aac_parser.c
index 3ad4610e95..9165178d15 100644
--- a/lib/ffmpeg/libavcodec/aac_parser.c
+++ b/lib/ffmpeg/libavcodec/aac_parser.c
@@ -60,7 +60,7 @@ static av_cold int aac_parse_init(AVCodecParserContext *s1)
}
-AVCodecParser aac_parser = {
+AVCodecParser ff_aac_parser = {
{ CODEC_ID_AAC },
sizeof(AACAC3ParseContext),
aac_parse_init,
diff --git a/lib/ffmpeg/libavcodec/aac_tablegen_decl.h b/lib/ffmpeg/libavcodec/aac_tablegen_decl.h
index 7157c80461..9a90a09b07 100644
--- a/lib/ffmpeg/libavcodec/aac_tablegen_decl.h
+++ b/lib/ffmpeg/libavcodec/aac_tablegen_decl.h
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AAC_TABLEGEN_INIT_H
-#define AAC_TABLEGEN_INIT_H
+#ifndef AAC_TABLEGEN_DECL_H
+#define AAC_TABLEGEN_DECL_H
#if CONFIG_HARDCODED_TABLES
#define ff_aac_tableinit()
@@ -31,4 +31,4 @@ void ff_aac_tableinit(void);
extern float ff_aac_pow2sf_tab[428];
#endif /* CONFIG_HARDCODED_TABLES */
-#endif /* AAC_TABLEGEN_INIT_H */
+#endif /* AAC_TABLEGEN_DECL_H */
diff --git a/lib/ffmpeg/libavcodec/aacadtsdec.h b/lib/ffmpeg/libavcodec/aacadtsdec.h
index bdc577179f..6e0a869cc5 100644
--- a/lib/ffmpeg/libavcodec/aacadtsdec.h
+++ b/lib/ffmpeg/libavcodec/aacadtsdec.h
@@ -43,8 +43,8 @@ typedef struct {
* Parse AAC frame header.
* Parse the ADTS frame header to the end of the variable header, which is
* the first 54 bits.
- * @param gbc BitContext containing the first 54 bits of the frame.
- * @param hdr Pointer to struct where header info is written.
+ * @param[in] gbc BitContext containing the first 54 bits of the frame.
+ * @param[out] 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.
diff --git a/lib/ffmpeg/libavcodec/aaccoder.c b/lib/ffmpeg/libavcodec/aaccoder.c
index 81ece4b23b..8063fb6cd4 100644
--- a/lib/ffmpeg/libavcodec/aaccoder.c
+++ b/lib/ffmpeg/libavcodec/aaccoder.c
@@ -99,25 +99,27 @@ static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16}
*
* @return quantization distortion
*/
-static float quantize_and_encode_band_cost(struct AACEncContext *s,
+static av_always_inline float quantize_and_encode_band_cost_template(
+ struct AACEncContext *s,
PutBitContext *pb, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
- int *bits)
+ int *bits, int BT_ZERO, int BT_UNSIGNED,
+ int BT_PAIR, int BT_ESC)
{
const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float CLIPPED_ESCAPE = 165140.0f*IQ;
int i, j, k;
float cost = 0;
- const int dim = cb < FIRST_PAIR_BT ? 4 : 2;
+ const int dim = BT_PAIR ? 2 : 4;
int resbits = 0;
const float Q34 = sqrtf(Q * sqrtf(Q));
const int range = aac_cb_range[cb];
const int maxval = aac_cb_maxval[cb];
int off;
- if (!cb) {
+ if (BT_ZERO) {
for (i = 0; i < size; i++)
cost += in[i]*in[i];
if (bits)
@@ -128,8 +130,8 @@ static float quantize_and_encode_band_cost(struct AACEncContext *s,
abs_pow34_v(s->scoefs, in, size);
scaled = s->scoefs;
}
- quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
- if (IS_CODEBOOK_UNSIGNED(cb)) {
+ quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED, maxval);
+ if (BT_UNSIGNED) {
off = 0;
} else {
off = maxval;
@@ -146,11 +148,11 @@ static float quantize_and_encode_band_cost(struct AACEncContext *s,
}
curbits = ff_aac_spectral_bits[cb-1][curidx];
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
- if (IS_CODEBOOK_UNSIGNED(cb)) {
+ if (BT_UNSIGNED) {
for (k = 0; k < dim; k++) {
float t = fabsf(in[i+k]);
float di;
- if (vec[k] == 64.0f) { //FIXME: slow
+ if (BT_ESC && vec[k] == 64.0f) { //FIXME: slow
if (t >= CLIPPED_ESCAPE) {
di = t - CLIPPED_ESCAPE;
curbits += 21;
@@ -177,29 +179,77 @@ static float quantize_and_encode_band_cost(struct AACEncContext *s,
if (cost >= uplim)
return uplim;
if (pb) {
- put_bits(pb, ff_aac_spectral_bits[cb-1][curidx], ff_aac_spectral_codes[cb-1][curidx]);
- if (IS_CODEBOOK_UNSIGNED(cb))
- for (j = 0; j < dim; j++)
- if (ff_aac_codebook_vectors[cb-1][curidx*dim+j] != 0.0f)
- put_bits(pb, 1, in[i+j] < 0.0f);
- if (cb == ESC_BT) {
- for (j = 0; j < 2; j++) {
- if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) {
- int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191);
- int len = av_log2(coef);
+ put_bits(pb, ff_aac_spectral_bits[cb-1][curidx], ff_aac_spectral_codes[cb-1][curidx]);
+ if (BT_UNSIGNED)
+ for (j = 0; j < dim; j++)
+ if (ff_aac_codebook_vectors[cb-1][curidx*dim+j] != 0.0f)
+ put_bits(pb, 1, in[i+j] < 0.0f);
+ if (BT_ESC) {
+ for (j = 0; j < 2; j++) {
+ if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) {
+ int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191);
+ int len = av_log2(coef);
- put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
- put_bits(pb, len, coef & ((1 << len) - 1));
+ put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
+ put_bits(pb, len, coef & ((1 << len) - 1));
+ }
}
}
}
- }
}
if (bits)
*bits = resbits;
return cost;
}
+
+#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC) \
+static float quantize_and_encode_band_cost_ ## NAME( \
+ struct AACEncContext *s, \
+ PutBitContext *pb, const float *in, \
+ const float *scaled, int size, int scale_idx, \
+ int cb, const float lambda, const float uplim, \
+ int *bits) { \
+ return quantize_and_encode_band_cost_template( \
+ s, pb, in, scaled, size, scale_idx, \
+ BT_ESC ? ESC_BT : cb, lambda, uplim, bits, \
+ BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC); \
+}
+
+QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ZERO, 1, 0, 0, 0)
+QUANTIZE_AND_ENCODE_BAND_COST_FUNC(SQUAD, 0, 0, 0, 0)
+QUANTIZE_AND_ENCODE_BAND_COST_FUNC(UQUAD, 0, 1, 0, 0)
+QUANTIZE_AND_ENCODE_BAND_COST_FUNC(SPAIR, 0, 0, 1, 0)
+QUANTIZE_AND_ENCODE_BAND_COST_FUNC(UPAIR, 0, 1, 1, 0)
+QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ESC, 0, 1, 1, 1)
+
+static float (*const quantize_and_encode_band_cost_arr[])(
+ struct AACEncContext *s,
+ PutBitContext *pb, const float *in,
+ const float *scaled, int size, int scale_idx,
+ int cb, const float lambda, const float uplim,
+ int *bits) = {
+ quantize_and_encode_band_cost_ZERO,
+ quantize_and_encode_band_cost_SQUAD,
+ quantize_and_encode_band_cost_SQUAD,
+ quantize_and_encode_band_cost_UQUAD,
+ quantize_and_encode_band_cost_UQUAD,
+ quantize_and_encode_band_cost_SPAIR,
+ quantize_and_encode_band_cost_SPAIR,
+ quantize_and_encode_band_cost_UPAIR,
+ quantize_and_encode_band_cost_UPAIR,
+ quantize_and_encode_band_cost_UPAIR,
+ quantize_and_encode_band_cost_UPAIR,
+ quantize_and_encode_band_cost_ESC,
+};
+
+#define quantize_and_encode_band_cost( \
+ s, pb, in, scaled, size, scale_idx, cb, \
+ lambda, uplim, bits) \
+ quantize_and_encode_band_cost_arr[cb]( \
+ s, pb, in, scaled, size, scale_idx, cb, \
+ lambda, uplim, bits)
+
static float quantize_band_cost(struct AACEncContext *s, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
@@ -438,7 +488,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
idx = cb;
ppos = max_sfb;
while (ppos > 0) {
- if (idx < 0) abort();
+ assert(idx >= 0);
cb = idx;
stackrun[stack_len] = path[ppos][cb].run;
stackcb [stack_len] = cb;
@@ -465,6 +515,16 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
}
}
+/** Return the minimum scalefactor where the quantized coef does not clip. */
+static av_always_inline uint8_t coef2minsf(float coef) {
+ return av_clip_uint8(log2f(coef)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
+}
+
+/** Return the maximum scalefactor where the quantized coef is not zero. */
+static av_always_inline uint8_t coef2maxsf(float coef) {
+ return av_clip_uint8(log2f(coef)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
+}
+
typedef struct TrellisPath {
float cost;
int prev;
@@ -504,15 +564,15 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
}
//minimum scalefactor index is when minimum nonzero coefficient after quantizing is not clipped
- q0 = av_clip_uint8(log2(q0f)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
+ q0 = coef2minsf(q0f);
//maximum scalefactor index is when maximum coefficient after quantizing is still not zero
- q1 = av_clip_uint8(log2(q1f)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
+ q1 = coef2maxsf(q1f);
//av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);
if (q1 - q0 > 60) {
int q0low = q0;
int q1high = q1;
//minimum scalefactor index is when maximum nonzero coefficient after quantizing is not clipped
- int qnrg = av_clip_uint8(log2(sqrt(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
+ int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
q1 = qnrg + 30;
q0 = qnrg - 30;
//av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);
@@ -568,9 +628,9 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s,
float minrd = INFINITY;
float maxval;
//minimum scalefactor index is when minimum nonzero coefficient after quantizing is not clipped
- minscale = av_clip_uint8(log2(qmin)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
+ minscale = coef2minsf(qmin);
//maximum scalefactor index is when maximum coefficient after quantizing is still not zero
- maxscale = av_clip_uint8(log2(qmax)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
+ maxscale = coef2maxsf(qmax);
minscale = av_clip(minscale - q0, 0, TRELLIS_STATES - 1);
maxscale = av_clip(maxscale - q0, 0, TRELLIS_STATES);
maxval = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], s->scoefs+start);
@@ -637,6 +697,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
int start = 0, i, w, w2, g;
int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels;
float dists[128], uplims[128];
+ float maxvals[128];
int fflag, minscaler;
int its = 0;
int allz = 0;
@@ -671,13 +732,23 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
sce->sf_idx[w*16+g] = SCALE_ONE_POS;
continue;
}
- sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMIN(log2(uplims[w*16+g]/minthr)*4,59);
+ sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMIN(log2f(uplims[w*16+g]/minthr)*4,59);
}
}
if (!allz)
return;
abs_pow34_v(s->scoefs, sce->coeffs, 1024);
+
+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
+ start = w*128;
+ for (g = 0; g < sce->ics.num_swb; g++) {
+ const float *scaled = s->scoefs + start;
+ maxvals[w*16+g] = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled);
+ start += sce->ics.swb_sizes[g];
+ }
+ }
+
//perform two-loop search
//outer loop - improve quality
do {
@@ -703,7 +774,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
continue;
}
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]);
+ cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
int b;
dist += quantize_band_cost(s, coefs + w2*128,
@@ -735,27 +806,26 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
sce->sf_idx[i] -= qstep;
}
qstep >>= 1;
- if (!qstep && tbits > destbits*1.02)
+ if (!qstep && tbits > destbits*1.02 && sce->sf_idx[0] < 217)
qstep = 1;
- if (sce->sf_idx[0] >= 217)
- break;
} while (qstep);
fflag = 0;
minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF);
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
- 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)
+ if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) {
+ if (find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]-1))
sce->sf_idx[w*16+g]--;
+ else //Try to make sure there is some energy in every band
+ sce->sf_idx[w*16+g]-=2;
+ }
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];
+ sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]);
}
}
its++;
@@ -865,7 +935,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s,
continue;
}
sce->zeroes[w*16+g] = 0;
- scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2(1/maxq[w*16+g])*16/3, 60, 218);
+ scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2f(1/maxq[w*16+g])*16/3, 60, 218);
step = 16;
for (;;) {
float dist = 0.0f;
@@ -894,7 +964,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s,
if (curdiff <= 1.0f)
step = 0;
else
- step = log2(curdiff);
+ step = log2f(curdiff);
if (dist > uplim[w*16+g])
step = -step;
scf += step;
@@ -947,7 +1017,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
sce->sf_idx[(w+w2)*16+g] = 218;
sce->zeroes[(w+w2)*16+g] = 1;
} else {
- sce->sf_idx[(w+w2)*16+g] = av_clip(SCALE_ONE_POS - SCALE_DIV_512 + log2(band->threshold), 80, 218);
+ sce->sf_idx[(w+w2)*16+g] = av_clip(SCALE_ONE_POS - SCALE_DIV_512 + log2f(band->threshold), 80, 218);
sce->zeroes[(w+w2)*16+g] = 0;
}
minq = FFMIN(minq, sce->sf_idx[(w+w2)*16+g]);
diff --git a/lib/ffmpeg/libavcodec/aacdec.c b/lib/ffmpeg/libavcodec/aacdec.c
index a302876176..411c1dfc1b 100644
--- a/lib/ffmpeg/libavcodec/aacdec.c
+++ b/lib/ffmpeg/libavcodec/aacdec.c
@@ -3,6 +3,10 @@
* Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
* Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
*
+ * AAC LATM decoder
+ * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz>
+ * Copyright (c) 2010 Janne Grunau <janne-ffmpeg@jannau.net>
+ *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
@@ -81,6 +85,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
#include "lpc.h"
#include "aac.h"
@@ -113,28 +118,11 @@ static const char overread_err[] = "Input buffer exhausted before END element fo
static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
{
- /* Some buggy encoders appear to set all elem_ids to zero and rely on
- channels always occurring in the same order. This is expressly forbidden
- by the spec but we will try to work around it.
- */
- int err_printed = 0;
- while (ac->tags_seen_this_frame[type][elem_id] && elem_id < MAX_ELEM_ID) {
- if (ac->output_configured < OC_LOCKED && !err_printed) {
- av_log(ac->avctx, AV_LOG_WARNING, "Duplicate channel tag found, attempting to remap.\n");
- err_printed = 1;
- }
- elem_id++;
- }
- if (elem_id == MAX_ELEM_ID)
- return NULL;
- ac->tags_seen_this_frame[type][elem_id] = 1;
-
- if (ac->tag_che_map[type][elem_id]) {
+ // For PCE based channel configurations map the channels solely based on tags.
+ if (!ac->m4ac.chan_config) {
return ac->tag_che_map[type][elem_id];
}
- if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) {
- return NULL;
- }
+ // For indexed channel configurations map the channels solely based on position.
switch (ac->m4ac.chan_config) {
case 7:
if (ac->tags_mapped == 3 && type == TYPE_CPE) {
@@ -242,7 +230,6 @@ static av_cold int output_configure(AACContext *ac,
}
memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
- ac->tags_mapped = 0;
avctx->channel_layout = aac_channel_layout[channel_config - 1];
} else {
@@ -263,7 +250,6 @@ static av_cold int output_configure(AACContext *ac,
}
memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
- ac->tags_mapped = 4 * MAX_ELEM_ID;
avctx->channel_layout = 0;
}
@@ -300,7 +286,8 @@ static void decode_channel_map(enum ChannelPosition *cpe_map,
*
* @return Returns error status. 0 - OK, !0 - error
*/
-static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
+static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
+ enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
GetBitContext *gb)
{
int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
@@ -309,8 +296,8 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL
skip_bits(gb, 2); // object_type
sampling_index = get_bits(gb, 4);
- if (ac->m4ac.sampling_index != sampling_index)
- av_log(ac->avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
+ if (m4ac->sampling_index != sampling_index)
+ av_log(avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
num_front = get_bits(gb, 4);
num_side = get_bits(gb, 4);
@@ -341,7 +328,7 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL
/* comment field, first byte is length */
comment_len = get_bits(gb, 8) * 8;
if (get_bits_left(gb) < comment_len) {
- av_log(ac->avctx, AV_LOG_ERROR, overread_err);
+ av_log(avctx, AV_LOG_ERROR, overread_err);
return -1;
}
skip_bits_long(gb, comment_len);
@@ -356,12 +343,12 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL
*
* @return Returns error status. 0 - OK, !0 - error
*/
-static av_cold int set_default_channel_config(AACContext *ac,
+static av_cold int set_default_channel_config(AVCodecContext *avctx,
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
int channel_config)
{
if (channel_config < 1 || channel_config > 7) {
- av_log(ac->avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
+ av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
channel_config);
return -1;
}
@@ -397,16 +384,21 @@ static av_cold int set_default_channel_config(AACContext *ac,
/**
* Decode GA "General Audio" specific configuration; reference: table 4.1.
*
+ * @param ac pointer to AACContext, may be null
+ * @param avctx pointer to AVCCodecContext, used for logging
+ *
* @return Returns error status. 0 - OK, !0 - error
*/
-static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb,
+static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
+ GetBitContext *gb,
+ MPEG4AudioConfig *m4ac,
int channel_config)
{
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
int extension_flag, ret;
if (get_bits1(gb)) { // frameLengthFlag
- av_log_missing_feature(ac->avctx, "960/120 MDCT window is", 1);
+ av_log_missing_feature(avctx, "960/120 MDCT window is", 1);
return -1;
}
@@ -414,24 +406,24 @@ static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb,
skip_bits(gb, 14); // coreCoderDelay
extension_flag = get_bits1(gb);
- if (ac->m4ac.object_type == AOT_AAC_SCALABLE ||
- ac->m4ac.object_type == AOT_ER_AAC_SCALABLE)
+ if (m4ac->object_type == AOT_AAC_SCALABLE ||
+ m4ac->object_type == AOT_ER_AAC_SCALABLE)
skip_bits(gb, 3); // layerNr
memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
if (channel_config == 0) {
skip_bits(gb, 4); // element_instance_tag
- if ((ret = decode_pce(ac, new_che_pos, gb)))
+ if ((ret = decode_pce(avctx, m4ac, new_che_pos, gb)))
return ret;
} else {
- if ((ret = set_default_channel_config(ac, new_che_pos, channel_config)))
+ if ((ret = set_default_channel_config(avctx, new_che_pos, channel_config)))
return ret;
}
- if ((ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR)))
+ if (ac && (ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR)))
return ret;
if (extension_flag) {
- switch (ac->m4ac.object_type) {
+ switch (m4ac->object_type) {
case AOT_ER_BSAC:
skip_bits(gb, 5); // numOfSubFrame
skip_bits(gb, 11); // layer_length
@@ -454,42 +446,48 @@ static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb,
/**
* Decode audio specific configuration; reference: table 1.13.
*
+ * @param ac pointer to AACContext, may be null
+ * @param avctx pointer to AVCCodecContext, used for logging
+ * @param m4ac pointer to MPEG4AudioConfig, used for parsing
* @param data pointer to AVCodecContext extradata
* @param data_size size of AVCCodecContext extradata
*
- * @return Returns error status. 0 - OK, !0 - error
+ * @return Returns error status or number of consumed bits. <0 - error
*/
-static int decode_audio_specific_config(AACContext *ac, void *data,
- int data_size)
+static int decode_audio_specific_config(AACContext *ac,
+ AVCodecContext *avctx,
+ MPEG4AudioConfig *m4ac,
+ const uint8_t *data, int data_size)
{
GetBitContext gb;
int i;
init_get_bits(&gb, data, data_size * 8);
- if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0)
+ if ((i = ff_mpeg4audio_get_config(m4ac, data, data_size)) < 0)
return -1;
- if (ac->m4ac.sampling_index > 12) {
- av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
+ if (m4ac->sampling_index > 12) {
+ av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
return -1;
}
- if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1)
- ac->m4ac.ps = 1;
+ if (m4ac->sbr == 1 && m4ac->ps == -1)
+ m4ac->ps = 1;
skip_bits_long(&gb, i);
- switch (ac->m4ac.object_type) {
+ switch (m4ac->object_type) {
case AOT_AAC_MAIN:
case AOT_AAC_LC:
- if (decode_ga_specific_config(ac, &gb, ac->m4ac.chan_config))
+ if (decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config))
return -1;
break;
default:
- av_log(ac->avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
- ac->m4ac.sbr == 1? "SBR+" : "", ac->m4ac.object_type);
+ av_log(avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
+ m4ac->sbr == 1? "SBR+" : "", m4ac->object_type);
return -1;
}
- return 0;
+
+ return get_bits_count(&gb);
}
/**
@@ -542,11 +540,13 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
ac->m4ac.sample_rate = avctx->sample_rate;
if (avctx->extradata_size > 0) {
- if (decode_audio_specific_config(ac, avctx->extradata, avctx->extradata_size))
+ if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
+ avctx->extradata,
+ avctx->extradata_size) < 0)
return -1;
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
AAC_INIT_VLC_STATIC( 0, 304);
AAC_INIT_VLC_STATIC( 1, 270);
@@ -563,22 +563,15 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
ff_aac_sbr_init();
dsputil_init(&ac->dsp, avctx);
+ ff_fmt_convert_init(&ac->fmt_conv, avctx);
ac->random_state = 0x1f2e3d4c;
// -1024 - Compensate wrong IMDCT method.
- // 32768 - Required to scale values to the correct range for the bias method
- // for float to int16 conversion.
-
- if (ac->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- ac->add_bias = 385.0f;
- ac->sf_scale = 1. / (-1024. * 32768.);
- ac->sf_offset = 0;
- } else {
- ac->add_bias = 0.0f;
- ac->sf_scale = 1. / -1024.;
- ac->sf_offset = 60;
- }
+ // 60 - Required to scale values to the correct range [-32768,32767]
+ // for float to int16 conversion. (1 << (60 / 4)) == 32768
+ ac->sf_scale = 1. / -1024.;
+ ac->sf_offset = 60;
ff_aac_tableinit();
@@ -1063,9 +1056,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 MIN_CACHE_BITS < 20
- UPDATE_CACHE(re, gb);
-#endif
cb_idx = cb_vector_idx[code];
nnz = cb_idx >> 8 & 15;
bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
@@ -1158,12 +1148,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
return -1;
}
-#if MIN_CACHE_BITS < 21
- LAST_SKIP_BITS(re, gb, b + 1);
- UPDATE_CACHE(re, gb);
-#else
SKIP_BITS(re, gb, b + 1);
-#endif
b += 4;
n = (1 << b) + SHOW_UBITS(re, gb, b);
LAST_SKIP_BITS(re, gb, b);
@@ -1231,7 +1216,8 @@ static av_always_inline float flt16_trunc(float pf)
return pun.f;
}
-static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *coef,
+static av_always_inline void predict(PredictorState *ps, float *coef,
+ float sf_scale, float inv_sf_scale,
int output_enable)
{
const float a = 0.953125; // 61.0 / 64
@@ -1239,23 +1225,26 @@ static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *
float e0, e1;
float pv;
float k1, k2;
+ float r0 = ps->r0, r1 = ps->r1;
+ float cor0 = ps->cor0, cor1 = ps->cor1;
+ float var0 = ps->var0, var1 = ps->var1;
- k1 = ps->var0 > 1 ? ps->cor0 * flt16_even(a / ps->var0) : 0;
- k2 = ps->var1 > 1 ? ps->cor1 * flt16_even(a / ps->var1) : 0;
+ k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0;
+ k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0;
- pv = flt16_round(k1 * ps->r0 + k2 * ps->r1);
+ pv = flt16_round(k1 * r0 + k2 * r1);
if (output_enable)
- *coef += pv * ac->sf_scale;
+ *coef += pv * sf_scale;
- e0 = *coef / ac->sf_scale;
- e1 = e0 - k1 * ps->r0;
+ e0 = *coef * inv_sf_scale;
+ e1 = e0 - k1 * r0;
- ps->cor1 = flt16_trunc(alpha * ps->cor1 + ps->r1 * 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.5f * (ps->r0 * ps->r0 + e0 * e0));
+ ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1);
+ ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1));
+ ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0);
+ ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0));
- ps->r1 = flt16_trunc(a * (ps->r0 - k1 * e0));
+ ps->r1 = flt16_trunc(a * (r0 - k1 * e0));
ps->r0 = flt16_trunc(a * e0);
}
@@ -1265,6 +1254,7 @@ static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *
static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
{
int sfb, k;
+ float sf_scale = ac->sf_scale, inv_sf_scale = 1 / ac->sf_scale;
if (!sce->ics.predictor_initialized) {
reset_all_predictors(sce->predictor_state);
@@ -1274,7 +1264,8 @@ static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) {
for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
- predict(ac, &sce->predictor_state[k], &sce->coeffs[k],
+ predict(&sce->predictor_state[k], &sce->coeffs[k],
+ sf_scale, inv_sf_scale,
sce->ics.predictor_present && sce->ics.prediction_used[sfb]);
}
}
@@ -1704,7 +1695,7 @@ static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
/**
* Conduct IMDCT and windowing.
*/
-static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias)
+static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
{
IndividualChannelStream *ics = &sce->ics;
float *in = sce->coeffs;
@@ -1732,32 +1723,29 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float
*/
if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
(ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
- ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, bias, 512);
+ ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512);
} else {
- for (i = 0; i < 448; i++)
- out[i] = saved[i] + bias;
+ memcpy( out, saved, 448 * sizeof(float));
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, bias, 64);
- ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, bias, 64);
- ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, bias, 64);
- ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, bias, 64);
- ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, bias, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64);
+ ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64);
+ ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64);
memcpy( out + 448 + 4*128, temp, 64 * sizeof(float));
} else {
- ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, bias, 64);
- for (i = 576; i < 1024; i++)
- out[i] = buf[i-512] + bias;
+ ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64);
+ memcpy( out + 576, buf + 64, 448 * sizeof(float));
}
}
// buffer update
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- for (i = 0; i < 64; i++)
- saved[i] = temp[64 + i] - bias;
- ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
- ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
+ memcpy( saved, temp + 64, 64 * sizeof(float));
+ ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64);
+ ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64);
+ ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64);
memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
} else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
memcpy( saved, buf + 512, 448 * sizeof(float));
@@ -1814,13 +1802,12 @@ static void apply_independent_coupling(AACContext *ac,
{
int i;
const float gain = cce->coup.gain[index][0];
- const float bias = ac->add_bias;
const float *src = cce->ch[0].ret;
float *dest = target->ret;
const int len = 1024 << (ac->m4ac.sbr == 1);
for (i = 0; i < len; i++)
- dest[i] += gain * (src[i] - bias);
+ dest[i] += gain * src[i];
}
/**
@@ -1864,7 +1851,6 @@ static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,
static void spectral_to_sample(AACContext *ac)
{
int i, type;
- float imdct_bias = (ac->m4ac.sbr <= 0) ? ac->add_bias : 0.0f;
for (type = 3; type >= 0; type--) {
for (i = 0; i < MAX_ELEM_ID; i++) {
ChannelElement *che = ac->che[type][i];
@@ -1878,9 +1864,9 @@ static void spectral_to_sample(AACContext *ac)
if (type <= TYPE_CPE)
apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) {
- imdct_and_windowing(ac, &che->ch[0], imdct_bias);
+ imdct_and_windowing(ac, &che->ch[0]);
if (type == TYPE_CPE) {
- imdct_and_windowing(ac, &che->ch[1], imdct_bias);
+ imdct_and_windowing(ac, &che->ch[1]);
}
if (ac->m4ac.sbr > 0) {
ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
@@ -1904,7 +1890,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
ac->m4ac.chan_config = hdr_info.chan_config;
- if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config))
+ if (set_default_channel_config(ac->avctx, new_che_pos, hdr_info.chan_config))
return -7;
if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME))
return -7;
@@ -1931,24 +1917,17 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
return size;
}
-static int aac_decode_frame(AVCodecContext *avctx, void *data,
- int *data_size, AVPacket *avpkt)
+static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
+ int *data_size, GetBitContext *gb)
{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
AACContext *ac = avctx->priv_data;
ChannelElement *che = NULL, *che_prev = NULL;
- GetBitContext gb;
enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
int err, elem_id, data_size_tmp;
- int buf_consumed;
int samples = 0, multiplier;
- int buf_offset;
-
- init_get_bits(&gb, buf, buf_size * 8);
- if (show_bits(&gb, 12) == 0xfff) {
- if (parse_adts_frame_header(ac, &gb) < 0) {
+ if (show_bits(gb, 12) == 0xfff) {
+ if (parse_adts_frame_header(ac, gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
return -1;
}
@@ -1958,10 +1937,10 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
}
}
- memset(ac->tags_seen_this_frame, 0, sizeof(ac->tags_seen_this_frame));
+ ac->tags_mapped = 0;
// parse
- while ((elem_type = get_bits(&gb, 3)) != TYPE_END) {
- elem_id = get_bits(&gb, 4);
+ while ((elem_type = get_bits(gb, 3)) != TYPE_END) {
+ elem_id = get_bits(gb, 4);
if (elem_type < TYPE_DSE) {
if (!(che=get_che(ac, elem_type, elem_id))) {
@@ -1975,29 +1954,29 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
switch (elem_type) {
case TYPE_SCE:
- err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
+ err = decode_ics(ac, &che->ch[0], gb, 0, 0);
break;
case TYPE_CPE:
- err = decode_cpe(ac, &gb, che);
+ err = decode_cpe(ac, gb, che);
break;
case TYPE_CCE:
- err = decode_cce(ac, &gb, che);
+ err = decode_cce(ac, gb, che);
break;
case TYPE_LFE:
- err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
+ err = decode_ics(ac, &che->ch[0], gb, 0, 0);
break;
case TYPE_DSE:
- err = skip_data_stream_element(ac, &gb);
+ err = skip_data_stream_element(ac, gb);
break;
case TYPE_PCE: {
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
- if ((err = decode_pce(ac, new_che_pos, &gb)))
+ if ((err = decode_pce(avctx, &ac->m4ac, new_che_pos, gb)))
break;
if (ac->output_configured > OC_TRIAL_PCE)
av_log(avctx, AV_LOG_ERROR,
@@ -2009,13 +1988,13 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
case TYPE_FIL:
if (elem_id == 15)
- elem_id += get_bits(&gb, 8) - 1;
- if (get_bits_left(&gb) < 8 * elem_id) {
+ elem_id += get_bits(gb, 8) - 1;
+ if (get_bits_left(gb) < 8 * elem_id) {
av_log(avctx, AV_LOG_ERROR, overread_err);
return -1;
}
while (elem_id > 0)
- elem_id -= decode_extension_payload(ac, &gb, elem_id, che_prev, elem_type_prev);
+ elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev);
err = 0; /* FIXME */
break;
@@ -2030,7 +2009,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
if (err)
return err;
- if (get_bits_left(&gb) < 3) {
+ if (get_bits_left(gb) < 3) {
av_log(avctx, AV_LOG_ERROR, overread_err);
return -1;
}
@@ -2055,11 +2034,29 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
*data_size = data_size_tmp;
if (samples)
- ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels);
+ ac->fmt_conv.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels);
if (ac->output_configured)
ac->output_configured = OC_LOCKED;
+ return 0;
+}
+
+static int aac_decode_frame(AVCodecContext *avctx, void *data,
+ int *data_size, AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ GetBitContext gb;
+ int buf_consumed;
+ int buf_offset;
+ int err;
+
+ init_get_bits(&gb, buf, buf_size * 8);
+
+ if ((err = aac_decode_frame_int(avctx, data, data_size, &gb)) < 0)
+ return err;
+
buf_consumed = (get_bits_count(&gb) + 7) >> 3;
for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
if (buf[buf_offset])
@@ -2086,7 +2083,264 @@ static av_cold int aac_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec aac_decoder = {
+
+#define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
+
+struct LATMContext {
+ AACContext aac_ctx; ///< containing AACContext
+ int initialized; ///< initilized after a valid extradata was seen
+
+ // parser data
+ int audio_mux_version_A; ///< LATM syntax version
+ int frame_length_type; ///< 0/1 variable/fixed frame length
+ int frame_length; ///< frame length for fixed frame length
+};
+
+static inline uint32_t latm_get_value(GetBitContext *b)
+{
+ int length = get_bits(b, 2);
+
+ return get_bits_long(b, (length+1)*8);
+}
+
+static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
+ GetBitContext *gb)
+{
+ AVCodecContext *avctx = latmctx->aac_ctx.avctx;
+ MPEG4AudioConfig m4ac;
+ int config_start_bit = get_bits_count(gb);
+ int bits_consumed, esize;
+
+ if (config_start_bit % 8) {
+ av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "
+ "config not byte aligned.\n", 1);
+ return AVERROR_INVALIDDATA;
+ } else {
+ bits_consumed =
+ decode_audio_specific_config(NULL, avctx, &m4ac,
+ gb->buffer + (config_start_bit / 8),
+ get_bits_left(gb) / 8);
+
+ if (bits_consumed < 0)
+ return AVERROR_INVALIDDATA;
+
+ esize = (bits_consumed+7) / 8;
+
+ if (avctx->extradata_size <= esize) {
+ av_free(avctx->extradata);
+ avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata)
+ return AVERROR(ENOMEM);
+ }
+
+ avctx->extradata_size = esize;
+ memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
+ memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
+ skip_bits_long(gb, bits_consumed);
+ }
+
+ return bits_consumed;
+}
+
+static int read_stream_mux_config(struct LATMContext *latmctx,
+ GetBitContext *gb)
+{
+ int ret, audio_mux_version = get_bits(gb, 1);
+
+ latmctx->audio_mux_version_A = 0;
+ if (audio_mux_version)
+ latmctx->audio_mux_version_A = get_bits(gb, 1);
+
+ if (!latmctx->audio_mux_version_A) {
+
+ if (audio_mux_version)
+ latm_get_value(gb); // taraFullness
+
+ skip_bits(gb, 1); // allStreamSameTimeFraming
+ skip_bits(gb, 6); // numSubFrames
+ // numPrograms
+ if (get_bits(gb, 4)) { // numPrograms
+ av_log_missing_feature(latmctx->aac_ctx.avctx,
+ "multiple programs are not supported\n", 1);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ // for each program (which there is only on in DVB)
+
+ // for each layer (which there is only on in DVB)
+ if (get_bits(gb, 3)) { // numLayer
+ av_log_missing_feature(latmctx->aac_ctx.avctx,
+ "multiple layers are not supported\n", 1);
+ return AVERROR_PATCHWELCOME;
+ }
+
+ // for all but first stream: use_same_config = get_bits(gb, 1);
+ if (!audio_mux_version) {
+ if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0)
+ return ret;
+ } else {
+ int ascLen = latm_get_value(gb);
+ if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0)
+ return ret;
+ ascLen -= ret;
+ skip_bits_long(gb, ascLen);
+ }
+
+ latmctx->frame_length_type = get_bits(gb, 3);
+ switch (latmctx->frame_length_type) {
+ case 0:
+ skip_bits(gb, 8); // latmBufferFullness
+ break;
+ case 1:
+ latmctx->frame_length = get_bits(gb, 9);
+ break;
+ case 3:
+ case 4:
+ case 5:
+ skip_bits(gb, 6); // CELP frame length table index
+ break;
+ case 6:
+ case 7:
+ skip_bits(gb, 1); // HVXC frame length table index
+ break;
+ }
+
+ if (get_bits(gb, 1)) { // other data
+ if (audio_mux_version) {
+ latm_get_value(gb); // other_data_bits
+ } else {
+ int esc;
+ do {
+ esc = get_bits(gb, 1);
+ skip_bits(gb, 8);
+ } while (esc);
+ }
+ }
+
+ if (get_bits(gb, 1)) // crc present
+ skip_bits(gb, 8); // config_crc
+ }
+
+ return 0;
+}
+
+static int read_payload_length_info(struct LATMContext *ctx, GetBitContext *gb)
+{
+ uint8_t tmp;
+
+ if (ctx->frame_length_type == 0) {
+ int mux_slot_length = 0;
+ do {
+ tmp = get_bits(gb, 8);
+ mux_slot_length += tmp;
+ } while (tmp == 255);
+ return mux_slot_length;
+ } else if (ctx->frame_length_type == 1) {
+ return ctx->frame_length;
+ } else if (ctx->frame_length_type == 3 ||
+ ctx->frame_length_type == 5 ||
+ ctx->frame_length_type == 7) {
+ skip_bits(gb, 2); // mux_slot_length_coded
+ }
+ return 0;
+}
+
+static int read_audio_mux_element(struct LATMContext *latmctx,
+ GetBitContext *gb)
+{
+ int err;
+ uint8_t use_same_mux = get_bits(gb, 1);
+ if (!use_same_mux) {
+ if ((err = read_stream_mux_config(latmctx, gb)) < 0)
+ return err;
+ } else if (!latmctx->aac_ctx.avctx->extradata) {
+ av_log(latmctx->aac_ctx.avctx, AV_LOG_DEBUG,
+ "no decoder config found\n");
+ return AVERROR(EAGAIN);
+ }
+ if (latmctx->audio_mux_version_A == 0) {
+ int mux_slot_length_bytes = read_payload_length_info(latmctx, gb);
+ if (mux_slot_length_bytes * 8 > get_bits_left(gb)) {
+ av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR, "incomplete frame\n");
+ return AVERROR_INVALIDDATA;
+ } else if (mux_slot_length_bytes * 8 + 256 < get_bits_left(gb)) {
+ av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
+ "frame length mismatch %d << %d\n",
+ mux_slot_length_bytes * 8, get_bits_left(gb));
+ return AVERROR_INVALIDDATA;
+ }
+ }
+ return 0;
+}
+
+
+static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,
+ AVPacket *avpkt)
+{
+ struct LATMContext *latmctx = avctx->priv_data;
+ int muxlength, err;
+ GetBitContext gb;
+
+ if (avpkt->size == 0)
+ return 0;
+
+ init_get_bits(&gb, avpkt->data, avpkt->size * 8);
+
+ // check for LOAS sync word
+ if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
+ return AVERROR_INVALIDDATA;
+
+ muxlength = get_bits(&gb, 13) + 3;
+ // not enough data, the parser should have sorted this
+ if (muxlength > avpkt->size)
+ return AVERROR_INVALIDDATA;
+
+ if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
+ return err;
+
+ if (!latmctx->initialized) {
+ if (!avctx->extradata) {
+ *out_size = 0;
+ return avpkt->size;
+ } else {
+ if ((err = aac_decode_init(avctx)) < 0)
+ return err;
+ latmctx->initialized = 1;
+ }
+ }
+
+ if (show_bits(&gb, 12) == 0xfff) {
+ av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
+ "ADTS header detected, probably as result of configuration "
+ "misparsing\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if ((err = aac_decode_frame_int(avctx, out, out_size, &gb)) < 0)
+ return err;
+
+ return muxlength;
+}
+
+av_cold static int latm_decode_init(AVCodecContext *avctx)
+{
+ struct LATMContext *latmctx = avctx->priv_data;
+ int ret;
+
+ ret = aac_decode_init(avctx);
+
+ if (avctx->extradata_size > 0) {
+ latmctx->initialized = !ret;
+ } else {
+ latmctx->initialized = 0;
+ }
+
+ return ret;
+}
+
+
+AVCodec ff_aac_decoder = {
"aac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AAC,
@@ -2096,8 +2350,28 @@ AVCodec aac_decoder = {
aac_decode_close,
aac_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
- .sample_fmts = (const enum SampleFormat[]) {
- SAMPLE_FMT_S16,SAMPLE_FMT_NONE
+ .sample_fmts = (const enum AVSampleFormat[]) {
+ AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE
+ },
+ .channel_layouts = aac_channel_layout,
+};
+
+/*
+ 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.
+*/
+AVCodec ff_aac_latm_decoder = {
+ .name = "aac_latm",
+ .type = CODEC_TYPE_AUDIO,
+ .id = CODEC_ID_AAC_LATM,
+ .priv_data_size = sizeof(struct LATMContext),
+ .init = latm_decode_init,
+ .close = aac_decode_close,
+ .decode = latm_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Codec LATM syntax)"),
+ .sample_fmts = (const enum AVSampleFormat[]) {
+ AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE
},
.channel_layouts = aac_channel_layout,
};
diff --git a/lib/ffmpeg/libavcodec/aacdectab.h b/lib/ffmpeg/libavcodec/aacdectab.h
index b74f100112..b4307f133c 100644
--- a/lib/ffmpeg/libavcodec/aacdectab.h
+++ b/lib/ffmpeg/libavcodec/aacdectab.h
@@ -30,6 +30,7 @@
#ifndef AVCODEC_AACDECTAB_H
#define AVCODEC_AACDECTAB_H
+#include "libavcore/audioconvert.h"
#include "aac.h"
#include <stdint.h>
@@ -82,13 +83,13 @@ static const uint8_t aac_channel_layout_map[7][5][2] = {
};
static const int64_t aac_channel_layout[8] = {
- CH_LAYOUT_MONO,
- CH_LAYOUT_STEREO,
- CH_LAYOUT_SURROUND,
- CH_LAYOUT_4POINT0,
- CH_LAYOUT_5POINT0_BACK,
- CH_LAYOUT_5POINT1_BACK,
- CH_LAYOUT_7POINT1_WIDE,
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_4POINT0,
+ AV_CH_LAYOUT_5POINT0_BACK,
+ AV_CH_LAYOUT_5POINT1_BACK,
+ AV_CH_LAYOUT_7POINT1_WIDE,
0,
};
diff --git a/lib/ffmpeg/libavcodec/aacenc.c b/lib/ffmpeg/libavcodec/aacenc.c
index 94fb13fd85..237f338ed7 100644
--- a/lib/ffmpeg/libavcodec/aacenc.c
+++ b/lib/ffmpeg/libavcodec/aacenc.c
@@ -149,6 +149,11 @@ static void put_audio_specific_config(AVCodecContext *avctx)
put_bits(&pb, 1, 0); //frame length - 1024 samples
put_bits(&pb, 1, 0); //does not depend on core coder
put_bits(&pb, 1, 0); //is not extension
+
+ //Explicitly Mark SBR absent
+ put_bits(&pb, 11, 0x2b7); //sync extension
+ put_bits(&pb, 5, AOT_SBR);
+ put_bits(&pb, 1, 0);
flush_put_bits(&pb);
}
@@ -193,8 +198,8 @@ 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_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE);
- avctx->extradata_size = 2;
+ avctx->extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE);
+ avctx->extradata_size = 5;
put_audio_specific_config(avctx);
sizes[0] = swb_size_1024[i];
@@ -213,9 +218,10 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
}
static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
- SingleChannelElement *sce, short *audio, int channel)
+ SingleChannelElement *sce, short *audio)
{
- int i, j, k;
+ int i, k;
+ const int chans = avctx->channels;
const float * lwindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
const float * swindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
const float * pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
@@ -230,18 +236,18 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
s->output[i] = sce->saved[i];
}
if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) {
- for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) {
- s->output[i+1024] = audio[j] * lwindow[1024 - i - 1];
- sce->saved[i] = audio[j] * lwindow[i];
+ for (i = 0; i < 1024; i++) {
+ s->output[i+1024] = audio[i * chans] * lwindow[1024 - i - 1];
+ sce->saved[i] = audio[i * chans] * lwindow[i];
}
} else {
- for (i = 0, j = channel; i < 448; i++, j += avctx->channels)
- s->output[i+1024] = audio[j];
- for (; i < 576; i++, j += avctx->channels)
- s->output[i+1024] = audio[j] * swindow[576 - i - 1];
+ for (i = 0; i < 448; i++)
+ s->output[i+1024] = audio[i * chans];
+ for (; i < 576; i++)
+ s->output[i+1024] = audio[i * chans] * swindow[576 - i - 1];
memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448);
- for (i = 0, j = channel; i < 1024; i++, j += avctx->channels)
- sce->saved[i] = audio[j];
+ for (i = 0; i < 1024; i++)
+ sce->saved[i] = audio[i * chans];
}
ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output);
} else {
@@ -249,13 +255,13 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
for (i = 448 + k; i < 448 + k + 256; i++)
s->output[i - 448 - k] = (i < 1024)
? sce->saved[i]
- : audio[channel + (i-1024)*avctx->channels];
- s->dsp.vector_fmul (s->output, k ? swindow : pwindow, 128);
+ : audio[(i-1024)*chans];
+ s->dsp.vector_fmul (s->output, s->output, k ? swindow : pwindow, 128);
s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128);
ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output);
}
- for (i = 0, j = channel; i < 1024; i++, j += avctx->channels)
- sce->saved[i] = audio[j];
+ for (i = 0; i < 1024; i++)
+ sce->saved[i] = audio[i * chans];
}
}
@@ -301,7 +307,7 @@ static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe)
static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, int chans)
{
int i, w, w2, g, ch;
- int start, sum, maxsfb, cmaxsfb;
+ int start, maxsfb, cmaxsfb;
for (ch = 0; ch < chans; ch++) {
IndividualChannelStream *ics = &cpe->ch[ch].ics;
@@ -310,9 +316,8 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in
cpe->ch[ch].pulse.num_pulse = 0;
for (w = 0; w < ics->num_windows*16; w += 16) {
for (g = 0; g < ics->num_swb; g++) {
- sum = 0;
//apply M/S
- if (!ch && cpe->ms_mask[w + g]) {
+ if (cpe->common_window && !ch && cpe->ms_mask[w + g]) {
for (i = 0; i < ics->swb_sizes[g]; i++) {
cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
@@ -516,20 +521,21 @@ static int aac_encode_frame(AVCodecContext *avctx,
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
- samples2 = samples + 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;
+ int cur_channel = start_ch + j;
+ samples2 = samples + cur_channel;
+ la = samples2 + (448+64) * avctx->channels;
+ if (!data)
+ la = NULL;
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,
+ wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, cur_channel,
ics->window_sequence[0]);
}
ics->window_sequence[1] = ics->window_sequence[0];
@@ -542,8 +548,7 @@ static int aac_encode_frame(AVCodecContext *avctx,
for (k = 0; k < ics->num_windows; k++)
ics->group_len[k] = wi[j].grouping[k];
- s->cur_channel = start_ch + j;
- apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j);
+ apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2);
}
start_ch += chans;
}
@@ -559,6 +564,8 @@ static int aac_encode_frame(AVCodecContext *avctx,
tag = chan_map[i+1];
chans = tag == TYPE_CPE ? 2 : 1;
cpe = &s->cpe[i];
+ put_bits(&s->pb, 3, tag);
+ put_bits(&s->pb, 4, chan_el_counter[tag]++);
for (j = 0; j < chans; j++) {
s->cur_channel = start_ch + j;
ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
@@ -581,8 +588,6 @@ static int aac_encode_frame(AVCodecContext *avctx,
if (cpe->common_window && s->coder->search_for_ms)
s->coder->search_for_ms(s, cpe, s->lambda);
adjust_frame_information(s, cpe, chans);
- put_bits(&s->pb, 3, tag);
- put_bits(&s->pb, 4, chan_el_counter[tag]++);
if (chans == 2) {
put_bits(&s->pb, 1, cpe->common_window);
if (cpe->common_window) {
@@ -641,7 +646,7 @@ static const AVProfile profiles[] = {
{ FF_PROFILE_UNKNOWN },
};
-AVCodec aac_encoder = {
+AVCodec ff_aac_encoder = {
"aac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AAC,
@@ -650,7 +655,7 @@ AVCodec aac_encoder = {
aac_encode_frame,
aac_encode_end,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
.profiles = profiles,
};
diff --git a/lib/ffmpeg/libavcodec/aacpsy.c b/lib/ffmpeg/libavcodec/aacpsy.c
index 466b0e9a1a..a987be0abb 100644
--- a/lib/ffmpeg/libavcodec/aacpsy.c
+++ b/lib/ffmpeg/libavcodec/aacpsy.c
@@ -39,11 +39,19 @@
* constants for 3GPP AAC psychoacoustic model
* @{
*/
-#define PSY_3GPP_SPREAD_LOW 1.5f // spreading factor for ascending threshold spreading (15 dB/Bark)
-#define PSY_3GPP_SPREAD_HI 3.0f // spreading factor for descending threshold spreading (30 dB/Bark)
+#define PSY_3GPP_SPREAD_HI 1.5f // spreading factor for ascending threshold spreading (15 dB/Bark)
+#define PSY_3GPP_SPREAD_LOW 3.0f // spreading factor for descending threshold spreading (30 dB/Bark)
#define PSY_3GPP_RPEMIN 0.01f
#define PSY_3GPP_RPELEV 2.0f
+
+/* LAME psy model constants */
+#define PSY_LAME_FIR_LEN 21 ///< LAME psy model FIR order
+#define AAC_BLOCK_SIZE_LONG 1024 ///< long block size
+#define AAC_BLOCK_SIZE_SHORT 128 ///< short block size
+#define AAC_NUM_BLOCKS_SHORT 8 ///< number of blocks in a short sequence
+#define PSY_LAME_NUM_SUBBLOCKS 3 ///< Number of sub-blocks in each short block
+
/**
* @}
*/
@@ -51,44 +59,156 @@
/**
* information for single band used by 3GPP TS26.403-inspired psychoacoustic model
*/
-typedef struct Psy3gppBand{
+typedef struct AacPsyBand{
float energy; ///< band energy
float ffac; ///< form factor
float thr; ///< energy threshold
float min_snr; ///< minimal SNR
float thr_quiet; ///< threshold in quiet
-}Psy3gppBand;
+}AacPsyBand;
/**
* single/pair channel context for psychoacoustic model
*/
-typedef struct Psy3gppChannel{
- Psy3gppBand band[128]; ///< bands information
- Psy3gppBand prev_band[128]; ///< bands information from the previous frame
+typedef struct AacPsyChannel{
+ AacPsyBand band[128]; ///< bands information
+ AacPsyBand prev_band[128]; ///< bands information from the previous frame
float win_energy; ///< sliding average of channel energy
float iir_state[2]; ///< hi-pass IIR filter state
uint8_t next_grouping; ///< stored grouping scheme for the next frame (in case of 8 short window sequence)
enum WindowSequence next_window_seq; ///< window sequence to be used in the next frame
-}Psy3gppChannel;
+ /* LAME psy model specific members */
+ float attack_threshold; ///< attack threshold for this channel
+ float prev_energy_subshort[AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS];
+ int prev_attack; ///< attack value for the last short block in the previous sequence
+}AacPsyChannel;
/**
* psychoacoustic model frame type-dependent coefficients
*/
-typedef struct Psy3gppCoeffs{
+typedef struct AacPsyCoeffs{
float ath [64]; ///< absolute threshold of hearing per bands
float barks [64]; ///< Bark value for each spectral band in long frame
float spread_low[64]; ///< spreading factor for low-to-high threshold spreading in long frame
float spread_hi [64]; ///< spreading factor for high-to-low threshold spreading in long frame
-}Psy3gppCoeffs;
+}AacPsyCoeffs;
/**
* 3GPP TS26.403-inspired psychoacoustic model specific data
*/
-typedef struct Psy3gppContext{
- Psy3gppCoeffs psy_coef[2];
- Psy3gppChannel *ch;
-}Psy3gppContext;
+typedef struct AacPsyContext{
+ AacPsyCoeffs psy_coef[2];
+ AacPsyChannel *ch;
+}AacPsyContext;
+
+/**
+ * LAME psy model preset struct
+ */
+typedef struct {
+ int quality; ///< Quality to map the rest of the vaules to.
+ /* This is overloaded to be both kbps per channel in ABR mode, and
+ * requested quality in constant quality mode.
+ */
+ float st_lrm; ///< short threshold for L, R, and M channels
+} PsyLamePreset;
+
+/**
+ * LAME psy model preset table for ABR
+ */
+static const PsyLamePreset psy_abr_map[] = {
+/* TODO: Tuning. These were taken from LAME. */
+/* kbps/ch st_lrm */
+ { 8, 6.60},
+ { 16, 6.60},
+ { 24, 6.60},
+ { 32, 6.60},
+ { 40, 6.60},
+ { 48, 6.60},
+ { 56, 6.60},
+ { 64, 6.40},
+ { 80, 6.00},
+ { 96, 5.60},
+ {112, 5.20},
+ {128, 5.20},
+ {160, 5.20}
+};
+
+/**
+* LAME psy model preset table for constant quality
+*/
+static const PsyLamePreset psy_vbr_map[] = {
+/* vbr_q st_lrm */
+ { 0, 4.20},
+ { 1, 4.20},
+ { 2, 4.20},
+ { 3, 4.20},
+ { 4, 4.20},
+ { 5, 4.20},
+ { 6, 4.20},
+ { 7, 4.20},
+ { 8, 4.20},
+ { 9, 4.20},
+ {10, 4.20}
+};
+
+/**
+ * LAME psy model FIR coefficient table
+ */
+static const float psy_fir_coeffs[] = {
+ -8.65163e-18 * 2, -0.00851586 * 2, -6.74764e-18 * 2, 0.0209036 * 2,
+ -3.36639e-17 * 2, -0.0438162 * 2, -1.54175e-17 * 2, 0.0931738 * 2,
+ -5.52212e-17 * 2, -0.313819 * 2
+};
+
+/**
+ * calculates the attack threshold for ABR from the above table for the LAME psy model
+ */
+static float lame_calc_attack_threshold(int bitrate)
+{
+ /* Assume max bitrate to start with */
+ int lower_range = 12, upper_range = 12;
+ int lower_range_kbps = psy_abr_map[12].quality;
+ int upper_range_kbps = psy_abr_map[12].quality;
+ int i;
+
+ /* Determine which bitrates the value specified falls between.
+ * If the loop ends without breaking our above assumption of 320kbps was correct.
+ */
+ for (i = 1; i < 13; i++) {
+ if (FFMAX(bitrate, psy_abr_map[i].quality) != bitrate) {
+ upper_range = i;
+ upper_range_kbps = psy_abr_map[i ].quality;
+ lower_range = i - 1;
+ lower_range_kbps = psy_abr_map[i - 1].quality;
+ break; /* Upper range found */
+ }
+ }
+
+ /* Determine which range the value specified is closer to */
+ if ((upper_range_kbps - bitrate) > (bitrate - lower_range_kbps))
+ return psy_abr_map[lower_range].st_lrm;
+ return psy_abr_map[upper_range].st_lrm;
+}
+
+/**
+ * LAME psy model specific initialization
+ */
+static void lame_window_init(AacPsyContext *ctx, AVCodecContext *avctx) {
+ int i, j;
+
+ for (i = 0; i < avctx->channels; i++) {
+ AacPsyChannel *pch = &ctx->ch[i];
+
+ if (avctx->flags & CODEC_FLAG_QSCALE)
+ pch->attack_threshold = psy_vbr_map[avctx->global_quality / FF_QP2LAMBDA].st_lrm;
+ else
+ pch->attack_threshold = lame_calc_attack_threshold(avctx->bit_rate / avctx->channels / 1000);
+
+ for (j = 0; j < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; j++)
+ pch->prev_energy_subshort[j] = 10.0f;
+ }
+}
/**
* Calculate Bark value for given line.
@@ -113,25 +233,25 @@ static av_cold float ath(float f, float add)
}
static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
- Psy3gppContext *pctx;
- float barks[1024];
+ AacPsyContext *pctx;
+ float bark;
int i, j, g, start;
float prev, minscale, minath;
- ctx->model_priv_data = av_mallocz(sizeof(Psy3gppContext));
- pctx = (Psy3gppContext*) ctx->model_priv_data;
+ ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext));
+ pctx = (AacPsyContext*) ctx->model_priv_data;
- for (i = 0; i < 1024; i++)
- barks[i] = calc_bark(i * ctx->avctx->sample_rate / 2048.0);
minath = ath(3410, ATH_ADD);
for (j = 0; j < 2; j++) {
- Psy3gppCoeffs *coeffs = &pctx->psy_coef[j];
+ AacPsyCoeffs *coeffs = &pctx->psy_coef[j];
+ float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f);
i = 0;
prev = 0.0;
for (g = 0; g < ctx->num_bands[j]; g++) {
i += ctx->bands[j][g];
- coeffs->barks[g] = (barks[i - 1] + prev) / 2.0;
- prev = barks[i - 1];
+ bark = calc_bark((i-1) * line_to_frequency);
+ coeffs->barks[g] = (bark + prev) / 2.0;
+ prev = bark;
}
for (g = 0; g < ctx->num_bands[j] - 1; g++) {
coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);
@@ -139,15 +259,18 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
}
start = 0;
for (g = 0; g < ctx->num_bands[j]; g++) {
- minscale = ath(ctx->avctx->sample_rate * start / 1024.0, ATH_ADD);
+ minscale = ath(start * line_to_frequency, ATH_ADD);
for (i = 1; i < ctx->bands[j][g]; i++)
- minscale = FFMIN(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD));
+ minscale = FFMIN(minscale, ath((start + i) * line_to_frequency, ATH_ADD));
coeffs->ath[g] = minscale - minath;
start += ctx->bands[j][g];
}
}
- pctx->ch = av_mallocz(sizeof(Psy3gppChannel) * ctx->avctx->channels);
+ pctx->ch = av_mallocz(sizeof(AacPsyChannel) * ctx->avctx->channels);
+
+ lame_window_init(pctx, ctx->avctx);
+
return 0;
}
@@ -182,8 +305,8 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
int i, j;
int br = ctx->avctx->bit_rate / ctx->avctx->channels;
int attack_ratio = br <= 16000 ? 18 : 10;
- Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
- Psy3gppChannel *pch = &pctx->ch[channel];
+ AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
+ AacPsyChannel *pch = &pctx->ch[channel];
uint8_t grouping = 0;
int next_type = pch->next_window_seq;
FFPsyWindowInfo wi;
@@ -264,24 +387,23 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
* Calculate band thresholds as suggested in 3GPP TS26.403
*/
static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
- const float *coefs, FFPsyWindowInfo *wi)
+ const float *coefs, const FFPsyWindowInfo *wi)
{
- Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data;
- Psy3gppChannel *pch = &pctx->ch[channel];
+ AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
+ AacPsyChannel *pch = &pctx->ch[channel];
int start = 0;
int i, w, g;
const int num_bands = ctx->num_bands[wi->num_windows == 8];
const uint8_t* band_sizes = ctx->bands[wi->num_windows == 8];
- Psy3gppCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
+ AacPsyCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
//calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
for (w = 0; w < wi->num_windows*16; w += 16) {
for (g = 0; g < num_bands; g++) {
- Psy3gppBand *band = &pch->band[w+g];
+ AacPsyBand *band = &pch->band[w+g];
band->energy = 0.0f;
for (i = 0; i < band_sizes[g]; i++)
band->energy += coefs[start+i] * coefs[start+i];
- band->energy *= 1.0f / (512*512);
band->thr = band->energy * 0.001258925f;
start += band_sizes[g];
@@ -290,18 +412,16 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
}
//modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"
for (w = 0; w < wi->num_windows*16; w += 16) {
- Psy3gppBand *band = &pch->band[w];
+ AacPsyBand *band = &pch->band[w];
for (g = 1; g < num_bands; g++)
- band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]);
+ band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_hi [g]);
for (g = num_bands - 2; g >= 0; g--)
- band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]);
+ band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_low[g]);
for (g = 0; g < num_bands; g++) {
- band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]);
- if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE)
- band[g].thr_quiet = FFMAX(PSY_3GPP_RPEMIN*band[g].thr_quiet,
- FFMIN(band[g].thr_quiet,
- PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
- band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25);
+ band[g].thr_quiet = band[g].thr = FFMAX(band[g].thr, coeffs->ath[g]);
+ if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w)))
+ band[g].thr = FFMAX(PSY_3GPP_RPEMIN*band[g].thr, FFMIN(band[g].thr,
+ PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr;
}
@@ -311,17 +431,196 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel,
static av_cold void psy_3gpp_end(FFPsyContext *apc)
{
- Psy3gppContext *pctx = (Psy3gppContext*) apc->model_priv_data;
+ AacPsyContext *pctx = (AacPsyContext*) apc->model_priv_data;
av_freep(&pctx->ch);
av_freep(&apc->model_priv_data);
}
+static void lame_apply_block_type(AacPsyChannel *ctx, FFPsyWindowInfo *wi, int uselongblock)
+{
+ int blocktype = ONLY_LONG_SEQUENCE;
+ if (uselongblock) {
+ if (ctx->next_window_seq == EIGHT_SHORT_SEQUENCE)
+ blocktype = LONG_STOP_SEQUENCE;
+ } else {
+ blocktype = EIGHT_SHORT_SEQUENCE;
+ if (ctx->next_window_seq == ONLY_LONG_SEQUENCE)
+ ctx->next_window_seq = LONG_START_SEQUENCE;
+ if (ctx->next_window_seq == LONG_STOP_SEQUENCE)
+ ctx->next_window_seq = EIGHT_SHORT_SEQUENCE;
+ }
+
+ wi->window_type[0] = ctx->next_window_seq;
+ ctx->next_window_seq = blocktype;
+}
+
+static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx,
+ const int16_t *audio, const int16_t *la,
+ int channel, int prev_type)
+{
+ AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
+ AacPsyChannel *pch = &pctx->ch[channel];
+ int grouping = 0;
+ int uselongblock = 1;
+ int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
+ int i;
+ FFPsyWindowInfo wi;
+
+ memset(&wi, 0, sizeof(wi));
+ if (la) {
+ float hpfsmpl[AAC_BLOCK_SIZE_LONG];
+ float const *pf = hpfsmpl;
+ float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
+ float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
+ float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
+ int chans = ctx->avctx->channels;
+ const int16_t *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN) * chans;
+ int j, att_sum = 0;
+
+ /* LAME comment: apply high pass filter of fs/4 */
+ for (i = 0; i < AAC_BLOCK_SIZE_LONG; i++) {
+ float sum1, sum2;
+ sum1 = firbuf[(i + ((PSY_LAME_FIR_LEN - 1) / 2)) * chans];
+ sum2 = 0.0;
+ for (j = 0; j < ((PSY_LAME_FIR_LEN - 1) / 2) - 1; j += 2) {
+ sum1 += psy_fir_coeffs[j] * (firbuf[(i + j) * chans] + firbuf[(i + PSY_LAME_FIR_LEN - j) * chans]);
+ sum2 += psy_fir_coeffs[j + 1] * (firbuf[(i + j + 1) * chans] + firbuf[(i + PSY_LAME_FIR_LEN - j - 1) * chans]);
+ }
+ hpfsmpl[i] = sum1 + sum2;
+ }
+
+ /* Calculate the energies of each sub-shortblock */
+ for (i = 0; i < PSY_LAME_NUM_SUBBLOCKS; i++) {
+ energy_subshort[i] = pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];
+ assert(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
+ attack_intensity[i] = energy_subshort[i] / pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];
+ energy_short[0] += energy_subshort[i];
+ }
+
+ for (i = 0; i < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; i++) {
+ float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
+ float p = 1.0f;
+ for (; pf < pfe; pf++)
+ if (p < fabsf(*pf))
+ p = fabsf(*pf);
+ pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p;
+ energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p;
+ /* FIXME: The indexes below are [i + 3 - 2] in the LAME source.
+ * Obviously the 3 and 2 have some significance, or this would be just [i + 1]
+ * (which is what we use here). What the 3 stands for is ambigious, as it is both
+ * number of short blocks, and the number of sub-short blocks.
+ * It seems that LAME is comparing each sub-block to sub-block + 1 in the
+ * previous block.
+ */
+ if (p > energy_subshort[i + 1])
+ p = p / energy_subshort[i + 1];
+ else if (energy_subshort[i + 1] > p * 10.0f)
+ p = energy_subshort[i + 1] / (p * 10.0f);
+ else
+ p = 0.0;
+ attack_intensity[i + PSY_LAME_NUM_SUBBLOCKS] = p;
+ }
+
+ /* compare energy between sub-short blocks */
+ for (i = 0; i < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; i++)
+ if (!attacks[i / PSY_LAME_NUM_SUBBLOCKS])
+ if (attack_intensity[i] > pch->attack_threshold)
+ attacks[i / PSY_LAME_NUM_SUBBLOCKS] = (i % PSY_LAME_NUM_SUBBLOCKS) + 1;
+
+ /* should have energy change between short blocks, in order to avoid periodic signals */
+ /* Good samples to show the effect are Trumpet test songs */
+ /* GB: tuned (1) to avoid too many short blocks for test sample TRUMPET */
+ /* RH: tuned (2) to let enough short blocks through for test sample FSOL and SNAPS */
+ for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) {
+ float const u = energy_short[i - 1];
+ float const v = energy_short[i];
+ float const m = FFMAX(u, v);
+ if (m < 40000) { /* (2) */
+ if (u < 1.7f * v && v < 1.7f * u) { /* (1) */
+ if (i == 1 && attacks[0] < attacks[i])
+ attacks[0] = 0;
+ attacks[i] = 0;
+ }
+ }
+ att_sum += attacks[i];
+ }
+
+ if (attacks[0] <= pch->prev_attack)
+ attacks[0] = 0;
+
+ att_sum += attacks[0];
+ /* 3 below indicates the previous attack happened in the last sub-block of the previous sequence */
+ if (pch->prev_attack == 3 || att_sum) {
+ uselongblock = 0;
+
+ if (attacks[1] && attacks[0])
+ attacks[1] = 0;
+ if (attacks[2] && attacks[1])
+ attacks[2] = 0;
+ if (attacks[3] && attacks[2])
+ attacks[3] = 0;
+ if (attacks[4] && attacks[3])
+ attacks[4] = 0;
+ if (attacks[5] && attacks[4])
+ attacks[5] = 0;
+ if (attacks[6] && attacks[5])
+ attacks[6] = 0;
+ if (attacks[7] && attacks[6])
+ attacks[7] = 0;
+ if (attacks[8] && attacks[7])
+ attacks[8] = 0;
+ }
+ } else {
+ /* We have no lookahead info, so just use same type as the previous sequence. */
+ uselongblock = !(prev_type == EIGHT_SHORT_SEQUENCE);
+ }
+
+ lame_apply_block_type(pch, &wi, uselongblock);
+
+ wi.window_type[1] = prev_type;
+ if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
+ wi.num_windows = 1;
+ wi.grouping[0] = 1;
+ if (wi.window_type[0] == LONG_START_SEQUENCE)
+ wi.window_shape = 0;
+ else
+ wi.window_shape = 1;
+ } else {
+ int lastgrp = 0;
+
+ wi.num_windows = 8;
+ wi.window_shape = 0;
+ for (i = 0; i < 8; i++) {
+ if (!((pch->next_grouping >> i) & 1))
+ lastgrp = i;
+ wi.grouping[lastgrp]++;
+ }
+ }
+
+ /* Determine grouping, based on the location of the first attack, and save for
+ * the next frame.
+ * FIXME: Move this to analysis.
+ * TODO: Tune groupings depending on attack location
+ * TODO: Handle more than one attack in a group
+ */
+ for (i = 0; i < 9; i++) {
+ if (attacks[i]) {
+ grouping = i;
+ break;
+ }
+ }
+ pch->next_grouping = window_grouping[grouping];
+
+ pch->prev_attack = attacks[8];
+
+ return wi;
+}
const FFPsyModel ff_aac_psy_model =
{
.name = "3GPP TS 26.403-inspired model",
.init = psy_3gpp_init,
- .window = psy_3gpp_window,
+ .window = psy_lame_window,
.analyze = psy_3gpp_analyze,
.end = psy_3gpp_end,
};
diff --git a/lib/ffmpeg/libavcodec/aacsbr.c b/lib/ffmpeg/libavcodec/aacsbr.c
index 050305a3fe..9b10bf25fe 100644
--- a/lib/ffmpeg/libavcodec/aacsbr.c
+++ b/lib/ffmpeg/libavcodec/aacsbr.c
@@ -1175,12 +1175,10 @@ static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in,
static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
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)
+ float *v0, int *v_off, const unsigned int div)
{
int i, n;
const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us;
- int scale_and_bias = scale != 1.0f || bias != 0.0f;
float *v;
for (i = 0; i < 32; i++) {
if (*v_off == 0) {
@@ -1222,9 +1220,6 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div);
dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div);
- if (scale_and_bias)
- for (n = 0; n < 64 >> div; n++)
- out[n] = out[n] * scale + bias;
out += 64 >> div;
}
}
@@ -1760,12 +1755,10 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
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,
- downsampled,
- ac->add_bias, -1024 * ac->sf_scale);
+ downsampled);
if (nch == 2)
sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, R, sbr->X[1], sbr->qmf_filter_scratch,
sbr->data[1].synthesis_filterbank_samples,
&sbr->data[1].synthesis_filterbank_samples_offset,
- downsampled,
- ac->add_bias, -1024 * ac->sf_scale);
+ downsampled);
}
diff --git a/lib/ffmpeg/libavcodec/aasc.c b/lib/ffmpeg/libavcodec/aasc.c
index 82bd2bfd3d..44bdcb0b63 100644
--- a/lib/ffmpeg/libavcodec/aasc.c
+++ b/lib/ffmpeg/libavcodec/aasc.c
@@ -109,7 +109,7 @@ static av_cold int aasc_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec aasc_decoder = {
+AVCodec ff_aasc_decoder = {
"aasc",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_AASC,
diff --git a/lib/ffmpeg/libavcodec/ac3.c b/lib/ffmpeg/libavcodec/ac3.c
index 1f5ab32eb8..23eee52661 100644
--- a/lib/ffmpeg/libavcodec/ac3.c
+++ b/lib/ffmpeg/libavcodec/ac3.c
@@ -28,12 +28,10 @@
#include "ac3.h"
#include "get_bits.h"
-#if CONFIG_HARDCODED_TABLES
-
/**
* Starting frequency coefficient bin for each critical band.
*/
-static const uint8_t band_start_tab[51] = {
+static const uint8_t band_start_tab[AC3_CRITICAL_BANDS+1] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
@@ -41,6 +39,8 @@ static const uint8_t band_start_tab[51] = {
79, 85, 97, 109, 121, 133, 157, 181, 205, 229, 253
};
+#if CONFIG_HARDCODED_TABLES
+
/**
* Map each frequency coefficient bin to the critical band that contains it.
*/
@@ -70,7 +70,6 @@ static const uint8_t bin_to_band_tab[253] = {
};
#else /* CONFIG_HARDCODED_TABLES */
-static uint8_t band_start_tab[51];
static uint8_t bin_to_band_tab[253];
#endif
@@ -127,7 +126,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
uint8_t *dba_lengths, uint8_t *dba_values,
int16_t *mask)
{
- int16_t excite[50]; /* excitation */
+ int16_t excite[AC3_CRITICAL_BANDS]; /* excitation */
int band;
int band_start, band_end, begin, end1;
int lowcomp, fastleak, slowleak;
@@ -198,7 +197,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
band = 0;
for (seg = 0; seg < dba_nsegs; seg++) {
band += dba_offsets[seg];
- if (band >= 50 || dba_lengths[seg] > 50-band)
+ if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
return -1;
if (dba_values[seg] >= 4) {
delta = (dba_values[seg] - 3) << 7;
@@ -221,7 +220,7 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
/* special case, if snr offset is -960, set all bap's to zero */
if (snr_offset == -960) {
- memset(bap, 0, 256);
+ memset(bap, 0, AC3_MAX_COEFS);
return;
}
@@ -237,45 +236,20 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
} while (end > band_start_tab[band++]);
}
-/* AC-3 bit allocation. The algorithm is the one described in the AC-3
- spec. */
-void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
- int8_t *exp, int start, int end,
- int snr_offset, int fast_gain, int is_lfe,
- int dba_mode, int dba_nsegs,
- uint8_t *dba_offsets, uint8_t *dba_lengths,
- uint8_t *dba_values)
-{
- int16_t psd[256]; /* scaled exponents */
- int16_t band_psd[50]; /* interpolated exponents */
- int16_t mask[50]; /* masking value */
-
- ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd);
-
- ff_ac3_bit_alloc_calc_mask(s, band_psd, start, end, fast_gain, is_lfe,
- dba_mode, dba_nsegs, dba_offsets, dba_lengths,
- dba_values, mask);
-
- ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snr_offset, s->floor,
- ff_ac3_bap_tab, bap);
-}
-
/**
* Initialize some tables.
* note: This function must remain thread safe because it is called by the
* AVParser init code.
*/
-av_cold void ac3_common_init(void)
+av_cold void ff_ac3_common_init(void)
{
#if !CONFIG_HARDCODED_TABLES
- /* compute bndtab and masktab from bandsz */
+ /* compute bin_to_band_tab from band_start_tab */
int bin = 0, band;
- for (band = 0; band < 50; band++) {
- int band_end = bin + ff_ac3_critical_band_size_tab[band];
- band_start_tab[band] = bin;
+ for (band = 0; band < AC3_CRITICAL_BANDS; band++) {
+ int band_end = band_start_tab[band+1];
while (bin < band_end)
bin_to_band_tab[bin++] = band;
}
- band_start_tab[50] = bin;
#endif /* !CONFIG_HARDCODED_TABLES */
}
diff --git a/lib/ffmpeg/libavcodec/ac3.h b/lib/ffmpeg/libavcodec/ac3.h
index 9c8dc4870e..405e3cd0a3 100644
--- a/lib/ffmpeg/libavcodec/ac3.h
+++ b/lib/ffmpeg/libavcodec/ac3.h
@@ -27,13 +27,17 @@
#ifndef AVCODEC_AC3_H
#define AVCODEC_AC3_H
-#include "ac3tab.h"
-
#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
#define AC3_MAX_CHANNELS 6 /* including LFE channel */
-#define NB_BLOCKS 6 /* number of PCM blocks inside an AC-3 frame */
-#define AC3_FRAME_SIZE (NB_BLOCKS * 256)
+#define AC3_MAX_COEFS 256
+#define AC3_BLOCK_SIZE 256
+#define AC3_MAX_BLOCKS 6
+#define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
+#define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
+#define AC3_CRITICAL_BANDS 50
+
+#include "ac3tab.h"
/* exponent encoding strategy */
#define EXP_REUSE 0
@@ -111,7 +115,7 @@ typedef enum {
EAC3_FRAME_TYPE_RESERVED
} EAC3FrameType;
-void ac3_common_init(void);
+void ff_ac3_common_init(void);
/**
* Calculate the log power-spectral density of the input signal.
@@ -177,11 +181,4 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
int snr_offset, int floor,
const uint8_t *bap_tab, uint8_t *bap);
-void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
- int8_t *exp, int start, int end,
- int snr_offset, int fast_gain, int is_lfe,
- int dba_mode, int dba_nsegs,
- uint8_t *dba_offsets, uint8_t *dba_lengths,
- uint8_t *dba_values);
-
#endif /* AVCODEC_AC3_H */
diff --git a/lib/ffmpeg/libavcodec/ac3_parser.c b/lib/ffmpeg/libavcodec/ac3_parser.c
index b844ec36c3..4737d6f868 100644
--- a/lib/ffmpeg/libavcodec/ac3_parser.c
+++ b/lib/ffmpeg/libavcodec/ac3_parser.c
@@ -128,35 +128,6 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
return 0;
}
-int ff_ac3_parse_header_full(GetBitContext *gbc, AC3HeaderInfo *hdr){
- int ret, i;
- ret = ff_ac3_parse_header(gbc, hdr);
- if(!ret){
- if(hdr->bitstream_id>10){
- /* Enhanced AC-3 */
- skip_bits(gbc, 5); // skip bitstream id
-
- /* skip dialog normalization and compression gain */
- for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {
- skip_bits(gbc, 5); // skip dialog normalization
- if (get_bits1(gbc)) {
- skip_bits(gbc, 8); //skip Compression gain word
- }
- }
- /* dependent stream channel map */
- if (hdr->frame_type == EAC3_FRAME_TYPE_DEPENDENT && get_bits1(gbc)) {
- hdr->channel_map = get_bits(gbc, 16); //custom channel map
- return 0;
- }
- }
- //default channel map based on acmod and lfeon
- hdr->channel_map = ff_eac3_default_chmap[hdr->channel_mode];
- if(hdr->lfe_on)
- hdr->channel_map |= AC3_CHMAP_LFE;
- }
- return ret;
-}
-
static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
@@ -198,7 +169,7 @@ static av_cold int ac3_parse_init(AVCodecParserContext *s1)
}
-AVCodecParser ac3_parser = {
+AVCodecParser ff_ac3_parser = {
{ CODEC_ID_AC3, CODEC_ID_EAC3 },
sizeof(AACAC3ParseContext),
ac3_parse_init,
diff --git a/lib/ffmpeg/libavcodec/ac3_parser.h b/lib/ffmpeg/libavcodec/ac3_parser.h
index 9226c90218..50b70b08e5 100644
--- a/lib/ffmpeg/libavcodec/ac3_parser.h
+++ b/lib/ffmpeg/libavcodec/ac3_parser.h
@@ -30,23 +30,12 @@
* 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 BitContext containing the first 54 bits of the frame.
- * @param hdr Pointer to struct where header info is written.
+ * @param[in] gbc BitContext containing the first 54 bits of the frame.
+ * @param[out] 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.
*/
int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
-/**
- * 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 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);
-
#endif /* AVCODEC_AC3_PARSER_H */
diff --git a/lib/ffmpeg/libavcodec/ac3dec.c b/lib/ffmpeg/libavcodec/ac3dec.c
index f2f6e5ce4d..5ebee1908d 100644
--- a/lib/ffmpeg/libavcodec/ac3dec.c
+++ b/lib/ffmpeg/libavcodec/ac3dec.c
@@ -187,22 +187,17 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
AC3DecodeContext *s = avctx->priv_data;
s->avctx = avctx;
- ac3_common_init();
+ ff_ac3_common_init();
ac3_tables_init();
ff_mdct_init(&s->imdct_256, 8, 1, 1.0);
ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
ff_kbd_window_init(s->window, 5.0, 256);
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
av_lfg_init(&s->dith_state, 0);
- /* set bias values for float to int16 conversion */
- if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- s->add_bias = 385.0f;
- s->mul_bias = 1.0f;
- } else {
- s->add_bias = 0.0f;
- s->mul_bias = 32767.0f;
- }
+ /* set scale value for float to int16 conversion */
+ s->mul_bias = 32767.0f;
/* allow downmixing to stereo or mono */
if (avctx->channels > 0 && avctx->request_channels > 0 &&
@@ -219,7 +214,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -626,9 +621,6 @@ static void do_rematrixing(AC3DecodeContext *s)
static inline void do_imdct(AC3DecodeContext *s, int channels)
{
int ch;
- float add_bias = s->add_bias;
- if(s->out_channels==1 && channels>1)
- add_bias *= LEVEL_MINUS_3DB; // compensate for the gain in downmix
for (ch=1; ch<=channels; ch++) {
if (s->block_switch[ch]) {
@@ -637,13 +629,13 @@ static inline void do_imdct(AC3DecodeContext *s, int channels)
for(i=0; i<128; i++)
x[i] = s->transform_coeffs[ch][2*i];
ff_imdct_half(&s->imdct_256, s->tmp_output, x);
- s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, add_bias, 128);
+ s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128);
for(i=0; i<128; i++)
x[i] = s->transform_coeffs[ch][2*i+1];
ff_imdct_half(&s->imdct_256, s->delay[ch-1], x);
} else {
ff_imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]);
- s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, add_bias, 128);
+ s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128);
memcpy(s->delay[ch-1], s->tmp_output+128, 128*sizeof(float));
}
}
@@ -1264,7 +1256,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
} else {
gain *= s->dynamic_range[0];
}
- s->dsp.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
+ s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
}
/* apply spectral extension to high frequency bins */
@@ -1416,7 +1408,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
err = 1;
}
- s->dsp.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
+ s->fmt_conv.float_to_int16_interleave(out_samples, output, 256, s->out_channels);
out_samples += 256 * s->out_channels;
}
*data_size = s->num_blocks * 256 * avctx->channels * sizeof (int16_t);
@@ -1437,7 +1429,7 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec ac3_decoder = {
+AVCodec ff_ac3_decoder = {
.name = "ac3",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_AC3,
@@ -1449,7 +1441,7 @@ AVCodec ac3_decoder = {
};
#if CONFIG_EAC3_DECODER
-AVCodec eac3_decoder = {
+AVCodec ff_eac3_decoder = {
.name = "eac3",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_EAC3,
diff --git a/lib/ffmpeg/libavcodec/ac3dec.h b/lib/ffmpeg/libavcodec/ac3dec.h
index 8c0d442fc0..147e5e59bc 100644
--- a/lib/ffmpeg/libavcodec/ac3dec.h
+++ b/lib/ffmpeg/libavcodec/ac3dec.h
@@ -55,6 +55,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
/* override ac3.h to include coupling channel */
#undef AC3_MAX_CHANNELS
@@ -63,9 +64,6 @@
#define AC3_OUTPUT_LFEON 8
-#define AC3_MAX_COEFS 256
-#define AC3_BLOCK_SIZE 256
-#define MAX_BLOCKS 6
#define SPX_MAX_BANDS 17
typedef struct {
@@ -101,8 +99,8 @@ typedef struct {
///@}
///@defgroup cpl standard coupling
- int cpl_in_use[MAX_BLOCKS]; ///< coupling in use (cplinu)
- int cpl_strategy_exists[MAX_BLOCKS]; ///< coupling strategy exists (cplstre)
+ int cpl_in_use[AC3_MAX_BLOCKS]; ///< coupling in use (cplinu)
+ int cpl_strategy_exists[AC3_MAX_BLOCKS];///< coupling strategy exists (cplstre)
int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl)
int phase_flags_in_use; ///< phase flags in use (phsflginu)
int phase_flags[18]; ///< phase flags (phsflg)
@@ -131,7 +129,7 @@ typedef struct {
///@defgroup aht adaptive hybrid transform
int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu)
- int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][MAX_BLOCKS]; ///< pre-IDCT mantissas
+ int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; ///< pre-IDCT mantissas
///@}
///@defgroup channel channel
@@ -161,7 +159,7 @@ typedef struct {
///@defgroup exponents exponents
int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups (nexpgrp)
int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< decoded exponents
- int exp_strategy[MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr)
+ int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr)
///@}
///@defgroup bitalloc bit allocation
@@ -171,8 +169,8 @@ typedef struct {
int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values/SMR's (fgain)
uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers
int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents
- int16_t band_psd[AC3_MAX_CHANNELS][50]; ///< interpolated exponents
- int16_t mask[AC3_MAX_CHANNELS][50]; ///< masking curve values
+ int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< interpolated exponents
+ int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< masking curve values
int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode
int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments
uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
@@ -193,7 +191,7 @@ typedef struct {
///@defgroup opt optimization
DSPContext dsp; ///< for optimization
- float add_bias; ///< offset for float_to_int16 conversion
+ FmtConvertContext fmt_conv; ///< optimized conversion functions
float mul_bias; ///< scaling for float_to_int16 conversion
///@}
diff --git a/lib/ffmpeg/libavcodec/ac3dec_data.c b/lib/ffmpeg/libavcodec/ac3dec_data.c
index ea13d3de51..c40390245c 100644
--- a/lib/ffmpeg/libavcodec/ac3dec_data.c
+++ b/lib/ffmpeg/libavcodec/ac3dec_data.c
@@ -43,12 +43,6 @@ const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3] = {
{ 3, 0, 1 }, { 3, 0, 2 }, { 3, 1, 0 }, { 3, 1, 1 }
};
-/**
- * Table of bin locations for rematrixing bands
- * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
- */
-const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
-
const uint8_t ff_eac3_hebap_tab[64] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 8,
8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
diff --git a/lib/ffmpeg/libavcodec/ac3dec_data.h b/lib/ffmpeg/libavcodec/ac3dec_data.h
index 9ed7c73188..e2ab7ddbe5 100644
--- a/lib/ffmpeg/libavcodec/ac3dec_data.h
+++ b/lib/ffmpeg/libavcodec/ac3dec_data.h
@@ -25,7 +25,6 @@
#include <stdint.h>
extern const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3];
-extern const uint8_t ff_ac3_rematrix_band_tab[5];
extern const uint8_t ff_eac3_hebap_tab[64];
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
diff --git a/lib/ffmpeg/libavcodec/ac3enc.c b/lib/ffmpeg/libavcodec/ac3enc.c
index edae9a92bf..e41a0aec65 100644
--- a/lib/ffmpeg/libavcodec/ac3enc.c
+++ b/lib/ffmpeg/libavcodec/ac3enc.c
@@ -1,6 +1,8 @@
/*
* The simplest AC-3 encoder
* Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
+ * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
*
* This file is part of FFmpeg.
*
@@ -23,512 +25,721 @@
* @file
* The simplest AC-3 encoder.
*/
+
//#define DEBUG
-//#define DEBUG_BITALLOC
+
+#include "libavcore/audioconvert.h"
#include "libavutil/crc.h"
#include "avcodec.h"
-#include "libavutil/common.h" /* for av_reverse */
#include "put_bits.h"
+#include "dsputil.h"
#include "ac3.h"
#include "audioconvert.h"
+
+#ifndef CONFIG_AC3ENC_FLOAT
+#define CONFIG_AC3ENC_FLOAT 0
+#endif
+
+
+/** Maximum number of exponent groups. +1 for separate DC exponent. */
+#define AC3_MAX_EXP_GROUPS 85
+
+/* stereo rematrixing algorithms */
+#define AC3_REMATRIXING_IS_STATIC 0x1
+#define AC3_REMATRIXING_SUMS 0
+#define AC3_REMATRIXING_NONE 1
+#define AC3_REMATRIXING_ALWAYS 3
+
+/** Scale a float value by 2^bits and convert to an integer. */
+#define SCALE_FLOAT(a, bits) lrintf((a) * (float)(1 << (bits)))
+
+
+#if CONFIG_AC3ENC_FLOAT
+#include "ac3enc_float.h"
+#else
+#include "ac3enc_fixed.h"
+#endif
+
+
+/**
+ * Data for a single audio block.
+ */
+typedef struct AC3Block {
+ uint8_t **bap; ///< bit allocation pointers (bap)
+ CoefType **mdct_coef; ///< MDCT coefficients
+ int32_t **fixed_coef; ///< fixed-point MDCT coefficients
+ uint8_t **exp; ///< original exponents
+ uint8_t **grouped_exp; ///< grouped exponents
+ int16_t **psd; ///< psd per frequency bin
+ int16_t **band_psd; ///< psd per critical band
+ int16_t **mask; ///< masking curve
+ uint16_t **qmant; ///< quantized mantissas
+ int8_t exp_shift[AC3_MAX_CHANNELS]; ///< exponent shift values
+ uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block
+ uint8_t rematrixing_flags[4]; ///< rematrixing flags
+} AC3Block;
+
+/**
+ * AC-3 encoder private context.
+ */
typedef struct AC3EncodeContext {
- PutBitContext pb;
- int nb_channels;
- int nb_all_channels;
- int lfe_channel;
- const uint8_t *channel_map;
- int bit_rate;
- unsigned int sample_rate;
- unsigned int bitstream_id;
- unsigned int frame_size_min; /* minimum frame size in case rounding is necessary */
- unsigned int frame_size; /* current frame size in words */
- unsigned int bits_written;
- unsigned int samples_written;
- int sr_shift;
- unsigned int frame_size_code;
- unsigned int sr_code; /* frequency */
- unsigned int channel_mode;
- int lfe;
- unsigned int bitstream_mode;
- short last_samples[AC3_MAX_CHANNELS][256];
- unsigned int chbwcod[AC3_MAX_CHANNELS];
+ PutBitContext pb; ///< bitstream writer context
+ DSPContext dsp;
+ AC3MDCTContext mdct; ///< MDCT context
+
+ AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info
+
+ int bitstream_id; ///< bitstream id (bsid)
+ int bitstream_mode; ///< bitstream mode (bsmod)
+
+ int bit_rate; ///< target bit rate, in bits-per-second
+ int sample_rate; ///< sampling frequency, in Hz
+
+ int frame_size_min; ///< minimum frame size in case rounding is necessary
+ int frame_size; ///< current frame size in bytes
+ int frame_size_code; ///< frame size code (frmsizecod)
+ uint16_t crc_inv[2];
+ int bits_written; ///< bit count (used to avg. bitrate)
+ int samples_written; ///< sample count (used to avg. bitrate)
+
+ int fbw_channels; ///< number of full-bandwidth channels (nfchans)
+ int channels; ///< total number of channels (nchans)
+ int lfe_on; ///< indicates if there is an LFE channel (lfeon)
+ int lfe_channel; ///< channel index of the LFE channel
+ int channel_mode; ///< channel mode (acmod)
+ const uint8_t *channel_map; ///< channel map used to reorder channels
+
+ int cutoff; ///< user-specified cutoff frequency, in Hz
+ int bandwidth_code[AC3_MAX_CHANNELS]; ///< bandwidth code (0 to 60) (chbwcod)
int nb_coefs[AC3_MAX_CHANNELS];
+ int rematrixing; ///< determines how rematrixing strategy is calculated
+
/* bitrate allocation control */
- int slow_gain_code, slow_decay_code, fast_decay_code, db_per_bit_code, floor_code;
- AC3BitAllocParameters bit_alloc;
- int coarse_snr_offset;
- int fast_gain_code[AC3_MAX_CHANNELS];
- int fine_snr_offset[AC3_MAX_CHANNELS];
+ int slow_gain_code; ///< slow gain code (sgaincod)
+ int slow_decay_code; ///< slow decay code (sdcycod)
+ int fast_decay_code; ///< fast decay code (fdcycod)
+ int db_per_bit_code; ///< dB/bit code (dbpbcod)
+ int floor_code; ///< floor code (floorcod)
+ AC3BitAllocParameters bit_alloc; ///< bit allocation parameters
+ int coarse_snr_offset; ///< coarse SNR offsets (csnroffst)
+ int fast_gain_code[AC3_MAX_CHANNELS]; ///< fast gain codes (signal-to-mask ratio) (fgaincod)
+ int fine_snr_offset[AC3_MAX_CHANNELS]; ///< fine SNR offsets (fsnroffst)
+ int frame_bits_fixed; ///< number of non-coefficient bits for fixed parameters
+ int frame_bits; ///< all frame bits except exponents and mantissas
+ int exponent_bits; ///< number of bits used for exponents
+
/* mantissa encoding */
- int mant1_cnt, mant2_cnt, mant4_cnt;
+ int mant1_cnt, mant2_cnt, mant4_cnt; ///< mantissa counts for bap=1,2,4
+ uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4
+
+ SampleType **planar_samples;
+ uint8_t *bap_buffer;
+ uint8_t *bap1_buffer;
+ CoefType *mdct_coef_buffer;
+ int32_t *fixed_coef_buffer;
+ uint8_t *exp_buffer;
+ uint8_t *grouped_exp_buffer;
+ int16_t *psd_buffer;
+ int16_t *band_psd_buffer;
+ int16_t *mask_buffer;
+ uint16_t *qmant_buffer;
+
+ uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies
+
+ DECLARE_ALIGNED(16, SampleType, windowed_samples)[AC3_WINDOW_SIZE];
} AC3EncodeContext;
-static int16_t costab[64];
-static int16_t sintab[64];
-static int16_t xcos1[128];
-static int16_t xsin1[128];
-#define MDCT_NBITS 9
-#define N (1 << MDCT_NBITS)
+/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */
+
+static av_cold void mdct_end(AC3MDCTContext *mdct);
-/* new exponents are sent if their Norm 1 exceed this number */
-#define EXP_DIFF_THRESHOLD 1000
+static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
+ int nbits);
-static inline int16_t fix15(float a)
+static void mdct512(AC3MDCTContext *mdct, CoefType *out, SampleType *in);
+
+static void apply_window(DSPContext *dsp, SampleType *output, const SampleType *input,
+ const SampleType *window, int n);
+
+static int normalize_samples(AC3EncodeContext *s);
+
+static void scale_coefficients(AC3EncodeContext *s);
+
+
+/**
+ * LUT for number of exponent groups.
+ * exponent_group_tab[exponent strategy-1][number of coefficients]
+ */
+static uint8_t exponent_group_tab[3][256];
+
+
+/**
+ * List of supported channel layouts.
+ */
+static const int64_t ac3_channel_layouts[] = {
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_2_1,
+ AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_2_2,
+ AV_CH_LAYOUT_QUAD,
+ AV_CH_LAYOUT_4POINT0,
+ AV_CH_LAYOUT_5POINT0,
+ AV_CH_LAYOUT_5POINT0_BACK,
+ (AV_CH_LAYOUT_MONO | AV_CH_LOW_FREQUENCY),
+ (AV_CH_LAYOUT_STEREO | AV_CH_LOW_FREQUENCY),
+ (AV_CH_LAYOUT_2_1 | AV_CH_LOW_FREQUENCY),
+ (AV_CH_LAYOUT_SURROUND | AV_CH_LOW_FREQUENCY),
+ (AV_CH_LAYOUT_2_2 | AV_CH_LOW_FREQUENCY),
+ (AV_CH_LAYOUT_QUAD | AV_CH_LOW_FREQUENCY),
+ (AV_CH_LAYOUT_4POINT0 | AV_CH_LOW_FREQUENCY),
+ AV_CH_LAYOUT_5POINT1,
+ AV_CH_LAYOUT_5POINT1_BACK,
+ 0
+};
+
+
+/**
+ * Adjust the frame size to make the average bit rate match the target bit rate.
+ * This is only needed for 11025, 22050, and 44100 sample rates.
+ */
+static void adjust_frame_size(AC3EncodeContext *s)
{
- int v;
- v = (int)(a * (float)(1 << 15));
- if (v < -32767)
- v = -32767;
- else if (v > 32767)
- v = 32767;
- return v;
+ while (s->bits_written >= s->bit_rate && s->samples_written >= s->sample_rate) {
+ s->bits_written -= s->bit_rate;
+ s->samples_written -= s->sample_rate;
+ }
+ s->frame_size = s->frame_size_min +
+ 2 * (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate);
+ s->bits_written += s->frame_size * 8;
+ s->samples_written += AC3_FRAME_SIZE;
}
-typedef struct IComplex {
- short re,im;
-} IComplex;
-static av_cold void fft_init(int ln)
+/**
+ * Deinterleave input samples.
+ * Channels are reordered from FFmpeg's default order to AC-3 order.
+ */
+static void deinterleave_input_samples(AC3EncodeContext *s,
+ const SampleType *samples)
{
- int i, n;
- float alpha;
+ int ch, i;
+
+ /* deinterleave and remap input samples */
+ for (ch = 0; ch < s->channels; ch++) {
+ const SampleType *sptr;
+ int sinc;
+
+ /* copy last 256 samples of previous frame to the start of the current frame */
+ memcpy(&s->planar_samples[ch][0], &s->planar_samples[ch][AC3_FRAME_SIZE],
+ AC3_BLOCK_SIZE * sizeof(s->planar_samples[0][0]));
+
+ /* deinterleave */
+ sinc = s->channels;
+ sptr = samples + s->channel_map[ch];
+ for (i = AC3_BLOCK_SIZE; i < AC3_FRAME_SIZE+AC3_BLOCK_SIZE; i++) {
+ s->planar_samples[ch][i] = *sptr;
+ sptr += sinc;
+ }
+ }
+}
+
+
+/**
+ * Apply the MDCT to input samples to generate frequency coefficients.
+ * This applies the KBD window and normalizes the input to reduce precision
+ * loss due to fixed-point calculations.
+ */
+static void apply_mdct(AC3EncodeContext *s)
+{
+ int blk, ch;
- n = 1 << ln;
+ for (ch = 0; ch < s->channels; ch++) {
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
- for(i=0;i<(n/2);i++) {
- alpha = 2 * M_PI * (float)i / (float)n;
- costab[i] = fix15(cos(alpha));
- sintab[i] = fix15(sin(alpha));
+ apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
+
+ block->exp_shift[ch] = normalize_samples(s);
+
+ mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples);
+ }
}
}
-/* butter fly op */
-#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
-{\
- int ax, ay, bx, by;\
- bx=pre1;\
- by=pim1;\
- ax=qre1;\
- ay=qim1;\
- pre = (bx + ax) >> 1;\
- pim = (by + ay) >> 1;\
- qre = (bx - ax) >> 1;\
- qim = (by - ay) >> 1;\
-}
-#define CMUL(pre, pim, are, aim, bre, bim) \
-{\
- pre = (MUL16(are, bre) - MUL16(aim, bim)) >> 15;\
- pim = (MUL16(are, bim) + MUL16(bre, aim)) >> 15;\
+/**
+ * Initialize stereo rematrixing.
+ * If the strategy does not change for each frame, set the rematrixing flags.
+ */
+static void rematrixing_init(AC3EncodeContext *s)
+{
+ if (s->channel_mode == AC3_CHMODE_STEREO)
+ s->rematrixing = AC3_REMATRIXING_SUMS;
+ else
+ s->rematrixing = AC3_REMATRIXING_NONE;
+ /* NOTE: AC3_REMATRIXING_ALWAYS might be used in
+ the future in conjunction with channel coupling. */
+
+ if (s->rematrixing & AC3_REMATRIXING_IS_STATIC) {
+ int flag = (s->rematrixing == AC3_REMATRIXING_ALWAYS);
+ s->blocks[0].new_rematrixing_strategy = 1;
+ memset(s->blocks[0].rematrixing_flags, flag,
+ sizeof(s->blocks[0].rematrixing_flags));
+ }
}
-/* do a 2^n point complex fft on 2^ln points. */
-static void fft(IComplex *z, int ln)
+/**
+ * Determine rematrixing flags for each block and band.
+ */
+static void compute_rematrixing_strategy(AC3EncodeContext *s)
{
- int j, l, np, np2;
- int nblocks, nloops;
- register IComplex *p,*q;
- int tmp_re, tmp_im;
-
- np = 1 << ln;
-
- /* reverse */
- for(j=0;j<np;j++) {
- int k = av_reverse[j] >> (8 - ln);
- if (k < j)
- FFSWAP(IComplex, z[k], z[j]);
- }
+ int nb_coefs;
+ int blk, bnd, i;
+ AC3Block *block, *block0;
+
+ if (s->rematrixing & AC3_REMATRIXING_IS_STATIC)
+ return;
- /* pass 0 */
-
- p=&z[0];
- j=(np >> 1);
- do {
- BF(p[0].re, p[0].im, p[1].re, p[1].im,
- p[0].re, p[0].im, p[1].re, p[1].im);
- p+=2;
- } while (--j != 0);
-
- /* pass 1 */
-
- p=&z[0];
- j=np >> 2;
- do {
- BF(p[0].re, p[0].im, p[2].re, p[2].im,
- p[0].re, p[0].im, p[2].re, p[2].im);
- BF(p[1].re, p[1].im, p[3].re, p[3].im,
- p[1].re, p[1].im, p[3].im, -p[3].re);
- p+=4;
- } while (--j != 0);
-
- /* pass 2 .. ln-1 */
-
- nblocks = np >> 3;
- nloops = 1 << 2;
- np2 = np >> 1;
- do {
- p = z;
- q = z + nloops;
- for (j = 0; j < nblocks; ++j) {
-
- BF(p->re, p->im, q->re, q->im,
- p->re, p->im, q->re, q->im);
-
- p++;
- q++;
- for(l = nblocks; l < np2; l += nblocks) {
- CMUL(tmp_re, tmp_im, costab[l], -sintab[l], q->re, q->im);
- BF(p->re, p->im, q->re, q->im,
- p->re, p->im, tmp_re, tmp_im);
- p++;
- q++;
+ nb_coefs = FFMIN(s->nb_coefs[0], s->nb_coefs[1]);
+
+ s->blocks[0].new_rematrixing_strategy = 1;
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ block = &s->blocks[blk];
+ for (bnd = 0; bnd < 4; bnd++) {
+ /* calculate calculate sum of squared coeffs for one band in one block */
+ int start = ff_ac3_rematrix_band_tab[bnd];
+ int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
+ CoefSumType sum[4] = {0,};
+ for (i = start; i < end; i++) {
+ CoefType lt = block->mdct_coef[0][i];
+ CoefType rt = block->mdct_coef[1][i];
+ CoefType md = lt + rt;
+ CoefType sd = lt - rt;
+ sum[0] += lt * lt;
+ sum[1] += rt * rt;
+ sum[2] += md * md;
+ sum[3] += sd * sd;
+ }
+
+ /* compare sums to determine if rematrixing will be used for this band */
+ if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))
+ block->rematrixing_flags[bnd] = 1;
+ else
+ block->rematrixing_flags[bnd] = 0;
+
+ /* determine if new rematrixing flags will be sent */
+ if (blk &&
+ !block->new_rematrixing_strategy &&
+ block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) {
+ block->new_rematrixing_strategy = 1;
}
- p += nloops;
- q += nloops;
}
- nblocks = nblocks >> 1;
- nloops = nloops << 1;
- } while (nblocks != 0);
+ block0 = block;
+ }
}
-/* do a 512 point mdct */
-static void mdct512(int32_t *out, int16_t *in)
+
+/**
+ * Apply stereo rematrixing to coefficients based on rematrixing flags.
+ */
+static void apply_rematrixing(AC3EncodeContext *s)
{
- int i, re, im, re1, im1;
- int16_t rot[N];
- IComplex x[N/4];
-
- /* shift to simplify computations */
- for(i=0;i<N/4;i++)
- rot[i] = -in[i + 3*N/4];
- for(i=N/4;i<N;i++)
- rot[i] = in[i - N/4];
-
- /* pre rotation */
- for(i=0;i<N/4;i++) {
- re = ((int)rot[2*i] - (int)rot[N-1-2*i]) >> 1;
- im = -((int)rot[N/2+2*i] - (int)rot[N/2-1-2*i]) >> 1;
- CMUL(x[i].re, x[i].im, re, im, -xcos1[i], xsin1[i]);
+ int nb_coefs;
+ int blk, bnd, i;
+ int start, end;
+ uint8_t *flags;
+
+ if (s->rematrixing == AC3_REMATRIXING_NONE)
+ return;
+
+ nb_coefs = FFMIN(s->nb_coefs[0], s->nb_coefs[1]);
+
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ if (block->new_rematrixing_strategy)
+ flags = block->rematrixing_flags;
+ for (bnd = 0; bnd < 4; bnd++) {
+ if (flags[bnd]) {
+ start = ff_ac3_rematrix_band_tab[bnd];
+ end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
+ for (i = start; i < end; i++) {
+ int32_t lt = block->fixed_coef[0][i];
+ int32_t rt = block->fixed_coef[1][i];
+ block->fixed_coef[0][i] = (lt + rt) >> 1;
+ block->fixed_coef[1][i] = (lt - rt) >> 1;
+ }
+ }
+ }
}
+}
- fft(x, MDCT_NBITS - 2);
- /* post rotation */
- for(i=0;i<N/4;i++) {
- re = x[i].re;
- im = x[i].im;
- CMUL(re1, im1, re, im, xsin1[i], xcos1[i]);
- out[2*i] = im1;
- out[N/2-1-2*i] = re1;
+/**
+ * Initialize exponent tables.
+ */
+static av_cold void exponent_init(AC3EncodeContext *s)
+{
+ int i;
+ for (i = 73; i < 256; i++) {
+ exponent_group_tab[0][i] = (i - 1) / 3;
+ exponent_group_tab[1][i] = (i + 2) / 6;
+ exponent_group_tab[2][i] = (i + 8) / 12;
}
+ /* LFE */
+ exponent_group_tab[0][7] = 2;
}
-/* XXX: use another norm ? */
-static int calc_exp_diff(uint8_t *exp1, uint8_t *exp2, int n)
+
+/**
+ * Extract exponents from the MDCT coefficients.
+ * This takes into account the normalization that was done to the input samples
+ * by adjusting the exponents by the exponent shift values.
+ */
+static void extract_exponents(AC3EncodeContext *s)
{
- int sum, i;
- sum = 0;
- for(i=0;i<n;i++) {
- sum += abs(exp1[i] - exp2[i]);
+ int blk, ch, i;
+
+ for (ch = 0; ch < s->channels; ch++) {
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ uint8_t *exp = block->exp[ch];
+ int32_t *coef = block->fixed_coef[ch];
+ int exp_shift = block->exp_shift[ch];
+ for (i = 0; i < AC3_MAX_COEFS; i++) {
+ int e;
+ int v = abs(coef[i]);
+ if (v == 0)
+ e = 24;
+ else {
+ e = 23 - av_log2(v) + exp_shift;
+ if (e >= 24) {
+ e = 24;
+ coef[i] = 0;
+ }
+ }
+ exp[i] = e;
+ }
+ }
}
- return sum;
}
-static void compute_exp_strategy(uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
- uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- int ch, int is_lfe)
+
+/**
+ * Exponent Difference Threshold.
+ * New exponents are sent if their SAD exceed this number.
+ */
+#define EXP_DIFF_THRESHOLD 500
+
+
+/**
+ * Calculate exponent strategies for all blocks in a single channel.
+ */
+static void compute_exp_strategy_ch(AC3EncodeContext *s, uint8_t *exp_strategy,
+ uint8_t *exp)
{
- int i, j;
+ int blk, blk1;
int exp_diff;
/* estimate if the exponent variation & decide if they should be
reused in the next frame */
- exp_strategy[0][ch] = EXP_NEW;
- for(i=1;i<NB_BLOCKS;i++) {
- exp_diff = calc_exp_diff(exp[i][ch], exp[i-1][ch], N/2);
- dprintf(NULL, "exp_diff=%d\n", exp_diff);
+ exp_strategy[0] = EXP_NEW;
+ exp += AC3_MAX_COEFS;
+ for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) {
+ exp_diff = s->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16);
if (exp_diff > EXP_DIFF_THRESHOLD)
- exp_strategy[i][ch] = EXP_NEW;
+ exp_strategy[blk] = EXP_NEW;
else
- exp_strategy[i][ch] = EXP_REUSE;
+ exp_strategy[blk] = EXP_REUSE;
+ exp += AC3_MAX_COEFS;
}
- if (is_lfe)
- return;
+ emms_c();
/* now select the encoding strategy type : if exponents are often
recoded, we use a coarse encoding */
- i = 0;
- while (i < NB_BLOCKS) {
- j = i + 1;
- while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE)
- j++;
- switch(j - i) {
- case 1:
- exp_strategy[i][ch] = EXP_D45;
- break;
+ blk = 0;
+ while (blk < AC3_MAX_BLOCKS) {
+ blk1 = blk + 1;
+ while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE)
+ blk1++;
+ switch (blk1 - blk) {
+ case 1: exp_strategy[blk] = EXP_D45; break;
case 2:
- case 3:
- exp_strategy[i][ch] = EXP_D25;
- break;
- default:
- exp_strategy[i][ch] = EXP_D15;
- break;
+ case 3: exp_strategy[blk] = EXP_D25; break;
+ default: exp_strategy[blk] = EXP_D15; break;
}
- i = j;
+ blk = blk1;
}
}
-/* set exp[i] to min(exp[i], exp1[i]) */
-static void exponent_min(uint8_t exp[N/2], uint8_t exp1[N/2], int n)
+
+/**
+ * Calculate exponent strategies for all channels.
+ * Array arrangement is reversed to simplify the per-channel calculation.
+ */
+static void compute_exp_strategy(AC3EncodeContext *s)
{
- int i;
+ int ch, blk;
+
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ compute_exp_strategy_ch(s, s->exp_strategy[ch], s->blocks[0].exp[ch]);
+ }
+ if (s->lfe_on) {
+ ch = s->lfe_channel;
+ s->exp_strategy[ch][0] = EXP_D15;
+ for (blk = 1; blk < AC3_MAX_BLOCKS; blk++)
+ s->exp_strategy[ch][blk] = EXP_REUSE;
+ }
+}
+
+
+/**
+ * Set each encoded exponent in a block to the minimum of itself and the
+ * exponents in the same frequency bin of up to 5 following blocks.
+ */
+static void exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
+{
+ int blk, i;
+
+ if (!num_reuse_blocks)
+ return;
- for(i=0;i<n;i++) {
- if (exp1[i] < exp[i])
- exp[i] = exp1[i];
+ for (i = 0; i < nb_coefs; i++) {
+ uint8_t min_exp = *exp;
+ uint8_t *exp1 = exp + AC3_MAX_COEFS;
+ for (blk = 0; blk < num_reuse_blocks; blk++) {
+ uint8_t next_exp = *exp1;
+ if (next_exp < min_exp)
+ min_exp = next_exp;
+ exp1 += AC3_MAX_COEFS;
+ }
+ *exp++ = min_exp;
}
}
-/* update the exponents so that they are the ones the decoder will
- decode. Return the number of bits used to code the exponents */
-static int encode_exp(uint8_t encoded_exp[N/2],
- uint8_t exp[N/2],
- int nb_exps,
- int exp_strategy)
+
+/**
+ * Update the exponents so that they are the ones the decoder will decode.
+ */
+static void encode_exponents_blk_ch(uint8_t *exp, int nb_exps, int exp_strategy)
{
- int group_size, nb_groups, i, j, k, exp_min;
- uint8_t exp1[N/2];
+ int nb_groups, i, k;
+
+ nb_groups = exponent_group_tab[exp_strategy-1][nb_exps] * 3;
+ /* for each group, compute the minimum exponent */
switch(exp_strategy) {
- case EXP_D15:
- group_size = 1;
- break;
case EXP_D25:
- group_size = 2;
+ for (i = 1, k = 1; i <= nb_groups; i++) {
+ uint8_t exp_min = exp[k];
+ if (exp[k+1] < exp_min)
+ exp_min = exp[k+1];
+ exp[i] = exp_min;
+ k += 2;
+ }
break;
- default:
case EXP_D45:
- group_size = 4;
- break;
- }
- nb_groups = ((nb_exps + (group_size * 3) - 4) / (3 * group_size)) * 3;
-
- /* for each group, compute the minimum exponent */
- exp1[0] = exp[0]; /* DC exponent is handled separately */
- k = 1;
- for(i=1;i<=nb_groups;i++) {
- exp_min = exp[k];
- assert(exp_min >= 0 && exp_min <= 24);
- for(j=1;j<group_size;j++) {
- if (exp[k+j] < exp_min)
- exp_min = exp[k+j];
+ for (i = 1, k = 1; i <= nb_groups; i++) {
+ uint8_t exp_min = exp[k];
+ if (exp[k+1] < exp_min)
+ exp_min = exp[k+1];
+ if (exp[k+2] < exp_min)
+ exp_min = exp[k+2];
+ if (exp[k+3] < exp_min)
+ exp_min = exp[k+3];
+ exp[i] = exp_min;
+ k += 4;
}
- exp1[i] = exp_min;
- k += group_size;
+ break;
}
/* constraint for DC exponent */
- if (exp1[0] > 15)
- exp1[0] = 15;
+ if (exp[0] > 15)
+ exp[0] = 15;
- /* Decrease the delta between each groups to within 2
- * so that they can be differentially encoded */
- for (i=1;i<=nb_groups;i++)
- exp1[i] = FFMIN(exp1[i], exp1[i-1] + 2);
- for (i=nb_groups-1;i>=0;i--)
- exp1[i] = FFMIN(exp1[i], exp1[i+1] + 2);
+ /* decrease the delta between each groups to within 2 so that they can be
+ differentially encoded */
+ for (i = 1; i <= nb_groups; i++)
+ exp[i] = FFMIN(exp[i], exp[i-1] + 2);
+ i--;
+ while (--i >= 0)
+ exp[i] = FFMIN(exp[i], exp[i+1] + 2);
/* now we have the exponent values the decoder will see */
- encoded_exp[0] = exp1[0];
- k = 1;
- for(i=1;i<=nb_groups;i++) {
- for(j=0;j<group_size;j++) {
- encoded_exp[k+j] = exp1[i];
+ switch (exp_strategy) {
+ case EXP_D25:
+ for (i = nb_groups, k = nb_groups * 2; i > 0; i--) {
+ uint8_t exp1 = exp[i];
+ exp[k--] = exp1;
+ exp[k--] = exp1;
}
- k += group_size;
- }
-
-#if defined(DEBUG)
- av_log(NULL, AV_LOG_DEBUG, "exponents: strategy=%d\n", exp_strategy);
- for(i=0;i<=nb_groups * group_size;i++) {
- av_log(NULL, AV_LOG_DEBUG, "%d ", encoded_exp[i]);
+ break;
+ case EXP_D45:
+ for (i = nb_groups, k = nb_groups * 4; i > 0; i--) {
+ exp[k] = exp[k-1] = exp[k-2] = exp[k-3] = exp[i];
+ k -= 4;
+ }
+ break;
}
- av_log(NULL, AV_LOG_DEBUG, "\n");
-#endif
-
- return 4 + (nb_groups / 3) * 7;
}
-/* return the size in bits taken by the mantissa */
-static int compute_mantissa_size(AC3EncodeContext *s, uint8_t *m, int nb_coefs)
+
+/**
+ * Encode exponents from original extracted form to what the decoder will see.
+ * This copies and groups exponents based on exponent strategy and reduces
+ * deltas between adjacent exponent groups so that they can be differentially
+ * encoded.
+ */
+static void encode_exponents(AC3EncodeContext *s)
{
- int bits, mant, i;
+ int blk, blk1, ch;
+ uint8_t *exp, *exp1, *exp_strategy;
+ int nb_coefs, num_reuse_blocks;
- bits = 0;
- for(i=0;i<nb_coefs;i++) {
- mant = m[i];
- switch(mant) {
- case 0:
- /* nothing */
- break;
- case 1:
- /* 3 mantissa in 5 bits */
- if (s->mant1_cnt == 0)
- bits += 5;
- if (++s->mant1_cnt == 3)
- s->mant1_cnt = 0;
- break;
- case 2:
- /* 3 mantissa in 7 bits */
- if (s->mant2_cnt == 0)
- bits += 7;
- if (++s->mant2_cnt == 3)
- s->mant2_cnt = 0;
- break;
- case 3:
- bits += 3;
- break;
- case 4:
- /* 2 mantissa in 7 bits */
- if (s->mant4_cnt == 0)
- bits += 7;
- if (++s->mant4_cnt == 2)
- s->mant4_cnt = 0;
- break;
- case 14:
- bits += 14;
- break;
- case 15:
- bits += 16;
- break;
- default:
- bits += mant - 1;
- break;
+ for (ch = 0; ch < s->channels; ch++) {
+ exp = s->blocks[0].exp[ch];
+ exp_strategy = s->exp_strategy[ch];
+ nb_coefs = s->nb_coefs[ch];
+
+ blk = 0;
+ while (blk < AC3_MAX_BLOCKS) {
+ blk1 = blk + 1;
+
+ /* count the number of EXP_REUSE blocks after the current block */
+ while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE)
+ blk1++;
+ num_reuse_blocks = blk1 - blk - 1;
+
+ /* for the EXP_REUSE case we select the min of the exponents */
+ exponent_min(exp, num_reuse_blocks, nb_coefs);
+
+ encode_exponents_blk_ch(exp, nb_coefs, exp_strategy[blk]);
+
+ /* copy encoded exponents for reuse case */
+ exp1 = exp + AC3_MAX_COEFS;
+ while (blk < blk1-1) {
+ memcpy(exp1, exp, nb_coefs * sizeof(*exp));
+ exp1 += AC3_MAX_COEFS;
+ blk++;
+ }
+ blk = blk1;
+ exp = exp1;
}
}
- return bits;
}
-static void bit_alloc_masking(AC3EncodeContext *s,
- uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
- int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50])
+/**
+ * Group exponents.
+ * 3 delta-encoded exponents are in each 7-bit group. The number of groups
+ * varies depending on exponent strategy and bandwidth.
+ */
+static void group_exponents(AC3EncodeContext *s)
{
- int blk, ch;
- int16_t band_psd[NB_BLOCKS][AC3_MAX_CHANNELS][50];
+ int blk, ch, i;
+ int group_size, nb_groups, bit_count;
+ uint8_t *p;
+ int delta0, delta1, delta2;
+ int exp0, exp1;
- for(blk=0; blk<NB_BLOCKS; blk++) {
- for(ch=0;ch<s->nb_all_channels;ch++) {
- if(exp_strategy[blk][ch] == EXP_REUSE) {
- memcpy(psd[blk][ch], psd[blk-1][ch], (N/2)*sizeof(int16_t));
- memcpy(mask[blk][ch], mask[blk-1][ch], 50*sizeof(int16_t));
- } else {
- ff_ac3_bit_alloc_calc_psd(encoded_exp[blk][ch], 0,
- s->nb_coefs[ch],
- psd[blk][ch], band_psd[blk][ch]);
- ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, band_psd[blk][ch],
- 0, s->nb_coefs[ch],
- ff_ac3_fast_gain_tab[s->fast_gain_code[ch]],
- ch == s->lfe_channel,
- DBA_NONE, 0, NULL, NULL, NULL,
- mask[blk][ch]);
+ bit_count = 0;
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ for (ch = 0; ch < s->channels; ch++) {
+ int exp_strategy = s->exp_strategy[ch][blk];
+ if (exp_strategy == EXP_REUSE)
+ continue;
+ group_size = exp_strategy + (exp_strategy == EXP_D45);
+ nb_groups = exponent_group_tab[exp_strategy-1][s->nb_coefs[ch]];
+ bit_count += 4 + (nb_groups * 7);
+ p = block->exp[ch];
+
+ /* DC exponent */
+ exp1 = *p++;
+ block->grouped_exp[ch][0] = exp1;
+
+ /* remaining exponents are delta encoded */
+ for (i = 1; i <= nb_groups; i++) {
+ /* merge three delta in one code */
+ exp0 = exp1;
+ exp1 = p[0];
+ p += group_size;
+ delta0 = exp1 - exp0 + 2;
+
+ exp0 = exp1;
+ exp1 = p[0];
+ p += group_size;
+ delta1 = exp1 - exp0 + 2;
+
+ exp0 = exp1;
+ exp1 = p[0];
+ p += group_size;
+ delta2 = exp1 - exp0 + 2;
+
+ block->grouped_exp[ch][i] = ((delta0 * 5 + delta1) * 5) + delta2;
}
}
}
+
+ s->exponent_bits = bit_count;
}
-static int bit_alloc(AC3EncodeContext *s,
- int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50],
- int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- int frame_bits, int coarse_snr_offset, int fine_snr_offset)
+
+/**
+ * Calculate final exponents from the supplied MDCT coefficients and exponent shift.
+ * Extract exponents from MDCT coefficients, calculate exponent strategies,
+ * and encode final exponents.
+ */
+static void process_exponents(AC3EncodeContext *s)
{
- int i, ch;
- int snr_offset;
-
- snr_offset = (((coarse_snr_offset - 15) << 4) + fine_snr_offset) << 2;
-
- /* compute size */
- for(i=0;i<NB_BLOCKS;i++) {
- s->mant1_cnt = 0;
- s->mant2_cnt = 0;
- s->mant4_cnt = 0;
- for(ch=0;ch<s->nb_all_channels;ch++) {
- ff_ac3_bit_alloc_calc_bap(mask[i][ch], psd[i][ch], 0,
- s->nb_coefs[ch], snr_offset,
- s->bit_alloc.floor, ff_ac3_bap_tab,
- bap[i][ch]);
- frame_bits += compute_mantissa_size(s, bap[i][ch],
- s->nb_coefs[ch]);
- }
- }
-#if 0
- printf("csnr=%d fsnr=%d frame_bits=%d diff=%d\n",
- coarse_snr_offset, fine_snr_offset, frame_bits,
- 16 * s->frame_size - ((frame_bits + 7) & ~7));
-#endif
- return 16 * s->frame_size - frame_bits;
+ extract_exponents(s);
+
+ compute_exp_strategy(s);
+
+ encode_exponents(s);
+
+ group_exponents(s);
}
-#define SNR_INC1 4
-static int compute_bit_allocation(AC3EncodeContext *s,
- uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
- int frame_bits)
+/**
+ * Count frame bits that are based solely on fixed parameters.
+ * This only has to be run once when the encoder is initialized.
+ */
+static void count_frame_bits_fixed(AC3EncodeContext *s)
{
- int i, ch;
- int coarse_snr_offset, fine_snr_offset;
- uint8_t bap1[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
- int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
- int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50];
static const int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };
+ int blk;
+ int frame_bits;
- /* init default parameters */
- s->slow_decay_code = 2;
- s->fast_decay_code = 1;
- s->slow_gain_code = 1;
- s->db_per_bit_code = 2;
- s->floor_code = 4;
- for(ch=0;ch<s->nb_all_channels;ch++)
- s->fast_gain_code[ch] = 4;
-
- /* compute real values */
- s->bit_alloc.sr_code = s->sr_code;
- s->bit_alloc.sr_shift = s->sr_shift;
- s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->sr_shift;
- s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->sr_shift;
- s->bit_alloc.slow_gain = ff_ac3_slow_gain_tab[s->slow_gain_code];
- s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code];
- s->bit_alloc.floor = ff_ac3_floor_tab[s->floor_code];
+ /* assumptions:
+ * no dynamic range codes
+ * no channel coupling
+ * bit allocation parameters do not change between blocks
+ * SNR offsets do not change between blocks
+ * no delta bit allocation
+ * no skipped data
+ * no auxilliary data
+ */
/* header size */
- frame_bits += 65;
- // if (s->channel_mode == 2)
- // frame_bits += 2;
+ frame_bits = 65;
frame_bits += frame_bits_inc[s->channel_mode];
/* audio blocks */
- for(i=0;i<NB_BLOCKS;i++) {
- frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ frame_bits += s->fbw_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */
if (s->channel_mode == AC3_CHMODE_STEREO) {
frame_bits++; /* rematstr */
- if(i==0) frame_bits += 4;
}
- frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */
- if (s->lfe)
+ frame_bits += 2 * s->fbw_channels; /* chexpstr[2] * c */
+ if (s->lfe_on)
frame_bits++; /* lfeexpstr */
- for(ch=0;ch<s->nb_channels;ch++) {
- if (exp_strategy[i][ch] != EXP_REUSE)
- frame_bits += 6 + 2; /* chbwcod[6], gainrng[2] */
- }
frame_bits++; /* baie */
frame_bits++; /* snr */
frame_bits += 2; /* delta / skip */
@@ -538,7 +749,7 @@ static int compute_bit_allocation(AC3EncodeContext *s,
/* sdcycod[2], fdcycod[2], sgaincod[2], dbpbcod[2], floorcod[3] */
/* csnroffset[6] */
/* (fsnoffset[4] + fgaincod[4]) * c */
- frame_bits += 2*4 + 3 + 6 + s->nb_all_channels * (4 + 3);
+ frame_bits += 2*4 + 3 + 6 + s->channels * (4 + 3);
/* auxdatae, crcrsv */
frame_bits += 2;
@@ -546,231 +757,357 @@ static int compute_bit_allocation(AC3EncodeContext *s,
/* CRC */
frame_bits += 16;
- /* calculate psd and masking curve before doing bit allocation */
- bit_alloc_masking(s, encoded_exp, exp_strategy, psd, mask);
+ s->frame_bits_fixed = frame_bits;
+}
- /* now the big work begins : do the bit allocation. Modify the snr
- offset until we can pack everything in the requested frame size */
- coarse_snr_offset = s->coarse_snr_offset;
- while (coarse_snr_offset >= 0 &&
- bit_alloc(s, mask, psd, bap, frame_bits, coarse_snr_offset, 0) < 0)
- coarse_snr_offset -= SNR_INC1;
- if (coarse_snr_offset < 0) {
- av_log(NULL, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
- return -1;
- }
- while ((coarse_snr_offset + SNR_INC1) <= 63 &&
- bit_alloc(s, mask, psd, bap1, frame_bits,
- coarse_snr_offset + SNR_INC1, 0) >= 0) {
- coarse_snr_offset += SNR_INC1;
- memcpy(bap, bap1, sizeof(bap1));
- }
- while ((coarse_snr_offset + 1) <= 63 &&
- bit_alloc(s, mask, psd, bap1, frame_bits, coarse_snr_offset + 1, 0) >= 0) {
- coarse_snr_offset++;
- memcpy(bap, bap1, sizeof(bap1));
- }
+/**
+ * Initialize bit allocation.
+ * Set default parameter codes and calculate parameter values.
+ */
+static void bit_alloc_init(AC3EncodeContext *s)
+{
+ int ch;
- fine_snr_offset = 0;
- while ((fine_snr_offset + SNR_INC1) <= 15 &&
- bit_alloc(s, mask, psd, bap1, frame_bits,
- coarse_snr_offset, fine_snr_offset + SNR_INC1) >= 0) {
- fine_snr_offset += SNR_INC1;
- memcpy(bap, bap1, sizeof(bap1));
- }
- while ((fine_snr_offset + 1) <= 15 &&
- bit_alloc(s, mask, psd, bap1, frame_bits,
- coarse_snr_offset, fine_snr_offset + 1) >= 0) {
- fine_snr_offset++;
- memcpy(bap, bap1, sizeof(bap1));
+ /* init default parameters */
+ s->slow_decay_code = 2;
+ s->fast_decay_code = 1;
+ s->slow_gain_code = 1;
+ s->db_per_bit_code = 3;
+ s->floor_code = 4;
+ for (ch = 0; ch < s->channels; ch++)
+ s->fast_gain_code[ch] = 4;
+
+ /* initial snr offset */
+ s->coarse_snr_offset = 40;
+
+ /* compute real values */
+ /* currently none of these values change during encoding, so we can just
+ set them once at initialization */
+ s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->bit_alloc.sr_shift;
+ s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->bit_alloc.sr_shift;
+ s->bit_alloc.slow_gain = ff_ac3_slow_gain_tab[s->slow_gain_code];
+ s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code];
+ s->bit_alloc.floor = ff_ac3_floor_tab[s->floor_code];
+
+ count_frame_bits_fixed(s);
+}
+
+
+/**
+ * Count the bits used to encode the frame, minus exponents and mantissas.
+ * Bits based on fixed parameters have already been counted, so now we just
+ * have to add the bits based on parameters that change during encoding.
+ */
+static void count_frame_bits(AC3EncodeContext *s)
+{
+ int blk, ch;
+ int frame_bits = 0;
+
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ /* stereo rematrixing */
+ if (s->channel_mode == AC3_CHMODE_STEREO &&
+ s->blocks[blk].new_rematrixing_strategy) {
+ frame_bits += 4;
+ }
+
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ if (s->exp_strategy[ch][blk] != EXP_REUSE)
+ frame_bits += 6 + 2; /* chbwcod[6], gainrng[2] */
+ }
}
+ s->frame_bits = s->frame_bits_fixed + frame_bits;
+}
- s->coarse_snr_offset = coarse_snr_offset;
- for(ch=0;ch<s->nb_all_channels;ch++)
- s->fine_snr_offset[ch] = fine_snr_offset;
-#if defined(DEBUG_BITALLOC)
- {
- int j;
-
- for(i=0;i<6;i++) {
- for(ch=0;ch<s->nb_all_channels;ch++) {
- printf("Block #%d Ch%d:\n", i, ch);
- printf("bap=");
- for(j=0;j<s->nb_coefs[ch];j++) {
- printf("%d ",bap[i][ch][j]);
- }
- printf("\n");
- }
+
+/**
+ * Calculate the number of bits needed to encode a set of mantissas.
+ */
+static int compute_mantissa_size(int mant_cnt[5], uint8_t *bap, int nb_coefs)
+{
+ int bits, b, i;
+
+ bits = 0;
+ for (i = 0; i < nb_coefs; i++) {
+ b = bap[i];
+ if (b <= 4) {
+ // bap=1 to bap=4 will be counted in compute_mantissa_size_final
+ mant_cnt[b]++;
+ } else if (b <= 13) {
+ // bap=5 to bap=13 use (bap-1) bits
+ bits += b - 1;
+ } else {
+ // bap=14 uses 14 bits and bap=15 uses 16 bits
+ bits += (b == 14) ? 14 : 16;
}
}
-#endif
- return 0;
+ return bits;
}
-static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
- int64_t *channel_layout)
+
+/**
+ * Finalize the mantissa bit count by adding in the grouped mantissas.
+ */
+static int compute_mantissa_size_final(int mant_cnt[5])
{
- int ch_layout;
+ // bap=1 : 3 mantissas in 5 bits
+ int bits = (mant_cnt[1] / 3) * 5;
+ // bap=2 : 3 mantissas in 7 bits
+ // bap=4 : 2 mantissas in 7 bits
+ bits += ((mant_cnt[2] / 3) + (mant_cnt[4] >> 1)) * 7;
+ // bap=3 : each mantissa is 3 bits
+ bits += mant_cnt[3] * 3;
+ return bits;
+}
- if (channels < 1 || channels > AC3_MAX_CHANNELS)
- return -1;
- if ((uint64_t)*channel_layout > 0x7FF)
- return -1;
- ch_layout = *channel_layout;
- if (!ch_layout)
- ch_layout = avcodec_guess_channel_layout(channels, CODEC_ID_AC3, NULL);
- if (avcodec_channel_layout_num_channels(ch_layout) != channels)
- return -1;
- s->lfe = !!(ch_layout & CH_LOW_FREQUENCY);
- s->nb_all_channels = channels;
- s->nb_channels = channels - s->lfe;
- s->lfe_channel = s->lfe ? s->nb_channels : -1;
- if (s->lfe)
- ch_layout -= CH_LOW_FREQUENCY;
+/**
+ * Calculate masking curve based on the final exponents.
+ * Also calculate the power spectral densities to use in future calculations.
+ */
+static void bit_alloc_masking(AC3EncodeContext *s)
+{
+ int blk, ch;
- switch (ch_layout) {
- case CH_LAYOUT_MONO: s->channel_mode = AC3_CHMODE_MONO; break;
- case CH_LAYOUT_STEREO: s->channel_mode = AC3_CHMODE_STEREO; break;
- case CH_LAYOUT_SURROUND: s->channel_mode = AC3_CHMODE_3F; break;
- case CH_LAYOUT_2_1: s->channel_mode = AC3_CHMODE_2F1R; break;
- case CH_LAYOUT_4POINT0: s->channel_mode = AC3_CHMODE_3F1R; break;
- case CH_LAYOUT_QUAD:
- case CH_LAYOUT_2_2: s->channel_mode = AC3_CHMODE_2F2R; break;
- case CH_LAYOUT_5POINT0:
- case CH_LAYOUT_5POINT0_BACK: s->channel_mode = AC3_CHMODE_3F2R; break;
- default:
- return -1;
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ for (ch = 0; ch < s->channels; ch++) {
+ /* We only need psd and mask for calculating bap.
+ Since we currently do not calculate bap when exponent
+ strategy is EXP_REUSE we do not need to calculate psd or mask. */
+ if (s->exp_strategy[ch][blk] != EXP_REUSE) {
+ ff_ac3_bit_alloc_calc_psd(block->exp[ch], 0,
+ s->nb_coefs[ch],
+ block->psd[ch], block->band_psd[ch]);
+ ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, block->band_psd[ch],
+ 0, s->nb_coefs[ch],
+ ff_ac3_fast_gain_tab[s->fast_gain_code[ch]],
+ ch == s->lfe_channel,
+ DBA_NONE, 0, NULL, NULL, NULL,
+ block->mask[ch]);
+ }
+ }
}
+}
- s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe];
- *channel_layout = ch_layout;
- if (s->lfe)
- *channel_layout |= CH_LOW_FREQUENCY;
- return 0;
+/**
+ * Ensure that bap for each block and channel point to the current bap_buffer.
+ * They may have been switched during the bit allocation search.
+ */
+static void reset_block_bap(AC3EncodeContext *s)
+{
+ int blk, ch;
+ if (s->blocks[0].bap[0] == s->bap_buffer)
+ return;
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ for (ch = 0; ch < s->channels; ch++) {
+ s->blocks[blk].bap[ch] = &s->bap_buffer[AC3_MAX_COEFS * (blk * s->channels + ch)];
+ }
+ }
}
-static av_cold int AC3_encode_init(AVCodecContext *avctx)
+
+/**
+ * Run the bit allocation with a given SNR offset.
+ * This calculates the bit allocation pointers that will be used to determine
+ * the quantization of each mantissa.
+ * @return the number of bits needed for mantissas if the given SNR offset is
+ * is used.
+ */
+static int bit_alloc(AC3EncodeContext *s, int snr_offset)
{
- int freq = avctx->sample_rate;
- int bitrate = avctx->bit_rate;
- AC3EncodeContext *s = avctx->priv_data;
- int i, j, ch;
- float alpha;
- int bw_code;
+ int blk, ch;
+ int mantissa_bits;
+ int mant_cnt[5];
+
+ snr_offset = (snr_offset - 240) << 2;
+
+ reset_block_bap(s);
+ mantissa_bits = 0;
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ // initialize grouped mantissa counts. these are set so that they are
+ // padded to the next whole group size when bits are counted in
+ // compute_mantissa_size_final
+ mant_cnt[0] = mant_cnt[3] = 0;
+ mant_cnt[1] = mant_cnt[2] = 2;
+ mant_cnt[4] = 1;
+ for (ch = 0; ch < s->channels; ch++) {
+ /* Currently the only bit allocation parameters which vary across
+ blocks within a frame are the exponent values. We can take
+ advantage of that by reusing the bit allocation pointers
+ whenever we reuse exponents. */
+ if (s->exp_strategy[ch][blk] == EXP_REUSE) {
+ memcpy(block->bap[ch], s->blocks[blk-1].bap[ch], AC3_MAX_COEFS);
+ } else {
+ ff_ac3_bit_alloc_calc_bap(block->mask[ch], block->psd[ch], 0,
+ s->nb_coefs[ch], snr_offset,
+ s->bit_alloc.floor, ff_ac3_bap_tab,
+ block->bap[ch]);
+ }
+ mantissa_bits += compute_mantissa_size(mant_cnt, block->bap[ch], s->nb_coefs[ch]);
+ }
+ mantissa_bits += compute_mantissa_size_final(mant_cnt);
+ }
+ return mantissa_bits;
+}
- avctx->frame_size = AC3_FRAME_SIZE;
- ac3_common_init();
+/**
+ * Constant bitrate bit allocation search.
+ * Find the largest SNR offset that will allow data to fit in the frame.
+ */
+static int cbr_bit_allocation(AC3EncodeContext *s)
+{
+ int ch;
+ int bits_left;
+ int snr_offset, snr_incr;
- if (!avctx->channel_layout) {
- av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
- "encoder will guess the layout, but it "
- "might be incorrect.\n");
- }
- if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) {
- av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");
- return -1;
- }
+ bits_left = 8 * s->frame_size - (s->frame_bits + s->exponent_bits);
- /* frequency */
- for(i=0;i<3;i++) {
- for(j=0;j<3;j++)
- if ((ff_ac3_sample_rate_tab[j] >> i) == freq)
- goto found;
+ snr_offset = s->coarse_snr_offset << 4;
+
+ /* if previous frame SNR offset was 1023, check if current frame can also
+ use SNR offset of 1023. if so, skip the search. */
+ if ((snr_offset | s->fine_snr_offset[0]) == 1023) {
+ if (bit_alloc(s, 1023) <= bits_left)
+ return 0;
}
- return -1;
- found:
- s->sample_rate = freq;
- s->sr_shift = i;
- s->sr_code = j;
- s->bitstream_id = 8 + s->sr_shift;
- s->bitstream_mode = 0; /* complete main audio service */
- /* bitrate & frame size */
- for(i=0;i<19;i++) {
- if ((ff_ac3_bitrate_tab[i] >> s->sr_shift)*1000 == bitrate)
- break;
+ while (snr_offset >= 0 &&
+ bit_alloc(s, snr_offset) > bits_left) {
+ snr_offset -= 64;
}
- if (i == 19)
- return -1;
- s->bit_rate = bitrate;
- s->frame_size_code = i << 1;
- s->frame_size_min = ff_ac3_frame_size_tab[s->frame_size_code][s->sr_code];
- s->bits_written = 0;
- s->samples_written = 0;
- s->frame_size = s->frame_size_min;
+ if (snr_offset < 0)
+ return AVERROR(EINVAL);
+
+ FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
+ for (snr_incr = 64; snr_incr > 0; snr_incr >>= 2) {
+ while (snr_offset + snr_incr <= 1023 &&
+ bit_alloc(s, snr_offset + snr_incr) <= bits_left) {
+ snr_offset += snr_incr;
+ FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
+ }
+ }
+ FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
+ reset_block_bap(s);
- /* bit allocation init */
- if(avctx->cutoff) {
- /* calculate bandwidth based on user-specified cutoff frequency */
- int cutoff = av_clip(avctx->cutoff, 1, s->sample_rate >> 1);
- int fbw_coeffs = cutoff * 512 / s->sample_rate;
- bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
- } else {
- /* use default bandwidth setting */
- /* XXX: should compute the bandwidth according to the frame
- size, so that we avoid annoying high frequency artifacts */
- bw_code = 50;
+ s->coarse_snr_offset = snr_offset >> 4;
+ for (ch = 0; ch < s->channels; ch++)
+ s->fine_snr_offset[ch] = snr_offset & 0xF;
+
+ return 0;
+}
+
+
+/**
+ * Downgrade exponent strategies to reduce the bits used by the exponents.
+ * This is a fallback for when bit allocation fails with the normal exponent
+ * strategies. Each time this function is run it only downgrades the
+ * strategy in 1 channel of 1 block.
+ * @return non-zero if downgrade was unsuccessful
+ */
+static int downgrade_exponents(AC3EncodeContext *s)
+{
+ int ch, blk;
+
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ for (blk = AC3_MAX_BLOCKS-1; blk >= 0; blk--) {
+ if (s->exp_strategy[ch][blk] == EXP_D15) {
+ s->exp_strategy[ch][blk] = EXP_D25;
+ return 0;
+ }
+ }
}
- for(ch=0;ch<s->nb_channels;ch++) {
- /* bandwidth for each channel */
- s->chbwcod[ch] = bw_code;
- s->nb_coefs[ch] = bw_code * 3 + 73;
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ for (blk = AC3_MAX_BLOCKS-1; blk >= 0; blk--) {
+ if (s->exp_strategy[ch][blk] == EXP_D25) {
+ s->exp_strategy[ch][blk] = EXP_D45;
+ return 0;
+ }
+ }
}
- if (s->lfe) {
- s->nb_coefs[s->lfe_channel] = 7; /* fixed */
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ /* block 0 cannot reuse exponents, so only downgrade D45 to REUSE if
+ the block number > 0 */
+ for (blk = AC3_MAX_BLOCKS-1; blk > 0; blk--) {
+ if (s->exp_strategy[ch][blk] > EXP_REUSE) {
+ s->exp_strategy[ch][blk] = EXP_REUSE;
+ return 0;
+ }
+ }
}
- /* initial snr offset */
- s->coarse_snr_offset = 40;
+ return -1;
+}
- /* mdct init */
- fft_init(MDCT_NBITS - 2);
- for(i=0;i<N/4;i++) {
- alpha = 2 * M_PI * (i + 1.0 / 8.0) / (float)N;
- xcos1[i] = fix15(-cos(alpha));
- xsin1[i] = fix15(-sin(alpha));
- }
- avctx->coded_frame= avcodec_alloc_frame();
- avctx->coded_frame->key_frame= 1;
+/**
+ * Reduce the bandwidth to reduce the number of bits used for a given SNR offset.
+ * This is a second fallback for when bit allocation still fails after exponents
+ * have been downgraded.
+ * @return non-zero if bandwidth reduction was unsuccessful
+ */
+static int reduce_bandwidth(AC3EncodeContext *s, int min_bw_code)
+{
+ int ch;
- return 0;
+ if (s->bandwidth_code[0] > min_bw_code) {
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ s->bandwidth_code[ch]--;
+ s->nb_coefs[ch] = s->bandwidth_code[ch] * 3 + 73;
+ }
+ return 0;
+ }
+ return -1;
}
-/* output the AC-3 frame header */
-static void output_frame_header(AC3EncodeContext *s, unsigned char *frame)
+
+/**
+ * Perform bit allocation search.
+ * Finds the SNR offset value that maximizes quality and fits in the specified
+ * frame size. Output is the SNR offset and a set of bit allocation pointers
+ * used to quantize the mantissas.
+ */
+static int compute_bit_allocation(AC3EncodeContext *s)
{
- init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
+ int ret;
- put_bits(&s->pb, 16, 0x0b77); /* frame header */
- put_bits(&s->pb, 16, 0); /* crc1: will be filled later */
- put_bits(&s->pb, 2, s->sr_code);
- put_bits(&s->pb, 6, s->frame_size_code + (s->frame_size - s->frame_size_min));
- put_bits(&s->pb, 5, s->bitstream_id);
- put_bits(&s->pb, 3, s->bitstream_mode);
- put_bits(&s->pb, 3, s->channel_mode);
- if ((s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO)
- put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */
- if (s->channel_mode & 0x04)
- put_bits(&s->pb, 2, 1); /* XXX -6 dB */
- if (s->channel_mode == AC3_CHMODE_STEREO)
- put_bits(&s->pb, 2, 0); /* surround not indicated */
- put_bits(&s->pb, 1, s->lfe); /* LFE */
- put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */
- put_bits(&s->pb, 1, 0); /* no compression control word */
- put_bits(&s->pb, 1, 0); /* no lang code */
- put_bits(&s->pb, 1, 0); /* no audio production info */
- put_bits(&s->pb, 1, 0); /* no copyright */
- put_bits(&s->pb, 1, 1); /* original bitstream */
- put_bits(&s->pb, 1, 0); /* no time code 1 */
- put_bits(&s->pb, 1, 0); /* no time code 2 */
- put_bits(&s->pb, 1, 0); /* no additional bit stream info */
+ count_frame_bits(s);
+
+ bit_alloc_masking(s);
+
+ ret = cbr_bit_allocation(s);
+ while (ret) {
+ /* fallback 1: downgrade exponents */
+ if (!downgrade_exponents(s)) {
+ extract_exponents(s);
+ encode_exponents(s);
+ group_exponents(s);
+ ret = compute_bit_allocation(s);
+ continue;
+ }
+
+ /* fallback 2: reduce bandwidth */
+ /* only do this if the user has not specified a specific cutoff
+ frequency */
+ if (!s->cutoff && !reduce_bandwidth(s, 0)) {
+ process_exponents(s);
+ ret = compute_bit_allocation(s);
+ continue;
+ }
+
+ /* fallbacks were not enough... */
+ break;
+ }
+
+ return ret;
}
-/* symetric quantization on 'levels' levels */
+
+/**
+ * Symmetric quantization on 'levels' levels.
+ */
static inline int sym_quant(int c, int e, int levels)
{
int v;
@@ -784,11 +1121,14 @@ static inline int sym_quant(int c, int e, int levels)
v = (v + 1) >> 1;
v = (levels >> 1) - v;
}
- assert (v >= 0 && v < levels);
+ assert(v >= 0 && v < levels);
return v;
}
-/* asymetric quantization on 2^qbits levels */
+
+/**
+ * Asymmetric quantization on 2^qbits levels.
+ */
static inline int asym_quant(int c, int e, int qbits)
{
int lshift, m, v;
@@ -807,126 +1147,225 @@ static inline int asym_quant(int c, int e, int qbits)
return v & ((1 << qbits)-1);
}
-/* Output one audio block. There are NB_BLOCKS audio blocks in one AC-3
- frame */
-static void output_audio_block(AC3EncodeContext *s,
- uint8_t exp_strategy[AC3_MAX_CHANNELS],
- uint8_t encoded_exp[AC3_MAX_CHANNELS][N/2],
- uint8_t bap[AC3_MAX_CHANNELS][N/2],
- int32_t mdct_coefs[AC3_MAX_CHANNELS][N/2],
- int8_t global_exp[AC3_MAX_CHANNELS],
- int block_num)
+
+/**
+ * Quantize a set of mantissas for a single channel in a single block.
+ */
+static void quantize_mantissas_blk_ch(AC3EncodeContext *s, int32_t *fixed_coef,
+ int8_t exp_shift, uint8_t *exp,
+ uint8_t *bap, uint16_t *qmant, int n)
{
- int ch, nb_groups, group_size, i, baie, rbnd;
- uint8_t *p;
- uint16_t qmant[AC3_MAX_CHANNELS][N/2];
- int exp0, exp1;
- int mant1_cnt, mant2_cnt, mant4_cnt;
- uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr;
- int delta0, delta1, delta2;
+ int i;
- for(ch=0;ch<s->nb_channels;ch++)
- put_bits(&s->pb, 1, 0); /* 512 point MDCT */
- for(ch=0;ch<s->nb_channels;ch++)
- put_bits(&s->pb, 1, 1); /* no dither */
- put_bits(&s->pb, 1, 0); /* no dynamic range */
- if (block_num == 0) {
- /* for block 0, even if no coupling, we must say it. This is a
- waste of bit :-) */
+ for (i = 0; i < n; i++) {
+ int v;
+ int c = fixed_coef[i];
+ int e = exp[i] - exp_shift;
+ int b = bap[i];
+ switch (b) {
+ case 0:
+ v = 0;
+ break;
+ case 1:
+ v = sym_quant(c, e, 3);
+ switch (s->mant1_cnt) {
+ case 0:
+ s->qmant1_ptr = &qmant[i];
+ v = 9 * v;
+ s->mant1_cnt = 1;
+ break;
+ case 1:
+ *s->qmant1_ptr += 3 * v;
+ s->mant1_cnt = 2;
+ v = 128;
+ break;
+ default:
+ *s->qmant1_ptr += v;
+ s->mant1_cnt = 0;
+ v = 128;
+ break;
+ }
+ break;
+ case 2:
+ v = sym_quant(c, e, 5);
+ switch (s->mant2_cnt) {
+ case 0:
+ s->qmant2_ptr = &qmant[i];
+ v = 25 * v;
+ s->mant2_cnt = 1;
+ break;
+ case 1:
+ *s->qmant2_ptr += 5 * v;
+ s->mant2_cnt = 2;
+ v = 128;
+ break;
+ default:
+ *s->qmant2_ptr += v;
+ s->mant2_cnt = 0;
+ v = 128;
+ break;
+ }
+ break;
+ case 3:
+ v = sym_quant(c, e, 7);
+ break;
+ case 4:
+ v = sym_quant(c, e, 11);
+ switch (s->mant4_cnt) {
+ case 0:
+ s->qmant4_ptr = &qmant[i];
+ v = 11 * v;
+ s->mant4_cnt = 1;
+ break;
+ default:
+ *s->qmant4_ptr += v;
+ s->mant4_cnt = 0;
+ v = 128;
+ break;
+ }
+ break;
+ case 5:
+ v = sym_quant(c, e, 15);
+ break;
+ case 14:
+ v = asym_quant(c, e, 14);
+ break;
+ case 15:
+ v = asym_quant(c, e, 16);
+ break;
+ default:
+ v = asym_quant(c, e, b - 1);
+ break;
+ }
+ qmant[i] = v;
+ }
+}
+
+
+/**
+ * Quantize mantissas using coefficients, exponents, and bit allocation pointers.
+ */
+static void quantize_mantissas(AC3EncodeContext *s)
+{
+ int blk, ch;
+
+
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ s->mant1_cnt = s->mant2_cnt = s->mant4_cnt = 0;
+ s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL;
+
+ for (ch = 0; ch < s->channels; ch++) {
+ quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch],
+ block->exp[ch], block->bap[ch],
+ block->qmant[ch], s->nb_coefs[ch]);
+ }
+ }
+}
+
+
+/**
+ * Write the AC-3 frame header to the output bitstream.
+ */
+static void output_frame_header(AC3EncodeContext *s)
+{
+ put_bits(&s->pb, 16, 0x0b77); /* frame header */
+ put_bits(&s->pb, 16, 0); /* crc1: will be filled later */
+ put_bits(&s->pb, 2, s->bit_alloc.sr_code);
+ put_bits(&s->pb, 6, s->frame_size_code + (s->frame_size - s->frame_size_min) / 2);
+ put_bits(&s->pb, 5, s->bitstream_id);
+ put_bits(&s->pb, 3, s->bitstream_mode);
+ put_bits(&s->pb, 3, s->channel_mode);
+ if ((s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO)
+ put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */
+ if (s->channel_mode & 0x04)
+ put_bits(&s->pb, 2, 1); /* XXX -6 dB */
+ if (s->channel_mode == AC3_CHMODE_STEREO)
+ put_bits(&s->pb, 2, 0); /* surround not indicated */
+ put_bits(&s->pb, 1, s->lfe_on); /* LFE */
+ put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */
+ put_bits(&s->pb, 1, 0); /* no compression control word */
+ put_bits(&s->pb, 1, 0); /* no lang code */
+ put_bits(&s->pb, 1, 0); /* no audio production info */
+ put_bits(&s->pb, 1, 0); /* no copyright */
+ put_bits(&s->pb, 1, 1); /* original bitstream */
+ put_bits(&s->pb, 1, 0); /* no time code 1 */
+ put_bits(&s->pb, 1, 0); /* no time code 2 */
+ put_bits(&s->pb, 1, 0); /* no additional bit stream info */
+}
+
+
+/**
+ * Write one audio block to the output bitstream.
+ */
+static void output_audio_block(AC3EncodeContext *s, int blk)
+{
+ int ch, i, baie, rbnd;
+ AC3Block *block = &s->blocks[blk];
+
+ /* block switching */
+ for (ch = 0; ch < s->fbw_channels; ch++)
+ put_bits(&s->pb, 1, 0);
+
+ /* dither flags */
+ for (ch = 0; ch < s->fbw_channels; ch++)
+ put_bits(&s->pb, 1, 1);
+
+ /* dynamic range codes */
+ put_bits(&s->pb, 1, 0);
+
+ /* channel coupling */
+ if (!blk) {
put_bits(&s->pb, 1, 1); /* coupling strategy present */
put_bits(&s->pb, 1, 0); /* no coupling strategy */
} else {
put_bits(&s->pb, 1, 0); /* no new coupling strategy */
}
- if (s->channel_mode == AC3_CHMODE_STEREO)
- {
- if(block_num==0)
- {
- /* first block must define rematrixing (rematstr) */
- put_bits(&s->pb, 1, 1);
-
- /* dummy rematrixing rematflg(1:4)=0 */
- for (rbnd=0;rbnd<4;rbnd++)
- put_bits(&s->pb, 1, 0);
- }
- else
- {
- /* no matrixing (but should be used in the future) */
- put_bits(&s->pb, 1, 0);
- }
- }
-
-#if defined(DEBUG)
- {
- static int count = 0;
- av_log(NULL, AV_LOG_DEBUG, "Block #%d (%d)\n", block_num, count++);
- }
-#endif
- /* exponent strategy */
- for(ch=0;ch<s->nb_channels;ch++) {
- put_bits(&s->pb, 2, exp_strategy[ch]);
- }
-
- if (s->lfe) {
- put_bits(&s->pb, 1, exp_strategy[s->lfe_channel]);
+ /* stereo rematrixing */
+ if (s->channel_mode == AC3_CHMODE_STEREO) {
+ put_bits(&s->pb, 1, block->new_rematrixing_strategy);
+ if (block->new_rematrixing_strategy) {
+ /* rematrixing flags */
+ for (rbnd = 0; rbnd < 4; rbnd++)
+ put_bits(&s->pb, 1, block->rematrixing_flags[rbnd]);
+ }
}
- for(ch=0;ch<s->nb_channels;ch++) {
- if (exp_strategy[ch] != EXP_REUSE)
- put_bits(&s->pb, 6, s->chbwcod[ch]);
+ /* exponent strategy */
+ for (ch = 0; ch < s->fbw_channels; ch++)
+ put_bits(&s->pb, 2, s->exp_strategy[ch][blk]);
+ if (s->lfe_on)
+ put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]);
+
+ /* bandwidth */
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ if (s->exp_strategy[ch][blk] != EXP_REUSE)
+ put_bits(&s->pb, 6, s->bandwidth_code[ch]);
}
/* exponents */
- for (ch = 0; ch < s->nb_all_channels; ch++) {
- switch(exp_strategy[ch]) {
- case EXP_REUSE:
+ for (ch = 0; ch < s->channels; ch++) {
+ int nb_groups;
+
+ if (s->exp_strategy[ch][blk] == EXP_REUSE)
continue;
- case EXP_D15:
- group_size = 1;
- break;
- case EXP_D25:
- group_size = 2;
- break;
- default:
- case EXP_D45:
- group_size = 4;
- break;
- }
- nb_groups = (s->nb_coefs[ch] + (group_size * 3) - 4) / (3 * group_size);
- p = encoded_exp[ch];
-
- /* first exponent */
- exp1 = *p++;
- put_bits(&s->pb, 4, exp1);
-
- /* next ones are delta encoded */
- for(i=0;i<nb_groups;i++) {
- /* merge three delta in one code */
- exp0 = exp1;
- exp1 = p[0];
- p += group_size;
- delta0 = exp1 - exp0 + 2;
-
- exp0 = exp1;
- exp1 = p[0];
- p += group_size;
- delta1 = exp1 - exp0 + 2;
-
- exp0 = exp1;
- exp1 = p[0];
- p += group_size;
- delta2 = exp1 - exp0 + 2;
-
- put_bits(&s->pb, 7, ((delta0 * 5 + delta1) * 5) + delta2);
- }
+ /* DC exponent */
+ put_bits(&s->pb, 4, block->grouped_exp[ch][0]);
+
+ /* exponent groups */
+ nb_groups = exponent_group_tab[s->exp_strategy[ch][blk]-1][s->nb_coefs[ch]];
+ for (i = 1; i <= nb_groups; i++)
+ put_bits(&s->pb, 7, block->grouped_exp[ch][i]);
+
+ /* gain range info */
if (ch != s->lfe_channel)
- put_bits(&s->pb, 2, 0); /* no gain range info */
+ put_bits(&s->pb, 2, 0);
}
/* bit allocation info */
- baie = (block_num == 0);
+ baie = (blk == 0);
put_bits(&s->pb, 1, baie);
if (baie) {
put_bits(&s->pb, 2, s->slow_decay_code);
@@ -937,10 +1376,10 @@ static void output_audio_block(AC3EncodeContext *s,
}
/* snr offset */
- put_bits(&s->pb, 1, baie); /* always present with bai */
+ put_bits(&s->pb, 1, baie);
if (baie) {
put_bits(&s->pb, 6, s->coarse_snr_offset);
- for(ch=0;ch<s->nb_all_channels;ch++) {
+ for (ch = 0; ch < s->channels; ch++) {
put_bits(&s->pb, 4, s->fine_snr_offset[ch]);
put_bits(&s->pb, 3, s->fast_gain_code[ch]);
}
@@ -949,141 +1388,31 @@ static void output_audio_block(AC3EncodeContext *s,
put_bits(&s->pb, 1, 0); /* no delta bit allocation */
put_bits(&s->pb, 1, 0); /* no data to skip */
- /* mantissa encoding : we use two passes to handle the grouping. A
- one pass method may be faster, but it would necessitate to
- modify the output stream. */
-
- /* first pass: quantize */
- mant1_cnt = mant2_cnt = mant4_cnt = 0;
- qmant1_ptr = qmant2_ptr = qmant4_ptr = NULL;
-
- for (ch = 0; ch < s->nb_all_channels; ch++) {
- int b, c, e, v;
-
- for(i=0;i<s->nb_coefs[ch];i++) {
- c = mdct_coefs[ch][i];
- e = encoded_exp[ch][i] - global_exp[ch];
- b = bap[ch][i];
- switch(b) {
- case 0:
- v = 0;
- break;
- case 1:
- v = sym_quant(c, e, 3);
- switch(mant1_cnt) {
- case 0:
- qmant1_ptr = &qmant[ch][i];
- v = 9 * v;
- mant1_cnt = 1;
- break;
- case 1:
- *qmant1_ptr += 3 * v;
- mant1_cnt = 2;
- v = 128;
- break;
- default:
- *qmant1_ptr += v;
- mant1_cnt = 0;
- v = 128;
- break;
- }
- break;
- case 2:
- v = sym_quant(c, e, 5);
- switch(mant2_cnt) {
- case 0:
- qmant2_ptr = &qmant[ch][i];
- v = 25 * v;
- mant2_cnt = 1;
- break;
- case 1:
- *qmant2_ptr += 5 * v;
- mant2_cnt = 2;
- v = 128;
- break;
- default:
- *qmant2_ptr += v;
- mant2_cnt = 0;
- v = 128;
- break;
- }
- break;
- case 3:
- v = sym_quant(c, e, 7);
- break;
- case 4:
- v = sym_quant(c, e, 11);
- switch(mant4_cnt) {
- case 0:
- qmant4_ptr = &qmant[ch][i];
- v = 11 * v;
- mant4_cnt = 1;
- break;
- default:
- *qmant4_ptr += v;
- mant4_cnt = 0;
- v = 128;
- break;
- }
- break;
- case 5:
- v = sym_quant(c, e, 15);
- break;
- case 14:
- v = asym_quant(c, e, 14);
- break;
- case 15:
- v = asym_quant(c, e, 16);
- break;
- default:
- v = asym_quant(c, e, b - 1);
- break;
- }
- qmant[ch][i] = v;
- }
- }
-
- /* second pass : output the values */
- for (ch = 0; ch < s->nb_all_channels; ch++) {
+ /* mantissas */
+ for (ch = 0; ch < s->channels; ch++) {
int b, q;
-
- for(i=0;i<s->nb_coefs[ch];i++) {
- q = qmant[ch][i];
- b = bap[ch][i];
- switch(b) {
- case 0:
- break;
- case 1:
- if (q != 128)
- put_bits(&s->pb, 5, q);
- break;
- case 2:
- if (q != 128)
- put_bits(&s->pb, 7, q);
- break;
- case 3:
- put_bits(&s->pb, 3, q);
- break;
- case 4:
- if (q != 128)
- put_bits(&s->pb, 7, q);
- break;
- case 14:
- put_bits(&s->pb, 14, q);
- break;
- case 15:
- put_bits(&s->pb, 16, q);
- break;
- default:
- put_bits(&s->pb, b - 1, q);
- break;
+ for (i = 0; i < s->nb_coefs[ch]; i++) {
+ q = block->qmant[ch][i];
+ b = block->bap[ch][i];
+ switch (b) {
+ case 0: break;
+ case 1: if (q != 128) put_bits(&s->pb, 5, q); break;
+ case 2: if (q != 128) put_bits(&s->pb, 7, q); break;
+ case 3: put_bits(&s->pb, 3, q); break;
+ case 4: if (q != 128) put_bits(&s->pb, 7, q); break;
+ case 14: put_bits(&s->pb, 14, q); break;
+ case 15: put_bits(&s->pb, 16, q); break;
+ default: put_bits(&s->pb, b-1, q); break;
}
}
}
}
+
+/** CRC-16 Polynomial */
#define CRC16_POLY ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16))
+
static unsigned int mul_poly(unsigned int a, unsigned int b, unsigned int poly)
{
unsigned int c;
@@ -1100,6 +1429,7 @@ static unsigned int mul_poly(unsigned int a, unsigned int b, unsigned int poly)
return c;
}
+
static unsigned int pow_poly(unsigned int a, unsigned int n, unsigned int poly)
{
unsigned int r;
@@ -1114,312 +1444,421 @@ static unsigned int pow_poly(unsigned int a, unsigned int n, unsigned int poly)
}
-/* compute log2(max(abs(tab[]))) */
-static int log2_tab(int16_t *tab, int n)
+/**
+ * Fill the end of the frame with 0's and compute the two CRCs.
+ */
+static void output_frame_end(AC3EncodeContext *s)
{
- int i, v;
+ const AVCRC *crc_ctx = av_crc_get_table(AV_CRC_16_ANSI);
+ int frame_size_58, pad_bytes, crc1, crc2_partial, crc2, crc_inv;
+ uint8_t *frame;
- v = 0;
- for(i=0;i<n;i++) {
- v |= abs(tab[i]);
+ frame_size_58 = ((s->frame_size >> 2) + (s->frame_size >> 4)) << 1;
+
+ /* pad the remainder of the frame with zeros */
+ flush_put_bits(&s->pb);
+ frame = s->pb.buf;
+ pad_bytes = s->frame_size - (put_bits_ptr(&s->pb) - frame) - 2;
+ assert(pad_bytes >= 0);
+ if (pad_bytes > 0)
+ memset(put_bits_ptr(&s->pb), 0, pad_bytes);
+
+ /* compute crc1 */
+ /* this is not so easy because it is at the beginning of the data... */
+ crc1 = av_bswap16(av_crc(crc_ctx, 0, frame + 4, frame_size_58 - 4));
+ crc_inv = s->crc_inv[s->frame_size > s->frame_size_min];
+ crc1 = mul_poly(crc_inv, crc1, CRC16_POLY);
+ AV_WB16(frame + 2, crc1);
+
+ /* compute crc2 */
+ crc2_partial = av_crc(crc_ctx, 0, frame + frame_size_58,
+ s->frame_size - frame_size_58 - 3);
+ crc2 = av_crc(crc_ctx, crc2_partial, frame + s->frame_size - 3, 1);
+ /* ensure crc2 does not match sync word by flipping crcrsv bit if needed */
+ if (crc2 == 0x770B) {
+ frame[s->frame_size - 3] ^= 0x1;
+ crc2 = av_crc(crc_ctx, crc2_partial, frame + s->frame_size - 3, 1);
}
- return av_log2(v);
+ crc2 = av_bswap16(crc2);
+ AV_WB16(frame + s->frame_size - 2, crc2);
}
-static void lshift_tab(int16_t *tab, int n, int lshift)
+
+/**
+ * Write the frame to the output bitstream.
+ */
+static void output_frame(AC3EncodeContext *s, unsigned char *frame)
{
- int i;
+ int blk;
- if (lshift > 0) {
- for(i=0;i<n;i++) {
- tab[i] <<= lshift;
- }
- } else if (lshift < 0) {
- lshift = -lshift;
- for(i=0;i<n;i++) {
- tab[i] >>= lshift;
- }
- }
-}
+ init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
-/* fill the end of the frame and compute the two crcs */
-static int output_frame_end(AC3EncodeContext *s)
-{
- int frame_size, frame_size_58, n, crc1, crc2, crc_inv;
- uint8_t *frame;
+ output_frame_header(s);
- frame_size = s->frame_size; /* frame size in words */
- /* align to 8 bits */
- flush_put_bits(&s->pb);
- /* add zero bytes to reach the frame size */
- frame = s->pb.buf;
- n = 2 * s->frame_size - (put_bits_ptr(&s->pb) - frame) - 2;
- assert(n >= 0);
- if(n>0)
- memset(put_bits_ptr(&s->pb), 0, n);
-
- /* Now we must compute both crcs : this is not so easy for crc1
- because it is at the beginning of the data... */
- frame_size_58 = (frame_size >> 1) + (frame_size >> 3);
- crc1 = 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 = 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);
-
- // printf("n=%d frame_size=%d\n", n, frame_size);
- return frame_size * 2;
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++)
+ output_audio_block(s, blk);
+
+ output_frame_end(s);
}
-static int AC3_encode_frame(AVCodecContext *avctx,
- unsigned char *frame, int buf_size, void *data)
+
+/**
+ * Encode a single AC-3 frame.
+ */
+static int ac3_encode_frame(AVCodecContext *avctx, unsigned char *frame,
+ int buf_size, void *data)
{
AC3EncodeContext *s = avctx->priv_data;
- int16_t *samples = data;
- int i, j, k, v, ch;
- int16_t input_samples[N];
- int32_t mdct_coef[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
- uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
- uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS];
- uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
- uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
- int8_t exp_samples[NB_BLOCKS][AC3_MAX_CHANNELS];
- int frame_bits;
+ const SampleType *samples = data;
+ int ret;
- frame_bits = 0;
- for(ch=0;ch<s->nb_all_channels;ch++) {
- int ich = s->channel_map[ch];
- /* fixed mdct to the six sub blocks & exponent computation */
- for(i=0;i<NB_BLOCKS;i++) {
- int16_t *sptr;
- int sinc;
-
- /* compute input samples */
- memcpy(input_samples, s->last_samples[ich], N/2 * sizeof(int16_t));
- sinc = s->nb_all_channels;
- sptr = samples + (sinc * (N/2) * i) + ich;
- for(j=0;j<N/2;j++) {
- v = *sptr;
- input_samples[j + N/2] = v;
- s->last_samples[ich][j] = v;
- sptr += sinc;
- }
+ if (s->bit_alloc.sr_code == 1)
+ adjust_frame_size(s);
- /* apply the MDCT window */
- for(j=0;j<N/2;j++) {
- input_samples[j] = MUL16(input_samples[j],
- ff_ac3_window[j]) >> 15;
- input_samples[N-j-1] = MUL16(input_samples[N-j-1],
- ff_ac3_window[j]) >> 15;
- }
+ deinterleave_input_samples(s, samples);
- /* Normalize the samples to use the maximum available
- precision */
- v = 14 - log2_tab(input_samples, N);
- if (v < 0)
- v = 0;
- exp_samples[i][ch] = v - 9;
- lshift_tab(input_samples, N, v);
+ apply_mdct(s);
- /* do the MDCT */
- mdct512(mdct_coef[i][ch], input_samples);
+ compute_rematrixing_strategy(s);
- /* compute "exponents". We take into account the
- normalization there */
- for(j=0;j<N/2;j++) {
- int e;
- v = abs(mdct_coef[i][ch][j]);
- if (v == 0)
- e = 24;
- else {
- e = 23 - av_log2(v) + exp_samples[i][ch];
- if (e >= 24) {
- e = 24;
- mdct_coef[i][ch][j] = 0;
- }
- }
- exp[i][ch][j] = e;
- }
- }
+ scale_coefficients(s);
- compute_exp_strategy(exp_strategy, exp, ch, ch == s->lfe_channel);
-
- /* compute the exponents as the decoder will see them. The
- EXP_REUSE case must be handled carefully : we select the
- min of the exponents */
- i = 0;
- while (i < NB_BLOCKS) {
- j = i + 1;
- while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE) {
- exponent_min(exp[i][ch], exp[j][ch], s->nb_coefs[ch]);
- j++;
- }
- frame_bits += encode_exp(encoded_exp[i][ch],
- exp[i][ch], s->nb_coefs[ch],
- exp_strategy[i][ch]);
- /* copy encoded exponents for reuse case */
- for(k=i+1;k<j;k++) {
- memcpy(encoded_exp[k][ch], encoded_exp[i][ch],
- s->nb_coefs[ch] * sizeof(uint8_t));
- }
- i = j;
- }
- }
+ apply_rematrixing(s);
- /* adjust for fractional frame sizes */
- while(s->bits_written >= s->bit_rate && s->samples_written >= s->sample_rate) {
- s->bits_written -= s->bit_rate;
- s->samples_written -= s->sample_rate;
+ process_exponents(s);
+
+ ret = compute_bit_allocation(s);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n");
+ return ret;
}
- s->frame_size = s->frame_size_min + (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate);
- s->bits_written += s->frame_size * 16;
- s->samples_written += AC3_FRAME_SIZE;
- compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);
- /* everything is known... let's output the frame */
- output_frame_header(s, frame);
+ quantize_mantissas(s);
- for(i=0;i<NB_BLOCKS;i++) {
- output_audio_block(s, exp_strategy[i], encoded_exp[i],
- bap[i], mdct_coef[i], exp_samples[i], i);
- }
- return output_frame_end(s);
+ output_frame(s, frame);
+
+ return s->frame_size;
}
-static av_cold int AC3_encode_close(AVCodecContext *avctx)
+
+/**
+ * Finalize encoding and free any memory allocated by the encoder.
+ */
+static av_cold int ac3_encode_close(AVCodecContext *avctx)
{
+ int blk, ch;
+ AC3EncodeContext *s = avctx->priv_data;
+
+ for (ch = 0; ch < s->channels; ch++)
+ av_freep(&s->planar_samples[ch]);
+ av_freep(&s->planar_samples);
+ av_freep(&s->bap_buffer);
+ av_freep(&s->bap1_buffer);
+ av_freep(&s->mdct_coef_buffer);
+ av_freep(&s->fixed_coef_buffer);
+ av_freep(&s->exp_buffer);
+ av_freep(&s->grouped_exp_buffer);
+ av_freep(&s->psd_buffer);
+ av_freep(&s->band_psd_buffer);
+ av_freep(&s->mask_buffer);
+ av_freep(&s->qmant_buffer);
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ av_freep(&block->bap);
+ av_freep(&block->mdct_coef);
+ av_freep(&block->fixed_coef);
+ av_freep(&block->exp);
+ av_freep(&block->grouped_exp);
+ av_freep(&block->psd);
+ av_freep(&block->band_psd);
+ av_freep(&block->mask);
+ av_freep(&block->qmant);
+ }
+
+ mdct_end(&s->mdct);
+
av_freep(&avctx->coded_frame);
return 0;
}
-#if 0
-/*************************************************************************/
-/* TEST */
-#undef random
-#define FN (N/4)
+/**
+ * Set channel information during initialization.
+ */
+static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
+ int64_t *channel_layout)
+{
+ int ch_layout;
+
+ if (channels < 1 || channels > AC3_MAX_CHANNELS)
+ return AVERROR(EINVAL);
+ if ((uint64_t)*channel_layout > 0x7FF)
+ return AVERROR(EINVAL);
+ ch_layout = *channel_layout;
+ if (!ch_layout)
+ ch_layout = avcodec_guess_channel_layout(channels, CODEC_ID_AC3, NULL);
+ if (av_get_channel_layout_nb_channels(ch_layout) != channels)
+ return AVERROR(EINVAL);
+
+ s->lfe_on = !!(ch_layout & AV_CH_LOW_FREQUENCY);
+ s->channels = channels;
+ s->fbw_channels = channels - s->lfe_on;
+ s->lfe_channel = s->lfe_on ? s->fbw_channels : -1;
+ if (s->lfe_on)
+ ch_layout -= AV_CH_LOW_FREQUENCY;
+
+ switch (ch_layout) {
+ case AV_CH_LAYOUT_MONO: s->channel_mode = AC3_CHMODE_MONO; break;
+ case AV_CH_LAYOUT_STEREO: s->channel_mode = AC3_CHMODE_STEREO; break;
+ case AV_CH_LAYOUT_SURROUND: s->channel_mode = AC3_CHMODE_3F; break;
+ case AV_CH_LAYOUT_2_1: s->channel_mode = AC3_CHMODE_2F1R; break;
+ case AV_CH_LAYOUT_4POINT0: s->channel_mode = AC3_CHMODE_3F1R; break;
+ case AV_CH_LAYOUT_QUAD:
+ case AV_CH_LAYOUT_2_2: s->channel_mode = AC3_CHMODE_2F2R; break;
+ case AV_CH_LAYOUT_5POINT0:
+ case AV_CH_LAYOUT_5POINT0_BACK: s->channel_mode = AC3_CHMODE_3F2R; break;
+ default:
+ return AVERROR(EINVAL);
+ }
-void fft_test(void)
+ s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe_on];
+ *channel_layout = ch_layout;
+ if (s->lfe_on)
+ *channel_layout |= AV_CH_LOW_FREQUENCY;
+
+ return 0;
+}
+
+
+static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
{
- IComplex in[FN], in1[FN];
- int k, n, i;
- float sum_re, sum_im, a;
+ int i, ret;
- /* FFT test */
+ /* validate channel layout */
+ if (!avctx->channel_layout) {
+ av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
+ "encoder will guess the layout, but it "
+ "might be incorrect.\n");
+ }
+ ret = set_channel_info(s, avctx->channels, &avctx->channel_layout);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");
+ return ret;
+ }
- for(i=0;i<FN;i++) {
- in[i].re = random() % 65535 - 32767;
- in[i].im = random() % 65535 - 32767;
- in1[i] = in[i];
+ /* validate sample rate */
+ for (i = 0; i < 9; i++) {
+ if ((ff_ac3_sample_rate_tab[i / 3] >> (i % 3)) == avctx->sample_rate)
+ break;
}
- fft(in, 7);
-
- /* do it by hand */
- for(k=0;k<FN;k++) {
- sum_re = 0;
- sum_im = 0;
- for(n=0;n<FN;n++) {
- a = -2 * M_PI * (n * k) / FN;
- sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);
- sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);
- }
- printf("%3d: %6d,%6d %6.0f,%6.0f\n",
- k, in[k].re, in[k].im, sum_re / FN, sum_im / FN);
+ if (i == 9) {
+ av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
+ return AVERROR(EINVAL);
+ }
+ s->sample_rate = avctx->sample_rate;
+ s->bit_alloc.sr_shift = i % 3;
+ s->bit_alloc.sr_code = i / 3;
+
+ /* validate bit rate */
+ for (i = 0; i < 19; i++) {
+ if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)
+ break;
+ }
+ if (i == 19) {
+ av_log(avctx, AV_LOG_ERROR, "invalid bit rate\n");
+ return AVERROR(EINVAL);
+ }
+ s->bit_rate = avctx->bit_rate;
+ s->frame_size_code = i << 1;
+
+ /* validate cutoff */
+ if (avctx->cutoff < 0) {
+ av_log(avctx, AV_LOG_ERROR, "invalid cutoff frequency\n");
+ return AVERROR(EINVAL);
}
+ s->cutoff = avctx->cutoff;
+ if (s->cutoff > (s->sample_rate >> 1))
+ s->cutoff = s->sample_rate >> 1;
+
+ return 0;
}
-void mdct_test(void)
+
+/**
+ * Set bandwidth for all channels.
+ * The user can optionally supply a cutoff frequency. Otherwise an appropriate
+ * default value will be used.
+ */
+static av_cold void set_bandwidth(AC3EncodeContext *s)
{
- int16_t input[N];
- int32_t output[N/2];
- float input1[N];
- float output1[N/2];
- float s, a, err, e, emax;
- int i, k, n;
-
- for(i=0;i<N;i++) {
- input[i] = (random() % 65535 - 32767) * 9 / 10;
- input1[i] = input[i];
+ int ch, bw_code;
+
+ if (s->cutoff) {
+ /* calculate bandwidth based on user-specified cutoff frequency */
+ int fbw_coeffs;
+ fbw_coeffs = s->cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
+ bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
+ } else {
+ /* use default bandwidth setting */
+ /* XXX: should compute the bandwidth according to the frame
+ size, so that we avoid annoying high frequency artifacts */
+ bw_code = 50;
}
- mdct512(output, input);
+ /* set number of coefficients for each channel */
+ for (ch = 0; ch < s->fbw_channels; ch++) {
+ s->bandwidth_code[ch] = bw_code;
+ s->nb_coefs[ch] = bw_code * 3 + 73;
+ }
+ if (s->lfe_on)
+ s->nb_coefs[s->lfe_channel] = 7; /* LFE channel always has 7 coefs */
+}
+
+
+static av_cold int allocate_buffers(AVCodecContext *avctx)
+{
+ int blk, ch;
+ AC3EncodeContext *s = avctx->priv_data;
- /* do it by hand */
- for(k=0;k<N/2;k++) {
- s = 0;
- for(n=0;n<N;n++) {
- a = (2*M_PI*(2*n+1+N/2)*(2*k+1) / (4 * N));
- s += input1[n] * cos(a);
+ FF_ALLOC_OR_GOTO(avctx, s->planar_samples, s->channels * sizeof(*s->planar_samples),
+ alloc_fail);
+ for (ch = 0; ch < s->channels; ch++) {
+ FF_ALLOCZ_OR_GOTO(avctx, s->planar_samples[ch],
+ (AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples),
+ alloc_fail);
+ }
+ FF_ALLOC_OR_GOTO(avctx, s->bap_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->bap_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->bap1_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->exp_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, AC3_MAX_BLOCKS * s->channels *
+ 128 * sizeof(*s->grouped_exp_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->psd_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, AC3_MAX_BLOCKS * s->channels *
+ 64 * sizeof(*s->band_psd_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, AC3_MAX_BLOCKS * s->channels *
+ 64 * sizeof(*s->mask_buffer), alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->qmant_buffer), alloc_fail);
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ FF_ALLOC_OR_GOTO(avctx, block->bap, s->channels * sizeof(*block->bap),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->mdct_coef, s->channels * sizeof(*block->mdct_coef),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->exp, s->channels * sizeof(*block->exp),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->grouped_exp, s->channels * sizeof(*block->grouped_exp),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->psd, s->channels * sizeof(*block->psd),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->band_psd, s->channels * sizeof(*block->band_psd),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->mask, s->channels * sizeof(*block->mask),
+ alloc_fail);
+ FF_ALLOCZ_OR_GOTO(avctx, block->qmant, s->channels * sizeof(*block->qmant),
+ alloc_fail);
+
+ for (ch = 0; ch < s->channels; ch++) {
+ /* arrangement: block, channel, coeff */
+ block->bap[ch] = &s->bap_buffer [AC3_MAX_COEFS * (blk * s->channels + ch)];
+ block->mdct_coef[ch] = &s->mdct_coef_buffer [AC3_MAX_COEFS * (blk * s->channels + ch)];
+ block->grouped_exp[ch] = &s->grouped_exp_buffer[128 * (blk * s->channels + ch)];
+ block->psd[ch] = &s->psd_buffer [AC3_MAX_COEFS * (blk * s->channels + ch)];
+ block->band_psd[ch] = &s->band_psd_buffer [64 * (blk * s->channels + ch)];
+ block->mask[ch] = &s->mask_buffer [64 * (blk * s->channels + ch)];
+ block->qmant[ch] = &s->qmant_buffer [AC3_MAX_COEFS * (blk * s->channels + ch)];
+
+ /* arrangement: channel, block, coeff */
+ block->exp[ch] = &s->exp_buffer [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];
}
- output1[k] = -2 * s / N;
}
- err = 0;
- emax = 0;
- for(i=0;i<N/2;i++) {
- printf("%3d: %7d %7.0f\n", i, output[i], output1[i]);
- e = output[i] - output1[i];
- if (e > emax)
- emax = e;
- err += e * e;
+ if (CONFIG_AC3ENC_FLOAT) {
+ FF_ALLOC_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * s->channels *
+ AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail);
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, s->channels *
+ sizeof(*block->fixed_coef), alloc_fail);
+ for (ch = 0; ch < s->channels; ch++)
+ block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (blk * s->channels + ch)];
+ }
+ } else {
+ for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
+ AC3Block *block = &s->blocks[blk];
+ FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, s->channels *
+ sizeof(*block->fixed_coef), alloc_fail);
+ for (ch = 0; ch < s->channels; ch++)
+ block->fixed_coef[ch] = (int32_t *)block->mdct_coef[ch];
+ }
}
- printf("err2=%f emax=%f\n", err / (N/2), emax);
+
+ return 0;
+alloc_fail:
+ return AVERROR(ENOMEM);
}
-void test_ac3(void)
+
+/**
+ * Initialize the encoder.
+ */
+static av_cold int ac3_encode_init(AVCodecContext *avctx)
{
- AC3EncodeContext ctx;
- unsigned char frame[AC3_MAX_CODED_FRAME_SIZE];
- short samples[AC3_FRAME_SIZE];
- int ret, i;
+ AC3EncodeContext *s = avctx->priv_data;
+ int ret, frame_size_58;
- AC3_encode_init(&ctx, 44100, 64000, 1);
+ avctx->frame_size = AC3_FRAME_SIZE;
- fft_test();
- mdct_test();
+ ff_ac3_common_init();
- for(i=0;i<AC3_FRAME_SIZE;i++)
- samples[i] = (int)(sin(2*M_PI*i*1000.0/44100) * 10000);
- ret = AC3_encode_frame(&ctx, frame, samples);
- printf("ret=%d\n", ret);
-}
-#endif
+ ret = validate_options(avctx, s);
+ if (ret)
+ return ret;
-AVCodec ac3_encoder = {
- "ac3",
- AVMEDIA_TYPE_AUDIO,
- CODEC_ID_AC3,
- sizeof(AC3EncodeContext),
- AC3_encode_init,
- AC3_encode_frame,
- AC3_encode_close,
- NULL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
- .channel_layouts = (const int64_t[]){
- CH_LAYOUT_MONO,
- CH_LAYOUT_STEREO,
- CH_LAYOUT_2_1,
- CH_LAYOUT_SURROUND,
- CH_LAYOUT_2_2,
- CH_LAYOUT_QUAD,
- CH_LAYOUT_4POINT0,
- CH_LAYOUT_5POINT0,
- CH_LAYOUT_5POINT0_BACK,
- (CH_LAYOUT_MONO | CH_LOW_FREQUENCY),
- (CH_LAYOUT_STEREO | CH_LOW_FREQUENCY),
- (CH_LAYOUT_2_1 | CH_LOW_FREQUENCY),
- (CH_LAYOUT_SURROUND | CH_LOW_FREQUENCY),
- (CH_LAYOUT_2_2 | CH_LOW_FREQUENCY),
- (CH_LAYOUT_QUAD | CH_LOW_FREQUENCY),
- (CH_LAYOUT_4POINT0 | CH_LOW_FREQUENCY),
- CH_LAYOUT_5POINT1,
- CH_LAYOUT_5POINT1_BACK,
- 0 },
-};
+ s->bitstream_id = 8 + s->bit_alloc.sr_shift;
+ s->bitstream_mode = 0; /* complete main audio service */
+
+ s->frame_size_min = 2 * ff_ac3_frame_size_tab[s->frame_size_code][s->bit_alloc.sr_code];
+ s->bits_written = 0;
+ s->samples_written = 0;
+ s->frame_size = s->frame_size_min;
+
+ /* calculate crc_inv for both possible frame sizes */
+ frame_size_58 = (( s->frame_size >> 2) + ( s->frame_size >> 4)) << 1;
+ s->crc_inv[0] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);
+ if (s->bit_alloc.sr_code == 1) {
+ frame_size_58 = (((s->frame_size+2) >> 2) + ((s->frame_size+2) >> 4)) << 1;
+ s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY);
+ }
+
+ set_bandwidth(s);
+
+ rematrixing_init(s);
+
+ exponent_init(s);
+
+ bit_alloc_init(s);
+
+ ret = mdct_init(avctx, &s->mdct, 9);
+ if (ret)
+ goto init_fail;
+
+ ret = allocate_buffers(avctx);
+ if (ret)
+ goto init_fail;
+
+ avctx->coded_frame= avcodec_alloc_frame();
+
+ dsputil_init(&s->dsp, avctx);
+
+ return 0;
+init_fail:
+ ac3_encode_close(avctx);
+ return ret;
+}
diff --git a/lib/ffmpeg/libavcodec/ac3enc_fixed.c b/lib/ffmpeg/libavcodec/ac3enc_fixed.c
new file mode 100644
index 0000000000..90e148b949
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ac3enc_fixed.c
@@ -0,0 +1,440 @@
+/*
+ * The simplest AC-3 encoder
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
+ * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * fixed-point AC-3 encoder.
+ */
+
+#undef CONFIG_AC3ENC_FLOAT
+#include "ac3enc.c"
+
+
+/** Scale a float value by 2^15, convert to an integer, and clip to range -32767..32767. */
+#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767)
+
+
+/**
+ * Finalize MDCT and free allocated memory.
+ */
+static av_cold void mdct_end(AC3MDCTContext *mdct)
+{
+ mdct->nbits = 0;
+ av_freep(&mdct->costab);
+ av_freep(&mdct->sintab);
+ av_freep(&mdct->xcos1);
+ av_freep(&mdct->xsin1);
+ av_freep(&mdct->rot_tmp);
+ av_freep(&mdct->cplx_tmp);
+}
+
+
+/**
+ * Initialize FFT tables.
+ * @param ln log2(FFT size)
+ */
+static av_cold int fft_init(AVCodecContext *avctx, AC3MDCTContext *mdct, int ln)
+{
+ int i, n, n2;
+ float alpha;
+
+ n = 1 << ln;
+ n2 = n >> 1;
+
+ FF_ALLOC_OR_GOTO(avctx, mdct->costab, n2 * sizeof(*mdct->costab), fft_alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, mdct->sintab, n2 * sizeof(*mdct->sintab), fft_alloc_fail);
+
+ for (i = 0; i < n2; i++) {
+ alpha = 2.0 * M_PI * i / n;
+ mdct->costab[i] = FIX15(cos(alpha));
+ mdct->sintab[i] = FIX15(sin(alpha));
+ }
+
+ return 0;
+fft_alloc_fail:
+ mdct_end(mdct);
+ return AVERROR(ENOMEM);
+}
+
+
+/**
+ * Initialize MDCT tables.
+ * @param nbits log2(MDCT size)
+ */
+static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
+ int nbits)
+{
+ int i, n, n4, ret;
+
+ n = 1 << nbits;
+ n4 = n >> 2;
+
+ mdct->nbits = nbits;
+
+ ret = fft_init(avctx, mdct, nbits - 2);
+ if (ret)
+ return ret;
+
+ mdct->window = ff_ac3_window;
+
+ FF_ALLOC_OR_GOTO(avctx, mdct->xcos1, n4 * sizeof(*mdct->xcos1), mdct_alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, mdct->xsin1, n4 * sizeof(*mdct->xsin1), mdct_alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, mdct->rot_tmp, n * sizeof(*mdct->rot_tmp), mdct_alloc_fail);
+ FF_ALLOC_OR_GOTO(avctx, mdct->cplx_tmp, n4 * sizeof(*mdct->cplx_tmp), mdct_alloc_fail);
+
+ for (i = 0; i < n4; i++) {
+ float alpha = 2.0 * M_PI * (i + 1.0 / 8.0) / n;
+ mdct->xcos1[i] = FIX15(-cos(alpha));
+ mdct->xsin1[i] = FIX15(-sin(alpha));
+ }
+
+ return 0;
+mdct_alloc_fail:
+ mdct_end(mdct);
+ return AVERROR(ENOMEM);
+}
+
+
+/** Butterfly op */
+#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
+{ \
+ int ax, ay, bx, by; \
+ bx = pre1; \
+ by = pim1; \
+ ax = qre1; \
+ ay = qim1; \
+ pre = (bx + ax) >> 1; \
+ pim = (by + ay) >> 1; \
+ qre = (bx - ax) >> 1; \
+ qim = (by - ay) >> 1; \
+}
+
+
+/** Complex multiply */
+#define CMUL(pre, pim, are, aim, bre, bim) \
+{ \
+ pre = (MUL16(are, bre) - MUL16(aim, bim)) >> 15; \
+ pim = (MUL16(are, bim) + MUL16(bre, aim)) >> 15; \
+}
+
+
+/**
+ * Calculate a 2^n point complex FFT on 2^ln points.
+ * @param z complex input/output samples
+ * @param ln log2(FFT size)
+ */
+static void fft(AC3MDCTContext *mdct, IComplex *z, int ln)
+{
+ int j, l, np, np2;
+ int nblocks, nloops;
+ register IComplex *p,*q;
+ int tmp_re, tmp_im;
+
+ np = 1 << ln;
+
+ /* reverse */
+ for (j = 0; j < np; j++) {
+ int k = av_reverse[j] >> (8 - ln);
+ if (k < j)
+ FFSWAP(IComplex, z[k], z[j]);
+ }
+
+ /* pass 0 */
+
+ p = &z[0];
+ j = np >> 1;
+ do {
+ BF(p[0].re, p[0].im, p[1].re, p[1].im,
+ p[0].re, p[0].im, p[1].re, p[1].im);
+ p += 2;
+ } while (--j);
+
+ /* pass 1 */
+
+ p = &z[0];
+ j = np >> 2;
+ do {
+ BF(p[0].re, p[0].im, p[2].re, p[2].im,
+ p[0].re, p[0].im, p[2].re, p[2].im);
+ BF(p[1].re, p[1].im, p[3].re, p[3].im,
+ p[1].re, p[1].im, p[3].im, -p[3].re);
+ p+=4;
+ } while (--j);
+
+ /* pass 2 .. ln-1 */
+
+ nblocks = np >> 3;
+ nloops = 1 << 2;
+ np2 = np >> 1;
+ do {
+ p = z;
+ q = z + nloops;
+ for (j = 0; j < nblocks; j++) {
+ BF(p->re, p->im, q->re, q->im,
+ p->re, p->im, q->re, q->im);
+ p++;
+ q++;
+ for(l = nblocks; l < np2; l += nblocks) {
+ CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im);
+ BF(p->re, p->im, q->re, q->im,
+ p->re, p->im, tmp_re, tmp_im);
+ p++;
+ q++;
+ }
+ p += nloops;
+ q += nloops;
+ }
+ nblocks = nblocks >> 1;
+ nloops = nloops << 1;
+ } while (nblocks);
+}
+
+
+/**
+ * Calculate a 512-point MDCT
+ * @param out 256 output frequency coefficients
+ * @param in 512 windowed input audio samples
+ */
+static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in)
+{
+ int i, re, im, n, n2, n4;
+ int16_t *rot = mdct->rot_tmp;
+ IComplex *x = mdct->cplx_tmp;
+
+ n = 1 << mdct->nbits;
+ n2 = n >> 1;
+ n4 = n >> 2;
+
+ /* shift to simplify computations */
+ for (i = 0; i <n4; i++)
+ rot[i] = -in[i + 3*n4];
+ memcpy(&rot[n4], &in[0], 3*n4*sizeof(*in));
+
+ /* pre rotation */
+ for (i = 0; i < n4; i++) {
+ re = ((int)rot[ 2*i] - (int)rot[ n-1-2*i]) >> 1;
+ im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1;
+ CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i]);
+ }
+
+ fft(mdct, x, mdct->nbits - 2);
+
+ /* post rotation */
+ for (i = 0; i < n4; i++) {
+ re = x[i].re;
+ im = x[i].im;
+ CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i]);
+ }
+}
+
+
+/**
+ * Apply KBD window to input samples prior to MDCT.
+ */
+static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input,
+ const int16_t *window, int n)
+{
+ int i;
+ int n2 = n >> 1;
+
+ for (i = 0; i < n2; i++) {
+ output[i] = MUL16(input[i], window[i]) >> 15;
+ output[n-i-1] = MUL16(input[n-i-1], window[i]) >> 15;
+ }
+}
+
+
+/**
+ * Calculate the log2() of the maximum absolute value in an array.
+ * @param tab input array
+ * @param n number of values in the array
+ * @return log2(max(abs(tab[])))
+ */
+static int log2_tab(int16_t *tab, int n)
+{
+ int i, v;
+
+ v = 0;
+ for (i = 0; i < n; i++)
+ v |= abs(tab[i]);
+
+ return av_log2(v);
+}
+
+
+/**
+ * Left-shift each value in an array by a specified amount.
+ * @param tab input array
+ * @param n number of values in the array
+ * @param lshift left shift amount. a negative value means right shift.
+ */
+static void lshift_tab(int16_t *tab, int n, int lshift)
+{
+ int i;
+
+ if (lshift > 0) {
+ for (i = 0; i < n; i++)
+ tab[i] <<= lshift;
+ } else if (lshift < 0) {
+ lshift = -lshift;
+ for (i = 0; i < n; i++)
+ tab[i] >>= lshift;
+ }
+}
+
+
+/**
+ * Normalize the input samples to use the maximum available precision.
+ * This assumes signed 16-bit input samples. Exponents are reduced by 9 to
+ * match the 24-bit internal precision for MDCT coefficients.
+ *
+ * @return exponent shift
+ */
+static int normalize_samples(AC3EncodeContext *s)
+{
+ int v = 14 - log2_tab(s->windowed_samples, AC3_WINDOW_SIZE);
+ v = FFMAX(0, v);
+ lshift_tab(s->windowed_samples, AC3_WINDOW_SIZE, v);
+ return v - 9;
+}
+
+
+/**
+ * Scale MDCT coefficients from float to fixed-point.
+ */
+static void scale_coefficients(AC3EncodeContext *s)
+{
+ /* scaling/conversion is obviously not needed for the fixed-point encoder
+ since the coefficients are already fixed-point. */
+ return;
+}
+
+
+#ifdef TEST
+/*************************************************************************/
+/* TEST */
+
+#include "libavutil/lfg.h"
+
+#define MDCT_NBITS 9
+#define MDCT_SAMPLES (1 << MDCT_NBITS)
+#define FN (MDCT_SAMPLES/4)
+
+
+static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg)
+{
+ IComplex in[FN], in1[FN];
+ int k, n, i;
+ float sum_re, sum_im, a;
+
+ for (i = 0; i < FN; i++) {
+ in[i].re = av_lfg_get(lfg) % 65535 - 32767;
+ in[i].im = av_lfg_get(lfg) % 65535 - 32767;
+ in1[i] = in[i];
+ }
+ fft(mdct, in, 7);
+
+ /* do it by hand */
+ for (k = 0; k < FN; k++) {
+ sum_re = 0;
+ sum_im = 0;
+ for (n = 0; n < FN; n++) {
+ a = -2 * M_PI * (n * k) / FN;
+ sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);
+ sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);
+ }
+ av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\n",
+ k, in[k].re, in[k].im, sum_re / FN, sum_im / FN);
+ }
+}
+
+
+static void mdct_test(AC3MDCTContext *mdct, AVLFG *lfg)
+{
+ int16_t input[MDCT_SAMPLES];
+ int32_t output[AC3_MAX_COEFS];
+ float input1[MDCT_SAMPLES];
+ float output1[AC3_MAX_COEFS];
+ float s, a, err, e, emax;
+ int i, k, n;
+
+ for (i = 0; i < MDCT_SAMPLES; i++) {
+ input[i] = (av_lfg_get(lfg) % 65535 - 32767) * 9 / 10;
+ input1[i] = input[i];
+ }
+
+ mdct512(mdct, output, input);
+
+ /* do it by hand */
+ for (k = 0; k < AC3_MAX_COEFS; k++) {
+ s = 0;
+ for (n = 0; n < MDCT_SAMPLES; n++) {
+ a = (2*M_PI*(2*n+1+MDCT_SAMPLES/2)*(2*k+1) / (4 * MDCT_SAMPLES));
+ s += input1[n] * cos(a);
+ }
+ output1[k] = -2 * s / MDCT_SAMPLES;
+ }
+
+ err = 0;
+ emax = 0;
+ for (i = 0; i < AC3_MAX_COEFS; i++) {
+ av_log(NULL, AV_LOG_DEBUG, "%3d: %7d %7.0f\n", i, output[i], output1[i]);
+ e = output[i] - output1[i];
+ if (e > emax)
+ emax = e;
+ err += e * e;
+ }
+ av_log(NULL, AV_LOG_DEBUG, "err2=%f emax=%f\n", err / AC3_MAX_COEFS, emax);
+}
+
+
+int main(void)
+{
+ AVLFG lfg;
+ AC3MDCTContext mdct;
+
+ mdct.avctx = NULL;
+ av_log_set_level(AV_LOG_DEBUG);
+ mdct_init(&mdct, 9);
+
+ fft_test(&mdct, &lfg);
+ mdct_test(&mdct, &lfg);
+
+ return 0;
+}
+#endif /* TEST */
+
+
+AVCodec ff_ac3_fixed_encoder = {
+ "ac3_fixed",
+ AVMEDIA_TYPE_AUDIO,
+ CODEC_ID_AC3,
+ sizeof(AC3EncodeContext),
+ ac3_encode_init,
+ ac3_encode_frame,
+ ac3_encode_close,
+ NULL,
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
+ .channel_layouts = ac3_channel_layouts,
+};
diff --git a/lib/ffmpeg/libavcodec/ac3enc_fixed.h b/lib/ffmpeg/libavcodec/ac3enc_fixed.h
new file mode 100644
index 0000000000..12c8ace4aa
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ac3enc_fixed.h
@@ -0,0 +1,59 @@
+/*
+ * The simplest AC-3 encoder
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
+ * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * fixed-point AC-3 encoder header.
+ */
+
+#ifndef AVCODEC_AC3ENC_FIXED_H
+#define AVCODEC_AC3ENC_FIXED_H
+
+#include <stdint.h>
+
+
+typedef int16_t SampleType;
+typedef int32_t CoefType;
+typedef int64_t CoefSumType;
+
+
+/**
+ * Compex number.
+ * Used in fixed-point MDCT calculation.
+ */
+typedef struct IComplex {
+ int16_t re,im;
+} IComplex;
+
+typedef struct AC3MDCTContext {
+ const int16_t *window; ///< MDCT window function
+ int nbits; ///< log2(transform size)
+ int16_t *costab; ///< FFT cos table
+ int16_t *sintab; ///< FFT sin table
+ int16_t *xcos1; ///< MDCT cos table
+ int16_t *xsin1; ///< MDCT sin table
+ int16_t *rot_tmp; ///< temp buffer for pre-rotated samples
+ IComplex *cplx_tmp; ///< temp buffer for complex pre-rotated samples
+} AC3MDCTContext;
+
+#endif /* AVCODEC_AC3ENC_FIXED_H */
diff --git a/lib/ffmpeg/libavcodec/ac3enc_float.c b/lib/ffmpeg/libavcodec/ac3enc_float.c
new file mode 100644
index 0000000000..8668b2e033
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ac3enc_float.c
@@ -0,0 +1,124 @@
+/*
+ * The simplest AC-3 encoder
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
+ * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * floating-point AC-3 encoder.
+ */
+
+#define CONFIG_AC3ENC_FLOAT 1
+#include "ac3enc.c"
+
+
+/**
+ * Finalize MDCT and free allocated memory.
+ */
+static av_cold void mdct_end(AC3MDCTContext *mdct)
+{
+ ff_mdct_end(&mdct->fft);
+ av_freep(&mdct->window);
+}
+
+
+/**
+ * Initialize MDCT tables.
+ * @param nbits log2(MDCT size)
+ */
+static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
+ int nbits)
+{
+ float *window;
+ int i, n, n2;
+
+ n = 1 << nbits;
+ n2 = n >> 1;
+
+ window = av_malloc(n * sizeof(*window));
+ if (!window) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
+ return AVERROR(ENOMEM);
+ }
+ ff_kbd_window_init(window, 5.0, n2);
+ for (i = 0; i < n2; i++)
+ window[n-1-i] = window[i];
+ mdct->window = window;
+
+ return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
+}
+
+
+/**
+ * Calculate a 512-point MDCT
+ * @param out 256 output frequency coefficients
+ * @param in 512 windowed input audio samples
+ */
+static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
+{
+ ff_mdct_calc(&mdct->fft, out, in);
+}
+
+
+/**
+ * Apply KBD window to input samples prior to MDCT.
+ */
+static void apply_window(DSPContext *dsp, float *output, const float *input,
+ const float *window, int n)
+{
+ dsp->vector_fmul(output, input, window, n);
+}
+
+
+/**
+ * Normalize the input samples to use the maximum available precision.
+ */
+static int normalize_samples(AC3EncodeContext *s)
+{
+ /* Normalization is not needed for floating-point samples, so just return 0 */
+ return 0;
+}
+
+
+/**
+ * Scale MDCT coefficients from float to 24-bit fixed-point.
+ */
+static void scale_coefficients(AC3EncodeContext *s)
+{
+ int i;
+ for (i = 0; i < AC3_MAX_COEFS * AC3_MAX_BLOCKS * s->channels; i++)
+ s->fixed_coef_buffer[i] = SCALE_FLOAT(s->mdct_coef_buffer[i], 24);
+}
+
+
+AVCodec ff_ac3_encoder = {
+ "ac3",
+ AVMEDIA_TYPE_AUDIO,
+ CODEC_ID_AC3,
+ sizeof(AC3EncodeContext),
+ ac3_encode_init,
+ ac3_encode_frame,
+ ac3_encode_close,
+ NULL,
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
+ .channel_layouts = ac3_channel_layouts,
+};
diff --git a/lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.h b/lib/ffmpeg/libavcodec/ac3enc_float.h
index 9094620eb2..1726ca045f 100644
--- a/lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.h
+++ b/lib/ffmpeg/libavcodec/ac3enc_float.h
@@ -1,6 +1,8 @@
/*
- * vp3dsp SSE2 function declarations
- * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org>
+ * The simplest AC-3 encoder
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2006-2010 Justin Ruggles <justin.ruggles@gmail.com>
+ * Copyright (c) 2006-2010 Prakash Punnoor <prakash@punnoor.de>
*
* This file is part of FFmpeg.
*
@@ -19,13 +21,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_X86_VP3DSP_SSE2_H
-#define AVCODEC_X86_VP3DSP_SSE2_H
+/**
+ * @file
+ * floating-point AC-3 encoder header.
+ */
+
+#ifndef AVCODEC_AC3ENC_FLOAT_H
+#define AVCODEC_AC3ENC_FLOAT_H
+
+#include "fft.h"
+
+
+typedef float SampleType;
+typedef float CoefType;
+typedef float CoefSumType;
-#include "libavcodec/dsputil.h"
-void ff_vp3_idct_sse2(int16_t *input_data);
-void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, DCTELEM *block);
+typedef struct AC3MDCTContext {
+ const float *window; ///< MDCT window function
+ FFTContext fft; ///< FFT context for MDCT calculation
+} AC3MDCTContext;
-#endif /* AVCODEC_X86_VP3DSP_SSE2_H */
+#endif /* AVCODEC_AC3ENC_FLOAT_H */
diff --git a/lib/ffmpeg/libavcodec/ac3tab.c b/lib/ffmpeg/libavcodec/ac3tab.c
index 76f6245ba0..7c0ebcdcd3 100644
--- a/lib/ffmpeg/libavcodec/ac3tab.c
+++ b/lib/ffmpeg/libavcodec/ac3tab.c
@@ -24,6 +24,7 @@
* tables taken directly from the AC-3 spec.
*/
+#include "libavcore/audioconvert.h"
#include "avcodec.h"
#include "ac3tab.h"
@@ -84,14 +85,14 @@ const uint8_t ff_ac3_channels_tab[8] = {
* Map audio coding mode (acmod) to channel layout mask.
*/
const uint16_t ff_ac3_channel_layout_tab[8] = {
- CH_LAYOUT_STEREO,
- CH_LAYOUT_MONO,
- CH_LAYOUT_STEREO,
- CH_LAYOUT_SURROUND,
- CH_LAYOUT_2_1,
- CH_LAYOUT_4POINT0,
- CH_LAYOUT_2_2,
- CH_LAYOUT_5POINT0
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_2_1,
+ AV_CH_LAYOUT_4POINT0,
+ AV_CH_LAYOUT_2_2,
+ AV_CH_LAYOUT_5POINT0
};
#define COMMON_CHANNEL_MAP \
@@ -131,10 +132,16 @@ const uint16_t ff_ac3_bitrate_tab[19] = {
160, 192, 224, 256, 320, 384, 448, 512, 576, 640
};
+/**
+ * Table of bin locations for rematrixing bands
+ * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
+ */
+const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
+
/* AC-3 MDCT window */
/* MDCT window */
-const int16_t ff_ac3_window[256] = {
+const int16_t ff_ac3_window[AC3_WINDOW_SIZE/2] = {
4, 7, 12, 16, 21, 28, 34, 42,
51, 61, 72, 84, 97, 111, 127, 145,
164, 184, 207, 231, 257, 285, 315, 347,
@@ -198,7 +205,7 @@ const uint8_t ff_ac3_log_add_tab[260]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
-const uint16_t ff_ac3_hearing_threshold_tab[50][3]= {
+const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3]= {
{ 0x04d0,0x04f0,0x0580 },
{ 0x04d0,0x04f0,0x0580 },
{ 0x0440,0x0460,0x04b0 },
@@ -285,11 +292,6 @@ const uint16_t ff_ac3_fast_gain_tab[8]= {
0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
};
-const uint8_t ff_ac3_critical_band_size_tab[50]={
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
- 3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
-};
/**
* Default channel map for a dependent substream defined by acmod
*/
diff --git a/lib/ffmpeg/libavcodec/ac3tab.h b/lib/ffmpeg/libavcodec/ac3tab.h
index b5c2b77c9d..36355d0a86 100644
--- a/lib/ffmpeg/libavcodec/ac3tab.h
+++ b/lib/ffmpeg/libavcodec/ac3tab.h
@@ -23,6 +23,7 @@
#define AVCODEC_AC3TAB_H
#include "libavutil/common.h"
+#include "ac3.h"
extern const uint16_t ff_ac3_frame_size_tab[38][3];
extern const uint8_t ff_ac3_channels_tab[8];
@@ -31,9 +32,10 @@ extern const uint8_t ff_ac3_enc_channel_map[8][2][6];
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
extern const uint16_t ff_ac3_sample_rate_tab[3];
extern const uint16_t ff_ac3_bitrate_tab[19];
-extern const int16_t ff_ac3_window[256];
+extern const uint8_t ff_ac3_rematrix_band_tab[5];
+extern const int16_t ff_ac3_window[AC3_WINDOW_SIZE/2];
extern const uint8_t ff_ac3_log_add_tab[260];
-extern const uint16_t ff_ac3_hearing_threshold_tab[50][3];
+extern const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3];
extern const uint8_t ff_ac3_bap_tab[64];
extern const uint8_t ff_ac3_slow_decay_tab[4];
extern const uint8_t ff_ac3_fast_decay_tab[4];
@@ -41,7 +43,6 @@ extern const uint16_t ff_ac3_slow_gain_tab[4];
extern const uint16_t ff_ac3_db_per_bit_tab[4];
extern const int16_t ff_ac3_floor_tab[8];
extern const uint16_t ff_ac3_fast_gain_tab[8];
-extern const uint8_t ff_ac3_critical_band_size_tab[50];
extern const uint16_t ff_eac3_default_chmap[8];
/** Custom channel map locations bitmask
diff --git a/lib/ffmpeg/libavcodec/acelp_filters.h b/lib/ffmpeg/libavcodec/acelp_filters.h
index 09b5da45be..0b1ccf4e71 100644
--- a/lib/ffmpeg/libavcodec/acelp_filters.h
+++ b/lib/ffmpeg/libavcodec/acelp_filters.h
@@ -38,7 +38,7 @@ extern const int16_t ff_acelp_interp_filter[61];
/**
* Generic FIR interpolation routine.
- * @param out [out] buffer for interpolated data
+ * @param[out] out buffer for interpolated data
* @param in input data
* @param filter_coeffs interpolation filter coefficients (0.15)
* @param precision sub sample factor, that is the precision of the position
@@ -65,8 +65,8 @@ void ff_acelp_interpolatef(float *out, const float *in,
/**
* high-pass filtering and upscaling (4.2.5 of G.729).
- * @param out [out] output buffer for filtered speech data
- * @param hpf_f [in/out] past filtered data from previous (2 items long)
+ * @param[out] out output buffer for filtered speech data
+ * @param[in,out] hpf_f past filtered data from previous (2 items long)
* frames (-0x20000000 <= (14.13) < 0x20000000)
* @param in speech data to process
* @param length input data size
diff --git a/lib/ffmpeg/libavcodec/acelp_pitch_delay.h b/lib/ffmpeg/libavcodec/acelp_pitch_delay.h
index 04be173380..ce06bc2539 100644
--- a/lib/ffmpeg/libavcodec/acelp_pitch_delay.h
+++ b/lib/ffmpeg/libavcodec/acelp_pitch_delay.h
@@ -116,7 +116,7 @@ int ff_acelp_decode_6bit_to_2nd_delay6(
/**
* \brief Update past quantized energies
- * \param quant_energy [in/out] past quantized energies (5.10)
+ * \param[in,out] quant_energy past quantized energies (5.10)
* \param gain_corr_factor gain correction factor
* \param log2_ma_pred_order log2() of MA prediction order
* \param erasure frame erasure flag
@@ -143,7 +143,7 @@ void ff_acelp_update_past_gain(
* \param gain_corr_factor gain correction factor (2.13)
* \param fc_v fixed-codebook vector (2.13)
* \param mr_energy mean innovation energy and fixed-point correction (7.13)
- * \param quant_energy [in/out] past quantized energies (5.10)
+ * \param[in,out] quant_energy past quantized energies (5.10)
* \param subframe_size length of subframe
*
* \return quantized fixed-codebook gain (14.1)
diff --git a/lib/ffmpeg/libavcodec/acelp_vectors.h b/lib/ffmpeg/libavcodec/acelp_vectors.h
index 9e3e7a8db3..f3bc781446 100644
--- a/lib/ffmpeg/libavcodec/acelp_vectors.h
+++ b/lib/ffmpeg/libavcodec/acelp_vectors.h
@@ -134,7 +134,7 @@ extern const float ff_pow_0_55[10];
/**
* Decode fixed-codebook vector (3.8 and D.5.8 of G.729, 5.7.1 of AMR).
- * @param fc_v [out] decoded fixed codebook vector (2.13)
+ * @param[out] fc_v decoded fixed codebook vector (2.13)
* @param tab1 table used for first pulse_count pulses
* @param tab2 table used for last pulse
* @param pulse_indexes fixed codebook indexes
@@ -174,7 +174,7 @@ void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
/**
* weighted sum of two vectors with rounding.
- * @param out [out] result of addition
+ * @param[out] out result of addition
* @param in_a first vector
* @param in_b second vector
* @param weight_coeff_a first vector weight coefficient
@@ -198,7 +198,7 @@ void ff_acelp_weighted_vector_sum(int16_t* out,
/**
* float implementation of weighted sum of two vectors.
- * @param out [out] result of addition
+ * @param[out] out result of addition
* @param in_a first vector
* @param in_b second vector
* @param weight_coeff_a first vector weight coefficient
diff --git a/lib/ffmpeg/libavcodec/adpcm.c b/lib/ffmpeg/libavcodec/adpcm.c
index eb044ba4b9..fb5bdc7faa 100644
--- a/lib/ffmpeg/libavcodec/adpcm.c
+++ b/lib/ffmpeg/libavcodec/adpcm.c
@@ -163,6 +163,7 @@ typedef struct ADPCMContext {
TrellisPath *paths;
TrellisNode *node_buf;
TrellisNode **nodep_buf;
+ uint8_t *trellis_hash;
} ADPCMContext;
#define FREEZE_INTERVAL 128
@@ -189,6 +190,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
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);
+ FF_ALLOC_OR_GOTO(avctx, s->trellis_hash, 65536 * sizeof(*s->trellis_hash), error);
}
switch(avctx->codec->id) {
@@ -242,6 +244,7 @@ error:
av_freep(&s->paths);
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
+ av_freep(&s->trellis_hash);
return -1;
}
@@ -252,6 +255,7 @@ static av_cold int adpcm_encode_close(AVCodecContext *avctx)
av_freep(&s->paths);
av_freep(&s->node_buf);
av_freep(&s->nodep_buf);
+ av_freep(&s->trellis_hash);
return 0;
}
@@ -325,7 +329,9 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
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;
+ int pathn = 0, froze = -1, i, j, k, generation = 0;
+ uint8_t *hash = s->trellis_hash;
+ memset(hash, 0xff, 65536 * sizeof(*hash));
memset(nodep_buf, 0, 2 * frontier * sizeof(*nodep_buf));
nodes[0] = node_buf + frontier;
@@ -352,9 +358,10 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
TrellisNode *t = node_buf + frontier*(i&1);
TrellisNode **u;
int sample = samples[i*stride];
+ int heap_pos = 0;
memset(nodes_next, 0, frontier*sizeof(TrellisNode*));
for(j=0; j<frontier && nodes[j]; j++) {
- // higher j have higher ssd already, so they're unlikely to use a suboptimal next sample too
+ // higher j have higher ssd already, so they're likely to yield a suboptimal next sample too
const int range = (j < frontier/2) ? 1 : 0;
const int step = nodes[j]->step;
int nidx;
@@ -369,38 +376,64 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
#define STORE_NODE(NAME, STEP_INDEX)\
int d;\
uint32_t ssd;\
+ int pos;\
+ TrellisNode *u;\
+ uint8_t *h;\
dec_sample = av_clip_int16(dec_sample);\
d = sample - dec_sample;\
ssd = nodes[j]->ssd + d*d;\
- if(nodes_next[frontier-1] && ssd >= nodes_next[frontier-1]->ssd)\
- continue;\
+ /* Check for wraparound, skip such samples completely. \
+ * Note, changing ssd to a 64 bit variable would be \
+ * simpler, avoiding this check, but it's slower on \
+ * x86 32 bit at the moment. */\
+ if (ssd < nodes[j]->ssd)\
+ goto next_##NAME;\
/* Collapse any two states with the same previous sample value. \
* One could also distinguish states by step and by 2nd to last
- * sample, but the effects of that are negligible. */\
- for(k=0; k<frontier && nodes_next[k]; k++) {\
- if(dec_sample == nodes_next[k]->sample1) {\
- assert(ssd >= nodes_next[k]->ssd);\
+ * sample, but the effects of that are negligible.
+ * Since nodes in the previous generation are iterated
+ * through a heap, they're roughly ordered from better to
+ * worse, but not strictly ordered. Therefore, an earlier
+ * node with the same sample value is better in most cases
+ * (and thus the current is skipped), but not strictly
+ * in all cases. Only skipping samples where ssd >=
+ * ssd of the earlier node with the same sample gives
+ * slightly worse quality, though, for some reason. */ \
+ h = &hash[(uint16_t) dec_sample];\
+ if (*h == generation)\
+ goto next_##NAME;\
+ if (heap_pos < frontier) {\
+ pos = heap_pos++;\
+ } else {\
+ /* Try to replace one of the leaf nodes with the new \
+ * one, but try a different slot each time. */\
+ pos = (frontier >> 1) + (heap_pos & ((frontier >> 1) - 1));\
+ if (ssd > nodes_next[pos]->ssd)\
goto next_##NAME;\
- }\
+ heap_pos++;\
}\
- for(k=0; k<frontier; k++) {\
- if(!nodes_next[k] || ssd < nodes_next[k]->ssd) {\
- TrellisNode *u = nodes_next[frontier-1];\
- if(!u) {\
- assert(pathn < FREEZE_INTERVAL<<avctx->trellis);\
- u = t++;\
- u->path = pathn++;\
- }\
- u->ssd = ssd;\
- u->step = STEP_INDEX;\
- u->sample2 = nodes[j]->sample1;\
- u->sample1 = dec_sample;\
- paths[u->path].nibble = nibble;\
- paths[u->path].prev = nodes[j]->path;\
- memmove(&nodes_next[k+1], &nodes_next[k], (frontier-k-1)*sizeof(TrellisNode*));\
- nodes_next[k] = u;\
+ *h = generation;\
+ u = nodes_next[pos];\
+ if(!u) {\
+ assert(pathn < FREEZE_INTERVAL<<avctx->trellis);\
+ u = t++;\
+ nodes_next[pos] = u;\
+ u->path = pathn++;\
+ }\
+ u->ssd = ssd;\
+ u->step = STEP_INDEX;\
+ u->sample2 = nodes[j]->sample1;\
+ u->sample1 = dec_sample;\
+ paths[u->path].nibble = nibble;\
+ paths[u->path].prev = nodes[j]->path;\
+ /* Sift the newly inserted node up in the heap to \
+ * restore the heap property. */\
+ while (pos > 0) {\
+ int parent = (pos - 1) >> 1;\
+ if (nodes_next[parent]->ssd <= ssd)\
break;\
- }\
+ FFSWAP(TrellisNode*, nodes_next[parent], nodes_next[pos]);\
+ pos = parent;\
}\
next_##NAME:;
STORE_NODE(ms, FFMAX(16, (AdaptationTable[nibble] * step) >> 8));
@@ -430,6 +463,12 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
nodes = nodes_next;
nodes_next = u;
+ generation++;
+ if (generation == 255) {
+ memset(hash, 0xff, 65536 * sizeof(*hash));
+ generation = 0;
+ }
+
// prevent overflow
if(nodes[0]->ssd > (1<<28)) {
for(j=1; j<frontier && nodes[j]; j++)
@@ -578,6 +617,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
}
}
+ flush_put_bits(&pb);
dst += put_bits_count(&pb)>>3;
break;
}
@@ -721,6 +761,12 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
case CODEC_ID_ADPCM_CT:
c->status[0].step = c->status[1].step = 511;
break;
+ case CODEC_ID_ADPCM_IMA_WAV:
+ if (avctx->bits_per_coded_sample != 4) {
+ av_log(avctx, AV_LOG_ERROR, "Only 4-bit ADPCM IMA WAV files are supported\n");
+ return -1;
+ }
+ break;
case CODEC_ID_ADPCM_IMA_WS:
if (avctx->extradata && avctx->extradata_size == 2 * 4) {
c->status[0].predictor = AV_RL32(avctx->extradata);
@@ -730,7 +776,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
default:
break;
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -1662,7 +1708,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
#if CONFIG_ENCODERS
#define ADPCM_ENCODER(id,name,long_name_) \
-AVCodec name ## _encoder = { \
+AVCodec ff_ ## name ## _encoder = { \
#name, \
AVMEDIA_TYPE_AUDIO, \
id, \
@@ -1671,7 +1717,7 @@ AVCodec name ## _encoder = { \
adpcm_encode_frame, \
adpcm_encode_close, \
NULL, \
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, \
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
};
#else
@@ -1680,7 +1726,7 @@ AVCodec name ## _encoder = { \
#if CONFIG_DECODERS
#define ADPCM_DECODER(id,name,long_name_) \
-AVCodec name ## _decoder = { \
+AVCodec ff_ ## name ## _decoder = { \
#name, \
AVMEDIA_TYPE_AUDIO, \
id, \
diff --git a/lib/ffmpeg/libavcodec/adxdec.c b/lib/ffmpeg/libavcodec/adxdec.c
index adb22fcfe5..991528a7d2 100644
--- a/lib/ffmpeg/libavcodec/adxdec.c
+++ b/lib/ffmpeg/libavcodec/adxdec.c
@@ -34,7 +34,7 @@
static av_cold int adx_decode_init(AVCodecContext *avctx)
{
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -166,7 +166,7 @@ static int adx_decode_frame(AVCodecContext *avctx,
return buf-buf0;
}
-AVCodec adpcm_adx_decoder = {
+AVCodec ff_adpcm_adx_decoder = {
"adpcm_adx",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ADPCM_ADX,
diff --git a/lib/ffmpeg/libavcodec/adxenc.c b/lib/ffmpeg/libavcodec/adxenc.c
index 116b746ed0..ca48f94b71 100644
--- a/lib/ffmpeg/libavcodec/adxenc.c
+++ b/lib/ffmpeg/libavcodec/adxenc.c
@@ -183,7 +183,7 @@ static int adx_encode_frame(AVCodecContext *avctx,
return dst-frame;
}
-AVCodec adpcm_adx_encoder = {
+AVCodec ff_adpcm_adx_encoder = {
"adpcm_adx",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ADPCM_ADX,
@@ -192,6 +192,6 @@ AVCodec adpcm_adx_encoder = {
adx_encode_frame,
adx_encode_close,
NULL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
};
diff --git a/lib/ffmpeg/libavcodec/alac.c b/lib/ffmpeg/libavcodec/alac.c
index 07b03c126f..96c15fffc9 100644
--- a/lib/ffmpeg/libavcodec/alac.c
+++ b/lib/ffmpeg/libavcodec/alac.c
@@ -65,9 +65,6 @@ typedef struct {
AVCodecContext *avctx;
GetBitContext gb;
- /* init to 0; first frame decode should initialize from extradata and
- * set this to 1 */
- int context_initialized;
int numchannels;
int bytespersample;
@@ -471,21 +468,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
/* short-circuit null buffers */
if (!inbuffer || !input_buffer_size)
- return input_buffer_size;
-
- /* initialize from the extradata */
- if (!alac->context_initialized) {
- if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
- ALAC_EXTRADATA_SIZE);
- return input_buffer_size;
- }
- if (alac_set_info(alac)) {
- av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
- return input_buffer_size;
- }
- alac->context_initialized = 1;
- }
+ return -1;
init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
@@ -493,7 +476,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
if (channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n",
MAX_CHANNELS);
- return input_buffer_size;
+ return -1;
}
/* 2^result = something to do with output waiting.
@@ -522,10 +505,10 @@ static int alac_decode_frame(AVCodecContext *avctx,
outputsamples = alac->setinfo_max_samples_per_frame;
switch (alac->setinfo_sample_size) {
- case 16: avctx->sample_fmt = SAMPLE_FMT_S16;
+ case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16;
alac->bytespersample = channels << 1;
break;
- case 24: avctx->sample_fmt = SAMPLE_FMT_S32;
+ case 24: avctx->sample_fmt = AV_SAMPLE_FMT_S32;
alac->bytespersample = channels << 2;
break;
default: av_log(avctx, AV_LOG_ERROR, "Sample depth %d is not supported.\n",
@@ -678,10 +661,19 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
{
ALACContext *alac = avctx->priv_data;
alac->avctx = avctx;
- alac->context_initialized = 0;
-
alac->numchannels = alac->avctx->channels;
+ /* initialize from the extradata */
+ if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
+ av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
+ ALAC_EXTRADATA_SIZE);
+ return -1;
+ }
+ if (alac_set_info(alac)) {
+ av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
+ return -1;
+ }
+
return 0;
}
@@ -699,7 +691,7 @@ static av_cold int alac_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec alac_decoder = {
+AVCodec ff_alac_decoder = {
"alac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ALAC,
diff --git a/lib/ffmpeg/libavcodec/alacenc.c b/lib/ffmpeg/libavcodec/alacenc.c
index ee6acc0715..9d2865d51e 100644
--- a/lib/ffmpeg/libavcodec/alacenc.c
+++ b/lib/ffmpeg/libavcodec/alacenc.c
@@ -51,11 +51,11 @@ typedef struct RiceContext {
int rice_modifier;
} RiceContext;
-typedef struct LPCContext {
+typedef struct AlacLPCContext {
int lpc_order;
int lpc_coeff[ALAC_MAX_LPC_ORDER+1];
int lpc_quant;
-} LPCContext;
+} AlacLPCContext;
typedef struct AlacEncodeContext {
int compression_level;
@@ -69,18 +69,18 @@ typedef struct AlacEncodeContext {
int interlacing_leftweight;
PutBitContext pbctx;
RiceContext rc;
- LPCContext lpc[MAX_CHANNELS];
- DSPContext dspctx;
+ AlacLPCContext lpc[MAX_CHANNELS];
+ LPCContext lpc_ctx;
AVCodecContext *avctx;
} AlacEncodeContext;
-static void init_sample_buffers(AlacEncodeContext *s, int16_t *input_samples)
+static void init_sample_buffers(AlacEncodeContext *s, const int16_t *input_samples)
{
int ch, i;
for(ch=0;ch<s->avctx->channels;ch++) {
- int16_t *sptr = input_samples + ch;
+ const int16_t *sptr = input_samples + ch;
for(i=0;i<s->avctx->frame_size;i++) {
s->sample_buf[ch][i] = *sptr;
sptr += s->avctx->channels;
@@ -141,7 +141,7 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch)
s->lpc[ch].lpc_coeff[4] = 80;
s->lpc[ch].lpc_coeff[5] = -25;
} else {
- opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch],
+ opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, s->sample_buf[ch],
s->avctx->frame_size,
s->min_prediction_order,
s->max_prediction_order,
@@ -237,7 +237,7 @@ static void alac_stereo_decorrelation(AlacEncodeContext *s)
static void alac_linear_predictor(AlacEncodeContext *s, int ch)
{
int i;
- LPCContext lpc = s->lpc[ch];
+ AlacLPCContext lpc = s->lpc[ch];
if(lpc.lpc_order == 31) {
s->predictor_buf[0] = s->sample_buf[ch][0];
@@ -378,12 +378,13 @@ static void write_compressed_frame(AlacEncodeContext *s)
static av_cold int alac_encode_init(AVCodecContext *avctx)
{
AlacEncodeContext *s = avctx->priv_data;
+ int ret;
uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);
avctx->frame_size = DEFAULT_FRAME_SIZE;
avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
- if(avctx->sample_fmt != SAMPLE_FMT_S16) {
+ if(avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
av_log(avctx, AV_LOG_ERROR, "only pcm_s16 input samples are supported\n");
return -1;
}
@@ -455,9 +456,10 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
avctx->coded_frame->key_frame = 1;
s->avctx = avctx;
- dsputil_init(&s->dspctx, avctx);
+ ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,
+ AV_LPC_TYPE_LEVINSON);
- return 0;
+ return ret;
}
static int alac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
@@ -482,7 +484,7 @@ verbatim:
if((s->compression_level == 0) || verbatim_flag) {
// Verbatim mode
- int16_t *samples = data;
+ const int16_t *samples = data;
write_frame_header(s, 1);
for(i=0; i<avctx->frame_size*avctx->channels; i++) {
put_sbits(pb, 16, *samples++);
@@ -513,13 +515,15 @@ verbatim:
static av_cold int alac_encode_close(AVCodecContext *avctx)
{
+ AlacEncodeContext *s = avctx->priv_data;
+ ff_lpc_end(&s->lpc_ctx);
av_freep(&avctx->extradata);
avctx->extradata_size = 0;
av_freep(&avctx->coded_frame);
return 0;
}
-AVCodec alac_encoder = {
+AVCodec ff_alac_encoder = {
"alac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ALAC,
@@ -528,6 +532,6 @@ AVCodec alac_encoder = {
alac_encode_frame,
alac_encode_close,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME,
- .sample_fmts = (const enum SampleFormat[]){ SAMPLE_FMT_S16, SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
};
diff --git a/lib/ffmpeg/libavcodec/allcodecs.c b/lib/ffmpeg/libavcodec/allcodecs.c
index 0a24f454c6..04c5c6aad4 100644
--- a/lib/ffmpeg/libavcodec/allcodecs.c
+++ b/lib/ffmpeg/libavcodec/allcodecs.c
@@ -27,23 +27,23 @@
#include "avcodec.h"
#define REGISTER_HWACCEL(X,x) { \
- extern AVHWAccel x##_hwaccel; \
- if(CONFIG_##X##_HWACCEL) av_register_hwaccel(&x##_hwaccel); }
+ extern AVHWAccel ff_##x##_hwaccel; \
+ if(CONFIG_##X##_HWACCEL) av_register_hwaccel(&ff_##x##_hwaccel); }
#define REGISTER_ENCODER(X,x) { \
- extern AVCodec x##_encoder; \
- if(CONFIG_##X##_ENCODER) avcodec_register(&x##_encoder); }
+ extern AVCodec ff_##x##_encoder; \
+ if(CONFIG_##X##_ENCODER) avcodec_register(&ff_##x##_encoder); }
#define REGISTER_DECODER(X,x) { \
- extern AVCodec x##_decoder; \
- if(CONFIG_##X##_DECODER) avcodec_register(&x##_decoder); }
+ extern AVCodec ff_##x##_decoder; \
+ if(CONFIG_##X##_DECODER) avcodec_register(&ff_##x##_decoder); }
#define REGISTER_ENCDEC(X,x) REGISTER_ENCODER(X,x); REGISTER_DECODER(X,x)
#define REGISTER_PARSER(X,x) { \
- extern AVCodecParser x##_parser; \
- if(CONFIG_##X##_PARSER) av_register_codec_parser(&x##_parser); }
+ extern AVCodecParser ff_##x##_parser; \
+ if(CONFIG_##X##_PARSER) av_register_codec_parser(&ff_##x##_parser); }
#define REGISTER_BSF(X,x) { \
- extern AVBitStreamFilter x##_bsf; \
- if(CONFIG_##X##_BSF) av_register_bitstream_filter(&x##_bsf); }
+ extern AVBitStreamFilter ff_##x##_bsf; \
+ if(CONFIG_##X##_BSF) av_register_bitstream_filter(&ff_##x##_bsf); }
void avcodec_register_all(void)
{
@@ -66,9 +66,12 @@ void avcodec_register_all(void)
REGISTER_HWACCEL (WMV3_VAAPI, wmv3_vaapi);
/* video codecs */
+ REGISTER_ENCODER (A64MULTI, a64multi);
+ REGISTER_ENCODER (A64MULTI5, a64multi5);
REGISTER_DECODER (AASC, aasc);
REGISTER_DECODER (AMV, amv);
REGISTER_DECODER (ANM, anm);
+ REGISTER_DECODER (ANSI, ansi);
REGISTER_ENCDEC (ASV1, asv1);
REGISTER_ENCDEC (ASV2, asv2);
REGISTER_DECODER (AURA, aura);
@@ -125,6 +128,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (JPEGLS, jpegls);
REGISTER_DECODER (KGV1, kgv1);
REGISTER_DECODER (KMVC, kmvc);
+ REGISTER_DECODER (LAGARITH, lagarith);
REGISTER_ENCODER (LJPEG, ljpeg);
REGISTER_DECODER (LOCO, loco);
REGISTER_DECODER (MDEC, mdec);
@@ -160,6 +164,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (QDRAW, qdraw);
REGISTER_DECODER (QPEG, qpeg);
REGISTER_ENCDEC (QTRLE, qtrle);
+ REGISTER_DECODER (R10K, r10k);
REGISTER_DECODER (R210, r210);
REGISTER_ENCDEC (RAWVIDEO, rawvideo);
REGISTER_DECODER (RL2, rl2);
@@ -216,10 +221,13 @@ void avcodec_register_all(void)
/* audio codecs */
REGISTER_ENCDEC (AAC, aac);
+ REGISTER_DECODER (AAC_LATM, aac_latm);
REGISTER_ENCDEC (AC3, ac3);
+ REGISTER_ENCODER (AC3_FIXED, ac3_fixed);
REGISTER_ENCDEC (ALAC, alac);
REGISTER_DECODER (ALS, als);
REGISTER_DECODER (AMRNB, amrnb);
+ REGISTER_DECODER (AMRWB, amrwb);
REGISTER_DECODER (APE, ape);
REGISTER_DECODER (ATRAC1, atrac1);
REGISTER_DECODER (ATRAC3, atrac3);
@@ -279,6 +287,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (PCM_F32LE, pcm_f32le);
REGISTER_ENCDEC (PCM_F64BE, pcm_f64be);
REGISTER_ENCDEC (PCM_F64LE, pcm_f64le);
+ REGISTER_DECODER (PCM_LXF, pcm_lxf);
REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
REGISTER_ENCDEC (PCM_S8, pcm_s8);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
@@ -314,6 +323,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (ADPCM_EA_R2, adpcm_ea_r2);
REGISTER_DECODER (ADPCM_EA_R3, adpcm_ea_r3);
REGISTER_DECODER (ADPCM_EA_XAS, adpcm_ea_xas);
+ REGISTER_ENCDEC (ADPCM_G722, adpcm_g722);
REGISTER_ENCDEC (ADPCM_G726, adpcm_g726);
REGISTER_DECODER (ADPCM_IMA_AMV, adpcm_ima_amv);
REGISTER_DECODER (ADPCM_IMA_DK3, adpcm_ima_dk3);
@@ -335,16 +345,16 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha);
/* subtitles */
+ REGISTER_ENCDEC (ASS, ass);
REGISTER_ENCDEC (DVBSUB, dvbsub);
REGISTER_ENCDEC (DVDSUB, dvdsub);
REGISTER_DECODER (PGSSUB, pgssub);
+ REGISTER_DECODER (SRT, srt);
REGISTER_ENCDEC (XSUB, xsub);
/* 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);
@@ -357,10 +367,12 @@ void avcodec_register_all(void)
REGISTER_ENCODER (LIBVORBIS, libvorbis);
REGISTER_ENCDEC (LIBVPX, libvpx);
REGISTER_ENCODER (LIBX264, libx264);
+ REGISTER_ENCODER (LIBXAVS, libxavs);
REGISTER_ENCODER (LIBXVID, libxvid);
/* parsers */
REGISTER_PARSER (AAC, aac);
+ REGISTER_PARSER (AAC_LATM, aac_latm);
REGISTER_PARSER (AC3, ac3);
REGISTER_PARSER (CAVSVIDEO, cavsvideo);
REGISTER_PARSER (DCA, dca);
@@ -368,10 +380,10 @@ void avcodec_register_all(void)
REGISTER_PARSER (DNXHD, dnxhd);
REGISTER_PARSER (DVBSUB, dvbsub);
REGISTER_PARSER (DVDSUB, dvdsub);
+ REGISTER_PARSER (FLAC, flac);
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);
@@ -388,6 +400,7 @@ void avcodec_register_all(void)
REGISTER_BSF (DUMP_EXTRADATA, dump_extradata);
REGISTER_BSF (H264_MP4TOANNEXB, h264_mp4toannexb);
REGISTER_BSF (IMX_DUMP_HEADER, imx_dump_header);
+ REGISTER_BSF (MJPEG2JPEG, mjpeg2jpeg);
REGISTER_BSF (MJPEGA_DUMP_HEADER, mjpega_dump_header);
REGISTER_BSF (MP3_HEADER_COMPRESS, mp3_header_compress);
REGISTER_BSF (MP3_HEADER_DECOMPRESS, mp3_header_decompress);
diff --git a/lib/ffmpeg/libavcodec/alsdec.c b/lib/ffmpeg/libavcodec/alsdec.c
index bbcbb70652..bfc589d26d 100644
--- a/lib/ffmpeg/libavcodec/alsdec.c
+++ b/lib/ffmpeg/libavcodec/alsdec.c
@@ -36,12 +36,13 @@
#include "bytestream.h"
#include "bgmc.h"
#include "dsputil.h"
+#include "libavcore/samplefmt.h"
#include "libavutil/crc.h"
#include <stdint.h>
/** Rice parameters and corresponding index offsets for decoding the
- * indices of scaled PARCOR values. The table choosen is set globally
+ * indices of scaled PARCOR values. The table chosen is set globally
* by the encoder and stored in ALSSpecificConfig.
*/
static const int8_t parcor_rice_table[3][20][2] = {
@@ -202,8 +203,12 @@ typedef struct {
unsigned int num_blocks; ///< number of blocks used in the current frame
unsigned int s_max; ///< maximum Rice parameter allowed in entropy coding
uint8_t *bgmc_lut; ///< pointer at lookup tables used for BGMC
- unsigned int *bgmc_lut_status; ///< pointer at lookup table status flags used for BGMC
+ int *bgmc_lut_status; ///< pointer at lookup table status flags used for BGMC
int ltp_lag_length; ///< number of bits used for ltp lag value
+ int *const_block; ///< contains const_block flags for all channels
+ unsigned int *shift_lsbs; ///< contains shift_lsbs flags for all channels
+ unsigned int *opt_order; ///< contains opt_order flags for all channels
+ int *store_prev_samples; ///< contains store_prev_samples flags for all channels
int *use_ltp; ///< contains use_ltp flags for all channels
int *ltp_lag; ///< contains ltp lag values for all channels
int **ltp_gain; ///< gain values for ltp 5-tap filter for a channel
@@ -226,12 +231,11 @@ typedef struct {
typedef struct {
unsigned int block_length; ///< number of samples within the block
unsigned int ra_block; ///< if true, this is a random access block
- int const_block; ///< if true, this is a constant value block
- int32_t const_val; ///< the sample value of a constant block
+ int *const_block; ///< if true, this is a constant value block
int js_blocks; ///< true if this block contains a difference signal
- unsigned int shift_lsbs; ///< shift of values for this block
- unsigned int opt_order; ///< prediction order of this block
- int store_prev_samples;///< if true, carryover samples have to be stored
+ unsigned int *shift_lsbs; ///< shift of values for this block
+ unsigned int *opt_order; ///< prediction order of this block
+ int *store_prev_samples;///< if true, carryover samples have to be stored
int *use_ltp; ///< if true, long-term prediction is used
int *ltp_lag; ///< lag value for long-term prediction
int *ltp_gain; ///< gain values for ltp 5-tap filter
@@ -249,24 +253,24 @@ static av_cold void dprint_specific_config(ALSDecContext *ctx)
AVCodecContext *avctx = ctx->avctx;
ALSSpecificConfig *sconf = &ctx->sconf;
- dprintf(avctx, "resolution = %i\n", sconf->resolution);
- dprintf(avctx, "floating = %i\n", sconf->floating);
- dprintf(avctx, "frame_length = %i\n", sconf->frame_length);
- dprintf(avctx, "ra_distance = %i\n", sconf->ra_distance);
- dprintf(avctx, "ra_flag = %i\n", sconf->ra_flag);
- dprintf(avctx, "adapt_order = %i\n", sconf->adapt_order);
- dprintf(avctx, "coef_table = %i\n", sconf->coef_table);
- dprintf(avctx, "long_term_prediction = %i\n", sconf->long_term_prediction);
- dprintf(avctx, "max_order = %i\n", sconf->max_order);
- dprintf(avctx, "block_switching = %i\n", sconf->block_switching);
- dprintf(avctx, "bgmc = %i\n", sconf->bgmc);
- dprintf(avctx, "sb_part = %i\n", sconf->sb_part);
- dprintf(avctx, "joint_stereo = %i\n", sconf->joint_stereo);
- dprintf(avctx, "mc_coding = %i\n", sconf->mc_coding);
- dprintf(avctx, "chan_config = %i\n", sconf->chan_config);
- dprintf(avctx, "chan_sort = %i\n", sconf->chan_sort);
- dprintf(avctx, "RLSLMS = %i\n", sconf->rlslms);
- dprintf(avctx, "chan_config_info = %i\n", sconf->chan_config_info);
+ av_dlog(avctx, "resolution = %i\n", sconf->resolution);
+ av_dlog(avctx, "floating = %i\n", sconf->floating);
+ av_dlog(avctx, "frame_length = %i\n", sconf->frame_length);
+ av_dlog(avctx, "ra_distance = %i\n", sconf->ra_distance);
+ av_dlog(avctx, "ra_flag = %i\n", sconf->ra_flag);
+ av_dlog(avctx, "adapt_order = %i\n", sconf->adapt_order);
+ av_dlog(avctx, "coef_table = %i\n", sconf->coef_table);
+ av_dlog(avctx, "long_term_prediction = %i\n", sconf->long_term_prediction);
+ av_dlog(avctx, "max_order = %i\n", sconf->max_order);
+ av_dlog(avctx, "block_switching = %i\n", sconf->block_switching);
+ av_dlog(avctx, "bgmc = %i\n", sconf->bgmc);
+ av_dlog(avctx, "sb_part = %i\n", sconf->sb_part);
+ av_dlog(avctx, "joint_stereo = %i\n", sconf->joint_stereo);
+ av_dlog(avctx, "mc_coding = %i\n", sconf->mc_coding);
+ av_dlog(avctx, "chan_config = %i\n", sconf->chan_config);
+ av_dlog(avctx, "chan_sort = %i\n", sconf->chan_sort);
+ av_dlog(avctx, "RLSLMS = %i\n", sconf->rlslms);
+ av_dlog(avctx, "chan_config_info = %i\n", sconf->chan_config_info);
#endif
}
@@ -553,20 +557,20 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
AVCodecContext *avctx = ctx->avctx;
GetBitContext *gb = &ctx->gb;
- bd->const_val = 0;
- bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence)
+ *bd->raw_samples = 0;
+ *bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence)
bd->js_blocks = get_bits1(gb);
// skip 5 reserved bits
skip_bits(gb, 5);
- if (bd->const_block) {
+ if (*bd->const_block) {
unsigned int const_val_bits = sconf->floating ? 24 : avctx->bits_per_raw_sample;
- bd->const_val = get_sbits_long(gb, const_val_bits);
+ *bd->raw_samples = get_sbits_long(gb, const_val_bits);
}
// ensure constant block decoding by reusing this field
- bd->const_block = 1;
+ *bd->const_block = 1;
}
@@ -574,9 +578,9 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
*/
static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
{
- int smp = bd->block_length;
- int32_t val = bd->const_val;
- int32_t *dst = bd->raw_samples;
+ int smp = bd->block_length - 1;
+ int32_t val = *bd->raw_samples;
+ int32_t *dst = bd->raw_samples + 1;
// write raw samples into buffer
for (; smp; smp--)
@@ -603,12 +607,12 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
// ensure variable block decoding by reusing this field
- bd->const_block = 0;
+ *bd->const_block = 0;
- bd->opt_order = 1;
+ *bd->opt_order = 1;
bd->js_blocks = get_bits1(gb);
- opt_order = bd->opt_order;
+ opt_order = *bd->opt_order;
// determine the number of subblocks for entropy decoding
if (!sconf->bgmc && !sconf->sb_part) {
@@ -648,21 +652,21 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
}
if (get_bits1(gb))
- bd->shift_lsbs = get_bits(gb, 4) + 1;
+ *bd->shift_lsbs = get_bits(gb, 4) + 1;
- bd->store_prev_samples = (bd->js_blocks && bd->raw_other) || bd->shift_lsbs;
+ *bd->store_prev_samples = (bd->js_blocks && bd->raw_other) || *bd->shift_lsbs;
if (!sconf->rlslms) {
if (sconf->adapt_order) {
int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
2, sconf->max_order + 1));
- bd->opt_order = get_bits(gb, opt_order_length);
+ *bd->opt_order = get_bits(gb, opt_order_length);
} else {
- bd->opt_order = sconf->max_order;
+ *bd->opt_order = sconf->max_order;
}
- opt_order = bd->opt_order;
+ opt_order = *bd->opt_order;
if (opt_order) {
int add_base;
@@ -748,7 +752,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
// read all residuals
if (sconf->bgmc) {
- unsigned int delta[8];
+ 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;
@@ -839,7 +843,7 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
unsigned int block_length = bd->block_length;
unsigned int smp = 0;
unsigned int k;
- int opt_order = bd->opt_order;
+ int opt_order = *bd->opt_order;
int sb;
int64_t y;
int32_t *quant_cof = bd->quant_cof;
@@ -884,7 +888,7 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
parcor_to_lpc(k, quant_cof, lpc_cof);
// store previous samples in case that they have to be altered
- if (bd->store_prev_samples)
+ if (*bd->store_prev_samples)
memcpy(bd->prev_raw_samples, raw_samples - sconf->max_order,
sizeof(*bd->prev_raw_samples) * sconf->max_order);
@@ -905,9 +909,9 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
}
// reconstruct shifted signal
- if (bd->shift_lsbs)
+ if (*bd->shift_lsbs)
for (sb = -1; sb >= -sconf->max_order; sb--)
- raw_samples[sb] >>= bd->shift_lsbs;
+ raw_samples[sb] >>= *bd->shift_lsbs;
}
// reverse linear prediction coefficients for efficiency
@@ -932,7 +936,7 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
raw_samples = bd->raw_samples;
// restore previous samples in case that they have been altered
- if (bd->store_prev_samples)
+ if (*bd->store_prev_samples)
memcpy(raw_samples - sconf->max_order, bd->prev_raw_samples,
sizeof(*raw_samples) * sconf->max_order);
@@ -946,6 +950,7 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
{
GetBitContext *gb = &ctx->gb;
+ *bd->shift_lsbs = 0;
// read block type flag and read the samples accordingly
if (get_bits1(gb)) {
if (read_var_block_data(ctx, bd))
@@ -965,16 +970,16 @@ static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
unsigned int smp;
// read block type flag and read the samples accordingly
- if (bd->const_block)
+ if (*bd->const_block)
decode_const_block_data(ctx, bd);
else if (decode_var_block_data(ctx, bd))
return -1;
// TODO: read RLSLMS extension data
- if (bd->shift_lsbs)
+ if (*bd->shift_lsbs)
for (smp = 0; smp < bd->block_length; smp++)
- bd->raw_samples[smp] <<= bd->shift_lsbs;
+ bd->raw_samples[smp] <<= *bd->shift_lsbs;
return 0;
}
@@ -1025,6 +1030,10 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
memset(&bd, 0, sizeof(ALSBlockData));
bd.ra_block = ra_frame;
+ bd.const_block = ctx->const_block;
+ bd.shift_lsbs = ctx->shift_lsbs;
+ bd.opt_order = ctx->opt_order;
+ bd.store_prev_samples = ctx->store_prev_samples;
bd.use_ltp = ctx->use_ltp;
bd.ltp_lag = ctx->ltp_lag;
bd.ltp_gain = ctx->ltp_gain[0];
@@ -1035,7 +1044,6 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
for (b = 0; b < ctx->num_blocks; b++) {
- bd.shift_lsbs = 0;
bd.block_length = div_blocks[b];
if (read_decode_block(ctx, &bd)) {
@@ -1065,6 +1073,10 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
memset(bd, 0, 2 * sizeof(ALSBlockData));
bd[0].ra_block = ra_frame;
+ bd[0].const_block = ctx->const_block;
+ bd[0].shift_lsbs = ctx->shift_lsbs;
+ bd[0].opt_order = ctx->opt_order;
+ bd[0].store_prev_samples = ctx->store_prev_samples;
bd[0].use_ltp = ctx->use_ltp;
bd[0].ltp_lag = ctx->ltp_lag;
bd[0].ltp_gain = ctx->ltp_gain[0];
@@ -1074,6 +1086,10 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
bd[0].js_blocks = *js_blocks;
bd[1].ra_block = ra_frame;
+ bd[1].const_block = ctx->const_block;
+ bd[1].shift_lsbs = ctx->shift_lsbs;
+ bd[1].opt_order = ctx->opt_order;
+ bd[1].store_prev_samples = ctx->store_prev_samples;
bd[1].use_ltp = ctx->use_ltp;
bd[1].ltp_lag = ctx->ltp_lag;
bd[1].ltp_gain = ctx->ltp_gain[0];
@@ -1086,9 +1102,6 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
for (b = 0; b < ctx->num_blocks; b++) {
unsigned int s;
- bd[0].shift_lsbs = 0;
- bd[1].shift_lsbs = 0;
-
bd[0].block_length = div_blocks[b];
bd[1].block_length = div_blocks[b];
@@ -1206,6 +1219,10 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
return -1;
}
+ bd->const_block = ctx->const_block + c;
+ bd->shift_lsbs = ctx->shift_lsbs + c;
+ bd->opt_order = ctx->opt_order + c;
+ bd->store_prev_samples = ctx->store_prev_samples + c;
bd->use_ltp = ctx->use_ltp + c;
bd->ltp_lag = ctx->ltp_lag + c;
bd->ltp_gain = ctx->ltp_gain[c];
@@ -1339,10 +1356,13 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
get_block_sizes(ctx, div_blocks, &bs_info);
for (b = 0; b < ctx->num_blocks; b++) {
- bd.shift_lsbs = 0;
bd.block_length = div_blocks[b];
for (c = 0; c < avctx->channels; c++) {
+ bd.const_block = ctx->const_block + c;
+ bd.shift_lsbs = ctx->shift_lsbs + c;
+ bd.opt_order = ctx->opt_order + c;
+ bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
@@ -1362,6 +1382,10 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
return -1;
for (c = 0; c < avctx->channels; c++) {
+ bd.const_block = ctx->const_block + c;
+ bd.shift_lsbs = ctx->shift_lsbs + c;
+ bd.opt_order = ctx->opt_order + c;
+ bd.store_prev_samples = ctx->store_prev_samples + c;
bd.use_ltp = ctx->use_ltp + c;
bd.ltp_lag = ctx->ltp_lag + c;
bd.ltp_gain = ctx->ltp_gain[c];
@@ -1426,7 +1450,7 @@ static int decode_frame(AVCodecContext *avctx,
// check for size of decoded data
size = ctx->cur_frame_length * avctx->channels *
- (av_get_bits_per_sample_format(avctx->sample_fmt) >> 3);
+ (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3);
if (size > *data_size) {
av_log(avctx, AV_LOG_ERROR, "Decoded data exceeds buffer size.\n");
@@ -1521,6 +1545,10 @@ static av_cold int decode_end(AVCodecContext *avctx)
ff_bgmc_end(&ctx->bgmc_lut, &ctx->bgmc_lut_status);
+ av_freep(&ctx->const_block);
+ av_freep(&ctx->shift_lsbs);
+ av_freep(&ctx->opt_order);
+ av_freep(&ctx->store_prev_samples);
av_freep(&ctx->use_ltp);
av_freep(&ctx->ltp_lag);
av_freep(&ctx->ltp_gain);
@@ -1536,6 +1564,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
av_freep(&ctx->chan_data);
av_freep(&ctx->chan_data_buffer);
av_freep(&ctx->reverted_channels);
+ av_freep(&ctx->crc_buffer);
return 0;
}
@@ -1572,11 +1601,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
if (sconf->floating) {
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->bits_per_raw_sample = 32;
} else {
avctx->sample_fmt = sconf->resolution > 1
- ? SAMPLE_FMT_S32 : SAMPLE_FMT_S16;
+ ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8;
}
@@ -1615,13 +1644,19 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
// allocate and assign lag and gain data buffer for ltp mode
+ ctx->const_block = av_malloc (sizeof(*ctx->const_block) * num_buffers);
+ ctx->shift_lsbs = av_malloc (sizeof(*ctx->shift_lsbs) * num_buffers);
+ ctx->opt_order = av_malloc (sizeof(*ctx->opt_order) * num_buffers);
+ ctx->store_prev_samples = av_malloc(sizeof(*ctx->store_prev_samples) * num_buffers);
ctx->use_ltp = av_mallocz(sizeof(*ctx->use_ltp) * num_buffers);
ctx->ltp_lag = av_malloc (sizeof(*ctx->ltp_lag) * num_buffers);
ctx->ltp_gain = av_malloc (sizeof(*ctx->ltp_gain) * num_buffers);
ctx->ltp_gain_buffer = av_malloc (sizeof(*ctx->ltp_gain_buffer) *
num_buffers * 5);
- if (!ctx->use_ltp || !ctx->ltp_lag ||
+ if (!ctx->const_block || !ctx->shift_lsbs ||
+ !ctx->opt_order || !ctx->store_prev_samples ||
+ !ctx->use_ltp || !ctx->ltp_lag ||
!ctx->ltp_gain || !ctx->ltp_gain_buffer) {
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
decode_end(avctx);
@@ -1679,7 +1714,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
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));
+ (av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3));
if (!ctx->crc_buffer) {
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
decode_end(avctx);
@@ -1703,7 +1738,7 @@ static av_cold void flush(AVCodecContext *avctx)
}
-AVCodec als_decoder = {
+AVCodec ff_als_decoder = {
"als",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MP4ALS,
diff --git a/lib/ffmpeg/libavcodec/amr.h b/lib/ffmpeg/libavcodec/amr.h
new file mode 100644
index 0000000000..7e5a4dce5b
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/amr.h
@@ -0,0 +1,68 @@
+/*
+ * Shared functions between AMR codecs
+ *
+ * Copyright (c) 2010 Marcelo Galvao Povoa
+ *
+ * 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_AMR_H
+#define AVCODEC_AMR_H
+
+#include "avcodec.h"
+
+#ifdef AMR_USE_16BIT_TABLES
+#define R_TABLE_TYPE uint16_t
+#else
+#define R_TABLE_TYPE uint8_t
+#endif
+
+/**
+ * Fill the frame structure variables from bitstream by parsing the
+ * given reordering table that uses the following format:
+ *
+ * Each field (16 bits) in the AMR Frame is stored as:
+ * - one byte for the number of bits in the field
+ * - one byte for the field index
+ * - then, one byte for each bit of the field (from most-significant to least)
+ * of the position of that bit in the AMR frame.
+ *
+ * @param out pointer to the frame struct
+ * @param size the size in bytes of the frame struct
+ * @param data input bitstream after the frame header
+ * @param ord_table the reordering table as above
+ */
+static inline void ff_amr_bit_reorder(uint16_t *out, int size,
+ const uint8_t *data,
+ const R_TABLE_TYPE *ord_table)
+{
+ int field_size;
+
+ memset(out, 0, size);
+ while ((field_size = *ord_table++)) {
+ int field = 0;
+ int field_offset = *ord_table++;
+ while (field_size--) {
+ int bit = *ord_table++;
+ field <<= 1;
+ field |= data[bit >> 3] >> (bit & 7) & 1;
+ }
+ out[field_offset] = field;
+ }
+}
+
+#endif /* AVCODEC_AMR_H */
diff --git a/lib/ffmpeg/libavcodec/amrnbdec.c b/lib/ffmpeg/libavcodec/amrnbdec.c
index d3fa7653f8..ec896c7dfb 100644
--- a/lib/ffmpeg/libavcodec/amrnbdec.c
+++ b/lib/ffmpeg/libavcodec/amrnbdec.c
@@ -52,6 +52,7 @@
#include "acelp_vectors.h"
#include "acelp_pitch_delay.h"
#include "lsp.h"
+#include "amr.h"
#include "amrnbdata.h"
@@ -153,7 +154,7 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx)
AMRContext *p = avctx->priv_data;
int i;
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
// p->excitation always points to the same position in p->excitation_buf
p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1];
@@ -195,24 +196,9 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
p->bad_frame_indicator = !get_bits1(&gb); // quality bit
skip_bits(&gb, 2); // two padding bits
- if (mode < MODE_DTX) {
- uint16_t *data = (uint16_t *)&p->frame;
- const uint8_t *order = amr_unpacking_bitmaps_per_mode[mode];
- int field_size;
-
- memset(&p->frame, 0, sizeof(AMRNBFrame));
- buf++;
- while ((field_size = *order++)) {
- int field = 0;
- int field_offset = *order++;
- while (field_size--) {
- int bit = *order++;
- field <<= 1;
- field |= buf[bit >> 3] >> (bit & 7) & 1;
- }
- data[field_offset] = field;
- }
- }
+ if (mode < MODE_DTX)
+ ff_amr_bit_reorder((uint16_t *) &p->frame, sizeof(AMRNBFrame), buf + 1,
+ amr_unpacking_bitmaps_per_mode[mode]);
return mode;
}
@@ -222,20 +208,6 @@ static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
/// @{
/**
- * Convert an lsf vector into an lsp vector.
- *
- * @param lsf input lsf vector
- * @param lsp output lsp vector
- */
-static void lsf2lsp(const float *lsf, double *lsp)
-{
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER; i++)
- lsp[i] = cos(2.0 * M_PI * lsf[i]);
-}
-
-/**
* Interpolate the LSF vector (used for fixed gain smoothing).
* The interpolation is done over all four subframes even in MODE_12k2.
*
@@ -293,7 +265,7 @@ static void lsf2lsp_for_mode12k2(AMRContext *p, double lsp[LP_FILTER_ORDER],
if (update)
interpolate_lsf(p->lsf_q, lsf_q);
- lsf2lsp(lsf_q, lsp);
+ ff_acelp_lsf2lspd(lsp, lsf_q, LP_FILTER_ORDER);
}
/**
@@ -357,7 +329,7 @@ static void lsf2lsp_3(AMRContext *p)
interpolate_lsf(p->lsf_q, lsf_q);
memcpy(p->prev_lsf_r, lsf_r, LP_FILTER_ORDER * sizeof(*lsf_r));
- lsf2lsp(lsf_q, p->lsp[3]);
+ ff_acelp_lsf2lspd(p->lsp[3], lsf_q, LP_FILTER_ORDER);
// interpolate LSP vectors at subframes 1, 2 and 3
for (i = 1; i <= 3; i++)
@@ -1064,7 +1036,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
-AVCodec amrnb_decoder = {
+AVCodec ff_amrnb_decoder = {
.name = "amrnb",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_AMR_NB,
@@ -1072,5 +1044,5 @@ AVCodec amrnb_decoder = {
.init = amrnb_decode_init,
.decode = amrnb_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"),
- .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_FLT,SAMPLE_FMT_NONE},
+ .sample_fmts = (enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
};
diff --git a/lib/ffmpeg/libavcodec/amrwbdata.h b/lib/ffmpeg/libavcodec/amrwbdata.h
new file mode 100644
index 0000000000..36553d5a0f
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/amrwbdata.h
@@ -0,0 +1,1890 @@
+/*
+ * AMR wideband data and definitions
+ * Copyright (c) 2010 Marcelo Galvao Povoa
+ *
+ * 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
+ * AMR wideband data and definitions
+ */
+
+#ifndef AVCODEC_AMRWBDATA_H
+#define AVCODEC_AMRWBDATA_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#define LP_ORDER 16 ///< linear predictive coding filter order
+#define LP_ORDER_16k 20 ///< lpc filter order at 16kHz
+#define HB_FIR_SIZE 30 ///< amount of past data needed by HB filters
+#define UPS_FIR_SIZE 12 ///< upsampling filter size
+#define UPS_MEM_SIZE (2 * UPS_FIR_SIZE)
+
+#define MIN_ISF_SPACING (128.0 / 32768.0) ///< minimum isf gap
+#define PRED_FACTOR (1.0 / 3.0)
+#define MIN_ENERGY -14.0 ///< initial innnovation energy (dB)
+#define ENERGY_MEAN 30.0 ///< mean innovation energy (dB) in all modes
+#define PREEMPH_FAC 0.68 ///< factor used to de-emphasize synthesis
+
+#define AMRWB_SFR_SIZE 64 ///< samples per subframe at 12.8 kHz
+#define AMRWB_SFR_SIZE_16k 80 ///< samples per subframe at 16 kHz
+#define AMRWB_P_DELAY_MAX 231 ///< maximum pitch delay value
+#define AMRWB_P_DELAY_MIN 34
+
+/* Relative mode ordering is sensitive */
+enum Mode {
+ MODE_6k60 = 0, ///< 6.60 kbit/s
+ MODE_8k85, ///< 8.85 kbit/s
+ MODE_12k65, ///< 12.65 kbit/s
+ MODE_14k25, ///< 14.25 kbit/s
+ MODE_15k85, ///< 15.85 kbit/s
+ MODE_18k25, ///< 18.25 kbit/s
+ MODE_19k85, ///< 19.85 kbit/s
+ MODE_23k05, ///< 23.05 kbit/s
+ MODE_23k85, ///< 23.85 kbit/s
+ MODE_SID, ///< comfort noise frame
+ /* 10-13: Future use */
+ SP_LOST = 14, ///< speech lost
+ NO_DATA ///< no transmission
+};
+
+/* All decoded parameters in these structs must be 2 bytes long
+ * because of the direct indexing at the frame parsing */
+typedef struct {
+ uint16_t adap; ///< adaptive codebook index
+ uint16_t ltp; ///< ltp-filtering flag
+ uint16_t vq_gain; ///< VQ adaptive and innovative gains
+ uint16_t hb_gain; ///< high-band energy index (mode 23k85 only)
+ uint16_t pul_ih[4]; ///< MSBs part of codebook index (high modes only)
+ uint16_t pul_il[4]; ///< LSBs part of codebook index
+} AMRWBSubFrame;
+
+typedef struct {
+ uint16_t vad; ///< voice activity detection flag
+ uint16_t isp_id[7]; ///< index of ISP subvectors
+ AMRWBSubFrame subframe[4]; ///< data for subframes
+} AMRWBFrame;
+
+/** The index of a frame parameter */
+#define AMR_BIT(field) (offsetof(AMRWBFrame, field) >> 1)
+/** The index of a subframe-specific parameter */
+#define AMR_OF(frame_num, variable) AMR_BIT(subframe[frame_num].variable)
+
+//As defined in 3GPP TS 26.201 V9.0.0
+//Tables for bit parsing in Core Frame speech frames
+//The reordered bits are in order of decreasing importance and
+//may be contiguously separated in Class A, B and C bits.
+
+// Each field in AMRWBFrame is stored as:
+// * one byte for the number of bits in the field
+// * one byte for the field index
+// * then, one byte for each bit of the field (from most-significant to least)
+// of the position of that bit in the AMR frame.
+static const uint16_t order_MODE_6k60[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 24, 33, 39, 12, 6, 5, 4, 13,
+ 8, AMR_BIT(isp_id[1]), 65, 79, 64, 78, 51, 61, 71, 70,
+ 7, AMR_BIT(isp_id[2]), 52, 55, 44, 54, 53, 43, 42,
+ 7, AMR_BIT(isp_id[3]), 60, 59, 58, 57, 56, 75, 74,
+ 6, AMR_BIT(isp_id[4]), 73, 72, 86, 87, 85, 84,
+ 8, AMR_OF(0, adap), 11, 10, 9, 8, 28, 27, 49, 69,
+ 6, AMR_OF(0, pul_il[0]), 83, 91, 99, 107, 115, 123,
+ 6, AMR_OF(0, pul_il[1]), 82, 103, 111, 119, 127, 135,
+ 6, AMR_OF(0, vq_gain), 38, 23, 34, 19, 3, 15,
+ 5, AMR_OF(1, adap), 32, 41, 63, 67, 77,
+ 6, AMR_OF(1, pul_il[0]), 81, 90, 98, 106, 114, 122,
+ 6, AMR_OF(1, pul_il[1]), 80, 102, 110, 118, 126, 134,
+ 6, AMR_OF(1, vq_gain), 26, 22, 36, 18, 2, 14,
+ 5, AMR_OF(2, adap), 45, 40, 50, 48, 68,
+ 6, AMR_OF(2, pul_il[0]), 95, 89, 97, 105, 113, 121,
+ 6, AMR_OF(2, pul_il[1]), 94, 101, 109, 117, 125, 133,
+ 6, AMR_OF(2, vq_gain), 37, 21, 35, 17, 1, 31,
+ 5, AMR_OF(3, adap), 47, 46, 62, 66, 76,
+ 6, AMR_OF(3, pul_il[0]), 93, 88, 96, 104, 112, 120,
+ 6, AMR_OF(3, pul_il[1]), 92, 100, 108, 116, 124, 132,
+ 6, AMR_OF(3, vq_gain), 25, 20, 29, 16, 0, 30,
+ 0
+};
+
+static const uint16_t order_MODE_8k85[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 47, 32, 2, 6, 3, 5, 4, 60,
+ 8, AMR_BIT(isp_id[1]), 69, 50, 67, 41, 51, 49, 59, 53,
+ 6, AMR_BIT(isp_id[2]), 40, 55, 43, 54, 42, 62,
+ 7, AMR_BIT(isp_id[3]), 63, 48, 52, 61, 77, 78, 72,
+ 7, AMR_BIT(isp_id[4]), 85, 56, 86, 68, 74, 73, 81,
+ 5, AMR_BIT(isp_id[5]), 82, 95, 80, 94, 91,
+ 5, AMR_BIT(isp_id[6]), 90, 89, 88, 103, 87,
+ 8, AMR_OF(0, adap), 1, 0, 15, 35, 33, 58, 64, 84,
+ 5, AMR_OF(0, pul_il[0]), 102, 118, 134, 150, 166,
+ 5, AMR_OF(0, pul_il[1]), 101, 114, 130, 146, 162,
+ 5, AMR_OF(0, pul_il[2]), 100, 126, 142, 158, 174,
+ 5, AMR_OF(0, pul_il[3]), 99, 122, 138, 154, 170,
+ 6, AMR_OF(0, vq_gain), 11, 39, 19, 31, 27, 23,
+ 5, AMR_OF(1, adap), 46, 71, 66, 76, 93,
+ 5, AMR_OF(1, pul_il[0]), 98, 117, 133, 149, 165,
+ 5, AMR_OF(1, pul_il[1]), 97, 113, 129, 145, 161,
+ 5, AMR_OF(1, pul_il[2]), 96, 125, 141, 157, 173,
+ 5, AMR_OF(1, pul_il[3]), 111, 121, 137, 153, 169,
+ 6, AMR_OF(1, vq_gain), 10, 38, 18, 30, 26, 22,
+ 8, AMR_OF(2, adap), 14, 13, 12, 34, 45, 57, 79, 83,
+ 5, AMR_OF(2, pul_il[0]), 110, 116, 132, 148, 164,
+ 5, AMR_OF(2, pul_il[1]), 109, 112, 128, 144, 160,
+ 5, AMR_OF(2, pul_il[2]), 108, 124, 140, 156, 172,
+ 5, AMR_OF(2, pul_il[3]), 107, 120, 136, 152, 168,
+ 6, AMR_OF(2, vq_gain), 9, 37, 17, 29, 25, 21,
+ 5, AMR_OF(3, adap), 44, 70, 65, 75, 92,
+ 5, AMR_OF(3, pul_il[0]), 106, 115, 131, 147, 163,
+ 5, AMR_OF(3, pul_il[1]), 105, 127, 143, 159, 175,
+ 5, AMR_OF(3, pul_il[2]), 104, 123, 139, 155, 171,
+ 5, AMR_OF(3, pul_il[3]), 119, 135, 151, 167, 183,
+ 6, AMR_OF(3, vq_gain), 8, 36, 16, 28, 24, 20,
+ 0
+};
+
+static const uint16_t order_MODE_12k65[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
+ 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
+ 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
+ 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
+ 92,
+ 1, AMR_OF(0, ltp), 110,
+ 9, AMR_OF(0, pul_il[0]), 106, 122, 154, 186, 218, 134, 166, 198,
+ 230,
+ 9, AMR_OF(0, pul_il[1]), 105, 130, 162, 194, 226, 142, 174, 206,
+ 238,
+ 9, AMR_OF(0, pul_il[2]), 104, 138, 170, 202, 234, 150, 182, 214,
+ 246,
+ 9, AMR_OF(0, pul_il[3]), 119, 146, 178, 210, 242, 158, 190, 222,
+ 254,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
+ 1, AMR_OF(1, ltp), 109,
+ 9, AMR_OF(1, pul_il[0]), 118, 121, 153, 185, 217, 133, 165, 197,
+ 229,
+ 9, AMR_OF(1, pul_il[1]), 117, 129, 161, 193, 225, 141, 173, 205,
+ 237,
+ 9, AMR_OF(1, pul_il[2]), 116, 137, 169, 201, 233, 149, 181, 213,
+ 245,
+ 9, AMR_OF(1, pul_il[3]), 115, 145, 177, 209, 241, 157, 189, 221,
+ 253,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
+ 91,
+ 1, AMR_OF(2, ltp), 108,
+ 9, AMR_OF(2, pul_il[0]), 114, 120, 152, 184, 216, 132, 164, 196,
+ 228,
+ 9, AMR_OF(2, pul_il[1]), 113, 128, 160, 192, 224, 140, 172, 204,
+ 236,
+ 9, AMR_OF(2, pul_il[2]), 112, 136, 168, 200, 232, 148, 180, 212,
+ 244,
+ 9, AMR_OF(2, pul_il[3]), 127, 144, 176, 208, 240, 156, 188, 220,
+ 252,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
+ 1, AMR_OF(3, ltp), 107,
+ 9, AMR_OF(3, pul_il[0]), 126, 135, 167, 199, 231, 131, 163, 195,
+ 227,
+ 9, AMR_OF(3, pul_il[1]), 125, 143, 175, 207, 239, 139, 171, 203,
+ 235,
+ 9, AMR_OF(3, pul_il[2]), 124, 151, 183, 215, 247, 147, 179, 211,
+ 243,
+ 9, AMR_OF(3, pul_il[3]), 123, 159, 191, 223, 255, 155, 187, 219,
+ 251,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 0
+};
+
+static const uint16_t order_MODE_14k25[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
+ 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
+ 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
+ 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
+ 92,
+ 1, AMR_OF(0, ltp), 110,
+ 13, AMR_OF(0, pul_il[0]), 114, 186, 210, 234, 258, 106, 126, 162,
+ 170, 198, 222, 246, 270,
+ 13, AMR_OF(0, pul_il[1]), 122, 194, 218, 242, 266, 118, 134, 174,
+ 182, 206, 230, 254, 278,
+ 9, AMR_OF(0, pul_il[2]), 130, 138, 146, 154, 178, 202, 226, 250,
+ 274,
+ 9, AMR_OF(0, pul_il[3]), 142, 150, 158, 166, 190, 214, 238, 262,
+ 286,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
+ 1, AMR_OF(1, ltp), 109,
+ 13, AMR_OF(1, pul_il[0]), 113, 185, 209, 233, 257, 105, 125, 161,
+ 169, 197, 221, 245, 269,
+ 13, AMR_OF(1, pul_il[1]), 121, 193, 217, 241, 265, 117, 133, 173,
+ 181, 205, 229, 253, 277,
+ 9, AMR_OF(1, pul_il[2]), 129, 137, 145, 153, 177, 201, 225, 249,
+ 273,
+ 9, AMR_OF(1, pul_il[3]), 141, 149, 157, 165, 189, 213, 237, 261,
+ 285,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
+ 91,
+ 1, AMR_OF(2, ltp), 108,
+ 13, AMR_OF(2, pul_il[0]), 112, 184, 208, 232, 256, 104, 124, 160,
+ 168, 196, 220, 244, 268,
+ 13, AMR_OF(2, pul_il[1]), 120, 192, 216, 240, 264, 116, 132, 172,
+ 180, 204, 228, 252, 276,
+ 9, AMR_OF(2, pul_il[2]), 128, 136, 144, 152, 176, 200, 224, 248,
+ 272,
+ 9, AMR_OF(2, pul_il[3]), 140, 148, 156, 164, 188, 212, 236, 260,
+ 284,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
+ 1, AMR_OF(3, ltp), 107,
+ 13, AMR_OF(3, pul_il[0]), 127, 199, 223, 247, 271, 119, 123, 175,
+ 183, 195, 219, 243, 267,
+ 13, AMR_OF(3, pul_il[1]), 135, 207, 231, 255, 279, 115, 131, 171,
+ 179, 203, 227, 251, 275,
+ 9, AMR_OF(3, pul_il[2]), 143, 151, 159, 167, 191, 215, 239, 263,
+ 287,
+ 9, AMR_OF(3, pul_il[3]), 139, 147, 155, 163, 187, 211, 235, 259,
+ 283,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 0
+};
+
+static const uint16_t order_MODE_15k85[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
+ 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
+ 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
+ 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
+ 92,
+ 1, AMR_OF(0, ltp), 110,
+ 13, AMR_OF(0, pul_il[0]), 122, 154, 170, 218, 266, 138, 106, 182,
+ 230, 278, 178, 226, 274,
+ 13, AMR_OF(0, pul_il[1]), 134, 166, 190, 238, 286, 150, 118, 186,
+ 234, 282, 198, 246, 294,
+ 13, AMR_OF(0, pul_il[2]), 130, 162, 194, 242, 290, 146, 114, 206,
+ 254, 302, 202, 250, 298,
+ 13, AMR_OF(0, pul_il[3]), 142, 174, 214, 262, 310, 158, 126, 210,
+ 258, 306, 222, 270, 318,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
+ 1, AMR_OF(1, ltp), 109,
+ 13, AMR_OF(1, pul_il[0]), 121, 153, 169, 217, 265, 137, 105, 181,
+ 229, 277, 177, 225, 273,
+ 13, AMR_OF(1, pul_il[1]), 133, 165, 189, 237, 285, 149, 117, 185,
+ 233, 281, 197, 245, 293,
+ 13, AMR_OF(1, pul_il[2]), 129, 161, 193, 241, 289, 145, 113, 205,
+ 253, 301, 201, 249, 297,
+ 13, AMR_OF(1, pul_il[3]), 141, 173, 213, 261, 309, 157, 125, 209,
+ 257, 305, 221, 269, 317,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
+ 91,
+ 1, AMR_OF(2, ltp), 108,
+ 13, AMR_OF(2, pul_il[0]), 120, 152, 168, 216, 264, 136, 104, 180,
+ 228, 276, 176, 224, 272,
+ 13, AMR_OF(2, pul_il[1]), 132, 164, 188, 236, 284, 148, 116, 184,
+ 232, 280, 196, 244, 292,
+ 13, AMR_OF(2, pul_il[2]), 128, 160, 192, 240, 288, 144, 112, 204,
+ 252, 300, 200, 248, 296,
+ 13, AMR_OF(2, pul_il[3]), 140, 172, 212, 260, 308, 156, 124, 208,
+ 256, 304, 220, 268, 316,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
+ 1, AMR_OF(3, ltp), 107,
+ 13, AMR_OF(3, pul_il[0]), 135, 167, 183, 231, 279, 151, 119, 179,
+ 227, 275, 191, 239, 287,
+ 13, AMR_OF(3, pul_il[1]), 131, 163, 187, 235, 283, 147, 115, 199,
+ 247, 295, 195, 243, 291,
+ 13, AMR_OF(3, pul_il[2]), 143, 175, 207, 255, 303, 159, 127, 203,
+ 251, 299, 215, 263, 311,
+ 13, AMR_OF(3, pul_il[3]), 139, 171, 211, 259, 307, 155, 123, 223,
+ 271, 319, 219, 267, 315,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 0
+};
+
+static const uint16_t order_MODE_18k25[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
+ 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
+ 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
+ 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
+ 92,
+ 1, AMR_OF(0, ltp), 110,
+ 2, AMR_OF(0, pul_ih[0]), 124, 115,
+ 2, AMR_OF(0, pul_ih[1]), 150, 117,
+ 2, AMR_OF(0, pul_ih[2]), 129, 114,
+ 2, AMR_OF(0, pul_ih[3]), 121, 131,
+ 14, AMR_OF(0, pul_il[0]), 161, 257, 343, 199, 177, 303, 204, 173,
+ 168, 260, 277, 307, 338, 128,
+ 14, AMR_OF(0, pul_il[1]), 194, 286, 347, 222, 214, 316, 236, 152,
+ 166, 242, 284, 308, 344, 142,
+ 14, AMR_OF(0, pul_il[2]), 169, 273, 353, 202, 189, 311, 240, 200,
+ 171, 261, 309, 296, 345, 130,
+ 14, AMR_OF(0, pul_il[3]), 198, 275, 349, 187, 163, 282, 193, 195,
+ 175, 234, 265, 289, 328, 119,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
+ 1, AMR_OF(1, ltp), 109,
+ 2, AMR_OF(1, pul_ih[0]), 139, 104,
+ 2, AMR_OF(1, pul_ih[1]), 135, 118,
+ 2, AMR_OF(1, pul_ih[2]), 112, 127,
+ 2, AMR_OF(1, pul_ih[3]), 140, 141,
+ 14, AMR_OF(1, pul_il[0]), 179, 276, 340, 225, 223, 321, 235, 190,
+ 182, 271, 310, 315, 352, 125,
+ 14, AMR_OF(1, pul_il[1]), 153, 264, 329, 232, 209, 323, 231, 165,
+ 191, 279, 290, 312, 367, 134,
+ 14, AMR_OF(1, pul_il[2]), 167, 269, 341, 205, 197, 298, 224, 160,
+ 170, 259, 280, 317, 357, 148,
+ 14, AMR_OF(1, pul_il[3]), 203, 272, 342, 227, 192, 299, 233, 172,
+ 183, 256, 283, 326, 355, 106,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
+ 91,
+ 1, AMR_OF(2, ltp), 108,
+ 2, AMR_OF(2, pul_ih[0]), 144, 120,
+ 2, AMR_OF(2, pul_ih[1]), 157, 123,
+ 2, AMR_OF(2, pul_ih[2]), 145, 138,
+ 2, AMR_OF(2, pul_ih[3]), 132, 154,
+ 14, AMR_OF(2, pul_il[0]), 241, 319, 365, 252, 253, 331, 254, 230,
+ 220, 263, 285, 314, 364, 156,
+ 14, AMR_OF(2, pul_il[1]), 247, 291, 339, 249, 250, 332, 267, 196,
+ 207, 268, 304, 324, 356, 158,
+ 14, AMR_OF(2, pul_il[2]), 210, 300, 348, 243, 237, 333, 246, 206,
+ 219, 266, 318, 335, 363, 159,
+ 14, AMR_OF(2, pul_il[3]), 239, 306, 366, 221, 226, 297, 251, 184,
+ 178, 258, 292, 305, 346, 116,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
+ 1, AMR_OF(3, ltp), 107,
+ 2, AMR_OF(3, pul_ih[0]), 143, 126,
+ 2, AMR_OF(3, pul_ih[1]), 137, 122,
+ 2, AMR_OF(3, pul_ih[2]), 149, 105,
+ 2, AMR_OF(3, pul_ih[3]), 133, 136,
+ 14, AMR_OF(3, pul_il[0]), 162, 287, 337, 244, 229, 322, 218, 180,
+ 186, 262, 274, 288, 351, 146,
+ 14, AMR_OF(3, pul_il[1]), 212, 294, 358, 248, 228, 334, 215, 174,
+ 176, 270, 293, 301, 354, 147,
+ 14, AMR_OF(3, pul_il[2]), 185, 327, 336, 211, 213, 313, 245, 181,
+ 188, 255, 281, 325, 350, 151,
+ 14, AMR_OF(3, pul_il[3]), 201, 295, 359, 216, 208, 320, 238, 164,
+ 155, 217, 278, 302, 330, 113,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 0
+};
+
+static const uint16_t order_MODE_19k85[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
+ 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
+ 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
+ 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
+ 92,
+ 1, AMR_OF(0, ltp), 110,
+ 10, AMR_OF(0, pul_ih[0]), 134, 153, 263, 342, 399, 154, 106, 177,
+ 317, 265,
+ 10, AMR_OF(0, pul_ih[1]), 128, 167, 270, 351, 385, 160, 105, 213,
+ 329, 259,
+ 2, AMR_OF(0, pul_ih[2]), 123, 147,
+ 2, AMR_OF(0, pul_ih[3]), 131, 143,
+ 10, AMR_OF(0, pul_il[0]), 346, 118, 170, 201, 296, 368, 250, 284,
+ 341, 391,
+ 10, AMR_OF(0, pul_il[1]), 345, 104, 166, 196, 281, 374, 242, 269,
+ 327, 390,
+ 14, AMR_OF(0, pul_il[2]), 141, 171, 291, 364, 229, 210, 308, 228,
+ 206, 200, 258, 295, 313, 361,
+ 14, AMR_OF(0, pul_il[3]), 144, 188, 282, 366, 217, 216, 309, 218,
+ 193, 182, 245, 287, 300, 367,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
+ 1, AMR_OF(1, ltp), 109,
+ 10, AMR_OF(1, pul_ih[0]), 139, 169, 267, 348, 389, 163, 116, 189,
+ 343, 268,
+ 10, AMR_OF(1, pul_ih[1]), 120, 161, 249, 339, 397, 152, 114, 230,
+ 334, 303,
+ 2, AMR_OF(1, pul_ih[2]), 125, 138,
+ 2, AMR_OF(1, pul_ih[3]), 112, 129,
+ 10, AMR_OF(1, pul_il[0]), 349, 122, 162, 203, 288, 372, 278, 274,
+ 312, 377,
+ 10, AMR_OF(1, pul_il[1]), 357, 126, 165, 214, 298, 362, 252, 260,
+ 321, 378,
+ 14, AMR_OF(1, pul_il[2]), 150, 199, 266, 355, 211, 180, 285, 241,
+ 195, 198, 243, 275, 323, 375,
+ 14, AMR_OF(1, pul_il[3]), 142, 191, 256, 353, 208, 220, 314, 237,
+ 190, 212, 255, 304, 318, 371,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
+ 91,
+ 1, AMR_OF(2, ltp), 108,
+ 10, AMR_OF(2, pul_ih[0]), 159, 168, 302, 356, 395, 178, 132, 185,
+ 330, 286,
+ 10, AMR_OF(2, pul_ih[1]), 158, 181, 292, 358, 396, 176, 133, 235,
+ 331, 276,
+ 2, AMR_OF(2, pul_ih[2]), 130, 157,
+ 2, AMR_OF(2, pul_ih[3]), 124, 136,
+ 10, AMR_OF(2, pul_il[0]), 354, 121, 194, 246, 322, 379, 272, 273,
+ 332, 398,
+ 10, AMR_OF(2, pul_il[1]), 359, 140, 186, 236, 333, 376, 290, 301,
+ 338, 387,
+ 14, AMR_OF(2, pul_il[2]), 155, 227, 319, 369, 253, 254, 350, 248,
+ 224, 239, 240, 293, 315, 383,
+ 14, AMR_OF(2, pul_il[3]), 156, 209, 297, 373, 225, 215, 326, 247,
+ 197, 184, 232, 289, 310, 365,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
+ 1, AMR_OF(3, ltp), 107,
+ 10, AMR_OF(3, pul_ih[0]), 148, 164, 264, 340, 388, 183, 117, 205,
+ 336, 261,
+ 10, AMR_OF(3, pul_ih[1]), 146, 174, 257, 335, 384, 173, 113, 187,
+ 320, 279,
+ 2, AMR_OF(3, pul_ih[2]), 127, 151,
+ 2, AMR_OF(3, pul_ih[3]), 119, 137,
+ 10, AMR_OF(3, pul_il[0]), 352, 135, 172, 238, 306, 381, 262, 271,
+ 328, 382,
+ 10, AMR_OF(3, pul_il[1]), 347, 115, 179, 219, 305, 380, 277, 294,
+ 337, 386,
+ 14, AMR_OF(3, pul_il[2]), 145, 192, 307, 370, 234, 223, 324, 244,
+ 202, 204, 251, 299, 325, 360,
+ 14, AMR_OF(3, pul_il[3]), 149, 221, 311, 363, 226, 222, 316, 231,
+ 207, 175, 233, 280, 283, 344,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 0
+};
+
+static const uint16_t order_MODE_23k05[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
+ 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
+ 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
+ 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
+ 92,
+ 1, AMR_OF(0, ltp), 110,
+ 11, AMR_OF(0, pul_ih[0]), 118, 129, 131, 153, 170, 282, 298, 210,
+ 191, 357, 317,
+ 11, AMR_OF(0, pul_ih[1]), 126, 146, 135, 165, 187, 273, 345, 295,
+ 172, 338, 340,
+ 11, AMR_OF(0, pul_ih[2]), 119, 137, 141, 167, 208, 304, 366, 256,
+ 177, 339, 328,
+ 11, AMR_OF(0, pul_ih[3]), 116, 130, 120, 166, 190, 252, 311, 239,
+ 173, 343, 318,
+ 11, AMR_OF(0, pul_il[0]), 245, 180, 342, 424, 259, 277, 266, 380,
+ 398, 423, 440,
+ 11, AMR_OF(0, pul_il[1]), 218, 207, 367, 434, 201, 240, 275, 363,
+ 399, 419, 452,
+ 11, AMR_OF(0, pul_il[2]), 274, 188, 348, 425, 242, 204, 262, 365,
+ 402, 431, 463,
+ 11, AMR_OF(0, pul_il[3]), 221, 183, 337, 439, 243, 216, 251, 354,
+ 390, 411, 462,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
+ 1, AMR_OF(1, ltp), 109,
+ 11, AMR_OF(1, pul_ih[0]), 115, 140, 142, 161, 230, 291, 351, 235,
+ 181, 293, 310,
+ 11, AMR_OF(1, pul_ih[1]), 104, 138, 132, 162, 211, 315, 347, 233,
+ 176, 320, 329,
+ 11, AMR_OF(1, pul_ih[2]), 106, 134, 125, 154, 205, 267, 306, 220,
+ 185, 330, 297,
+ 11, AMR_OF(1, pul_ih[3]), 105, 148, 122, 152, 215, 302, 350, 254,
+ 178, 319, 313,
+ 11, AMR_OF(1, pul_il[0]), 269, 189, 382, 432, 272, 228, 263, 383,
+ 406, 422, 453,
+ 11, AMR_OF(1, pul_il[1]), 286, 206, 377, 446, 226, 222, 265, 368,
+ 404, 416, 454,
+ 11, AMR_OF(1, pul_il[2]), 247, 195, 358, 445, 224, 236, 309, 341,
+ 375, 408, 449,
+ 11, AMR_OF(1, pul_il[3]), 225, 192, 359, 436, 250, 258, 290, 389,
+ 400, 420, 448,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
+ 91,
+ 1, AMR_OF(2, ltp), 108,
+ 11, AMR_OF(2, pul_ih[0]), 139, 144, 145, 169, 234, 327, 395, 299,
+ 244, 356, 379,
+ 11, AMR_OF(2, pul_ih[1]), 127, 156, 158, 171, 231, 308, 397, 355,
+ 261, 371, 335,
+ 11, AMR_OF(2, pul_ih[2]), 123, 155, 157, 193, 241, 362, 384, 323,
+ 238, 392, 361,
+ 11, AMR_OF(2, pul_ih[3]), 114, 147, 121, 175, 196, 333, 373, 303,
+ 184, 353, 322,
+ 11, AMR_OF(2, pul_il[0]), 271, 203, 385, 442, 307, 276, 334, 405,
+ 412, 427, 459,
+ 11, AMR_OF(2, pul_il[1]), 278, 200, 388, 447, 292, 288, 296, 403,
+ 415, 429, 460,
+ 11, AMR_OF(2, pul_il[2]), 312, 214, 393, 433, 279, 301, 314, 391,
+ 410, 426, 450,
+ 11, AMR_OF(2, pul_il[3]), 280, 186, 376, 437, 268, 260, 255, 364,
+ 414, 417, 441,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
+ 1, AMR_OF(3, ltp), 107,
+ 11, AMR_OF(3, pul_ih[0]), 112, 159, 143, 164, 213, 281, 332, 284,
+ 168, 344, 325,
+ 11, AMR_OF(3, pul_ih[1]), 113, 150, 149, 179, 199, 316, 324, 285,
+ 237, 360, 336,
+ 11, AMR_OF(3, pul_ih[2]), 124, 136, 151, 174, 209, 326, 349, 248,
+ 198, 374, 331,
+ 11, AMR_OF(3, pul_ih[3]), 117, 128, 133, 163, 202, 300, 372, 305,
+ 194, 387, 321,
+ 11, AMR_OF(3, pul_il[0]), 249, 182, 352, 428, 253, 264, 289, 413,
+ 407, 418, 461,
+ 11, AMR_OF(3, pul_il[1]), 287, 212, 369, 444, 223, 246, 217, 346,
+ 394, 401, 451,
+ 11, AMR_OF(3, pul_il[2]), 219, 197, 378, 435, 229, 257, 283, 396,
+ 409, 430, 455,
+ 11, AMR_OF(3, pul_il[3]), 232, 160, 370, 438, 227, 270, 294, 381,
+ 386, 421, 443,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 0
+};
+
+static const uint16_t order_MODE_23k85[] = {
+ 1, AMR_BIT(vad), 7,
+ 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
+ 8, AMR_BIT(isp_id[1]), 93, 58, 91, 49, 59, 57, 67, 61,
+ 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
+ 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 101, 102, 96,
+ 7, AMR_BIT(isp_id[4]), 109, 64, 110, 92, 98, 97, 105,
+ 5, AMR_BIT(isp_id[5]), 106, 119, 104, 118, 115,
+ 5, AMR_BIT(isp_id[6]), 114, 113, 112, 127, 111,
+ 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 88,
+ 108,
+ 1, AMR_OF(0, ltp), 126,
+ 11, AMR_OF(0, pul_ih[0]), 134, 145, 147, 169, 186, 298, 314, 226,
+ 207, 373, 333,
+ 11, AMR_OF(0, pul_ih[1]), 142, 162, 151, 181, 203, 289, 361, 311,
+ 188, 354, 356,
+ 11, AMR_OF(0, pul_ih[2]), 135, 153, 157, 183, 224, 320, 382, 272,
+ 193, 355, 344,
+ 11, AMR_OF(0, pul_ih[3]), 132, 146, 136, 182, 206, 268, 327, 255,
+ 189, 359, 334,
+ 11, AMR_OF(0, pul_il[0]), 261, 196, 358, 440, 275, 293, 282, 396,
+ 414, 439, 456,
+ 11, AMR_OF(0, pul_il[1]), 234, 223, 383, 450, 217, 256, 291, 379,
+ 415, 435, 468,
+ 11, AMR_OF(0, pul_il[2]), 290, 204, 364, 441, 258, 220, 278, 381,
+ 418, 447, 479,
+ 11, AMR_OF(0, pul_il[3]), 237, 199, 353, 455, 259, 232, 267, 370,
+ 406, 427, 478,
+ 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
+ 4, AMR_OF(0, hb_gain), 79, 78, 77, 76,
+ 6, AMR_OF(1, adap), 35, 54, 95, 90, 100, 117,
+ 1, AMR_OF(1, ltp), 125,
+ 11, AMR_OF(1, pul_ih[0]), 131, 156, 158, 177, 246, 307, 367, 251,
+ 197, 309, 326,
+ 11, AMR_OF(1, pul_ih[1]), 120, 154, 148, 178, 227, 331, 363, 249,
+ 192, 336, 345,
+ 11, AMR_OF(1, pul_ih[2]), 122, 150, 141, 170, 221, 283, 322, 236,
+ 201, 346, 313,
+ 11, AMR_OF(1, pul_ih[3]), 121, 164, 138, 168, 231, 318, 366, 270,
+ 194, 335, 329,
+ 11, AMR_OF(1, pul_il[0]), 285, 205, 398, 448, 288, 244, 279, 399,
+ 422, 438, 469,
+ 11, AMR_OF(1, pul_il[1]), 302, 222, 393, 462, 242, 238, 281, 384,
+ 420, 432, 470,
+ 11, AMR_OF(1, pul_il[2]), 263, 211, 374, 461, 240, 252, 325, 357,
+ 391, 424, 465,
+ 11, AMR_OF(1, pul_il[3]), 241, 208, 375, 452, 266, 274, 306, 405,
+ 416, 436, 464,
+ 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
+ 4, AMR_OF(1, hb_gain), 75, 74, 73, 72,
+ 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 103,
+ 107,
+ 1, AMR_OF(2, ltp), 124,
+ 11, AMR_OF(2, pul_ih[0]), 155, 160, 161, 185, 250, 343, 411, 315,
+ 260, 372, 395,
+ 11, AMR_OF(2, pul_ih[1]), 143, 172, 174, 187, 247, 324, 413, 371,
+ 277, 387, 351,
+ 11, AMR_OF(2, pul_ih[2]), 139, 171, 173, 209, 257, 378, 400, 339,
+ 254, 408, 377,
+ 11, AMR_OF(2, pul_ih[3]), 130, 163, 137, 191, 212, 349, 389, 319,
+ 200, 369, 338,
+ 11, AMR_OF(2, pul_il[0]), 287, 219, 401, 458, 323, 292, 350, 421,
+ 428, 443, 475,
+ 11, AMR_OF(2, pul_il[1]), 294, 216, 404, 463, 308, 304, 312, 419,
+ 431, 445, 476,
+ 11, AMR_OF(2, pul_il[2]), 328, 230, 409, 449, 295, 317, 330, 407,
+ 426, 442, 466,
+ 11, AMR_OF(2, pul_il[3]), 296, 202, 392, 453, 284, 276, 271, 380,
+ 430, 433, 457,
+ 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
+ 4, AMR_OF(2, hb_gain), 87, 86, 85, 84,
+ 6, AMR_OF(3, adap), 34, 53, 94, 89, 99, 116,
+ 1, AMR_OF(3, ltp), 123,
+ 11, AMR_OF(3, pul_ih[0]), 128, 175, 159, 180, 229, 297, 348, 300,
+ 184, 360, 341,
+ 11, AMR_OF(3, pul_ih[1]), 129, 166, 165, 195, 215, 332, 340, 301,
+ 253, 376, 352,
+ 11, AMR_OF(3, pul_ih[2]), 140, 152, 167, 190, 225, 342, 365, 264,
+ 214, 390, 347,
+ 11, AMR_OF(3, pul_ih[3]), 133, 144, 149, 179, 218, 316, 388, 321,
+ 210, 403, 337,
+ 11, AMR_OF(3, pul_il[0]), 265, 198, 368, 444, 269, 280, 305, 429,
+ 423, 434, 477,
+ 11, AMR_OF(3, pul_il[1]), 303, 228, 385, 460, 239, 262, 233, 362,
+ 410, 417, 467,
+ 11, AMR_OF(3, pul_il[2]), 235, 213, 394, 451, 245, 273, 299, 412,
+ 425, 446, 471,
+ 11, AMR_OF(3, pul_il[3]), 248, 176, 386, 454, 243, 286, 310, 397,
+ 402, 437, 459,
+ 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
+ 4, AMR_OF(3, hb_gain), 83, 82, 81, 80,
+ 0
+};
+
+/** Reordering array addresses for each mode */
+static const uint16_t* amr_bit_orderings_by_mode[] = {
+ order_MODE_6k60,
+ order_MODE_8k85,
+ order_MODE_12k65,
+ order_MODE_14k25,
+ order_MODE_15k85,
+ order_MODE_18k25,
+ order_MODE_19k85,
+ order_MODE_23k05,
+ order_MODE_23k85
+};
+
+// Extracted from 3GPP TS 26.173 V9.0.0 (qpisf_2s.tab)
+// The *_36b tables are used in 6k60 mode
+// Stored in fixed-point to save some space
+/** Indexed tables for retrieval of quantized ISF vectors in Q15 */
+static const int16_t dico1_isf[256][9] = {
+ { 579, 1081, 1035, 390, 3, -263, -198, -82, 38},
+ { 18, -68, -12, 313, 761, 405, 249, 111, -76},
+ { 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923},
+ { -91, 827, 948, 648, 613, 535, 522, 490, 421},
+ { 41, -44, -281, -472, 652, 534, 193, 135, -90},
+ { 41, -121, -356, -60, 663, 307, 61, -48, -344},
+ { 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241},
+ { -118, -204, 328, 512, 870, 793, 610, 402, 186},
+ { 156, 293, 74, -338, -475, -897, -594, -161, -497},
+ { 226, 131, -138, 307, 169, -271, -164, -387, -624},
+ { 62, -32, -61, -252, -541, -828, -1027, -523, -662},
+ { 102, -61, 141, 112, -270, -251, -541, 25, -150},
+ { 6, -132, -356, -686, -96, -322, -522, -31, -326},
+ { -36, -209, -521, -229, 307, -132, -5, -99, -384},
+ { 60, -51, -237, -668, -973, -407, -708, -75, -172},
+ { 26, -138, -266, 111, -302, 43, -278, -356, -359},
+ { 570, 822, 496, -154, -312, -92, 137, 279, 371},
+ { -146, 368, 409, 68, 6, 77, 167, 202, 162},
+ { 633, 898, 996, 756, 662, 683, 783, 909, 996},
+ { -103, 294, 607, 415, 483, 462, 480, 431, 408},
+ { -120, -338, -612, -524, 584, 331, 92, 433, 276},
+ { -178, -293, -154, -41, 269, 100, -9, 213, 160},
+ { 830, 736, 278, 820, 1254, 686, 712, 1039, 473},
+ { -218, -304, 463, 454, 397, 273, 202, 286, 273},
+ { -232, 7, 6, -388, -472, -427, -378, -167, -100},
+ { -294, -183, 134, -47, 101, -88, -84, -117, -3},
+ { 57, 17, -202, -634, -989, -1119, -533, 176, -36},
+ { 120, -28, 23, 111, -319, 318, -22, -77, 266},
+ { -271, -464, -434, -658, -640, -385, -385, -99, -69},
+ { -198, -259, -266, -44, -39, -139, -137, 171, 66},
+ { 9, -145, -377, -846, -1000, -111, -325, 342, 135},
+ { -81, -286, -380, 192, -57, 307, 76, -24, -140},
+ { 677, 702, 247, 56, 249, 141, -105, -236, -99},
+ { 36, -39, -69, 348, 198, -93, 322, 91, -72},
+ { 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061},
+ { 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044},
+ { -127, -376, -657, 139, 623, 223, 501, 306, 220},
+ { -113, -384, -796, 504, 438, 85, 213, -83, -194},
+ { 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314},
+ { -174, -422, 7, 1155, 1089, 1182, 1003, 945, 806},
+ { 8, -126, -317, -103, -351, -695, -98, -268, -537},
+ { 33, -103, -290, 167, -39, -407, 44, -208, -375},
+ { 104, -23, -64, -291, -637, -851, -1084, -61, -112},
+ { -75, -306, -434, 218, -148, -354, -680, -133, -216},
+ { -121, -377, -718, -97, -130, -361, -156, -379, -599},
+ { -56, -254, -586, 235, 157, -214, 11, -260, -149},
+ { -124, -267, -397, -580, -593, -527, -805, -385, 346},
+ { -193, -440, -708, -351, -141, -255, -499, -147, -185},
+ { 448, 660, 494, 208, 509, 461, 338, 291, 149},
+ { -223, 88, 335, 159, 212, 191, 286, 308, 205},
+ { -31, 469, 803, 659, 619, 658, 843, 987, 1113},
+ { -171, -242, 514, 362, 295, 524, 552, 694, 585},
+ { -64, -308, -448, -21, 284, 786, 446, 289, 92},
+ { -218, -390, -7, 169, 206, 330, 352, 408, 358},
+ { -36, 702, 959, 859, 861, 1115, 1269, 1357, 1305},
+ { -133, -341, -65, 678, 417, 440, 486, 518, 780},
+ { 33, -44, -191, -344, -461, -755, -201, 217, -31},
+ { -353, -547, -44, 123, -61, -68, -79, 29, 60},
+ { 73, -57, -406, -766, -1243, -1203, 240, 400, 165},
+ { -73, -282, -601, -213, -171, -375, 332, 35, -103},
+ { -29, -207, -553, -476, -638, -908, 172, -22, -135},
+ { -192, -239, -164, -103, -111, -47, 153, 125, 110},
+ { -1, -203, -570, -1030, -1424, -535, 155, 1, 147},
+ { -333, -653, -865, -197, -158, -21, -44, 95, 108},
+ { 389, 588, 490, 33, -237, -524, -628, -136, -260},
+ { 40, -177, -462, 453, 862, 380, 131, -130, -405},
+ { 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742},
+ { 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71},
+ { -76, -281, -741, -742, 898, 619, 277, 71, -222},
+ { -32, -265, -556, -25, 994, 682, 305, 126, -165},
+ { 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391},
+ { -69, -349, -585, 234, 1158, 903, 626, 510, 251},
+ { -1, -99, -272, -210, -603, -351, -540, -811, -383},
+ { -16, -230, -504, 410, 149, -205, -343, -651, -639},
+ { 103, -9, -227, -205, -562, -781, -1079, -1208, -156},
+ { 143, 63, -135, -67, -317, -602, -784, -1154, -640},
+ { -144, -391, -674, -622, -200, -254, -660, -947, -395},
+ { -40, -250, -625, 27, 543, 94, -131, -386, -673},
+ { -123, -371, -757, -451, -564, -614, -415, -711, -35},
+ { -116, -309, -593, -268, 239, -33, -338, -650, -135},
+ { 94, 251, 554, 57, -312, -423, -154, -57, 235},
+ { -268, -71, 381, 114, -44, -87, 125, 173, 133},
+ { 1513, 1714, 1238, 534, 276, 315, 461, 459, 508},
+ { -131, -19, 1149, 670, 486, 356, 309, 369, 296},
+ { -223, -501, -899, -722, -70, 6, 131, 310, 394},
+ { -99, -303, -517, 249, 64, -53, 135, -11, 453},
+ { -147, -399, -730, -401, 817, 738, 802, 749, 575},
+ { -154, -435, -739, 800, 593, 366, 529, 318, 326},
+ { -224, 45, -39, -387, -515, -518, -608, -384, -321},
+ { -315, -377, 143, -101, -113, -377, -177, -144, -12},
+ { 117, 40, -239, -651, -1051, -581, -737, -990, -328},
+ { 26, -50, -157, -23, -453, -283, -531, -546, 192},
+ { -252, -501, -743, -589, -627, -499, -328, -118, -72},
+ { -324, -494, -244, -306, -144, -177, -262, -135, -78},
+ { -36, -234, -519, -961, -1290, -314, -479, -371, -45},
+ { -95, -292, -535, -8, -300, 112, -164, -277, 198},
+ { -99, -128, 880, 836, 579, 351, 23, -95, -217},
+ { -27, -258, 124, 1011, 597, 425, 144, 7, -73},
+ { 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006},
+ { -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712},
+ { -69, -300, -683, -435, 1132, 899, 504, 332, 109},
+ { -74, -323, -637, 563, 1074, 608, 371, 105, -49},
+ { -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217},
+ { -259, -121, 1440, 1334, 1628, 1490, 1438, 1223, 933},
+ { -82, -306, -613, -222, -378, -675, -545, -671, -845},
+ { 53, -124, -347, 422, 52, -125, -270, -529, 9},
+ { 79, -89, -320, -662, -999, -1199, -1243, -676, -297},
+ { -68, -273, -611, 137, -146, -397, -627, -845, -220},
+ { -112, -346, -797, -826, 234, -132, -188, -278, -522},
+ { -159, -405, -734, -419, 293, 74, -167, -167, 184},
+ { -153, -437, -833, -1080, -336, -472, -561, -340, -253},
+ { -169, -423, -820, -904, -131, -19, -346, -604, 31},
+ { 33, -31, 312, 62, -148, 49, -59, 564, 486},
+ { -306, -333, 194, -44, 67, 72, 147, 205, 243},
+ { -207, -49, 1360, 983, 969, 991, 1014, 1110, 973},
+ { -211, -172, 883, 627, 711, 674, 705, 798, 746},
+ { -88, -325, -763, -974, 687, 908, 514, 382, 172},
+ { -292, -612, -805, 63, 131, 270, 259, 352, 348},
+ { -235, -84, 955, 818, 1120, 1289, 1559, 1480, 1285},
+ { -180, -461, -614, 657, 691, 745, 854, 783, 713},
+ { -97, -309, -477, -614, -777, -734, -768, -526, -472},
+ { -344, -476, -35, -169, 49, -77, -150, -240, -141},
+ { -52, -268, -639, -919, -1278, -1113, -342, -333, -151},
+ { -68, -242, -585, -73, -209, -478, -159, -429, 133},
+ { -197, -499, -1005, -1268, -272, -224, -105, -67, 17},
+ { -363, -618, -414, -116, -62, 20, 10, 116, 108},
+ { -195, -475, -906, -1260, -891, -441, -277, -142, -28},
+ { -226, -519, -950, -700, -275, -266, -116, -105, 82},
+ { 404, 511, 520, 327, 17, -194, -333, -536, -586},
+ { -114, -130, 276, 237, 204, 342, 135, -16, -111},
+ { 670, 1208, 1168, 860, 742, 601, 528, 403, 309},
+ { 397, 621, 966, 752, 579, 398, 400, 329, 252},
+ { 191, 180, -137, -467, 272, 106, -95, 17, -192},
+ { -80, -290, -626, 194, 598, 196, 21, -281, 77},
+ { 510, 864, 1108, 807, 939, 902, 925, 717, 481},
+ { 137, 367, 534, 764, 670, 382, 296, 153, 84},
+ { 303, 497, 144, -85, -125, -539, -482, -464, -764},
+ { 233, 347, 68, -147, 169, -210, -242, -226, -482},
+ { 307, 422, 154, -175, -386, -722, -724, -904, -1015},
+ { 309, 308, 160, -60, -470, -420, -598, -791, -219},
+ { 68, 121, -137, -560, -146, -446, -515, -494, -729},
+ { 130, 53, -227, 46, 474, 32, -161, -192, -490},
+ { 213, 164, -71, -465, -876, -161, -456, -587, -48},
+ { 218, 117, 39, 177, -194, -88, -226, -418, 50},
+ { 210, 547, 569, 279, 121, -44, -50, 10, -84},
+ { 58, 140, 182, -5, 267, 117, 106, 211, 198},
+ { 539, 835, 913, 719, 617, 544, 591, 565, 642},
+ { 153, 559, 872, 460, 222, 108, 188, 180, 183},
+ { 158, 119, 284, -153, -271, 229, 87, 110, -57},
+ { -183, 82, 118, 21, 13, 40, 118, 191, 185},
+ { 162, 889, 654, 108, -34, 244, 488, 561, 532},
+ { 163, 56, 609, 341, 50, 329, 68, 266, 218},
+ { 100, 206, 18, -304, -107, -436, -487, -65, -306},
+ { -86, 154, 134, -30, -45, -73, -104, -80, -96},
+ { 245, 330, 10, -440, -849, -1082, 79, 40, -265},
+ { 196, 372, 272, -181, -493, -389, 275, 80, -59},
+ { 2, -12, -246, -505, -100, -436, 21, -187, -431},
+ { -221, -48, 36, -271, -186, -147, -109, 26, 71},
+ { 213, 140, 72, -351, -620, -84, -363, 69, 46},
+ { 91, 167, -3, -95, -99, -105, -48, 114, 147},
+ { 259, 249, 172, 607, 406, 52, 59, -189, -320},
+ { 115, -85, -54, 574, 128, 226, -59, -253, 130},
+ { -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823},
+ { 39, 364, 757, 940, 728, 660, 659, 583, 770},
+ { -115, -338, -760, -471, 394, 37, 441, 178, 6},
+ { -57, -305, -525, 796, 453, 188, -4, -114, 248},
+ { 71, 444, 797, 731, 1096, 1157, 1222, 1029, 811},
+ { 135, 359, 551, 425, 749, 815, 874, 704, 502},
+ { 132, 247, 0, -206, -449, -750, -258, -514, -633},
+ { 248, 249, 91, 121, -195, -499, -90, -282, -435},
+ { 78, 20, -277, -623, -983, -1224, -415, -458, -639},
+ { 347, 509, 208, -179, -464, -728, -76, -237, -486},
+ { -103, -343, -756, -713, -265, -609, -191, -398, -636},
+ { -121, -383, -749, 567, 252, -36, -354, -417, -50},
+ { 204, 100, -149, -650, -1081, -47, -7, -263, 111},
+ { -46, -180, -267, -324, -562, -394, -692, 398, 292},
+ { 482, 670, 683, 624, 442, 165, 116, 36, -149},
+ { 108, 247, 291, 247, 355, 122, 109, 224, 296},
+ { -14, 945, 990, 801, 755, 815, 847, 913, 892},
+ { 292, 349, 725, 482, 388, 329, 429, 620, 667},
+ { -34, 197, 213, -127, 84, 494, 620, 575, 375},
+ { 126, 207, 172, 167, 362, 202, 296, 395, 455},
+ { -6, 250, 539, 467, 636, 801, 1149, 1287, 1118},
+ { 27, 240, 369, 280, 440, 411, 634, 892, 953},
+ { 159, 170, -58, -395, -797, -690, 77, -211, -334},
+ { -5, -28, -13, -74, -335, -603, 300, 88, -205},
+ { 82, -33, -364, -698, -1203, -1153, 110, -146, -289},
+ { 113, 1, -243, -588, -994, -496, 414, 160, 42},
+ { -56, -247, -440, -693, -996, -479, 11, -178, -357},
+ { -151, -353, -327, -211, -340, 141, 65, 425, 453},
+ { 34, -169, -455, -932, -1215, 138, 499, 256, 324},
+ { 68, 139, -15, -547, -478, 17, 306, 502, 481},
+ { -32, -134, 445, 129, -143, -244, -503, -507, -599},
+ { 61, -140, -345, 496, 458, -2, 20, -227, -514},
+ { 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380},
+ { 215, 519, 920, 1053, 1090, 791, 528, 290, 155},
+ { -54, -233, -647, -602, 639, 294, -2, -167, -442},
+ { -78, -315, -791, -113, 820, 403, 158, -116, -356},
+ { 529, 1851, 2003, 1228, 622, -41, -416, 344, 819},
+ { -105, -379, -236, 1224, 893, 749, 568, 356, 214},
+ { -17, -199, -144, 50, -283, -247, -578, -846, -1087},
+ { 69, -11, -381, -206, 209, -284, -387, -416, -716},
+ { 39, -5, -145, -374, -682, -909, -1074, -1169, -1066},
+ { 287, 226, 67, -221, -662, -171, -421, -642, -707},
+ { -132, -348, -538, -448, -20, -4, -354, -748, -933},
+ { 4, -75, -289, -598, 317, 52, -208, -297, -559},
+ { -88, -264, -358, -589, -631, -248, -523, -822, -1071},
+ { 70, -8, 54, -314, -515, 92, -146, -274, -493},
+ { 199, 62, 391, 158, -141, 71, -219, -203, -207},
+ { 152, 40, 329, 162, -29, 48, -149, 108, 127},
+ { 635, 1058, 883, 492, 372, 312, 317, 274, 241},
+ { 267, 722, 1256, 882, 625, 248, 8, -81, -60},
+ { -58, -138, -291, -600, -12, -2, -39, 147, 117},
+ { -107, -345, -513, 459, 76, 92, -272, 388, 262},
+ { 362, 516, 203, -409, -716, -831, -331, 185, 209},
+ { -117, -391, -298, 671, 292, 538, 257, 166, -38},
+ { -102, -319, -194, -283, -573, -262, -579, -219, -444},
+ { -235, 78, 11, -168, -101, -229, -263, -321, -123},
+ { 70, 50, -170, -599, -996, -588, -263, -516, -455},
+ { 394, 363, 229, -136, -538, 21, -183, -348, -201},
+ { -124, -368, -640, -879, -847, -209, -409, -494, -515},
+ { -127, -341, -541, -425, -510, -10, -252, -473, -291},
+ { 84, -69, -201, -676, -868, 103, -311, -132, -320},
+ { 5, -173, -188, -297, -628, 197, -57, 7, -11},
+ { 49, -160, 56, 558, 111, 33, -311, -440, -463},
+ { -1, -246, -307, 862, 453, 139, -170, -355, -232},
+ { 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339},
+ { -197, -38, 1702, 1331, 1252, 950, 692, 504, 426},
+ { -108, -344, -861, -1172, 444, 354, 88, -46, -220},
+ { -53, -321, -494, 1113, 744, 364, 198, -34, -75},
+ { 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539},
+ { -69, 199, 897, 1140, 1343, 1183, 977, 742, 522},
+ { 122, 44, -269, 27, -155, -562, -307, -590, -773},
+ { 154, 42, -160, 252, -129, -305, -471, -733, -371},
+ { 135, 185, -82, -416, -722, -913, -504, -743, -880},
+ { 149, 214, -84, -329, -680, -835, -426, -661, -81},
+ { -128, -380, -735, -998, -337, 17, -182, -467, -697},
+ { -84, -290, -510, -592, 13, 440, 154, -38, -279},
+ { 70, -61, -246, -727, -1047, -80, -381, -535, -704},
+ { 178, -2, -146, -670, -938, 482, 138, 63, 65},
+ { -11, 15, 772, 443, 142, -20, -209, -126, -161},
+ { -32, -249, 95, 552, 124, 30, -343, 82, -86},
+ { 148, 751, 1515, 1105, 867, 606, 474, 448, 399},
+ { -163, -257, 899, 1097, 906, 751, 502, 390, 294},
+ { -51, -258, -447, -806, -368, 763, 464, 364, 183},
+ { -166, -374, -367, 87, 35, 399, 418, 856, 833},
+ { -205, -310, 588, 778, 785, 1065, 1118, 1245, 1157},
+ { -173, -312, 107, 345, 400, 790, 870, 1113, 1001},
+ { -7, -120, -387, -410, -614, -943, -226, -384, -491},
+ { -203, -288, -51, -331, -90, -178, -408, -573, -338},
+ { 56, -29, -273, -627, -1041, -798, -247, -467, 148},
+ { 66, -2, -205, -205, -575, -349, -57, -352, -58},
+ { -45, -225, -471, -924, -497, 77, -32, 44, -135},
+ { -277, -491, -497, -502, -424, -202, -137, 77, 96},
+ { 26, -179, -469, -1008, -1260, 262, -35, -132, -259},
+ { -66, -232, -447, -533, -789, -191, -100, -267, 364}
+};
+
+static const int16_t dico2_isf[256][7] = {
+ { 1357, 1313, 1136, 784, 438, 181, 145},
+ { 636, 648, 667, 568, 442, 217, 362},
+ { 427, 440, 674, 524, 332, 117, -417},
+ { 121, 295, 468, 465, 230, 44, -221},
+ { -147, -240, 149, 80, 390, 278, 106},
+ { -418, -556, 552, 511, 235, 144, -95},
+ { 43, 193, 274, 150, 67, 34, -273},
+ { -43, -126, 171, 416, 282, 63, -354},
+ { -372, -86, -344, -108, -94, -182, -89},
+ { -600, -840, -200, 465, 258, -11, -253},
+ { -48, 329, 97, -290, -543, -795, -354},
+ { -570, -117, 187, 10, -133, -416, -76},
+ { -618, -129, -247, -371, 45, -76, 277},
+ { -1022, -1079, 126, 474, 254, 127, 52},
+ { -281, 76, -167, -361, -283, -551, -283},
+ { -119, -52, -1, 134, -32, -204, -415},
+ { 1064, 827, 637, 684, 464, 209, 12},
+ { 482, 416, 449, 371, 335, 294, 194},
+ { 719, 576, 365, 135, 113, 91, -199},
+ { 298, 176, 493, 366, 194, 163, 36},
+ { -35, -236, -259, -36, -4, 99, 152},
+ { -98, -306, -27, 228, 90, 111, -86},
+ { 91, 13, -211, -258, -106, 86, -64},
+ { 73, -35, -57, -31, 162, 35, -192},
+ { -109, -335, -629, -66, -61, -128, 322},
+ { -495, -669, -728, 193, 31, -220, 122},
+ { 324, 95, -89, -91, -409, -710, -154},
+ { 0, -234, 92, 33, -343, -609, -220},
+ { -343, -408, -476, -655, -153, 82, 222},
+ { -490, -745, -255, 49, -48, 135, -127},
+ { 119, -67, -328, -390, -272, -545, -56},
+ { -57, -130, -10, -7, -164, -47, -22},
+ { 984, 1064, 961, 568, 210, -27, 16},
+ { 811, 691, 754, 514, 224, -35, 166},
+ { 662, 704, 618, 386, 57, -211, -257},
+ { 510, 359, 418, 393, 91, -144, -18},
+ { -193, -31, -27, 223, 89, -143, 24},
+ { -112, -98, 471, 319, 185, 3, 175},
+ { 252, 146, -47, 272, 48, -211, -234},
+ { 146, 69, 203, 364, 68, -52, 51},
+ { -259, -478, -697, -349, -758, -501, 63},
+ { -501, -769, -289, 79, -311, -497, -106},
+ { 251, 53, -235, -469, -895, -884, 145},
+ { -416, -551, 140, -133, -523, -775, 44},
+ { -326, -423, -713, -497, -86, -431, 99},
+ { -757, -772, -160, -76, -46, -32, 379},
+ { 85, -35, -200, -401, -663, -1040, -247},
+ { -180, -330, -92, -376, 27, -183, -110},
+ { 1279, 1086, 781, 502, 324, 164, 157},
+ { 682, 466, 449, 277, 146, 28, 409},
+ { 635, 472, 390, 107, -232, -538, -139},
+ { 196, 396, 332, 213, 209, -29, -81},
+ { 150, -95, -312, 76, -77, -320, -50},
+ { 46, 9, 47, 175, 139, 30, 384},
+ { 218, 206, -24, -250, -96, -276, -183},
+ { 26, 119, 38, 14, -4, -133, -52},
+ { -477, -614, -987, -715, -631, -813, 200},
+ { -744, -1009, -1065, -745, -631, -171, 18},
+ { -137, -251, -483, -613, -980, -1203, 12},
+ { -605, -767, -562, -686, -1088, -515, 58},
+ { -202, -428, -782, -1072, -96, -234, -179},
+ { -480, -709, -1070, -897, -131, -92, 321},
+ { -145, -193, -512, -729, -572, -765, -210},
+ { -331, -585, -525, -631, -281, -208, -303},
+ { 1165, 1104, 939, 828, 716, 426, 155},
+ { 6, -109, 820, 778, 415, 113, -27},
+ { 381, 339, 314, 265, 121, -9, -474},
+ { -373, 47, 584, 442, 99, -231, -113},
+ { -496, -38, -285, 262, 305, 170, 4},
+ { -587, -556, 69, 66, 471, 354, 13},
+ { -138, 70, -18, 106, 67, 167, -302},
+ { -445, -141, 185, 191, 151, 83, -133},
+ { -257, -521, -720, -198, 134, -46, -182},
+ { -819, -1168, -777, 512, 359, 95, -113},
+ { 137, -2, -74, -138, -401, -114, -371},
+ { -242, -466, 204, 223, -31, -212, -192},
+ { -532, -637, -466, -686, 256, 277, -139},
+ { -1141, -1244, -381, -75, -54, 14, 88},
+ { -311, 115, -143, -499, -343, 124, -416},
+ { -616, -147, -135, 43, -4, 121, -369},
+ { 835, 783, 641, 390, 355, 350, 64},
+ { 72, 194, 443, 467, 436, 219, 372},
+ { 464, 369, 192, 4, -156, -72, -226},
+ { 57, 206, 303, 205, 188, 101, 265},
+ { -40, -205, -488, -184, 276, 64, -26},
+ { -217, -433, -297, 137, 328, 308, -289},
+ { 378, 81, -308, -465, 57, -37, 227},
+ { -100, 24, -36, -151, 199, 8, 143},
+ { -426, -697, -1059, -133, 388, 161, 321},
+ { -644, -1023, -1271, 39, 66, -123, 70},
+ { 372, 177, -173, -556, -553, -304, -189},
+ { -117, -369, -425, -122, -462, -152, -73},
+ { -649, -850, -1189, -767, 497, 360, 222},
+ { -798, -1139, -1455, -190, 430, 234, 179},
+ { 42, -94, -405, -692, 38, -202, -246},
+ { -169, -366, -290, -88, -64, 32, -292},
+ { 1010, 923, 938, 710, 465, 230, 342},
+ { 217, 300, 1054, 675, 68, -458, -179},
+ { 78, 453, 316, 18, -237, -496, -243},
+ { 167, 21, 424, 215, -91, -303, -170},
+ { -290, -81, -70, -67, 40, 54, -59},
+ { -353, -427, -90, 53, 94, 9, 54},
+ { -28, 318, 283, 15, -240, -58, 79},
+ { -75, -121, 229, 35, 58, 6, -133},
+ { -351, -514, -744, -834, -705, -137, 164},
+ { -1124, -1388, -1055, -230, -73, 40, 36},
+ { -163, -233, -532, -785, -1170, -697, 96},
+ { -788, -959, -246, -430, -624, -165, -8},
+ { -856, -540, -630, -907, -337, -70, 76},
+ { -937, -1042, -659, -733, -208, 199, -26},
+ { -523, 78, -98, -501, -869, -890, -81},
+ { -624, -703, -45, -348, -25, 87, -186},
+ { 1005, 823, 546, 249, 90, -22, 207},
+ { 298, 397, 381, 319, 200, 62, 303},
+ { 473, 379, 133, -247, -632, -441, 75},
+ { 284, 208, 391, 115, -25, 44, 95},
+ { -72, 79, -95, -63, -129, -293, 203},
+ { -164, -349, 115, 122, 69, -1, 378},
+ { 348, 170, 99, 58, -179, -302, 188},
+ { -190, -2, 150, 23, -51, -11, 216},
+ { -615, -863, -1090, -1427, -802, -48, -6},
+ { -961, -1276, -1548, -727, -58, 56, 223},
+ { -124, -255, -561, -988, -1277, -148, -82},
+ { -480, -660, -891, -1191, -1339, -325, 20},
+ { -621, -917, -1296, -1350, 264, 289, 50},
+ { -844, -1022, -1345, -1329, -293, 46, 278},
+ { -260, -468, -829, -1176, -533, -560, -78},
+ { -215, -484, -822, -1233, -791, 15, -138},
+ { 1301, 1317, 1262, 1048, 716, 357, -64},
+ { 578, 824, 925, 802, 630, 362, 102},
+ { 470, 925, 767, 514, 327, 190, -112},
+ { 225, 492, 495, 437, 598, 384, -45},
+ { 43, 82, -42, 175, 519, 342, -64},
+ { -304, -154, 159, 576, 403, 221, 327},
+ { 214, 244, 122, -62, 312, 92, -160},
+ { 218, 208, 310, 268, 306, 323, -199},
+ { -285, -269, -79, -124, -143, -153, 236},
+ { -205, -384, -426, 344, 59, -185, -184},
+ { -272, 247, 126, -210, -518, -468, 78},
+ { -99, -120, 502, 160, -280, -557, 304},
+ { -423, -17, -283, -443, 215, 212, -140},
+ { -564, -684, -228, 510, 361, 130, 323},
+ { -428, 335, 98, -65, 36, -215, -246},
+ { -362, 51, 364, -16, -234, 150, -165},
+ { 914, 883, 751, 653, 676, 464, -153},
+ { 631, 545, 535, 720, 596, 360, -81},
+ { 783, 712, 512, 439, 341, 251, -391},
+ { 497, 417, 249, 372, 295, 173, -193},
+ { 128, -110, -385, 93, 39, 173, -231},
+ { 216, -59, -253, 462, 389, 154, 69},
+ { 455, 270, -4, -337, -49, 233, -322},
+ { 307, 143, 53, 218, 128, 236, -156},
+ { -37, -186, -240, -411, -110, 9, 399},
+ { -140, -365, -628, 258, 380, 214, 277},
+ { 131, 454, 177, -285, -520, 108, -214},
+ { 77, -141, 201, -123, -490, -131, 60},
+ { -14, -194, -521, -741, 273, 362, -33},
+ { -362, -566, -287, -228, 161, 237, 317},
+ { -269, 195, -75, -375, -204, 11, 77},
+ { -128, -264, -156, -223, -475, 265, 27},
+ { 1238, 1147, 916, 689, 432, 210, -280},
+ { 800, 664, 879, 726, 411, 160, -164},
+ { 454, 686, 536, 275, 147, 46, 111},
+ { 303, 486, 512, 355, 241, 181, -69},
+ { 79, 92, 29, 147, 233, 52, 17},
+ { -171, 289, 131, 439, 271, 3, -10},
+ { 413, 241, 144, 174, 155, -2, 14},
+ { 58, 217, 247, 219, 149, 175, -18},
+ { 228, -8, -240, -206, -513, -191, 202},
+ { -96, -272, -454, 33, -300, -575, 46},
+ { -10, -108, -246, -347, -770, -535, 9},
+ { -326, -430, -61, -321, -704, -299, 201},
+ { -1, -280, -603, -419, -185, 18, -36},
+ { -516, -522, -379, -291, -181, -97, 27},
+ { -159, -313, -525, -224, -510, -831, -197},
+ { -292, -459, -59, -310, -562, -143, -351},
+ { 1066, 912, 631, 389, 207, 86, -224},
+ { 596, 512, 596, 505, 314, 122, -48},
+ { 787, 861, 441, -93, -303, 33, -190},
+ { 257, 469, 337, 51, 15, 298, -93},
+ { 295, 73, -119, 25, 36, 23, 108},
+ { -28, -3, -32, 114, 21, 185, 107},
+ { 482, 305, 15, -279, -319, 52, 96},
+ { 226, 46, 115, 72, -136, 133, -125},
+ { 18, -207, -559, -590, -503, -482, 321},
+ { -571, -789, -951, -172, -441, -538, 113},
+ { 181, 14, -310, -641, -1001, -202, 159},
+ { -136, -393, -433, -513, -911, -144, -22},
+ { 72, -265, -706, -954, -159, 53, 332},
+ { -338, -591, -852, -383, -395, 56, 44},
+ { 43, -158, -464, -897, -631, -157, -294},
+ { -161, -128, -328, -573, -483, -125, 11},
+ { 1017, 906, 1051, 1005, 679, 341, -102},
+ { 359, 334, 1567, 1314, 723, 105, 10},
+ { -65, 726, 529, 301, 220, 43, -273},
+ { -510, 436, 719, 566, 358, 179, 114},
+ { -560, 298, 133, -120, 342, 225, 14},
+ { -899, -101, 217, 617, 400, 146, -58},
+ { -41, 352, 82, -196, 39, 121, -167},
+ { -212, 59, 447, 284, 423, 250, -169},
+ { -371, -484, -596, 30, -41, 249, 22},
+ { -372, -650, -794, 477, 445, 216, -79},
+ { -352, 275, 17, -443, -929, 92, 19},
+ { -699, -696, 431, 264, -49, -310, 182},
+ { -978, -217, -430, -400, 101, 261, 72},
+ { -929, -889, -357, -13, 463, 378, 236},
+ { -826, 56, 30, -299, -360, -128, -51},
+ { -878, -299, -111, 75, 65, 36, 3},
+ { 817, 368, -25, 354, 697, 591, -173},
+ { 309, 212, 222, 751, 484, 140, -56},
+ { 593, 379, 70, -8, 258, 180, 110},
+ { 165, -46, 255, 297, 219, 273, 105},
+ { 160, -70, -358, -181, 379, 330, 319},
+ { -238, -369, -198, 740, 580, 319, -143},
+ { 201, 109, -202, -456, 328, 276, -141},
+ { 203, 170, 111, 42, 207, 360, 188},
+ { -345, -399, -513, -233, 650, 422, 81},
+ { -635, -961, -1220, 463, 539, 204, 209},
+ { 202, -25, -194, -498, -787, 193, -143},
+ { -449, -538, 195, -106, -331, 68, 62},
+ { -228, -477, -840, -576, 317, 128, 283},
+ { -671, -937, -807, -114, 391, 335, -62},
+ { 246, 2, -314, -679, -303, 180, -88},
+ { -107, -272, 90, -198, -28, 290, -112},
+ { 885, 1149, 1021, 712, 496, 281, -83},
+ { 269, 492, 787, 643, 347, 70, 124},
+ { 336, 636, 499, 92, -229, -179, 191},
+ { 26, 402, 564, 340, 149, -11, 135},
+ { -440, 561, 470, 204, -72, -186, 140},
+ { -720, 14, 355, 229, 68, -133, 465},
+ { 110, 310, 103, 12, 106, 29, 158},
+ { -178, 113, 161, 142, 121, 115, 27},
+ { -651, -414, -645, -152, -164, -13, -429},
+ { -639, -944, -681, -104, -81, 52, -189},
+ { -663, -164, -316, -683, -954, -205, -83},
+ { -609, -669, -172, -517, -694, 283, -80},
+ { -646, -152, -383, -678, -246, -40, -143},
+ { -747, -796, -745, -390, -98, 43, 275},
+ { -599, -199, -398, -433, -436, -538, 31},
+ { -1107, -568, -376, -265, -126, -21, 1},
+ { 847, 573, 308, 392, 305, 101, 55},
+ { 273, 293, 201, 267, 346, 201, 123},
+ { 727, 480, 226, 2, -65, -138, 164},
+ { 273, 208, 173, 292, 12, 253, 174},
+ { 340, 207, 180, 88, 116, 46, 475},
+ { -460, -166, -30, 13, 110, 173, 396},
+ { 137, 88, 43, -137, -94, 34, 284},
+ { 96, -14, 226, 40, 63, 70, 130},
+ { -467, -735, -1012, -1174, -307, 305, -67},
+ { -612, -920, -1146, -567, -8, 92, -25},
+ { -182, -271, -492, -754, -857, 287, -75},
+ { -494, -787, -689, -683, -709, 137, -326},
+ { -288, -550, -903, -1105, 334, 321, -62},
+ { -354, -653, -834, -445, 1, 377, -152},
+ { -162, -306, -608, -937, -297, 247, -192},
+ { -234, -477, -244, -488, -266, 342, -332}
+};
+
+static const int16_t dico21_isf[64][3] = {
+ { 329, 409, 249}, { -33, 505, 160},
+ { -29, -14, 582}, { -262, 127, 354},
+ { 145, 237, 175}, { -152, 245, 122},
+ { 27, 42, 340}, { -84, -93, 311},
+ { 285, 222, -156}, { 47, -43, -504},
+ { 234, 121, 385}, { 104, -317, 45},
+ { 176, 195, 8}, { 104, -59, -94},
+ { 177, 53, 192}, { -34, -127, 152},
+ { 570, 277, -34}, { -67, -329, -639},
+ { -157, -272, 462}, { -177, -462, 198},
+ { 322, 179, 115}, { -386, 171, 19},
+ { 19, -12, 195}, { -120, -252, 201},
+ { 304, 36, -336}, { -128, -221, -380},
+ { 171, -185, 296}, { -242, -312, 23},
+ { 198, 39, 16}, { -3, -177, -111},
+ { 111, -93, 76}, { -92, -223, 4},
+ { 177, 406, -44}, { -168, 380, -149},
+ { -4, 273, 331}, { -420, 513, 277},
+ { 21, 247, 47}, { -58, 131, -2},
+ { -3, 134, 180}, { -145, 40, 175},
+ { 189, 74, -145}, { -27, -45, -325},
+ { 370, -114, -21}, { -83, -415, -173},
+ { 77, 95, -51}, { -40, -30, -67},
+ { 71, 88, 86}, { -35, -98, 14},
+ { 69, 197, -334}, { -196, 79, -231},
+ { -348, -137, 218}, { -352, -89, -85},
+ { 47, 201, -130}, { -165, 37, -15},
+ { -43, 3, 86}, { -161, -108, 79},
+ { 83, 21, -237}, { -81, -149, -238},
+ { 150, -186, -251}, { -186, -249, -162},
+ { -19, 66, -139}, { -26, -50, -181},
+ { 24, 11, 0}, { -130, -105, -98}
+};
+
+static const int16_t dico22_isf[128][3] = {
+ { -127, 310, 42}, { -242, 197, 5},
+ { -151, 84, -17}, { -214, 127, -149},
+ { -247, -131, 159}, { -268, -267, -95},
+ { -217, 1, -79}, { -271, -80, -185},
+ { -45, 436, 159}, { 165, 199, 391},
+ { -33, 81, 187}, { -66, -42, 355},
+ { -298, -57, 343}, { -108, -537, 226},
+ { -144, -23, 193}, { 176, -402, 87},
+ { 53, 296, 25}, { -84, 253, -104},
+ { -58, 105, -126}, { -169, 174, -314},
+ { -48, 44, -294}, { -164, -417, -242},
+ { -139, 3, -194}, { -155, -207, -211},
+ { 119, 322, 213}, { 333, 50, 380},
+ { 237, 247, -2}, { 466, -16, 201},
+ { 238, -255, -107}, { 67, -440, -149},
+ { 122, -88, -139}, { 88, -247, -73},
+ { -41, 231, 167}, { -62, 155, 16},
+ { -65, 16, 77}, { -68, -2, -63},
+ { -151, -300, 160}, { -18, -333, 54},
+ { -56, -94, 5}, { 2, -190, 14},
+ { 92, 148, 209}, { 108, 9, 272},
+ { 108, 35, 110}, { 142, -85, 145},
+ { 47, -157, 279}, { 3, -320, 246},
+ { 43, -72, 68}, { 86, -217, 135},
+ { 36, 140, 79}, { 56, 175, -49},
+ { 26, 45, 3}, { 73, 55, -101},
+ { 109, -183, -242}, { -4, -283, -242},
+ { 48, -68, -48}, { -6, -153, -122},
+ { 161, 196, 96}, { 232, 80, 190},
+ { 165, 97, 11}, { 258, -31, 71},
+ { 267, -77, -91}, { 311, -209, 87},
+ { 152, -14, -22}, { 150, -149, 9},
+ { -324, 557, 187}, { -384, 307, 46},
+ { -251, 27, 77}, { -365, 77, -52},
+ { -482, -84, 160}, { -424, -515, -64},
+ { -294, -120, -4}, { -476, -116, -109},
+ { -97, 318, 365}, { 106, 627, 445},
+ { -190, 120, 287}, { -146, 65, 619},
+ { -427, 242, 363}, { -361, -371, 432},
+ { -347, 102, 168}, { -629, 195, -14},
+ { -65, 476, -47}, { -297, 320, -168},
+ { -55, 356, -264}, { -391, 82, -286},
+ { -51, -31, -556}, { -178, -399, -586},
+ { -205, -49, -360}, { -343, -238, -337},
+ { 220, 457, 58}, { 561, 467, 259},
+ { 340, 270, -168}, { 450, 77, -280},
+ { 60, 167, -413}, { 133, -252, -492},
+ { 216, 157, -290}, { 282, 0, -495},
+ { -226, 293, 183}, { -157, 135, 122},
+ { -158, -59, 39}, { -133, -118, -97},
+ { -332, -309, 113}, { -160, -425, -6},
+ { -149, -211, 24}, { -80, -277, -90},
+ { -11, 125, 338}, { 130, -71, 465},
+ { 5, -45, 184}, { 237, -95, 253},
+ { -139, -197, 297}, { -19, -300, 511},
+ { -63, -152, 139}, { 250, -289, 336},
+ { 124, 339, -150}, { 34, 176, -208},
+ { 171, 166, -116}, { 94, 38, -229},
+ { 75, -65, -339}, { -78, -205, -385},
+ { 0, -30, -163}, { -56, -110, -242},
+ { 321, 244, 194}, { 505, 238, -1},
+ { 317, 116, 65}, { 309, 88, -74},
+ { 452, -51, -50}, { 334, -217, -290},
+ { 211, 41, -152}, { 238, -55, -260}
+};
+
+static const int16_t dico23_isf[128][3] = {
+ { -10, 151, 359}, { 136, 298, 223},
+ { 255, -104, 290}, { 423, 6, 183},
+ { -270, -269, -98}, { -52, -82, 13},
+ { -82, -274, -97}, { 90, -246, -72},
+ { -299, -70, 421}, { -88, 365, 430},
+ { 187, -318, 381}, { 380, 37, 488},
+ { -373, -316, 79}, { -308, -101, 5},
+ { -135, -451, 8}, { 72, -421, -154},
+ { 180, 170, -121}, { 62, 177, -40},
+ { 326, 80, -105}, { 248, 263, -5},
+ { -168, -181, -221}, { -2, -23, -158},
+ { -14, -149, -121}, { 119, -91, -147},
+ { 119, 332, -153}, { 49, 303, 34},
+ { 442, -55, -69}, { 217, 454, 58},
+ { -359, -187, -375}, { -42, 50, -274},
+ { -8, -267, -249}, { 85, -86, -346},
+ { -77, -40, 345}, { 89, 134, 219},
+ { 156, -80, 160}, { 108, 40, 116},
+ { -158, -206, 29}, { 5, -32, 175},
+ { -65, -158, 146}, { 55, -78, 73},
+ { -114, -222, 353}, { -47, 81, 211},
+ { 49, -151, 268}, { 105, 4, 302},
+ { -263, -132, 183}, { -151, -28, 201},
+ { -177, -307, 166}, { 101, -221, 130},
+ { 74, 58, -98}, { 32, 44, 13},
+ { 194, 30, -142}, { 170, 96, 8},
+ { -136, -119, -91}, { -65, 8, -55},
+ { 3, -188, 12}, { 45, -63, -49},
+ { 149, -21, -19}, { 24, 144, 95},
+ { 254, -22, 60}, { 161, 196, 96},
+ { -158, -61, 48}, { -70, 33, 82},
+ { -23, -321, 58}, { 155, -147, 5},
+ { -364, 328, 77}, { -21, 453, 173},
+ { -108, 82, 630}, { 367, 263, 208},
+ { -300, -62, -176}, { -205, 143, -158},
+ { -169, -410, -264}, { 257, -269, -100},
+ { -636, 289, -2}, { -292, 627, 173},
+ { -382, -363, 387}, { 248, 524, 447},
+ { -521, -111, -107}, { -395, 118, -274},
+ { -343, -680, -125}, { -172, -447, -663},
+ { 75, 148, -367}, { -79, 263, -94},
+ { 249, 148, -286}, { 380, 271, -162},
+ { -142, -4, -186}, { -57, 111, -125},
+ { -35, -108, -254}, { 100, 29, -242},
+ { -80, 303, -264}, { -78, 464, -57},
+ { 248, -22, -494}, { 661, 662, 44},
+ { -193, -40, -330}, { -178, 145, -337},
+ { -90, -199, -400}, { -40, -23, -498},
+ { -192, 114, 315}, { -41, 244, 190},
+ { 88, -97, 485}, { 241, 80, 212},
+ { -246, 40, 87}, { -156, 147, 134},
+ { -2, -334, 239}, { 308, -203, 110},
+ { -459, 251, 422}, { -218, 310, 228},
+ { -86, -346, 654}, { 184, 175, 425},
+ { -481, -63, 169}, { -349, 117, 188},
+ { -125, -560, 310}, { 158, -416, 94},
+ { 46, 171, -192}, { -63, 157, 14},
+ { 256, -35, -271}, { 322, 123, 53},
+ { -214, 4, -76}, { -156, 86, -18},
+ { 128, -197, -232}, { 265, -90, -98},
+ { -308, 332, -145}, { -131, 308, 58},
+ { 509, 59, -339}, { 562, 196, -14},
+ { -378, 100, -47}, { -234, 202, 1},
+ { 104, -270, -493}, { 319, -210, -325}
+};
+
+static const int16_t dico24_isf[32][3] = {
+ { -79, -89, -4}, { -171, 77, -211},
+ { 160, -193, 98}, { 120, -103, 323},
+ { 32, -22, -129}, { 72, 78, -268},
+ { 182, -76, -66}, { 309, 99, -145},
+ { -229, -157, -84}, { -383, 98, -71},
+ { -90, -352, 12}, { -284, -178, 178},
+ { -65, -125, -166}, { -87, -175, -351},
+ { 42, -198, -48}, { 154, -140, -243},
+ { -77, 18, 108}, { -39, 355, 91},
+ { 87, 8, 155}, { -4, 158, 239},
+ { 128, 95, -54}, { 7, 246, -124},
+ { 258, 15, 89}, { 206, 216, 98},
+ { -201, 9, 18}, { -312, 233, 204},
+ { -39, -174, 155}, { -144, -9, 284},
+ { -57, 70, -69}, { -157, 187, 18},
+ { 54, -30, 23}, { 24, 135, 55}
+};
+
+static const int16_t dico25_isf[32][4] = {
+ { 169, 142, -119, 115}, { 206, -20, 94, 226},
+ { -106, 313, -21, 16}, { -62, 161, 71, 255},
+ { -89, 101, -185, 125}, { 72, -30, -201, 344},
+ { -258, 33, -8, 81}, { -104, -154, 72, 296},
+ { 144, -68, -268, -25}, { 81, -78, -87, 106},
+ { 22, 155, -186, -119}, { -46, -28, 27, 91},
+ { -114, -37, -175, -33}, { -94, -222, -189, 122},
+ { -132, -119, -191, -270}, { -172, -173, 18, -43},
+ { 279, 135, -42, -128}, { 187, -86, 229, -138},
+ { 159, 240, 140, 46}, { 69, 25, 227, 77},
+ { 21, 115, 13, 8}, { 68, -248, 126, 81},
+ { -150, 137, 207, -9}, { -154, -133, 289, 67},
+ { 143, -37, -86, -326}, { 180, -32, 19, -23},
+ { 26, 168, 116, -233}, { -32, -26, 118, -78},
+ { 3, -8, -45, -115}, { 57, -215, -54, -83},
+ { -209, 112, -22, -167}, { -91, -151, 168, -262}
+};
+
+static const int16_t dico21_isf_36b[128][5] = {
+ { -52, -96, 212, 315, -73}, { 82, -204, 363, 136, -197},
+ { -126, -331, 183, 218, 143}, { -49, -41, 557, 230, 72},
+ { 2, -73, 163, 377, 221}, { 133, 111, 278, 215, -110},
+ { -102, -20, 284, 113, 273}, { 84, 319, 290, 18, 85},
+ { -25, -5, 125, 132, -204}, { -38, -5, 286, -9, -356},
+ { -140, -256, 92, 117, -189}, { -144, 191, 313, 51, -98},
+ { 167, -10, 44, 247, 36}, { 381, 197, 238, 74, 6},
+ { 38, -408, 29, -3, -85}, { 92, 266, 157, -25, -200},
+ { 161, -121, 70, 84, -140}, { -16, -86, 112, -94, -189},
+ { -269, -270, 351, 107, -24}, { -68, -67, 492, -103, -155},
+ { -53, -131, 62, 122, 10}, { 135, 84, 283, -55, -120},
+ { -12, -219, 331, -81, 167}, { 220, -136, 147, -172, -42},
+ { 140, -95, -109, -88, -194}, { 0, -2, -4, -33, -381},
+ { -66, -217, 152, -186, -402}, { 244, 108, 156, -140, -395},
+ { 113, -136, -196, 110, -24}, { 214, 118, 11, -64, -131},
+ { -110, -286, -6, -332, 16}, { 94, 97, 79, -291, -205},
+ { -5, -39, -20, 252, -96}, { 76, 174, 101, 163, 61},
+ { -69, -239, -55, 399, 6}, { -115, 319, 164, 275, 196},
+ { -15, 36, -47, 331, 121}, { 226, 209, 271, 325, 184},
+ { 13, -80, -218, 471, 353}, { 288, 378, 16, -51, 251},
+ { 174, 116, 52, 149, -279}, { 235, 276, 39, 120, -48},
+ { 0, -108, -108, 241, -339}, { -93, 534, 45, 33, -87},
+ { 194, 149, -71, 405, -44}, { 409, 370, 81, -186, -154},
+ { 25, -102, -448, 124, -173}, { 22, 408, -110, -310, -214},
+ { -26, 23, -83, 114, 14}, { -110, 164, 52, 223, -82},
+ { 37, -25, -263, 306, -15}, { -466, 415, 292, 165, -18},
+ { 29, -19, -171, 155, 182}, { 179, 144, -27, 231, 258},
+ { -103, -247, -396, 238, 113}, { 375, -154, -109, -4, 156},
+ { 98, 85, -292, -5, -124}, { 116, 139, -116, -98, -294},
+ { -14, -83, -278, -117, -378}, { 106, 33, -106, -344, -484},
+ { 119, 17, -412, 138, 166}, { 384, 101, -204, 88, -156},
+ { -121, -284, -300, -1, -166}, { 280, 33, -152, -313, -81},
+ { -37, 22, 229, 153, 37}, { -60, -83, 236, -8, -41},
+ { -169, -228, 126, -20, 363}, { -235, 17, 364, -156, 156},
+ { -25, -30, 72, 144, 156}, { 153, -26, 256, 97, 144},
+ { -21, -37, 48, -65, 250}, { 63, 77, 273, -128, 124},
+ { -129, -26, 40, 9, -115}, { -6, 82, 38, -90, -182},
+ { -336, -13, 28, 158, 91}, { -30, 241, 137, -170, -17},
+ { 146, 14, -11, 33, 61}, { 192, 197, 54, -84, 85},
+ { 23, -200, -78, -29, 140}, { 122, 237, 106, -341, 136},
+ { -57, -142, -85, -16, -74}, { -59, -90, -8, -187, -20},
+ { -211, -267, 216, -179, -110}, { -50, -7, 220, -267, -70},
+ { -57, -42, -17, -15, 71}, { 32, 21, 63, -137, 33},
+ { -137, -175, 104, -68, 97}, { -67, -43, 133, -301, 221},
+ { -116, -200, -81, -92, -272}, { -64, -41, -54, -244, -220},
+ { -287, -242, -50, -87, -89}, { -245, 236, 102, -166, -295},
+ { 66, 24, -162, -71, 95}, { 66, 136, -90, -220, -36},
+ { -98, -161, -222, -188, 29}, { -18, 18, -19, -415, 9},
+ { 49, 61, 100, 39, -56}, { -111, 82, 135, -31, 52},
+ { -90, -153, -93, 189, 182}, { -214, 295, 119, -74, 284},
+ { 2, 137, 37, 47, 182}, { 92, 117, 184, -53, 373},
+ { -21, -14, -35, 136, 391}, { 146, 129, -164, -28, 333},
+ { 92, 80, -84, 100, -134}, { -8, 217, -32, 3, -47},
+ { -151, 251, -215, 142, 92}, { -224, 310, -172, -275, 98},
+ { 159, 155, -177, 112, 53}, { 205, 27, 8, -240, 192},
+ { 169, 120, -319, -201, 106}, { 11, 36, -86, -237, 455},
+ { -109, -154, -163, 174, -55}, { -38, 32, -101, -78, -59},
+ { -205, -321, -97, 69, 79}, { -310, 44, 18, -185, 34},
+ { -115, -20, -148, -39, 203}, { -29, 154, -30, -158, 166},
+ { -45, -131, -317, -24, 363}, { -165, -205, -112, -222, 265},
+ { -32, -44, -150, 54, -193}, { -6, -38, -255, -169, -115},
+ { -266, 87, -189, -36, -169}, { -60, -87, -266, -436, -170},
+ { -68, -81, -278, 24, 38}, { -23, -19, -155, -256, 141},
+ { -61, -226, -565, -175, 71}, { 9, -29, -237, -515, 263}
+};
+
+static const int16_t dico22_isf_36b[128][4] = {
+ { -298, -6, 95, 31}, { -213, -87, -122, 261},
+ { 4, -49, 208, 14}, { -129, -110, 30, 118},
+ { -214, 258, 110, -235}, { -41, -18, -126, 120},
+ { 103, 65, 127, -37}, { 126, -36, -24, 25},
+ { -138, -67, -278, -186}, { -164, -194, -201, 78},
+ { -211, -87, -51, -221}, { -174, -79, -94, -39},
+ { 23, -6, -157, -240}, { 22, -110, -153, -68},
+ { 148, -5, -2, -149}, { -1, -135, -39, -179},
+ { 68, 360, -117, -15}, { 137, 47, -278, 146},
+ { 136, 260, 135, 65}, { 61, 116, -45, 97},
+ { 231, 379, 87, -120}, { 338, 177, -272, 3},
+ { 266, 156, 28, -69}, { 260, 84, -85, 86},
+ { -266, 154, -256, -182}, { -17, -65, -304, -6},
+ { -40, 175, -151, -180}, { -27, 27, -87, -63},
+ { 121, 114, -166, -469}, { 159, -66, -323, -231},
+ { 214, 152, -141, -212}, { 137, 36, -184, -51},
+ { -282, -237, 40, 10}, { -48, -235, -37, 251},
+ { -54, -323, 136, 29}, { -88, -174, 213, 198},
+ { -390, 99, -63, -375}, { 107, -169, -164, 424},
+ { 69, -111, 141, -167}, { 74, -129, 65, 144},
+ { -353, -207, -205, -109}, { -160, -386, -355, 98},
+ { -176, -493, -20, -143}, { -252, -432, -2, 216},
+ { -90, -174, -168, -411}, { 13, -284, -229, -160},
+ { -87, -279, 34, -251}, { -75, -263, -58, -42},
+ { 420, 53, -211, -358}, { 384, -35, -374, 396},
+ { 68, -228, 323, -2}, { 167, -307, 192, 194},
+ { 459, 329, -5, -332}, { 375, 79, -7, 313},
+ { 282, -124, 200, -92}, { 271, -162, -70, 180},
+ { -157, -298, -514, -309}, { 58, -163, -546, 18},
+ { 124, -364, 167, -238}, { 83, -411, -117, 96},
+ { 140, -112, -388, -624}, { 259, -133, -317, 41},
+ { 163, -130, -64, -334}, { 226, -165, -124, -110},
+ { -466, -61, 6, 229}, { -153, 205, -145, 242},
+ { -159, 48, 195, 148}, { -58, 28, 31, 279},
+ { -303, 185, 279, -4}, { -61, 197, 59, 86},
+ { -114, 123, 168, -52}, { 35, 36, 100, 126},
+ { -407, 102, -77, -40}, { -338, -1, -342, 156},
+ { -179, 105, -34, -97}, { -185, 84, -35, 108},
+ { -133, 107, -91, -357}, { -180, 54, -229, 24},
+ { -44, 47, 47, -182}, { -66, 13, 45, 4},
+ { -339, 251, 64, 226}, { -42, 101, -350, 275},
+ { -99, 398, 142, 121}, { 111, 12, -102, 260},
+ { 0, 505, 260, -94}, { 161, 285, -96, 224},
+ { -4, 206, 314, 33}, { 167, 139, 88, 204},
+ { -235, 316, -60, -25}, { -8, -150, -312, 201},
+ { -36, 292, 61, -104}, { -40, 174, -162, 42},
+ { -21, 402, -29, -351}, { 21, 152, -360, -93},
+ { 57, 191, 212, -196}, { 76, 158, -21, -69},
+ { -328, -185, 331, 119}, { -53, 285, 56, 337},
+ { -107, -24, 405, 29}, { -18, 137, 272, 277},
+ { -255, 22, 173, -191}, { 295, 322, 325, 302},
+ { 21, -27, 332, -178}, { 119, 13, 271, 129},
+ { -455, -180, 116, -191}, { -227, 62, -148, 524},
+ { -176, -287, 282, -157}, { -243, 13, 199, 430},
+ { -59, -49, 115, -365}, { 72, -172, -137, 93},
+ { -138, -126, 141, -84}, { 5, -124, 38, -20},
+ { -258, 311, 601, 213}, { 94, 130, -61, 502},
+ { -1, -157, 485, 313}, { 146, -74, 158, 345},
+ { 276, 135, 280, -57}, { 490, 252, 99, 43},
+ { 267, -74, 429, 105}, { 278, -23, 119, 94},
+ { -542, 488, 257, -115}, { -84, -244, -438, 478},
+ { -113, -545, 387, 101}, { -95, -306, 111, 498},
+ { 95, 166, 22, -301}, { 420, -15, -58, -78},
+ { 270, 29, 122, -282}, { 160, -240, 50, -38}
+};
+
+static const int16_t dico23_isf_36b[64][7] = {
+ { 81, -18, 68, -27, -122, -280, -4},
+ { 45, -177, 209, -30, -136, -74, 131},
+ { -44, 101, -75, -88, -48, -137, -54},
+ { -245, -28, 63, -18, -112, -103, 58},
+ { -79, -6, 220, -65, 114, -35, -50},
+ { 109, -65, 143, -114, 129, 76, 125},
+ { 166, 90, -61, -242, 186, -74, -43},
+ { -46, -92, 49, -227, 24, -155, 39},
+ { 67, 85, 99, -42, 53, -184, -281},
+ { 142, -122, 0, 21, -142, -15, -17},
+ { 223, 92, -21, -48, -82, -14, -167},
+ { 51, -37, -243, -30, -90, 18, -56},
+ { 54, 105, 74, 86, 69, 13, -101},
+ { 196, 72, -89, 43, 65, 19, 39},
+ { 121, 34, 131, -82, 25, 213, -156},
+ { 101, -102, -136, -21, 57, 214, 22},
+ { 36, -124, 205, 204, 58, -156, -83},
+ { 83, -117, 137, 137, 85, 116, 44},
+ { -92, -148, -68, 11, -102, -197, -220},
+ { -76, -185, -58, 132, -26, -183, 85},
+ { -7, -31, -2, 23, 205, -151, 10},
+ { -27, -37, -5, -18, 292, 131, 1},
+ { 117, -168, 9, -93, 80, -59, -125},
+ { -182, -244, 98, -24, 135, -22, 94},
+ { 221, 97, 106, 42, 43, -160, 83},
+ { 25, -64, -21, 6, 14, -15, 154},
+ { 126, 15, -140, 150, -10, -207, -114},
+ { 79, -63, -211, -70, -28, -217, 165},
+ { 46, 38, -22, 281, 132, -62, 109},
+ { 112, 54, -112, -93, 208, 27, 296},
+ { 115, 10, -147, 41, 216, 42, -276},
+ { 50, -115, -254, 167, 117, -2, 61},
+ { 17, 144, 34, -72, -186, -150, 272},
+ { -29, -66, -89, -95, -149, 129, 251},
+ { 122, 0, -50, -234, -91, 36, 26},
+ { -105, -102, -88, -121, -236, -7, -11},
+ { -204, 109, 5, -191, 105, -15, 163},
+ { -80, 32, -24, -209, 41, 294, 70},
+ { -106, -94, -204, -118, 120, -50, -37},
+ { -82, -241, 46, -131, -29, 150, -55},
+ { 33, 155, 120, -89, -8, 7, 62},
+ { 213, 82, 61, 18, -161, 144, 152},
+ { 30, 131, 65, -87, -255, -17, -107},
+ { -8, 85, -64, 51, -162, 223, -53},
+ { -134, 261, 69, -56, 218, 72, -111},
+ { 2, 155, -113, -87, 49, 85, -28},
+ { -163, 42, -1, -196, 7, 39, -245},
+ { 14, -137, -79, 11, -160, 202, -293},
+ { -94, 33, 208, 100, 56, -44, 326},
+ { -78, -41, 232, 13, -142, 227, 80},
+ { -16, -87, 201, 33, -133, 15, -183},
+ { -58, -192, -47, 184, -128, 133, 99},
+ { -205, 11, -155, 78, 52, 72, 141},
+ { -246, 26, 99, 151, 59, 115, -64},
+ { -79, -47, -16, -14, 6, 47, -43},
+ { -72, -178, -27, 162, 112, 43, -174},
+ { -175, 238, 186, 71, -54, -188, -76},
+ { -225, 233, 39, -39, -158, 122, 44},
+ { -26, 43, 84, 130, -93, -51, 22},
+ { 3, 92, -150, 136, -182, -57, 97},
+ { -131, 179, -78, 80, 91, -165, 90},
+ { -2, 148, 15, 130, 65, 175, 117},
+ { -138, 114, -137, 132, 3, -10, -186},
+ { 140, -4, -37, 254, -62, 92, -109}
+};
+
+/** Means of ISF vectors in Q15 */
+static const int16_t isf_mean[LP_ORDER] = {
+ 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
+ 8750, 9753, 10705, 11728, 12833, 13971, 15043, 4037
+};
+
+/** Initialization tables for the processed ISF vector in Q15 */
+static const int16_t isf_init[LP_ORDER] = {
+ 1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192,
+ 9216, 10240, 11264, 12288, 13312, 14336, 15360, 3840
+};
+
+/** ISF/ISP interpolation coefficients for each subframe */
+static const float isfp_inter[4] = { 0.45, 0.8, 0.96, 1.0 };
+
+/** Coefficients for FIR interpolation of excitation vector
+ * at pitch lag resulting the adaptive codebook vector */
+static const float ac_inter[65] = {
+ 9.400024e-01,
+ 8.563843e-01, 6.322632e-01, 3.375854e-01, 5.908203e-02,
+ -1.310425e-01, -1.994019e-01, -1.585693e-01, -5.633545e-02,
+ 4.760742e-02, 1.067505e-01, 1.036987e-01, 5.206299e-02,
+ -1.519775e-02, -6.372070e-02, -7.366943e-02, -4.650879e-02,
+ -9.765625e-04, 3.820801e-02, 5.316162e-02, 4.003906e-02,
+ 9.338379e-03, -2.166748e-02, -3.778076e-02, -3.320312e-02,
+ -1.300049e-02, 1.068115e-02, 2.587891e-02, 2.630615e-02,
+ 1.379395e-02, -3.662109e-03, -1.678467e-02, -1.983643e-02,
+ -1.275635e-02, -5.493164e-04, 1.007080e-02, 1.409912e-02,
+ 1.068115e-02, 2.624512e-03, -5.371094e-03, -9.338379e-03,
+ -8.117676e-03, -3.173828e-03, 2.319336e-03, 5.615234e-03,
+ 5.554199e-03, 2.868652e-03, -6.103516e-04, -2.990723e-03,
+ -3.356934e-03, -2.014160e-03, -1.220703e-04, 1.342773e-03,
+ 1.708984e-03, 1.159668e-03, 2.441406e-04, -4.272461e-04,
+ -6.103516e-04, -4.272461e-04, -1.220703e-04, 6.103516e-05,
+ 1.220703e-04, 6.103516e-05, 0.000000e+00, 0.000000e+00
+};
+
+/** [i][j] is the number of pulses present in track j at mode i */
+static const uint8_t pulses_nb_per_mode_tr[][4] = {
+ {1, 1, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2},
+ {3, 3, 2, 2}, {3, 3, 3, 3}, {4, 4, 4, 4},
+ {5, 5, 4, 4}, {6, 6, 6, 6}, {6, 6, 6, 6}
+};
+
+/** Tables for decoding quantized gains { pitch (Q14), fixed factor (Q11) } */
+static const int16_t qua_gain_6b[64][2] = {
+ { 1566, 1332}, { 1577, 3557},
+ { 3071, 6490}, { 4193, 10163},
+ { 4496, 2534}, { 5019, 4488},
+ { 5586, 15614}, { 5725, 1422},
+ { 6453, 580}, { 6724, 6831},
+ { 7657, 3527}, { 8072, 2099},
+ { 8232, 5319}, { 8827, 8775},
+ { 9740, 2868}, { 9856, 1465},
+ { 10087, 12488}, { 10241, 4453},
+ { 10859, 6618}, { 11321, 3587},
+ { 11417, 1800}, { 11643, 2428},
+ { 11718, 988}, { 12312, 5093},
+ { 12523, 8413}, { 12574, 26214},
+ { 12601, 3396}, { 13172, 1623},
+ { 13285, 2423}, { 13418, 6087},
+ { 13459, 12810}, { 13656, 3607},
+ { 14111, 4521}, { 14144, 1229},
+ { 14425, 1871}, { 14431, 7234},
+ { 14445, 2834}, { 14628, 10036},
+ { 14860, 17496}, { 15161, 3629},
+ { 15209, 5819}, { 15299, 2256},
+ { 15518, 4722}, { 15663, 1060},
+ { 15759, 7972}, { 15939, 11964},
+ { 16020, 2996}, { 16086, 1707},
+ { 16521, 4254}, { 16576, 6224},
+ { 16894, 2380}, { 16906, 681},
+ { 17213, 8406}, { 17610, 3418},
+ { 17895, 5269}, { 18168, 11748},
+ { 18230, 1575}, { 18607, 32767},
+ { 18728, 21684}, { 19137, 2543},
+ { 19422, 6577}, { 19446, 4097},
+ { 19450, 9056}, { 20371, 14885}
+};
+
+static const int16_t qua_gain_7b[128][2] = {
+ { 204, 441}, { 464, 1977},
+ { 869, 1077}, { 1072, 3062},
+ { 1281, 4759}, { 1647, 1539},
+ { 1845, 7020}, { 1853, 634},
+ { 1995, 2336}, { 2351, 15400},
+ { 2661, 1165}, { 2702, 3900},
+ { 2710, 10133}, { 3195, 1752},
+ { 3498, 2624}, { 3663, 849},
+ { 3984, 5697}, { 4214, 3399},
+ { 4415, 1304}, { 4695, 2056},
+ { 5376, 4558}, { 5386, 676},
+ { 5518, 23554}, { 5567, 7794},
+ { 5644, 3061}, { 5672, 1513},
+ { 5957, 2338}, { 6533, 1060},
+ { 6804, 5998}, { 6820, 1767},
+ { 6937, 3837}, { 7277, 414},
+ { 7305, 2665}, { 7466, 11304},
+ { 7942, 794}, { 8007, 1982},
+ { 8007, 1366}, { 8326, 3105},
+ { 8336, 4810}, { 8708, 7954},
+ { 8989, 2279}, { 9031, 1055},
+ { 9247, 3568}, { 9283, 1631},
+ { 9654, 6311}, { 9811, 2605},
+ { 10120, 683}, { 10143, 4179},
+ { 10245, 1946}, { 10335, 1218},
+ { 10468, 9960}, { 10651, 3000},
+ { 10951, 1530}, { 10969, 5290},
+ { 11203, 2305}, { 11325, 3562},
+ { 11771, 6754}, { 11839, 1849},
+ { 11941, 4495}, { 11954, 1298},
+ { 11975, 15223}, { 11977, 883},
+ { 11986, 2842}, { 12438, 2141},
+ { 12593, 3665}, { 12636, 8367},
+ { 12658, 1594}, { 12886, 2628},
+ { 12984, 4942}, { 13146, 1115},
+ { 13224, 524}, { 13341, 3163},
+ { 13399, 1923}, { 13549, 5961},
+ { 13606, 1401}, { 13655, 2399},
+ { 13782, 3909}, { 13868, 10923},
+ { 14226, 1723}, { 14232, 2939},
+ { 14278, 7528}, { 14439, 4598},
+ { 14451, 984}, { 14458, 2265},
+ { 14792, 1403}, { 14818, 3445},
+ { 14899, 5709}, { 15017, 15362},
+ { 15048, 1946}, { 15069, 2655},
+ { 15405, 9591}, { 15405, 4079},
+ { 15570, 7183}, { 15687, 2286},
+ { 15691, 1624}, { 15699, 3068},
+ { 15772, 5149}, { 15868, 1205},
+ { 15970, 696}, { 16249, 3584},
+ { 16338, 1917}, { 16424, 2560},
+ { 16483, 4438}, { 16529, 6410},
+ { 16620, 11966}, { 16839, 8780},
+ { 17030, 3050}, { 17033, 18325},
+ { 17092, 1568}, { 17123, 5197},
+ { 17351, 2113}, { 17374, 980},
+ { 17566, 26214}, { 17609, 3912},
+ { 17639, 32767}, { 18151, 7871},
+ { 18197, 2516}, { 18202, 5649},
+ { 18679, 3283}, { 18930, 1370},
+ { 19271, 13757}, { 19317, 4120},
+ { 19460, 1973}, { 19654, 10018},
+ { 19764, 6792}, { 19912, 5135},
+ { 20040, 2841}, { 21234, 19833}
+};
+
+/** 4-tap moving average prediction coefficients in reverse order */
+static const float energy_pred_fac[4] = { 0.2, 0.3, 0.4, 0.5 };
+
+/** impulse response filter tables converted to float from Q15
+ * used for anti-sparseness processing */
+static const float ir_filter_str[64] = {
+ 6.159058e-01, 2.958069e-01, 9.979248e-02, -1.048889e-01,
+ 8.740234e-02, -1.599121e-01, 4.849243e-02, -4.141235e-02,
+ 1.831055e-02, 1.188049e-01, -4.568481e-02, -2.130127e-02,
+ 3.671265e-02, -1.601868e-01, 3.659058e-02, 1.639099e-01,
+ -4.541016e-02, -2.151489e-02, -8.810425e-02, 6.030273e-02,
+ 2.740479e-02, 2.200317e-02, -1.182861e-01, 1.289978e-01,
+ -1.560059e-01, 1.953125e-01, -3.149414e-02, -1.441956e-01,
+ 1.249084e-01, -1.328125e-01, 9.780884e-02, 6.500244e-02,
+ -6.091309e-02, -5.599976e-02, 8.081055e-02, -5.450439e-02,
+ -1.239014e-02, 1.748657e-02, 7.580566e-02, -1.101074e-01,
+ 9.579468e-02, -4.159546e-02, -7.830811e-02, 1.162109e-01,
+ -1.950073e-02, -6.259155e-02, -1.651001e-02, 7.250977e-02,
+ 1.199951e-01, -1.911011e-01, 4.370117e-02, -1.098938e-01,
+ 1.492004e-01, 1.129150e-02, 1.730347e-02, -3.549194e-02,
+ -8.709717e-02, 5.841064e-02, 1.190186e-03, -7.379150e-02,
+ 1.054077e-01, 9.078979e-02, -1.227112e-01, 1.047058e-01
+};
+
+static const float ir_filter_mid[64] = {
+ 7.354126e-01, 3.192139e-01, -1.606140e-01, -2.328491e-02,
+ 6.250000e-02, -2.828979e-02, 5.349731e-02, -1.014099e-01,
+ 6.750488e-02, 1.989746e-02, -6.549072e-02, 7.589722e-02,
+ -1.080017e-01, 1.253967e-01, -6.430054e-02, -1.141357e-02,
+ -1.910400e-02, 1.303101e-01, -1.673889e-01, 6.820679e-02,
+ 5.670166e-02, -8.450317e-02, 2.270508e-02, 3.479004e-02,
+ -2.328491e-02, -4.928589e-02, 1.239014e-01, -1.395874e-01,
+ 9.100342e-02, -3.549194e-02, 2.230835e-02, -3.350830e-02,
+ 2.450562e-02, 5.096436e-03, -2.178955e-02, 1.849365e-02,
+ -1.708984e-02, 1.950073e-02, 1.312256e-03, -5.389404e-02,
+ 9.851074e-02, -8.489990e-02, 2.029419e-02, 2.328491e-02,
+ 7.110596e-03, -6.109619e-02, 3.939819e-02, 5.709839e-02,
+ -1.058960e-01, 3.149414e-02, 8.270264e-02, -1.232910e-01,
+ 1.105957e-01, -1.286011e-01, 1.614990e-01, -1.303101e-01,
+ 4.769897e-02, 3.295898e-03, -1.770020e-02, 5.010986e-02,
+ -7.501221e-02, 2.920532e-02, 1.660156e-02, 7.751465e-02
+};
+
+static const float *ir_filters_lookup[2] = {
+ ir_filter_str, ir_filter_mid
+};
+
+/** High-pass filters coefficients for 31 Hz and 400 Hz cutoff */
+static const float hpf_zeros[2] = { -2.0, 1.0 };
+static const float hpf_31_poles[2] = { -1.978881836, 0.979125977 };
+static const float hpf_31_gain = 0.989501953;
+
+static const float hpf_400_poles[2] = { -1.787109375, 0.864257812 };
+static const float hpf_400_gain = 0.893554687;
+
+/** Interpolation coefficients for 5/4 signal upsampling
+ * Table from the reference source was reordered for efficiency */
+static const float upsample_fir[4][24] = {
+ { -6.103516e-05, 7.324219e-04, -2.014160e-03, 4.150391e-03,
+ -7.263184e-03, 1.165771e-02, -1.776123e-02, 2.624512e-02,
+ -3.869629e-02, 5.877686e-02, -9.863281e-02, 2.314453e-01,
+ 9.348755e-01, -1.523438e-01, 7.861328e-02, -4.937744e-02,
+ 3.308105e-02, -2.252197e-02, 1.507568e-02, -9.765625e-03,
+ 5.859375e-03, -3.173828e-03, 1.403809e-03, -3.662109e-04 },
+ { -2.441406e-04, 1.464844e-03, -3.784180e-03, 7.568359e-03,
+ -1.300049e-02, 2.062988e-02, -3.112793e-02, 4.589844e-02,
+ -6.781006e-02, 1.042480e-01, -1.815186e-01, 5.016479e-01,
+ 7.548828e-01, -2.094727e-01, 1.148071e-01, -7.348633e-02,
+ 4.956055e-02, -3.369141e-02, 2.246094e-02, -1.434326e-02,
+ 8.483887e-03, -4.455566e-03, 1.831055e-03, -4.272461e-04 },
+ { -4.272461e-04, 1.831055e-03, -4.455566e-03, 8.483887e-03,
+ -1.434326e-02, 2.246094e-02, -3.369141e-02, 4.956055e-02,
+ -7.348633e-02, 1.148071e-01, -2.094727e-01, 7.548828e-01,
+ 5.016479e-01, -1.815186e-01, 1.042480e-01, -6.781006e-02,
+ 4.589844e-02, -3.112793e-02, 2.062988e-02, -1.300049e-02,
+ 7.568359e-03, -3.784180e-03, 1.464844e-03, -2.441406e-04 },
+ { -3.662109e-04, 1.403809e-03, -3.173828e-03, 5.859375e-03,
+ -9.765625e-03, 1.507568e-02, -2.252197e-02, 3.308105e-02,
+ -4.937744e-02, 7.861328e-02, -1.523438e-01, 9.348755e-01,
+ 2.314453e-01, -9.863281e-02, 5.877686e-02, -3.869629e-02,
+ 2.624512e-02, -1.776123e-02, 1.165771e-02, -7.263184e-03,
+ 4.150391e-03, -2.014160e-03, 7.324219e-04, -6.103516e-05 }
+};
+
+/** High band quantized gains for 23k85 in Q14 */
+static const uint16_t qua_hb_gain[16] = {
+ 3624, 4673, 5597, 6479, 7425, 8378, 9324, 10264,
+ 11210, 12206, 13391, 14844, 16770, 19655, 24289, 32728
+};
+
+/** High-band post-processing FIR filters coefficients from Q15 */
+static const float bpf_6_7_coef[31] = { // band pass, 6kHz and 7kHz cutoffs
+ -2.441406e-04, 3.585815e-04, 2.441406e-04,
+ -2.059937e-04, -2.815248e-03, 8.560180e-03,
+ -1.084137e-02, 0.000000e+00, 2.897645e-02,
+ -6.774902e-02, 9.421540e-02, -8.380128e-02,
+ 2.706910e-02, 5.924987e-02, -1.373367e-01,
+ 1.687469e-01,
+ -1.373367e-01, 5.924987e-02, 2.706910e-02,
+ -8.380128e-02, 9.421540e-02, -6.774902e-02,
+ 2.897645e-02, 0.000000e+00, -1.084137e-02,
+ 8.560180e-03, -2.815248e-03, -2.059937e-04,
+ 2.441406e-04, 3.585815e-04, -2.441406e-04
+};
+
+static const float lpf_7_coef[31] = { // low pass, 7kHz cutoff
+ -6.408691e-04, 1.434326e-03, -2.716064e-03,
+ 4.455566e-03, -6.195068e-03, 6.988525e-03,
+ -5.401611e-03, 0.000000e+00, 1.022339e-02,
+ -2.560425e-02, 4.531860e-02, -6.747437e-02,
+ 8.944702e-02, -1.080933e-01, 1.206360e-01,
+ 8.753052e-01,
+ 1.206360e-01, -1.080933e-01, 8.944702e-02,
+ -6.747437e-02, 4.531860e-02, -2.560425e-02,
+ 1.022339e-02, 0.000000e+00, -5.401611e-03,
+ 6.988525e-03, -6.195068e-03, 4.455566e-03,
+ -2.716064e-03, 1.434326e-03, -6.408691e-04
+};
+
+/** Core frame sizes in each mode */
+static const uint16_t cf_sizes_wb[] = {
+ 132, 177, 253, 285, 317, 365, 397, 461, 477,
+ 40 /// SID/comfort noise frame
+};
+
+#endif
diff --git a/lib/ffmpeg/libavcodec/amrwbdec.c b/lib/ffmpeg/libavcodec/amrwbdec.c
new file mode 100644
index 0000000000..8bf02a2b10
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/amrwbdec.c
@@ -0,0 +1,1237 @@
+/*
+ * AMR wideband decoder
+ * Copyright (c) 2010 Marcelo Galvao Povoa
+ *
+ * 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
+ * AMR wideband decoder
+ */
+
+#include "libavutil/lfg.h"
+
+#include "avcodec.h"
+#include "get_bits.h"
+#include "lsp.h"
+#include "celp_math.h"
+#include "celp_filters.h"
+#include "acelp_filters.h"
+#include "acelp_vectors.h"
+#include "acelp_pitch_delay.h"
+
+#define AMR_USE_16BIT_TABLES
+#include "amr.h"
+
+#include "amrwbdata.h"
+
+typedef struct {
+ AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
+ enum Mode fr_cur_mode; ///< mode index of current frame
+ uint8_t fr_quality; ///< frame quality index (FQI)
+ float isf_cur[LP_ORDER]; ///< working ISF vector from current frame
+ float isf_q_past[LP_ORDER]; ///< quantized ISF vector of the previous frame
+ float isf_past_final[LP_ORDER]; ///< final processed ISF vector of the previous frame
+ double isp[4][LP_ORDER]; ///< ISP vectors from current frame
+ double isp_sub4_past[LP_ORDER]; ///< ISP vector for the 4th subframe of the previous frame
+
+ float lp_coef[4][LP_ORDER]; ///< Linear Prediction Coefficients from ISP vector
+
+ uint8_t base_pitch_lag; ///< integer part of pitch lag for the next relative subframe
+ uint8_t pitch_lag_int; ///< integer part of pitch lag of the previous subframe
+
+ float excitation_buf[AMRWB_P_DELAY_MAX + LP_ORDER + 2 + AMRWB_SFR_SIZE]; ///< current excitation and all necessary excitation history
+ float *excitation; ///< points to current excitation in excitation_buf[]
+
+ float pitch_vector[AMRWB_SFR_SIZE]; ///< adaptive codebook (pitch) vector for current subframe
+ float fixed_vector[AMRWB_SFR_SIZE]; ///< algebraic codebook (fixed) vector for current subframe
+
+ float prediction_error[4]; ///< quantified prediction errors {20log10(^gamma_gc)} for previous four subframes
+ float pitch_gain[6]; ///< quantified pitch gains for the current and previous five subframes
+ float fixed_gain[2]; ///< quantified fixed gains for the current and previous subframes
+
+ float tilt_coef; ///< {beta_1} related to the voicing of the previous subframe
+
+ float prev_sparse_fixed_gain; ///< previous fixed gain; used by anti-sparseness to determine "onset"
+ uint8_t prev_ir_filter_nr; ///< previous impulse response filter "impNr": 0 - strong, 1 - medium, 2 - none
+ float prev_tr_gain; ///< previous initial gain used by noise enhancer for threshold
+
+ float samples_az[LP_ORDER + AMRWB_SFR_SIZE]; ///< low-band samples and memory from synthesis at 12.8kHz
+ float samples_up[UPS_MEM_SIZE + AMRWB_SFR_SIZE]; ///< low-band samples and memory processed for upsampling
+ float samples_hb[LP_ORDER_16k + AMRWB_SFR_SIZE_16k]; ///< high-band samples and memory from synthesis at 16kHz
+
+ float hpf_31_mem[2], hpf_400_mem[2]; ///< previous values in the high pass filters
+ float demph_mem[1]; ///< previous value in the de-emphasis filter
+ float bpf_6_7_mem[HB_FIR_SIZE]; ///< previous values in the high-band band pass filter
+ float lpf_7_mem[HB_FIR_SIZE]; ///< previous values in the high-band low pass filter
+
+ AVLFG prng; ///< random number generator for white noise excitation
+ uint8_t first_frame; ///< flag active during decoding of the first frame
+} AMRWBContext;
+
+static av_cold int amrwb_decode_init(AVCodecContext *avctx)
+{
+ AMRWBContext *ctx = avctx->priv_data;
+ int i;
+
+ avctx->sample_fmt = SAMPLE_FMT_FLT;
+
+ av_lfg_init(&ctx->prng, 1);
+
+ ctx->excitation = &ctx->excitation_buf[AMRWB_P_DELAY_MAX + LP_ORDER + 1];
+ ctx->first_frame = 1;
+
+ for (i = 0; i < LP_ORDER; i++)
+ ctx->isf_past_final[i] = isf_init[i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 4; i++)
+ ctx->prediction_error[i] = MIN_ENERGY;
+
+ return 0;
+}
+
+/**
+ * Decode the frame header in the "MIME/storage" format. This format
+ * is simpler and does not carry the auxiliary information of the frame
+ *
+ * @param[in] ctx The Context
+ * @param[in] buf Pointer to the input buffer
+ *
+ * @return The decoded header length in bytes
+ */
+static int decode_mime_header(AMRWBContext *ctx, const uint8_t *buf)
+{
+ GetBitContext gb;
+ init_get_bits(&gb, buf, 8);
+
+ /* Decode frame header (1st octet) */
+ skip_bits(&gb, 1); // padding bit
+ ctx->fr_cur_mode = get_bits(&gb, 4);
+ ctx->fr_quality = get_bits1(&gb);
+ skip_bits(&gb, 2); // padding bits
+
+ return 1;
+}
+
+/**
+ * Decodes quantized ISF vectors using 36-bit indexes (6K60 mode only)
+ *
+ * @param[in] ind Array of 5 indexes
+ * @param[out] isf_q Buffer for isf_q[LP_ORDER]
+ *
+ */
+static void decode_isf_indices_36b(uint16_t *ind, float *isf_q)
+{
+ int i;
+
+ for (i = 0; i < 9; i++)
+ isf_q[i] = dico1_isf[ind[0]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 7; i++)
+ isf_q[i + 9] = dico2_isf[ind[1]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 5; i++)
+ isf_q[i] += dico21_isf_36b[ind[2]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 4; i++)
+ isf_q[i + 5] += dico22_isf_36b[ind[3]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 7; i++)
+ isf_q[i + 9] += dico23_isf_36b[ind[4]][i] * (1.0f / (1 << 15));
+}
+
+/**
+ * Decodes quantized ISF vectors using 46-bit indexes (except 6K60 mode)
+ *
+ * @param[in] ind Array of 7 indexes
+ * @param[out] isf_q Buffer for isf_q[LP_ORDER]
+ *
+ */
+static void decode_isf_indices_46b(uint16_t *ind, float *isf_q)
+{
+ int i;
+
+ for (i = 0; i < 9; i++)
+ isf_q[i] = dico1_isf[ind[0]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 7; i++)
+ isf_q[i + 9] = dico2_isf[ind[1]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 3; i++)
+ isf_q[i] += dico21_isf[ind[2]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 3; i++)
+ isf_q[i + 3] += dico22_isf[ind[3]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 3; i++)
+ isf_q[i + 6] += dico23_isf[ind[4]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 3; i++)
+ isf_q[i + 9] += dico24_isf[ind[5]][i] * (1.0f / (1 << 15));
+
+ for (i = 0; i < 4; i++)
+ isf_q[i + 12] += dico25_isf[ind[6]][i] * (1.0f / (1 << 15));
+}
+
+/**
+ * Apply mean and past ISF values using the prediction factor
+ * Updates past ISF vector
+ *
+ * @param[in,out] isf_q Current quantized ISF
+ * @param[in,out] isf_past Past quantized ISF
+ *
+ */
+static void isf_add_mean_and_past(float *isf_q, float *isf_past)
+{
+ int i;
+ float tmp;
+
+ for (i = 0; i < LP_ORDER; i++) {
+ tmp = isf_q[i];
+ isf_q[i] += isf_mean[i] * (1.0f / (1 << 15));
+ isf_q[i] += PRED_FACTOR * isf_past[i];
+ isf_past[i] = tmp;
+ }
+}
+
+/**
+ * Interpolate the fourth ISP vector from current and past frames
+ * to obtain a ISP vector for each subframe
+ *
+ * @param[in,out] isp_q ISPs for each subframe
+ * @param[in] isp4_past Past ISP for subframe 4
+ */
+static void interpolate_isp(double isp_q[4][LP_ORDER], const double *isp4_past)
+{
+ int i, k;
+
+ for (k = 0; k < 3; k++) {
+ float c = isfp_inter[k];
+ for (i = 0; i < LP_ORDER; i++)
+ isp_q[k][i] = (1.0 - c) * isp4_past[i] + c * isp_q[3][i];
+ }
+}
+
+/**
+ * Decode an adaptive codebook index into pitch lag (except 6k60, 8k85 modes)
+ * Calculate integer lag and fractional lag always using 1/4 resolution
+ * In 1st and 3rd subframes the index is relative to last subframe integer lag
+ *
+ * @param[out] lag_int Decoded integer pitch lag
+ * @param[out] lag_frac Decoded fractional pitch lag
+ * @param[in] pitch_index Adaptive codebook pitch index
+ * @param[in,out] base_lag_int Base integer lag used in relative subframes
+ * @param[in] subframe Current subframe index (0 to 3)
+ */
+static void decode_pitch_lag_high(int *lag_int, int *lag_frac, int pitch_index,
+ uint8_t *base_lag_int, int subframe)
+{
+ if (subframe == 0 || subframe == 2) {
+ if (pitch_index < 376) {
+ *lag_int = (pitch_index + 137) >> 2;
+ *lag_frac = pitch_index - (*lag_int << 2) + 136;
+ } else if (pitch_index < 440) {
+ *lag_int = (pitch_index + 257 - 376) >> 1;
+ *lag_frac = (pitch_index - (*lag_int << 1) + 256 - 376) << 1;
+ /* the actual resolution is 1/2 but expressed as 1/4 */
+ } else {
+ *lag_int = pitch_index - 280;
+ *lag_frac = 0;
+ }
+ /* minimum lag for next subframe */
+ *base_lag_int = av_clip(*lag_int - 8 - (*lag_frac < 0),
+ AMRWB_P_DELAY_MIN, AMRWB_P_DELAY_MAX - 15);
+ // XXX: the spec states clearly that *base_lag_int should be
+ // the nearest integer to *lag_int (minus 8), but the ref code
+ // actually always uses its floor, I'm following the latter
+ } else {
+ *lag_int = (pitch_index + 1) >> 2;
+ *lag_frac = pitch_index - (*lag_int << 2);
+ *lag_int += *base_lag_int;
+ }
+}
+
+/**
+ * Decode a adaptive codebook index into pitch lag for 8k85 and 6k60 modes
+ * Description is analogous to decode_pitch_lag_high, but in 6k60 relative
+ * index is used for all subframes except the first
+ */
+static void decode_pitch_lag_low(int *lag_int, int *lag_frac, int pitch_index,
+ uint8_t *base_lag_int, int subframe, enum Mode mode)
+{
+ if (subframe == 0 || (subframe == 2 && mode != MODE_6k60)) {
+ if (pitch_index < 116) {
+ *lag_int = (pitch_index + 69) >> 1;
+ *lag_frac = (pitch_index - (*lag_int << 1) + 68) << 1;
+ } else {
+ *lag_int = pitch_index - 24;
+ *lag_frac = 0;
+ }
+ // XXX: same problem as before
+ *base_lag_int = av_clip(*lag_int - 8 - (*lag_frac < 0),
+ AMRWB_P_DELAY_MIN, AMRWB_P_DELAY_MAX - 15);
+ } else {
+ *lag_int = (pitch_index + 1) >> 1;
+ *lag_frac = (pitch_index - (*lag_int << 1)) << 1;
+ *lag_int += *base_lag_int;
+ }
+}
+
+/**
+ * Find the pitch vector by interpolating the past excitation at the
+ * pitch delay, which is obtained in this function
+ *
+ * @param[in,out] ctx The context
+ * @param[in] amr_subframe Current subframe data
+ * @param[in] subframe Current subframe index (0 to 3)
+ */
+static void decode_pitch_vector(AMRWBContext *ctx,
+ const AMRWBSubFrame *amr_subframe,
+ const int subframe)
+{
+ int pitch_lag_int, pitch_lag_frac;
+ int i;
+ float *exc = ctx->excitation;
+ enum Mode mode = ctx->fr_cur_mode;
+
+ if (mode <= MODE_8k85) {
+ decode_pitch_lag_low(&pitch_lag_int, &pitch_lag_frac, amr_subframe->adap,
+ &ctx->base_pitch_lag, subframe, mode);
+ } else
+ decode_pitch_lag_high(&pitch_lag_int, &pitch_lag_frac, amr_subframe->adap,
+ &ctx->base_pitch_lag, subframe);
+
+ ctx->pitch_lag_int = pitch_lag_int;
+ pitch_lag_int += pitch_lag_frac > 0;
+
+ /* Calculate the pitch vector by interpolating the past excitation at the
+ pitch lag using a hamming windowed sinc function */
+ ff_acelp_interpolatef(exc, exc + 1 - pitch_lag_int,
+ ac_inter, 4,
+ pitch_lag_frac + (pitch_lag_frac > 0 ? 0 : 4),
+ LP_ORDER, AMRWB_SFR_SIZE + 1);
+
+ /* Check which pitch signal path should be used
+ * 6k60 and 8k85 modes have the ltp flag set to 0 */
+ if (amr_subframe->ltp) {
+ memcpy(ctx->pitch_vector, exc, AMRWB_SFR_SIZE * sizeof(float));
+ } else {
+ for (i = 0; i < AMRWB_SFR_SIZE; i++)
+ ctx->pitch_vector[i] = 0.18 * exc[i - 1] + 0.64 * exc[i] +
+ 0.18 * exc[i + 1];
+ memcpy(exc, ctx->pitch_vector, AMRWB_SFR_SIZE * sizeof(float));
+ }
+}
+
+/** Get x bits in the index interval [lsb,lsb+len-1] inclusive */
+#define BIT_STR(x,lsb,len) (((x) >> (lsb)) & ((1 << (len)) - 1))
+
+/** Get the bit at specified position */
+#define BIT_POS(x, p) (((x) >> (p)) & 1)
+
+/**
+ * The next six functions decode_[i]p_track decode exactly i pulses
+ * positions and amplitudes (-1 or 1) in a subframe track using
+ * an encoded pulse indexing (TS 26.190 section 5.8.2)
+ *
+ * The results are given in out[], in which a negative number means
+ * amplitude -1 and vice versa (i.e., ampl(x) = x / abs(x) )
+ *
+ * @param[out] out Output buffer (writes i elements)
+ * @param[in] code Pulse index (no. of bits varies, see below)
+ * @param[in] m (log2) Number of potential positions
+ * @param[in] off Offset for decoded positions
+ */
+static inline void decode_1p_track(int *out, int code, int m, int off)
+{
+ int pos = BIT_STR(code, 0, m) + off; ///code: m+1 bits
+
+ out[0] = BIT_POS(code, m) ? -pos : pos;
+}
+
+static inline void decode_2p_track(int *out, int code, int m, int off) ///code: 2m+1 bits
+{
+ int pos0 = BIT_STR(code, m, m) + off;
+ int pos1 = BIT_STR(code, 0, m) + off;
+
+ out[0] = BIT_POS(code, 2*m) ? -pos0 : pos0;
+ out[1] = BIT_POS(code, 2*m) ? -pos1 : pos1;
+ out[1] = pos0 > pos1 ? -out[1] : out[1];
+}
+
+static void decode_3p_track(int *out, int code, int m, int off) ///code: 3m+1 bits
+{
+ int half_2p = BIT_POS(code, 2*m - 1) << (m - 1);
+
+ decode_2p_track(out, BIT_STR(code, 0, 2*m - 1),
+ m - 1, off + half_2p);
+ decode_1p_track(out + 2, BIT_STR(code, 2*m, m + 1), m, off);
+}
+
+static void decode_4p_track(int *out, int code, int m, int off) ///code: 4m bits
+{
+ int half_4p, subhalf_2p;
+ int b_offset = 1 << (m - 1);
+
+ switch (BIT_STR(code, 4*m - 2, 2)) { /* case ID (2 bits) */
+ case 0: /* 0 pulses in A, 4 pulses in B or vice versa */
+ half_4p = BIT_POS(code, 4*m - 3) << (m - 1); // which has 4 pulses
+ subhalf_2p = BIT_POS(code, 2*m - 3) << (m - 2);
+
+ decode_2p_track(out, BIT_STR(code, 0, 2*m - 3),
+ m - 2, off + half_4p + subhalf_2p);
+ decode_2p_track(out + 2, BIT_STR(code, 2*m - 2, 2*m - 1),
+ m - 1, off + half_4p);
+ break;
+ case 1: /* 1 pulse in A, 3 pulses in B */
+ decode_1p_track(out, BIT_STR(code, 3*m - 2, m),
+ m - 1, off);
+ decode_3p_track(out + 1, BIT_STR(code, 0, 3*m - 2),
+ m - 1, off + b_offset);
+ break;
+ case 2: /* 2 pulses in each half */
+ decode_2p_track(out, BIT_STR(code, 2*m - 1, 2*m - 1),
+ m - 1, off);
+ decode_2p_track(out + 2, BIT_STR(code, 0, 2*m - 1),
+ m - 1, off + b_offset);
+ break;
+ case 3: /* 3 pulses in A, 1 pulse in B */
+ decode_3p_track(out, BIT_STR(code, m, 3*m - 2),
+ m - 1, off);
+ decode_1p_track(out + 3, BIT_STR(code, 0, m),
+ m - 1, off + b_offset);
+ break;
+ }
+}
+
+static void decode_5p_track(int *out, int code, int m, int off) ///code: 5m bits
+{
+ int half_3p = BIT_POS(code, 5*m - 1) << (m - 1);
+
+ decode_3p_track(out, BIT_STR(code, 2*m + 1, 3*m - 2),
+ m - 1, off + half_3p);
+
+ decode_2p_track(out + 3, BIT_STR(code, 0, 2*m + 1), m, off);
+}
+
+static void decode_6p_track(int *out, int code, int m, int off) ///code: 6m-2 bits
+{
+ int b_offset = 1 << (m - 1);
+ /* which half has more pulses in cases 0 to 2 */
+ int half_more = BIT_POS(code, 6*m - 5) << (m - 1);
+ int half_other = b_offset - half_more;
+
+ switch (BIT_STR(code, 6*m - 4, 2)) { /* case ID (2 bits) */
+ case 0: /* 0 pulses in A, 6 pulses in B or vice versa */
+ decode_1p_track(out, BIT_STR(code, 0, m),
+ m - 1, off + half_more);
+ decode_5p_track(out + 1, BIT_STR(code, m, 5*m - 5),
+ m - 1, off + half_more);
+ break;
+ case 1: /* 1 pulse in A, 5 pulses in B or vice versa */
+ decode_1p_track(out, BIT_STR(code, 0, m),
+ m - 1, off + half_other);
+ decode_5p_track(out + 1, BIT_STR(code, m, 5*m - 5),
+ m - 1, off + half_more);
+ break;
+ case 2: /* 2 pulses in A, 4 pulses in B or vice versa */
+ decode_2p_track(out, BIT_STR(code, 0, 2*m - 1),
+ m - 1, off + half_other);
+ decode_4p_track(out + 2, BIT_STR(code, 2*m - 1, 4*m - 4),
+ m - 1, off + half_more);
+ break;
+ case 3: /* 3 pulses in A, 3 pulses in B */
+ decode_3p_track(out, BIT_STR(code, 3*m - 2, 3*m - 2),
+ m - 1, off);
+ decode_3p_track(out + 3, BIT_STR(code, 0, 3*m - 2),
+ m - 1, off + b_offset);
+ break;
+ }
+}
+
+/**
+ * Decode the algebraic codebook index to pulse positions and signs,
+ * then construct the algebraic codebook vector
+ *
+ * @param[out] fixed_vector Buffer for the fixed codebook excitation
+ * @param[in] pulse_hi MSBs part of the pulse index array (higher modes only)
+ * @param[in] pulse_lo LSBs part of the pulse index array
+ * @param[in] mode Mode of the current frame
+ */
+static void decode_fixed_vector(float *fixed_vector, const uint16_t *pulse_hi,
+ const uint16_t *pulse_lo, const enum Mode mode)
+{
+ /* sig_pos stores for each track the decoded pulse position indexes
+ * (1-based) multiplied by its corresponding amplitude (+1 or -1) */
+ int sig_pos[4][6];
+ int spacing = (mode == MODE_6k60) ? 2 : 4;
+ int i, j;
+
+ switch (mode) {
+ case MODE_6k60:
+ for (i = 0; i < 2; i++)
+ decode_1p_track(sig_pos[i], pulse_lo[i], 5, 1);
+ break;
+ case MODE_8k85:
+ for (i = 0; i < 4; i++)
+ decode_1p_track(sig_pos[i], pulse_lo[i], 4, 1);
+ break;
+ case MODE_12k65:
+ for (i = 0; i < 4; i++)
+ decode_2p_track(sig_pos[i], pulse_lo[i], 4, 1);
+ break;
+ case MODE_14k25:
+ for (i = 0; i < 2; i++)
+ decode_3p_track(sig_pos[i], pulse_lo[i], 4, 1);
+ for (i = 2; i < 4; i++)
+ decode_2p_track(sig_pos[i], pulse_lo[i], 4, 1);
+ break;
+ case MODE_15k85:
+ for (i = 0; i < 4; i++)
+ decode_3p_track(sig_pos[i], pulse_lo[i], 4, 1);
+ break;
+ case MODE_18k25:
+ for (i = 0; i < 4; i++)
+ decode_4p_track(sig_pos[i], (int) pulse_lo[i] +
+ ((int) pulse_hi[i] << 14), 4, 1);
+ break;
+ case MODE_19k85:
+ for (i = 0; i < 2; i++)
+ decode_5p_track(sig_pos[i], (int) pulse_lo[i] +
+ ((int) pulse_hi[i] << 10), 4, 1);
+ for (i = 2; i < 4; i++)
+ decode_4p_track(sig_pos[i], (int) pulse_lo[i] +
+ ((int) pulse_hi[i] << 14), 4, 1);
+ break;
+ case MODE_23k05:
+ case MODE_23k85:
+ for (i = 0; i < 4; i++)
+ decode_6p_track(sig_pos[i], (int) pulse_lo[i] +
+ ((int) pulse_hi[i] << 11), 4, 1);
+ break;
+ }
+
+ memset(fixed_vector, 0, sizeof(float) * AMRWB_SFR_SIZE);
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < pulses_nb_per_mode_tr[mode][i]; j++) {
+ int pos = (FFABS(sig_pos[i][j]) - 1) * spacing + i;
+
+ fixed_vector[pos] += sig_pos[i][j] < 0 ? -1.0 : 1.0;
+ }
+}
+
+/**
+ * Decode pitch gain and fixed gain correction factor
+ *
+ * @param[in] vq_gain Vector-quantized index for gains
+ * @param[in] mode Mode of the current frame
+ * @param[out] fixed_gain_factor Decoded fixed gain correction factor
+ * @param[out] pitch_gain Decoded pitch gain
+ */
+static void decode_gains(const uint8_t vq_gain, const enum Mode mode,
+ float *fixed_gain_factor, float *pitch_gain)
+{
+ const int16_t *gains = (mode <= MODE_8k85 ? qua_gain_6b[vq_gain] :
+ qua_gain_7b[vq_gain]);
+
+ *pitch_gain = gains[0] * (1.0f / (1 << 14));
+ *fixed_gain_factor = gains[1] * (1.0f / (1 << 11));
+}
+
+/**
+ * Apply pitch sharpening filters to the fixed codebook vector
+ *
+ * @param[in] ctx The context
+ * @param[in,out] fixed_vector Fixed codebook excitation
+ */
+// XXX: Spec states this procedure should be applied when the pitch
+// lag is less than 64, but this checking seems absent in reference and AMR-NB
+static void pitch_sharpening(AMRWBContext *ctx, float *fixed_vector)
+{
+ int i;
+
+ /* Tilt part */
+ for (i = AMRWB_SFR_SIZE - 1; i != 0; i--)
+ fixed_vector[i] -= fixed_vector[i - 1] * ctx->tilt_coef;
+
+ /* Periodicity enhancement part */
+ for (i = ctx->pitch_lag_int; i < AMRWB_SFR_SIZE; i++)
+ fixed_vector[i] += fixed_vector[i - ctx->pitch_lag_int] * 0.85;
+}
+
+/**
+ * Calculate the voicing factor (-1.0 = unvoiced to 1.0 = voiced)
+ *
+ * @param[in] p_vector, f_vector Pitch and fixed excitation vectors
+ * @param[in] p_gain, f_gain Pitch and fixed gains
+ */
+// XXX: There is something wrong with the precision here! The magnitudes
+// of the energies are not correct. Please check the reference code carefully
+static float voice_factor(float *p_vector, float p_gain,
+ float *f_vector, float f_gain)
+{
+ double p_ener = (double) ff_dot_productf(p_vector, p_vector,
+ AMRWB_SFR_SIZE) * p_gain * p_gain;
+ double f_ener = (double) ff_dot_productf(f_vector, f_vector,
+ AMRWB_SFR_SIZE) * f_gain * f_gain;
+
+ return (p_ener - f_ener) / (p_ener + f_ener);
+}
+
+/**
+ * Reduce fixed vector sparseness by smoothing with one of three IR filters
+ * Also known as "adaptive phase dispersion"
+ *
+ * @param[in] ctx The context
+ * @param[in,out] fixed_vector Unfiltered fixed vector
+ * @param[out] buf Space for modified vector if necessary
+ *
+ * @return The potentially overwritten filtered fixed vector address
+ */
+static float *anti_sparseness(AMRWBContext *ctx,
+ float *fixed_vector, float *buf)
+{
+ int ir_filter_nr;
+
+ if (ctx->fr_cur_mode > MODE_8k85) // no filtering in higher modes
+ return fixed_vector;
+
+ if (ctx->pitch_gain[0] < 0.6) {
+ ir_filter_nr = 0; // strong filtering
+ } else if (ctx->pitch_gain[0] < 0.9) {
+ ir_filter_nr = 1; // medium filtering
+ } else
+ ir_filter_nr = 2; // no filtering
+
+ /* detect 'onset' */
+ if (ctx->fixed_gain[0] > 3.0 * ctx->fixed_gain[1]) {
+ if (ir_filter_nr < 2)
+ ir_filter_nr++;
+ } else {
+ int i, count = 0;
+
+ for (i = 0; i < 6; i++)
+ if (ctx->pitch_gain[i] < 0.6)
+ count++;
+
+ if (count > 2)
+ ir_filter_nr = 0;
+
+ if (ir_filter_nr > ctx->prev_ir_filter_nr + 1)
+ ir_filter_nr--;
+ }
+
+ /* update ir filter strength history */
+ ctx->prev_ir_filter_nr = ir_filter_nr;
+
+ ir_filter_nr += (ctx->fr_cur_mode == MODE_8k85);
+
+ if (ir_filter_nr < 2) {
+ int i;
+ const float *coef = ir_filters_lookup[ir_filter_nr];
+
+ /* Circular convolution code in the reference
+ * decoder was modified to avoid using one
+ * extra array. The filtered vector is given by:
+ *
+ * c2(n) = sum(i,0,len-1){ c(i) * coef( (n - i + len) % len ) }
+ */
+
+ memset(buf, 0, sizeof(float) * AMRWB_SFR_SIZE);
+ for (i = 0; i < AMRWB_SFR_SIZE; i++)
+ if (fixed_vector[i])
+ ff_celp_circ_addf(buf, buf, coef, i, fixed_vector[i],
+ AMRWB_SFR_SIZE);
+ fixed_vector = buf;
+ }
+
+ return fixed_vector;
+}
+
+/**
+ * Calculate a stability factor {teta} based on distance between
+ * current and past isf. A value of 1 shows maximum signal stability
+ */
+static float stability_factor(const float *isf, const float *isf_past)
+{
+ int i;
+ float acc = 0.0;
+
+ for (i = 0; i < LP_ORDER - 1; i++)
+ acc += (isf[i] - isf_past[i]) * (isf[i] - isf_past[i]);
+
+ // XXX: This part is not so clear from the reference code
+ // the result is more accurate changing the "/ 256" to "* 512"
+ return FFMAX(0.0, 1.25 - acc * 0.8 * 512);
+}
+
+/**
+ * Apply a non-linear fixed gain smoothing in order to reduce
+ * fluctuation in the energy of excitation
+ *
+ * @param[in] fixed_gain Unsmoothed fixed gain
+ * @param[in,out] prev_tr_gain Previous threshold gain (updated)
+ * @param[in] voice_fac Frame voicing factor
+ * @param[in] stab_fac Frame stability factor
+ *
+ * @return The smoothed gain
+ */
+static float noise_enhancer(float fixed_gain, float *prev_tr_gain,
+ float voice_fac, float stab_fac)
+{
+ float sm_fac = 0.5 * (1 - voice_fac) * stab_fac;
+ float g0;
+
+ // XXX: the following fixed-point constants used to in(de)crement
+ // gain by 1.5dB were taken from the reference code, maybe it could
+ // be simpler
+ if (fixed_gain < *prev_tr_gain) {
+ g0 = FFMIN(*prev_tr_gain, fixed_gain + fixed_gain *
+ (6226 * (1.0f / (1 << 15)))); // +1.5 dB
+ } else
+ g0 = FFMAX(*prev_tr_gain, fixed_gain *
+ (27536 * (1.0f / (1 << 15)))); // -1.5 dB
+
+ *prev_tr_gain = g0; // update next frame threshold
+
+ return sm_fac * g0 + (1 - sm_fac) * fixed_gain;
+}
+
+/**
+ * Filter the fixed_vector to emphasize the higher frequencies
+ *
+ * @param[in,out] fixed_vector Fixed codebook vector
+ * @param[in] voice_fac Frame voicing factor
+ */
+static void pitch_enhancer(float *fixed_vector, float voice_fac)
+{
+ int i;
+ float cpe = 0.125 * (1 + voice_fac);
+ float last = fixed_vector[0]; // holds c(i - 1)
+
+ fixed_vector[0] -= cpe * fixed_vector[1];
+
+ for (i = 1; i < AMRWB_SFR_SIZE - 1; i++) {
+ float cur = fixed_vector[i];
+
+ fixed_vector[i] -= cpe * (last + fixed_vector[i + 1]);
+ last = cur;
+ }
+
+ fixed_vector[AMRWB_SFR_SIZE - 1] -= cpe * last;
+}
+
+/**
+ * Conduct 16th order linear predictive coding synthesis from excitation
+ *
+ * @param[in] ctx Pointer to the AMRWBContext
+ * @param[in] lpc Pointer to the LPC coefficients
+ * @param[out] excitation Buffer for synthesis final excitation
+ * @param[in] fixed_gain Fixed codebook gain for synthesis
+ * @param[in] fixed_vector Algebraic codebook vector
+ * @param[in,out] samples Pointer to the output samples and memory
+ */
+static void synthesis(AMRWBContext *ctx, float *lpc, float *excitation,
+ float fixed_gain, const float *fixed_vector,
+ float *samples)
+{
+ ff_weighted_vector_sumf(excitation, ctx->pitch_vector, fixed_vector,
+ ctx->pitch_gain[0], fixed_gain, AMRWB_SFR_SIZE);
+
+ /* emphasize pitch vector contribution in low bitrate modes */
+ if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) {
+ int i;
+ float energy = ff_dot_productf(excitation, excitation,
+ AMRWB_SFR_SIZE);
+
+ // XXX: Weird part in both ref code and spec. A unknown parameter
+ // {beta} seems to be identical to the current pitch gain
+ float pitch_factor = 0.25 * ctx->pitch_gain[0] * ctx->pitch_gain[0];
+
+ for (i = 0; i < AMRWB_SFR_SIZE; i++)
+ excitation[i] += pitch_factor * ctx->pitch_vector[i];
+
+ ff_scale_vector_to_given_sum_of_squares(excitation, excitation,
+ energy, AMRWB_SFR_SIZE);
+ }
+
+ ff_celp_lp_synthesis_filterf(samples, lpc, excitation,
+ AMRWB_SFR_SIZE, LP_ORDER);
+}
+
+/**
+ * Apply to synthesis a de-emphasis filter of the form:
+ * H(z) = 1 / (1 - m * z^-1)
+ *
+ * @param[out] out Output buffer
+ * @param[in] in Input samples array with in[-1]
+ * @param[in] m Filter coefficient
+ * @param[in,out] mem State from last filtering
+ */
+static void de_emphasis(float *out, float *in, float m, float mem[1])
+{
+ int i;
+
+ out[0] = in[0] + m * mem[0];
+
+ for (i = 1; i < AMRWB_SFR_SIZE; i++)
+ out[i] = in[i] + out[i - 1] * m;
+
+ mem[0] = out[AMRWB_SFR_SIZE - 1];
+}
+
+/**
+ * Upsample a signal by 5/4 ratio (from 12.8kHz to 16kHz) using
+ * a FIR interpolation filter. Uses past data from before *in address
+ *
+ * @param[out] out Buffer for interpolated signal
+ * @param[in] in Current signal data (length 0.8*o_size)
+ * @param[in] o_size Output signal length
+ */
+static void upsample_5_4(float *out, const float *in, int o_size)
+{
+ const float *in0 = in - UPS_FIR_SIZE + 1;
+ int i, j, k;
+ int int_part = 0, frac_part;
+
+ i = 0;
+ for (j = 0; j < o_size / 5; j++) {
+ out[i] = in[int_part];
+ frac_part = 4;
+ i++;
+
+ for (k = 1; k < 5; k++) {
+ out[i] = ff_dot_productf(in0 + int_part, upsample_fir[4 - frac_part],
+ UPS_MEM_SIZE);
+ int_part++;
+ frac_part--;
+ i++;
+ }
+ }
+}
+
+/**
+ * Calculate the high-band gain based on encoded index (23k85 mode) or
+ * on the low-band speech signal and the Voice Activity Detection flag
+ *
+ * @param[in] ctx The context
+ * @param[in] synth LB speech synthesis at 12.8k
+ * @param[in] hb_idx Gain index for mode 23k85 only
+ * @param[in] vad VAD flag for the frame
+ */
+static float find_hb_gain(AMRWBContext *ctx, const float *synth,
+ uint16_t hb_idx, uint8_t vad)
+{
+ int wsp = (vad > 0);
+ float tilt;
+
+ if (ctx->fr_cur_mode == MODE_23k85)
+ return qua_hb_gain[hb_idx] * (1.0f / (1 << 14));
+
+ tilt = ff_dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1) /
+ ff_dot_productf(synth, synth, AMRWB_SFR_SIZE);
+
+ /* return gain bounded by [0.1, 1.0] */
+ return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0);
+}
+
+/**
+ * Generate the high-band excitation with the same energy from the lower
+ * one and scaled by the given gain
+ *
+ * @param[in] ctx The context
+ * @param[out] hb_exc Buffer for the excitation
+ * @param[in] synth_exc Low-band excitation used for synthesis
+ * @param[in] hb_gain Wanted excitation gain
+ */
+static void scaled_hb_excitation(AMRWBContext *ctx, float *hb_exc,
+ const float *synth_exc, float hb_gain)
+{
+ int i;
+ float energy = ff_dot_productf(synth_exc, synth_exc, AMRWB_SFR_SIZE);
+
+ /* Generate a white-noise excitation */
+ for (i = 0; i < AMRWB_SFR_SIZE_16k; i++)
+ hb_exc[i] = 32768.0 - (uint16_t) av_lfg_get(&ctx->prng);
+
+ ff_scale_vector_to_given_sum_of_squares(hb_exc, hb_exc,
+ energy * hb_gain * hb_gain,
+ AMRWB_SFR_SIZE_16k);
+}
+
+/**
+ * Calculate the auto-correlation for the ISF difference vector
+ */
+static float auto_correlation(float *diff_isf, float mean, int lag)
+{
+ int i;
+ float sum = 0.0;
+
+ for (i = 7; i < LP_ORDER - 2; i++) {
+ float prod = (diff_isf[i] - mean) * (diff_isf[i - lag] - mean);
+ sum += prod * prod;
+ }
+ return sum;
+}
+
+/**
+ * Extrapolate a ISF vector to the 16kHz range (20th order LP)
+ * used at mode 6k60 LP filter for the high frequency band
+ *
+ * @param[out] out Buffer for extrapolated isf
+ * @param[in] isf Input isf vector
+ */
+static void extrapolate_isf(float out[LP_ORDER_16k], float isf[LP_ORDER])
+{
+ float diff_isf[LP_ORDER - 2], diff_mean;
+ float *diff_hi = diff_isf - LP_ORDER + 1; // diff array for extrapolated indexes
+ float corr_lag[3];
+ float est, scale;
+ int i, i_max_corr;
+
+ memcpy(out, isf, (LP_ORDER - 1) * sizeof(float));
+ out[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
+
+ /* Calculate the difference vector */
+ for (i = 0; i < LP_ORDER - 2; i++)
+ diff_isf[i] = isf[i + 1] - isf[i];
+
+ diff_mean = 0.0;
+ for (i = 2; i < LP_ORDER - 2; i++)
+ diff_mean += diff_isf[i] * (1.0f / (LP_ORDER - 4));
+
+ /* Find which is the maximum autocorrelation */
+ i_max_corr = 0;
+ for (i = 0; i < 3; i++) {
+ corr_lag[i] = auto_correlation(diff_isf, diff_mean, i + 2);
+
+ if (corr_lag[i] > corr_lag[i_max_corr])
+ i_max_corr = i;
+ }
+ i_max_corr++;
+
+ for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
+ out[i] = isf[i - 1] + isf[i - 1 - i_max_corr]
+ - isf[i - 2 - i_max_corr];
+
+ /* Calculate an estimate for ISF(18) and scale ISF based on the error */
+ est = 7965 + (out[2] - out[3] - out[4]) / 6.0;
+ scale = 0.5 * (FFMIN(est, 7600) - out[LP_ORDER - 2]) /
+ (out[LP_ORDER_16k - 2] - out[LP_ORDER - 2]);
+
+ for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
+ diff_hi[i] = scale * (out[i] - out[i - 1]);
+
+ /* Stability insurance */
+ for (i = LP_ORDER; i < LP_ORDER_16k - 1; i++)
+ if (diff_hi[i] + diff_hi[i - 1] < 5.0) {
+ if (diff_hi[i] > diff_hi[i - 1]) {
+ diff_hi[i - 1] = 5.0 - diff_hi[i];
+ } else
+ diff_hi[i] = 5.0 - diff_hi[i - 1];
+ }
+
+ for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
+ out[i] = out[i - 1] + diff_hi[i] * (1.0f / (1 << 15));
+
+ /* Scale the ISF vector for 16000 Hz */
+ for (i = 0; i < LP_ORDER_16k - 1; i++)
+ out[i] *= 0.8;
+}
+
+/**
+ * Spectral expand the LP coefficients using the equation:
+ * y[i] = x[i] * (gamma ** i)
+ *
+ * @param[out] out Output buffer (may use input array)
+ * @param[in] lpc LP coefficients array
+ * @param[in] gamma Weighting factor
+ * @param[in] size LP array size
+ */
+static void lpc_weighting(float *out, const float *lpc, float gamma, int size)
+{
+ int i;
+ float fac = gamma;
+
+ for (i = 0; i < size; i++) {
+ out[i] = lpc[i] * fac;
+ fac *= gamma;
+ }
+}
+
+/**
+ * Conduct 20th order linear predictive coding synthesis for the high
+ * frequency band excitation at 16kHz
+ *
+ * @param[in] ctx The context
+ * @param[in] subframe Current subframe index (0 to 3)
+ * @param[in,out] samples Pointer to the output speech samples
+ * @param[in] exc Generated white-noise scaled excitation
+ * @param[in] isf Current frame isf vector
+ * @param[in] isf_past Past frame final isf vector
+ */
+static void hb_synthesis(AMRWBContext *ctx, int subframe, float *samples,
+ const float *exc, const float *isf, const float *isf_past)
+{
+ float hb_lpc[LP_ORDER_16k];
+ enum Mode mode = ctx->fr_cur_mode;
+
+ if (mode == MODE_6k60) {
+ float e_isf[LP_ORDER_16k]; // ISF vector for extrapolation
+ double e_isp[LP_ORDER_16k];
+
+ ff_weighted_vector_sumf(e_isf, isf_past, isf, isfp_inter[subframe],
+ 1.0 - isfp_inter[subframe], LP_ORDER);
+
+ extrapolate_isf(e_isf, e_isf);
+
+ e_isf[LP_ORDER_16k - 1] *= 2.0;
+ ff_acelp_lsf2lspd(e_isp, e_isf, LP_ORDER_16k);
+ ff_amrwb_lsp2lpc(e_isp, hb_lpc, LP_ORDER_16k);
+
+ lpc_weighting(hb_lpc, hb_lpc, 0.9, LP_ORDER_16k);
+ } else {
+ lpc_weighting(hb_lpc, ctx->lp_coef[subframe], 0.6, LP_ORDER);
+ }
+
+ ff_celp_lp_synthesis_filterf(samples, hb_lpc, exc, AMRWB_SFR_SIZE_16k,
+ (mode == MODE_6k60) ? LP_ORDER_16k : LP_ORDER);
+}
+
+/**
+ * Apply to high-band samples a 15th order filter
+ * The filter characteristic depends on the given coefficients
+ *
+ * @param[out] out Buffer for filtered output
+ * @param[in] fir_coef Filter coefficients
+ * @param[in,out] mem State from last filtering (updated)
+ * @param[in] in Input speech data (high-band)
+ *
+ * @remark It is safe to pass the same array in in and out parameters
+ */
+static void hb_fir_filter(float *out, const float fir_coef[HB_FIR_SIZE + 1],
+ float mem[HB_FIR_SIZE], const float *in)
+{
+ int i, j;
+ float data[AMRWB_SFR_SIZE_16k + HB_FIR_SIZE]; // past and current samples
+
+ memcpy(data, mem, HB_FIR_SIZE * sizeof(float));
+ memcpy(data + HB_FIR_SIZE, in, AMRWB_SFR_SIZE_16k * sizeof(float));
+
+ for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) {
+ out[i] = 0.0;
+ for (j = 0; j <= HB_FIR_SIZE; j++)
+ out[i] += data[i + j] * fir_coef[j];
+ }
+
+ memcpy(mem, data + AMRWB_SFR_SIZE_16k, HB_FIR_SIZE * sizeof(float));
+}
+
+/**
+ * Update context state before the next subframe
+ */
+static void update_sub_state(AMRWBContext *ctx)
+{
+ memmove(&ctx->excitation_buf[0], &ctx->excitation_buf[AMRWB_SFR_SIZE],
+ (AMRWB_P_DELAY_MAX + LP_ORDER + 1) * sizeof(float));
+
+ memmove(&ctx->pitch_gain[1], &ctx->pitch_gain[0], 5 * sizeof(float));
+ memmove(&ctx->fixed_gain[1], &ctx->fixed_gain[0], 1 * sizeof(float));
+
+ memmove(&ctx->samples_az[0], &ctx->samples_az[AMRWB_SFR_SIZE],
+ LP_ORDER * sizeof(float));
+ memmove(&ctx->samples_up[0], &ctx->samples_up[AMRWB_SFR_SIZE],
+ UPS_MEM_SIZE * sizeof(float));
+ memmove(&ctx->samples_hb[0], &ctx->samples_hb[AMRWB_SFR_SIZE_16k],
+ LP_ORDER_16k * sizeof(float));
+}
+
+static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ AMRWBContext *ctx = avctx->priv_data;
+ AMRWBFrame *cf = &ctx->frame;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ int expected_fr_size, header_size;
+ float *buf_out = data;
+ float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing
+ float fixed_gain_factor; // fixed gain correction factor (gamma)
+ float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use
+ float synth_fixed_gain; // the fixed gain that synthesis should use
+ float voice_fac, stab_fac; // parameters used for gain smoothing
+ float synth_exc[AMRWB_SFR_SIZE]; // post-processed excitation for synthesis
+ float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band
+ float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis
+ float hb_gain;
+ int sub, i;
+
+ header_size = decode_mime_header(ctx, buf);
+ expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
+
+ if (buf_size < expected_fr_size) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Frame too small (%d bytes). Truncated file?\n", buf_size);
+ *data_size = 0;
+ return buf_size;
+ }
+
+ if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID)
+ av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n");
+
+ if (ctx->fr_cur_mode == MODE_SID) /* Comfort noise frame */
+ av_log_missing_feature(avctx, "SID mode", 1);
+
+ if (ctx->fr_cur_mode >= MODE_SID)
+ return -1;
+
+ ff_amr_bit_reorder((uint16_t *) &ctx->frame, sizeof(AMRWBFrame),
+ buf + header_size, amr_bit_orderings_by_mode[ctx->fr_cur_mode]);
+
+ /* Decode the quantized ISF vector */
+ if (ctx->fr_cur_mode == MODE_6k60) {
+ decode_isf_indices_36b(cf->isp_id, ctx->isf_cur);
+ } else {
+ decode_isf_indices_46b(cf->isp_id, ctx->isf_cur);
+ }
+
+ isf_add_mean_and_past(ctx->isf_cur, ctx->isf_q_past);
+ ff_set_min_dist_lsf(ctx->isf_cur, MIN_ISF_SPACING, LP_ORDER - 1);
+
+ stab_fac = stability_factor(ctx->isf_cur, ctx->isf_past_final);
+
+ ctx->isf_cur[LP_ORDER - 1] *= 2.0;
+ ff_acelp_lsf2lspd(ctx->isp[3], ctx->isf_cur, LP_ORDER);
+
+ /* Generate a ISP vector for each subframe */
+ if (ctx->first_frame) {
+ ctx->first_frame = 0;
+ memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(double));
+ }
+ interpolate_isp(ctx->isp, ctx->isp_sub4_past);
+
+ for (sub = 0; sub < 4; sub++)
+ ff_amrwb_lsp2lpc(ctx->isp[sub], ctx->lp_coef[sub], LP_ORDER);
+
+ for (sub = 0; sub < 4; sub++) {
+ const AMRWBSubFrame *cur_subframe = &cf->subframe[sub];
+ float *sub_buf = buf_out + sub * AMRWB_SFR_SIZE_16k;
+
+ /* Decode adaptive codebook (pitch vector) */
+ decode_pitch_vector(ctx, cur_subframe, sub);
+ /* Decode innovative codebook (fixed vector) */
+ decode_fixed_vector(ctx->fixed_vector, cur_subframe->pul_ih,
+ cur_subframe->pul_il, ctx->fr_cur_mode);
+
+ pitch_sharpening(ctx, ctx->fixed_vector);
+
+ decode_gains(cur_subframe->vq_gain, ctx->fr_cur_mode,
+ &fixed_gain_factor, &ctx->pitch_gain[0]);
+
+ ctx->fixed_gain[0] =
+ ff_amr_set_fixed_gain(fixed_gain_factor,
+ ff_dot_productf(ctx->fixed_vector, ctx->fixed_vector,
+ AMRWB_SFR_SIZE) / AMRWB_SFR_SIZE,
+ ctx->prediction_error,
+ ENERGY_MEAN, energy_pred_fac);
+
+ /* Calculate voice factor and store tilt for next subframe */
+ voice_fac = voice_factor(ctx->pitch_vector, ctx->pitch_gain[0],
+ ctx->fixed_vector, ctx->fixed_gain[0]);
+ ctx->tilt_coef = voice_fac * 0.25 + 0.25;
+
+ /* Construct current excitation */
+ for (i = 0; i < AMRWB_SFR_SIZE; i++) {
+ ctx->excitation[i] *= ctx->pitch_gain[0];
+ ctx->excitation[i] += ctx->fixed_gain[0] * ctx->fixed_vector[i];
+ ctx->excitation[i] = truncf(ctx->excitation[i]);
+ }
+
+ /* Post-processing of excitation elements */
+ synth_fixed_gain = noise_enhancer(ctx->fixed_gain[0], &ctx->prev_tr_gain,
+ voice_fac, stab_fac);
+
+ synth_fixed_vector = anti_sparseness(ctx, ctx->fixed_vector,
+ spare_vector);
+
+ pitch_enhancer(synth_fixed_vector, voice_fac);
+
+ synthesis(ctx, ctx->lp_coef[sub], synth_exc, synth_fixed_gain,
+ synth_fixed_vector, &ctx->samples_az[LP_ORDER]);
+
+ /* Synthesis speech post-processing */
+ de_emphasis(&ctx->samples_up[UPS_MEM_SIZE],
+ &ctx->samples_az[LP_ORDER], PREEMPH_FAC, ctx->demph_mem);
+
+ ff_acelp_apply_order_2_transfer_function(&ctx->samples_up[UPS_MEM_SIZE],
+ &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_31_poles,
+ hpf_31_gain, ctx->hpf_31_mem, AMRWB_SFR_SIZE);
+
+ upsample_5_4(sub_buf, &ctx->samples_up[UPS_FIR_SIZE],
+ AMRWB_SFR_SIZE_16k);
+
+ /* High frequency band (6.4 - 7.0 kHz) generation part */
+ ff_acelp_apply_order_2_transfer_function(hb_samples,
+ &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_400_poles,
+ hpf_400_gain, ctx->hpf_400_mem, AMRWB_SFR_SIZE);
+
+ hb_gain = find_hb_gain(ctx, hb_samples,
+ cur_subframe->hb_gain, cf->vad);
+
+ scaled_hb_excitation(ctx, hb_exc, synth_exc, hb_gain);
+
+ hb_synthesis(ctx, sub, &ctx->samples_hb[LP_ORDER_16k],
+ hb_exc, ctx->isf_cur, ctx->isf_past_final);
+
+ /* High-band post-processing filters */
+ hb_fir_filter(hb_samples, bpf_6_7_coef, ctx->bpf_6_7_mem,
+ &ctx->samples_hb[LP_ORDER_16k]);
+
+ if (ctx->fr_cur_mode == MODE_23k85)
+ hb_fir_filter(hb_samples, lpf_7_coef, ctx->lpf_7_mem,
+ hb_samples);
+
+ /* Add the low and high frequency bands */
+ for (i = 0; i < AMRWB_SFR_SIZE_16k; i++)
+ sub_buf[i] = (sub_buf[i] + hb_samples[i]) * (1.0f / (1 << 15));
+
+ /* Update buffers and history */
+ update_sub_state(ctx);
+ }
+
+ /* update state for next frame */
+ memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
+ memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
+
+ /* report how many samples we got */
+ *data_size = 4 * AMRWB_SFR_SIZE_16k * sizeof(float);
+
+ return expected_fr_size;
+}
+
+AVCodec ff_amrwb_decoder = {
+ .name = "amrwb",
+ .type = CODEC_TYPE_AUDIO,
+ .id = CODEC_ID_AMR_WB,
+ .priv_data_size = sizeof(AMRWBContext),
+ .init = amrwb_decode_init,
+ .decode = amrwb_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"),
+ .sample_fmts = (enum AVSampleFormat[]){SAMPLE_FMT_FLT,SAMPLE_FMT_NONE},
+};
diff --git a/lib/ffmpeg/libavcodec/anm.c b/lib/ffmpeg/libavcodec/anm.c
index f38486188c..5b2b9df8ea 100644
--- a/lib/ffmpeg/libavcodec/anm.c
+++ b/lib/ffmpeg/libavcodec/anm.c
@@ -183,7 +183,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec anm_decoder = {
+AVCodec ff_anm_decoder = {
"anm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ANM,
diff --git a/lib/ffmpeg/libavcodec/ansi.c b/lib/ffmpeg/libavcodec/ansi.c
new file mode 100644
index 0000000000..9d6dc9d3d2
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ansi.c
@@ -0,0 +1,435 @@
+/*
+ * ASCII/ANSI art decoder
+ * Copyright (c) 2010 Peter Ross <pross@xvid.org>
+ *
+ * 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
+ * ASCII/ANSI art decoder
+ */
+
+#include "libavutil/lfg.h"
+#include "avcodec.h"
+#include "cga_data.h"
+
+#define ATTR_BOLD 0x01 /**< Bold/Bright-foreground (mode 1) */
+#define ATTR_FAINT 0x02 /**< Faint (mode 2) */
+#define ATTR_UNDERLINE 0x08 /**< Underline (mode 4) */
+#define ATTR_BLINK 0x10 /**< Blink/Bright-background (mode 5) */
+#define ATTR_REVERSE 0x40 /**< Reverse (mode 7) */
+#define ATTR_CONCEALED 0x80 /**< Concealed (mode 8) */
+
+#define DEFAULT_FG_COLOR 7 /**< CGA color index */
+#define DEFAULT_BG_COLOR 0
+#define DEFAULT_SCREEN_MODE 3 /**< 80x25 */
+
+#define FONT_WIDTH 8 /**< Font width */
+
+/** map ansi color index to cga palette index */
+static const uint8_t ansi_to_cga[16] = {
+ 0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15
+};
+
+typedef struct {
+ AVFrame frame;
+ int x; /**< x cursor position (pixels) */
+ int y; /**< y cursor position (pixels) */
+ int sx; /**< saved x cursor position (pixels) */
+ int sy; /**< saved y cursor position (pixels) */
+ const uint8_t* font; /**< font */
+ int font_height; /**< font height */
+ int attributes; /**< attribute flags */
+ int fg; /**< foreground color */
+ int bg; /**< background color */
+
+ /* ansi parser state machine */
+ enum {
+ STATE_NORMAL = 0,
+ STATE_ESCAPE,
+ STATE_CODE,
+ STATE_MUSIC_PREAMBLE
+ } state;
+#define MAX_NB_ARGS 4
+ int args[MAX_NB_ARGS];
+ int nb_args; /**< number of arguments (may exceed MAX_NB_ARGS) */
+} AnsiContext;
+
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+ AnsiContext *s = avctx->priv_data;
+ avctx->pix_fmt = PIX_FMT_PAL8;
+
+ /* defaults */
+ s->font = ff_vga16_font;
+ s->font_height = 16;
+ s->fg = DEFAULT_FG_COLOR;
+ s->bg = DEFAULT_BG_COLOR;
+
+ if (!avctx->width || !avctx->height)
+ avcodec_set_dimensions(avctx, 80<<3, 25<<4);
+
+ return 0;
+}
+
+static void hscroll(AVCodecContext *avctx)
+{
+ AnsiContext *s = avctx->priv_data;
+ int i;
+
+ if (s->y < avctx->height - s->font_height) {
+ s->y += s->font_height;
+ return;
+ }
+
+ i = 0;
+ for (; i < avctx->height - s->font_height; i++)
+ memcpy(s->frame.data[0] + i * s->frame.linesize[0],
+ s->frame.data[0] + (i + s->font_height) * s->frame.linesize[0],
+ avctx->width);
+ for (; i < avctx->height; i++)
+ memset(s->frame.data[0] + i * s->frame.linesize[0],
+ DEFAULT_BG_COLOR, avctx->width);
+}
+
+static void erase_line(AVCodecContext * avctx, int xoffset, int xlength)
+{
+ AnsiContext *s = avctx->priv_data;
+ int i;
+ for (i = 0; i < s->font_height; i++)
+ memset(s->frame.data[0] + (s->y + i)*s->frame.linesize[0] + xoffset,
+ DEFAULT_BG_COLOR, xlength);
+}
+
+static void erase_screen(AVCodecContext *avctx)
+{
+ AnsiContext *s = avctx->priv_data;
+ int i;
+ for (i = 0; i < avctx->height; i++)
+ memset(s->frame.data[0] + i * s->frame.linesize[0], DEFAULT_BG_COLOR, avctx->width);
+ s->x = s->y = 0;
+}
+
+/**
+ * Draw character to screen
+ */
+static void draw_char(AVCodecContext *avctx, int c)
+{
+ AnsiContext *s = avctx->priv_data;
+ int fg = s->fg;
+ int bg = s->bg;
+
+ if ((s->attributes & ATTR_BOLD))
+ fg += 8;
+ if ((s->attributes & ATTR_BLINK))
+ bg += 8;
+ if ((s->attributes & ATTR_REVERSE))
+ FFSWAP(int, fg, bg);
+ if ((s->attributes & ATTR_CONCEALED))
+ fg = bg;
+ ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
+ s->frame.linesize[0], s->font, s->font_height, c, fg, bg);
+ s->x += FONT_WIDTH;
+ if (s->x >= avctx->width) {
+ s->x = 0;
+ hscroll(avctx);
+ }
+}
+
+/**
+ * Execute ANSI escape code
+ * @param <0 error
+ */
+static int execute_code(AVCodecContext * avctx, int c)
+{
+ AnsiContext *s = avctx->priv_data;
+ int ret, i, width, height;
+ switch(c) {
+ case 'A': //Cursor Up
+ s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
+ break;
+ case 'B': //Cursor Down
+ s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height);
+ break;
+ case 'C': //Cursor Right
+ s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH);
+ break;
+ case 'D': //Cursor Left
+ s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0);
+ break;
+ case 'H': //Cursor Position
+ case 'f': //Horizontal and Vertical Position
+ s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0;
+ s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0;
+ break;
+ case 'h': //set creen mode
+ case 'l': //reset screen mode
+ if (s->nb_args < 2)
+ s->args[0] = DEFAULT_SCREEN_MODE;
+ switch(s->args[0]) {
+ case 0: case 1: case 4: case 5: case 13: case 19: //320x200 (25 rows)
+ s->font = ff_cga_font;
+ s->font_height = 8;
+ width = 40<<3;
+ height = 25<<3;
+ break;
+ case 2: case 3: //640x400 (25 rows)
+ s->font = ff_vga16_font;
+ s->font_height = 16;
+ width = 80<<3;
+ height = 25<<4;
+ break;
+ case 6: case 14: //640x200 (25 rows)
+ s->font = ff_cga_font;
+ s->font_height = 8;
+ width = 80<<3;
+ height = 25<<3;
+ break;
+ case 7: //set line wrapping
+ break;
+ case 15: case 16: //640x350 (43 rows)
+ s->font = ff_cga_font;
+ s->font_height = 8;
+ width = 80<<3;
+ height = 43<<3;
+ break;
+ case 17: case 18: //640x480 (60 rows)
+ s->font = ff_cga_font;
+ s->font_height = 8;
+ width = 80<<3;
+ height = 60<<4;
+ break;
+ default:
+ av_log_ask_for_sample(avctx, "unsupported screen mode\n");
+ }
+ if (width != avctx->width || height != avctx->height) {
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+ avcodec_set_dimensions(avctx, width, height);
+ ret = avctx->get_buffer(avctx, &s->frame);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+ s->frame.pict_type = FF_I_TYPE;
+ s->frame.palette_has_changed = 1;
+ memcpy(s->frame.data[1], ff_cga_palette, 16 * 4);
+ erase_screen(avctx);
+ } else if (c == 'l') {
+ erase_screen(avctx);
+ }
+ break;
+ case 'J': //Erase in Page
+ switch (s->args[0]) {
+ case 0:
+ erase_line(avctx, s->x, avctx->width - s->x);
+ if (s->y < avctx->height - s->font_height)
+ memset(s->frame.data[0] + (s->y + s->font_height)*s->frame.linesize[0],
+ DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame.linesize[0]);
+ break;
+ case 1:
+ erase_line(avctx, 0, s->x);
+ if (s->y > 0)
+ memset(s->frame.data[0], DEFAULT_BG_COLOR, s->y * s->frame.linesize[0]);
+ break;
+ case 2:
+ erase_screen(avctx);
+ }
+ break;
+ case 'K': //Erase in Line
+ switch(s->args[0]) {
+ case 0:
+ erase_line(avctx, s->x, avctx->width - s->x);
+ break;
+ case 1:
+ erase_line(avctx, 0, s->x);
+ break;
+ case 2:
+ erase_line(avctx, 0, avctx->width);
+ }
+ break;
+ case 'm': //Select Graphics Rendition
+ if (s->nb_args == 0) {
+ s->nb_args = 1;
+ s->args[0] = 0;
+ }
+ for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) {
+ int m = s->args[i];
+ if (m == 0) {
+ s->attributes = 0;
+ s->fg = DEFAULT_FG_COLOR;
+ s->bg = DEFAULT_BG_COLOR;
+ } else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) {
+ s->attributes |= 1 << (m - 1);
+ } else if (m >= 30 && m <= 38) {
+ s->fg = ansi_to_cga[m - 30];
+ } else if (m == 39) {
+ s->fg = ansi_to_cga[DEFAULT_FG_COLOR];
+ } else if (m >= 40 && m <= 47) {
+ s->bg = ansi_to_cga[m - 40];
+ } else if (m == 49) {
+ s->fg = ansi_to_cga[DEFAULT_BG_COLOR];
+ } else {
+ av_log_ask_for_sample(avctx, "unsupported rendition parameter\n");
+ }
+ }
+ break;
+ case 'n': //Device Status Report
+ case 'R': //report current line and column
+ /* ignore */
+ break;
+ case 's': //Save Cursor Position
+ s->sx = s->x;
+ s->sy = s->y;
+ break;
+ case 'u': //Restore Cursor Position
+ s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH);
+ s->y = av_clip(s->sy, 0, avctx->height - s->font_height);
+ break;
+ default:
+ av_log_ask_for_sample(avctx, "unsupported escape code\n");
+ break;
+ }
+ return 0;
+}
+
+static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ AnsiContext *s = avctx->priv_data;
+ uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ const uint8_t *buf_end = buf+buf_size;
+ int ret, i, count;
+
+ ret = avctx->reget_buffer(avctx, &s->frame);
+ if (ret < 0){
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+ s->frame.pict_type = FF_I_TYPE;
+ s->frame.palette_has_changed = 1;
+ memcpy(s->frame.data[1], ff_cga_palette, 16 * 4);
+
+ while(buf < buf_end) {
+ switch(s->state) {
+ case STATE_NORMAL:
+ switch (buf[0]) {
+ case 0x00: //NUL
+ case 0x07: //BEL
+ case 0x1A: //SUB
+ /* ignore */
+ break;
+ case 0x08: //BS
+ s->x = FFMAX(s->x - 1, 0);
+ break;
+ case 0x09: //HT
+ i = s->x / FONT_WIDTH;
+ count = ((i + 8) & ~7) - i;
+ for (i = 0; i < count; i++)
+ draw_char(avctx, ' ');
+ break;
+ case 0x0A: //LF
+ hscroll(avctx);
+ case 0x0D: //CR
+ s->x = 0;
+ break;
+ case 0x0C: //FF
+ erase_screen(avctx);
+ break;
+ case 0x1B: //ESC
+ s->state = STATE_ESCAPE;
+ break;
+ default:
+ draw_char(avctx, buf[0]);
+ }
+ break;
+ case STATE_ESCAPE:
+ if (buf[0] == '[') {
+ s->state = STATE_CODE;
+ s->nb_args = 0;
+ s->args[0] = 0;
+ } else {
+ s->state = STATE_NORMAL;
+ draw_char(avctx, 0x1B);
+ return -1;
+ continue;
+ }
+ break;
+ case STATE_CODE:
+ switch(buf[0]) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ if (s->nb_args < MAX_NB_ARGS)
+ s->args[s->nb_args] = s->args[s->nb_args] * 10 + buf[0] - '0';
+ break;
+ case ';':
+ s->nb_args++;
+ if (s->nb_args < MAX_NB_ARGS)
+ s->args[s->nb_args] = 0;
+ break;
+ case 'M':
+ s->state = STATE_MUSIC_PREAMBLE;
+ break;
+ case '=': case '?':
+ /* ignore */
+ break;
+ default:
+ if (s->nb_args > MAX_NB_ARGS)
+ av_log(avctx, AV_LOG_WARNING, "args overflow (%i)\n", s->nb_args);
+ if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args])
+ s->nb_args++;
+ if (execute_code(avctx, buf[0]) < 0)
+ return -1;
+ s->state = STATE_NORMAL;
+ }
+ break;
+ case STATE_MUSIC_PREAMBLE:
+ if (buf[0] == 0x0E || buf[0] == 0x1B)
+ s->state = STATE_NORMAL;
+ /* ignore music data */
+ break;
+ }
+ buf++;
+ }
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = s->frame;
+ return buf_size;
+}
+
+static av_cold int decode_close(AVCodecContext *avctx)
+{
+ AnsiContext *s = avctx->priv_data;
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+ return 0;
+}
+
+AVCodec ff_ansi_decoder = {
+ .name = "ansi",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_ANSI,
+ .priv_data_size = sizeof(AnsiContext),
+ .init = decode_init,
+ .close = decode_close,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
+};
diff --git a/lib/ffmpeg/libavcodec/apedec.c b/lib/ffmpeg/libavcodec/apedec.c
index dd372e275a..b6d6f9d9cc 100644
--- a/lib/ffmpeg/libavcodec/apedec.c
+++ b/lib/ffmpeg/libavcodec/apedec.c
@@ -198,7 +198,7 @@ static av_cold int ape_decode_init(AVCodecContext * avctx)
}
dsputil_init(&s->dsp, avctx);
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
return 0;
}
@@ -883,7 +883,7 @@ static void ape_flush(AVCodecContext *avctx)
s->samples= 0;
}
-AVCodec ape_decoder = {
+AVCodec ff_ape_decoder = {
"ape",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_APE,
diff --git a/lib/ffmpeg/libavcodec/arm/Makefile b/lib/ffmpeg/libavcodec/arm/Makefile
index bab4b875c0..014456ee32 100644
--- a/lib/ffmpeg/libavcodec/arm/Makefile
+++ b/lib/ffmpeg/libavcodec/arm/Makefile
@@ -3,12 +3,13 @@ OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o \
OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_init_arm.o
OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_init_arm.o
-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_init_arm.o \
- arm/h264pred_init_arm.o \
+OBJS-$(CONFIG_H264DSP) += arm/h264dsp_init_arm.o
+OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o
OBJS += arm/dsputil_init_arm.o \
arm/dsputil_arm.o \
arm/fft_init_arm.o \
+ arm/fmtconvert_init_arm.o \
arm/jrevdct_arm.o \
arm/mpegvideo_arm.o \
arm/simple_idct_arm.o \
@@ -22,8 +23,11 @@ OBJS-$(HAVE_ARMV6) += arm/dsputil_init_armv6.o \
arm/dsputil_armv6.o \
arm/simple_idct_armv6.o \
+VFP-OBJS-$(HAVE_ARMV6) += arm/fmtconvert_vfp.o \
+
OBJS-$(HAVE_ARMVFP) += arm/dsputil_vfp.o \
arm/dsputil_init_vfp.o \
+ $(VFP-OBJS-yes)
OBJS-$(HAVE_IWMMXT) += arm/dsputil_iwmmxt.o \
arm/mpegvideo_iwmmxt.o \
@@ -36,7 +40,8 @@ NEON-OBJS-$(CONFIG_RDFT) += arm/rdft_neon.o \
NEON-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_neon.o \
arm/h264idct_neon.o \
- arm/h264pred_neon.o \
+
+NEON-OBJS-$(CONFIG_H264PRED) += arm/h264pred_neon.o \
NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_neon.o \
arm/synth_filter_neon.o \
@@ -51,6 +56,7 @@ NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_neon.o \
OBJS-$(HAVE_NEON) += arm/dsputil_init_neon.o \
arm/dsputil_neon.o \
+ arm/fmtconvert_neon.o \
arm/int_neon.o \
arm/mpegvideo_neon.o \
arm/simple_idct_neon.o \
diff --git a/lib/ffmpeg/libavcodec/arm/asm-offsets.h b/lib/ffmpeg/libavcodec/arm/asm-offsets.h
index c7285ac39a..7f73534834 100644
--- a/lib/ffmpeg/libavcodec/arm/asm-offsets.h
+++ b/lib/ffmpeg/libavcodec/arm/asm-offsets.h
@@ -29,20 +29,11 @@
#endif
/* MpegEncContext */
-#if defined(__ARM_EABI__) || defined(__eabi__)
-#define Y_DC_SCALE 0xa54
-#define C_DC_SCALE 0xa58
-#define AC_PRED 0xa80
-#define BLOCK_LAST_INDEX 0x2278
-#define INTER_SCANTAB_RASTER_END 0x2478
-#define H263_AIC 0x2728
-#elif defined(__APPLE__)
-#define Y_DC_SCALE 0xa30
-#define C_DC_SCALE 0xa34
-#define AC_PRED 0xa5c
-#define BLOCK_LAST_INDEX 0x2254
-#define INTER_SCANTAB_RASTER_END 0x2454
-#define H263_AIC 0x26f8
-#endif
+#define Y_DC_SCALE 0xb4
+#define C_DC_SCALE 0xb8
+#define AC_PRED 0xbc
+#define BLOCK_LAST_INDEX 0xc0
+#define H263_AIC 0xf0
+#define INTER_SCANTAB_RASTER_END 0x138
#endif
diff --git a/lib/ffmpeg/libavcodec/arm/asm.S b/lib/ffmpeg/libavcodec/arm/asm.S
index f364a24f9b..cf73a77609 100644
--- a/lib/ffmpeg/libavcodec/arm/asm.S
+++ b/lib/ffmpeg/libavcodec/arm/asm.S
@@ -50,6 +50,16 @@ ELF .type \name, %function
\name:
.endm
+.macro const name, align=2
+ .macro endconst
+ELF .size \name, . - \name
+ .purgem endconst
+ .endm
+ .section .rodata
+ .align \align
+\name:
+.endm
+
.macro mov32 rd, val
#if HAVE_ARMV6T2
movw \rd, #(\val) & 0xffff
@@ -62,7 +72,7 @@ ELF .type \name, %function
.endm
.macro movrel rd, val
-#if HAVE_ARMV6T2 && !CONFIG_PIC
+#if HAVE_ARMV6T2 && !CONFIG_PIC && !defined(__APPLE__)
movw \rd, #:lower16:\val
movt \rd, #:upper16:\val
#else
diff --git a/lib/ffmpeg/libavcodec/arm/dcadsp_init_arm.c b/lib/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
index 816718d483..5663cd7fc2 100644
--- a/lib/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
+++ b/lib/ffmpeg/libavcodec/arm/dcadsp_init_arm.c
@@ -23,7 +23,7 @@
#include "libavcodec/dcadsp.h"
void ff_dca_lfe_fir_neon(float *out, const float *in, const float *coefs,
- int decifactor, float scale, float bias);
+ int decifactor, float scale);
void av_cold ff_dcadsp_init_arm(DCADSPContext *s)
{
diff --git a/lib/ffmpeg/libavcodec/arm/dcadsp_neon.S b/lib/ffmpeg/libavcodec/arm/dcadsp_neon.S
index 19960ab193..c3bddd3e41 100644
--- a/lib/ffmpeg/libavcodec/arm/dcadsp_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/dcadsp_neon.S
@@ -29,7 +29,7 @@ function ff_dca_lfe_fir_neon, export=1
cmp r3, #32
moveq r6, #256/32
movne r6, #256/64
-NOVFP vldr d0, [sp, #16] @ scale, bias
+NOVFP vldr s0, [sp, #16] @ scale
mov lr, #-16
1:
vmov.f32 q2, #0.0 @ v0
@@ -51,8 +51,7 @@ NOVFP vldr d0, [sp, #16] @ scale, bias
vadd.f32 d4, d4, d5
vadd.f32 d6, d6, d7
vpadd.f32 d4, d4, d6
- vdup.32 d5, d0[1]
- vmla.f32 d5, d4, d0[0]
+ vmul.f32 d5, d4, d0[0]
vst1.32 {d5[0]}, [r0,:32]!
vst1.32 {d5[1]}, [r4,:32]!
bne 1b
diff --git a/lib/ffmpeg/libavcodec/arm/dsputil_init_arm.c b/lib/ffmpeg/libavcodec/arm/dsputil_init_arm.c
index c9c335112d..5c132905f6 100644
--- a/lib/ffmpeg/libavcodec/arm/dsputil_init_arm.c
+++ b/lib/ffmpeg/libavcodec/arm/dsputil_init_arm.c
@@ -73,11 +73,6 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block)
ff_add_pixels_clamped(block, dest, line_size);
}
-int mm_support(void)
-{
- return HAVE_IWMMXT * FF_MM_IWMMXT;
-}
-
void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
{
ff_put_pixels_clamped = c->put_pixels_clamped;
diff --git a/lib/ffmpeg/libavcodec/arm/dsputil_init_neon.c b/lib/ffmpeg/libavcodec/arm/dsputil_init_neon.c
index 04ebb00576..76ae632273 100644
--- a/lib/ffmpeg/libavcodec/arm/dsputil_init_neon.c
+++ b/lib/ffmpeg/libavcodec/arm/dsputil_init_neon.c
@@ -138,10 +138,9 @@ void ff_avg_h264_chroma_mc2_neon(uint8_t *, uint8_t *, int, int, int, int);
void ff_vp3_v_loop_filter_neon(uint8_t *, int, int *);
void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *);
-void ff_vector_fmul_neon(float *dst, const float *src, int len);
+void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1, int len);
void ff_vector_fmul_window_neon(float *dst, const float *src0,
- const float *src1, const float *win,
- float add_bias, int len);
+ const float *src1, const float *win, int len);
void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,
int len);
void ff_vector_fmul_sv_scalar_2_neon(float *dst, const float *src,
@@ -154,8 +153,6 @@ void ff_sv_fmul_scalar_4_neon(float *dst, const float **vp, float mul,
int len);
void ff_butterflies_float_neon(float *v1, float *v2, int len);
float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
-void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src,
- float mul, int len);
void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
const float *src1, int len);
void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1,
@@ -163,8 +160,6 @@ void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1,
void ff_vector_clipf_neon(float *dst, const float *src, float min, float max,
int len);
-void ff_float_to_int16_neon(int16_t *, const float *, long);
-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);
@@ -309,7 +304,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
c->vector_fmul_scalar = ff_vector_fmul_scalar_neon;
c->butterflies_float = ff_butterflies_float_neon;
c->scalarproduct_float = ff_scalarproduct_float_neon;
- c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_neon;
c->vector_fmul_reverse = ff_vector_fmul_reverse_neon;
c->vector_fmul_add = ff_vector_fmul_add_neon;
c->vector_clipf = ff_vector_clipf_neon;
@@ -320,11 +314,6 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
c->sv_fmul_scalar[0] = ff_sv_fmul_scalar_2_neon;
c->sv_fmul_scalar[1] = ff_sv_fmul_scalar_4_neon;
- if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
- c->float_to_int16 = ff_float_to_int16_neon;
- c->float_to_int16_interleave = ff_float_to_int16_interleave_neon;
- }
-
if (CONFIG_VORBIS_DECODER)
c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_neon;
diff --git a/lib/ffmpeg/libavcodec/arm/dsputil_init_vfp.c b/lib/ffmpeg/libavcodec/arm/dsputil_init_vfp.c
index 9f8c1b7840..bd52315934 100644
--- a/lib/ffmpeg/libavcodec/arm/dsputil_init_vfp.c
+++ b/lib/ffmpeg/libavcodec/arm/dsputil_init_vfp.c
@@ -21,16 +21,13 @@
#include "libavcodec/dsputil.h"
#include "dsputil_arm.h"
-void ff_vector_fmul_vfp(float *dst, const float *src, int len);
+void ff_vector_fmul_vfp(float *dst, const float *src0,
+ const float *src1, int len);
void ff_vector_fmul_reverse_vfp(float *dst, const float *src0,
const float *src1, int len);
-void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len);
void ff_dsputil_init_vfp(DSPContext* c, AVCodecContext *avctx)
{
c->vector_fmul = ff_vector_fmul_vfp;
c->vector_fmul_reverse = ff_vector_fmul_reverse_vfp;
-#if HAVE_ARMV6
- c->float_to_int16 = ff_float_to_int16_vfp;
-#endif
}
diff --git a/lib/ffmpeg/libavcodec/arm/dsputil_iwmmxt.c b/lib/ffmpeg/libavcodec/arm/dsputil_iwmmxt.c
index 6a23732e33..758d9cbfea 100644
--- a/lib/ffmpeg/libavcodec/arm/dsputil_iwmmxt.c
+++ b/lib/ffmpeg/libavcodec/arm/dsputil_iwmmxt.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h"
#define DEF(x, y) x ## _no_rnd_ ## y ##_iwmmxt
@@ -150,18 +151,19 @@ static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h)
/* A run time test is not simple. If this file is compiled in
* then we should install the functions
*/
-int mm_flags = FF_MM_IWMMXT; /* multimedia extension flags */
void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)
{
+ int mm_flags = AV_CPU_FLAG_IWMMXT; /* multimedia extension flags */
+
if (avctx->dsp_mask) {
- if (avctx->dsp_mask & FF_MM_FORCE)
+ if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
mm_flags |= (avctx->dsp_mask & 0xffff);
else
mm_flags &= ~(avctx->dsp_mask & 0xffff);
}
- if (!(mm_flags & FF_MM_IWMMXT)) return;
+ if (!(mm_flags & AV_CPU_FLAG_IWMMXT)) return;
c->add_pixels_clamped = add_pixels_clamped_iwmmxt;
diff --git a/lib/ffmpeg/libavcodec/arm/dsputil_neon.S b/lib/ffmpeg/libavcodec/arm/dsputil_neon.S
index 2bcdb397f9..05a911502b 100644
--- a/lib/ffmpeg/libavcodec/arm/dsputil_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/dsputil_neon.S
@@ -400,389 +400,48 @@ function ff_add_pixels_clamped_neon, export=1
bx lr
endfunc
-function ff_float_to_int16_neon, export=1
- subs r2, r2, #8
- vld1.64 {d0-d1}, [r1,:128]!
- vcvt.s32.f32 q8, q0, #16
- vld1.64 {d2-d3}, [r1,:128]!
- vcvt.s32.f32 q9, q1, #16
- beq 3f
- bics ip, r2, #15
- beq 2f
-1: subs ip, ip, #16
- vshrn.s32 d4, q8, #16
- vld1.64 {d0-d1}, [r1,:128]!
- vcvt.s32.f32 q0, q0, #16
- vshrn.s32 d5, q9, #16
- vld1.64 {d2-d3}, [r1,:128]!
- vcvt.s32.f32 q1, q1, #16
- vshrn.s32 d6, q0, #16
- vst1.64 {d4-d5}, [r0,:128]!
- vshrn.s32 d7, q1, #16
- vld1.64 {d16-d17},[r1,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r1,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.64 {d6-d7}, [r0,:128]!
- bne 1b
- ands r2, r2, #15
- beq 3f
-2: vld1.64 {d0-d1}, [r1,:128]!
- vshrn.s32 d4, q8, #16
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r1,:128]!
- vshrn.s32 d5, q9, #16
- vcvt.s32.f32 q1, q1, #16
- vshrn.s32 d6, q0, #16
- vst1.64 {d4-d5}, [r0,:128]!
- vshrn.s32 d7, q1, #16
- vst1.64 {d6-d7}, [r0,:128]!
- bx lr
-3: vshrn.s32 d4, q8, #16
- vshrn.s32 d5, q9, #16
- vst1.64 {d4-d5}, [r0,:128]!
- bx lr
-endfunc
-
-function ff_float_to_int16_interleave_neon, export=1
- cmp r3, #2
- ldrlt r1, [r1]
- blt ff_float_to_int16_neon
- bne 4f
-
- ldr r3, [r1]
- ldr r1, [r1, #4]
-
- subs r2, r2, #8
- vld1.64 {d0-d1}, [r3,:128]!
- vcvt.s32.f32 q8, q0, #16
- vld1.64 {d2-d3}, [r3,:128]!
- vcvt.s32.f32 q9, q1, #16
- vld1.64 {d20-d21},[r1,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r1,:128]!
- vcvt.s32.f32 q11, q11, #16
- beq 3f
- bics ip, r2, #15
- beq 2f
-1: subs ip, ip, #16
- vld1.64 {d0-d1}, [r3,:128]!
- vcvt.s32.f32 q0, q0, #16
- vsri.32 q10, q8, #16
- vld1.64 {d2-d3}, [r3,:128]!
- vcvt.s32.f32 q1, q1, #16
- vld1.64 {d24-d25},[r1,:128]!
- vcvt.s32.f32 q12, q12, #16
- vld1.64 {d26-d27},[r1,:128]!
- vsri.32 q11, q9, #16
- vst1.64 {d20-d21},[r0,:128]!
- vcvt.s32.f32 q13, q13, #16
- vst1.64 {d22-d23},[r0,:128]!
- vsri.32 q12, q0, #16
- vld1.64 {d16-d17},[r3,:128]!
- vsri.32 q13, q1, #16
- vst1.64 {d24-d25},[r0,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r3,:128]!
- vcvt.s32.f32 q9, q9, #16
- vld1.64 {d20-d21},[r1,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r1,:128]!
- vcvt.s32.f32 q11, q11, #16
- vst1.64 {d26-d27},[r0,:128]!
- bne 1b
- ands r2, r2, #15
- beq 3f
-2: vsri.32 q10, q8, #16
- vld1.64 {d0-d1}, [r3,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r3,:128]!
- vcvt.s32.f32 q1, q1, #16
- vld1.64 {d24-d25},[r1,:128]!
- vcvt.s32.f32 q12, q12, #16
- vsri.32 q11, q9, #16
- vld1.64 {d26-d27},[r1,:128]!
- vcvt.s32.f32 q13, q13, #16
- vst1.64 {d20-d21},[r0,:128]!
- vsri.32 q12, q0, #16
- vst1.64 {d22-d23},[r0,:128]!
- vsri.32 q13, q1, #16
- vst1.64 {d24-d27},[r0,:128]!
- bx lr
-3: vsri.32 q10, q8, #16
- vsri.32 q11, q9, #16
- vst1.64 {d20-d23},[r0,:128]!
- bx lr
-
-4: push {r4-r8,lr}
- cmp r3, #4
- lsl ip, r3, #1
- blt 4f
-
- @ 4 channels
-5: ldmia r1!, {r4-r7}
- mov lr, r2
- mov r8, r0
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vld1.64 {d20-d21},[r6,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r7,:128]!
- vcvt.s32.f32 q11, q11, #16
-6: subs lr, lr, #8
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vsri.32 q9, q8, #16
- vld1.64 {d2-d3}, [r5,:128]!
- vcvt.s32.f32 q1, q1, #16
- vsri.32 q11, q10, #16
- vld1.64 {d4-d5}, [r6,:128]!
- vcvt.s32.f32 q2, q2, #16
- vzip.32 d18, d22
- vld1.64 {d6-d7}, [r7,:128]!
- vcvt.s32.f32 q3, q3, #16
- vzip.32 d19, d23
- vst1.64 {d18}, [r8], ip
- vsri.32 q1, q0, #16
- vst1.64 {d22}, [r8], ip
- vsri.32 q3, q2, #16
- vst1.64 {d19}, [r8], ip
- vzip.32 d2, d6
- vst1.64 {d23}, [r8], ip
- vzip.32 d3, d7
- beq 7f
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vst1.64 {d2}, [r8], ip
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.64 {d6}, [r8], ip
- vld1.64 {d20-d21},[r6,:128]!
- vcvt.s32.f32 q10, q10, #16
- vst1.64 {d3}, [r8], ip
- vld1.64 {d22-d23},[r7,:128]!
- vcvt.s32.f32 q11, q11, #16
- vst1.64 {d7}, [r8], ip
- b 6b
-7: vst1.64 {d2}, [r8], ip
- vst1.64 {d6}, [r8], ip
- vst1.64 {d3}, [r8], ip
- vst1.64 {d7}, [r8], ip
- subs r3, r3, #4
- popeq {r4-r8,pc}
- cmp r3, #4
- add r0, r0, #8
- bge 5b
-
- @ 2 channels
-4: cmp r3, #2
- blt 4f
- ldmia r1!, {r4-r5}
- mov lr, r2
- mov r8, r0
- tst lr, #8
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vld1.64 {d20-d21},[r4,:128]!
- vcvt.s32.f32 q10, q10, #16
- vld1.64 {d22-d23},[r5,:128]!
- vcvt.s32.f32 q11, q11, #16
- beq 6f
- subs lr, lr, #8
- beq 7f
- vsri.32 d18, d16, #16
- vsri.32 d19, d17, #16
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vst1.32 {d18[0]}, [r8], ip
- vsri.32 d22, d20, #16
- vst1.32 {d18[1]}, [r8], ip
- vsri.32 d23, d21, #16
- vst1.32 {d19[0]}, [r8], ip
- vst1.32 {d19[1]}, [r8], ip
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.32 {d22[0]}, [r8], ip
- vst1.32 {d22[1]}, [r8], ip
- vld1.64 {d20-d21},[r4,:128]!
- vcvt.s32.f32 q10, q10, #16
- vst1.32 {d23[0]}, [r8], ip
- vst1.32 {d23[1]}, [r8], ip
- vld1.64 {d22-d23},[r5,:128]!
- vcvt.s32.f32 q11, q11, #16
-6: subs lr, lr, #16
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vsri.32 d18, d16, #16
- vld1.64 {d2-d3}, [r5,:128]!
- vcvt.s32.f32 q1, q1, #16
- vsri.32 d19, d17, #16
- vld1.64 {d4-d5}, [r4,:128]!
- vcvt.s32.f32 q2, q2, #16
- vld1.64 {d6-d7}, [r5,:128]!
- vcvt.s32.f32 q3, q3, #16
- vst1.32 {d18[0]}, [r8], ip
- vsri.32 d22, d20, #16
- vst1.32 {d18[1]}, [r8], ip
- vsri.32 d23, d21, #16
- vst1.32 {d19[0]}, [r8], ip
- vsri.32 d2, d0, #16
- vst1.32 {d19[1]}, [r8], ip
- vsri.32 d3, d1, #16
- vst1.32 {d22[0]}, [r8], ip
- vsri.32 d6, d4, #16
- vst1.32 {d22[1]}, [r8], ip
- vsri.32 d7, d5, #16
- vst1.32 {d23[0]}, [r8], ip
- vst1.32 {d23[1]}, [r8], ip
- beq 6f
- vld1.64 {d16-d17},[r4,:128]!
- vcvt.s32.f32 q8, q8, #16
- vst1.32 {d2[0]}, [r8], ip
- vst1.32 {d2[1]}, [r8], ip
- vld1.64 {d18-d19},[r5,:128]!
- vcvt.s32.f32 q9, q9, #16
- vst1.32 {d3[0]}, [r8], ip
- vst1.32 {d3[1]}, [r8], ip
- vld1.64 {d20-d21},[r4,:128]!
- vcvt.s32.f32 q10, q10, #16
- vst1.32 {d6[0]}, [r8], ip
- vst1.32 {d6[1]}, [r8], ip
- vld1.64 {d22-d23},[r5,:128]!
- vcvt.s32.f32 q11, q11, #16
- vst1.32 {d7[0]}, [r8], ip
- vst1.32 {d7[1]}, [r8], ip
- bgt 6b
-6: vst1.32 {d2[0]}, [r8], ip
- vst1.32 {d2[1]}, [r8], ip
- vst1.32 {d3[0]}, [r8], ip
- vst1.32 {d3[1]}, [r8], ip
- vst1.32 {d6[0]}, [r8], ip
- vst1.32 {d6[1]}, [r8], ip
- vst1.32 {d7[0]}, [r8], ip
- vst1.32 {d7[1]}, [r8], ip
- b 8f
-7: vsri.32 d18, d16, #16
- vsri.32 d19, d17, #16
- vst1.32 {d18[0]}, [r8], ip
- vsri.32 d22, d20, #16
- vst1.32 {d18[1]}, [r8], ip
- vsri.32 d23, d21, #16
- vst1.32 {d19[0]}, [r8], ip
- vst1.32 {d19[1]}, [r8], ip
- vst1.32 {d22[0]}, [r8], ip
- vst1.32 {d22[1]}, [r8], ip
- vst1.32 {d23[0]}, [r8], ip
- vst1.32 {d23[1]}, [r8], ip
-8: subs r3, r3, #2
- add r0, r0, #4
- popeq {r4-r8,pc}
-
- @ 1 channel
-4: ldr r4, [r1],#4
- tst r2, #8
- mov lr, r2
- mov r5, r0
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r4,:128]!
- vcvt.s32.f32 q1, q1, #16
- bne 8f
-6: subs lr, lr, #16
- vld1.64 {d4-d5}, [r4,:128]!
- vcvt.s32.f32 q2, q2, #16
- vld1.64 {d6-d7}, [r4,:128]!
- vcvt.s32.f32 q3, q3, #16
- vst1.16 {d0[1]}, [r5,:16], ip
- vst1.16 {d0[3]}, [r5,:16], ip
- vst1.16 {d1[1]}, [r5,:16], ip
- vst1.16 {d1[3]}, [r5,:16], ip
- vst1.16 {d2[1]}, [r5,:16], ip
- vst1.16 {d2[3]}, [r5,:16], ip
- vst1.16 {d3[1]}, [r5,:16], ip
- vst1.16 {d3[3]}, [r5,:16], ip
- beq 7f
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r4,:128]!
- vcvt.s32.f32 q1, q1, #16
-7: vst1.16 {d4[1]}, [r5,:16], ip
- vst1.16 {d4[3]}, [r5,:16], ip
- vst1.16 {d5[1]}, [r5,:16], ip
- vst1.16 {d5[3]}, [r5,:16], ip
- vst1.16 {d6[1]}, [r5,:16], ip
- vst1.16 {d6[3]}, [r5,:16], ip
- vst1.16 {d7[1]}, [r5,:16], ip
- vst1.16 {d7[3]}, [r5,:16], ip
- bgt 6b
- pop {r4-r8,pc}
-8: subs lr, lr, #8
- vst1.16 {d0[1]}, [r5,:16], ip
- vst1.16 {d0[3]}, [r5,:16], ip
- vst1.16 {d1[1]}, [r5,:16], ip
- vst1.16 {d1[3]}, [r5,:16], ip
- vst1.16 {d2[1]}, [r5,:16], ip
- vst1.16 {d2[3]}, [r5,:16], ip
- vst1.16 {d3[1]}, [r5,:16], ip
- vst1.16 {d3[3]}, [r5,:16], ip
- popeq {r4-r8,pc}
- vld1.64 {d0-d1}, [r4,:128]!
- vcvt.s32.f32 q0, q0, #16
- vld1.64 {d2-d3}, [r4,:128]!
- vcvt.s32.f32 q1, q1, #16
- b 6b
-endfunc
-
function ff_vector_fmul_neon, export=1
- mov r3, r0
- subs r2, r2, #8
- vld1.64 {d0-d3}, [r0,:128]!
- vld1.64 {d4-d7}, [r1,:128]!
+ subs r3, r3, #8
+ vld1.64 {d0-d3}, [r1,:128]!
+ vld1.64 {d4-d7}, [r2,:128]!
vmul.f32 q8, q0, q2
vmul.f32 q9, q1, q3
beq 3f
- bics ip, r2, #15
+ bics ip, r3, #15
beq 2f
1: subs ip, ip, #16
- vld1.64 {d0-d1}, [r0,:128]!
- vld1.64 {d4-d5}, [r1,:128]!
+ vld1.64 {d0-d1}, [r1,:128]!
+ vld1.64 {d4-d5}, [r2,:128]!
vmul.f32 q10, q0, q2
- vld1.64 {d2-d3}, [r0,:128]!
- vld1.64 {d6-d7}, [r1,:128]!
+ vld1.64 {d2-d3}, [r1,:128]!
+ vld1.64 {d6-d7}, [r2,:128]!
vmul.f32 q11, q1, q3
- vst1.64 {d16-d19},[r3,:128]!
- vld1.64 {d0-d1}, [r0,:128]!
- vld1.64 {d4-d5}, [r1,:128]!
+ vst1.64 {d16-d19},[r0,:128]!
+ vld1.64 {d0-d1}, [r1,:128]!
+ vld1.64 {d4-d5}, [r2,:128]!
vmul.f32 q8, q0, q2
- vld1.64 {d2-d3}, [r0,:128]!
- vld1.64 {d6-d7}, [r1,:128]!
+ vld1.64 {d2-d3}, [r1,:128]!
+ vld1.64 {d6-d7}, [r2,:128]!
vmul.f32 q9, q1, q3
- vst1.64 {d20-d23},[r3,:128]!
+ vst1.64 {d20-d23},[r0,:128]!
bne 1b
- ands r2, r2, #15
+ ands r3, r3, #15
beq 3f
-2: vld1.64 {d0-d1}, [r0,:128]!
- vld1.64 {d4-d5}, [r1,:128]!
- vst1.64 {d16-d17},[r3,:128]!
+2: vld1.64 {d0-d1}, [r1,:128]!
+ vld1.64 {d4-d5}, [r2,:128]!
+ vst1.64 {d16-d17},[r0,:128]!
vmul.f32 q8, q0, q2
- vld1.64 {d2-d3}, [r0,:128]!
- vld1.64 {d6-d7}, [r1,:128]!
- vst1.64 {d18-d19},[r3,:128]!
+ vld1.64 {d2-d3}, [r1,:128]!
+ vld1.64 {d6-d7}, [r2,:128]!
+ vst1.64 {d18-d19},[r0,:128]!
vmul.f32 q9, q1, q3
-3: vst1.64 {d16-d19},[r3,:128]!
+3: vst1.64 {d16-d19},[r0,:128]!
bx lr
endfunc
function ff_vector_fmul_window_neon, export=1
-VFP vdup.32 q8, d0[0]
-NOVFP vld1.32 {d16[],d17[]}, [sp,:32]
push {r4,r5,lr}
-VFP ldr lr, [sp, #12]
-NOVFP ldr lr, [sp, #16]
+ ldr lr, [sp, #12]
sub r2, r2, #8
sub r5, lr, #2
add r2, r2, r5, lsl #2
@@ -794,14 +453,12 @@ NOVFP ldr lr, [sp, #16]
vld1.64 {d4,d5}, [r3,:128]!
vld1.64 {d6,d7}, [r4,:128], r5
1: subs lr, lr, #4
- vmov q11, q8
- vmla.f32 d22, d0, d4
- vmov q10, q8
- vmla.f32 d23, d1, d5
+ vmul.f32 d22, d0, d4
vrev64.32 q3, q3
- vmla.f32 d20, d0, d7
+ vmul.f32 d23, d1, d5
vrev64.32 q1, q1
- vmla.f32 d21, d1, d6
+ vmul.f32 d20, d0, d7
+ vmul.f32 d21, d1, d6
beq 2f
vmla.f32 d22, d3, d7
vld1.64 {d0,d1}, [r1,:128]!
@@ -1056,34 +713,6 @@ NOVFP vmov.32 r0, d0[0]
bx lr
endfunc
-function ff_int32_to_float_fmul_scalar_neon, export=1
-VFP vdup.32 q0, d0[0]
-VFP len .req r2
-NOVFP vdup.32 q0, r2
-NOVFP len .req r3
-
- vld1.32 {q1},[r1,:128]!
- vcvt.f32.s32 q3, q1
- vld1.32 {q2},[r1,:128]!
- vcvt.f32.s32 q8, q2
-1: subs len, len, #8
- pld [r1, #16]
- vmul.f32 q9, q3, q0
- vmul.f32 q10, q8, q0
- beq 2f
- vld1.32 {q1},[r1,:128]!
- vcvt.f32.s32 q3, q1
- vld1.32 {q2},[r1,:128]!
- vcvt.f32.s32 q8, q2
- vst1.32 {q9}, [r0,:128]!
- vst1.32 {q10},[r0,:128]!
- b 1b
-2: vst1.32 {q9}, [r0,:128]!
- vst1.32 {q10},[r0,:128]!
- bx lr
- .unreq len
-endfunc
-
function ff_vector_fmul_reverse_neon, export=1
add r2, r2, r3, lsl #2
sub r2, r2, #32
diff --git a/lib/ffmpeg/libavcodec/arm/dsputil_vfp.S b/lib/ffmpeg/libavcodec/arm/dsputil_vfp.S
index b704ba9144..197d500819 100644
--- a/lib/ffmpeg/libavcodec/arm/dsputil_vfp.S
+++ b/lib/ffmpeg/libavcodec/arm/dsputil_vfp.S
@@ -41,34 +41,33 @@
* ARM VFP optimized implementation of 'vector_fmul_c' function.
* Assume that len is a positive number and is multiple of 8
*/
-@ void ff_vector_fmul_vfp(float *dst, const float *src, int len)
+@ void ff_vector_fmul_vfp(float *dst, const float *src0, const float *src1, int len)
function ff_vector_fmul_vfp, export=1
vpush {d8-d15}
- mov r3, r0
fmrx r12, fpscr
orr r12, r12, #(3 << 16) /* set vector size to 4 */
fmxr fpscr, r12
- vldmia r3!, {s0-s3}
- vldmia r1!, {s8-s11}
- vldmia r3!, {s4-s7}
- vldmia r1!, {s12-s15}
+ vldmia r1!, {s0-s3}
+ vldmia r2!, {s8-s11}
+ vldmia r1!, {s4-s7}
+ vldmia r2!, {s12-s15}
vmul.f32 s8, s0, s8
1:
- subs r2, r2, #16
+ subs r3, r3, #16
vmul.f32 s12, s4, s12
- vldmiage r3!, {s16-s19}
- vldmiage r1!, {s24-s27}
- vldmiage r3!, {s20-s23}
- vldmiage r1!, {s28-s31}
+ vldmiage r1!, {s16-s19}
+ vldmiage r2!, {s24-s27}
+ vldmiage r1!, {s20-s23}
+ vldmiage r2!, {s28-s31}
vmulge.f32 s24, s16, s24
vstmia r0!, {s8-s11}
vstmia r0!, {s12-s15}
vmulge.f32 s28, s20, s28
- vldmiagt r3!, {s0-s3}
- vldmiagt r1!, {s8-s11}
- vldmiagt r3!, {s4-s7}
- vldmiagt r1!, {s12-s15}
+ vldmiagt r1!, {s0-s3}
+ vldmiagt r2!, {s8-s11}
+ vldmiagt r1!, {s4-s7}
+ vldmiagt r2!, {s12-s15}
vmulge.f32 s8, s0, s8
vstmiage r0!, {s24-s27}
vstmiage r0!, {s28-s31}
@@ -132,58 +131,3 @@ function ff_vector_fmul_reverse_vfp, export=1
vpop {d8-d15}
bx lr
endfunc
-
-#if HAVE_ARMV6
-/**
- * ARM VFP optimized float to int16 conversion.
- * Assume that len is a positive number and is multiple of 8, destination
- * buffer is at least 4 bytes aligned (8 bytes alignment is better for
- * performance), little endian byte sex
- */
-@ void ff_float_to_int16_vfp(int16_t *dst, const float *src, int len)
-function ff_float_to_int16_vfp, export=1
- push {r4-r8,lr}
- vpush {d8-d11}
- vldmia r1!, {s16-s23}
- vcvt.s32.f32 s0, s16
- vcvt.s32.f32 s1, s17
- vcvt.s32.f32 s2, s18
- vcvt.s32.f32 s3, s19
- vcvt.s32.f32 s4, s20
- vcvt.s32.f32 s5, s21
- vcvt.s32.f32 s6, s22
- vcvt.s32.f32 s7, s23
-1:
- subs r2, r2, #8
- vmov r3, r4, s0, s1
- vmov r5, r6, s2, s3
- vmov r7, r8, s4, s5
- vmov ip, lr, s6, s7
- vldmiagt r1!, {s16-s23}
- ssat r4, #16, r4
- ssat r3, #16, r3
- ssat r6, #16, r6
- ssat r5, #16, r5
- pkhbt r3, r3, r4, lsl #16
- pkhbt r4, r5, r6, lsl #16
- vcvtgt.s32.f32 s0, s16
- vcvtgt.s32.f32 s1, s17
- vcvtgt.s32.f32 s2, s18
- vcvtgt.s32.f32 s3, s19
- vcvtgt.s32.f32 s4, s20
- vcvtgt.s32.f32 s5, s21
- vcvtgt.s32.f32 s6, s22
- vcvtgt.s32.f32 s7, s23
- ssat r8, #16, r8
- ssat r7, #16, r7
- ssat lr, #16, lr
- ssat ip, #16, ip
- pkhbt r5, r7, r8, lsl #16
- pkhbt r6, ip, lr, lsl #16
- stmia r0!, {r3-r6}
- bgt 1b
-
- vpop {d8-d11}
- pop {r4-r8,pc}
-endfunc
-#endif
diff --git a/lib/ffmpeg/libavcodec/arm/fft_init_arm.c b/lib/ffmpeg/libavcodec/arm/fft_init_arm.c
index bde12400de..3f2d554413 100644
--- a/lib/ffmpeg/libavcodec/arm/fft_init_arm.c
+++ b/lib/ffmpeg/libavcodec/arm/fft_init_arm.c
@@ -34,7 +34,7 @@ void ff_synth_filter_float_neon(FFTContext *imdct,
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
float out[32], const float in[32],
- float scale, float bias);
+ float scale);
av_cold void ff_fft_init_arm(FFTContext *s)
{
diff --git a/lib/ffmpeg/libavcodec/arm/fft_neon.S b/lib/ffmpeg/libavcodec/arm/fft_neon.S
index 72431535d8..1db7abd146 100644
--- a/lib/ffmpeg/libavcodec/arm/fft_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/fft_neon.S
@@ -4,6 +4,9 @@
* Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
* Copyright (c) 2009 Naotoshi Nojiri
*
+ * This algorithm (though not any of the implementation details) is
+ * based on libdjbfft by D. J. Bernstein.
+ *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
diff --git a/lib/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c b/lib/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c
new file mode 100644
index 0000000000..4b6e3939f5
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/arm/fmtconvert_init_arm.c
@@ -0,0 +1,48 @@
+/*
+ * ARM optimized Format Conversion Utils
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/fmtconvert.h"
+
+void ff_int32_to_float_fmul_scalar_neon(float *dst, const int *src,
+ float mul, int len);
+
+void ff_float_to_int16_neon(int16_t *dst, const float *src, long len);
+void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int);
+
+void ff_float_to_int16_vfp(int16_t *dst, const float *src, long len);
+
+void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx)
+{
+ if (HAVE_ARMVFP && HAVE_ARMV6) {
+ c->float_to_int16 = ff_float_to_int16_vfp;
+ }
+
+ if (HAVE_NEON) {
+ c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_neon;
+
+ if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
+ c->float_to_int16 = ff_float_to_int16_neon;
+ c->float_to_int16_interleave = ff_float_to_int16_interleave_neon;
+ }
+ }
+}
diff --git a/lib/ffmpeg/libavcodec/arm/fmtconvert_neon.S b/lib/ffmpeg/libavcodec/arm/fmtconvert_neon.S
new file mode 100644
index 0000000000..359e57e40b
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/arm/fmtconvert_neon.S
@@ -0,0 +1,391 @@
+/*
+ * ARM NEON optimised Format Conversion Utils
+ * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "asm.S"
+
+ preserve8
+ .text
+
+function ff_float_to_int16_neon, export=1
+ subs r2, r2, #8
+ vld1.64 {d0-d1}, [r1,:128]!
+ vcvt.s32.f32 q8, q0, #16
+ vld1.64 {d2-d3}, [r1,:128]!
+ vcvt.s32.f32 q9, q1, #16
+ beq 3f
+ bics ip, r2, #15
+ beq 2f
+1: subs ip, ip, #16
+ vshrn.s32 d4, q8, #16
+ vld1.64 {d0-d1}, [r1,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vshrn.s32 d5, q9, #16
+ vld1.64 {d2-d3}, [r1,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vshrn.s32 d6, q0, #16
+ vst1.64 {d4-d5}, [r0,:128]!
+ vshrn.s32 d7, q1, #16
+ vld1.64 {d16-d17},[r1,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r1,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.64 {d6-d7}, [r0,:128]!
+ bne 1b
+ ands r2, r2, #15
+ beq 3f
+2: vld1.64 {d0-d1}, [r1,:128]!
+ vshrn.s32 d4, q8, #16
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r1,:128]!
+ vshrn.s32 d5, q9, #16
+ vcvt.s32.f32 q1, q1, #16
+ vshrn.s32 d6, q0, #16
+ vst1.64 {d4-d5}, [r0,:128]!
+ vshrn.s32 d7, q1, #16
+ vst1.64 {d6-d7}, [r0,:128]!
+ bx lr
+3: vshrn.s32 d4, q8, #16
+ vshrn.s32 d5, q9, #16
+ vst1.64 {d4-d5}, [r0,:128]!
+ bx lr
+endfunc
+
+function ff_float_to_int16_interleave_neon, export=1
+ cmp r3, #2
+ ldrlt r1, [r1]
+ blt ff_float_to_int16_neon
+ bne 4f
+
+ ldr r3, [r1]
+ ldr r1, [r1, #4]
+
+ subs r2, r2, #8
+ vld1.64 {d0-d1}, [r3,:128]!
+ vcvt.s32.f32 q8, q0, #16
+ vld1.64 {d2-d3}, [r3,:128]!
+ vcvt.s32.f32 q9, q1, #16
+ vld1.64 {d20-d21},[r1,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r1,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ beq 3f
+ bics ip, r2, #15
+ beq 2f
+1: subs ip, ip, #16
+ vld1.64 {d0-d1}, [r3,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vsri.32 q10, q8, #16
+ vld1.64 {d2-d3}, [r3,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vld1.64 {d24-d25},[r1,:128]!
+ vcvt.s32.f32 q12, q12, #16
+ vld1.64 {d26-d27},[r1,:128]!
+ vsri.32 q11, q9, #16
+ vst1.64 {d20-d21},[r0,:128]!
+ vcvt.s32.f32 q13, q13, #16
+ vst1.64 {d22-d23},[r0,:128]!
+ vsri.32 q12, q0, #16
+ vld1.64 {d16-d17},[r3,:128]!
+ vsri.32 q13, q1, #16
+ vst1.64 {d24-d25},[r0,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r3,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vld1.64 {d20-d21},[r1,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r1,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ vst1.64 {d26-d27},[r0,:128]!
+ bne 1b
+ ands r2, r2, #15
+ beq 3f
+2: vsri.32 q10, q8, #16
+ vld1.64 {d0-d1}, [r3,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r3,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vld1.64 {d24-d25},[r1,:128]!
+ vcvt.s32.f32 q12, q12, #16
+ vsri.32 q11, q9, #16
+ vld1.64 {d26-d27},[r1,:128]!
+ vcvt.s32.f32 q13, q13, #16
+ vst1.64 {d20-d21},[r0,:128]!
+ vsri.32 q12, q0, #16
+ vst1.64 {d22-d23},[r0,:128]!
+ vsri.32 q13, q1, #16
+ vst1.64 {d24-d27},[r0,:128]!
+ bx lr
+3: vsri.32 q10, q8, #16
+ vsri.32 q11, q9, #16
+ vst1.64 {d20-d23},[r0,:128]!
+ bx lr
+
+4: push {r4-r8,lr}
+ cmp r3, #4
+ lsl ip, r3, #1
+ blt 4f
+
+ @ 4 channels
+5: ldmia r1!, {r4-r7}
+ mov lr, r2
+ mov r8, r0
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vld1.64 {d20-d21},[r6,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r7,:128]!
+ vcvt.s32.f32 q11, q11, #16
+6: subs lr, lr, #8
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vsri.32 q9, q8, #16
+ vld1.64 {d2-d3}, [r5,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vsri.32 q11, q10, #16
+ vld1.64 {d4-d5}, [r6,:128]!
+ vcvt.s32.f32 q2, q2, #16
+ vzip.32 d18, d22
+ vld1.64 {d6-d7}, [r7,:128]!
+ vcvt.s32.f32 q3, q3, #16
+ vzip.32 d19, d23
+ vst1.64 {d18}, [r8], ip
+ vsri.32 q1, q0, #16
+ vst1.64 {d22}, [r8], ip
+ vsri.32 q3, q2, #16
+ vst1.64 {d19}, [r8], ip
+ vzip.32 d2, d6
+ vst1.64 {d23}, [r8], ip
+ vzip.32 d3, d7
+ beq 7f
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vst1.64 {d2}, [r8], ip
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.64 {d6}, [r8], ip
+ vld1.64 {d20-d21},[r6,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vst1.64 {d3}, [r8], ip
+ vld1.64 {d22-d23},[r7,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ vst1.64 {d7}, [r8], ip
+ b 6b
+7: vst1.64 {d2}, [r8], ip
+ vst1.64 {d6}, [r8], ip
+ vst1.64 {d3}, [r8], ip
+ vst1.64 {d7}, [r8], ip
+ subs r3, r3, #4
+ popeq {r4-r8,pc}
+ cmp r3, #4
+ add r0, r0, #8
+ bge 5b
+
+ @ 2 channels
+4: cmp r3, #2
+ blt 4f
+ ldmia r1!, {r4-r5}
+ mov lr, r2
+ mov r8, r0
+ tst lr, #8
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vld1.64 {d20-d21},[r4,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vld1.64 {d22-d23},[r5,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ beq 6f
+ subs lr, lr, #8
+ beq 7f
+ vsri.32 d18, d16, #16
+ vsri.32 d19, d17, #16
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vst1.32 {d18[0]}, [r8], ip
+ vsri.32 d22, d20, #16
+ vst1.32 {d18[1]}, [r8], ip
+ vsri.32 d23, d21, #16
+ vst1.32 {d19[0]}, [r8], ip
+ vst1.32 {d19[1]}, [r8], ip
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.32 {d22[0]}, [r8], ip
+ vst1.32 {d22[1]}, [r8], ip
+ vld1.64 {d20-d21},[r4,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vst1.32 {d23[0]}, [r8], ip
+ vst1.32 {d23[1]}, [r8], ip
+ vld1.64 {d22-d23},[r5,:128]!
+ vcvt.s32.f32 q11, q11, #16
+6: subs lr, lr, #16
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vsri.32 d18, d16, #16
+ vld1.64 {d2-d3}, [r5,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ vsri.32 d19, d17, #16
+ vld1.64 {d4-d5}, [r4,:128]!
+ vcvt.s32.f32 q2, q2, #16
+ vld1.64 {d6-d7}, [r5,:128]!
+ vcvt.s32.f32 q3, q3, #16
+ vst1.32 {d18[0]}, [r8], ip
+ vsri.32 d22, d20, #16
+ vst1.32 {d18[1]}, [r8], ip
+ vsri.32 d23, d21, #16
+ vst1.32 {d19[0]}, [r8], ip
+ vsri.32 d2, d0, #16
+ vst1.32 {d19[1]}, [r8], ip
+ vsri.32 d3, d1, #16
+ vst1.32 {d22[0]}, [r8], ip
+ vsri.32 d6, d4, #16
+ vst1.32 {d22[1]}, [r8], ip
+ vsri.32 d7, d5, #16
+ vst1.32 {d23[0]}, [r8], ip
+ vst1.32 {d23[1]}, [r8], ip
+ beq 6f
+ vld1.64 {d16-d17},[r4,:128]!
+ vcvt.s32.f32 q8, q8, #16
+ vst1.32 {d2[0]}, [r8], ip
+ vst1.32 {d2[1]}, [r8], ip
+ vld1.64 {d18-d19},[r5,:128]!
+ vcvt.s32.f32 q9, q9, #16
+ vst1.32 {d3[0]}, [r8], ip
+ vst1.32 {d3[1]}, [r8], ip
+ vld1.64 {d20-d21},[r4,:128]!
+ vcvt.s32.f32 q10, q10, #16
+ vst1.32 {d6[0]}, [r8], ip
+ vst1.32 {d6[1]}, [r8], ip
+ vld1.64 {d22-d23},[r5,:128]!
+ vcvt.s32.f32 q11, q11, #16
+ vst1.32 {d7[0]}, [r8], ip
+ vst1.32 {d7[1]}, [r8], ip
+ bgt 6b
+6: vst1.32 {d2[0]}, [r8], ip
+ vst1.32 {d2[1]}, [r8], ip
+ vst1.32 {d3[0]}, [r8], ip
+ vst1.32 {d3[1]}, [r8], ip
+ vst1.32 {d6[0]}, [r8], ip
+ vst1.32 {d6[1]}, [r8], ip
+ vst1.32 {d7[0]}, [r8], ip
+ vst1.32 {d7[1]}, [r8], ip
+ b 8f
+7: vsri.32 d18, d16, #16
+ vsri.32 d19, d17, #16
+ vst1.32 {d18[0]}, [r8], ip
+ vsri.32 d22, d20, #16
+ vst1.32 {d18[1]}, [r8], ip
+ vsri.32 d23, d21, #16
+ vst1.32 {d19[0]}, [r8], ip
+ vst1.32 {d19[1]}, [r8], ip
+ vst1.32 {d22[0]}, [r8], ip
+ vst1.32 {d22[1]}, [r8], ip
+ vst1.32 {d23[0]}, [r8], ip
+ vst1.32 {d23[1]}, [r8], ip
+8: subs r3, r3, #2
+ add r0, r0, #4
+ popeq {r4-r8,pc}
+
+ @ 1 channel
+4: ldr r4, [r1],#4
+ tst r2, #8
+ mov lr, r2
+ mov r5, r0
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r4,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ bne 8f
+6: subs lr, lr, #16
+ vld1.64 {d4-d5}, [r4,:128]!
+ vcvt.s32.f32 q2, q2, #16
+ vld1.64 {d6-d7}, [r4,:128]!
+ vcvt.s32.f32 q3, q3, #16
+ vst1.16 {d0[1]}, [r5,:16], ip
+ vst1.16 {d0[3]}, [r5,:16], ip
+ vst1.16 {d1[1]}, [r5,:16], ip
+ vst1.16 {d1[3]}, [r5,:16], ip
+ vst1.16 {d2[1]}, [r5,:16], ip
+ vst1.16 {d2[3]}, [r5,:16], ip
+ vst1.16 {d3[1]}, [r5,:16], ip
+ vst1.16 {d3[3]}, [r5,:16], ip
+ beq 7f
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r4,:128]!
+ vcvt.s32.f32 q1, q1, #16
+7: vst1.16 {d4[1]}, [r5,:16], ip
+ vst1.16 {d4[3]}, [r5,:16], ip
+ vst1.16 {d5[1]}, [r5,:16], ip
+ vst1.16 {d5[3]}, [r5,:16], ip
+ vst1.16 {d6[1]}, [r5,:16], ip
+ vst1.16 {d6[3]}, [r5,:16], ip
+ vst1.16 {d7[1]}, [r5,:16], ip
+ vst1.16 {d7[3]}, [r5,:16], ip
+ bgt 6b
+ pop {r4-r8,pc}
+8: subs lr, lr, #8
+ vst1.16 {d0[1]}, [r5,:16], ip
+ vst1.16 {d0[3]}, [r5,:16], ip
+ vst1.16 {d1[1]}, [r5,:16], ip
+ vst1.16 {d1[3]}, [r5,:16], ip
+ vst1.16 {d2[1]}, [r5,:16], ip
+ vst1.16 {d2[3]}, [r5,:16], ip
+ vst1.16 {d3[1]}, [r5,:16], ip
+ vst1.16 {d3[3]}, [r5,:16], ip
+ popeq {r4-r8,pc}
+ vld1.64 {d0-d1}, [r4,:128]!
+ vcvt.s32.f32 q0, q0, #16
+ vld1.64 {d2-d3}, [r4,:128]!
+ vcvt.s32.f32 q1, q1, #16
+ b 6b
+endfunc
+
+function ff_int32_to_float_fmul_scalar_neon, export=1
+VFP vdup.32 q0, d0[0]
+VFP len .req r2
+NOVFP vdup.32 q0, r2
+NOVFP len .req r3
+
+ vld1.32 {q1},[r1,:128]!
+ vcvt.f32.s32 q3, q1
+ vld1.32 {q2},[r1,:128]!
+ vcvt.f32.s32 q8, q2
+1: subs len, len, #8
+ pld [r1, #16]
+ vmul.f32 q9, q3, q0
+ vmul.f32 q10, q8, q0
+ beq 2f
+ vld1.32 {q1},[r1,:128]!
+ vcvt.f32.s32 q3, q1
+ vld1.32 {q2},[r1,:128]!
+ vcvt.f32.s32 q8, q2
+ vst1.32 {q9}, [r0,:128]!
+ vst1.32 {q10},[r0,:128]!
+ b 1b
+2: vst1.32 {q9}, [r0,:128]!
+ vst1.32 {q10},[r0,:128]!
+ bx lr
+ .unreq len
+endfunc
diff --git a/lib/ffmpeg/libavcodec/arm/fmtconvert_vfp.S b/lib/ffmpeg/libavcodec/arm/fmtconvert_vfp.S
new file mode 100644
index 0000000000..1d19e7758b
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/arm/fmtconvert_vfp.S
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net>
+ *
+ * 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"
+#include "asm.S"
+
+ .syntax unified
+
+/**
+ * ARM VFP optimized float to int16 conversion.
+ * Assume that len is a positive number and is multiple of 8, destination
+ * buffer is at least 4 bytes aligned (8 bytes alignment is better for
+ * performance), little endian byte sex
+ */
+@ void ff_float_to_int16_vfp(int16_t *dst, const float *src, int len)
+function ff_float_to_int16_vfp, export=1
+ push {r4-r8,lr}
+ vpush {d8-d11}
+ vldmia r1!, {s16-s23}
+ vcvt.s32.f32 s0, s16
+ vcvt.s32.f32 s1, s17
+ vcvt.s32.f32 s2, s18
+ vcvt.s32.f32 s3, s19
+ vcvt.s32.f32 s4, s20
+ vcvt.s32.f32 s5, s21
+ vcvt.s32.f32 s6, s22
+ vcvt.s32.f32 s7, s23
+1:
+ subs r2, r2, #8
+ vmov r3, r4, s0, s1
+ vmov r5, r6, s2, s3
+ vmov r7, r8, s4, s5
+ vmov ip, lr, s6, s7
+ vldmiagt r1!, {s16-s23}
+ ssat r4, #16, r4
+ ssat r3, #16, r3
+ ssat r6, #16, r6
+ ssat r5, #16, r5
+ pkhbt r3, r3, r4, lsl #16
+ pkhbt r4, r5, r6, lsl #16
+ vcvtgt.s32.f32 s0, s16
+ vcvtgt.s32.f32 s1, s17
+ vcvtgt.s32.f32 s2, s18
+ vcvtgt.s32.f32 s3, s19
+ vcvtgt.s32.f32 s4, s20
+ vcvtgt.s32.f32 s5, s21
+ vcvtgt.s32.f32 s6, s22
+ vcvtgt.s32.f32 s7, s23
+ ssat r8, #16, r8
+ ssat r7, #16, r7
+ ssat lr, #16, lr
+ ssat ip, #16, ip
+ pkhbt r5, r7, r8, lsl #16
+ pkhbt r6, ip, lr, lsl #16
+ stmia r0!, {r3-r6}
+ bgt 1b
+
+ vpop {d8-d11}
+ pop {r4-r8,pc}
+endfunc
diff --git a/lib/ffmpeg/libavcodec/arm/h264dsp_init_arm.c b/lib/ffmpeg/libavcodec/arm/h264dsp_init_arm.c
index 3955d2c096..e55a9f4646 100644
--- a/lib/ffmpeg/libavcodec/arm/h264dsp_init_arm.c
+++ b/lib/ffmpeg/libavcodec/arm/h264dsp_init_arm.c
@@ -86,6 +86,12 @@ void ff_h264_idct_add8_neon(uint8_t **dest, const int *block_offset,
DCTELEM *block, int stride,
const uint8_t nnzc[6*8]);
+void ff_h264_idct8_add_neon(uint8_t *dst, DCTELEM *block, int stride);
+void ff_h264_idct8_dc_add_neon(uint8_t *dst, DCTELEM *block, int stride);
+void ff_h264_idct8_add4_neon(uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride,
+ const uint8_t nnzc[6*8]);
+
static void ff_h264dsp_init_neon(H264DSPContext *c)
{
c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon;
@@ -116,6 +122,9 @@ static void ff_h264dsp_init_neon(H264DSPContext *c)
c->h264_idct_add16 = ff_h264_idct_add16_neon;
c->h264_idct_add16intra = ff_h264_idct_add16intra_neon;
c->h264_idct_add8 = ff_h264_idct_add8_neon;
+ c->h264_idct8_add = ff_h264_idct8_add_neon;
+ c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
+ c->h264_idct8_add4 = ff_h264_idct8_add4_neon;
}
void ff_h264dsp_init_arm(H264DSPContext *c)
diff --git a/lib/ffmpeg/libavcodec/arm/h264dsp_neon.S b/lib/ffmpeg/libavcodec/arm/h264dsp_neon.S
index d9cdad8e05..bd15ced736 100644
--- a/lib/ffmpeg/libavcodec/arm/h264dsp_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/h264dsp_neon.S
@@ -586,19 +586,17 @@ endfunc
vclt.u8 d26, d26, d22 @ < alpha
vsubw.u8 q2, q2, d2
vdup.8 d22, r3 @ beta
- vclt.s8 d25, d24, #0
vrshrn.i16 d4, q2, #3
vclt.u8 d28, d28, d22 @ < beta
- vbic d26, d26, d25
vclt.u8 d30, d30, d22 @ < beta
- vand d26, d26, d28
- vneg.s8 d25, d24
- vand d26, d26, d30
vmin.s8 d4, d4, d24
- vmovl.u8 q14, d16
- vand d4, d4, d26
+ vneg.s8 d25, d24
+ vand d26, d26, d28
vmax.s8 d4, d4, d25
+ vand d26, d26, d30
vmovl.u8 q11, d0
+ vand d4, d4, d26
+ vmovl.u8 q14, d16
vaddw.s8 q14, q14, d4
vsubw.s8 q11, q11, d4
vqmovun.s16 d16, q14
diff --git a/lib/ffmpeg/libavcodec/arm/h264idct_neon.S b/lib/ffmpeg/libavcodec/arm/h264idct_neon.S
index 0ba48809c4..6b6a669f35 100644
--- a/lib/ffmpeg/libavcodec/arm/h264idct_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/h264idct_neon.S
@@ -150,13 +150,13 @@ function ff_h264_idct_add8_neon, export=1
mov r2, r3
ldr r6, [sp, #32]
movrel r7, scan8+16
- mov ip, #8
+ mov ip, #7
1: ldrb r8, [r7], #1
ldr r0, [r5], #4
ldrb r8, [r6, r8]
tst ip, #4
- addeq r0, r0, r4
- addne r0, r0, r9
+ addne r0, r0, r4
+ addeq r0, r0, r9
cmp r8, #0
ldrsh r8, [r1]
adrne lr, ff_h264_idct_add_neon
@@ -165,10 +165,214 @@ function ff_h264_idct_add8_neon, export=1
blxne lr
subs ip, ip, #1
add r1, r1, #32
- bne 1b
+ bge 1b
pop {r4-r10,pc}
endfunc
+.macro idct8x8_cols pass
+ .if \pass == 0
+ qa .req q2
+ qb .req q14
+ vshr.s16 q2, q10, #1
+ vadd.i16 q0, q8, q12
+ vld1.16 {q14-q15},[r1,:128]!
+ vsub.i16 q1, q8, q12
+ vshr.s16 q3, q14, #1
+ vsub.i16 q2, q2, q14
+ vadd.i16 q3, q3, q10
+ .else
+ qa .req q14
+ qb .req q2
+ vtrn.32 q8, q10
+ vtrn.16 q12, q13
+ vtrn.32 q9, q11
+ vtrn.32 q12, q2
+ vtrn.32 q13, q15
+ vswp d21, d4
+ vshr.s16 q14, q10, #1
+ vswp d17, d24
+ vshr.s16 q3, q2, #1
+ vswp d19, d26
+ vadd.i16 q0, q8, q12
+ vswp d23, d30
+ vsub.i16 q1, q8, q12
+ vsub.i16 q14, q14, q2
+ vadd.i16 q3, q3, q10
+ .endif
+ vadd.i16 q10, q1, qa
+ vsub.i16 q12, q1, qa
+ vadd.i16 q8, q0, q3
+ vsub.i16 qb, q0, q3
+ vsub.i16 q0, q13, q11
+ vadd.i16 q1, q15, q9
+ vsub.i16 qa, q15, q9
+ vadd.i16 q3, q13, q11
+ vsub.i16 q0, q0, q15
+ vsub.i16 q1, q1, q11
+ vadd.i16 qa, qa, q13
+ vadd.i16 q3, q3, q9
+ vshr.s16 q9, q9, #1
+ vshr.s16 q11, q11, #1
+ vshr.s16 q13, q13, #1
+ vshr.s16 q15, q15, #1
+ vsub.i16 q0, q0, q15
+ vsub.i16 q1, q1, q11
+ vadd.i16 qa, qa, q13
+ vadd.i16 q3, q3, q9
+ vshr.s16 q9, q0, #2
+ vshr.s16 q11, q1, #2
+ vshr.s16 q13, qa, #2
+ vshr.s16 q15, q3, #2
+ vsub.i16 q3, q3, q9
+ vsub.i16 qa, q11, qa
+ vadd.i16 q1, q1, q13
+ vadd.i16 q0, q0, q15
+ .if \pass == 0
+ vsub.i16 q15, q8, q3
+ vadd.i16 q8, q8, q3
+ vadd.i16 q9, q10, q2
+ vsub.i16 q2, q10, q2
+ vtrn.16 q8, q9
+ vadd.i16 q10, q12, q1
+ vtrn.16 q2, q15
+ vadd.i16 q11, q14, q0
+ vsub.i16 q13, q12, q1
+ vtrn.16 q10, q11
+ vsub.i16 q12, q14, q0
+ .else
+ vsub.i16 q15, q8, q3
+ vadd.i16 q8, q8, q3
+ vadd.i16 q9, q10, q14
+ vsub.i16 q14, q10, q14
+ vadd.i16 q10, q12, q1
+ vsub.i16 q13, q12, q1
+ vadd.i16 q11, q2, q0
+ vsub.i16 q12, q2, q0
+ .endif
+ .unreq qa
+ .unreq qb
+.endm
+
+function ff_h264_idct8_add_neon, export=1
+ vld1.16 {q8-q9}, [r1,:128]!
+ vld1.16 {q10-q11},[r1,:128]!
+ vld1.16 {q12-q13},[r1,:128]!
+
+ idct8x8_cols 0
+ idct8x8_cols 1
+
+ mov r3, r0
+ vrshr.s16 q8, q8, #6
+ vld1.8 {d0}, [r0,:64], r2
+ vrshr.s16 q9, q9, #6
+ vld1.8 {d1}, [r0,:64], r2
+ vrshr.s16 q10, q10, #6
+ vld1.8 {d2}, [r0,:64], r2
+ vrshr.s16 q11, q11, #6
+ vld1.8 {d3}, [r0,:64], r2
+ vrshr.s16 q12, q12, #6
+ vld1.8 {d4}, [r0,:64], r2
+ vrshr.s16 q13, q13, #6
+ vld1.8 {d5}, [r0,:64], r2
+ vrshr.s16 q14, q14, #6
+ vld1.8 {d6}, [r0,:64], r2
+ vrshr.s16 q15, q15, #6
+ vld1.8 {d7}, [r0,:64], r2
+ vaddw.u8 q8, q8, d0
+ vaddw.u8 q9, q9, d1
+ vaddw.u8 q10, q10, d2
+ vqmovun.s16 d0, q8
+ vaddw.u8 q11, q11, d3
+ vqmovun.s16 d1, q9
+ vaddw.u8 q12, q12, d4
+ vqmovun.s16 d2, q10
+ vst1.8 {d0}, [r3,:64], r2
+ vaddw.u8 q13, q13, d5
+ vqmovun.s16 d3, q11
+ vst1.8 {d1}, [r3,:64], r2
+ vaddw.u8 q14, q14, d6
+ vqmovun.s16 d4, q12
+ vst1.8 {d2}, [r3,:64], r2
+ vaddw.u8 q15, q15, d7
+ vqmovun.s16 d5, q13
+ vst1.8 {d3}, [r3,:64], r2
+ vqmovun.s16 d6, q14
+ vqmovun.s16 d7, q15
+ vst1.8 {d4}, [r3,:64], r2
+ vst1.8 {d5}, [r3,:64], r2
+ vst1.8 {d6}, [r3,:64], r2
+ vst1.8 {d7}, [r3,:64], r2
+
+ sub r1, r1, #128
+ bx lr
+endfunc
+
+function ff_h264_idct8_dc_add_neon, export=1
+ vld1.16 {d30[],d31[]},[r1,:16]
+ vld1.32 {d0}, [r0,:64], r2
+ vrshr.s16 q15, q15, #6
+ vld1.32 {d1}, [r0,:64], r2
+ vld1.32 {d2}, [r0,:64], r2
+ vaddw.u8 q8, q15, d0
+ vld1.32 {d3}, [r0,:64], r2
+ vaddw.u8 q9, q15, d1
+ vld1.32 {d4}, [r0,:64], r2
+ vaddw.u8 q10, q15, d2
+ vld1.32 {d5}, [r0,:64], r2
+ vaddw.u8 q11, q15, d3
+ vld1.32 {d6}, [r0,:64], r2
+ vaddw.u8 q12, q15, d4
+ vld1.32 {d7}, [r0,:64], r2
+ vaddw.u8 q13, q15, d5
+ vaddw.u8 q14, q15, d6
+ vaddw.u8 q15, q15, d7
+ vqmovun.s16 d0, q8
+ vqmovun.s16 d1, q9
+ vqmovun.s16 d2, q10
+ vqmovun.s16 d3, q11
+ sub r0, r0, r2, lsl #3
+ vst1.32 {d0}, [r0,:64], r2
+ vqmovun.s16 d4, q12
+ vst1.32 {d1}, [r0,:64], r2
+ vqmovun.s16 d5, q13
+ vst1.32 {d2}, [r0,:64], r2
+ vqmovun.s16 d6, q14
+ vst1.32 {d3}, [r0,:64], r2
+ vqmovun.s16 d7, q15
+ vst1.32 {d4}, [r0,:64], r2
+ vst1.32 {d5}, [r0,:64], r2
+ vst1.32 {d6}, [r0,:64], r2
+ vst1.32 {d7}, [r0,:64], r2
+ bx lr
+endfunc
+
+function ff_h264_idct8_add4_neon, export=1
+ push {r4-r8,lr}
+ mov r4, r0
+ mov r5, r1
+ mov r1, r2
+ mov r2, r3
+ ldr r6, [sp, #24]
+ movrel r7, scan8
+ mov r12, #16
+1: ldrb r8, [r7], #4
+ ldr r0, [r5], #16
+ ldrb r8, [r6, r8]
+ subs r8, r8, #1
+ blt 2f
+ ldrsh lr, [r1]
+ add r0, r0, r4
+ movne lr, #0
+ cmp lr, #0
+ adrne lr, ff_h264_idct8_dc_add_neon
+ adreq lr, ff_h264_idct8_add_neon
+ blx lr
+2: subs r12, r12, #4
+ add r1, r1, #128
+ bne 1b
+ pop {r4-r8,pc}
+endfunc
+
.section .rodata
scan8: .byte 4+1*8, 5+1*8, 4+2*8, 5+2*8
.byte 6+1*8, 7+1*8, 6+2*8, 7+2*8
diff --git a/lib/ffmpeg/libavcodec/arm/h264pred_neon.S b/lib/ffmpeg/libavcodec/arm/h264pred_neon.S
index e2c69e1054..63c96ee725 100644
--- a/lib/ffmpeg/libavcodec/arm/h264pred_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/h264pred_neon.S
@@ -131,8 +131,8 @@ function ff_pred16x16_plane_neon, export=1
vadd.i16 d5, d6, d7
vpadd.i16 d4, d4, d5
vpadd.i16 d4, d4, d4
- vshl.i16 d5, d4, #2
- vaddl.s16 q2, d4, d5
+ vshll.s16 q3, d4, #2
+ vaddw.s16 q2, q3, d4
vrshrn.s32 d4, q2, #6
mov r3, #0
vtrn.16 d4, d5
diff --git a/lib/ffmpeg/libavcodec/arm/mpegvideo_iwmmxt.c b/lib/ffmpeg/libavcodec/arm/mpegvideo_iwmmxt.c
index 9e3878fa57..0a288630ab 100644
--- a/lib/ffmpeg/libavcodec/arm/mpegvideo_iwmmxt.c
+++ b/lib/ffmpeg/libavcodec/arm/mpegvideo_iwmmxt.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h"
@@ -111,7 +112,7 @@ static void dct_unquantize_h263_inter_iwmmxt(MpegEncContext *s,
void MPV_common_init_iwmmxt(MpegEncContext *s)
{
- if (!(mm_flags & FF_MM_IWMMXT)) return;
+ if (!(mm_flags & AV_CPU_FLAG_IWMMXT)) return;
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt;
#if 0
diff --git a/lib/ffmpeg/libavcodec/arm/mpegvideo_neon.S b/lib/ffmpeg/libavcodec/arm/mpegvideo_neon.S
index b25ead4941..b695fb7c22 100644
--- a/lib/ffmpeg/libavcodec/arm/mpegvideo_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/mpegvideo_neon.S
@@ -22,10 +22,9 @@
#include "asm-offsets.h"
function ff_dct_unquantize_h263_inter_neon, export=1
- add r0, r0, #0x2200
- add r12, r0, #BLOCK_LAST_INDEX-0x2200
+ add r12, r0, #BLOCK_LAST_INDEX
ldr r12, [r12, r2, lsl #2]
- add r0, r0, #INTER_SCANTAB_RASTER_END-0x2200
+ add r0, r0, #INTER_SCANTAB_RASTER_END
ldrb r12, [r0, r12]
sub r2, r3, #1
lsl r0, r3, #1
@@ -75,17 +74,15 @@ endfunc
function ff_dct_unquantize_h263_intra_neon, export=1
push {r4-r6,lr}
+ add r12, r0, #BLOCK_LAST_INDEX
ldr r6, [r0, #AC_PRED]
- add r5, r0, #0x2700
+ add lr, r0, #INTER_SCANTAB_RASTER_END
cmp r6, #0
movne r12, #63
bne 1f
- add lr, r0, #0x2200
- add r12, lr, #BLOCK_LAST_INDEX-0x2200
- add lr, lr, #INTER_SCANTAB_RASTER_END-0x2200
ldr r12, [r12, r2, lsl #2]
ldrb r12, [lr, r12]
-1: ldr r5, [r5, #H263_AIC-0x2700]
+1: ldr r5, [r0, #H263_AIC]
ldrsh r4, [r1]
cmp r5, #0
mov r5, r1
diff --git a/lib/ffmpeg/libavcodec/arm/synth_filter_neon.S b/lib/ffmpeg/libavcodec/arm/synth_filter_neon.S
index a7c23df02b..1464abe562 100644
--- a/lib/ffmpeg/libavcodec/arm/synth_filter_neon.S
+++ b/lib/ffmpeg/libavcodec/arm/synth_filter_neon.S
@@ -42,7 +42,7 @@ VFP vpop {d0}
ldr r5, [sp, #9*4] @ window
ldr r2, [sp, #10*4] @ out
-NOVFP vldr d0, [sp, #12*4] @ scale, bias
+NOVFP vldr s0, [sp, #12*4] @ scale
add r8, r9, #12*4
mov lr, #64*4
@@ -90,10 +90,8 @@ NOVFP vldr d0, [sp, #12*4] @ scale, bias
sub r11, r11, #512*4
b 2b
3:
- vdup.32 q8, d0[1]
- vdup.32 q9, d0[1]
- vmla.f32 q8, q10, d0[0]
- vmla.f32 q9, q1, d0[0]
+ vmul.f32 q8, q10, d0[0]
+ vmul.f32 q9, q1, d0[0]
vst1.32 {q3}, [r3,:128]
sub r3, r3, #16*4
vst1.32 {q2}, [r3,:128]
diff --git a/lib/ffmpeg/libavcodec/ass.c b/lib/ffmpeg/libavcodec/ass.c
new file mode 100644
index 0000000000..0662b8dfdf
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ass.c
@@ -0,0 +1,124 @@
+/*
+ * SSA/ASS common funtions
+ * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
+ *
+ * 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 "ass.h"
+
+/**
+ * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS.
+ *
+ * @param avctx pointer to the AVCodecContext
+ * @param font name of the default font face to use
+ * @param font_size default font size to use
+ * @param color default text color to use (ABGR)
+ * @param back_color default background color to use (ABGR)
+ * @param bold 1 for bold text, 0 for normal text
+ * @param italic 1 for italic text, 0 for normal text
+ * @param underline 1 for underline text, 0 for normal text
+ * @param alignment position of the text (left, center, top...), defined after
+ * the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top)
+ * @return >= 0 on success otherwise an error code <0
+ */
+static int ff_ass_subtitle_header(AVCodecContext *avctx,
+ const char *font, int font_size,
+ int color, int back_color,
+ int bold, int italic, int underline,
+ int alignment)
+{
+ char header[512];
+
+ snprintf(header, sizeof(header),
+ "[Script Info]\r\n"
+ "ScriptType: v4.00+\r\n"
+ "\r\n"
+ "[V4+ Styles]\r\n"
+ "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\r\n"
+ "Style: Default,%s,%d,&H%x,&H%x,&H%x,&H%x,%d,%d,%d,1,1,0,%d,10,10,10,0,0\r\n"
+ "\r\n"
+ "[Events]\r\n"
+ "Format: Layer, Start, End, Text\r\n",
+ font, font_size, color, color, back_color, back_color,
+ -bold, -italic, -underline, alignment);
+
+ avctx->subtitle_header = av_strdup(header);
+ if (!avctx->subtitle_header)
+ return AVERROR(ENOMEM);
+ avctx->subtitle_header_size = strlen(avctx->subtitle_header);
+ return 0;
+}
+
+int ff_ass_subtitle_header_default(AVCodecContext *avctx)
+{
+ return ff_ass_subtitle_header(avctx, ASS_DEFAULT_FONT,
+ ASS_DEFAULT_FONT_SIZE,
+ ASS_DEFAULT_COLOR,
+ ASS_DEFAULT_BACK_COLOR,
+ ASS_DEFAULT_BOLD,
+ ASS_DEFAULT_ITALIC,
+ ASS_DEFAULT_UNDERLINE,
+ ASS_DEFAULT_ALIGNMENT);
+}
+
+void ff_ass_init(AVSubtitle *sub)
+{
+ memset(sub, 0, sizeof(*sub));
+}
+
+static int ts_to_string(char *str, int strlen, int ts)
+{
+ int h, m, s;
+ h = ts/360000; ts -= 360000*h;
+ m = ts/ 6000; ts -= 6000*m;
+ s = ts/ 100; ts -= 100*s;
+ return snprintf(str, strlen, "%d:%02d:%02d.%02d", h, m, s, ts);
+}
+
+int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
+ int ts_start, int ts_end, int raw)
+{
+ int len = 0, dlen, duration = ts_end - ts_start;
+ char s_start[16], s_end[16], header[48] = {0};
+ AVSubtitleRect **rects;
+
+ if (!raw) {
+ ts_to_string(s_start, sizeof(s_start), ts_start);
+ ts_to_string(s_end, sizeof(s_end), ts_end );
+ len = snprintf(header, sizeof(header), "Dialogue: 0,%s,%s,",
+ s_start, s_end);
+ }
+
+ dlen = strcspn(dialog, "\n");
+ dlen += dialog[dlen] == '\n';
+
+ rects = av_realloc(sub->rects, (sub->num_rects+1) * sizeof(*sub->rects));
+ if (!rects)
+ return AVERROR(ENOMEM);
+ sub->rects = rects;
+ sub->end_display_time = FFMAX(sub->end_display_time, 10 * duration);
+ rects[sub->num_rects] = av_mallocz(sizeof(*rects[0]));
+ rects[sub->num_rects]->type = SUBTITLE_ASS;
+ rects[sub->num_rects]->ass = av_malloc(len + dlen + 1);
+ strcpy (rects[sub->num_rects]->ass , header);
+ strncpy(rects[sub->num_rects]->ass + len, dialog, dlen);
+ rects[sub->num_rects]->ass[len+dlen] = 0;
+ sub->num_rects++;
+ return dlen;
+}
diff --git a/lib/ffmpeg/libavcodec/ass.h b/lib/ffmpeg/libavcodec/ass.h
new file mode 100644
index 0000000000..f29a7c4697
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ass.h
@@ -0,0 +1,77 @@
+/*
+ * SSA/ASS common funtions
+ * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
+ *
+ * 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_ASS_H
+#define AVCODEC_ASS_H
+
+#include "avcodec.h"
+
+/**
+ * Default values for ASS style.
+ * @defgroup ass_default
+ * @{
+ */
+#define ASS_DEFAULT_FONT "Arial"
+#define ASS_DEFAULT_FONT_SIZE 16
+#define ASS_DEFAULT_COLOR 0xffffff
+#define ASS_DEFAULT_BACK_COLOR 0
+#define ASS_DEFAULT_BOLD 0
+#define ASS_DEFAULT_ITALIC 0
+#define ASS_DEFAULT_UNDERLINE 0
+#define ASS_DEFAULT_ALIGNMENT 2
+/** @} */
+
+/**
+ * Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS
+ * with default style.
+ *
+ * @param avctx pointer to the AVCodecContext
+ * @return >= 0 on success otherwise an error code <0
+ */
+int ff_ass_subtitle_header_default(AVCodecContext *avctx);
+
+/**
+ * Initialize an AVSubtitle structure for use with ff_ass_add_rect().
+ *
+ * @param sub pointer to the AVSubtitle
+ */
+void ff_ass_init(AVSubtitle *sub);
+
+/**
+ * Add an ASS dialog line to an AVSubtitle as a new AVSubtitleRect.
+ *
+ * @param sub pointer to the AVSubtitle
+ * @param dialog ASS dialog to add to sub
+ * @param ts_start start timestamp for this dialog (in 1/100 second unit)
+ * @param ts_end end timestamp for this dialog (in 1/100 second unit)
+ * @param raw when set to 1, it indicates that dialog contains a whole ASS
+ * dialog line which should be copied as is.
+ * when set to 0, it indicates that dialog contains only the Text
+ * part of the ASS dialog line, the rest of the line
+ * will be generated.
+ * @return number of characters read from dialog. It can be less than the whole
+ * length of dialog, if dialog contains several lines of text.
+ * A negative value indicates an error.
+ */
+int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
+ int ts_start, int ts_end, int raw);
+
+#endif /* AVCODEC_ASS_H */
diff --git a/lib/ffmpeg/libavcodec/assdec.c b/lib/ffmpeg/libavcodec/assdec.c
new file mode 100644
index 0000000000..c1ad0c4af4
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/assdec.c
@@ -0,0 +1,62 @@
+/*
+ * SSA/ASS decoder
+ * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
+ *
+ * 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 "ass.h"
+
+static av_cold int ass_decode_init(AVCodecContext *avctx)
+{
+ avctx->subtitle_header = av_malloc(avctx->extradata_size);
+ if (!avctx->extradata)
+ return AVERROR(ENOMEM);
+ memcpy(avctx->subtitle_header, avctx->extradata, avctx->extradata_size);
+ avctx->subtitle_header_size = avctx->extradata_size;
+ return 0;
+}
+
+static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr,
+ AVPacket *avpkt)
+{
+ const char *ptr = avpkt->data;
+ int len, size = avpkt->size;
+
+ ff_ass_init(data);
+
+ while (size > 0) {
+ len = ff_ass_add_rect(data, ptr, 0, 0/* FIXME: duration */, 1);
+ if (len < 0)
+ return len;
+ ptr += len;
+ size -= len;
+ }
+
+ *got_sub_ptr = avpkt->size > 0;
+ return avpkt->size;
+}
+
+AVCodec ff_ass_decoder = {
+ .name = "ass",
+ .long_name = NULL_IF_CONFIG_SMALL("Advanced SubStation Alpha subtitle"),
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ .id = CODEC_ID_SSA,
+ .init = ass_decode_init,
+ .decode = ass_decode_frame,
+};
diff --git a/lib/ffmpeg/libavcodec/assenc.c b/lib/ffmpeg/libavcodec/assenc.c
new file mode 100644
index 0000000000..103f2ff276
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/assenc.c
@@ -0,0 +1,67 @@
+/*
+ * SSA/ASS encoder
+ * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
+ *
+ * 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 "libavutil/avstring.h"
+
+static av_cold int ass_encode_init(AVCodecContext *avctx)
+{
+ avctx->extradata = av_malloc(avctx->subtitle_header_size);
+ if (!avctx->extradata)
+ return AVERROR(ENOMEM);
+ memcpy(avctx->extradata, avctx->subtitle_header, avctx->subtitle_header_size);
+ avctx->extradata_size = avctx->subtitle_header_size;
+ return 0;
+}
+
+static int ass_encode_frame(AVCodecContext *avctx,
+ unsigned char *buf, int bufsize, void *data)
+{
+ AVSubtitle *sub = data;
+ int i, len, total_len = 0;
+
+ for (i=0; i<sub->num_rects; i++) {
+ if (sub->rects[i]->type != SUBTITLE_ASS) {
+ av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
+ return -1;
+ }
+
+ len = av_strlcpy(buf+total_len, sub->rects[i]->ass, bufsize-total_len);
+
+ if (len > bufsize-total_len-1) {
+ av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
+ return -1;
+ }
+
+ total_len += len;
+ }
+
+ return total_len;
+}
+
+AVCodec ff_ass_encoder = {
+ .name = "ass",
+ .long_name = NULL_IF_CONFIG_SMALL("Advanced SubStation Alpha subtitle"),
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ .id = CODEC_ID_SSA,
+ .init = ass_encode_init,
+ .encode = ass_encode_frame,
+};
diff --git a/lib/ffmpeg/libavcodec/asv1.c b/lib/ffmpeg/libavcodec/asv1.c
index 6b1a0935ae..d2005fff60 100644
--- a/lib/ffmpeg/libavcodec/asv1.c
+++ b/lib/ffmpeg/libavcodec/asv1.c
@@ -613,7 +613,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec asv1_decoder = {
+AVCodec ff_asv1_decoder = {
"asv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ASV1,
@@ -626,7 +626,7 @@ AVCodec asv1_decoder = {
.long_name= NULL_IF_CONFIG_SMALL("ASUS V1"),
};
-AVCodec asv2_decoder = {
+AVCodec ff_asv2_decoder = {
"asv2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ASV2,
@@ -640,7 +640,7 @@ AVCodec asv2_decoder = {
};
#if CONFIG_ASV1_ENCODER
-AVCodec asv1_encoder = {
+AVCodec ff_asv1_encoder = {
"asv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ASV1,
@@ -654,7 +654,7 @@ AVCodec asv1_encoder = {
#endif
#if CONFIG_ASV2_ENCODER
-AVCodec asv2_encoder = {
+AVCodec ff_asv2_encoder = {
"asv2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ASV2,
diff --git a/lib/ffmpeg/libavcodec/atrac.c b/lib/ffmpeg/libavcodec/atrac.c
index e398cee7b8..6c1b1f19ce 100644
--- a/lib/ffmpeg/libavcodec/atrac.c
+++ b/lib/ffmpeg/libavcodec/atrac.c
@@ -32,8 +32,8 @@
#include "dsputil.h"
#include "atrac.h"
-float sf_table[64];
-float qmf_window[48];
+float ff_atrac_sf_table[64];
+static float qmf_window[48];
static const float qmf_48tap_half[24] = {
-0.00001461907, -0.00009205479,-0.000056157569,0.00030117269,
@@ -54,9 +54,9 @@ void atrac_generate_tables(void)
float s;
/* Generate scale factors */
- if (!sf_table[63])
+ if (!ff_atrac_sf_table[63])
for (i=0 ; i<64 ; i++)
- sf_table[i] = pow(2.0, (i - 15) / 3.0);
+ ff_atrac_sf_table[i] = pow(2.0, (i - 15) / 3.0);
/* Generate the QMF window. */
if (!qmf_window[47])
diff --git a/lib/ffmpeg/libavcodec/atrac.h b/lib/ffmpeg/libavcodec/atrac.h
index 0732da0740..e126935e12 100644
--- a/lib/ffmpeg/libavcodec/atrac.h
+++ b/lib/ffmpeg/libavcodec/atrac.h
@@ -28,9 +28,7 @@
#ifndef AVCODEC_ATRAC_H
#define AVCODEC_ATRAC_H
-
-extern float sf_table[64];
-extern float qmf_window[48];
+extern float ff_atrac_sf_table[64];
void atrac_generate_tables(void);
void atrac_iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp);
diff --git a/lib/ffmpeg/libavcodec/atrac1.c b/lib/ffmpeg/libavcodec/atrac1.c
index 5ff8816476..be78445b8f 100644
--- a/lib/ffmpeg/libavcodec/atrac1.c
+++ b/lib/ffmpeg/libavcodec/atrac1.c
@@ -141,7 +141,7 @@ static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
/* overlap and window */
q->dsp.vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
- &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 0, 16);
+ &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
prev_buf = &su->spectrum[0][ref_pos+start_pos + 16];
start_pos += block_size;
@@ -223,7 +223,7 @@ static int at1_unpack_dequant(GetBitContext* gb, AT1SUCtx* su,
int num_specs = specs_per_bfu[bfu_num];
int word_len = !!idwls[bfu_num] + idwls[bfu_num];
- float scale_factor = sf_table[idsfs[bfu_num]];
+ float scale_factor = ff_atrac_sf_table[idsfs[bfu_num]];
bits_used += word_len * num_specs; /* add number of bits consumed by current BFU */
/* check for bitstream overflow */
@@ -326,7 +326,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
{
AT1Ctx *q = avctx->priv_data;
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
q->channels = avctx->channels;
@@ -365,7 +365,7 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx) {
}
-AVCodec atrac1_decoder = {
+AVCodec ff_atrac1_decoder = {
.name = "atrac1",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_ATRAC1,
diff --git a/lib/ffmpeg/libavcodec/atrac3.c b/lib/ffmpeg/libavcodec/atrac3.c
index c29fb19252..3d1f990164 100644
--- a/lib/ffmpeg/libavcodec/atrac3.c
+++ b/lib/ffmpeg/libavcodec/atrac3.c
@@ -118,13 +118,14 @@ typedef struct {
int scrambled_stream;
int frame_factor;
//@}
+
+ FFTContext mdct_ctx;
} ATRAC3Context;
static DECLARE_ALIGNED(16, float,mdct_window)[512];
static VLC spectral_coeff_tab[7];
static float gain_tab1[16];
static float gain_tab2[31];
-static FFTContext mdct_ctx;
static DSPContext dsp;
@@ -137,7 +138,7 @@ static DSPContext dsp;
* @param odd_band 1 if the band is an odd band
*/
-static void IMLT(float *pInput, float *pOutput, int odd_band)
+static void IMLT(ATRAC3Context *q, float *pInput, float *pOutput, int odd_band)
{
int i;
@@ -155,10 +156,10 @@ static void IMLT(float *pInput, float *pOutput, int odd_band)
FFSWAP(float, pInput[i], pInput[255-i]);
}
- ff_imdct_calc(&mdct_ctx,pOutput,pInput);
+ ff_imdct_calc(&q->mdct_ctx,pOutput,pInput);
/* Perform windowing on the output. */
- dsp.vector_fmul(pOutput,mdct_window,512);
+ dsp.vector_fmul(pOutput, pOutput, mdct_window, 512);
}
@@ -207,7 +208,7 @@ static av_cold void init_atrac3_transforms(ATRAC3Context *q) {
}
/* Initialize the MDCT transform. */
- ff_mdct_init(&mdct_ctx, 9, 1, 1.0);
+ ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0);
}
/**
@@ -220,6 +221,7 @@ static av_cold int atrac3_decode_close(AVCodecContext *avctx)
av_free(q->pUnits);
av_free(q->decoded_bytes_buffer);
+ ff_mdct_end(&q->mdct_ctx);
return 0;
}
@@ -325,7 +327,7 @@ static int decodeSpectrum (GetBitContext *gb, float *pOut)
readQuantSpectralCoeffs (gb, subband_vlc_index[cnt], codingMode, mantissas, subbWidth);
/* Decode the scale factor for this subband. */
- SF = sf_table[SF_idxs[cnt]] * iMaxQuant[subband_vlc_index[cnt]];
+ SF = ff_atrac_sf_table[SF_idxs[cnt]] * iMaxQuant[subband_vlc_index[cnt]];
/* Inverse quantize the coefficients. */
for (pIn=mantissas ; first<last; first++, pIn++)
@@ -398,7 +400,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
coded_values = coded_values_per_component + 1;
coded_values = FFMIN(max_coded_values,coded_values);
- scalefactor = sf_table[sfIndx] * iMaxQuant[quant_step_index];
+ scalefactor = ff_atrac_sf_table[sfIndx] * iMaxQuant[quant_step_index];
readQuantSpectralCoeffs(gb, quant_step_index, coding_mode, mantissa, coded_values);
@@ -694,7 +696,7 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_
for (band=0; band<4; band++) {
/* Perform the IMDCT step without overlapping. */
if (band <= numBands) {
- IMLT(&(pSnd->spectrum[band*256]), pSnd->IMDCT_buf, band&1);
+ IMLT(q, &(pSnd->spectrum[band*256]), pSnd->IMDCT_buf, band&1);
} else
memset(pSnd->IMDCT_buf, 0, 512 * sizeof(float));
@@ -825,8 +827,12 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
const uint8_t* databuf;
int16_t* samples = data;
- if (buf_size < avctx->block_align)
+ if (buf_size < avctx->block_align) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Frame too small (%d bytes). Truncated file?\n", buf_size);
+ *data_size = 0;
return buf_size;
+ }
/* Check if we need to descramble and what buffer to pass on. */
if (q->scrambled_stream) {
@@ -1008,12 +1014,12 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
-AVCodec atrac3_decoder =
+AVCodec ff_atrac3_decoder =
{
.name = "atrac3",
.type = AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/audioconvert.c b/lib/ffmpeg/libavcodec/audioconvert.c
index d022bc9ee3..b29b030644 100644
--- a/lib/ffmpeg/libavcodec/audioconvert.c
+++ b/lib/ffmpeg/libavcodec/audioconvert.c
@@ -27,145 +27,65 @@
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
+#include "libavcore/samplefmt.h"
#include "avcodec.h"
#include "audioconvert.h"
-typedef struct SampleFmtInfo {
- const char *name;
- int bits;
-} SampleFmtInfo;
-
-/** this table gives more information about formats */
-static const SampleFmtInfo sample_fmt_info[SAMPLE_FMT_NB] = {
- [SAMPLE_FMT_U8] = { .name = "u8", .bits = 8 },
- [SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 },
- [SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 },
- [SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 },
- [SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 },
-};
-
+#if FF_API_OLD_SAMPLE_FMT
const char *avcodec_get_sample_fmt_name(int sample_fmt)
{
- if (sample_fmt < 0 || sample_fmt >= SAMPLE_FMT_NB)
- return NULL;
- return sample_fmt_info[sample_fmt].name;
+ return av_get_sample_fmt_name(sample_fmt);
}
-enum SampleFormat avcodec_get_sample_fmt(const char* name)
+enum AVSampleFormat avcodec_get_sample_fmt(const char* name)
{
- int i;
-
- for (i=0; i < SAMPLE_FMT_NB; i++)
- if (!strcmp(sample_fmt_info[i].name, name))
- return i;
- return SAMPLE_FMT_NONE;
+ return av_get_sample_fmt(name);
}
void avcodec_sample_fmt_string (char *buf, int buf_size, int sample_fmt)
{
- /* print header */
- if (sample_fmt < 0)
- snprintf (buf, buf_size, "name " " depth");
- else if (sample_fmt < SAMPLE_FMT_NB) {
- SampleFmtInfo info= sample_fmt_info[sample_fmt];
- snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits);
- }
-}
-
-static const char* const channel_names[]={
- "FL", "FR", "FC", "LFE", "BL", "BR", "FLC", "FRC",
- "BC", "SL", "SR", "TC", "TFL", "TFC", "TFR", "TBL",
- "TBC", "TBR",
- [29] = "DL",
- [30] = "DR",
-};
-
-static const char *get_channel_name(int channel_id)
-{
- if (channel_id<0 || channel_id>=FF_ARRAY_ELEMS(channel_names))
- return NULL;
- return channel_names[channel_id];
+ av_get_sample_fmt_string(buf, buf_size, sample_fmt);
}
+#endif
int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)
{
switch(nb_channels) {
- case 1: return CH_LAYOUT_MONO;
- case 2: return CH_LAYOUT_STEREO;
- case 3: return CH_LAYOUT_SURROUND;
- case 4: return CH_LAYOUT_QUAD;
- case 5: return CH_LAYOUT_5POINT0;
- case 6: return CH_LAYOUT_5POINT1;
- case 8: return CH_LAYOUT_7POINT1;
+ case 1: return AV_CH_LAYOUT_MONO;
+ case 2: return AV_CH_LAYOUT_STEREO;
+ case 3: return AV_CH_LAYOUT_SURROUND;
+ case 4: return AV_CH_LAYOUT_QUAD;
+ case 5: return AV_CH_LAYOUT_5POINT0;
+ case 6: return AV_CH_LAYOUT_5POINT1;
+ case 8: return AV_CH_LAYOUT_7POINT1;
default: return 0;
}
}
-static const struct {
- const char *name;
- int nb_channels;
- int64_t layout;
-} channel_layout_map[] = {
- { "mono", 1, CH_LAYOUT_MONO },
- { "stereo", 2, CH_LAYOUT_STEREO },
- { "4.0", 4, CH_LAYOUT_4POINT0 },
- { "quad", 4, CH_LAYOUT_QUAD },
- { "5.0", 5, CH_LAYOUT_5POINT0 },
- { "5.0", 5, CH_LAYOUT_5POINT0_BACK },
- { "5.1", 6, CH_LAYOUT_5POINT1 },
- { "5.1", 6, CH_LAYOUT_5POINT1_BACK },
- { "5.1+downmix", 8, CH_LAYOUT_5POINT1|CH_LAYOUT_STEREO_DOWNMIX, },
- { "7.1", 8, CH_LAYOUT_7POINT1 },
- { "7.1(wide)", 8, CH_LAYOUT_7POINT1_WIDE },
- { "7.1+downmix", 10, CH_LAYOUT_7POINT1|CH_LAYOUT_STEREO_DOWNMIX, },
- { 0 }
-};
+#if FF_API_OLD_AUDIOCONVERT
+int64_t avcodec_get_channel_layout(const char *name)
+{
+ return av_get_channel_layout(name);
+}
void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout)
{
- int i;
-
- for (i=0; channel_layout_map[i].name; i++)
- if (nb_channels == channel_layout_map[i].nb_channels &&
- channel_layout == channel_layout_map[i].layout) {
- av_strlcpy(buf, channel_layout_map[i].name, buf_size);
- return;
- }
-
- snprintf(buf, buf_size, "%d channels", nb_channels);
- if (channel_layout) {
- int i,ch;
- av_strlcat(buf, " (", buf_size);
- for(i=0,ch=0; i<64; i++) {
- if ((channel_layout & (1L<<i))) {
- const char *name = get_channel_name(i);
- if (name) {
- if (ch>0) av_strlcat(buf, "|", buf_size);
- av_strlcat(buf, name, buf_size);
- }
- ch++;
- }
- }
- av_strlcat(buf, ")", buf_size);
- }
+ av_get_channel_layout_string(buf, buf_size, nb_channels, channel_layout);
}
int avcodec_channel_layout_num_channels(int64_t channel_layout)
{
- int count;
- uint64_t x = channel_layout;
- for (count = 0; x; count++)
- x &= x-1; // unset lowest set bit
- return count;
+ return av_get_channel_layout_nb_channels(channel_layout);
}
+#endif
struct AVAudioConvert {
int in_channels, out_channels;
int fmt_pair;
};
-AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channels,
- enum SampleFormat in_fmt, int in_channels,
+AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
+ enum AVSampleFormat in_fmt, int in_channels,
const float *matrix, int flags)
{
AVAudioConvert *ctx;
@@ -176,7 +96,7 @@ AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channe
return NULL;
ctx->in_channels = in_channels;
ctx->out_channels = out_channels;
- ctx->fmt_pair = out_fmt + SAMPLE_FMT_NB*in_fmt;
+ ctx->fmt_pair = out_fmt + AV_SAMPLE_FMT_NB*in_fmt;
return ctx;
}
@@ -203,7 +123,7 @@ int av_audio_convert(AVAudioConvert *ctx,
continue;
#define CONV(ofmt, otype, ifmt, expr)\
-if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\
+if(ctx->fmt_pair == ofmt + AV_SAMPLE_FMT_NB*ifmt){\
do{\
*(otype*)po = expr; pi += is; po += os;\
}while(po < end);\
@@ -212,31 +132,31 @@ if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\
//FIXME put things below under ifdefs so we do not waste space for cases no codec will need
//FIXME rounding ?
- CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_U8 , *(const uint8_t*)pi)
- else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<8)
- else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<24)
- else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
- else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
- else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S16, (*(const int16_t*)pi>>8) + 0x80)
- else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S16, *(const int16_t*)pi)
- else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S16, *(const int16_t*)pi<<16)
- else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_S16, *(const int16_t*)pi*(1.0 / (1<<15)))
- else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S16, *(const int16_t*)pi*(1.0 / (1<<15)))
- else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S32, (*(const int32_t*)pi>>24) + 0x80)
- else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S32, *(const int32_t*)pi>>16)
- else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32, *(const int32_t*)pi)
- else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31)))
- else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31)))
- else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, av_clip_uint8( lrintf(*(const float*)pi * (1<<7)) + 0x80))
- else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, av_clip_int16( lrintf(*(const float*)pi * (1<<15))))
- else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float*)pi * (1U<<31))))
- else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_FLT, *(const float*)pi)
- else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_FLT, *(const float*)pi)
- else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, av_clip_uint8( lrint(*(const double*)pi * (1<<7)) + 0x80))
- else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, av_clip_int16( lrint(*(const double*)pi * (1<<15))))
- else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double*)pi * (1U<<31))))
- else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_DBL, *(const double*)pi)
- else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_DBL, *(const double*)pi)
+ CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_U8 , *(const uint8_t*)pi)
+ else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<8)
+ else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<24)
+ else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
+ else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
+ else CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S16, (*(const int16_t*)pi>>8) + 0x80)
+ else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S16, *(const int16_t*)pi)
+ else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t*)pi<<16)
+ else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S16, *(const int16_t*)pi*(1.0 / (1<<15)))
+ else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S16, *(const int16_t*)pi*(1.0 / (1<<15)))
+ else CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S32, (*(const int32_t*)pi>>24) + 0x80)
+ else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S32, *(const int32_t*)pi>>16)
+ else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S32, *(const int32_t*)pi)
+ else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31)))
+ else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31)))
+ else CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8( lrintf(*(const float*)pi * (1<<7)) + 0x80))
+ else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16( lrintf(*(const float*)pi * (1<<15))))
+ else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float*)pi * (1U<<31))))
+ else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_FLT, *(const float*)pi)
+ else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_FLT, *(const float*)pi)
+ else CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8( lrint(*(const double*)pi * (1<<7)) + 0x80))
+ else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16( lrint(*(const double*)pi * (1<<15))))
+ else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double*)pi * (1U<<31))))
+ else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_DBL, *(const double*)pi)
+ else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_DBL, *(const double*)pi)
else return -1;
}
return 0;
diff --git a/lib/ffmpeg/libavcodec/audioconvert.h b/lib/ffmpeg/libavcodec/audioconvert.h
index 81b6cded39..be4867c22e 100644
--- a/lib/ffmpeg/libavcodec/audioconvert.h
+++ b/lib/ffmpeg/libavcodec/audioconvert.h
@@ -29,42 +29,50 @@
*/
+#include "libavutil/cpu.h"
#include "avcodec.h"
-
+#if FF_API_OLD_SAMPLE_FMT
/**
- * Generate string corresponding to the sample format with
- * number sample_fmt, or a header if sample_fmt is negative.
- *
- * @param[in] buf the buffer where to write the string
- * @param[in] buf_size the size of buf
- * @param[in] sample_fmt the number of the sample format to print the corresponding info string, or
- * a negative value to print the corresponding header.
- * Meaningful values for obtaining a sample format info vary from 0 to SAMPLE_FMT_NB -1.
+ * @deprecated Use av_get_sample_fmt_string() instead.
*/
+attribute_deprecated
void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
/**
- * @return NULL on error
+ * @deprecated Use av_get_sample_fmt_name() instead.
*/
+attribute_deprecated
const char *avcodec_get_sample_fmt_name(int sample_fmt);
/**
- * @return SAMPLE_FMT_NONE on error
+ * @deprecated Use av_get_sample_fmt() instead.
*/
-enum SampleFormat avcodec_get_sample_fmt(const char* name);
+attribute_deprecated
+enum AVSampleFormat avcodec_get_sample_fmt(const char* name);
+#endif
+#if FF_API_OLD_AUDIOCONVERT
/**
- * @return NULL on error
+ * @deprecated Use av_get_channel_layout() instead.
*/
-const char *avcodec_get_channel_name(int channel_id);
+attribute_deprecated
+int64_t avcodec_get_channel_layout(const char *name);
/**
- * Return description of channel layout
+ * @deprecated Use av_get_channel_layout_string() instead.
*/
+attribute_deprecated
void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
/**
+ * @deprecated Use av_get_channel_layout_nb_channels() instead.
+ */
+attribute_deprecated
+int avcodec_channel_layout_num_channels(int64_t channel_layout);
+#endif
+
+/**
* Guess the channel layout
* @param nb_channels
* @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
@@ -73,11 +81,6 @@ void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels,
*/
int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
-/**
- * @return the number of channels in the channel layout.
- */
-int avcodec_channel_layout_num_channels(int64_t channel_layout);
-
struct AVAudioConvert;
typedef struct AVAudioConvert AVAudioConvert;
@@ -88,11 +91,11 @@ typedef struct AVAudioConvert AVAudioConvert;
* @param in_fmt Input sample format
* @param in_channels Number of input channels
* @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
- * @param flags See FF_MM_xx
+ * @param flags See AV_CPU_FLAG_xx
* @return NULL on error
*/
-AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channels,
- enum SampleFormat in_fmt, int in_channels,
+AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
+ enum AVSampleFormat in_fmt, int in_channels,
const float *matrix, int flags);
/**
diff --git a/lib/ffmpeg/libavcodec/aura.c b/lib/ffmpeg/libavcodec/aura.c
index 8942cdd576..9041c7cb68 100644
--- a/lib/ffmpeg/libavcodec/aura.c
+++ b/lib/ffmpeg/libavcodec/aura.c
@@ -122,7 +122,7 @@ static av_cold int aura_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec aura2_decoder = {
+AVCodec ff_aura2_decoder = {
"aura2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_AURA2,
diff --git a/lib/ffmpeg/libavcodec/avcodec.h b/lib/ffmpeg/libavcodec/avcodec.h
index 59ac3ba601..4745980fd1 100644
--- a/lib/ffmpeg/libavcodec/avcodec.h
+++ b/lib/ffmpeg/libavcodec/avcodec.h
@@ -27,10 +27,12 @@
*/
#include <errno.h>
+#include "libavcore/samplefmt.h"
#include "libavutil/avutil.h"
+#include "libavutil/cpu.h"
#define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 83
+#define LIBAVCODEC_VERSION_MINOR 108
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -43,9 +45,49 @@
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
-#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
-#define AV_TIME_BASE 1000000
-#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
+/**
+ * Those FF_API_* defines are not part of public API.
+ * They may change, break or disappear at any time.
+ */
+#ifndef FF_API_PALETTE_CONTROL
+#define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_MM_FLAGS
+#define FF_API_MM_FLAGS (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_OPT_SHOW
+#define FF_API_OPT_SHOW (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_AUDIO_OLD
+#define FF_API_AUDIO_OLD (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_VIDEO_OLD
+#define FF_API_VIDEO_OLD (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_SUBTITLE_OLD
+#define FF_API_SUBTITLE_OLD (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_USE_LPC
+#define FF_API_USE_LPC (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_SET_STRING_OLD
+#define FF_API_SET_STRING_OLD (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_INOFFICIAL
+#define FF_API_INOFFICIAL (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_OLD_SAMPLE_FMT
+#define FF_API_OLD_SAMPLE_FMT (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_OLD_AUDIOCONVERT
+#define FF_API_OLD_AUDIOCONVERT (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
+
+#if LIBAVCODEC_VERSION_MAJOR < 53
+# define FF_INTERNALC_MEM_TYPE unsigned int
+#else
+# define FF_INTERNALC_MEM_TYPE size_t
+#endif
/**
* Identify the syntax and semantics of the bitstream.
@@ -212,6 +254,12 @@ enum CodecID {
CODEC_ID_YOP,
CODEC_ID_VP8,
CODEC_ID_PICTOR,
+ CODEC_ID_ANSI,
+ CODEC_ID_A64_MULTI,
+ CODEC_ID_A64_MULTI5,
+ CODEC_ID_R10K,
+ CODEC_ID_MXPEG,
+ CODEC_ID_LAGARITH,
/* various PCM "codecs" */
CODEC_ID_PCM_S16LE= 0x10000,
@@ -239,6 +287,7 @@ enum CodecID {
CODEC_ID_PCM_F64BE,
CODEC_ID_PCM_F64LE,
CODEC_ID_PCM_BLURAY,
+ CODEC_ID_PCM_LXF,
/* various ADPCM codecs */
CODEC_ID_ADPCM_IMA_QT= 0x11000,
@@ -269,6 +318,7 @@ enum CodecID {
CODEC_ID_ADPCM_EA_XAS,
CODEC_ID_ADPCM_EA_MAXIS_XA,
CODEC_ID_ADPCM_IMA_ISS,
+ CODEC_ID_ADPCM_G722,
/* AMR */
CODEC_ID_AMR_NB= 0x12000,
@@ -288,7 +338,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,
@@ -338,6 +387,7 @@ enum CodecID {
CODEC_ID_ATRAC1,
CODEC_ID_BINKAUDIO_RDFT,
CODEC_ID_BINKAUDIO_DCT,
+ CODEC_ID_AAC_LATM,
/* subtitle codecs */
CODEC_ID_DVD_SUBTITLE= 0x17000,
@@ -348,6 +398,7 @@ enum CodecID {
CODEC_ID_MOV_TEXT,
CODEC_ID_HDMV_PGS_SUBTITLE,
CODEC_ID_DVB_TELETEXT,
+ CODEC_ID_SRT,
/* data codecs */
CODEC_ID_VBI_DATA= 0x17500,
@@ -360,6 +411,7 @@ enum CodecID {
CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
* stream (only used by libavformat) */
+ CODEC_ID_FFMETADATA=0x21000, ///< Dummy codec for streams containing only metadata information.
};
#if LIBAVCODEC_VERSION_MAJOR < 53
@@ -374,63 +426,65 @@ enum CodecID {
#define CODEC_TYPE_NB AVMEDIA_TYPE_NB
#endif
-/**
- * all in native-endian format
- */
-enum SampleFormat {
- SAMPLE_FMT_NONE = -1,
- SAMPLE_FMT_U8, ///< unsigned 8 bits
- SAMPLE_FMT_S16, ///< signed 16 bits
- SAMPLE_FMT_S32, ///< signed 32 bits
- SAMPLE_FMT_FLT, ///< float
- SAMPLE_FMT_DBL, ///< double
- SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
-};
+#if FF_API_OLD_SAMPLE_FMT
+#define SampleFormat AVSampleFormat
+
+#define SAMPLE_FMT_NONE AV_SAMPLE_FMT_NONE
+#define SAMPLE_FMT_U8 AV_SAMPLE_FMT_U8
+#define SAMPLE_FMT_S16 AV_SAMPLE_FMT_S16
+#define SAMPLE_FMT_S32 AV_SAMPLE_FMT_S32
+#define SAMPLE_FMT_FLT AV_SAMPLE_FMT_FLT
+#define SAMPLE_FMT_DBL AV_SAMPLE_FMT_DBL
+#define SAMPLE_FMT_NB AV_SAMPLE_FMT_NB
+#endif
+
+#if FF_API_OLD_AUDIOCONVERT
+#include "libavcore/audioconvert.h"
/* Audio channel masks */
-#define CH_FRONT_LEFT 0x00000001
-#define CH_FRONT_RIGHT 0x00000002
-#define CH_FRONT_CENTER 0x00000004
-#define CH_LOW_FREQUENCY 0x00000008
-#define CH_BACK_LEFT 0x00000010
-#define CH_BACK_RIGHT 0x00000020
-#define CH_FRONT_LEFT_OF_CENTER 0x00000040
-#define CH_FRONT_RIGHT_OF_CENTER 0x00000080
-#define CH_BACK_CENTER 0x00000100
-#define CH_SIDE_LEFT 0x00000200
-#define CH_SIDE_RIGHT 0x00000400
-#define CH_TOP_CENTER 0x00000800
-#define CH_TOP_FRONT_LEFT 0x00001000
-#define CH_TOP_FRONT_CENTER 0x00002000
-#define CH_TOP_FRONT_RIGHT 0x00004000
-#define CH_TOP_BACK_LEFT 0x00008000
-#define CH_TOP_BACK_CENTER 0x00010000
-#define CH_TOP_BACK_RIGHT 0x00020000
-#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
-#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT.
+#define CH_FRONT_LEFT AV_CH_FRONT_LEFT
+#define CH_FRONT_RIGHT AV_CH_FRONT_RIGHT
+#define CH_FRONT_CENTER AV_CH_FRONT_CENTER
+#define CH_LOW_FREQUENCY AV_CH_LOW_FREQUENCY
+#define CH_BACK_LEFT AV_CH_BACK_LEFT
+#define CH_BACK_RIGHT AV_CH_BACK_RIGHT
+#define CH_FRONT_LEFT_OF_CENTER AV_CH_FRONT_LEFT_OF_CENTER
+#define CH_FRONT_RIGHT_OF_CENTER AV_CH_FRONT_RIGHT_OF_CENTER
+#define CH_BACK_CENTER AV_CH_BACK_CENTER
+#define CH_SIDE_LEFT AV_CH_SIDE_LEFT
+#define CH_SIDE_RIGHT AV_CH_SIDE_RIGHT
+#define CH_TOP_CENTER AV_CH_TOP_CENTER
+#define CH_TOP_FRONT_LEFT AV_CH_TOP_FRONT_LEFT
+#define CH_TOP_FRONT_CENTER AV_CH_TOP_FRONT_CENTER
+#define CH_TOP_FRONT_RIGHT AV_CH_TOP_FRONT_RIGHT
+#define CH_TOP_BACK_LEFT AV_CH_TOP_BACK_LEFT
+#define CH_TOP_BACK_CENTER AV_CH_TOP_BACK_CENTER
+#define CH_TOP_BACK_RIGHT AV_CH_TOP_BACK_RIGHT
+#define CH_STEREO_LEFT AV_CH_STEREO_LEFT
+#define CH_STEREO_RIGHT AV_CH_STEREO_RIGHT
/** Channel mask value used for AVCodecContext.request_channel_layout
to indicate that the user requests the channel order of the decoder output
to be the native codec channel order. */
-#define CH_LAYOUT_NATIVE 0x8000000000000000LL
+#define CH_LAYOUT_NATIVE AV_CH_LAYOUT_NATIVE
/* Audio channel convenience macros */
-#define CH_LAYOUT_MONO (CH_FRONT_CENTER)
-#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT)
-#define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER)
-#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER)
-#define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER)
-#define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT)
-#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT)
-#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT)
-#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY)
-#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
-#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
-#define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT)
-#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT)
-#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
-#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT)
+#define CH_LAYOUT_MONO AV_CH_LAYOUT_MONO
+#define CH_LAYOUT_STEREO AV_CH_LAYOUT_STEREO
+#define CH_LAYOUT_2_1 AV_CH_LAYOUT_2_1
+#define CH_LAYOUT_SURROUND AV_CH_LAYOUT_SURROUND
+#define CH_LAYOUT_4POINT0 AV_CH_LAYOUT_4POINT0
+#define CH_LAYOUT_2_2 AV_CH_LAYOUT_2_2
+#define CH_LAYOUT_QUAD AV_CH_LAYOUT_QUAD
+#define CH_LAYOUT_5POINT0 AV_CH_LAYOUT_5POINT0
+#define CH_LAYOUT_5POINT1 AV_CH_LAYOUT_5POINT1
+#define CH_LAYOUT_5POINT0_BACK AV_CH_LAYOUT_5POINT0_BACK
+#define CH_LAYOUT_5POINT1_BACK AV_CH_LAYOUT_5POINT1_BACK
+#define CH_LAYOUT_7POINT0 AV_CH_LAYOUT_7POINT0
+#define CH_LAYOUT_7POINT1 AV_CH_LAYOUT_7POINT1
+#define CH_LAYOUT_7POINT1_WIDE AV_CH_LAYOUT_7POINT1_WIDE
+#define CH_LAYOUT_STEREO_DOWNMIX AV_CH_LAYOUT_STEREO_DOWNMIX
+#endif
/* in bytes */
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
@@ -668,6 +722,14 @@ typedef struct RcOverride{
* encoders
*/
#define CODEC_CAP_EXPERIMENTAL 0x0200
+/**
+ * Codec should fill in channel configuration and samplerate instead of container
+ */
+#define CODEC_CAP_CHANNEL_CONF 0x0400
+/**
+ * Codec is able to deal with negative linesizes
+ */
+#define CODEC_CAP_NEG_LINESIZES 0x0800
//The following defines may change, don't expect compatibility if you use them.
#define MB_TYPE_INTRA4x4 0x0001
@@ -935,8 +997,13 @@ typedef struct AVPanScan{
int8_t *ref_index[2];\
\
/**\
- * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\
- * output in AVFrame.reordered_opaque\
+ * reordered opaque 64bit (generally an integer or a double precision float\
+ * PTS but can be anything). \
+ * The user sets AVCodecContext.reordered_opaque to represent the input at\
+ * that time,\
+ * the decoder reorders values as needed and sets AVFrame.reordered_opaque\
+ * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque \
+ * @deprecated in favor of pkt_pts\
* - encoding: unused\
* - decoding: Read by user.\
*/\
@@ -948,6 +1015,20 @@ typedef struct AVPanScan{
* - decoding: Set by libavcodec\
*/\
void *hwaccel_picture_private;\
+\
+ /**\
+ * reordered pts from the last AVPacket that has been input into the decoder\
+ * - encoding: unused\
+ * - decoding: Read by user.\
+ */\
+ int64_t pkt_pts;\
+\
+ /**\
+ * dts from the last AVPacket that has been input into the decoder\
+ * - encoding: unused\
+ * - decoding: Read by user.\
+ */\
+ int64_t pkt_dts;\
#define FF_QSCALE_TYPE_MPEG1 0
@@ -1187,7 +1268,7 @@ typedef struct AVCodecContext {
* - encoding: Set by user.
* - decoding: Set by libavcodec.
*/
- enum SampleFormat sample_fmt; ///< sample format
+ enum AVSampleFormat sample_fmt; ///< sample format
/* The following data should not be initialized. */
/**
@@ -1380,7 +1461,7 @@ 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
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_INOFFICIAL
#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead).
#endif
#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
@@ -1650,23 +1731,25 @@ typedef struct AVCodecContext {
* result into program crash.)
*/
unsigned dsp_mask;
-#define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */
- /* lower 16 bits - CPU features */
-#define FF_MM_MMX 0x0001 ///< standard MMX
-#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW
-#if LIBAVCODEC_VERSION_MAJOR < 53
-#define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
+
+#if FF_API_MM_FLAGS
+#define FF_MM_FORCE AV_CPU_FLAG_FORCE
+#define FF_MM_MMX AV_CPU_FLAG_MMX
+#define FF_MM_3DNOW AV_CPU_FLAG_3DNOW
+#define FF_MM_MMXEXT AV_CPU_FLAG_MMX2
+#define FF_MM_MMX2 AV_CPU_FLAG_MMX2
+#define FF_MM_SSE AV_CPU_FLAG_SSE
+#define FF_MM_SSE2 AV_CPU_FLAG_SSE2
+#define FF_MM_SSE2SLOW AV_CPU_FLAG_SSE2SLOW
+#define FF_MM_3DNOWEXT AV_CPU_FLAG_3DNOWEXT
+#define FF_MM_SSE3 AV_CPU_FLAG_SSE3
+#define FF_MM_SSE3SLOW AV_CPU_FLAG_SSE3SLOW
+#define FF_MM_SSSE3 AV_CPU_FLAG_SSSE3
+#define FF_MM_SSE4 AV_CPU_FLAG_SSE4
+#define FF_MM_SSE42 AV_CPU_FLAG_SSE42
+#define FF_MM_IWMMXT AV_CPU_FLAG_IWMMXT
+#define FF_MM_ALTIVEC AV_CPU_FLAG_ALTIVEC
#endif
-#define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
-#define FF_MM_SSE 0x0008 ///< SSE functions
-#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions
-#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt
-#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions
-#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions
-#define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions
-#define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions
-#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT
-#define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec
/**
* bits per sample/pixel from the demuxer (needed for huffyuv).
@@ -1910,12 +1993,6 @@ typedef struct AVCodecContext {
*/
void *internal_buffer;
-#define FF_LAMBDA_SHIFT 7
-#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
-#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
-#define FF_LAMBDA_MAX (256*128-1)
-
-#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
/**
* Global quality for codecs which cannot change it per frame.
* This should be proportional to MPEG-1/2/4 qscale.
@@ -2022,12 +2099,14 @@ typedef struct AVCodecContext {
*/
int lmax;
+#if FF_API_PALETTE_CONTROL
/**
* palette control structure
* - encoding: ??? (no palette-enabled encoder yet)
* - decoding: Set by user.
*/
struct AVPaletteControl *palctrl;
+#endif
/**
* noise reduction strength
@@ -2185,14 +2264,21 @@ typedef struct AVCodecContext {
#define FF_PROFILE_DTS_HD_HRA 50
#define FF_PROFILE_DTS_HD_MA 60
-#define FF_PROFILE_H264_BASELINE 66
-#define FF_PROFILE_H264_MAIN 77
-#define FF_PROFILE_H264_EXTENDED 88
-#define FF_PROFILE_H264_HIGH 100
-#define FF_PROFILE_H264_HIGH_10 110
-#define FF_PROFILE_H264_HIGH_422 122
-#define FF_PROFILE_H264_HIGH_444 244
-#define FF_PROFILE_H264_CAVLC_444 44
+#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
+#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
+
+#define FF_PROFILE_H264_BASELINE 66
+#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
+#define FF_PROFILE_H264_MAIN 77
+#define FF_PROFILE_H264_EXTENDED 88
+#define FF_PROFILE_H264_HIGH 100
+#define FF_PROFILE_H264_HIGH_10 110
+#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
+#define FF_PROFILE_H264_HIGH_422 122
+#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
+#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
+#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
+#define FF_PROFILE_H264_CAVLC_444 44
/**
* level
@@ -2436,7 +2522,7 @@ typedef struct AVCodecContext {
int compression_level;
#define FF_COMPRESSION_DEFAULT -1
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_USE_LPC
/**
* Sets whether to use LPC mode - used by FLAC encoder.
* - encoding: Set by user.
@@ -2512,6 +2598,7 @@ typedef struct AVCodecContext {
/**
* opaque 64bit number (generally a PTS) that will be reordered and
* output in AVFrame.reordered_opaque
+ * @deprecated in favor of pkt_pts
* - encoding: unused
* - decoding: Set by user.
*/
@@ -2519,7 +2606,7 @@ typedef struct AVCodecContext {
/**
* Bits per sample/pixel of internal libavcodec pixel/sample format.
- * This field is applicable only when sample_fmt is SAMPLE_FMT_S32.
+ * This field is applicable only when sample_fmt is AV_SAMPLE_FMT_S32.
* - encoding: set by user.
* - decoding: set by libavcodec.
*/
@@ -2712,6 +2799,35 @@ typedef struct AVCodecContext {
* - decoding: unused
*/
int lpc_passes;
+
+ /**
+ * Number of slices.
+ * Indicates number of picture subdivisions. Used for parallelized
+ * decoding.
+ * - encoding: Set by user
+ * - decoding: unused
+ */
+ int slices;
+
+ /**
+ * Header containing style information for text subtitles.
+ * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
+ * [Script Info] and [V4+ Styles] section, plus the [Events] line and
+ * the Format line following. It shouldn't include any Dialogue line.
+ * - encoding: Set/allocated/freed by user (before avcodec_open())
+ * - decoding: Set/allocated/freed by libavcodec (by avcodec_open())
+ */
+ uint8_t *subtitle_header;
+ int subtitle_header_size;
+
+ /**
+ * Current packet as passed into the decoder, to avoid having
+ * to pass the packet into every function. Currently only valid
+ * inside lavc and get/release_buffer callbacks.
+ * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
+ * - encoding: unused
+ */
+ AVPacket *pkt;
} AVCodecContext;
/**
@@ -2759,9 +2875,10 @@ typedef struct AVCodec {
*/
const char *long_name;
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 enum AVSampleFormat *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
+ AVClass *priv_class; ///< AVClass for the private context
const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
} AVCodec;
@@ -2864,7 +2981,7 @@ typedef struct AVPicture {
int linesize[4]; ///< number of bytes per line
} AVPicture;
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_PALETTE_CONTROL
/**
* AVPaletteControl
* This structure defines a method for communicating palette changes
@@ -2979,6 +3096,14 @@ int av_new_packet(AVPacket *pkt, int size);
void av_shrink_packet(AVPacket *pkt, int size);
/**
+ * Increase packet size, correctly zeroing padding
+ *
+ * @param pkt packet
+ * @param grow_by number of bytes by which to increase the size of the packet
+ */
+int av_grow_packet(AVPacket *pkt, int grow_by);
+
+/**
* @warning This is a hack - the packet memory allocation stuff is broken. The
* packet is allocated if it was not really allocated.
*/
@@ -2998,7 +3123,7 @@ struct AVResampleContext;
typedef struct ReSampleContext ReSampleContext;
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_AUDIO_OLD
/**
* @deprecated Use av_audio_resample_init() instead.
*/
@@ -3023,8 +3148,8 @@ attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, i
*/
ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
int output_rate, int input_rate,
- enum SampleFormat sample_fmt_out,
- enum SampleFormat sample_fmt_in,
+ enum AVSampleFormat sample_fmt_out,
+ enum AVSampleFormat sample_fmt_in,
int filter_length, int log2_phase_count,
int linear, double cutoff);
@@ -3212,18 +3337,13 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
int has_alpha, int *loss_ptr);
-
+#if LIBAVCODEC_VERSION_MAJOR < 53
/**
- * Print in buf the string corresponding to the pixel format with
- * number pix_fmt, or an header if pix_fmt is negative.
- *
- * @param[in] buf the buffer where to write the string
- * @param[in] buf_size the size of buf
- * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or
- * a negative value to print the corresponding header.
- * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
+ * @deprecated Use av_get_pix_fmt_string() instead.
*/
+attribute_deprecated
void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
+#endif
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
@@ -3339,6 +3459,10 @@ void avcodec_get_context_defaults(AVCodecContext *s);
* we WILL change its arguments and name a few times! */
void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
+/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
+ * we WILL change its arguments and name a few times! */
+int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec);
+
/**
* Allocate an AVCodecContext and set its fields to default values. The
* resulting struct can be deallocated by simply calling av_free().
@@ -3352,6 +3476,10 @@ AVCodecContext *avcodec_alloc_context(void);
* we WILL change its arguments and name a few times! */
AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
+/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
+ * we WILL change its arguments and name a few times! */
+AVCodecContext *avcodec_alloc_context3(AVCodec *codec);
+
/**
* Copy the settings of the source AVCodecContext into the destination
* AVCodecContext. The resulting destination codec context will be
@@ -3415,15 +3543,14 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
int linesize_align[4]);
+#if LIBAVCODEC_VERSION_MAJOR < 53
/**
- * 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.
- * @param[in] h Height of the picture.
- * @return Zero if valid, a negative value if invalid.
+ * @deprecated Deprecated in favor of av_check_image_size().
*/
+attribute_deprecated
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
+#endif
+
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
int avcodec_thread_init(AVCodecContext *s, int thread_count);
@@ -3461,7 +3588,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
*/
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_AUDIO_OLD
/**
* Decode an audio frame from buf into samples.
* Wrapper function which calls avcodec_decode_audio3.
@@ -3523,7 +3650,7 @@ int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
AVPacket *avpkt);
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_VIDEO_OLD
/**
* Decode a video frame from buf into picture.
* Wrapper function which calls avcodec_decode_video2.
@@ -3586,7 +3713,7 @@ int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
AVPacket *avpkt);
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_SUBTITLE_OLD
/* Decode a subtitle message. Return -1 if error, otherwise return the
* number of bytes used. If no subtitle could be decompressed,
* got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
@@ -3704,13 +3831,13 @@ char av_get_pict_type_char(int pict_type);
*/
int av_get_bits_per_sample(enum CodecID codec_id);
+#if FF_API_OLD_SAMPLE_FMT
/**
- * 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.
+ * @deprecated Use av_get_bits_per_sample_fmt() instead.
*/
-int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
+attribute_deprecated
+int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt);
+#endif
/* frame parsing */
typedef struct AVCodecParserContext {
@@ -3749,6 +3876,8 @@ typedef struct AVCodecParserContext {
int flags;
#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
#define PARSER_FLAG_ONCE 0x0002
+/// Set if the parser has a valid file offset
+#define PARSER_FLAG_FETCHED_OFFSET 0x0004
int64_t offset; ///< byte offset from starting packet start
int64_t cur_frame_end[AV_PARSER_PTS_NB];
@@ -3944,7 +4073,7 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
*
* @see av_realloc
*/
-void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
+void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size);
/**
* Allocate a buffer, reusing the given one if large enough.
@@ -3958,10 +4087,20 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
* @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
* *size 0 if an error occurred.
*/
-void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size);
+void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size);
+
+#if LIBAVCODEC_VERSION_MAJOR < 53
+/**
+ * @deprecated Deprecated in favor of av_image_copy().
+ */
+attribute_deprecated
+void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
+ uint8_t *src_data[4], int src_linesize[4],
+ enum PixelFormat pix_fmt, int width, int height);
+#endif
/**
- * Copy image 'src' to 'dst'.
+ * Copy image src to dst. Wraps av_picture_data_copy() above.
*/
void av_picture_copy(AVPicture *dst, const AVPicture *src,
enum PixelFormat pix_fmt, int width, int height);
@@ -3987,29 +4126,21 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
*/
unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
+#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* 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
- * 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
- * frame height value
+ * @deprecated Deprecated in favor of av_parse_video_size().
*/
-int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
+attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
/**
* 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
- * 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
+ * @deprecated Deprecated in favor of av_parse_video_rate().
*/
-int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
+attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
+#endif
/**
* Logs a generic warning message about a missing feature. This function is
diff --git a/lib/ffmpeg/libavcodec/avpacket.c b/lib/ffmpeg/libavcodec/avpacket.c
index c51260face..82890c3676 100644
--- a/lib/ffmpeg/libavcodec/avpacket.c
+++ b/lib/ffmpeg/libavcodec/avpacket.c
@@ -20,6 +20,7 @@
*/
#include "avcodec.h"
+#include "libavutil/avassert.h"
void av_destruct_packet_nofree(AVPacket *pkt)
@@ -71,6 +72,23 @@ void av_shrink_packet(AVPacket *pkt, int size)
memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
+int av_grow_packet(AVPacket *pkt, int grow_by)
+{
+ void *new_ptr;
+ av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!pkt->size)
+ return av_new_packet(pkt, grow_by);
+ if ((unsigned)grow_by > INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE))
+ return -1;
+ new_ptr = av_realloc(pkt->data, pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!new_ptr)
+ return AVERROR(ENOMEM);
+ pkt->data = new_ptr;
+ pkt->size += grow_by;
+ memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ return 0;
+}
+
int av_dup_packet(AVPacket *pkt)
{
if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {
diff --git a/lib/ffmpeg/libavcodec/avs.c b/lib/ffmpeg/libavcodec/avs.c
index f65a25a8e3..e1a66a9930 100644
--- a/lib/ffmpeg/libavcodec/avs.c
+++ b/lib/ffmpeg/libavcodec/avs.c
@@ -150,7 +150,7 @@ static av_cold int avs_decode_init(AVCodecContext * avctx)
return 0;
}
-AVCodec avs_decoder = {
+AVCodec ff_avs_decoder = {
"avs",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_AVS,
diff --git a/lib/ffmpeg/libavcodec/bethsoftvideo.c b/lib/ffmpeg/libavcodec/bethsoftvideo.c
index 0ba39e63a5..5b06e5f12e 100644
--- a/lib/ffmpeg/libavcodec/bethsoftvideo.c
+++ b/lib/ffmpeg/libavcodec/bethsoftvideo.c
@@ -130,7 +130,7 @@ static av_cold int bethsoftvid_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec bethsoftvid_decoder = {
+AVCodec ff_bethsoftvid_decoder = {
.name = "bethsoftvid",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_BETHSOFTVID,
diff --git a/lib/ffmpeg/libavcodec/bfi.c b/lib/ffmpeg/libavcodec/bfi.c
index 91c8f6d24d..ff74233df9 100644
--- a/lib/ffmpeg/libavcodec/bfi.c
+++ b/lib/ffmpeg/libavcodec/bfi.c
@@ -47,7 +47,7 @@ static av_cold int bfi_decode_init(AVCodecContext * avctx)
static int bfi_decode_frame(AVCodecContext * avctx, void *data,
int *data_size, AVPacket *avpkt)
{
- const uint8_t *buf = avpkt->data;
+ const uint8_t *buf = avpkt->data, *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size;
BFIContext *bfi = avctx->priv_data;
uint8_t *dst = bfi->dst;
@@ -99,6 +99,11 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data,
unsigned int code = byte >> 6;
unsigned int length = byte & ~0xC0;
+ if (buf >= buf_end) {
+ av_log(avctx, AV_LOG_ERROR, "Input resolution larger than actual frame.\n");
+ return -1;
+ }
+
/* Get length and offset(if required) */
if (length == 0) {
if (code == 1) {
@@ -121,6 +126,10 @@ static int bfi_decode_frame(AVCodecContext * avctx, void *data,
switch (code) {
case 0: //Normal Chain
+ if (length >= buf_end - buf) {
+ av_log(avctx, AV_LOG_ERROR, "Frame larger than buffer.\n");
+ return -1;
+ }
bytestream_get_buffer(&buf, dst, length);
dst += length;
break;
@@ -171,7 +180,7 @@ static av_cold int bfi_decode_close(AVCodecContext * avctx)
return 0;
}
-AVCodec bfi_decoder = {
+AVCodec ff_bfi_decoder = {
.name = "bfi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_BFI,
diff --git a/lib/ffmpeg/libavcodec/bgmc.c b/lib/ffmpeg/libavcodec/bgmc.c
index ffe3cea4a6..b9041d080e 100644
--- a/lib/ffmpeg/libavcodec/bgmc.c
+++ b/lib/ffmpeg/libavcodec/bgmc.c
@@ -426,8 +426,8 @@ static const uint16_t * const cf_table[16] = {
/** Initialize a given lookup table using a given delta
*/
-static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status,
- unsigned int delta)
+static void bgmc_lut_fillp(uint8_t *lut, int *lut_status,
+ int delta)
{
unsigned int sx, i;
@@ -448,8 +448,8 @@ static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status,
/** 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)
+static uint8_t* bgmc_lut_getp(uint8_t *lut, int *lut_status,
+ int delta)
{
unsigned int i = av_clip(delta, 0, LUT_BUFF - 1);
@@ -464,7 +464,7 @@ static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status,
/** Initialize the lookup table arrays
*/
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status)
+int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
{
*cf_lut = av_malloc(sizeof(*cf_lut ) * LUT_BUFF * 16 * LUT_SIZE);
*cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
@@ -473,6 +473,9 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_
ff_bgmc_end(cf_lut, cf_lut_status);
av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
return AVERROR(ENOMEM);
+ } else {
+ // initialize lut_status buffer to a value never used to compare against
+ memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);
}
return 0;
@@ -481,7 +484,7 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_
/** Release the lookup table arrays
*/
-void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status)
+void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
{
av_freep(cf_lut);
av_freep(cf_lut_status);
@@ -510,9 +513,9 @@ void ff_bgmc_decode_end(GetBitContext *gb)
/** 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,
+ int delta, unsigned int sx,
unsigned int *h, unsigned int *l, unsigned int *v,
- uint8_t *cf_lut, unsigned int *cf_lut_status)
+ uint8_t *cf_lut, int *cf_lut_status)
{
unsigned int i;
uint8_t *lut = bgmc_lut_getp(cf_lut, cf_lut_status, delta);
diff --git a/lib/ffmpeg/libavcodec/bgmc.h b/lib/ffmpeg/libavcodec/bgmc.h
index eab413b6a8..9e386fdbdd 100644
--- a/lib/ffmpeg/libavcodec/bgmc.h
+++ b/lib/ffmpeg/libavcodec/bgmc.h
@@ -34,10 +34,10 @@
#include "get_bits.h"
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status);
+int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status);
-void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status);
+void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status);
void ff_bgmc_decode_init(GetBitContext *gb,
@@ -48,9 +48,9 @@ void ff_bgmc_decode_end(GetBitContext *gb);
void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
- unsigned int delta, unsigned int sx,
+ int delta, unsigned int sx,
unsigned int *h, unsigned int *l, unsigned int *v,
- uint8_t *cf_lut, unsigned int *cf_lut_status);
+ uint8_t *cf_lut, int *cf_lut_status);
#endif /* AVCODEC_BGMC_H */
diff --git a/lib/ffmpeg/libavcodec/bink.c b/lib/ffmpeg/libavcodec/bink.c
index 0a0b5bc915..64a10b71e5 100644
--- a/lib/ffmpeg/libavcodec/bink.c
+++ b/lib/ffmpeg/libavcodec/bink.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "binkdata.h"
@@ -118,7 +119,7 @@ static void init_lengths(BinkContext *c, int width, int bw)
c->bundle[BINK_SRC_SUB_BLOCK_TYPES].len = av_log2((width >> 4) + 511) + 1;
- c->bundle[BINK_SRC_COLORS].len = av_log2((width >> 3)*64 + 511) + 1;
+ c->bundle[BINK_SRC_COLORS].len = av_log2(bw*64 + 511) + 1;
c->bundle[BINK_SRC_INTRA_DC].len =
c->bundle[BINK_SRC_INTER_DC].len =
@@ -127,7 +128,7 @@ static void init_lengths(BinkContext *c, int width, int bw)
c->bundle[BINK_SRC_PATTERN].len = av_log2((bw << 3) + 511) + 1;
- c->bundle[BINK_SRC_RUN].len = av_log2((width >> 3)*48 + 511) + 1;
+ c->bundle[BINK_SRC_RUN].len = av_log2(bw*48 + 511) + 1;
}
/**
@@ -324,7 +325,7 @@ static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle *
return 0;
}
-const uint8_t bink_rlelens[4] = { 4, 8, 12, 32 };
+static const uint8_t bink_rlelens[4] = { 4, 8, 12, 32 };
static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b)
{
@@ -971,7 +972,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
c->pic.data[0] = NULL;
- if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+ if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
return 1;
}
@@ -999,7 +1000,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec bink_decoder = {
+AVCodec ff_bink_decoder = {
"binkvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_BINKVIDEO,
diff --git a/lib/ffmpeg/libavcodec/binkaudio.c b/lib/ffmpeg/libavcodec/binkaudio.c
index 295b351898..53484654db 100644
--- a/lib/ffmpeg/libavcodec/binkaudio.c
+++ b/lib/ffmpeg/libavcodec/binkaudio.c
@@ -33,6 +33,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
extern const uint16_t ff_wma_critical_freqs[25];
@@ -43,6 +44,7 @@ typedef struct {
AVCodecContext *avctx;
GetBitContext gb;
DSPContext dsp;
+ FmtConvertContext fmt_conv;
int first;
int channels;
int frame_len; ///< transform size (samples)
@@ -71,6 +73,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->avctx = avctx;
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
/* determine frame length */
if (avctx->sample_rate < 22050) {
@@ -119,7 +122,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->bands[s->num_bands] = s->frame_len / 2;
s->first = 1;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
for (i = 0; i < s->channels; i++)
s->coeffs_ptr[i] = s->coeffs + i * s->frame_len;
@@ -222,12 +225,8 @@ static void decode_block(BinkAudioContext *s, short *out, int use_dct)
ff_rdft_calc(&s->trans.rdft, coeffs);
}
- if (s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- for (i = 0; i < s->channels; i++)
- for (j = 0; j < s->frame_len; j++)
- s->coeffs_ptr[i][j] = 385.0 + s->coeffs_ptr[i][j]*(1.0/32767.0);
- }
- s->dsp.float_to_int16_interleave(out, (const float **)s->coeffs_ptr, s->frame_len, s->channels);
+ s->fmt_conv.float_to_int16_interleave(out, (const float **)s->coeffs_ptr,
+ s->frame_len, s->channels);
if (!s->first) {
int count = s->overlap_len * s->channels;
@@ -286,7 +285,7 @@ static int decode_frame(AVCodecContext *avctx,
return buf_size;
}
-AVCodec binkaudio_rdft_decoder = {
+AVCodec ff_binkaudio_rdft_decoder = {
"binkaudio_rdft",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_BINKAUDIO_RDFT,
@@ -298,7 +297,7 @@ AVCodec binkaudio_rdft_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)")
};
-AVCodec binkaudio_dct_decoder = {
+AVCodec ff_binkaudio_dct_decoder = {
"binkaudio_dct",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_BINKAUDIO_DCT,
diff --git a/lib/ffmpeg/libavcodec/bmp.c b/lib/ffmpeg/libavcodec/bmp.c
index 270452fe66..c02aac6cb7 100644
--- a/lib/ffmpeg/libavcodec/bmp.c
+++ b/lib/ffmpeg/libavcodec/bmp.c
@@ -335,7 +335,7 @@ static av_cold int bmp_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec bmp_decoder = {
+AVCodec ff_bmp_decoder = {
"bmp",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_BMP,
@@ -345,6 +345,5 @@ 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/lib/ffmpeg/libavcodec/bmpenc.c b/lib/ffmpeg/libavcodec/bmpenc.c
index ee85f3cfae..d424662b5c 100644
--- a/lib/ffmpeg/libavcodec/bmpenc.c
+++ b/lib/ffmpeg/libavcodec/bmpenc.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/internal.h"
#include "avcodec.h"
#include "bytestream.h"
#include "bmp.h"
@@ -33,6 +34,32 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){
avcodec_get_frame_defaults((AVFrame*)&s->picture);
avctx->coded_frame = (AVFrame*)&s->picture;
+ switch (avctx->pix_fmt) {
+ case PIX_FMT_BGR24:
+ avctx->bits_per_coded_sample = 24;
+ break;
+ case PIX_FMT_RGB555:
+ avctx->bits_per_coded_sample = 16;
+ break;
+ case PIX_FMT_RGB565:
+ avctx->bits_per_coded_sample = 16;
+ break;
+ case PIX_FMT_RGB8:
+ case PIX_FMT_BGR8:
+ case PIX_FMT_RGB4_BYTE:
+ case PIX_FMT_BGR4_BYTE:
+ case PIX_FMT_GRAY8:
+ case PIX_FMT_PAL8:
+ avctx->bits_per_coded_sample = 8;
+ break;
+ case PIX_FMT_MONOBLACK:
+ avctx->bits_per_coded_sample = 1;
+ break;
+ default:
+ av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n");
+ return -1;
+ }
+
return 0;
}
@@ -42,21 +69,15 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
AVFrame * const p= (AVFrame*)&s->picture;
int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize;
const uint32_t *pal = NULL;
- int pad_bytes_per_row, bit_count, pal_entries = 0, compression = BMP_RGB;
+ int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
+ int bit_count = avctx->bits_per_coded_sample;
uint8_t *ptr;
unsigned char* buf0 = buf;
*p = *pict;
p->pict_type= FF_I_TYPE;
p->key_frame= 1;
switch (avctx->pix_fmt) {
- case PIX_FMT_BGR24:
- bit_count = 24;
- break;
- case PIX_FMT_RGB555:
- bit_count = 16;
- break;
case PIX_FMT_RGB565:
- bit_count = 16;
compression = BMP_BITFIELDS;
pal = rgb565_masks; // abuse pal to hold color masks
pal_entries = 3;
@@ -66,16 +87,13 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
case PIX_FMT_RGB4_BYTE:
case PIX_FMT_BGR4_BYTE:
case PIX_FMT_GRAY8:
+ ff_set_systematic_pal2((uint32_t*)p->data[1], avctx->pix_fmt);
case PIX_FMT_PAL8:
- bit_count = 8;
pal = (uint32_t *)p->data[1];
break;
case PIX_FMT_MONOBLACK:
- bit_count = 1;
pal = monoblack_pal;
break;
- default:
- return -1;
}
if (pal && !pal_entries) pal_entries = 1 << bit_count;
n_bytes_per_row = ((int64_t)avctx->width * (int64_t)bit_count + 7LL) >> 3LL;
@@ -131,7 +149,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
return n_bytes;
}
-AVCodec bmp_encoder = {
+AVCodec ff_bmp_encoder = {
"bmp",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_BMP,
diff --git a/lib/ffmpeg/libavcodec/c93.c b/lib/ffmpeg/libavcodec/c93.c
index d713ff8e26..ed6e91d831 100644
--- a/lib/ffmpeg/libavcodec/c93.c
+++ b/lib/ffmpeg/libavcodec/c93.c
@@ -242,7 +242,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return buf_size;
}
-AVCodec c93_decoder = {
+AVCodec ff_c93_decoder = {
"c93",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_C93,
diff --git a/lib/ffmpeg/libavcodec/cavs.c b/lib/ffmpeg/libavcodec/cavs.c
index ff6c86964a..db49ef3e67 100644
--- a/lib/ffmpeg/libavcodec/cavs.c
+++ b/lib/ffmpeg/libavcodec/cavs.c
@@ -113,22 +113,22 @@ void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type) {
if(h->flags & A_AVAIL) {
qp_avg = (h->qp + h->left_qp + 1) >> 1;
SET_PARAMS;
- h->s.dsp.cavs_filter_lv(h->cy,h->l_stride,alpha,beta,tc,bs[0],bs[1]);
- h->s.dsp.cavs_filter_cv(h->cu,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
- h->s.dsp.cavs_filter_cv(h->cv,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
+ h->cdsp.cavs_filter_lv(h->cy,h->l_stride,alpha,beta,tc,bs[0],bs[1]);
+ h->cdsp.cavs_filter_cv(h->cu,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
+ h->cdsp.cavs_filter_cv(h->cv,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
}
qp_avg = h->qp;
SET_PARAMS;
- h->s.dsp.cavs_filter_lv(h->cy + 8,h->l_stride,alpha,beta,tc,bs[2],bs[3]);
- h->s.dsp.cavs_filter_lh(h->cy + 8*h->l_stride,h->l_stride,alpha,beta,tc,
+ h->cdsp.cavs_filter_lv(h->cy + 8,h->l_stride,alpha,beta,tc,bs[2],bs[3]);
+ h->cdsp.cavs_filter_lh(h->cy + 8*h->l_stride,h->l_stride,alpha,beta,tc,
bs[6],bs[7]);
if(h->flags & B_AVAIL) {
qp_avg = (h->qp + h->top_qp[h->mbx] + 1) >> 1;
SET_PARAMS;
- h->s.dsp.cavs_filter_lh(h->cy,h->l_stride,alpha,beta,tc,bs[4],bs[5]);
- h->s.dsp.cavs_filter_ch(h->cu,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
- h->s.dsp.cavs_filter_ch(h->cv,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
+ h->cdsp.cavs_filter_lh(h->cy,h->l_stride,alpha,beta,tc,bs[4],bs[5]);
+ h->cdsp.cavs_filter_ch(h->cu,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
+ h->cdsp.cavs_filter_ch(h->cv,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
}
}
}
@@ -353,7 +353,7 @@ static inline void mc_dir_part(AVSContext *h,Picture *pic,int square,
|| full_my < 0-extra_height
|| full_mx + 16/*FIXME*/ > pic_width + extra_width
|| full_my + 16/*FIXME*/ > pic_height + extra_height){
- ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*h->l_stride, h->l_stride,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*h->l_stride, h->l_stride,
16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
src_y= s->edge_emu_buffer + 2 + 2*h->l_stride;
emu=1;
@@ -365,14 +365,14 @@ static inline void mc_dir_part(AVSContext *h,Picture *pic,int square,
}
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, h->c_stride,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->c_stride,
9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
src_cb= s->edge_emu_buffer;
}
chroma_op(dest_cb, src_cb, h->c_stride, chroma_height, mx&7, my&7);
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, h->c_stride,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->c_stride,
9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
src_cr= s->edge_emu_buffer;
}
@@ -414,30 +414,30 @@ static inline void mc_part_std(AVSContext *h,int square,int chroma_height,int de
void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type) {
if(ff_cavs_partition_flags[mb_type] == 0){ // 16x16
mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
- h->s.dsp.put_cavs_qpel_pixels_tab[0],
+ h->cdsp.put_cavs_qpel_pixels_tab[0],
h->s.dsp.put_h264_chroma_pixels_tab[0],
- h->s.dsp.avg_cavs_qpel_pixels_tab[0],
+ h->cdsp.avg_cavs_qpel_pixels_tab[0],
h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]);
}else{
mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0,
- h->s.dsp.put_cavs_qpel_pixels_tab[1],
+ h->cdsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
- h->s.dsp.avg_cavs_qpel_pixels_tab[1],
+ h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X0]);
mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 0,
- h->s.dsp.put_cavs_qpel_pixels_tab[1],
+ h->cdsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
- h->s.dsp.avg_cavs_qpel_pixels_tab[1],
+ h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X1]);
mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 4,
- h->s.dsp.put_cavs_qpel_pixels_tab[1],
+ h->cdsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
- h->s.dsp.avg_cavs_qpel_pixels_tab[1],
+ h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X2]);
mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 4,
- h->s.dsp.put_cavs_qpel_pixels_tab[1],
+ h->cdsp.put_cavs_qpel_pixels_tab[1],
h->s.dsp.put_h264_chroma_pixels_tab[1],
- h->s.dsp.avg_cavs_qpel_pixels_tab[1],
+ h->cdsp.avg_cavs_qpel_pixels_tab[1],
h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]);
}
}
@@ -672,6 +672,7 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) {
MpegEncContext * const s = &h->s;
MPV_decode_defaults(s);
+ ff_cavsdsp_init(&h->cdsp, avctx);
s->avctx = avctx;
avctx->pix_fmt= PIX_FMT_YUV420P;
diff --git a/lib/ffmpeg/libavcodec/cavs.h b/lib/ffmpeg/libavcodec/cavs.h
index 729c83ea7b..dfa320fa84 100644
--- a/lib/ffmpeg/libavcodec/cavs.h
+++ b/lib/ffmpeg/libavcodec/cavs.h
@@ -24,6 +24,7 @@
#include "dsputil.h"
#include "mpegvideo.h"
+#include "cavsdsp.h"
#define SLICE_MAX_START_CODE 0x000001af
#define EXT_START_CODE 0x000001b5
@@ -153,6 +154,7 @@ struct dec_2dvlc {
typedef struct {
MpegEncContext s;
+ CAVSDSPContext cdsp;
Picture picture; ///< currently decoded frame
Picture DPB[2]; ///< reference frames
int dist[2]; ///< temporal distances from current frame to ref frames
diff --git a/lib/ffmpeg/libavcodec/cavs_parser.c b/lib/ffmpeg/libavcodec/cavs_parser.c
index 8e9c35b7a7..be32345af8 100644
--- a/lib/ffmpeg/libavcodec/cavs_parser.c
+++ b/lib/ffmpeg/libavcodec/cavs_parser.c
@@ -97,7 +97,7 @@ static int cavsvideo_parse(AVCodecParserContext *s,
return next;
}
-AVCodecParser cavsvideo_parser = {
+AVCodecParser ff_cavsvideo_parser = {
{ CODEC_ID_CAVS },
sizeof(ParseContext1),
NULL,
diff --git a/lib/ffmpeg/libavcodec/cavsdec.c b/lib/ffmpeg/libavcodec/cavsdec.c
index 9d6307c217..7ff1a57eb5 100644
--- a/lib/ffmpeg/libavcodec/cavsdec.c
+++ b/lib/ffmpeg/libavcodec/cavsdec.c
@@ -143,7 +143,7 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp],
ff_cavs_dequant_shift[qp], i))
return -1;
- h->s.dsp.cavs_idct8_add(dst,block,stride);
+ h->cdsp.cavs_idct8_add(dst,block,stride);
h->s.dsp.clear_block(block);
return 0;
}
@@ -709,7 +709,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size,
}
}
-AVCodec cavs_decoder = {
+AVCodec ff_cavs_decoder = {
"cavs",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CAVS,
diff --git a/lib/ffmpeg/libavcodec/cavsdsp.c b/lib/ffmpeg/libavcodec/cavsdsp.c
index 808f62b69f..192e0f976d 100644
--- a/lib/ffmpeg/libavcodec/cavsdsp.c
+++ b/lib/ffmpeg/libavcodec/cavsdsp.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "dsputil.h"
+#include "cavsdsp.h"
/*****************************************************************************
*
@@ -510,7 +511,12 @@ CAVS_MC(put_, 16)
CAVS_MC(avg_, 8)
CAVS_MC(avg_, 16)
-av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
+#define ff_put_cavs_qpel8_mc00_c ff_put_pixels8x8_c
+#define ff_avg_cavs_qpel8_mc00_c ff_avg_pixels8x8_c
+#define ff_put_cavs_qpel16_mc00_c ff_put_pixels16x16_c
+#define ff_avg_cavs_qpel16_mc00_c ff_avg_pixels16x16_c
+
+av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) {
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \
c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \
@@ -537,4 +543,6 @@ av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
c->cavs_filter_cv = cavs_filter_cv_c;
c->cavs_filter_ch = cavs_filter_ch_c;
c->cavs_idct8_add = cavs_idct8_add_c;
+
+ if (HAVE_MMX) ff_cavsdsp_init_mmx(c, avctx);
}
diff --git a/lib/ffmpeg/libavcodec/cavsdsp.h b/lib/ffmpeg/libavcodec/cavsdsp.h
new file mode 100644
index 0000000000..d3fae69e84
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/cavsdsp.h
@@ -0,0 +1,41 @@
+/*
+ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
+ * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_CAVSDSP_H
+#define AVCODEC_CAVSDSP_H
+
+#include <stdint.h>
+#include "dsputil.h"
+
+typedef struct CAVSDSPContext {
+ qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
+ qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
+ void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
+ void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
+} CAVSDSPContext;
+
+void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx);
+void ff_cavsdsp_init_mmx(CAVSDSPContext* c, AVCodecContext *avctx);
+
+#endif
diff --git a/lib/ffmpeg/libavcodec/cdgraphics.c b/lib/ffmpeg/libavcodec/cdgraphics.c
index 8afbb27aad..68f556b3f3 100644
--- a/lib/ffmpeg/libavcodec/cdgraphics.c
+++ b/lib/ffmpeg/libavcodec/cdgraphics.c
@@ -367,7 +367,7 @@ static av_cold int cdg_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec cdgraphics_decoder = {
+AVCodec ff_cdgraphics_decoder = {
"cdgraphics",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CDGRAPHICS,
diff --git a/lib/ffmpeg/libavcodec/celp_filters.h b/lib/ffmpeg/libavcodec/celp_filters.h
index 7b64fc0306..145e3d3346 100644
--- a/lib/ffmpeg/libavcodec/celp_filters.h
+++ b/lib/ffmpeg/libavcodec/celp_filters.h
@@ -56,7 +56,7 @@ void ff_celp_circ_addf(float *out, const float *in,
/**
* LP synthesis filter.
- * @param out [out] pointer to output buffer
+ * @param[out] out pointer to output buffer
* @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
* @param in input signal
* @param buffer_length amount of data to process
@@ -79,7 +79,7 @@ int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
/**
* LP synthesis filter.
- * @param out [out] pointer to output buffer
+ * @param[out] out pointer to output buffer
* - the array out[-filter_length, -1] must
* contain the previous result of this filter
* @param filter_coeffs filter coefficients.
@@ -99,7 +99,7 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
/**
* LP zero synthesis filter.
- * @param out [out] pointer to output buffer
+ * @param[out] out pointer to output buffer
* @param filter_coeffs filter coefficients.
* @param in input signal
* - the array in[-filter_length, -1] must
diff --git a/lib/ffmpeg/libavcodec/cga_data.c b/lib/ffmpeg/libavcodec/cga_data.c
index 35239814ec..160d77cde2 100644
--- a/lib/ffmpeg/libavcodec/cga_data.c
+++ b/lib/ffmpeg/libavcodec/cga_data.c
@@ -1,5 +1,5 @@
/*
- * CGA ROM data
+ * CGA/EGA/VGA ROM data
*
* This file is part of FFmpeg.
*
@@ -18,7 +18,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * @file
+ * CGA/EGA/VGA ROM data
+ */
+
#include <stdint.h>
+#include "cga_data.h"
const uint8_t ff_cga_font[2048] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
@@ -151,6 +157,265 @@ const uint8_t ff_cga_font[2048] = {
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
+const uint8_t ff_vga16_font[4096] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x66, 0xc3, 0xc3, 0xdb, 0xdb, 0xc3, 0xc3, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xdb, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xc3, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc1, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+ 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00,
+ 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00,
+ 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0xff, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xdb, 0xdb, 0xff, 0x66, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00,
+ 0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xcc, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc6, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x3b, 0x1b, 0x7e, 0xd8, 0xdc, 0x77, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc6, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc6, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00,
+ 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x18, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x62, 0x66, 0x6f, 0x66, 0x66, 0x66, 0xf3, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00,
+ 0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
+ 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x9b, 0x06, 0x0c, 0x1f, 0x00, 0x00,
+ 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xce, 0x96, 0x3e, 0x06, 0x06, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44,
+ 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
+ 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
+ 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xd8, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x70, 0xd8, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
const uint32_t ff_cga_palette[16] = {
0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAA5500, 0xAAAAAA,
0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF,
@@ -166,3 +431,14 @@ const uint32_t ff_ega_palette[64] = {
0x555500, 0x5555AA, 0x55FF00, 0x55FFAA, 0xFF5500, 0xFF55AA, 0xFFFF00, 0xFFFFAA,
0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF
};
+
+void ff_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg)
+{
+ int char_y, mask;
+ for (char_y = 0; char_y < font_height; char_y++) {
+ for (mask = 0x80; mask; mask >>= 1) {
+ *dst++ = font[ch * font_height + char_y] & mask ? fg : bg;
+ }
+ dst += linesize - 8;
+ }
+}
diff --git a/lib/ffmpeg/libavcodec/cga_data.h b/lib/ffmpeg/libavcodec/cga_data.h
index 09aaaa57a1..788b2b3911 100644
--- a/lib/ffmpeg/libavcodec/cga_data.h
+++ b/lib/ffmpeg/libavcodec/cga_data.h
@@ -1,5 +1,5 @@
/*
- * CGA ROM data
+ * CGA/EGA/VGA ROM data
*
* This file is part of FFmpeg.
*
@@ -18,13 +18,31 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * @file
+ * CGA/EGA/VGA ROM data
+ */
+
#ifndef AVCODEC_CGA_DATA_H
#define AVCODEC_CGA_DATA_H
#include <stdint.h>
extern const uint8_t ff_cga_font[2048];
+extern const uint8_t ff_vga16_font[4096];
extern const uint32_t ff_cga_palette[16];
extern const uint32_t ff_ega_palette[64];
+/**
+ * Draw CGA/EGA/VGA font to 8-bit pixel buffer
+ *
+ * @param dst Destination pixel buffer
+ * @param linesize Linesize (pixels)
+ * @param font Font table. We assume font width is always 8 pixels wide.
+ * @param font_height Font height (pixels)
+ * @param fg,bg Foreground and background palette index
+ * @param ch Character to draw
+ */
+void ff_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg);
+
#endif
diff --git a/lib/ffmpeg/libavcodec/chomp_bsf.c b/lib/ffmpeg/libavcodec/chomp_bsf.c
index e9ac8e8e29..eaefaaa539 100644
--- a/lib/ffmpeg/libavcodec/chomp_bsf.c
+++ b/lib/ffmpeg/libavcodec/chomp_bsf.c
@@ -40,7 +40,7 @@ static int chomp_filter(AVBitStreamFilterContext *bsfc,
/**
* This filter removes a string of NULL bytes from the end of a packet.
*/
-AVBitStreamFilter chomp_bsf = {
+AVBitStreamFilter ff_chomp_bsf = {
"chomp",
0,
chomp_filter,
diff --git a/lib/ffmpeg/libavcodec/cinepak.c b/lib/ffmpeg/libavcodec/cinepak.c
index 8e7aa5aa99..52fde64813 100644
--- a/lib/ffmpeg/libavcodec/cinepak.c
+++ b/lib/ffmpeg/libavcodec/cinepak.c
@@ -455,7 +455,7 @@ static av_cold int cinepak_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec cinepak_decoder = {
+AVCodec ff_cinepak_decoder = {
"cinepak",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CINEPAK,
diff --git a/lib/ffmpeg/libavcodec/cljr.c b/lib/ffmpeg/libavcodec/cljr.c
index 47809c0ce4..36b6cbbb94 100644
--- a/lib/ffmpeg/libavcodec/cljr.c
+++ b/lib/ffmpeg/libavcodec/cljr.c
@@ -54,6 +54,11 @@ static int decode_frame(AVCodecContext *avctx,
if(p->data[0])
avctx->release_buffer(avctx, p);
+ if(buf_size/avctx->height < avctx->width) {
+ av_log(avctx, AV_LOG_ERROR, "Resolution larger than buffer size. Invalid header?\n");
+ return -1;
+ }
+
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
@@ -135,7 +140,7 @@ static av_cold int encode_init(AVCodecContext *avctx){
}
#endif
-AVCodec cljr_decoder = {
+AVCodec ff_cljr_decoder = {
"cljr",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CLJR,
@@ -149,7 +154,7 @@ AVCodec cljr_decoder = {
};
#if CONFIG_CLJR_ENCODER
-AVCodec cljr_encoder = {
+AVCodec ff_cljr_encoder = {
"cljr",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CLJR,
diff --git a/lib/ffmpeg/libavcodec/cook.c b/lib/ffmpeg/libavcodec/cook.c
index b7e2ef1a91..6b70560546 100644
--- a/lib/ffmpeg/libavcodec/cook.c
+++ b/lib/ffmpeg/libavcodec/cook.c
@@ -1270,7 +1270,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
return -1;
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (channel_mask)
avctx->channel_layout = channel_mask;
else
@@ -1283,7 +1283,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
}
-AVCodec cook_decoder =
+AVCodec ff_cook_decoder =
{
.name = "cook",
.type = AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/cscd.c b/lib/ffmpeg/libavcodec/cscd.c
index e4f4b8f825..82a44defc7 100644
--- a/lib/ffmpeg/libavcodec/cscd.c
+++ b/lib/ffmpeg/libavcodec/cscd.c
@@ -35,19 +35,19 @@ typedef struct {
unsigned char* decomp_buf;
} CamStudioContext;
-static void copy_frame_default(AVFrame *f, const uint8_t *src,
+static void copy_frame_default(AVFrame *f, const uint8_t *src, int src_stride,
int linelen, int height) {
int i;
uint8_t *dst = f->data[0];
dst += (height - 1) * f->linesize[0];
for (i = height; i; i--) {
memcpy(dst, src, linelen);
- src += linelen;
+ src += src_stride;
dst -= f->linesize[0];
}
}
-static void add_frame_default(AVFrame *f, const uint8_t *src,
+static void add_frame_default(AVFrame *f, const uint8_t *src, int src_stride,
int linelen, int height) {
int i, j;
uint8_t *dst = f->data[0];
@@ -55,15 +55,16 @@ static void add_frame_default(AVFrame *f, const uint8_t *src,
for (i = height; i; i--) {
for (j = linelen; j; j--)
*dst++ += *src++;
+ src += src_stride - linelen;
dst -= f->linesize[0] + linelen;
}
}
#if !HAVE_BIGENDIAN
-#define copy_frame_16 copy_frame_default
-#define copy_frame_32 copy_frame_default
-#define add_frame_16 add_frame_default
-#define add_frame_32 add_frame_default
+#define copy_frame_16(f, s, l, h) copy_frame_default(f, s, l, l, h)
+#define copy_frame_32(f, s, l, h) copy_frame_default(f, s, l, l, h)
+#define add_frame_16(f, s, l, h) add_frame_default(f, s, l, l, h)
+#define add_frame_32(f, s, l, h) add_frame_default(f, s, l, l, h)
#else
static void copy_frame_16(AVFrame *f, const uint8_t *src,
int linelen, int height) {
@@ -192,7 +193,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
copy_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
break;
default:
- copy_frame_default(&c->pic, c->decomp_buf, c->linelen, c->height);
+ copy_frame_default(&c->pic, c->decomp_buf, FFALIGN(c->linelen, 4),
+ c->linelen, c->height);
}
} else {
c->pic.pict_type = FF_P_TYPE;
@@ -205,7 +207,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
add_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
break;
default:
- add_frame_default(&c->pic, c->decomp_buf, c->linelen, c->height);
+ add_frame_default(&c->pic, c->decomp_buf, FFALIGN(c->linelen, 4),
+ c->linelen, c->height);
}
}
@@ -216,6 +219,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
static av_cold int decode_init(AVCodecContext *avctx) {
CamStudioContext *c = avctx->priv_data;
+ int stride;
switch (avctx->bits_per_coded_sample) {
case 16: avctx->pix_fmt = PIX_FMT_RGB555; break;
case 24: avctx->pix_fmt = PIX_FMT_BGR24; break;
@@ -224,13 +228,16 @@ static av_cold int decode_init(AVCodecContext *avctx) {
av_log(avctx, AV_LOG_ERROR,
"CamStudio codec error: invalid depth %i bpp\n",
avctx->bits_per_coded_sample);
- return 1;
+ return 1;
}
c->bpp = avctx->bits_per_coded_sample;
c->pic.data[0] = NULL;
c->linelen = avctx->width * avctx->bits_per_coded_sample / 8;
c->height = avctx->height;
- c->decomp_size = c->height * c->linelen;
+ stride = c->linelen;
+ if (avctx->bits_per_coded_sample == 24)
+ stride = FFALIGN(stride, 4);
+ c->decomp_size = c->height * stride;
c->decomp_buf = av_malloc(c->decomp_size + AV_LZO_OUTPUT_PADDING);
if (!c->decomp_buf) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
@@ -247,7 +254,7 @@ static av_cold int decode_end(AVCodecContext *avctx) {
return 0;
}
-AVCodec cscd_decoder = {
+AVCodec ff_cscd_decoder = {
"camstudio",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CSCD,
diff --git a/lib/ffmpeg/libavcodec/cyuv.c b/lib/ffmpeg/libavcodec/cyuv.c
index db7e690be7..79a84412e7 100644
--- a/lib/ffmpeg/libavcodec/cyuv.c
+++ b/lib/ffmpeg/libavcodec/cyuv.c
@@ -178,7 +178,7 @@ static av_cold int cyuv_decode_end(AVCodecContext *avctx)
}
#if CONFIG_AURA_DECODER
-AVCodec aura_decoder = {
+AVCodec ff_aura_decoder = {
"aura",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_AURA,
@@ -194,7 +194,7 @@ AVCodec aura_decoder = {
#endif
#if CONFIG_CYUV_DECODER
-AVCodec cyuv_decoder = {
+AVCodec ff_cyuv_decoder = {
"cyuv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CYUV,
diff --git a/lib/ffmpeg/libavcodec/dca.c b/lib/ffmpeg/libavcodec/dca.c
index 9817790e5f..2e2b37fd81 100644
--- a/lib/ffmpeg/libavcodec/dca.c
+++ b/lib/ffmpeg/libavcodec/dca.c
@@ -29,6 +29,7 @@
#include "libavutil/common.h"
#include "libavutil/intmath.h"
#include "libavutil/intreadwrite.h"
+#include "libavcore/audioconvert.h"
#include "avcodec.h"
#include "dsputil.h"
#include "fft.h"
@@ -39,6 +40,7 @@
#include "dca.h"
#include "synth_filter.h"
#include "dcadsp.h"
+#include "fmtconvert.h"
//#define TRACE
@@ -108,22 +110,22 @@ enum DCAExtensionMask {
*/
static const int64_t dca_core_channel_layout[] = {
- CH_FRONT_CENTER, ///< 1, A
- CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
- CH_LAYOUT_STEREO, ///< 2, L + R (stereo)
- CH_LAYOUT_STEREO, ///< 2, (L+R) + (L-R) (sum-difference)
- CH_LAYOUT_STEREO, ///< 2, LT +RT (left and right total)
- CH_LAYOUT_STEREO|CH_FRONT_CENTER, ///< 3, C+L+R
- CH_LAYOUT_STEREO|CH_BACK_CENTER, ///< 3, L+R+S
- CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_BACK_CENTER, ///< 4, C + L + R+ S
- CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT, ///< 4, L + R +SL+ SR
- CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_SIDE_LEFT|CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR
- CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
- CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_FRONT_CENTER|CH_BACK_CENTER, ///< 6, C + L + R+ LR + RR + OV
- CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_FRONT_LEFT_OF_CENTER|CH_BACK_CENTER|CH_BACK_LEFT|CH_BACK_RIGHT, ///< 6, CF+ CR+LF+ RF+LR + RR
- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT|CH_BACK_LEFT|CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2
- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_BACK_CENTER|CH_SIDE_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR
+ AV_CH_FRONT_CENTER, ///< 1, A
+ AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
+ AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo)
+ AV_CH_LAYOUT_STEREO, ///< 2, (L+R) + (L-R) (sum-difference)
+ AV_CH_LAYOUT_STEREO, ///< 2, LT +RT (left and right total)
+ AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER, ///< 3, C+L+R
+ AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER, ///< 3, L+R+S
+ AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|CH_BACK_CENTER, ///< 4, C + L + R+ S
+ AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 4, L + R +SL+ SR
+ AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR
+ AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
+ AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 6, C + L + R+ LR + RR + OV
+ AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 6, CF+ CR+LF+ RF+LR + RR
+ AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
+ AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2
+ AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_BACK_CENTER|AV_CH_SIDE_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR
};
static const int8_t dca_lfe_index[] = {
@@ -218,6 +220,8 @@ static const int8_t dca_channel_reorder_nolfe_xch[][9] = {
#define DCA_MAX_FRAME_SIZE 16384
#define DCA_MAX_EXSS_HEADER_SIZE 4096
+#define DCA_BUFFER_PADDING_SIZE 1024
+
/** Bit allocation */
typedef struct {
int offset; ///< code values offset
@@ -270,6 +274,7 @@ typedef struct {
/* Primary audio coding header */
int subframes; ///< number of subframes
+ int is_channels_set; ///< check for if the channel number is already set
int total_channels; ///< number of channels including extensions
int prim_channels; ///< number of primary audio channels
int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count
@@ -307,14 +312,13 @@ typedef struct {
DECLARE_ALIGNED(16, float, raXin)[32];
int output; ///< type of output
- float add_bias; ///< output bias
float scale_bias; ///< output scale
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 + DCA_MAX_EXSS_HEADER_SIZE];
+ uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE];
int dca_buffer_size; ///< how much data is in the dca_buffer
const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe
@@ -344,6 +348,7 @@ typedef struct {
FFTContext imdct;
SynthFilterContext synth;
DCADSPContext dcadsp;
+ FmtConvertContext fmt_conv;
} DCAContext;
static const uint16_t dca_vlc_offs[] = {
@@ -604,6 +609,9 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
/* Primary audio coding side information */
int j, k;
+ if (get_bits_left(&s->gb) < 0)
+ return -1;
+
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);
@@ -660,6 +668,9 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
}
}
+ if (get_bits_left(&s->gb) < 0)
+ return -1;
+
for (j = base_channel; j < s->prim_channels; j++) {
const uint32_t *scale_table;
int scale_sum;
@@ -695,6 +706,9 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
s->joint_huff[j] = get_bits(&s->gb, 3);
}
+ if (get_bits_left(&s->gb) < 0)
+ return -1;
+
/* Scale factors for joint subband coding */
for (j = base_channel; j < s->prim_channels; j++) {
int source_channel;
@@ -738,7 +752,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
}
/* Dynamic range coefficient */
- if (s->dynrange)
+ if (!base_channel && s->dynrange)
s->dynrange_coef = get_bits(&s->gb, 8);
/* Side information CRC check word */
@@ -855,7 +869,7 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
static void qmf_32_subbands(DCAContext * s, int chans,
float samples_in[32][8], float *samples_out,
- float scale, float bias)
+ float scale)
{
const float *prCoeff;
int i;
@@ -884,7 +898,7 @@ static void qmf_32_subbands(DCAContext * s, int chans,
s->synth.synth_filter_float(&s->imdct,
s->subband_fir_hist[chans], &s->hist_index[chans],
s->subband_fir_noidea[chans], prCoeff,
- samples_out, s->raXin, scale, bias);
+ samples_out, s->raXin, scale);
samples_out+= 32;
}
@@ -892,8 +906,7 @@ static void qmf_32_subbands(DCAContext * s, int chans,
static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
int num_deci_sample, float *samples_in,
- float *samples_out, float scale,
- float bias)
+ float *samples_out, float scale)
{
/* samples_in: An array holding decimated samples.
* Samples in current subframe starts from samples_in[0],
@@ -918,7 +931,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
/* Interpolation */
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor,
- scale, bias);
+ scale);
samples_in++;
samples_out += 2 * decifactor;
}
@@ -926,7 +939,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
/* downmixing routines */
#define MIX_REAR1(samples, si1, rs, coef) \
- samples[i] += samples[si1] * coef[rs][0]; \
+ samples[i] += samples[si1] * coef[rs][0]; \
samples[i+256] += samples[si1] * coef[rs][1];
#define MIX_REAR2(samples, si1, si2, rs, coef) \
@@ -934,9 +947,11 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs+1][1];
#define MIX_FRONT3(samples, coef) \
- t = samples[i]; \
- samples[i] = t * coef[0][0] + samples[i+256] * coef[1][0] + samples[i+512] * coef[2][0]; \
- samples[i+256] = t * coef[0][1] + samples[i+256] * coef[1][1] + samples[i+512] * coef[2][1];
+ t = samples[i+c]; \
+ u = samples[i+l]; \
+ v = samples[i+r]; \
+ samples[i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
+ samples[i+256] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
#define DOWNMIX_TO_STEREO(op1, op2) \
for (i = 0; i < 256; i++){ \
@@ -945,10 +960,12 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
}
static void dca_downmix(float *samples, int srcfmt,
- int downmix_coef[DCA_PRIM_CHANNELS_MAX][2])
+ int downmix_coef[DCA_PRIM_CHANNELS_MAX][2],
+ const int8_t *channel_mapping)
{
+ int c,l,r,sl,sr,s;
int i;
- float t;
+ float t, u, v;
float coef[DCA_PRIM_CHANNELS_MAX][2];
for (i=0; i<DCA_PRIM_CHANNELS_MAX; i++) {
@@ -967,21 +984,36 @@ static void dca_downmix(float *samples, int srcfmt,
case DCA_STEREO:
break;
case DCA_3F:
+ c = channel_mapping[0] * 256;
+ l = channel_mapping[1] * 256;
+ r = channel_mapping[2] * 256;
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),);
break;
case DCA_2F1R:
- DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + 512, 2, coef),);
+ s = channel_mapping[2] * 256;
+ DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + s, 2, coef),);
break;
case DCA_3F1R:
+ c = channel_mapping[0] * 256;
+ l = channel_mapping[1] * 256;
+ r = channel_mapping[2] * 256;
+ s = channel_mapping[3] * 256;
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
- MIX_REAR1(samples, i + 768, 3, coef));
+ MIX_REAR1(samples, i + s, 3, coef));
break;
case DCA_2F2R:
- DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + 512, i + 768, 2, coef),);
+ sl = channel_mapping[2] * 256;
+ sr = channel_mapping[3] * 256;
+ DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + sl, i + sr, 2, coef),);
break;
case DCA_3F2R:
+ c = channel_mapping[0] * 256;
+ l = channel_mapping[1] * 256;
+ r = channel_mapping[2] * 256;
+ sl = channel_mapping[3] * 256;
+ sr = channel_mapping[4] * 256;
DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
- MIX_REAR2(samples, i + 768, i + 1024, 3, coef));
+ MIX_REAR2(samples, i + sl, i + sr, 3, coef));
break;
}
}
@@ -1033,6 +1065,9 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
quant_step_table = lossy_quant_d;
for (k = base_channel; k < s->prim_channels; k++) {
+ if (get_bits_left(&s->gb) < 0)
+ return -1;
+
for (l = 0; l < s->vq_start_subband[k]; l++) {
int m;
@@ -1082,7 +1117,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
}
- s->dsp.int32_to_float_fmul_scalar(subband_samples[k][l],
+ s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
block, rscale, 8);
}
@@ -1158,13 +1193,12 @@ static int dca_filter_channels(DCAContext * s, int block_index)
/* static float pcm_to_double[8] =
{32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * s->channel_order_tab[k]],
- M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ ,
- s->add_bias );
+ M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ );
}
/* Down mixing */
if (s->avctx->request_channels == 2 && s->prim_channels > 2) {
- dca_downmix(s->samples, s->amode, s->downmix_coef);
+ dca_downmix(s->samples, s->amode, s->downmix_coef, s->channel_order_tab);
}
/* Generate LFE samples for this subsubframe FIXME!!! */
@@ -1172,7 +1206,7 @@ static int dca_filter_channels(DCAContext * s, int block_index)
lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
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);
+ (1.0/256.0)*s->scale_bias);
/* Outputs 20bits pcm samples */
}
@@ -1322,7 +1356,9 @@ static int dca_exss_mask2count(int mask)
*/
static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch)
{
- for (int i = 0; i < channels; i++) {
+ int i;
+
+ for (i = 0; i < channels; i++) {
int mix_map_mask = get_bits(gb, out_ch);
int num_coeffs = av_popcount(mix_map_mask);
skip_bits_long(gb, num_coeffs * 6);
@@ -1668,15 +1704,21 @@ static int dca_decode_frame(AVCodecContext * avctx,
s->profile = FFMAX(s->profile, FF_PROFILE_DTS_ES);
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);
+ case 0x1d95f262: {
+ int fsize96 = show_bits(&s->gb, 12) + 1;
+ if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)
+ continue;
+
+ av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", get_bits_count(&s->gb));
+ skip_bits(&s->gb, 12);
+ av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
s->x96_present = 1;
s->profile = FFMAX(s->profile, FF_PROFILE_DTS_96_24);
break;
}
+ }
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
}
@@ -1694,30 +1736,32 @@ static int dca_decode_frame(AVCodecContext * avctx,
avctx->channel_layout = dca_core_channel_layout[s->amode];
if (s->xch_present && (!avctx->request_channels ||
- avctx->request_channels > num_core_channels)) {
- avctx->channel_layout |= CH_BACK_CENTER;
+ avctx->request_channels > num_core_channels + !!s->lfe)) {
+ avctx->channel_layout |= AV_CH_BACK_CENTER;
if (s->lfe) {
- avctx->channel_layout |= CH_LOW_FREQUENCY;
+ avctx->channel_layout |= AV_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 {
+ channels = num_core_channels + !!s->lfe;
+ s->xch_present = 0; /* disable further xch processing */
if (s->lfe) {
- avctx->channel_layout |= CH_LOW_FREQUENCY;
+ avctx->channel_layout |= AV_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)
+ if (channels > !!s->lfe &&
+ s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
return -1;
if (avctx->request_channels == 2 && s->prim_channels > 2) {
channels = 2;
s->output = DCA_STEREO;
- avctx->channel_layout = CH_LAYOUT_STEREO;
+ avctx->channel_layout = AV_CH_LAYOUT_STEREO;
}
} else {
av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode);
@@ -1730,8 +1774,15 @@ static int dca_decode_frame(AVCodecContext * avctx,
unset. Ideally during the first probe for channels the crc should be checked
and only set avctx->channels when the crc is ok. Right now the decoder could
set the channels based on a broken first frame.*/
- if (!avctx->channels)
+ if (s->is_channels_set == 0) {
+ s->is_channels_set = 1;
avctx->channels = channels;
+ }
+ if (avctx->channels != channels) {
+ av_log(avctx, AV_LOG_ERROR, "DCA decoder does not support number of "
+ "channels changing in stream. Skipping frame.\n");
+ return -1;
+ }
if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
return -1;
@@ -1749,12 +1800,12 @@ static int dca_decode_frame(AVCodecContext * avctx,
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;
+ lt_chan[j] -= back_chan[j] * M_SQRT1_2;
+ rt_chan[j] -= back_chan[j] * M_SQRT1_2;
}
}
- s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
+ s->fmt_conv.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels);
samples += 256 * channels;
}
@@ -1787,26 +1838,20 @@ static av_cold int dca_decode_init(AVCodecContext * avctx)
ff_mdct_init(&s->imdct, 6, 1, 1.0);
ff_synth_filter_init(&s->synth);
ff_dcadsp_init(&s->dcadsp);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++)
s->samples_chanptr[i] = s->samples + i * 256;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- 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 {
- s->add_bias = 0.0f;
- s->scale_bias = 1.0;
+ s->scale_bias = 1.0;
- /* allow downmixing to stereo */
- if (avctx->channels > 0 && avctx->request_channels < avctx->channels &&
- avctx->request_channels == 2) {
- avctx->channels = avctx->request_channels;
- }
+ /* allow downmixing to stereo */
+ if (avctx->channels > 0 && avctx->request_channels < avctx->channels &&
+ avctx->request_channels == 2) {
+ avctx->channels = avctx->request_channels;
}
-
return 0;
}
@@ -1826,7 +1871,7 @@ static const AVProfile profiles[] = {
{ FF_PROFILE_UNKNOWN },
};
-AVCodec dca_decoder = {
+AVCodec ff_dca_decoder = {
.name = "dca",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_DTS,
@@ -1835,5 +1880,6 @@ AVCodec dca_decoder = {
.decode = dca_decode_frame,
.close = dca_decode_end,
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
- .profiles = profiles,
+ .capabilities = CODEC_CAP_CHANNEL_CONF,
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};
diff --git a/lib/ffmpeg/libavcodec/dca_parser.c b/lib/ffmpeg/libavcodec/dca_parser.c
index 01c559709a..a956e7506b 100644
--- a/lib/ffmpeg/libavcodec/dca_parser.c
+++ b/lib/ffmpeg/libavcodec/dca_parser.c
@@ -125,7 +125,7 @@ static int dca_parse(AVCodecParserContext * s,
return next;
}
-AVCodecParser dca_parser = {
+AVCodecParser ff_dca_parser = {
{CODEC_ID_DTS},
sizeof(DCAParseContext),
dca_parse_init,
diff --git a/lib/ffmpeg/libavcodec/dcadata.h b/lib/ffmpeg/libavcodec/dcadata.h
index fbd22ab211..e8a31fd0a1 100644
--- a/lib/ffmpeg/libavcodec/dcadata.h
+++ b/lib/ffmpeg/libavcodec/dcadata.h
@@ -60,4102 +60,4102 @@ static const uint8_t dca_bits_per_sample[7] =
/* 16bits signed fractional Q13 binary codes */
static const int16_t adpcm_vb[4096][4] =
{
- { 9928, -2618, -1093, -1263 },
- { 11077, -2876, -1747, -308 },
- { 10503, -1082, -1426, -1167 },
- { 9337, -2403, -1495, 274 },
- { 10698, -2529, -532, -1122 },
- { 10368, -3974, -1264, -750 },
- { 10070, -3667, 346, 863 },
- { 10278, -3093, 311, -576 },
- { 9894, -1330, -1428, -860 },
- { 10544, -1923, -1058, -971 },
- { 10996, -1632, -841, -1404 },
- { 11832, -3465, 1658, -1990 },
- { 10852, -688, -2658, -499 },
- { 10546, -1749, -147, -1733 },
- { 10801, -1004, -708, -1453 },
- { 10588, -441, -2113, -952 },
- { 10141, -3331, -582, -1432 },
- { 9608, -2590, 383, 258 },
- { 11422, -3265, 229, -1544 },
- { 10460, -1338, -713, -1568 },
- { 10306, -1721, -1660, -603 },
- { 9580, -1812, -1235, -1061 },
- { 11471, -2285, -1617, -607 },
- { 10081, -2225, -1408, -868 },
- { 10715, -2624, -1367, -704 },
- { 10616, -1871, -2770, -35 },
- { 9352, -2340, -1024, -1566 },
- { 11065, -1458, -1926, -735 },
- { 11334, -2056, -1041, -1144 },
- { 9825, -2048, -794, -1536 },
- { 11850, -2695, -1123, -867 },
- { 10654, -2226, -1891, -373 },
- { 10024, -1557, -808, -1069 },
- { 11142, -1266, -3238, 128 },
- { 11729, -3282, -514, -1011 },
- { 11402, -2094, -2335, -189 },
- { 10195, -3658, 181, -1875 },
- { 11431, -2626, -404, -1377 },
- { 11001, -3868, -619, -1077 },
- { 10894, -2559, 274, -1758 },
- { 9633, -1482, -2253, -773 },
- { 11245, -3321, 830, -1972 },
- { 9768, -2701, -199, -1859 },
- { 10500, -2042, 525, -2043 },
- { 11669, -4069, 293, -1468 },
- { 9192, -1991, -583, -61 },
- { 10057, -3220, -2015, -473 },
- { 9497, -2315, -2490, -467 },
- { 10455, -3069, -1194, -1007 },
- { 9994, -1936, -60, -1225 },
- { 9295, -2156, -1761, -1134 },
- { 10085, -3748, -1026, 197 },
- { 9334, -2360, 804, -351 },
- { 11561, -2553, 1352, -2313 },
- { 12837, -3998, 1195, -1958 },
- { 10114, -1100, -2414, -394 },
- { 9341, -2530, 315, 755 },
- { 10131, -3164, 1411, -674 },
- { 9535, -905, -1551, 579 },
- { 11717, -1519, -3051, 91 },
- { 9824, -2911, -2775, 192 },
- { 9662, -2934, -561, 1450 },
- { 11085, -3392, -1298, -659 },
- { 8955, -2102, -1899, 703 },
- { 8607, -1742, -4348, 814 },
- { 7640, -2063, -3617, 52 },
- { 7074, -826, -4325, 4375 },
- { 7714, 584, -4238, 1927 },
- { 6355, -952, -4912, 3127 },
- { 7069, -660, -6413, 4087 },
- { 8313, -132, -2964, -876 },
- { 6952, -1422, -3962, -24 },
- { 9299, -734, -3088, -263 },
- { 9484, -574, -4513, 466 },
- { 7246, -91, -3735, -704 },
- { 8325, -1417, -3090, -530 },
- { 6469, -1226, -4757, 829 },
- { 6652, -368, -5682, 1393 },
- { 7971, -1278, -2284, 1205 },
- { 7229, -699, -3556, 1840 },
- { 7994, 1284, -2729, 732 },
- { 9005, -698, -4522, 2189 },
- { 6963, 197, -2727, 380 },
- { 8527, 135, -3991, -213 },
- { 8840, 934, -3014, -567 },
- { 10125, 418, -3284, -371 },
- { 6367, 361, -2318, 2554 },
- { 7892, 172, -5247, 4673 },
- { 6674, 387, -5424, 4398 },
- { 6240, 684, -4047, 1219 },
- { 11170, -794, -5081, 1195 },
- { 11765, -648, -6265, 2052 },
- { 10845, -775, -3837, 366 },
- { 12496, -689, -8260, 3562 },
- { 7893, -1166, -4972, 988 },
- { 8592, 1052, -5986, 3087 },
- { 7277, 1874, -5685, 3579 },
- { 6900, 2016, -4809, 3491 },
- { 8530, -2405, -3250, 1986 },
- { 9426, 494, -7067, 5038 },
- { 10285, 564, -8210, 5370 },
- { 8749, -2207, -3980, 2852 },
- { 9653, -2686, -4300, 1400 },
- { 9770, -2286, -5663, 4233 },
- { 8490, -4, -7048, 4496 },
- { 7697, -1209, -5328, 3183 },
- { 6451, 801, -4324, -554 },
- { 7387, 1806, -5265, 545 },
- { 7450, -2302, -4445, 1418 },
- { 8817, -1370, -5827, 2168 },
- { 10324, -2406, -5629, 2579 },
- { 8863, -2578, -3537, 467 },
- { 6901, -1624, -3169, 3392 },
- { 7846, 156, -6948, 3381 },
- { 7928, -1115, -5972, 4816 },
- { 6089, -599, -4368, -320 },
- { 7833, 1246, -3960, -621 },
- { 8931, 2521, -6768, 2052 },
- { 8900, 1944, -4126, 40 },
- { 7661, -34, -2855, 2480 },
- { 5873, 474, -3262, 3712 },
- { 7535, -234, -4699, 216 },
- { 5856, 143, -5142, 73 },
- { 8944, -106, -5874, 3663 },
- { 7134, 426, -5879, 2895 },
- { 10199, 1011, -4762, 369 },
- { 8454, 264, -5971, 1291 },
- { 7822, -2449, -4333, 4540 },
- { 6200, -2758, -2632, 1497 },
- { 6070, -4315, -2699, 414 },
- { 7047, -3739, -3210, 1060 },
- { 5675, -3801, -2717, -407 },
- { 4789, -4063, -2628, -744 },
- { 4023, -3366, -3133, -726 },
- { 4296, -2407, -3381, -513 },
- { 4388, -2931, -2820, 1512 },
- { 4559, -4233, -1941, 1976 },
- { 6702, -3208, -1755, 1680 },
- { 4416, -3521, -1052, 2984 },
- { 7154, -4266, -1203, 3732 },
- { 3625, -4242, -3244, 1395 },
- { 6518, -2856, -1304, 2887 },
- { 6170, -1949, -3014, 3973 },
- { 5189, -2451, -4020, 3477 },
- { 6218, -2988, -1921, 3844 },
- { 4827, -3688, -1928, 3343 },
- { 6668, -3991, -2805, 3095 },
- { 5297, -3115, -3684, 2390 },
- { 5354, -4614, -2662, 1504 },
- { 4196, -3091, -4147, 1135 },
- { 3540, -2893, -4007, 100 },
- { 5569, -1602, -4007, 1909 },
- { 4341, -2091, -4272, 252 },
- { 5559, -2878, -3832, 498 },
- { 4548, -4479, -2898, -27 },
- { 5176, -2494, -4635, 1476 },
- { 3294, -3485, -3738, 716 },
- { 4920, -1229, -4195, -365 },
- { 3257, -3518, -3349, 2862 },
- { 5286, -1948, -3485, -778 },
- { 6502, -3051, -152, 2854 },
- { 5864, -4192, -1076, 3451 },
- { 4656, -3122, -3448, 179 },
- { 5907, -754, -1596, 3116 },
- { 7229, -3680, -1590, 2892 },
- { 5107, -3888, -3364, 806 },
- { 6764, -2635, -3450, 134 },
- { 5258, -2827, -2844, -1052 },
- { 5798, -1725, -4305, 205 },
- { 5404, -1213, -3362, 449 },
- { 6224, -2738, -3046, -581 },
- { 4223, -2438, -2725, 3745 },
- { 4751, -3411, -2123, 116 },
- { 3868, -3000, -3954, 2297 },
- { 6819, -2899, -4277, 2825 },
- { 4207, -4754, -2808, 865 },
- { 4804, -1494, -1997, 4688 },
- { 5282, -2213, -548, 3559 },
- { 5580, -1912, -566, 4370 },
- { 6168, -2857, -672, 4053 },
- { 6583, -4515, -2850, 1670 },
- { 6511, -3093, -3988, 1421 },
- { 4646, -1790, -1443, 3650 },
- { 5915, -924, -2020, 896 },
- { 7814, -4181, -3152, 2007 },
- { 6190, -2238, -4817, 2279 },
- { 4737, -4034, -3288, 1835 },
- { 8161, -3633, -3423, 3137 },
- { 7415, -2351, -2088, 4290 },
- { 4106, -2517, -62, 2905 },
- { 4909, -3145, -614, 4112 },
- { 4938, -3281, -397, 1100 },
- { -173, 919, 1589, -5363 },
- { -13, 796, -295, -6655 },
- { -1860, -829, 1141, -4555 },
- { 2298, -838, -664, -5005 },
- { -884, -1097, 2074, -4613 },
- { -101, 281, 2846, -4535 },
- { 1166, 453, 2429, -5910 },
- { 879, -664, 2370, -5452 },
- { 1415, -370, -1699, -4727 },
- { -1413, 1277, -669, -6649 },
- { 2133, 304, -968, -4624 },
- { 380, 586, -2087, -4892 },
- { 1336, 275, -82, -5789 },
- { -2459, 1057, -34, -5416 },
- { 2278, -1758, 866, -5653 },
- { 1945, -2295, -149, -5302 },
- { 1287, -3525, 996, -5255 },
- { 2297, 803, 1177, -6067 },
- { 187, -180, -619, -6202 },
- { -793, -2537, 1554, -5057 },
- { -2703, -204, -629, -5853 },
- { -1007, -146, 313, -5582 },
- { 830, 357, 869, -6363 },
- { -228, -575, -3177, -4433 },
- { -1001, -1553, -142, -5708 },
- { -1644, 1683, 1721, -4533 },
- { 893, 1924, -15, -5791 },
- { 2195, 2061, -262, -5471 },
- { 3031, 270, 311, -5096 },
- { 1912, 1638, -1523, -4677 },
- { -3142, -55, 253, -4914 },
- { 356, -1680, 343, -6123 },
- { -2241, -1734, -976, -5939 },
- { -2196, -2893, 547, -4938 },
- { -1245, 126, -1916, -5419 },
- { -249, -3755, -1422, -5594 },
- { 575, -2683, -1926, -4566 },
- { -762, 1885, 192, -5880 },
- { -811, -2562, -1068, -6013 },
- { -2264, -3086, -976, -4775 },
- { 70, -1215, 2880, -4410 },
- { 714, -3760, 2916, -4691 },
- { -244, -3404, 1740, -4493 },
- { 684, -5137, -328, -5608 },
- { -529, -3825, -1786, -4535 },
- { -713, -4743, -1118, -5546 },
- { 2718, -3788, 1798, -5708 },
- { -1639, -3679, -1564, -6095 },
- { 1693, -2642, -1389, -4539 },
- { 505, -1573, -1651, -4878 },
- { -835, -2256, -1941, -5352 },
- { 1464, -411, 1993, -6441 },
- { 493, -3184, -145, -6148 },
- { -1413, 499, -1617, -6479 },
- { -294, 1722, -1419, -5725 },
- { -2937, -1528, -175, -4624 },
- { -594, -5911, -56, -6146 },
- { -300, -4275, 1156, -5947 },
- { 552, -2643, 2669, -3959 },
- { 905, -4158, 1789, -5809 },
- { 1336, -2009, 2108, -5903 },
- { 1555, -3600, 1110, -6759 },
- { -1294, -3464, 77, -6084 },
- { -1139, -4006, -1270, -4181 },
- { -5094, -3296, 1092, -2847 },
- { -5503, -2883, 1984, -2067 },
- { -4671, -4218, -1417, -4132 },
- { -3763, -3818, 1262, -3082 },
- { -5132, -3430, 2928, -728 },
- { -5957, -2877, 1251, -2446 },
- { -4425, -2319, -212, -4276 },
- { -6201, -1993, 1774, -2182 },
- { -5500, -3836, 2201, -1396 },
- { -6934, -2334, 2366, -1293 },
- { -6124, -4140, 1337, -1977 },
- { -6553, -4186, 1756, -1325 },
- { -5126, -1258, 744, -3656 },
- { -5167, -1390, 1581, -2895 },
- { -4525, -3398, 2429, -1865 },
- { -4076, -3183, 2027, -2510 },
- { -6191, -3274, 1838, -1814 },
- { -4454, -2753, 2723, -1185 },
- { -6655, -4797, 251, -2595 },
- { -6332, -2232, 1832, 217 },
- { -5869, -1698, 134, 340 },
- { -6614, -1045, 2126, -1932 },
- { -4859, -2107, 2010, -2435 },
- { -6274, -1622, 2808, -1374 },
- { -3119, -3209, 521, -3988 },
- { -5676, -2082, -420, -2711 },
- { -7073, -3623, 696, -2343 },
- { -5986, -4224, 572, -2454 },
- { -4340, -4521, 882, -2771 },
- { -6178, -1933, 535, -1444 },
- { -4923, -4163, 1744, -2066 },
- { -6410, -1519, 1058, -2683 },
- { -5077, -1185, 856, -2216 },
- { -7091, -2444, 687, -2597 },
- { -5284, -2165, 3239, -993 },
- { -4763, -1497, 197, -3179 },
- { -4128, -4958, -396, -3578 },
- { -5054, -3878, -647, -2672 },
- { -7005, -3348, 1679, -1579 },
- { -5767, -1017, 2582, -1915 },
- { -7069, -2787, 1331, -2070 },
- { -5532, -2296, 706, -2950 },
- { -5059, -3543, -821, -3637 },
- { -6639, -1835, 1016, -696 },
- { -5611, -5220, -694, -3371 },
- { -5994, -2803, 2933, -729 },
- { -5948, -619, 1596, -2676 },
- { -5486, -4419, 153, -3265 },
- { -4329, -3440, 1646, -1439 },
- { -4083, -3978, 177, -3569 },
- { -4289, -2599, 1224, -3075 },
- { -5707, -3253, 1912, -759 },
- { -6606, -3437, 2562, -571 },
- { -5254, -2444, 769, -352 },
- { -6545, -3154, 582, -1103 },
- { -5328, -2241, 2566, -1775 },
- { -7216, -1936, 1538, -1983 },
- { -3730, -2451, 426, -3869 },
- { -5110, -1385, 2031, -1169 },
- { -6470, -2715, 269, -3123 },
- { -5806, -2480, -97, -3832 },
- { -3683, -4916, -490, -4330 },
- { -6341, -2083, -669, -115 },
- { -4913, -4079, -837, -4673 },
- { -3274, -2497, 2334, -2652 },
- { -1286, -1731, 2550, -3756 },
- { -3375, -877, 926, -3977 },
- { -2525, -2079, 2879, -2625 },
- { -5308, -504, 3111, -1607 },
- { -4904, 460, 4093, -1232 },
- { -1993, 1616, 4656, -1913 },
- { -3481, -1176, 3119, -2236 },
- { -4132, -1502, 2339, -2545 },
- { -2542, 1151, 3569, -2550 },
- { -4381, 430, 3147, -2082 },
- { -3888, 867, 3899, -1657 },
- { -2861, 1290, 4202, -1979 },
- { -3893, -253, 2363, -2764 },
- { -1705, 688, 3827, -2923 },
- { -2223, 2312, 3700, -3148 },
- { -1986, -720, 5021, -795 },
- { -3177, 242, 1952, -3352 },
- { -1854, 1509, 2528, -3815 },
- { -3173, 97, 5019, -706 },
- { -2689, -145, 1375, -3915 },
- { -4838, -385, 2488, -2427 },
- { -4557, -355, 1603, -3060 },
- { -3522, 1832, 3292, -2674 },
- { -3769, 780, 2378, -2704 },
- { -4323, -1932, 3414, -1169 },
- { -2740, 1158, 2729, -3273 },
- { -3647, 210, 1464, -2892 },
- { -2342, -2097, 1513, -3727 },
- { -4422, -1242, 3130, -1833 },
- { -1308, -1039, 4290, -1875 },
- { -1754, -2535, 3298, -2314 },
- { -4102, -186, 4037, -1094 },
- { -1008, 1570, 3290, 171 },
- { -3322, -2621, 2791, -1536 },
- { -2539, -2597, 3442, -1672 },
- { -3411, -2015, 3670, -1174 },
- { -2097, 730, 5581, -1399 },
- { -1510, -74, 4820, -2004 },
- { -4086, -868, 4425, -771 },
- { -956, -986, 3640, -2925 },
- { -2087, -1250, 3464, -2458 },
- { -3308, -2411, 1334, -3667 },
- { -2264, -389, 4004, -1854 },
- { -680, 239, 4058, -3388 },
- { -1357, 30, 2993, -3658 },
- { -3601, -552, 1177, -1136 },
- { -2641, 442, 4374, -1625 },
- { -2525, 770, 1640, -3895 },
- { -3172, -891, 3893, -1608 },
- { -2996, 13, 3277, -2414 },
- { -899, 1055, 4470, -2501 },
- { -422, -584, 3475, -3787 },
- { -1978, -593, 2566, -3415 },
- { -3150, -1280, 2362, -3047 },
- { -3592, 224, 1026, -3932 },
- { -4840, -1189, 3633, -879 },
- { -3952, -2255, 2916, -1826 },
- { -1695, 28, 1810, -349 },
- { -745, -2484, 3308, -3293 },
- { -1016, 1563, 5365, -1823 },
- { -2172, -1787, 4266, -1287 },
- { -1241, -1951, 3982, -2413 },
- { -2009, -2639, 2330, -3480 },
- { 5105, -1618, -2588, -2015 },
- { 6497, -1523, -3218, -910 },
- { 6526, -2305, -2029, -1790 },
- { 5289, -99, -3436, -400 },
- { 5781, -1623, -1577, -2617 },
- { 5259, -670, -3125, -1700 },
- { 6343, -1256, -331, -3222 },
- { 7967, -678, -2195, -1462 },
- { 6119, -695, -2988, -1538 },
- { 6108, 494, -3359, -1548 },
- { 5067, 969, -2328, -2707 },
- { 7595, -435, -1497, -2056 },
- { 6929, -719, -2420, -1665 },
- { 5190, 584, -2982, -2103 },
- { 6106, -444, -1411, -2739 },
- { 5584, 289, -1804, -2803 },
- { 5276, 227, -1180, -3361 },
- { 7544, -1525, -1834, -1725 },
- { 5986, -1470, -2606, -1701 },
- { 5096, -765, -1712, -3006 },
- { 5423, -149, -3933, -1157 },
- { 7651, 26, -2445, -1507 },
- { 4745, -464, -1735, -2362 },
- { 5352, -1011, -1094, -1999 },
- { 6300, -672, -542, -1950 },
- { 6675, -1020, -1318, -1059 },
- { 7218, -2036, -603, -2462 },
- { 7755, -1514, -2430, -1229 },
- { 5041, 449, -1056, -2405 },
- { 6710, -2277, -1344, -2284 },
- { 6824, -1347, -2254, 251 },
- { 6068, -1857, -983, -1316 },
- { 5603, -2177, -2730, -1477 },
- { 5838, -1059, -3604, -970 },
- { 5076, -789, -335, -2413 },
- { 6191, -1634, -2000, -2129 },
- { 5092, -1292, -2543, -1034 },
- { 5305, 435, -1710, -1850 },
- { 6140, 561, -2176, -2380 },
- { 6752, 348, -2496, -1890 },
- { 6405, 273, -1098, -2778 },
- { 6942, -1340, -496, -1381 },
- { 5238, -687, -2454, -2349 },
- { 6959, -882, -1833, -2061 },
- { 6292, -253, -2125, -2199 },
- { 5838, -574, -759, -3215 },
- { 6954, -1484, -640, -2771 },
- { 7498, -1706, -1210, -2154 },
- { 6772, -1003, -1235, -2532 },
- { 6014, 228, -2154, -1108 },
- { 6943, -2178, -2644, -1122 },
- { 7262, -763, -3056, -1090 },
- { 6273, -1478, -1072, 177 },
- { 4734, 425, -2912, 357 },
- { 7129, 168, -1537, -2327 },
- { 7204, -434, -746, -2660 },
- { 6879, 57, -3087, -1310 },
- { 4623, -610, -718, -3459 },
- { 6565, -543, -1998, -339 },
- { 4752, -277, -2066, -1405 },
- { 7435, -1416, -1904, -505 },
- { 4076, 150, -1222, -3556 },
- { 7082, -28, -1456, -1174 },
- { 5941, -446, -1326, -1158 },
- { 3870, -1648, -2474, -2589 },
- { 858, 37, -3387, -3721 },
- { 3557, -1503, -1664, -3383 },
- { 3336, -1972, -3079, -2216 },
- { 3186, 60, -4185, -863 },
- { 3456, -773, -3066, -2457 },
- { 4131, -913, -2060, -2601 },
- { 4431, -691, -4114, -972 },
- { 3461, -334, -3680, -1751 },
- { 2006, -459, -2214, -3827 },
- { 1322, 32, -2816, -3203 },
- { 4425, -1897, -2791, -1946 },
- { 4504, 23, -3421, -1909 },
- { 3090, -885, -2366, -3264 },
- { 3209, -2363, -3730, -834 },
- { 3312, -1471, -3641, -1579 },
- { 4184, -1669, -3323, -1248 },
- { 2190, -931, -3302, -2944 },
- { 2947, -229, -4791, -1195 },
- { 2020, -1626, -2700, -3125 },
- { 2214, -326, -4352, -1683 },
- { 3286, -2619, -2412, -2458 },
- { 1000, -2571, -4129, -2158 },
- { 2496, -2627, -3611, -1433 },
- { 2043, -2191, -2167, -3827 },
- { 2571, -2544, -1915, -3222 },
- { 2022, -1501, -3856, -2165 },
- { 2685, -1180, -1461, -4038 },
- { 1610, -2313, -4391, -1173 },
- { 2340, -2490, -4215, -516 },
- { 1742, -2615, -3632, -2146 },
- { 523, -1293, -4246, -2442 },
- { 3725, -2723, -3014, -1576 },
- { 3554, -1381, -4200, -824 },
- { 1291, -1594, -4777, -1430 },
- { 1452, 515, -2960, -3830 },
- { 4264, -894, -3305, -1826 },
- { 2606, -1452, -4522, -966 },
- { 1196, -830, -4807, -1816 },
- { 1054, -775, -2616, -4071 },
- { 4206, 415, -4344, -1132 },
- { 3044, 491, -4126, -1934 },
- { 988, -901, -3353, -3443 },
- { 1729, -3063, -2267, -3370 },
- { 3915, 912, -2989, -2387 },
- { 3781, 300, -2457, -3050 },
- { 2712, 924, -1350, -1206 },
- { 4230, 405, -2343, 665 },
- { 1878, -873, -225, -29 },
- { 3510, 56, -1334, -3420 },
- { 2850, 1447, -2651, -3150 },
- { 1510, -706, -4125, -2483 },
- { 3115, 793, -1692, -3894 },
- { 2667, 213, -2973, -2786 },
- { 1184, -2384, -3051, -3173 },
- { 2139, 796, -2079, -3697 },
- { 1464, -1483, -3726, -2754 },
- { 2407, -1148, -3915, -1569 },
- { 2612, -1779, -3217, -2271 },
- { 2406, -2870, -2937, -2496 },
- { 2140, 126, -3646, -2758 },
- { 2952, -1036, 268, -1423 },
- { 93, -1931, -3841, -3535 },
- { 389, -2953, -3383, -3343 },
- { 8652, -5511, -1662, 565 },
- { 7427, -2791, -2535, -842 },
- { 8541, -4253, -1407, -988 },
- { 8018, -3203, -2998, 105 },
- { 7231, -3926, -958, 1308 },
- { 7331, -3690, -363, 2586 },
- { 6803, -3646, -2226, -903 },
- { 8163, -2811, -477, -2235 },
- { 9356, -3818, -1685, -684 },
- { 8466, -2854, -302, -698 },
- { 8458, -3224, 517, 279 },
- { 8074, -2619, -1326, 2596 },
- { 8779, -2761, -2527, -441 },
- { 6533, -2887, -899, -696 },
- { 7394, -2305, -1642, -120 },
- { 8281, -3780, -22, 1305 },
- { 9158, -4413, -779, 901 },
- { 9031, -5240, -1109, 1678 },
- { 8717, -3650, 410, -1075 },
- { 7317, -3197, -818, -2264 },
- { 7934, -2385, -1214, -1886 },
- { 8256, -4441, -291, -587 },
- { 7358, -3395, 1090, -270 },
- { 9446, -4910, -1343, -473 },
- { 8187, -4726, -808, 1166 },
- { 7504, -3845, -47, 267 },
- { 8029, -2146, -1283, -383 },
- { 7461, -2705, -853, 783 },
- { 9367, -3636, -645, -354 },
- { 8955, -3473, -308, -1947 },
- { 8676, -2683, -2099, 1485 },
- { 7481, -3003, -871, -444 },
- { 8015, -2839, -1673, 1175 },
- { 6947, -4643, -1527, -1047 },
- { 7622, -2575, -137, -960 },
- { 9388, -4279, -707, -1322 },
- { 8382, -5259, -1283, -565 },
- { 6856, -4138, -1030, 630 },
- { 8659, -2571, -1124, -1666 },
- { 8763, -3807, -537, 2543 },
- { 8049, -3578, -2186, -604 },
- { 8272, -2351, -1985, -1214 },
- { 6855, -3796, -1527, -1631 },
- { 7178, -2896, -1600, -1756 },
- { 7040, -2888, -89, -1586 },
- { 6261, -3403, -264, 998 },
- { 7756, -4699, -1543, -834 },
- { 7682, -4622, -758, -1721 },
- { 8839, -4232, -2932, 1959 },
- { 9363, -4679, -1956, 39 },
- { 7883, -3616, -1414, -1432 },
- { 8828, -3188, -1356, -1312 },
- { 7746, -3987, -121, -2424 },
- { 9262, -3256, -693, 818 },
- { 7670, -3420, -148, 3504 },
- { 7344, -3183, 608, 1595 },
- { 8976, -4139, -1848, 1304 },
- { 6708, -4131, 33, -852 },
- { 7840, -4429, -2275, 79 },
- { 8980, -3858, -2838, 453 },
- { 7815, -4604, -2563, 944 },
- { 8372, -4422, -1783, 3071 },
- { 8623, -5128, -1754, 2888 },
- { 7462, -3281, 889, 920 },
- { 8416, -59, -1320, -1825 },
- { 7928, -1488, -414, -2499 },
- { 8110, -977, -1047, -2042 },
- { 8278, -687, -1597, -1550 },
- { 7988, -174, -977, -2106 },
- { 8609, -1547, -1628, -1527 },
- { 9000, -1798, -946, -1761 },
- { 8954, -872, -1404, -1594 },
- { 8939, 466, -748, -1212 },
- { 9549, -329, -177, -1360 },
- { 9411, -18, -1126, -1568 },
- { 8859, -782, -488, -1338 },
- { 8955, -218, -43, -1209 },
- { 9131, -69, -453, -1001 },
- { 9069, -1519, -1091, -1199 },
- { 9247, -1309, -566, -1146 },
- { 8528, -1617, -287, -1313 },
- { 7763, -745, -149, -2040 },
- { 8294, -343, 257, -2633 },
- { 10149, -893, -552, -1649 },
- { 9398, -915, 218, -2042 },
- { 9703, -1194, -675, -1592 },
- { 9586, -700, -427, -1710 },
- { 8930, 497, -1445, -1218 },
- { 9285, -1323, -163, -1552 },
- { 8431, -1289, -985, -1404 },
- { 8965, -655, 653, -1483 },
- { 9542, -1001, -951, -1128 },
- { 9205, -647, -37, -882 },
- { 8603, -56, 514, -1793 },
- { 9300, -12, -1324, -567 },
- { 8773, 238, -184, -1456 },
- { 9941, -1306, -69, -1792 },
- { 9360, 279, -376, -1919 },
- { 9180, -285, 95, -2170 },
- { 9922, -501, -970, -1570 },
- { 8341, -1493, -856, -2092 },
- { 8780, -981, -850, -1014 },
- { 9721, -548, -1504, -1094 },
- { 9973, -1493, 482, -2105 },
- { 8707, -333, -1027, -1087 },
- { 9098, -469, -315, -1723 },
- { 8879, -1050, -661, -2020 },
- { 8857, 602, -866, -1918 },
- { 8945, -1025, -2154, -1071 },
- { 8484, -1930, -468, -2179 },
- { 9177, -1903, -224, -2112 },
- { 8652, -137, -2097, -1214 },
- { 9063, -973, -1405, -772 },
- { 9328, -456, 662, -2469 },
- { 10101, -697, 127, -2113 },
- { 9685, 811, -2359, -1024 },
- { 8586, -94, -460, -1982 },
- { 7924, -141, -509, -2513 },
- { 7773, -669, -107, -2835 },
- { 8636, -1064, -46, -2409 },
- { 9748, 596, -1815, -1349 },
- { 8924, 304, 547, -2614 },
- { 9442, 746, -1153, -1679 },
- { 9454, -278, -529, -1976 },
- { 8488, 561, -32, -2160 },
- { 10083, -63, -1544, -1364 },
- { 9390, -1278, 568, -1131 },
- { 9740, -49, -2253, -910 },
- { 3636, -2391, -1115, -3614 },
- { 6014, -3204, -1902, -1808 },
- { 5787, -3497, -1116, -2590 },
- { 4365, -3046, -1632, -2668 },
- { 4733, -2192, -2029, -2468 },
- { 5412, -2753, -1633, -2464 },
- { 4455, -3375, -767, -3399 },
- { 4456, -1644, -983, -2841 },
- { 4039, -2523, 38, -3967 },
- { 3406, -2662, 72, -4757 },
- { 4279, -2005, 1055, -4399 },
- { 4321, -1377, -860, -3786 },
- { 3743, -5739, -651, -3047 },
- { 3528, -5510, 361, -4060 },
- { 6496, -4886, -136, -2689 },
- { 4513, -5254, 551, -4010 },
- { 6557, -3413, -92, -3063 },
- { 4186, -2059, 187, 47 },
- { 6210, -4117, -1256, -1985 },
- { 6038, -4343, 351, -2124 },
- { 4305, -4780, -2077, -1897 },
- { 4480, -3815, -2228, -1533 },
- { 5582, -3689, 1221, -3429 },
- { 5532, -4874, 1195, -2765 },
- { 6518, -2853, -905, -2568 },
- { 5467, -2192, 470, -4115 },
- { 4139, -1577, 240, -3493 },
- { 5281, -1926, -729, -3340 },
- { 5214, -2870, 1359, -4289 },
- { 3046, -3510, -1536, -3214 },
- { 5433, -2881, -1230, -1184 },
- { 4861, -3932, -1071, -2791 },
- { 5693, -4234, -1906, -1502 },
- { 4004, -3935, -1804, -2383 },
- { 3728, -3792, 681, -4773 },
- { 3621, -3030, -1951, -2598 },
- { 5133, -3903, 44, -3700 },
- { 3561, -3451, 1183, -5301 },
- { 5026, -2762, -2341, -1780 },
- { 5841, -2492, -467, -3210 },
- { 5591, -1791, 497, -2472 },
- { 5054, -3898, -1822, -2097 },
- { 5813, -2792, 83, -1469 },
- { 4432, -4497, 1670, -5193 },
- { 5338, -4653, -1109, -2200 },
- { 3239, -4401, -648, -3655 },
- { 2147, -3598, -1200, -4242 },
- { 4417, -2271, -1552, -3210 },
- { 6494, -4360, 852, -3565 },
- { 2393, -6358, -856, -4524 },
- { 4959, -4196, -847, -1403 },
- { 4924, -5438, -226, -3026 },
- { 4254, -5303, -1306, -2424 },
- { 4121, -3126, -2334, -1981 },
- { 3437, -4443, -1464, -2953 },
- { 3203, -3459, -529, -4339 },
- { 5896, -5945, 543, -3246 },
- { 1987, -4733, -220, -4863 },
- { 4358, -4431, -514, -3081 },
- { 4583, -2416, -492, -2287 },
- { 2943, -5035, 419, -4927 },
- { 5358, -5129, 987, -4309 },
- { 4460, -3392, 1752, -5634 },
- { 3415, -4633, 1507, -5945 },
- { 811, -4692, -445, 2333 },
- { 1009, -5613, -1857, 1360 },
- { 1338, -2712, -2720, 3036 },
- { 1002, -3754, -2582, 2344 },
- { 750, -4608, -2334, 714 },
- { 2043, -3207, -2822, 2173 },
- { -140, -4654, -2953, 357 },
- { -54, -4026, -2376, 2695 },
- { 1858, -5022, -717, 2287 },
- { 2064, -3894, -722, 3255 },
- { 2727, -4558, -332, 2603 },
- { 1810, -5378, 283, 1826 },
- { 3935, -4326, 762, 3383 },
- { -767, -4697, -2510, 1922 },
- { 2146, -4312, -3090, 1641 },
- { 54, -5881, -2114, 921 },
- { 1992, -5766, -640, 1574 },
- { 1200, -5371, -1114, 1828 },
- { 2973, -5337, 34, 2266 },
- { 1531, -5018, -2817, 1192 },
- { 3078, -4570, 117, 1990 },
- { 924, -4286, -1388, 2713 },
- { 142, -5058, -2848, 1487 },
- { -106, -6180, -881, 842 },
- { 673, -5433, -229, 1596 },
- { 783, -5710, -2784, 562 },
- { 1935, -5729, -2009, 856 },
- { -410, -3375, -3326, 2734 },
- { 234, -3000, -2628, 3260 },
- { 733, -3405, -3806, 1589 },
- { 771, -4285, -3544, 1314 },
- { 1192, -3563, -3960, 2178 },
- { 206, -5555, -1250, 1546 },
- { -130, -3815, -1210, 3041 },
- { 646, -3940, -393, 2992 },
- { -184, -4931, -1767, 1925 },
- { 2746, -5120, -2275, 1464 },
- { 2440, -3731, -3352, 2729 },
- { -490, -4942, -3779, 997 },
- { 68, -2636, -4167, 3778 },
- { 48, -3986, -4118, 2106 },
- { -978, -5486, -1336, 1390 },
- { 1126, -5297, -855, 640 },
- { -472, -3975, -3622, 1557 },
- { 2456, -5344, -1523, 1648 },
- { -774, -5652, -2417, 1147 },
- { 995, -6122, -812, 1132 },
- { 3282, -4571, -1763, 2175 },
- { 3655, -3862, -676, 3568 },
- { 3038, -3647, -1672, 3381 },
- { 2595, -2964, -2772, 3263 },
- { 4176, -3353, -1148, 4354 },
- { 1603, -3442, -1500, 3444 },
- { 828, -6226, -1783, 678 },
- { 1421, -3333, -3080, 3403 },
- { 1121, -4727, -1924, 1984 },
- { -186, -5083, -682, 1796 },
- { 819, -2778, -3488, 530 },
- { 421, -2873, -3832, 2596 },
- { 2164, -4263, -1605, 2282 },
- { 585, -4437, -682, -491 },
- { -644, -4452, -1157, 2325 },
- { 1991, -4299, 210, 2834 },
- { 2135, -3632, -2113, 665 },
- { -7482, -2724, -2662, -1380 },
- { -6983, -2166, -3756, -3509 },
- { -7085, -1439, -2397, -3112 },
- { -7760, -3049, -3319, -2822 },
- { -8413, -2760, -4406, -3298 },
- { -5995, -3943, -1260, -3750 },
- { -7879, -1554, -3464, -2606 },
- { -6314, -2034, -3878, -1681 },
- { -8849, -2084, -1399, -1231 },
- { -7153, -2602, -1384, -817 },
- { -8041, -2571, -407, -2785 },
- { -7246, -2233, -1578, 260 },
- { -7336, -3883, -4061, -1342 },
- { -7619, -3908, -2342, 382 },
- { -8684, -3724, -1662, -727 },
- { -7850, -2922, -1770, -3449 },
- { -6766, -2034, -1293, -1988 },
- { -6895, -2116, -968, -3744 },
- { -7136, -5147, -2618, -2809 },
- { -8224, -3724, -2519, -1589 },
- { -6711, -2750, -3021, -219 },
- { -8059, -1638, -1102, -3175 },
- { -8710, -4839, -3963, -3143 },
- { -9363, -4965, -3257, -1002 },
- { -6099, -1751, -3157, -395 },
- { -6453, -3216, -4597, -483 },
- { -7879, -5477, -839, -2638 },
- { -7202, -4038, -526, -2856 },
- { -8022, -1228, -1910, -1646 },
- { -9117, -1393, -1582, -2535 },
- { -9095, -2693, -636, -2605 },
- { -9076, -2580, -3481, -2519 },
- { -8327, -4859, -2422, 83 },
- { -8368, -2129, -2324, -2173 },
- { -8554, -4563, -3842, -2007 },
- { -10462, -4261, -1934, -2084 },
- { -9717, -3187, -2294, -1896 },
- { -9625, -3889, -3020, -3224 },
- { -9857, -4955, -4239, -2184 },
- { -9752, -2351, -2277, -3129 },
- { -7219, -1302, -2639, -1603 },
- { -7477, -4360, -3718, -559 },
- { -5680, -2033, -2326, -3078 },
- { -10190, -5548, -4643, -3601 },
- { -9431, -4121, -879, -2479 },
- { -8365, -5450, -2020, -1439 },
- { -6289, -5178, -1605, -3845 },
- { -8319, -3866, -687, -2792 },
- { -8131, -1031, -3608, -3947 },
- { -10510, -2560, -1199, -2082 },
- { -11015, -3640, -2748, -3041 },
- { -8762, -5022, -5231, -1162 },
- { -10153, -2715, -4648, -4859 },
- { -7930, -5205, -1900, -3600 },
- { -9561, -3548, -4812, -3722 },
- { -7663, -4709, -1180, -1475 },
- { -9073, -5707, -1815, -2980 },
- { -8602, -2363, -2675, -3770 },
- { -9967, -5614, -3575, -3838 },
- { -8324, -1005, -2131, -3254 },
- { -10331, -5737, -2550, -2940 },
- { -8234, -3354, -3361, -4479 },
- { -8140, -1951, -4526, -4545 },
- { -6679, -2662, -2284, -4182 },
- { -1122, -1514, -6427, -212 },
- { 54, -1660, -5424, -1404 },
- { 254, -2778, -5222, 846 },
- { -267, -1661, -6577, 814 },
- { -305, -2021, -5759, 1484 },
- { -1791, -2446, -6867, -86 },
- { -2929, -3158, -6603, -1799 },
- { -1391, -3189, -5557, -1053 },
- { -1602, -884, -6767, -1213 },
- { -361, -318, -6219, -44 },
- { -4078, -2635, -5523, -433 },
- { -956, 478, -4382, 1470 },
- { -3300, -2462, -6021, -2721 },
- { 708, -2434, -5085, -540 },
- { -2435, -3607, -5647, -2110 },
- { -491, -1134, -4681, -2886 },
- { 87, -3435, -4641, -1194 },
- { -586, -2927, -4784, 366 },
- { -1394, -2326, -6021, 350 },
- { 97, -2519, -4678, -2120 },
- { -1547, -1907, -5069, -2993 },
- { 268, -3724, -4719, 127 },
- { -827, -1190, -5912, 1144 },
- { -3959, -2322, -6898, -1974 },
- { -2728, -2228, -6426, -562 },
- { -456, -666, -5785, -1609 },
- { 531, -1096, -5731, -656 },
- { -3569, -688, -3915, 110 },
- { -4752, -1725, -4393, -377 },
- { -3210, -3315, -6960, -840 },
- { -688, -3416, -4971, 1221 },
- { -1833, 77, -6491, -2434 },
- { -239, -255, -6850, -886 },
- { -2112, -1490, -6291, -2689 },
- { -1544, -4579, -5198, -1261 },
- { -2771, -4014, -5520, 683 },
- { -1635, -2829, -5512, 1214 },
- { -958, -2582, -4823, 2360 },
- { -2077, -4566, -4642, 365 },
- { -3112, -4214, -5960, -823 },
- { -2467, -2510, -4858, 1467 },
- { -1561, -3399, -5822, 211 },
- { -775, -1081, -4424, 2636 },
- { -1263, 25, -6378, -1392 },
- { -3476, -366, -5417, -1393 },
- { -3176, -1476, -4149, 1466 },
- { -2479, 518, -4448, -257 },
- { -2992, 158, -4660, -1279 },
- { -1320, -3872, -4479, 1147 },
- { -1475, -312, -5318, 539 },
- { -3527, -1679, -5860, -1681 },
- { -3397, -3438, -5593, 1866 },
- { -4089, -2439, -4763, 1275 },
- { -748, -4513, -4687, -48 },
- { -2166, -4531, -4691, -2856 },
- { -2385, -853, -6035, -627 },
- { -1194, -4091, -4472, -1963 },
- { -682, -3234, -4084, -3033 },
- { -3255, -5015, -5328, -12 },
- { -2313, -3436, -4601, -155 },
- { -2792, -1038, -6947, -2019 },
- { -1244, -1526, -5771, -1882 },
- { -4679, -3731, -5506, 283 },
- { -3062, -66, -3558, -758 },
- { -4895, -1187, 4751, 3728 },
- { -7600, -2752, 3320, 4613 },
- { -5703, -2975, 3944, 2659 },
- { -4972, -1257, -246, 2952 },
- { -4221, -2487, 1702, 4295 },
- { -2900, -1529, 2458, 4935 },
- { -5061, 407, 2416, 4050 },
- { -6931, -3478, 2761, 2213 },
- { -6037, -3921, 3192, 1866 },
- { -6113, -811, 2407, 3782 },
- { -5878, -1716, 1207, 3478 },
- { -5953, -2853, 2207, 2712 },
- { -6807, -3223, 2749, 3595 },
- { -3272, -3157, 1389, 3788 },
- { -5368, -1904, 1980, 5077 },
- { -7235, -1398, 3075, 4548 },
- { -4765, -3487, 2755, 2796 },
- { -7658, -4435, 2694, 2582 },
- { -6997, -4282, 456, 3832 },
- { -5563, -3115, -63, 3713 },
- { -4244, -4220, 1450, 2767 },
- { -3801, -2194, 190, 4303 },
- { -5458, -4119, 1958, 2274 },
- { -7300, -3469, 3514, 3193 },
- { -4594, -2067, 775, 4752 },
- { -3389, -1654, 1464, 5412 },
- { -4845, -3483, 964, 3437 },
- { -6007, -2818, 1666, 4659 },
- { -8709, -5007, 1757, 3287 },
- { -5833, -4389, 1025, 3171 },
- { -5788, -1780, 3944, 3661 },
- { -4430, -920, 1938, 4753 },
- { -7066, -1857, 4591, 4538 },
- { -3549, -513, 1427, 5317 },
- { -7517, -1220, 2883, 3049 },
- { -7605, -2687, 1874, 2735 },
- { -8718, -4035, 2676, 3730 },
- { -7990, -3907, 1185, 2607 },
- { -6058, -1744, 3349, 5157 },
- { -5954, 565, 3161, 3250 },
- { -6478, -612, 1930, 2271 },
- { -6535, -1445, -2, 1618 },
- { -8963, -4151, 1192, 4044 },
- { -7227, -3570, 1600, 4234 },
- { -4674, 79, 595, 3015 },
- { -3974, 430, 2727, 5137 },
- { -5299, 9, 3714, 4779 },
- { -6779, -2699, -8, 2436 },
- { -7016, -1145, 1293, 2310 },
- { -6955, -3312, 1534, 1801 },
- { -4025, 740, 1850, 4054 },
- { -9589, -3460, 4154, 5270 },
- { -4404, -1181, 4298, 5173 },
- { -7356, -4583, -18, 2644 },
- { -6516, -1235, 4439, 6234 },
- { -3453, -301, 4344, 4464 },
- { -4643, 1530, 3315, 4340 },
- { -4575, -2557, 3754, 3682 },
- { -3643, -3501, 2051, 2997 },
- { -5412, -2475, 2301, 1579 },
- { -5846, 259, 1360, 2348 },
- { -5258, -1358, 1050, 838 },
- { -5542, -219, 6377, 5750 },
- { -5713, -2952, 922, 899 },
- { -2049, -1135, 5206, 1033 },
- { -1693, -1886, 4835, -106 },
- { -2344, -3504, 4232, -13 },
- { -2475, -2334, 5043, 1126 },
- { -787, -2549, 3880, 2138 },
- { -3159, -2341, 4830, 2887 },
- { -1780, -1009, 6240, 2061 },
- { -4327, -3363, 2818, 886 },
- { -3376, -2743, 4104, 207 },
- { -3250, -4640, 2718, 1498 },
- { -382, -1075, 4382, 3460 },
- { -2416, -4168, 3530, 816 },
- { -1756, -2708, 4861, 622 },
- { -1879, -2097, 5156, 2889 },
- { -2496, -2418, 3722, 2671 },
- { -2717, -3252, 3341, 1944 },
- { -4063, -4091, 3306, 267 },
- { -3549, -3808, 3747, 842 },
- { -2635, 546, 5794, 1894 },
- { -1857, -1121, 4383, 3964 },
- { -2226, -2166, 3489, 3678 },
- { -3492, -660, 5323, 1063 },
- { -3033, -3130, 4382, 1828 },
- { -2703, -625, 6369, 2851 },
- { -1656, -2842, 4584, -528 },
- { -4781, -2622, 4390, 2097 },
- { -413, -2045, 5081, 3035 },
- { -3810, -2662, 4532, 1095 },
- { -3144, -1858, 5215, 1880 },
- { -3562, -1795, 4928, 670 },
- { -4800, -1509, 5189, 1859 },
- { -1085, -3832, 4169, 900 },
- { -1969, -3270, 2857, 2878 },
- { -4267, -4140, 3176, 1805 },
- { -5145, -3727, 3524, 1168 },
- { -1346, -1876, 5501, 1748 },
- { -4998, -2945, 3699, 338 },
- { -3458, -3096, 3406, -635 },
- { -1751, -3209, 3508, 395 },
- { -2507, 170, 5987, 705 },
- { -3756, -1072, 5647, 3536 },
- { -2870, -1439, 5026, 3212 },
- { -3913, -3225, 3669, 2144 },
- { -3739, 226, 5747, 764 },
- { -2052, -820, 5266, 3093 },
- { -3214, -3820, 2409, 2391 },
- { -4398, -2588, 3501, -218 },
- { -4484, -1763, 4180, -198 },
- { -3368, -1525, 4362, -134 },
- { -2407, 224, 4905, 3533 },
- { -1369, -2937, 4728, 1788 },
- { -4848, -1707, 4159, 851 },
- { -3454, -1749, 4281, 3230 },
- { -1990, -3853, 3487, 1735 },
- { -3117, 92, 6155, 4075 },
- { -2676, -2472, 4078, -589 },
- { -1547, -2012, 2626, 1835 },
- { -4275, -588, 4824, 725 },
- { -601, -2249, 3736, 3548 },
- { -4060, -61, 5333, 3097 },
- { -4303, 7, 6551, 3054 },
- { -5003, -1029, 5786, 3319 },
- { -2810, -728, 5392, 199 },
- { -1232, -200, 5228, 3121 },
- { 2621, 165, -6255, 298 },
- { 3669, 537, -6844, 1564 },
- { 1598, -1190, -6235, 2523 },
- { 2164, -32, -6894, 1383 },
- { 853, -1597, -6069, 1449 },
- { 1377, -1661, -5266, 108 },
- { 2660, 48, -5172, -517 },
- { 1903, -391, -5677, 1010 },
- { 3792, 206, -5274, -11 },
- { 1239, 2776, -2929, 2721 },
- { 4071, 149, -7259, 3125 },
- { 1436, -480, -6156, -196 },
- { 1373, -1960, -5005, 3122 },
- { 3413, -1271, -5176, 3283 },
- { 3060, -68, -6495, 2238 },
- { 2700, -2075, -4681, 91 },
- { 2928, -1728, -5168, 1858 },
- { 4424, 828, -4471, 88 },
- { 2672, -2604, -4038, 2753 },
- { 5223, -123, -6749, 2295 },
- { 4237, -420, -5538, 1353 },
- { 4744, -1281, -4097, 4708 },
- { 1103, -2764, -4751, 2024 },
- { 3747, -1913, -3911, 3960 },
- { 2470, -1416, -5542, 615 },
- { 4847, -1354, -5334, 1733 },
- { 5336, 88, -7593, 4007 },
- { 2388, -2880, -4807, 1037 },
- { 4495, 1391, -5685, -139 },
- { 5253, 1637, -6450, 1533 },
- { 1199, 795, -5515, 1261 },
- { 1397, -1259, -4252, 3838 },
- { 746, 70, -6640, 604 },
- { 1584, 166, -4972, 3072 },
- { 380, -999, -5397, 2267 },
- { 2974, 1707, -3242, 5360 },
- { 5202, -403, -5453, 2832 },
- { 3718, -1731, -4760, 714 },
- { 4150, -975, -4792, 61 },
- { 2925, -818, -4841, 15 },
- { 5301, 577, -4006, 3259 },
- { 5265, 1986, -5679, 3028 },
- { 3752, 1928, -4509, 3729 },
- { 3278, 1925, -6370, 1247 },
- { 5107, 1721, -4853, 3127 },
- { 3279, 2982, -2515, 4005 },
- { 4622, 668, -6204, 759 },
- { 6034, 317, -5763, 4818 },
- { -558, 57, -3785, 2817 },
- { 4476, 1616, -3965, 4536 },
- { 5953, 2056, -8215, 2715 },
- { 4387, 2613, -7463, 868 },
- { 5834, 1088, -4736, 4924 },
- { 6473, -856, -6991, 4172 },
- { 4959, -293, -5162, 76 },
- { 2731, -843, -6119, 3847 },
- { 3245, 1202, -6833, 616 },
- { 2553, 1383, -3829, 3859 },
- { 4332, 2099, -3480, 3622 },
- { 2110, 2683, -2728, 3990 },
- { 876, 1167, -3290, 3466 },
- { 3991, 1709, -2410, 4077 },
- { 5105, 939, -2584, 3256 },
- { 4719, 688, -1566, 3040 },
- { -3632, 4335, 1266, -3303 },
- { -4956, 3207, 1312, -2806 },
- { -4669, 2627, 2663, -2435 },
- { -4282, 3708, 2303, -3038 },
- { -4536, 2297, -175, -3350 },
- { -5234, 2503, -139, -880 },
- { -3978, 1512, 1092, -3619 },
- { -4519, 4649, 1363, -2455 },
- { -5118, 3132, 1961, -1577 },
- { -5196, 3379, -182, -1378 },
- { -6420, 4486, 2397, -1993 },
- { -5030, 5046, 1292, -1118 },
- { -4559, 2573, -927, -1406 },
- { -3501, 3730, 691, -4930 },
- { -4364, 2758, 1007, -3909 },
- { -4026, 2839, -1559, -2340 },
- { -5037, 4053, 836, -1571 },
- { -4727, 5136, 1110, -3588 },
- { -5245, 2799, -999, -2164 },
- { -4954, 1501, 422, -3963 },
- { -5994, 2726, 1462, -2833 },
- { -5621, 5159, 2038, -2512 },
- { -4991, 2291, 1917, -3151 },
- { -5469, 4382, -148, -2978 },
- { -5858, 1983, 807, -2720 },
- { -4709, 3556, 952, -467 },
- { -2489, 2362, 1714, -4230 },
- { -4717, 5004, -1180, -3672 },
- { -5914, 3653, 1359, -1317 },
- { -5506, 2995, 780, -1059 },
- { -5287, 3945, 2480, -2293 },
- { -3849, 4358, 322, -1770 },
- { -3911, 3570, 252, -3185 },
- { -3660, 5128, 158, -3719 },
- { -4599, 3277, -503, -2727 },
- { -3673, 3760, -1252, -3339 },
- { -5161, 2337, 388, -1943 },
- { -3529, 2216, 2156, -3080 },
- { -4309, 4331, 1808, -1460 },
- { -4782, 3820, 480, -2504 },
- { -4166, 3544, -378, -1567 },
- { -5572, 2466, -418, -2909 },
- { -6096, 2930, 119, -1878 },
- { -5963, 3554, 1011, -2233 },
- { -6433, 4335, 935, -2930 },
- { -5004, 3314, -1352, -3430 },
- { -6042, 3463, -1008, -3940 },
- { -4671, 2214, -640, -5040 },
- { -2795, 3759, 1412, -3803 },
- { -3647, 4436, 729, -515 },
- { -3594, 1033, 56, -4148 },
- { -2908, 3027, 2889, -3485 },
- { -3338, 2234, 313, -4285 },
- { -3825, 4497, -561, -2634 },
- { -6167, 3012, -48, -3149 },
- { -4828, 3515, -969, -4475 },
- { -5789, 2757, -539, -4173 },
- { -2452, 3067, 564, -4249 },
- { -4921, 1358, 1331, -2889 },
- { -3127, 4239, -1045, -1523 },
- { -4780, 2326, -1118, -3446 },
- { -3908, 5546, 152, -2622 },
- { -6972, 2976, 337, -2809 },
- { -4839, 4613, -35, -4077 },
- { -1408, 4822, -1149, -4997 },
- { -981, 4979, -912, -6304 },
- { -2098, 5689, -888, -2878 },
- { -3343, 4814, -657, -4434 },
- { -2461, 3601, -967, -4869 },
- { -2652, 3944, 87, -5520 },
- { -1104, 6076, 174, -6407 },
- { 355, 5370, -1721, -5869 },
- { 1242, 4497, -1107, -5091 },
- { -89, 4002, -1491, -5182 },
- { 1059, 5693, -1591, -4905 },
- { 1323, 4682, -2078, -4768 },
- { 818, 3996, -549, -5468 },
- { -287, 4529, 929, -5543 },
- { -919, 5519, -2791, -2844 },
- { -1407, 5679, -3289, -3974 },
- { -189, 6530, -3547, -4002 },
- { -900, 7039, -3371, -4855 },
- { -2983, 7211, -363, -4835 },
- { -814, 6503, -104, -5106 },
- { -2386, 6896, 809, -4919 },
- { 845, 4492, 352, -6621 },
- { -1998, 7237, -1646, -4231 },
- { -3380, 6251, 471, -4577 },
- { -1908, 7059, 84, -5726 },
- { -340, 6346, -803, -6265 },
- { -2279, 5834, -47, -4633 },
- { -1532, 5286, -1748, -1901 },
- { -2757, 6188, -453, -3415 },
- { -1255, 6405, -2043, -6357 },
- { 918, 5581, -121, -5667 },
- { 1840, 5336, -821, -5034 },
- { -2475, 4992, -1825, -3104 },
- { -2413, 5606, -1789, -4298 },
- { 132, 5128, -2389, -4442 },
- { 223, 6400, -2653, -4742 },
- { -673, 5012, 680, -4582 },
- { -1657, 6624, -349, -3596 },
- { -755, 6289, -1860, -3978 },
- { -572, 6894, -1946, -5207 },
- { -1141, 4756, -2665, -5586 },
- { -1073, 4269, -431, -4030 },
- { 186, 5761, 916, -5868 },
- { -1907, 4836, 1017, -5106 },
- { -963, 3363, -1248, -6348 },
- { -3262, 4774, -1818, -5858 },
- { 847, 3812, -2538, -4302 },
- { -1223, 5903, 1360, -5479 },
- { -1094, 6923, -1244, -2381 },
- { 267, 6276, -709, -2846 },
- { -157, 5840, 1124, -4266 },
- { 889, 3206, -910, -5305 },
- { -1736, 3344, 582, -4838 },
- { -2357, 5676, -2695, -6277 },
- { -1916, 6901, -986, -5397 },
- { -3062, 6028, -695, -5687 },
- { 1836, 3566, -1357, -5226 },
- { -2176, 4938, 646, -3872 },
- { -2199, 3055, -208, -6124 },
- { -236, 3032, -821, -5325 },
- { -3989, 7277, -565, -3899 },
- { -595, 4362, 74, -5975 },
- { 684, 5874, -841, -4424 },
- { -2731, 6305, -2389, -5465 },
- { -5775, 1325, -56, -2528 },
- { -7029, -534, -1890, -3278 },
- { -5798, -15, -2734, -2210 },
- { -5504, -1198, -353, -3659 },
- { -5079, 960, -894, -4336 },
- { -6073, -36, -133, -3014 },
- { -5782, -259, -1025, -3986 },
- { -6843, 1262, -807, -1639 },
- { -5263, -918, -3290, -579 },
- { -4840, 461, -2158, -533 },
- { -6014, -50, -620, 504 },
- { -5843, 241, -1359, -282 },
- { -5898, 577, 769, -3271 },
- { -6833, -946, -466, -3347 },
- { -6026, 1459, -512, -729 },
- { -7361, 747, -388, -1110 },
- { -6391, 2142, -1160, -2513 },
- { -6995, 304, 498, -2673 },
- { -6757, 679, -386, -433 },
- { -5222, 1688, -1093, -1032 },
- { -5019, 575, 184, -3627 },
- { -4237, 628, -3507, -1243 },
- { -7479, -456, -1722, -1486 },
- { -6464, 713, -1273, -1153 },
- { -6255, 1682, -606, -3607 },
- { -7033, 1497, -71, -1955 },
- { -6694, 1556, -1721, -3214 },
- { -6114, -356, 813, -2575 },
- { -5308, 632, -1851, -1636 },
- { -5742, -911, -1733, 383 },
- { -6083, -387, -2313, -879 },
- { -6535, -530, -1505, -2083 },
- { -4896, 1223, -2750, -1816 },
- { -6392, -463, -3247, -2093 },
- { -5373, 1264, -2706, -3042 },
- { -3894, -1390, -1020, -891 },
- { -6179, 1168, -1966, -1922 },
- { -5162, 1668, -1617, -1916 },
- { -6453, 920, -1169, -2432 },
- { -6130, 2005, -536, -1519 },
- { -6552, -98, -518, -1938 },
- { -7528, 355, -1101, -1772 },
- { -5745, 610, -247, -1360 },
- { -7003, 177, -2064, -1958 },
- { -6956, -570, -2220, -4225 },
- { -7830, 791, -1394, -2774 },
- { -7634, 480, -3171, -4224 },
- { -7913, 1154, -350, -2381 },
- { -5063, 1704, -1804, -2977 },
- { -4887, -524, -2703, 188 },
- { -5551, 406, -1620, -3063 },
- { -7109, 1342, 381, -3021 },
- { -6846, 631, -458, -3398 },
- { -4606, -605, 11, -3930 },
- { -8134, -225, -1738, -2648 },
- { -7043, 402, -2734, -3059 },
- { -7417, 1825, -2545, -4389 },
- { -6971, -236, -1031, -665 },
- { -5752, 2111, -1632, -3808 },
- { -7660, -78, -624, -3135 },
- { -6358, 619, -1951, -3911 },
- { -8134, 408, -1935, -3695 },
- { -6335, 1911, -2368, -4505 },
- { -7116, 2163, -344, -2753 },
- { 2357, 4488, 2220, -5682 },
- { 1385, 3206, 2300, -5305 },
- { 1419, 2557, 5203, -3516 },
- { 262, 4315, 3920, -1847 },
- { 3316, 3187, 1612, -5609 },
- { 1729, 2350, 1673, -6068 },
- { 1603, 6126, 1467, -2839 },
- { -1339, 3316, 3691, -3530 },
- { -563, 4618, 3180, -4548 },
- { 463, 4624, 3111, -5614 },
- { 1246, 5455, 3356, -5720 },
- { 480, 2149, 5422, -2893 },
- { 1768, 4827, 913, -5579 },
- { -149, 5381, 4366, -3297 },
- { 985, 3672, 2644, -92 },
- { -258, 2911, 5817, -2213 },
- { 3428, 3289, 3351, -3541 },
- { -666, 3295, 4727, -2869 },
- { 35, 6641, 4160, -4052 },
- { 623, 6787, 3156, -4560 },
- { 2654, 4360, 4676, -4632 },
- { 1386, 5246, 4834, -4497 },
- { 3488, 4574, 3856, -5946 },
- { 383, 4481, 4168, -4110 },
- { 1753, 3652, 4288, -3326 },
- { 1344, 4905, 2508, -4660 },
- { 1580, 4106, 3104, -2224 },
- { 2027, 5038, 1683, -1554 },
- { 446, 3699, 5872, -3013 },
- { 4637, 4087, 3578, -5018 },
- { 2629, 3560, 5331, -4900 },
- { 1527, 6674, 2523, -4131 },
- { -1437, 2804, 2528, -4464 },
- { -229, 3355, 2016, -5537 },
- { 3666, 3418, 4374, -4581 },
- { 1192, 3799, 923, -6596 },
- { 2040, 2956, 448, -5322 },
- { 2468, 5768, 4029, -5869 },
- { 3438, 6516, 3529, -6667 },
- { 2737, 5495, 680, -5535 },
- { 3896, 5727, 1801, -4958 },
- { 4988, 4957, 3592, -6518 },
- { -542, 4416, 5794, -2787 },
- { 4136, 4354, 2064, -4696 },
- { 3067, 5936, 1207, -3396 },
- { 2789, 4966, 2405, -3854 },
- { 1731, 3270, 3251, -1063 },
- { 1767, 5537, 2084, -2349 },
- { 465, 3116, 4532, -837 },
- { 1499, 2627, 4610, -2212 },
- { 122, 3095, 3642, -3552 },
- { 2542, 2866, 2705, -6402 },
- { 3134, 4323, 698, -4785 },
- { 731, 1859, 3112, -5242 },
- { 2553, 2980, 3241, -4846 },
- { 1329, 5310, 1607, -6624 },
- { 2468, 1858, 3476, -1034 },
- { -172, 4996, 2000, -5562 },
- { 2621, 4220, 1574, -3386 },
- { -333, 1832, 3362, -4117 },
- { 2169, 6762, 3065, -6225 },
- { 2844, 5528, 3223, -4765 },
- { 526, 5175, 1644, -4267 },
- { 2922, 4426, 2414, -2610 },
- { 452, 1399, -4516, -2636 },
- { 2872, 1720, -4667, -1435 },
- { 1279, 702, -5424, -1984 },
- { 2187, 870, -5021, -1341 },
- { 583, -144, -4628, -2464 },
- { 3, 2237, -5284, -2827 },
- { -19, 1005, -5460, -1819 },
- { 2897, 2084, -5885, -515 },
- { -400, 3370, -5527, -2947 },
- { 1505, 2593, -5518, -1802 },
- { 1341, 4534, -5094, -1899 },
- { 3241, 3670, -5493, -1252 },
- { -1287, 921, -5994, -1675 },
- { 627, 408, -6652, -364 },
- { -260, 1127, -4849, -3247 },
- { 371, 3400, -5976, -2285 },
- { 1533, 1566, -6373, -610 },
- { 2462, 4274, -6184, -1254 },
- { 1782, 3363, -6222, -1381 },
- { 572, 4650, -5673, -2754 },
- { 2674, 3414, -4460, -2154 },
- { 3614, 3820, -6883, -398 },
- { 1136, -1, -5511, -1112 },
- { -1773, 1137, -5647, -2377 },
- { -753, 2104, -6085, -2565 },
- { -204, 3025, -4731, -1418 },
- { -1486, 1438, -4380, -216 },
- { 302, 858, -5786, -264 },
- { 3486, 1495, -5234, -783 },
- { 888, 2327, -3423, -3720 },
- { -259, 772, -6596, -1311 },
- { -1197, 2073, -5174, -1826 },
- { 1500, 3470, -4462, -2645 },
- { 3072, 1960, -3277, -2264 },
- { 1841, 952, -4324, -2340 },
- { 1994, 2200, -3940, -2923 },
- { -1782, 1699, -4667, -1075 },
- { -1464, 2906, -3468, -375 },
- { 366, 2380, -3747, 1467 },
- { -545, 1645, -4619, 376 },
- { 1724, 2350, -2374, -3512 },
- { 3184, 2628, -2996, -3275 },
- { 734, 2010, -6239, -1479 },
- { 524, 3756, -4496, -3263 },
- { 1492, 3570, -3494, -3600 },
- { -932, 618, -5389, -2894 },
- { -133, 2161, -4083, -3267 },
- { 786, 774, -3279, -3731 },
- { 1078, 803, -3843, -3007 },
- { -332, 3405, -3347, 40 },
- { -17, 6, -4005, -3690 },
- { -189, 4372, -4488, -2561 },
- { -450, 3846, -3790, -1370 },
- { 362, 2212, -5272, -15 },
- { -1529, 791, -6802, -2296 },
- { 2145, 4241, -4474, 376 },
- { 1813, 2426, -2932, -2726 },
- { -542, 4557, -3140, -1080 },
- { 1192, 3784, -4371, -20 },
- { 2784, 5188, -6399, -1394 },
- { 431, 4561, -3673, -1398 },
- { 1382, 3096, -4083, 1253 },
- { 1209, 4224, -2930, 1500 },
- { 2798, 2684, -6676, -606 },
- { -2396, 1510, -5381, -2713 },
- { -2625, 2542, -4032, -2880 },
- { -1231, 3967, -4098, -2886 },
- { -1393, 2374, -3862, -4525 },
- { -2495, 1665, -1637, -5445 },
- { -3854, 1759, -1750, -4944 },
- { -2373, 1668, -2856, -6251 },
- { -2668, 1981, -886, -4557 },
- { -2927, 4427, -3451, -6172 },
- { -1925, 2596, -4696, -2527 },
- { -3202, 2847, -3928, -5896 },
- { -3332, 1665, -5025, -3412 },
- { -3212, 3115, -4155, -4062 },
- { -1013, 3205, -5133, -3751 },
- { -2022, 4595, -3947, -5611 },
- { -3556, 1755, -3715, -2300 },
- { -1784, 4114, -2723, -1773 },
- { -3586, 4081, -2733, -4942 },
- { -1608, 3685, -4154, -4573 },
- { -3368, 4042, -4452, -6227 },
- { -1407, 3881, -5729, -3719 },
- { -2751, 3281, -5077, -4999 },
- { -3791, 2410, -4906, -5288 },
- { -730, 2303, -4217, -3755 },
- { -1812, 2311, -5492, -3709 },
- { -610, 4336, -3915, -3783 },
- { -2841, 4337, -4278, -4430 },
- { -1662, 4666, -4661, -3964 },
- { -589, 5209, -4923, -3682 },
- { -4155, 2234, -4076, -4218 },
- { -3951, 2770, -2665, -2805 },
- { -2302, 3228, -3717, -1908 },
- { -3129, 4373, -2264, -2851 },
- { -447, 1363, -3578, -4323 },
- { -2648, 4237, -3159, -3071 },
- { -4072, 3241, -3541, -4605 },
- { -4507, 3458, -2339, -3838 },
- { -1646, 997, -4926, -3970 },
- { -3025, 1614, -3940, -1242 },
- { -1337, 1756, -3163, -5529 },
- { -3203, 1865, -3282, -4354 },
- { -1646, 2118, -2203, -6018 },
- { 174, 1871, -2707, -4639 },
- { -2607, 1485, -4778, -4750 },
- { -2199, 3991, -3134, -4879 },
- { -2962, 3323, -2816, -2419 },
- { -5286, 2495, -4548, -5395 },
- { -2810, 3710, -2274, -4211 },
- { -330, 3006, -2993, -4678 },
- { -1187, 2411, -2743, -5196 },
- { -664, 4033, -3101, -5641 },
- { -1458, 3602, -2816, -5371 },
- { -4116, 4923, -3321, -5630 },
- { -4165, 2528, -2592, -4798 },
- { -2759, 3080, -2333, -5719 },
- { -5157, 3011, -5526, -6348 },
- { -3095, 2126, -5881, -4234 },
- { -4377, 3849, -3600, -6099 },
- { -1994, 4947, -5235, -4753 },
- { -1067, 600, -3258, -5133 },
- { -4992, 3302, -2208, -5051 },
- { -3377, 2981, -1655, -4815 },
- { -3325, 2446, -1787, -6116 },
- { -2341, 2737, -3240, -6347 },
- { -2258, -3732, 3710, -1235 },
- { -1558, -3849, 2694, -3012 },
- { -599, -4837, 3050, -2951 },
- { -2246, -5433, 2798, -1910 },
- { -2255, -4989, 3260, 270 },
- { -3026, -5353, 2693, -1036 },
- { -1151, -6097, 1097, -3782 },
- { -3391, -6012, 2130, -1303 },
- { -2850, -4422, 3375, -480 },
- { -1138, -3779, 1491, -4162 },
- { -551, -3892, 3787, -2082 },
- { -3221, -3676, 3144, -1202 },
- { -3023, -5196, 2650, 605 },
- { -1756, -5729, 2646, 321 },
- { -2693, -4409, 494, -4797 },
- { -1913, -4573, 3372, -1730 },
- { -1277, -3604, 4061, -993 },
- { -420, -4993, 1351, -4796 },
- { -3052, -5333, 1435, -1242 },
- { -602, -5034, 3869, -1141 },
- { -2436, -4680, 1665, -3019 },
- { -2657, -3658, 1459, -3391 },
- { -1220, -6246, 2749, -525 },
- { -3838, -4844, 2265, -1735 },
- { -1247, -5679, 3356, -1417 },
- { -917, -5448, 3342, 105 },
- { -1756, -6839, 2276, -2350 },
- { -412, -5206, 1764, -3539 },
- { -1439, -6915, 1442, -3750 },
- { -1381, -4439, 3863, -282 },
- { -3482, -4953, 2726, -336 },
- { -1376, -5931, 1714, -1987 },
- { -1716, -4405, 2608, 105 },
- { -1590, -5191, 2652, -2704 },
- { -2149, -6442, 2453, -1263 },
- { -3426, -3832, 2334, -1829 },
- { -2747, -5948, 2362, -173 },
- { -2435, -3267, 2966, -1710 },
- { -3979, -4282, 2705, -775 },
- { -356, -4238, 2544, -4343 },
- { -1363, -6471, 2817, -1836 },
- { -2878, -5117, 218, -3149 },
- { -3539, -5196, 1710, -2356 },
- { -2888, -4537, 2746, -1701 },
- { -1870, -4439, 1496, -4121 },
- { -1486, -3388, 3349, -2145 },
- { -3333, -4138, 1467, -2876 },
- { -345, -5340, 1012, -1190 },
- { -1672, -4992, 2289, -1029 },
- { -2146, -5528, 3038, -635 },
- { -316, -3656, 3426, -3152 },
- { -2695, -5812, 2336, -2050 },
- { -2067, -6052, 737, -3258 },
- { -2664, -4205, -350, -1266 },
- { -617, -5406, 80, -4853 },
- { -2418, -3825, 1853, -1326 },
- { -1961, -4339, 583, -4315 },
- { -1495, -5141, -133, -5205 },
- { -3208, -6440, 1691, -2069 },
- { -2632, -3633, 2325, -2761 },
- { -2624, -5670, 1252, -3676 },
- { -3687, -5608, 687, -2833 },
- { -3320, -5707, 16, -3877 },
- { -2738, -6112, 84, -5135 },
- { 2277, -5661, 3076, 843 },
- { 1555, -5769, 2821, -5236 },
- { 536, -6381, 603, -4910 },
- { 734, -4609, 3314, -4092 },
- { 1836, -4547, 3267, -4322 },
- { -13, -5976, 3752, -1607 },
- { 1423, -6318, 2336, 398 },
- { 365, -7779, 1498, -534 },
- { 2104, -8366, 2946, -1345 },
- { 143, -5545, 1898, -3756 },
- { 655, -6852, 1430, 148 },
- { 4, -6653, 2397, -59 },
- { 2346, -5996, 4562, -934 },
- { 1229, -7104, 2963, -598 },
- { -528, -7048, 2887, -1790 },
- { 1451, -6857, 3900, -1637 },
- { 554, -6018, 3336, 9 },
- { 3278, -5758, 4034, 129 },
- { 3541, -7145, 4905, -1575 },
- { 2339, -6907, 3464, -301 },
- { 2775, -7301, 1667, -3894 },
- { 539, -7887, 991, -4156 },
- { 2115, -7421, 3131, -3075 },
- { 2803, -8546, 2564, -5836 },
- { 2869, -5833, 1620, -4561 },
- { 2591, -7281, 3215, -4719 },
- { -1228, -8477, 706, -4782 },
- { 1967, -5243, 4813, -1940 },
- { 701, -7010, 2273, -3893 },
- { 915, -8470, 1918, -5620 },
- { -94, -6715, 156, -3873 },
- { 1074, -5607, 4389, -1017 },
- { 2739, -6551, 1227, -3521 },
- { 725, -7835, 2701, -1291 },
- { -493, -7475, 2263, -1075 },
- { -412, -6508, 2984, -744 },
- { 665, -5451, 3725, -2692 },
- { 1499, -8129, 3564, -2072 },
- { 2870, -6333, 4487, -2108 },
- { 706, -5007, 3911, -152 },
- { -482, -8660, 1483, -2900 },
- { 2481, -6596, 2518, -1715 },
- { 1403, -6414, 1398, -5387 },
- { 652, -6267, 583, -5942 },
- { 694, -7540, 646, -6272 },
- { 2275, -7614, 256, -5015 },
- { 1416, -9727, 1900, -3153 },
- { 2760, -6433, 3875, -3771 },
- { 2325, -11196, 2182, -5155 },
- { 1223, -11061, 1377, -5097 },
- { 108, -10603, 307, -4952 },
- { -118, -8268, 1650, -1572 },
- { 1839, -7943, 1755, -612 },
- { 2501, -9056, 981, -2969 },
- { 2902, -8476, 1491, -5780 },
- { 1995, -11175, 1585, -3643 },
- { 696, -8212, 828, -2474 },
- { 1526, -8649, 1380, -1210 },
- { 461, -7253, 3222, -2229 },
- { 2966, -8641, 4121, -3271 },
- { 833, -6039, 2361, -1086 },
- { 3565, -7312, 1980, -5427 },
- { 2850, -8671, 3760, -1846 },
- { 2643, -7281, 2163, -173 },
- { 3463, -3706, -3132, -923 },
- { 1315, -3825, -3443, 2 },
- { 2594, -4083, -3815, 670 },
- { 1826, -4291, -2741, -155 },
- { 868, -3749, -4175, -298 },
- { 2008, -4237, -3897, -517 },
- { 1242, -3493, -4335, -1335 },
- { -88, -4142, -3390, -1529 },
- { 2176, -3488, -3822, -975 },
- { 1706, -5188, -3415, -637 },
- { 2717, -6159, -2333, -882 },
- { 1276, -3978, -4361, 537 },
- { 2471, -5556, -2866, -208 },
- { 799, -4673, -4086, 56 },
- { 1901, -4786, -3533, 270 },
- { 3036, -3902, -3606, -333 },
- { 2249, -3317, -4319, -144 },
- { 2594, -4207, -2105, -2930 },
- { 4008, -4774, -2626, -902 },
- { 1038, -3659, -3496, -2454 },
- { 2725, -3597, -3298, -1535 },
- { 1662, -5803, -2813, 175 },
- { 705, -3757, -3441, -1484 },
- { 1860, -5987, -2821, -886 },
- { 3786, -4918, -2199, -1929 },
- { 3683, -4235, -2547, -1287 },
- { 2531, -4896, -2956, -1593 },
- { 1005, -5585, -3324, -180 },
- { 1625, -5229, -1756, -3642 },
- { 1494, -5041, -2989, -2685 },
- { 2718, -4655, -3224, -867 },
- { 2374, -6640, -1745, -2975 },
- { 2133, -6436, -2477, -1499 },
- { 1833, -4418, -3523, -1512 },
- { 1128, -4910, -2658, -1106 },
- { 689, -4777, -2831, -2085 },
- { 3593, -5280, -2627, -315 },
- { 3264, -3771, -2673, -1861 },
- { 3202, -5602, -2409, 402 },
- { 552, -4618, -2221, -3002 },
- { 3095, -5356, -2666, -1083 },
- { 3401, -4609, -3146, 45 },
- { 3051, -4662, -2192, -2232 },
- { 2798, -5552, -2462, -1941 },
- { 2354, -5815, -2223, -2619 },
- { 192, -3708, -2807, -2658 },
- { 1886, -4226, -1862, -3529 },
- { 2526, -3976, -2819, -2332 },
- { 1577, -3870, -2711, -2806 },
- { 1288, -5588, -3382, -1403 },
- { 2711, -5399, -1564, -3253 },
- { 1459, -5492, -2222, -322 },
- { 2823, -5091, -2886, 776 },
- { 3559, -5821, -2109, -1360 },
- { 1587, -6331, -2760, -1909 },
- { 2139, -5213, -2874, -2120 },
- { 1318, -4337, -3695, -2098 },
- { 821, -4471, -1849, -565 },
- { 3329, -4782, -1725, -89 },
- { 582, -4914, -4105, -1119 },
- { 417, -4144, -4072, -2529 },
- { -199, -3803, -2765, -4042 },
- { 2731, -4283, -2143, 1 },
- { 2911, -6187, -1951, -2116 },
- { 1573, -6094, -493, -2838 },
- { 2081, -6927, -864, -3211 },
- { 1058, -7826, 79, -364 },
- { 3147, -5570, -684, -978 },
- { 3572, -5856, 1060, 1824 },
- { 1143, -6702, -1478, 338 },
- { 2341, -7220, -88, 260 },
- { 3639, -6861, 668, 815 },
- { 2227, -6268, -1706, 446 },
- { 3390, -6082, -353, 1302 },
- { 1123, -7556, -1237, -430 },
- { 1729, -7742, 729, -218 },
- { 1457, -6774, 587, 579 },
- { 505, -6919, -569, 371 },
- { 1106, -7245, 78, 158 },
- { 2755, -6745, -1122, 338 },
- { 3069, -6040, -1415, 986 },
- { 2174, -7064, -1430, -283 },
- { 1390, -8626, -446, -3031 },
- { 3534, -6890, -431, 547 },
- { 2267, -9618, 475, -2994 },
- { 3672, -7673, 75, -115 },
- { 2131, -7560, -1206, -750 },
- { 2972, -7477, -685, -262 },
- { 1604, -6637, -672, 699 },
- { 1666, -7577, -577, -240 },
- { 1591, -6554, -2158, -94 },
- { 2348, -6286, -353, 1123 },
- { 2017, -8810, -412, -1805 },
- { 2892, -6713, -1765, -554 },
- { 2500, -6828, -1995, -1197 },
- { 3877, -6639, -224, -1655 },
- { 2392, -7872, -91, -333 },
- { 3562, -7370, -532, -2836 },
- { 2552, -7614, 164, -1805 },
- { 990, -6104, 218, 438 },
- { 910, -7861, 312, -1195 },
- { 1472, -6327, 372, -640 },
- { 1576, -7143, -1983, -843 },
- { 422, -7625, -457, -278 },
- { 1797, -8532, 405, -1011 },
- { 1088, -7396, -238, -2277 },
- { 3209, -6753, -1431, -2072 },
- { 2617, -6839, 100, -2573 },
- { 2575, -8573, -387, -3188 },
- { 3618, -6971, -1190, -321 },
- { 2205, -7361, -1695, -2008 },
- { 2985, -6297, 1464, 1179 },
- { 2804, -7310, 1053, 338 },
- { 1362, -6074, -1163, -840 },
- { 3336, -6325, -1794, 21 },
- { 2836, -8109, 818, -329 },
- { 2791, -5879, 560, 1546 },
- { 2392, -6064, 135, 100 },
- { 1838, -6194, 596, 1085 },
- { 1926, -7515, -414, -4901 },
- { 3225, -7298, -1202, -1189 },
- { 3960, -7558, -659, -719 },
- { 3442, -6647, -1692, -1095 },
- { 3381, -6441, 262, -886 },
- { 1431, -8150, -1186, -1406 },
- { 340, -8498, -150, -899 },
- { 3004, -8149, -260, -953 },
- { 2749, -6611, 563, 873 },
- { -6647, -1325, -4517, -4691 },
- { -6005, -1657, -4089, -3797 },
- { -3157, 588, -5213, -3068 },
- { -3311, -1425, -6329, -3726 },
- { -5866, -819, -3857, -2744 },
- { -5001, -1799, -1075, -4621 },
- { -5330, -2650, -2672, -4664 },
- { -4930, -539, -2363, -4010 },
- { -2984, 10, -3863, -5749 },
- { -1055, -2106, -3713, -4267 },
- { -5476, -502, -4279, -6504 },
- { -5231, -1543, -5018, -6425 },
- { -5134, -363, -3165, -5109 },
- { -3953, -771, -4107, -6393 },
- { -2159, -563, -3652, -5342 },
- { -3888, -2321, -919, -5057 },
- { -1236, -597, -4235, -4193 },
- { -4053, 675, -3083, -6174 },
- { -2793, -1089, -5396, -3460 },
- { -3000, -44, -2209, -6575 },
- { -3336, -1531, -4313, -5160 },
- { -2127, 128, -4851, -3692 },
- { -3321, 136, -2067, -5660 },
- { -5215, 1404, -4374, -4356 },
- { -2747, 400, -6340, -3691 },
- { -3926, -599, -5361, -5006 },
- { -2875, -2592, -5143, -4092 },
- { -4991, -1958, -5322, -4891 },
- { -4965, -1318, -6652, -5333 },
- { -4920, -1691, -3388, -5561 },
- { -3644, -3354, -2688, -5982 },
- { -5076, -919, -4563, -2984 },
- { -6114, 250, -3884, -3915 },
- { -4014, 744, -3973, -1924 },
- { -5543, -1041, -5557, -3847 },
- { -4711, -1352, -5649, -2603 },
- { -3362, 775, -5305, -4879 },
- { -5001, 107, -3554, -2888 },
- { -6258, -1651, -6356, -6566 },
- { -4529, 407, -5003, -3865 },
- { -5154, 550, -5278, -5465 },
- { -4195, -467, -1894, -3129 },
- { -5022, 1127, -3349, -3314 },
- { -6075, 1250, -4313, -5641 },
- { -2677, -2283, -2312, -5903 },
- { -4113, 193, -1195, -4833 },
- { -3940, -1048, -1389, -5079 },
- { -3703, 917, -4043, -4451 },
- { -3366, -4231, -1534, -5488 },
- { -3326, -3583, -2091, -4903 },
- { -5144, 1254, -2532, -4949 },
- { -5982, -870, -2545, -4555 },
- { -3925, -157, -5367, -2281 },
- { -6419, -746, -5668, -4371 },
- { -5787, 518, -7096, -5805 },
- { -4258, 954, -6453, -4321 },
- { -4771, -695, -4158, -1639 },
- { -7078, -760, -5195, -5877 },
- { -7348, 83, -4101, -4586 },
- { -2430, 184, -2874, -1679 },
- { -2284, -3943, -2924, -5034 },
- { -1804, -1785, -3002, -4710 },
- { -4399, -2772, -1815, -4637 },
- { -6340, -2626, -2824, -5191 },
- { -4998, -5168, -3480, 1905 },
- { -3958, -5492, -1599, 1579 },
- { -2471, -3755, -276, 3182 },
- { -3033, -5779, -1063, 1554 },
- { -2936, -4829, -1290, 2386 },
- { -1835, -5073, -3051, 1299 },
- { -1724, -3771, -3935, 2324 },
- { -5070, -2550, -3692, 768 },
- { -4326, -5333, -297, 1878 },
- { -3472, -5619, -3094, 992 },
- { -3027, -4384, -3038, 2265 },
- { -3201, -5332, 67, 2200 },
- { -1681, -4373, -1947, 2461 },
- { -3221, -3329, -4238, 2564 },
- { -1262, -2968, -2915, 3227 },
- { -3419, -1878, -3373, 2110 },
- { -2244, -5583, -2012, 1288 },
- { -1971, -5266, -990, 1812 },
- { -2975, -2778, -452, 4063 },
- { -2198, -1165, -3298, 2965 },
- { -4782, -4894, -4767, 664 },
- { -6002, -3950, -2806, 2025 },
- { -3142, -3162, -2859, 3295 },
- { -3262, -3340, -4123, 1596 },
- { -4014, -3918, -1955, 3361 },
- { -1700, -3463, -1346, 3449 },
- { -4245, -4445, -4743, 1644 },
- { -4180, -3969, -401, 3281 },
- { -2782, -5240, -4117, 1156 },
- { -5744, -4040, -1439, 3470 },
- { -5063, -4663, -323, 3172 },
- { -4531, -3319, -844, 3988 },
- { -6226, -5125, -2064, 2976 },
- { -3115, -3267, -1531, 3898 },
- { -4628, -4421, -2864, 2808 },
- { -4559, -2989, -3442, 2024 },
- { -1775, -4487, -656, 2477 },
- { -2664, -1865, -1884, 4081 },
- { -1828, -2575, -3894, 3378 },
- { -6441, -3677, -2025, 1677 },
- { -4141, -2156, -1191, 3474 },
- { -4802, -1623, -1727, 2160 },
- { -5474, -2745, -1475, 2498 },
- { -3664, -1056, -1975, 2491 },
- { -4672, -3062, -2235, 2933 },
- { -4205, -5960, -2849, 1517 },
- { -4995, -5708, -1739, 1805 },
- { -4892, -6080, -4793, 872 },
- { -4270, -4172, -4263, 2185 },
- { -4687, -1470, -2905, 1023 },
- { -6446, -5017, -3919, 1000 },
- { -6046, -5538, -3943, 2006 },
- { -6028, -3750, -3953, 771 },
- { -5959, -4582, -5024, 824 },
- { -5818, -2576, -2249, 1326 },
- { -5659, -5345, -1119, 2500 },
- { -3346, -4155, 606, 2749 },
- { -5680, -4827, -2501, 1838 },
- { -6193, -2543, -1295, 840 },
- { -6871, -4925, -3512, 1801 },
- { -5605, -1788, -1895, 779 },
- { -3922, -5712, -4644, 510 },
- { -4745, -3869, -4533, 99 },
- { -2984, -4907, -399, 1497 },
- { 1847, -478, 3061, -5812 },
- { 4450, -1116, 3609, -6570 },
- { 3139, 99, 3007, -5532 },
- { 2590, -3782, 3138, -4770 },
- { 1881, 1204, 5778, -3404 },
- { 3631, 2060, 5566, -5038 },
- { 3461, 1961, 5167, -3800 },
- { 2947, 273, 4536, -4389 },
- { 4453, -1730, 5788, -4370 },
- { 4032, 1805, 2666, -4534 },
- { 3487, -944, 2313, -6028 },
- { 1313, 34, 4210, -4067 },
- { 5632, -1502, 5825, -5855 },
- { 7736, -547, 4879, -5476 },
- { 4906, -1512, 4760, -5760 },
- { 3843, 447, 1091, -4958 },
- { 2982, -1135, 5442, -4386 },
- { 3579, 271, 3031, -6770 },
- { 3932, -211, 4688, -5507 },
- { 4411, 1720, 2387, -5584 },
- { 5379, -479, 4575, -6280 },
- { 3613, -362, 2012, -4885 },
- { 3744, -2013, 4493, -5073 },
- { 5693, 109, 4379, -3362 },
- { 5475, -621, 5317, -3985 },
- { 6411, -673, 5708, -4752 },
- { 4933, -796, 7262, -4290 },
- { 2804, 444, 6276, -3655 },
- { 4120, -517, 6078, -4531 },
- { 5119, 841, 3486, -3910 },
- { 4738, 1539, 3525, -2970 },
- { 5086, 370, 5895, -5640 },
- { 4235, 2716, 4589, -5044 },
- { 3691, 682, 6199, -4700 },
- { 6111, -570, 6271, -6528 },
- { 2611, 1277, 3756, -4802 },
- { 4395, 970, 3807, -5879 },
- { 5225, 2299, 3242, -4333 },
- { 5144, 1778, 4946, -5545 },
- { 2989, -3016, 3247, -5495 },
- { 2983, 920, 2071, -6059 },
- { 5270, -903, 4434, -2350 },
- { 6415, -585, 3970, -3554 },
- { 3866, -197, 5216, -2884 },
- { 3767, -1298, 6702, -3315 },
- { 6299, 2620, 5284, -6824 },
- { 6654, 646, 3653, -4927 },
- { 4770, 3047, 5160, -6287 },
- { 5364, 434, 2919, -5207 },
- { 2998, 1344, 4801, -2456 },
- { 3896, 1013, 3773, -1864 },
- { 2115, 655, 2999, -6344 },
- { 5170, -981, 2849, -4464 },
- { 2735, -2159, 2717, -5776 },
- { 2430, -1952, 4392, -4559 },
- { 6143, -1180, 3659, -4746 },
- { 4978, -1483, 1726, -4875 },
- { 3486, -2383, 3306, -4301 },
- { 1434, -1372, 4171, -4770 },
- { 3354, -2627, 1525, -5093 },
- { 6790, 2386, 3995, -5909 },
- { 1475, -2674, 3451, -4204 },
- { 1999, -3494, 3693, -5556 },
- { 4764, -2848, 2856, -5589 },
- { -3677, 5131, 2827, -2934 },
- { -2844, 7078, 2852, -3580 },
- { -3902, 6434, 4118, -1911 },
- { -1769, 7530, 3492, -3541 },
- { -1937, 5679, -447, -1127 },
- { -2456, 4680, 4196, -2407 },
- { -2778, 8241, 1698, -4288 },
- { -2876, 6104, 5182, -2387 },
- { -2802, 7341, 4463, -2938 },
- { -1025, 6267, 4752, -3201 },
- { -2349, 5413, 2041, -3794 },
- { -2252, 8225, 2856, -4269 },
- { -1465, 4967, 4976, -2500 },
- { -636, 7565, 3517, -4233 },
- { -1905, 5618, 3904, -2942 },
- { -302, 6816, 3343, -3316 },
- { -2210, 4156, 2817, -3511 },
- { -717, 6568, 1863, -2951 },
- { -3873, 5682, 2164, -575 },
- { -2878, 5835, 440, -2597 },
- { -3228, 7701, 2610, -2514 },
- { -3608, 8888, 3377, -2468 },
- { -2582, 9717, 2519, -3126 },
- { -5238, 6202, 2866, -2831 },
- { -3428, 7370, 3056, -335 },
- { -1681, 8836, 1210, -2010 },
- { -3276, 6724, 1156, -3930 },
- { -894, 8149, 827, -1258 },
- { -2965, 8631, 2549, -1320 },
- { -3961, 6902, 3581, 55 },
- { -1894, 7745, 1750, -841 },
- { -821, 6844, 850, -676 },
- { -608, 6948, -4, -1376 },
- { 615, 6524, 1089, -1147 },
- { -2972, 5668, 1091, -489 },
- { -157, 4649, 2904, -413 },
- { 673, 5121, 1498, -66 },
- { -390, 5902, 1611, -245 },
- { -2349, 5478, 4772, -1320 },
- { 88, 6798, 1972, -1859 },
- { -1213, 5120, 2991, 200 },
- { -2347, 6040, 2839, 376 },
- { -578, 5976, 3364, -1796 },
- { -1391, 5872, 3002, -965 },
- { -564, 4496, 3946, -1186 },
- { -2299, 6386, 3135, -2176 },
- { -2131, 5641, 2011, 1223 },
- { -772, 5807, 1124, 895 },
- { -2837, 6758, 2297, -740 },
- { -3091, 6298, 1415, -2126 },
- { -4197, 6036, 1843, -3022 },
- { -41, 6459, 92, 344 },
- { -2241, 6860, 2095, -4396 },
- { -1931, 7088, 2117, -2135 },
- { -2375, 4422, 1688, -3169 },
- { -1742, 6674, 1538, -119 },
- { -4818, 7749, 4192, -1577 },
- { -2004, 5672, 193, -430 },
- { -3825, 6042, 2128, -1898 },
- { -1108, 8033, 2119, -3013 },
- { -2370, 5453, 1721, 266 },
- { -1570, 7134, 614, -2638 },
- { -1519, 8752, 3503, -4330 },
- { -2050, 3845, 2907, -1126 },
- { 5085, 4412, -335, -1923 },
- { 3618, 1423, -613, -4012 },
- { 4481, 3729, 589, -4631 },
- { 4270, 3216, -1763, -3168 },
- { 4241, 1796, -1701, -2796 },
- { 4787, 2338, -487, -3639 },
- { 2915, 3429, -621, -4753 },
- { 5175, 1660, -1265, -3223 },
- { 4280, 4057, -684, -4079 },
- { 4980, 4419, -1455, -2719 },
- { 5436, 2464, 387, -4197 },
- { 4507, 4018, 1121, -3314 },
- { 6020, 2401, -413, -3201 },
- { 4200, 3789, -333, -2813 },
- { 5229, 2493, -1194, -1878 },
- { 5851, 2695, -492, -2292 },
- { 5743, 3288, -697, -1221 },
- { 5692, 2612, 979, -2227 },
- { 5085, 2067, 1046, -1214 },
- { 3163, 2240, -2098, -3435 },
- { 5228, 1898, 145, -2397 },
- { 5860, 3976, -418, -2872 },
- { 6008, 3399, 1027, -3506 },
- { 4126, 2035, 1865, -893 },
- { 5375, 3596, 511, -2362 },
- { 1937, 1493, -852, -122 },
- { 3473, 4849, 547, -2603 },
- { 4631, 2977, 1141, -1768 },
- { 6149, 3050, -71, -1886 },
- { 4069, 4353, -289, -1429 },
- { 2884, 1225, -1388, 365 },
- { 5485, 2518, -235, -571 },
- { 1216, 4375, 1443, 398 },
- { 4988, 3106, 107, -1435 },
- { 4511, 2801, 307, -444 },
- { 3235, 4386, 327, -676 },
- { 2055, 3708, 1657, -305 },
- { 5839, 2374, 290, -1385 },
- { 5110, 3305, 1936, -4206 },
- { 6416, 2920, 338, -2736 },
- { 3350, 2824, -1269, -3881 },
- { 4840, 1815, 464, 186 },
- { 2399, 3332, 238, 1238 },
- { 3516, 1363, 1582, 688 },
- { 3582, 1874, 154, -4770 },
- { 3261, 2878, 886, 283 },
- { 3877, 2658, -327, 884 },
- { 4151, 3436, 2173, -2923 },
- { 3592, 3674, 1281, -1295 },
- { 4561, 3730, -1114, -1747 },
- { 4595, 3625, -558, -575 },
- { 2577, 2348, 2267, 120 },
- { 5242, 3299, 32, -3412 },
- { 4264, 3637, 709, -2320 },
- { 6556, 3570, -838, -2472 },
- { 5745, 4014, -940, -1973 },
- { 5629, 4475, 477, -3328 },
- { 5269, 3199, 1682, -3085 },
- { 4432, 2416, 1145, -3299 },
- { 4465, 2505, 2162, -2186 },
- { 4643, 4941, -88, -2885 },
- { 4568, 5231, 552, -3915 },
- { 5667, 3075, -1406, -2963 },
- { 5418, 5259, -771, -2818 },
- { -256, -7875, 511, -471 },
- { -1813, -7971, -424, -396 },
- { -306, -7006, 862, 282 },
- { -2306, -6422, -1440, 508 },
- { -245, -6787, 375, -100 },
- { -1309, -6065, -20, 779 },
- { -1656, -6047, -641, 1307 },
- { -1496, -6522, 964, 726 },
- { -2291, -6588, -202, 795 },
- { -762, -7522, 1454, -558 },
- { -2270, -7004, -834, -580 },
- { -1139, -7078, 259, 362 },
- { -2535, -7568, -1040, 49 },
- { -3786, -7280, 934, -476 },
- { -3336, -6368, 606, 1056 },
- { -3602, -6924, 52, 714 },
- { -2278, -6550, 1674, 204 },
- { -2855, -5765, 930, 1530 },
- { -2889, -7325, -215, 305 },
- { -2749, -6080, -237, 1452 },
- { -985, -6667, 1577, 400 },
- { -2036, -6083, 380, 1267 },
- { -2077, -7460, 380, -30 },
- { -1775, -7175, 1540, -386 },
- { -3065, -6927, 989, 168 },
- { -2836, -7602, 117, -3392 },
- { -1058, -6396, 593, -3078 },
- { -844, -6062, 999, -236 },
- { -3261, -6951, 1491, -720 },
- { -2186, -8484, 75, -1287 },
- { -2882, -7756, 456, -510 },
- { -1800, -6879, 960, -1183 },
- { -2554, -7241, 1614, -1474 },
- { -2608, -5305, 392, 851 },
- { -2973, -6562, -859, 858 },
- { -2640, -5989, 1031, -416 },
- { -977, -8366, 705, -1434 },
- { -1213, -7409, -77, -1390 },
- { -1335, -6657, 2125, -123 },
- { -2544, -6862, 1852, -737 },
- { -3235, -6422, 1752, -103 },
- { -1300, -7557, 939, -348 },
- { -3476, -7579, 202, -109 },
- { -2482, -6572, 753, 619 },
- { -2554, -8136, -648, -429 },
- { -1012, -7870, -3, -421 },
- { -3604, -6247, 32, -3102 },
- { -1486, -7271, 2013, -1021 },
- { -578, -6799, -523, 405 },
- { -2841, -5948, 1644, 911 },
- { -2411, -7473, 1084, -484 },
- { -2238, -6033, 294, -1059 },
- { -3459, -6470, -201, -790 },
- { -2027, -6009, 1833, 805 },
- { -1433, -8047, 1531, -1754 },
- { -3258, -7884, 763, -1422 },
- { -1544, -6928, -729, 478 },
- { -2314, -8415, 74, -3757 },
- { -3201, -5684, 95, -2214 },
- { -2423, -8694, 725, -3631 },
- { -3545, -7071, 1162, -1798 },
- { -294, -9662, 403, -2274 },
- { -2290, -5460, 1196, 402 },
- { -1603, -6713, 903, -2363 },
- { 4121, 2491, -3142, -2482 },
- { 4500, 3305, -3671, -1567 },
- { 5973, 3172, -1348, -534 },
- { 4830, 3379, -1549, 643 },
- { 5214, 3938, -2641, -2302 },
- { 4639, 4826, -5532, -847 },
- { 5639, 2731, -2170, -963 },
- { 6084, 3487, -3525, -1346 },
- { 5971, 3154, -2190, -2316 },
- { 5618, 4865, -6927, 116 },
- { 5345, 3568, -7391, 709 },
- { 5429, 5078, -3811, -1524 },
- { 6960, 2037, -3515, -1096 },
- { 7092, 2531, -4557, -588 },
- { 6061, 4247, -5651, -478 },
- { 4595, 3684, -4907, -827 },
- { 7497, 3213, -3048, -424 },
- { 5996, 2137, -3098, -1745 },
- { 6198, 5199, -2223, -2274 },
- { 6888, 2851, -2768, -1675 },
- { 6114, 4210, -2316, -954 },
- { 7127, 4242, -3041, -1408 },
- { 6126, 3668, -1517, -1427 },
- { 6245, 6129, -4225, -1186 },
- { 6816, 3213, -2101, -964 },
- { 5345, 5276, -2643, -847 },
- { 6592, 4665, -4338, 484 },
- { 6746, 3751, -3443, 124 },
- { 5453, 1980, -2738, 2606 },
- { 4662, 2179, -4226, -1059 },
- { 5571, 3208, -3554, 174 },
- { 5256, 4447, -1815, -1481 },
- { 5400, 2570, -1210, 235 },
- { 7056, 2549, -2674, 318 },
- { 4574, 4340, -2892, -130 },
- { 6203, 4587, -3273, -305 },
- { 5103, 1925, -2715, -2137 },
- { 3905, 4296, -1700, 247 },
- { 4421, 4605, -3299, 811 },
- { 5671, 1273, -3870, -924 },
- { 5486, 1805, -4901, 133 },
- { 6437, 2578, -1828, -106 },
- { 5530, 5253, -5058, 1223 },
- { 4816, 2025, -1215, 1443 },
- { 3457, 3525, -2456, 3217 },
- { 3316, 2595, -1108, 2459 },
- { 3068, 3810, -2207, 1926 },
- { 6351, 5436, -6470, 600 },
- { 6324, 4240, -5365, 2416 },
- { 4851, 4774, -4075, 1878 },
- { 4900, 3679, -5198, 1078 },
- { 8347, 3633, -4565, -171 },
- { 5244, 5718, -3853, 173 },
- { 3960, 3492, -2939, 2105 },
- { 6070, 3473, -2351, 161 },
- { 8228, 3034, -3360, -901 },
- { 7006, 3985, -1940, -1926 },
- { 7123, 4681, -4301, -878 },
- { 5122, 4097, -1851, -449 },
- { 6200, 2060, -2251, 1049 },
- { 7106, 3844, -7209, 2625 },
- { 7108, 3370, -6734, 533 },
- { 6859, 2849, -3992, 1360 },
- { 5458, 2278, -3253, 1131 },
- { -1072, -2109, 4783, -1073 },
- { -319, -2604, 4257, -2418 },
- { 2466, 1300, 3476, -314 },
- { 2847, -1502, 5296, -141 },
- { 1667, -1273, 5559, -2725 },
- { 2877, -3402, 6434, 204 },
- { 53, -2637, 5275, -1181 },
- { 1091, -2215, 5803, -1549 },
- { 2397, -922, 4327, 1182 },
- { 219, -3747, 4647, -1564 },
- { -29, -2705, 4812, 1277 },
- { 1499, -2608, 5648, 1407 },
- { 2139, -2399, 4202, 2791 },
- { -426, -2064, 5528, 151 },
- { 2560, -2803, 6179, -2806 },
- { 4537, -2479, 3797, 1095 },
- { 888, -3357, 5341, -415 },
- { 4460, -1814, 5388, -1227 },
- { 3920, -3268, 6364, -703 },
- { 3343, -4698, 4410, 784 },
- { 309, -1897, 6306, 1223 },
- { 958, -3318, 4254, -3167 },
- { -99, 1596, 6018, -1983 },
- { -429, -853, 6407, 878 },
- { 1170, -1322, 6290, -417 },
- { 2288, -505, 6303, -1999 },
- { 3312, -1674, 6749, -2494 },
- { -415, -3401, 4721, -371 },
- { -189, -1210, 4844, -2002 },
- { 888, -4142, 4377, 130 },
- { 2469, -4381, 5398, -2492 },
- { 2879, -2912, 5094, -2598 },
- { -717, -617, 5650, -685 },
- { 1470, -3863, 5352, -1684 },
- { 3935, -96, 3823, -730 },
- { 3769, -430, 3168, 694 },
- { 2556, 385, 3539, 512 },
- { 77, -1415, 5111, 2655 },
- { 2724, -2158, 6715, -822 },
- { 1832, 1001, 5385, -1900 },
- { 900, 2198, 4464, -559 },
- { 441, 69, 5921, -1743 },
- { -1161, 738, 6732, -308 },
- { 257, 2035, 4091, 736 },
- { 1607, 1288, 4355, -23 },
- { -13, 1316, 4180, 1672 },
- { 1511, 1336, 3057, 1435 },
- { 2189, -3813, 4530, 939 },
- { 3632, -706, 2646, 1375 },
- { 4266, -3761, 4241, 1077 },
- { 3101, -427, 5273, -1202 },
- { 2293, 276, 4810, -313 },
- { 3430, -1851, 3101, 2045 },
- { 3453, -2979, 5142, 942 },
- { 1683, -3281, 4802, 2002 },
- { 3954, -4715, 5611, 578 },
- { 1272, -155, 5085, 454 },
- { 128, -194, 5095, 1409 },
- { 820, 880, 5797, -2658 },
- { -1095, 656, 5774, 1095 },
- { 813, -1669, 4320, -3251 },
- { -119, 518, 6372, -651 },
- { 2922, -4299, 6115, -877 },
- { 4205, -4273, 4004, 2642 },
- { -1211, -3892, 224, 3127 },
- { -34, -4371, 1321, 2318 },
- { 77, -6326, 1201, 828 },
- { 3995, -3775, 1958, 3233 },
- { 178, -3301, 1985, 3318 },
- { 2330, -3801, 1033, 3195 },
- { 1413, -5536, 826, 1709 },
- { 2468, -3499, 3653, 3631 },
- { 741, -4617, 1723, 2008 },
- { 1246, -3043, 2978, 3949 },
- { -343, -4308, 2258, 2189 },
- { -682, -4640, 454, 2272 },
- { 1236, -4829, 2491, 1642 },
- { -512, -3766, 1182, 3052 },
- { 119, -3939, 3712, 971 },
- { -1145, -4624, 1360, 2281 },
- { 101, -4746, 2866, 1255 },
- { -1500, -5455, 539, 1637 },
- { -969, -5909, 1414, 1128 },
- { -1261, -4939, -231, 2022 },
- { -226, -5345, 1207, 705 },
- { 2712, -5109, 3205, 1866 },
- { -476, -5913, 273, 1208 },
- { -2039, -4464, 624, 2545 },
- { -2351, -3930, 2019, 2673 },
- { -2675, -4849, 1522, 1990 },
- { -1524, -3461, 1446, 3204 },
- { 477, -5314, 1710, 1577 },
- { 656, -3729, 2346, 2511 },
- { 550, -5917, 1975, 1040 },
- { 1728, -4704, 3067, 1058 },
- { -9, -5247, 506, 1760 },
- { -574, -5135, 1675, 1672 },
- { 2129, -3781, 3444, 2313 },
- { 1144, -4439, 2214, 2529 },
- { 1292, -4160, 3185, 1833 },
- { 2445, -3262, 2534, 3227 },
- { 2266, -4401, 2023, 2400 },
- { -587, -3602, 3408, 2067 },
- { -885, -4951, 3228, 1174 },
- { -728, -2711, 2807, 3552 },
- { 1019, -3043, 3195, 2954 },
- { 1888, -4615, 1140, 2454 },
- { 660, -5616, 754, 800 },
- { -1975, -5371, 1649, 1585 },
- { -1544, -5436, 2422, 1081 },
- { -422, -5882, 2390, 750 },
- { 1336, -5557, 2441, 1230 },
- { 136, -4001, 267, 2854 },
- { -522, -3289, 2226, 2728 },
- { -971, -4580, 2471, 708 },
- { 704, -5306, 3300, 1001 },
- { 325, -3464, 3555, 2398 },
- { 794, -3686, 848, 3169 },
- { 660, -3017, 4584, 3242 },
- { -1486, -3978, 2170, 1644 },
- { -1615, -4650, 2688, 1844 },
- { 750, -4578, 538, 2239 },
- { 1668, -5849, 1455, 1031 },
- { 3486, -4681, 2030, 2183 },
- { 2642, -5429, 1696, 1761 },
- { 4491, -4502, 3538, 2767 },
- { 3545, -4528, 3514, 2982 },
- { 3269, -3676, 2758, 3966 },
- { 5572, 1146, 209, -3379 },
- { 7459, 1053, 593, -1896 },
- { 4480, 200, -310, -4259 },
- { 5577, -939, 242, -3992 },
- { 8142, 442, 1257, -3083 },
- { 5442, 1261, 1424, -3236 },
- { 6260, -183, 3125, -2532 },
- { 7179, 889, 1618, -2548 },
- { 6416, 932, 2379, -2487 },
- { 7094, 2560, 961, -3392 },
- { 7322, 463, 2732, -3735 },
- { 6632, 1577, 1912, -3272 },
- { 6312, 1349, 3028, -3460 },
- { 6105, 386, 1213, -977 },
- { 5478, 1158, 1114, -486 },
- { 6493, 410, 1686, -2180 },
- { 6378, 1881, 1333, -2240 },
- { 5711, 812, 1958, -1300 },
- { 6844, 877, 730, -1189 },
- { 6824, -245, 2249, -2000 },
- { 7515, 1521, 1251, -3058 },
- { 6697, 1051, 1300, -1749 },
- { 6476, 1425, 811, -2773 },
- { 7350, 465, -76, -2849 },
- { 6975, 2095, 567, -2492 },
- { 4691, 1736, 2660, -2289 },
- { 7837, 1456, 340, -2767 },
- { 7930, 507, 838, -2074 },
- { 6106, 1502, 766, -1110 },
- { 4891, -659, 835, -3954 },
- { 7250, 141, 1369, -1523 },
- { 7651, 67, 1651, -2298 },
- { 7364, -305, 601, -3132 },
- { 7179, 193, 2491, -2871 },
- { 6504, -272, 2167, -1322 },
- { 4456, 983, 2300, -421 },
- { 4817, 457, 1695, 371 },
- { 6914, 555, 850, -3159 },
- { 5904, 1030, 202, -1959 },
- { 6258, 880, 2233, -4503 },
- { 6029, 10, 2130, -3600 },
- { 6449, 985, 1129, -3963 },
- { 6616, -18, -111, -3285 },
- { 4496, 775, 817, -4276 },
- { 6134, 2338, 1470, -2973 },
- { 6911, 152, 430, -1946 },
- { 4053, 991, 3218, -1193 },
- { 5435, 1285, 3124, -2412 },
- { 5507, 1836, 1935, -1988 },
- { 5240, 689, 2189, -2670 },
- { 6638, 1719, 606, -1799 },
- { 5556, -180, 129, -2595 },
- { 5644, 1918, 1281, -4316 },
- { 6410, 1088, -282, -3117 },
- { 6503, 1841, 312, -3514 },
- { 6947, 20, 1358, -3886 },
- { 5464, 2109, 2398, -3194 },
- { 5616, -407, 2140, -498 },
- { 6121, 2707, 2379, -4096 },
- { 7303, 1846, 2266, -4095 },
- { 5444, 470, 2718, -1553 },
- { 5817, -645, 3285, -1349 },
- { 5625, 1427, 1103, -1991 },
- { 6041, -806, 1196, -2943 },
- { 3050, -5722, 4070, -5460 },
- { 3420, -4386, 4078, -5155 },
- { 6020, -3982, 7268, -2689 },
- { 7502, -4317, 7894, -3973 },
- { 4156, -3558, 5247, -4316 },
- { 4725, -4401, 7290, -1540 },
- { 6688, -5122, 8216, -3210 },
- { 9176, -6576, 9276, -4963 },
- { 8706, -5708, 7987, -4621 },
- { 7060, -3535, 6532, -3308 },
- { 5600, -2719, 5363, -1568 },
- { 4661, -2803, 6263, -4716 },
- { 3673, -3636, 6147, -3433 },
- { 5305, -2585, 6073, -2638 },
- { 7614, -1962, 6079, -5266 },
- { 6760, -3366, 7382, -4322 },
- { 6385, -3883, 4797, -1353 },
- { 8182, -5120, 4298, -4641 },
- { 9130, -6198, 4975, -3063 },
- { 7421, -5436, 5576, -3713 },
- { 3483, -4898, 5443, -2745 },
- { 4907, -5643, 6390, -4105 },
- { 8119, -7008, 7992, -6764 },
- { 6528, -6122, 6967, -5590 },
- { 5890, -4190, 6624, -5688 },
- { 6815, -7934, 7275, -5456 },
- { 5434, -4306, 5169, -5378 },
- { 4364, -6436, 5376, -2604 },
- { 8152, -3404, 5913, -5048 },
- { 7983, -4863, 4262, -2461 },
- { 8023, -6188, 6238, -5062 },
- { 6753, -3692, 3935, -3723 },
- { 6826, -4760, 3284, -4051 },
- { 7224, -7423, 4492, -3875 },
- { 6904, -2590, 6587, -6248 },
- { 6106, -1944, 7345, -5506 },
- { 4956, -2990, 7808, -3146 },
- { 6908, -6885, 5949, -1288 },
- { 7162, -6058, 3419, -3401 },
- { 7015, -7080, 6907, -3018 },
- { 6971, -6832, 5646, -3273 },
- { 8014, -5546, 5471, -1544 },
- { 6792, -2220, 5105, -2879 },
- { 8494, -3974, 4408, -3999 },
- { 9591, -4866, 6027, -4558 },
- { 5264, -5161, 6101, -738 },
- { 5803, -6141, 5197, -5231 },
- { 4657, -6822, 3232, -5189 },
- { 4791, -5135, 3809, -4665 },
- { 6108, -5103, 2379, -3873 },
- { 4680, -3909, 3234, -5093 },
- { 5802, -3853, 3795, -4984 },
- { 4360, -7483, 4802, -3877 },
- { 5429, -7517, 5911, -3717 },
- { 6866, -2280, 4880, -4634 },
- { 10131, -4628, 4414, -4092 },
- { 10811, -5189, 7746, -5337 },
- { 5663, -8941, 5287, -5680 },
- { 8023, -5991, 7403, -2796 },
- { 9669, -6919, 6525, -4932 },
- { 7275, -3796, 4962, -2547 },
- { 8848, -4806, 5677, -3080 },
- { 8128, -4308, 7749, -6569 },
- { 4032, -5196, 2282, -6239 },
- { 6593, 700, -229, 304 },
- { 8260, 539, -66, -1259 },
- { 6605, 176, -814, -109 },
- { 8057, 0, -1, -136 },
- { 7382, -38, -484, -1129 },
- { 8373, -929, 682, -454 },
- { 7674, 690, -1278, 546 },
- { 7326, -517, 406, -1283 },
- { 7612, -1715, -1167, 1175 },
- { 8590, 441, -782, -710 },
- { 8572, -1202, -291, 260 },
- { 7308, -147, -1785, 414 },
- { 6787, -353, -672, 934 },
- { 5177, -133, 179, 82 },
- { 4161, -34, 447, 1497 },
- { 5997, -902, 1533, -121 },
- { 5727, -871, -1370, 945 },
- { 8386, -252, 293, -823 },
- { 6573, -1354, 682, 616 },
- { 7650, -2096, 725, 457 },
- { 8122, 78, 636, -1400 },
- { 8421, 428, -1620, 131 },
- { 7341, -1292, -717, 186 },
- { 7998, -49, -720, 266 },
- { 5987, -351, 669, 844 },
- { 7314, -1620, 250, -603 },
- { 7219, -1562, -572, 1994 },
- { 8682, -358, -290, -388 },
- { 5810, 155, -178, 1199 },
- { 7246, -12, 1042, -786 },
- { 7357, -923, 1468, -475 },
- { 7801, 621, -212, -724 },
- { 5346, -514, 1210, 1356 },
- { 8459, 36, -127, -779 },
- { 6878, -2429, 854, 1750 },
- { 7280, -1401, -1353, 2845 },
- { 7579, -2148, -1463, 2087 },
- { 6637, 946, -872, 750 },
- { 4807, -1100, 1289, 2602 },
- { 4495, 219, 1551, 1128 },
- { 7639, 506, 446, -1107 },
- { 6359, 188, 1009, -115 },
- { 6641, -1820, 1655, 723 },
- { 5394, -2382, 1604, 2542 },
- { 6021, -2644, 2396, 1407 },
- { 4698, 882, 245, 1525 },
- { 8103, 573, -798, -349 },
- { 8045, -519, 997, -1092 },
- { 7571, -122, 227, -338 },
- { 5347, -1200, 630, 1718 },
- { 7070, 790, 218, -544 },
- { 7440, 728, -527, -20 },
- { 6402, -355, 197, -736 },
- { 4031, 771, 866, 1895 },
- { 6009, 896, 445, -31 },
- { 5160, 1098, -856, 1784 },
- { 7980, -886, -1293, 1396 },
- { 6318, -1361, 2423, 252 },
- { 7547, -699, 133, 506 },
- { 8562, -2344, 940, 264 },
- { 5890, 1187, -1425, 2194 },
- { 6558, -645, -1311, 2621 },
- { 4634, -1671, 2075, 1623 },
- { 5614, 105, -816, 2376 },
- { 6646, 1558, -1365, 630 },
- { 6998, 1150, -2117, -990 },
- { 6555, 2311, -1093, -1783 },
- { 6682, 1430, -2391, -1940 },
- { 7861, 1555, -2977, -1188 },
- { 6745, 1723, -459, -2085 },
- { 7504, 1229, -1666, -2060 },
- { 7937, 671, -2128, -1529 },
- { 7139, 991, -735, -2632 },
- { 6867, 1592, -1303, -2324 },
- { 6401, 2230, -1732, -2508 },
- { 7201, 2184, -2169, -1988 },
- { 6636, 2190, -995, -2840 },
- { 7620, 2306, -2089, -651 },
- { 7584, 1875, -1438, -631 },
- { 9214, 1561, -2464, -1139 },
- { 6154, 1318, -1237, -2917 },
- { 7917, 2847, -1797, -1599 },
- { 8309, 2029, -2555, -465 },
- { 8204, 1282, -584, -2405 },
- { 8440, 1035, -1147, -1137 },
- { 7107, 1858, -60, -1568 },
- { 6781, 2912, -873, -1463 },
- { 7603, 1316, -319, -1249 },
- { 7833, 1335, -78, -1849 },
- { 7930, 1141, -1016, -695 },
- { 7883, 1610, -1017, -1314 },
- { 8069, 1409, -1811, -196 },
- { 8319, 1031, -582, -1590 },
- { 5948, 1537, -2153, -2373 },
- { 8684, 1171, -1871, -850 },
- { 8357, 2484, -2411, -1292 },
- { 6516, 2092, -193, -1167 },
- { 6112, 1697, 22, -525 },
- { 7161, 703, -602, -1879 },
- { 6047, 2351, -807, -219 },
- { 8072, 1854, -1817, -1553 },
- { 6956, 1304, 76, -1011 },
- { 6607, 1481, -544, -162 },
- { 6958, 2541, -265, -1938 },
- { 6416, 2514, -777, -850 },
- { 7272, 2110, -899, -1171 },
- { 7741, 2153, -283, -2614 },
- { 6482, 2041, -1758, -1221 },
- { 6762, 940, -1862, -2281 },
- { 5610, 1194, -1691, -1561 },
- { 7833, 2164, -823, -1952 },
- { 5460, 1438, -848, 1189 },
- { 6011, 1377, -771, -1557 },
- { 7679, 544, -1134, -2214 },
- { 7209, 1292, -2714, -1564 },
- { 5567, 1200, -404, -169 },
- { 5853, 1461, -1465, -518 },
- { 6782, 689, -844, -860 },
- { 7330, 1337, -1152, -71 },
- { 7189, 1506, -653, -685 },
- { 6860, 2116, -1403, -240 },
- { 8804, 1516, -1391, -1760 },
- { 7210, 2689, -1498, -989 },
- { 7030, 3022, -1441, -2083 },
- { 5649, 1836, -407, 525 },
- { 7451, 3099, -717, -2464 },
- { 7384, 1656, -2007, 398 },
- { 6504, 707, -1919, -134 },
- { -1851, 3639, -2279, -695 },
- { -4037, 1644, -77, 1329 },
- { -4025, 1960, -1565, -567 },
- { -3430, 2495, -795, 368 },
- { -4771, 2480, 993, 756 },
- { -3431, 2058, -2539, -971 },
- { -3802, 3418, 380, 217 },
- { -3074, 3350, -1652, -1056 },
- { -3705, 326, -1650, 1535 },
- { -3122, 1281, -1192, 1607 },
- { -4601, 1367, -968, 53 },
- { -3808, 958, 44, 2560 },
- { -2079, 2530, -1485, 1166 },
- { -3707, 343, -2889, 180 },
- { -5249, 1431, -31, 688 },
- { -4990, 125, -704, 1270 },
- { -2771, 1334, -2446, 746 },
- { -2292, 994, -1527, 2630 },
- { -1261, 3070, -2519, 268 },
- { -2544, 3890, -1057, -552 },
- { -4421, 255, -1980, 530 },
- { -2951, 454, -13, 3643 },
- { -2262, 1815, -370, 2880 },
- { -2383, 3657, -649, 576 },
- { -3541, -161, -1389, 2550 },
- { -4241, 1575, 1325, 2561 },
- { -2767, 4037, 1221, 1578 },
- { -3748, 2697, 1148, 1801 },
- { -4686, 2385, -220, 0 },
- { -1531, 1645, -2751, 1327 },
- { -45, 4032, -799, 2298 },
- { -2915, 2280, 709, 2495 },
- { -1199, 3278, -406, 2346 },
- { -2471, 116, -2706, 2060 },
- { -2440, 2173, -2894, -344 },
- { -3375, 2287, 1781, 3226 },
- { -2153, 3568, 1827, 2918 },
- { -862, 2267, -1626, 2527 },
- { -2698, 1135, 301, 4239 },
- { -2364, 2123, 1010, 3710 },
- { -2447, 3281, -81, 1408 },
- { -2660, 4735, 472, 258 },
- { -1053, 3097, 2682, 2398 },
- { -3366, -1037, -1152, -868 },
- { -643, 4242, 2212, 1259 },
- { 971, 3991, 934, 643 },
- { -1617, 2002, 2139, 2195 },
- { -4897, 972, 784, 1719 },
- { -1275, 2992, 1039, 3821 },
- { -392, 4973, -209, 1821 },
- { -1028, 4718, -1479, -137 },
- { 50, 3914, 553, 2210 },
- { 678, 4364, 359, 1303 },
- { -582, 4911, 514, 1671 },
- { 1276, 3914, -1252, 2934 },
- { -1496, 3984, 857, 2330 },
- { 772, 4744, -655, 2332 },
- { -799, 5283, -439, 624 },
- { 1341, 2937, 650, 2027 },
- { -1739, 4892, 1275, 1702 },
- { -892, 2596, -151, 3951 },
- { -3532, 1090, 1292, 32 },
- { 321, 3146, 2647, 1475 },
- { 264, 4199, -1591, 1317 },
- { -452, -2357, 2266, 4192 },
- { 3022, -1033, -2389, 5678 },
- { -1162, -1342, 3543, 4990 },
- { -474, -1477, -1223, 5016 },
- { -699, -2857, 900, 3835 },
- { -461, -2255, -117, 4626 },
- { 1204, -2062, -1211, 4403 },
- { 2192, -3035, -337, 3966 },
- { 108, -831, 279, 5643 },
- { 1457, -620, -2908, 5276 },
- { -2527, -78, 1085, 5460 },
- { -1978, -1918, -949, 4733 },
- { 32, 367, -1904, 5166 },
- { 1890, -1665, 440, 4752 },
- { -518, -348, 2816, 4891 },
- { 3695, -2490, -1374, 4603 },
- { 246, -1965, 3549, 3969 },
- { 1100, -3111, 656, 3737 },
- { -1379, 870, -414, 4575 },
- { 628, -357, -1227, 6179 },
- { -1129, -1318, -2457, 4576 },
- { -425, -98, -73, 6336 },
- { 367, -887, 2990, 4207 },
- { 2091, -1251, 2444, 3557 },
- { -1759, -1610, 2046, 5273 },
- { 3210, 1414, -20, 2616 },
- { 3303, -2636, 1005, 4237 },
- { -327, -3107, -640, 3687 },
- { -197, 764, 572, 5486 },
- { 646, -767, 1388, 5464 },
- { 104, 2742, -228, 3907 },
- { -236, 1829, -579, 4585 },
- { -2150, -474, -1525, 4006 },
- { -23, -2632, -2400, 3892 },
- { -12, -1739, -2910, 4867 },
- { -2310, -368, -102, 4583 },
- { -1991, -2061, 533, 4531 },
- { 3884, -1446, -153, 4393 },
- { 1568, 14, -289, 5268 },
- { -1376, -253, -2797, 3417 },
- { 3193, -2577, 2475, 3566 },
- { 3418, 617, 1350, 1857 },
- { 3792, -24, -272, 3370 },
- { 153, 1159, 2906, 2877 },
- { 511, 2162, 1548, 2741 },
- { 262, 819, -2791, 3734 },
- { 4232, -2015, 1486, 3477 },
- { 2943, -1110, -1014, 5480 },
- { 2842, 369, 703, 3476 },
- { 3011, 1634, -933, 3553 },
- { 4412, -1548, -942, 5021 },
- { -1405, 593, 2372, 5267 },
- { 2093, 2129, 896, 2365 },
- { 4845, -1980, 0, 3823 },
- { -2140, 81, 3278, 5637 },
- { 1484, 2665, -324, 3653 },
- { 10, 192, 1620, 5291 },
- { 2152, 738, -2269, 5000 },
- { 2102, 2748, -1652, 4707 },
- { 2855, -2131, -387, 5188 },
- { 1173, 676, 1338, 3277 },
- { 2340, -2329, -2064, 4095 },
- { 861, -2024, 1296, 5055 },
- { 2189, 3225, -695, 2626 },
- { 6196, -7079, 1943, -822 },
- { 4547, -4813, 3261, 1856 },
- { 4243, -6904, 3443, 448 },
- { 4581, -7503, 946, 506 },
- { 6626, -7754, 3427, 470 },
- { 3407, -9088, 3269, -1496 },
- { 4079, -6464, 2304, 777 },
- { 5621, -9336, 2684, -768 },
- { 5351, -6464, 5238, -214 },
- { 5961, -8007, 1724, -3091 },
- { 4213, -8067, 603, -246 },
- { 7208, -7403, 3168, -1738 },
- { 6098, -7700, 329, -1379 },
- { 6525, -6735, 4248, -1072 },
- { 6073, -6241, 2167, -2378 },
- { 4609, -9218, 3051, -1033 },
- { 6813, -7283, 1581, -1897 },
- { 6126, -6275, 2789, 681 },
- { 4423, -6538, 1621, -1692 },
- { 6272, -8298, 3167, -1855 },
- { 6172, -8558, 4498, -1169 },
- { 4844, -8588, 1647, -366 },
- { 6209, -8807, 1581, -369 },
- { 5389, -8059, 550, -192 },
- { 6654, -9775, 2504, -1063 },
- { 7103, -7998, 806, 530 },
- { 5662, -6736, 1565, -3620 },
- { 4165, -9564, 4191, -2131 },
- { 4526, -7181, 576, -2875 },
- { 4633, -8623, 2807, -4742 },
- { 3709, -7794, 1815, 34 },
- { 3634, -8622, 2313, -826 },
- { 6991, -8447, 2063, -3198 },
- { 7757, -9486, 2255, -558 },
- { 4149, -7778, 4728, -1696 },
- { 5767, -7427, 1113, 707 },
- { 4592, -6261, 2329, 1864 },
- { 3159, -10498, 1677, -4273 },
- { 3534, -9010, 2437, -3565 },
- { 4479, -10821, 2715, -4942 },
- { 3207, -9805, 3054, -3886 },
- { 4627, -8189, 3018, -2354 },
- { 5527, -10566, 3244, -2749 },
- { 4346, -10127, 3335, -3084 },
- { 6132, -10085, 3316, -1308 },
- { 5629, -9704, 2178, -3058 },
- { 3603, -8538, 1246, -624 },
- { 3737, -8488, 395, -3167 },
- { 5465, -11414, 2810, -4640 },
- { 5306, -7745, 2721, -3988 },
- { 7000, -9111, 1695, -1409 },
- { 6663, -7741, 2466, -4079 },
- { 4083, -7175, 1836, -4831 },
- { 3613, -9926, 1342, -3455 },
- { 6588, -8033, 457, -258 },
- { 4720, -8102, 17, -1209 },
- { 7414, -8709, 1294, -344 },
- { 5437, -10030, 4043, -1704 },
- { 4862, -9281, 1558, -1431 },
- { 6800, -6403, 5113, 862 },
- { 4623, -8242, 2667, -228 },
- { 5919, -5083, 3348, 2135 },
- { 5985, -8889, 2733, -5105 },
- { 5029, -5767, 4407, 719 },
- { 354, -6158, -838, -3001 },
- { 351, -5943, -2104, -1534 },
- { -633, -7190, -25, -4798 },
- { -1595, -7235, -3812, -1400 },
- { 103, -6197, -2933, -78 },
- { -1722, -5020, -3441, -4333 },
- { -1963, -5644, -4365, -270 },
- { -846, -5743, -3477, 196 },
- { -191, -5348, -4054, -469 },
- { -2515, -7754, -3495, -818 },
- { -2090, -6710, -2701, 117 },
- { -546, -7036, -1398, 163 },
- { -278, -7091, -2662, -536 },
- { -622, -7962, -2731, -1464 },
- { -1555, -8118, -3612, -2057 },
- { -1094, -6280, -2314, 505 },
- { -2556, -8538, -4024, -2247 },
- { 109, -7134, -3107, -1823 },
- { -900, -6954, -3340, -717 },
- { -605, -7113, -3656, -2154 },
- { 837, -6263, -3211, -2177 },
- { -417, -5810, -3871, -1469 },
- { -1318, -5649, -4207, -3198 },
- { 413, -6765, -2082, -33 },
- { -3101, -6450, -4362, -766 },
- { 755, -6489, -2967, -846 },
- { 1117, -7106, -2452, -1352 },
- { -1202, -8387, -3072, -2897 },
- { -365, -4894, -3561, -2937 },
- { -2372, -8776, -265, -4441 },
- { -1224, -8678, -896, -5074 },
- { -755, -10096, -600, -6623 },
- { 300, -8206, -225, -4568 },
- { -1176, -6824, -2633, -3527 },
- { -2006, -5443, -1526, -5849 },
- { -1115, -5540, -2363, -4785 },
- { 1059, -6812, -2543, -2654 },
- { -1976, -6861, -3062, -5508 },
- { -379, -5328, -2321, -3624 },
- { -2108, -5860, -4518, -1915 },
- { -379, -7885, -1329, -594 },
- { 774, -5389, -581, -5213 },
- { -2601, -5083, -1849, -4921 },
- { -176, -5580, 74, -5075 },
- { -204, -6780, -190, -6232 },
- { 418, -7594, -1987, -820 },
- { -1873, -8529, -2926, -1609 },
- { 1340, -6362, -919, -4975 },
- { 577, -7990, -2044, -1873 },
- { -2572, -7413, -1745, -2224 },
- { -2037, -7030, -1461, -7138 },
- { -2559, -8756, -2039, -5836 },
- { -2079, -6764, -1209, -5669 },
- { -1613, -7801, -2006, -685 },
- { -1865, -6583, -722, -3529 },
- { -589, -6358, -1377, -1003 },
- { -540, -7514, -1331, -3542 },
- { 419, -6192, -1677, -4927 },
- { -2786, -8763, -2966, -5065 },
- { -2172, -8411, -1726, -4675 },
- { -3382, -9833, -3497, -5722 },
- { -2433, -10169, -2077, -5775 },
- { -424, -9451, -1096, -3658 },
- { -537, -8522, -910, -1897 },
- { -5550, 2807, 1683, -693 },
- { -6395, 635, 3573, -1246 },
- { -7544, 2280, 2140, 44 },
- { -8751, 1136, 2951, -794 },
- { -5605, 2709, 2052, 916 },
- { -7650, 654, 869, 135 },
- { -6939, 967, 1409, 870 },
- { -7834, 2123, 3310, 974 },
- { -6935, 2818, 1274, -1678 },
- { -5605, 2233, 1013, 471 },
- { -7095, 1849, 1648, 198 },
- { -6636, 1634, 712, -37 },
- { -7279, 978, 296, -315 },
- { -7664, 3504, 3292, -216 },
- { -7836, 1209, 1221, -257 },
- { -7913, 2201, 1765, -1529 },
- { -7077, 3783, 2632, -1407 },
- { -5565, 1645, 1410, -622 },
- { -6494, 2879, 1181, -759 },
- { -7073, 3137, 3010, 550 },
- { -7249, 1839, 847, -805 },
- { -6630, 2197, 282, -1096 },
- { -8836, 1573, 1988, -1090 },
- { -7809, 1274, 836, -1198 },
- { -7895, 2970, 3511, -1097 },
- { -6960, 1664, 1356, -2442 },
- { -6582, 2866, 2273, 307 },
- { -7221, 821, 2851, -1435 },
- { -6015, 1703, 2001, -2367 },
- { -8082, 1034, 2103, 239 },
- { -5952, 1912, 301, -465 },
- { -6099, 841, 379, 567 },
- { -6343, 50, 494, 658 },
- { -6586, 983, 591, -893 },
- { -5500, 869, 2187, -2479 },
- { -6482, 60, 1545, -979 },
- { -6705, 515, 1974, -53 },
- { -6460, 1755, 1325, -1275 },
- { -6093, 2617, 2465, -623 },
- { -7330, 2161, 594, -2115 },
- { -7324, 762, 1593, -2004 },
- { -6385, 679, 1510, -2514 },
- { -6159, 241, 2976, -1631 },
- { -8583, 3030, 4045, -162 },
- { -6299, 66, 2209, -2103 },
- { -5428, 1279, 3267, -1846 },
- { -6438, 1335, 2728, -1631 },
- { -8012, 1070, 2428, -1151 },
- { -6201, 2781, 2349, -1918 },
- { -5918, 1139, 3121, -148 },
- { -6314, 2481, 3137, -1808 },
- { -7180, 1722, 2435, -1602 },
- { -6750, 1829, 3763, -1145 },
- { -6713, 1777, 2221, 1212 },
- { -7479, 1835, 3627, -479 },
- { -7299, 10, 2406, -1593 },
- { -8249, 3129, 996, -2870 },
- { -8374, 1534, 1333, -1882 },
- { -7507, 3353, 1598, -2299 },
- { -7379, 2701, 2326, -1167 },
- { -8440, 2276, 2796, -542 },
- { -10348, 1527, 2649, -1165 },
- { -8184, 3614, 2574, -1738 },
- { -5539, 1574, 1733, 1138 },
- { 9404, -7652, 67, 79 },
- { 8654, -3972, 1358, -60 },
- { 8617, -4794, 117, 2318 },
- { 7886, -4505, 1784, 1200 },
- { 8636, -6125, 3879, -1003 },
- { 9654, -6836, 1816, 205 },
- { 9374, -6553, 913, 1875 },
- { 8020, -6150, 1134, 2390 },
- { 7786, -4970, 2078, -1857 },
- { 8691, -6119, 711, 708 },
- { 9039, -5568, 2944, -1902 },
- { 9955, -5048, 1433, -601 },
- { 8089, -6927, 3093, -2846 },
- { 8487, -7024, 2415, 19 },
- { 9388, -5287, 3577, -2655 },
- { 8591, -7371, 2300, -996 },
- { 9104, -4763, 1453, -2558 },
- { 7615, -5457, 596, 164 },
- { 9860, -7047, 3433, -614 },
- { 8756, -4404, 2235, -964 },
- { 9462, -4660, 299, -1822 },
- { 10119, -5550, 2689, -1273 },
- { 10915, -7471, 2705, -1007 },
- { 11433, -7090, 1410, -1198 },
- { 9882, -7431, 2965, -1895 },
- { 7628, -5219, 769, -2661 },
- { 8169, -5318, 2262, 70 },
- { 8846, -6320, 1939, -754 },
- { 7147, -5593, 1248, -971 },
- { 10652, -5485, 935, 137 },
- { 7778, -6533, 2564, -1932 },
- { 8878, -5173, 1214, -361 },
- { 9828, -4943, 282, 510 },
- { 10042, -6134, 3895, -1914 },
- { 7965, -6630, 3566, -433 },
- { 8573, -4502, 3574, -1209 },
- { 8398, -4801, 1031, -1347 },
- { 10136, -7772, 2612, 1547 },
- { 9890, -7280, 1768, -1083 },
- { 8407, -6585, -706, -58 },
- { 7976, -7582, 229, -131 },
- { 10481, -8866, 1166, -147 },
- { 10914, -4342, 3189, -2412 },
- { 10440, -5198, -104, -1109 },
- { 11227, -6530, 2381, -2449 },
- { 8487, -8064, 1086, 230 },
- { 9975, -6123, -857, -134 },
- { 8339, -6498, 1232, -2337 },
- { 11042, -4506, 1119, -2098 },
- { 12563, -5592, 1837, -2062 },
- { 11801, -5590, 632, -1296 },
- { 10152, -5617, 1511, -1917 },
- { 7800, -6473, 51, -1337 },
- { 7941, -5560, 2438, -3270 },
- { 6554, -3834, 2100, 1476 },
- { 9065, -5520, -226, -1120 },
- { 10794, -7120, -243, 122 },
- { 10429, -6968, 272, -806 },
- { 8942, -8914, 1442, -392 },
- { 9969, -5051, 2033, -2953 },
- { 7275, -4152, 3058, -64 },
- { 11127, -5488, 4589, -3227 },
- { 9626, -6666, 2739, -2958 },
- { 6943, -5362, 4470, 1008 },
- { -7456, -967, 2936, -1002 },
- { -8622, -333, 6962, 2606 },
- { -7486, -3392, 3668, 1287 },
- { -8053, -827, 5148, 1097 },
- { -6610, 454, 4952, 96 },
- { -7701, -1982, 3161, -468 },
- { -7307, -1132, 4071, -36 },
- { -8125, -271, 5199, 3862 },
- { -9182, -1950, 2813, 1878 },
- { -9855, -952, 4794, 3010 },
- { -7241, 1431, 4202, 2468 },
- { -9646, 157, 4766, 1046 },
- { -9371, 1230, 6009, 2958 },
- { -11514, -64, 8630, 5248 },
- { -6766, 565, 2766, 2140 },
- { -8426, -9, 2852, 1271 },
- { -11291, -1113, 5087, 2937 },
- { -8297, 2092, 4495, 1264 },
- { -9983, 735, 3809, -51 },
- { -9048, -1000, 3191, -308 },
- { -7331, -1987, 2655, 1391 },
- { -7144, -21, 4333, 2161 },
- { -6032, -1540, 3543, 896 },
- { -7987, -1036, 1985, 1529 },
- { -9264, 2004, 5194, 290 },
- { -11308, -840, 5754, 1654 },
- { -9130, -2398, 4292, 2973 },
- { -6248, 838, 3563, 1223 },
- { -6819, -2760, 3511, 119 },
- { -7213, -2006, 4364, 762 },
- { -5431, -1047, 4533, 166 },
- { -7098, -641, 2021, 639 },
- { -8628, -2249, 3588, 399 },
- { -6352, -1498, 3560, -648 },
- { -7033, -2190, 4870, 2562 },
- { -7405, -46, 3772, -581 },
- { -6104, 796, 5143, 1965 },
- { -5787, 943, 5784, 3030 },
- { -8367, 1465, 7192, 4097 },
- { -8259, 789, 5694, 1963 },
- { -10614, -1899, 5748, 2645 },
- { -8258, -805, 3698, 2275 },
- { -6877, -972, 6431, 3160 },
- { -6483, 363, 7018, 3129 },
- { -6283, -1358, 5191, 1524 },
- { -8853, -3157, 4119, 1741 },
- { -6086, -267, 3883, -835 },
- { -7254, 1032, 6613, 4017 },
- { -11470, -3350, 4649, 3426 },
- { -6743, 481, 6148, 1239 },
- { -5394, -166, 5309, 3165 },
- { -7958, 1068, 4268, -240 },
- { -10520, 2256, 7916, 2828 },
- { -5132, -4, 5739, 1176 },
- { -8643, 120, 3255, -629 },
- { -9631, 1974, 8870, 4362 },
- { -10663, -1221, 3733, 589 },
- { -8224, -1843, 5806, 2655 },
- { -8282, 1255, 8647, 3478 },
- { -12311, -1505, 9043, 6256 },
- { -11312, -856, 7136, 4681 },
- { -11944, -722, 7941, 3309 },
- { -7868, -463, 6846, 4196 },
- { -8679, -241, 7410, 5347 },
- { 6759, -4680, -508, 1220 },
- { 5176, -6111, 944, 121 },
- { 6843, -5667, -1368, -533 },
- { 5616, -5884, -1471, -695 },
- { 6030, -5089, -1808, -940 },
- { 7444, -5463, -52, 1881 },
- { 4207, -6079, -506, 1571 },
- { 6785, -4410, -649, 3084 },
- { 4838, -5214, 2026, 2998 },
- { 4201, -5790, 645, 1811 },
- { 6930, -5129, -1940, 1698 },
- { 6332, -4627, 692, 3027 },
- { 6285, -4314, -106, 3644 },
- { 6255, -5450, -1975, 742 },
- { 4199, -4676, -459, 1796 },
- { 5592, -5500, 1345, 1300 },
- { 4358, -5556, -2236, 114 },
- { 4620, -5875, -1563, 888 },
- { 4892, -7550, -327, -419 },
- { 4734, -7085, 7, 613 },
- { 3883, -5562, -1969, 1080 },
- { 5610, -4990, -204, 834 },
- { 4117, -6482, -1271, 341 },
- { 6585, -5107, 892, 1169 },
- { 6632, -3683, 302, 3002 },
- { 6326, -5351, -983, -1250 },
- { 4382, -7192, -730, -158 },
- { 5227, -6540, -451, 1123 },
- { 5468, -6472, -870, -1471 },
- { 5191, -6402, -1365, -127 },
- { 7407, -6317, -973, -336 },
- { 4611, -6530, -820, -1980 },
- { 4963, -5159, -2050, -966 },
- { 4414, -5691, -211, -998 },
- { 5954, -5873, 750, -1749 },
- { 4394, -4796, -1268, 254 },
- { 7161, -6214, -1010, 689 },
- { 4965, -3598, 2372, 1711 },
- { 6248, -6180, 981, 864 },
- { 6473, -5336, 525, -600 },
- { 4591, -6864, -1131, -900 },
- { 6314, -6440, -1021, -375 },
- { 5838, -6209, -1199, 944 },
- { 5308, -5283, -2100, 1267 },
- { 4342, -5860, -1637, -1356 },
- { 5680, -4388, -1227, -104 },
- { 4900, -4098, 1449, 4046 },
- { 4677, -4284, -106, 3190 },
- { 7574, -6173, -848, 1859 },
- { 6493, -7207, -131, 726 },
- { 5513, -5261, -2117, 4 },
- { 6191, -7352, -193, -505 },
- { 5885, -4333, 324, -134 },
- { 6162, -6081, -312, -2044 },
- { 4216, -6200, -1810, -572 },
- { 5652, -7035, -696, -197 },
- { 7131, -7189, -366, -60 },
- { 5032, -4803, -1514, 2832 },
- { 7386, -4610, -606, 3489 },
- { 4211, -5031, 1221, 3047 },
- { 4050, -4653, 1584, 1469 },
- { 6852, -5302, -1861, 206 },
- { 7736, -4816, -1794, 3359 },
- { 6290, -3439, 1522, 2454 },
- { 1768, 5990, -5560, -2594 },
- { 3903, 5326, -1530, -1501 },
- { 2472, 3738, -2117, -4240 },
- { 3260, 5448, -904, -4733 },
- { 1435, 7297, -3676, -4102 },
- { 4096, 5951, -656, -3312 },
- { 2178, 6009, -3146, -3724 },
- { 3787, 5493, -5473, -1633 },
- { 2998, 7286, -3334, -3571 },
- { 2894, 6576, -4708, -2804 },
- { 830, 6163, -4286, -3348 },
- { 4755, 5569, -1730, -2739 },
- { 4604, 6065, -3562, -2605 },
- { 2749, 5141, -3986, -2775 },
- { 3942, 4875, -2143, -3340 },
- { 2819, 8517, -2004, -2724 },
- { 2146, 6298, -689, -3093 },
- { 5196, 6504, -3393, -1475 },
- { 1851, 8386, -1748, -1420 },
- { 3474, 8572, -3534, -2688 },
- { 4503, 7560, -3561, -2245 },
- { 4433, 6219, -2393, -1575 },
- { 3506, 7248, -2275, -1977 },
- { 3490, 7409, -3147, -604 },
- { 4214, 6447, -3520, 516 },
- { 619, 7034, -829, -1705 },
- { 1732, 7395, -356, -2208 },
- { 1226, 5204, -3294, -3732 },
- { 2027, 5619, -1813, -4146 },
- { 3078, 5877, 47, -2651 },
- { 1654, 5458, 424, -682 },
- { 3163, 5464, -2026, -270 },
- { 2884, 5375, -685, -530 },
- { 2950, 7286, -35, -2967 },
- { 1986, 5066, -597, 482 },
- { 3459, 4308, -3845, -2333 },
- { 3155, 7037, -1346, -4345 },
- { 2193, 6696, -717, -1319 },
- { 3677, 5089, -3892, -487 },
- { 2186, 5136, -4186, -1492 },
- { 773, 5796, -917, 817 },
- { 2489, 6546, -3570, -2117 },
- { 1223, 6469, -1362, -33 },
- { 271, 6061, -1466, -1725 },
- { 2540, 5171, -1847, 1032 },
- { 2548, 5251, -2697, 1677 },
- { 771, 7600, -768, -632 },
- { 4710, 6647, -4736, -1275 },
- { 1369, 5917, -2971, -1056 },
- { 163, 5239, -3499, -2275 },
- { 2104, 4285, -3211, -3286 },
- { 1107, 7411, -1972, -1671 },
- { 2196, 7262, -2310, -1926 },
- { -244, 6439, -1745, -839 },
- { 3293, 3832, -2890, -3000 },
- { 419, 6443, -379, -407 },
- { 3077, 4930, -1156, -2869 },
- { 2131, 5874, -2330, 224 },
- { 690, 6538, -2212, -2841 },
- { 1602, 4421, -2515, 1542 },
- { 3318, 9373, -3032, -3477 },
- { 5646, 7462, -5153, -1463 },
- { 4139, 7137, -1539, -3321 },
- { 3481, 9077, -1645, -3653 },
- { -7747, 375, -106, -543 },
- { -8587, -1379, -586, -461 },
- { -10146, -892, 2094, 694 },
- { -8103, 382, 504, -325 },
- { -8548, -92, 94, -656 },
- { -7460, 38, 152, 388 },
- { -8266, -271, -459, -883 },
- { -7935, -664, -1026, -802 },
- { -8341, -109, 853, 161 },
- { -8802, -1355, 1099, 630 },
- { -8957, -6, 1108, -669 },
- { -7260, -1520, -43, -407 },
- { -7555, -174, 668, -2562 },
- { -9014, -126, 227, -1191 },
- { -8184, 769, 290, -1375 },
- { -9476, 55, 962, -1528 },
- { -8679, 541, 755, -1030 },
- { -9842, -1626, 838, -1588 },
- { -8513, -702, 788, -1998 },
- { -10101, -1558, -366, -1841 },
- { -8135, 78, 1479, -1813 },
- { -9128, -454, 313, -1786 },
- { -7554, -1084, 831, -2442 },
- { -7576, -701, 2068, -1665 },
- { -7791, -1481, 1587, -1808 },
- { -6701, -596, -97, 802 },
- { -7418, -15, 684, -963 },
- { -7127, -477, -139, -426 },
- { -8097, -110, -36, -264 },
- { -7620, -1922, -590, -101 },
- { -7647, -1201, 279, 660 },
- { -7856, -1974, 758, -2271 },
- { -8496, -167, 2232, -1143 },
- { -8506, -1359, 624, -740 },
- { -7274, -1052, 1062, -139 },
- { -7800, -217, 91, -1794 },
- { -7030, -1694, -955, 615 },
- { -9020, -1864, 101, -2182 },
- { -9400, -740, 598, -667 },
- { -8448, -1184, 2024, -1272 },
- { -8812, -570, -897, -2384 },
- { -10559, -1286, 538, -1536 },
- { -8728, -888, -1089, -1397 },
- { -7080, -1185, 636, -1252 },
- { -9880, 233, 2344, -782 },
- { -7952, -1326, -378, -1947 },
- { -7207, -378, 1408, -2237 },
- { -8467, -1545, 902, -1987 },
- { -9163, -1474, 924, -1739 },
- { -8159, -992, -77, -2744 },
- { -8343, 148, -423, -1573 },
- { -9105, -649, -254, -1214 },
- { -8939, 456, 281, -1905 },
- { -8837, 179, -394, -2634 },
- { -9145, 757, 1547, -1319 },
- { -9775, -723, 441, -1680 },
- { -8910, -686, 1529, -1525 },
- { -9492, -1134, 2064, -938 },
- { -6111, -943, 677, -31 },
- { -7411, -613, -814, 46 },
- { -9479, -922, -430, -2061 },
- { -11298, -1268, 1318, -1117 },
- { -8190, 832, 671, -2214 },
- { -10453, -550, 1672, -886 },
- { 1044, 9353, -1651, -5423 },
- { 1034, 8149, -455, -6166 },
- { 761, 8293, -3214, -4838 },
- { 938, 8077, 164, -5130 },
- { 1295, 8673, 2582, -5490 },
- { -314, 7973, -2395, -5231 },
- { -507, 9012, -2497, -5775 },
- { 2396, 8314, -1022, -4673 },
- { -1516, 8501, 1950, -4969 },
- { -308, 7401, 1549, -4866 },
- { -112, 8340, 3003, -4920 },
- { -50, 9315, 1371, -5666 },
- { -659, 9449, 2496, -5547 },
- { 2573, 9148, -2270, -4783 },
- { 830, 7104, -438, -3907 },
- { 522, 10672, -677, -6483 },
- { -1190, 10108, -510, -6518 },
- { -427, 8271, -579, -6315 },
- { 1602, 8113, -1927, -4418 },
- { -2266, 8180, 448, -5190 },
- { -1633, 8816, -226, -5771 },
- { 759, 9481, -105, -5813 },
- { 2254, 6679, -466, -5662 },
- { -88, 6946, 895, -5958 },
- { -1705, 10009, 1394, -5574 },
- { 748, 7943, 540, -6692 },
- { 1411, 7009, 232, -6145 },
- { 697, 7290, -1221, -5342 },
- { -1764, 10580, 1944, -3981 },
- { -1334, 9124, 1195, -3903 },
- { -905, 10067, 635, -5039 },
- { 664, 10680, 49, -4625 },
- { 1374, 9536, -777, -3591 },
- { 252, 9698, -597, -2931 },
- { 824, 9164, -1014, -2144 },
- { 2438, 10569, -2289, -4424 },
- { 2101, 7102, 507, -3614 },
- { 294, 8051, -432, -1518 },
- { -665, 10337, 547, -2852 },
- { 1168, 11989, -492, -5427 },
- { 1344, 6416, 302, -5061 },
- { -1727, 12264, 1507, -4543 },
- { 674, 10889, -902, -3605 },
- { -582, 9504, 300, -3618 },
- { 641, 7654, 689, -2109 },
- { 2065, 9243, 508, -4367 },
- { 1055, 8373, 688, -3144 },
- { -641, 8185, 986, -3307 },
- { 1120, 7426, 1785, -3757 },
- { 1660, 8070, -593, -3104 },
- { 2002, 9467, -1722, -3475 },
- { 2361, 8368, 100, -3709 },
- { -772, 7845, -613, -4988 },
- { 1485, 7430, 1896, -6127 },
- { -432, 7823, -947, -2882 },
- { 313, 11122, -760, -4871 },
- { 412, 8412, -283, -4231 },
- { 1585, 10402, -1884, -3267 },
- { 321, 6952, 773, -3016 },
- { -105, 9014, 121, -2249 },
- { 1585, 10313, -977, -4812 },
- { 1619, 11869, 1306, -6876 },
- { -1168, 8886, -81, -2500 },
- { -395, 10886, 733, -6490 },
- { -4949, 4274, 3992, -1054 },
- { -4241, 5299, 4262, -1584 },
- { -2710, 3862, 4552, -1673 },
- { -4608, 2472, 3672, -1715 },
- { -2843, 2816, 4003, -2326 },
- { -5229, 2964, 5636, 90 },
- { -4924, 3442, 5015, -1096 },
- { -1281, 3313, 5537, -2066 },
- { -3808, 1939, 4351, -919 },
- { -1915, 2585, 4939, -1614 },
- { -3470, 1843, 5562, -682 },
- { -3800, 870, 5827, 144 },
- { -4985, 1452, 4728, -709 },
- { -3745, 2750, 7220, 259 },
- { -1875, 1900, 6514, -826 },
- { -4329, 1574, 7192, 1304 },
- { -5408, 1444, 6208, 631 },
- { -3327, 5312, 5707, -1541 },
- { -6966, 3334, 4034, 1028 },
- { -7484, 4245, 4218, -212 },
- { -6567, 5839, 4539, -512 },
- { -5715, 5935, 3747, -1186 },
- { -6410, 4881, 3356, -1610 },
- { -5146, 2590, 2850, 2172 },
- { -5196, 4095, 2569, -373 },
- { -5043, 6025, 4318, 692 },
- { -5525, 4884, 3513, 370 },
- { -6804, 7533, 5812, -488 },
- { -5657, 2480, 4061, 1234 },
- { -3155, 1472, 6071, 1188 },
- { -3427, 5217, 3442, 858 },
- { -4698, 3013, 5517, 2586 },
- { -4449, 2226, 5418, 3580 },
- { -6395, 3547, 5487, 2028 },
- { -3500, 5019, 4787, 1 },
- { -4038, 2578, 3073, 3151 },
- { -2750, 1955, 4469, 3856 },
- { -5696, 1659, 6118, 2469 },
- { -4350, 1241, 6840, 3126 },
- { -5565, 5058, 5196, 1314 },
- { -1642, 4190, 3948, 607 },
- { -1233, 4108, 4850, -640 },
- { -997, 3428, 3239, 1378 },
- { -6488, 2741, 6926, 2792 },
- { -4188, 3763, 4235, 2018 },
- { -3210, 3224, 5646, 1427 },
- { -5526, 6909, 5070, -627 },
- { -2815, 3994, 3425, 1903 },
- { -2163, 2734, 5423, 145 },
- { -4149, 4247, 2355, 734 },
- { -410, 2521, 4138, -16 },
- { -2411, 2385, 4927, 2105 },
- { -6077, 3591, 3114, 594 },
- { -4186, 4834, 5926, -1004 },
- { -7315, 3369, 5966, 448 },
- { -7042, 5721, 5771, 238 },
- { -4466, 3907, 3535, -1751 },
- { -2116, 3970, 6163, -1392 },
- { -7239, 2143, 8407, 3630 },
- { -5431, 4486, 6486, -42 },
- { -1874, 1617, 6333, 519 },
- { -6478, 2629, 4634, -505 },
- { -7784, 2342, 7216, 1365 },
- { -1154, 1432, 4831, 1544 },
- { -4964, -5801, 1797, 506 },
- { -4436, -6905, 1059, -1237 },
- { -5400, -6886, 884, -290 },
- { -6259, -7103, 523, -227 },
- { -4819, -6450, 1412, -450 },
- { -4056, -6213, 1725, -943 },
- { -5642, -6091, 1357, 605 },
- { -4196, -5678, 2187, -173 },
- { -4726, -5126, 2470, 321 },
- { -6642, -5091, 1507, -1005 },
- { -5304, -5250, 1944, 1579 },
- { -7179, -5520, 1468, -425 },
- { -6033, -4895, 1876, -955 },
- { -6595, -5143, 2207, 1291 },
- { -4224, -4943, 1846, 1792 },
- { -7128, -6950, 539, 724 },
- { -4369, -4901, 2590, 1103 },
- { -7413, -5696, 1712, 1440 },
- { -5885, -6821, 418, 871 },
- { -6828, -5599, 710, -1563 },
- { -6123, -5817, 1358, 1631 },
- { -5291, -5622, 578, 2138 },
- { -7171, -6004, 347, 2208 },
- { -6083, -5251, 2132, 425 },
- { -4329, -5721, 407, -2993 },
- { -5326, -5056, 1119, -1837 },
- { -5485, -5856, 185, -2389 },
- { -6529, -5178, 403, -697 },
- { -6719, -4412, 2726, 871 },
- { -5126, -5629, 1835, -771 },
- { -5622, -4361, 2973, 858 },
- { -5282, -5895, 45, -335 },
- { -4357, -5656, 1696, -1558 },
- { -7139, -6659, 627, -409 },
- { -4415, -6328, 35, 1306 },
- { -7639, -6110, 1134, 197 },
- { -3626, -5592, 2019, 901 },
- { -3547, -5064, 1176, 1738 },
- { -5075, -3899, 2087, 266 },
- { -4086, -6311, 1479, 360 },
- { -6210, -5220, -199, -1477 },
- { -3910, -5063, 1356, -15 },
- { -7616, -4977, 461, 2401 },
- { -6118, -6131, 1258, -563 },
- { -6127, -4968, 1286, -27 },
- { -4121, -5852, 1113, 1476 },
- { -5157, -4881, 1162, -662 },
- { -4637, -5031, 1179, 709 },
- { -5509, -5452, -397, 1224 },
- { -4597, -6861, 646, 467 },
- { -6247, -4043, 468, 278 },
- { -5336, -6465, 874, -1472 },
- { -6998, -6346, 78, -1798 },
- { -4915, -4530, 2756, -203 },
- { -6048, -4373, 1468, 1052 },
- { -4273, -7100, 942, -323 },
- { -6552, -4287, 2351, 69 },
- { -6954, -4613, 722, 1521 },
- { -4201, -5361, 763, -1562 },
- { -6881, -5596, -748, 669 },
- { -6695, -3547, -34, 1299 },
- { -3981, -5728, 84, 111 },
- { -4663, -4809, 2173, -1031 },
- { -6599, -6077, 1303, 256 },
- { -7596, -4265, -5791, -4140 },
- { -6610, -2758, -5288, -3936 },
- { -5880, -3865, -6563, -3088 },
- { -7228, -5510, -7677, -3912 },
- { -8854, -6553, -8318, -5361 },
- { -9362, -5249, -6413, -4319 },
- { -4418, -3110, -6368, -4358 },
- { -5544, -4203, -6863, -5013 },
- { -3056, -4316, -5567, -3181 },
- { -3078, -5999, -5051, -2657 },
- { -5884, -6292, -5756, -4013 },
- { -4825, -4549, -5535, -4053 },
- { -4443, -6126, -5316, -1368 },
- { -3972, -6341, -6098, -2686 },
- { -5751, -2781, -5398, -6230 },
- { -4466, -6135, -5570, -3679 },
- { -4291, -5992, -3564, -5189 },
- { -7189, -4429, -7279, -6082 },
- { -5076, -4433, -2748, -5366 },
- { -6225, -2825, -6833, -5663 },
- { -2989, -4792, -3960, -4492 },
- { -7836, -7773, -7722, -5741 },
- { -6559, -5703, -5844, -5589 },
- { -7612, -5438, -4136, -3774 },
- { -4218, -4176, -6591, -2333 },
- { -4837, -5063, -6581, 322 },
- { -6590, -5990, -2980, -3847 },
- { -5558, -2971, -5489, -1932 },
- { -7001, -5323, -4975, -1697 },
- { -4694, -2688, -6904, -3044 },
- { -8511, -5379, -5767, -2549 },
- { -7548, -5412, -6522, -2572 },
- { -6597, -4973, -6423, -1274 },
- { -6415, -4022, -5168, -1072 },
- { -5528, -5530, -7218, -2345 },
- { -4845, -4805, -5943, -1227 },
- { -6049, -7150, -6744, -2161 },
- { -9061, -7299, -8542, -4375 },
- { -5010, -5546, -5416, -82 },
- { -4135, -4205, -5109, -3373 },
- { -3311, -5869, -4007, -5061 },
- { -5993, -6472, -3962, -4718 },
- { -2966, -5832, -2821, -6305 },
- { -4851, -5152, -2067, -3930 },
- { -3620, -4441, -3362, -5836 },
- { -4469, -5221, -4534, -5592 },
- { -4022, -6335, -4321, -6107 },
- { -4899, -4503, -3084, -3725 },
- { -4490, -8276, -4620, -6236 },
- { -6591, -4342, -7365, -4063 },
- { -6498, -5057, -5553, 485 },
- { -6060, -2714, -7093, -4144 },
- { -6199, -7774, -7094, -4057 },
- { -7536, -6424, -6415, -4265 },
- { -7439, -2454, -6348, -4827 },
- { -5333, -7565, -4417, -4639 },
- { -4353, -7103, -4197, -2689 },
- { -5229, -6549, -5129, -6804 },
- { -6129, -7701, -5236, -4836 },
- { -6797, -3983, -3884, -4406 },
- { -6624, -4467, -4745, -5052 },
- { -3324, -7596, -2720, -6553 },
- { -5473, -6284, -1704, -4511 },
- { -4131, -7263, -3180, -5196 },
- { -7116, -5565, -3469, 685 },
- { -6002, -6021, -3858, 576 },
- { -3144, -8203, -1291, -434 },
- { -6096, -7027, -4004, 1353 },
- { -3943, -7709, -2344, -36 },
- { -4510, -6767, -2642, 631 },
- { -3657, -11541, -2570, -3984 },
- { -5959, -8854, -1333, -867 },
- { -6699, -8866, -1606, -344 },
- { -3836, -7961, -2334, -2028 },
- { -3430, -8045, -3037, -672 },
- { -3868, -9184, -3635, -1819 },
- { -4258, -9060, -2621, -1008 },
- { -3595, -8693, -2022, -752 },
- { -4573, -8048, -3166, -2622 },
- { -4852, -7903, -1405, 256 },
- { -4591, -7057, -1560, 965 },
- { -6963, -7655, -980, 808 },
- { -5179, -6641, -3356, 1196 },
- { -7102, -6941, -2798, 2123 },
- { -6867, -5834, -3320, -770 },
- { -5977, -7369, -2500, -778 },
- { -6160, -6400, -934, -2543 },
- { -6741, -7608, -355, -1289 },
- { -6856, -6466, -1433, -1643 },
- { -4786, -6292, -4970, 376 },
- { -5407, -8866, -2255, -400 },
- { -3814, -6506, -1387, -3620 },
- { -4998, -6137, -1200, -4092 },
- { -5123, -9557, -2849, -1306 },
- { -4259, -6444, -4395, -338 },
- { -5221, -6810, -883, 1225 },
- { -6137, -6215, -2165, 554 },
- { -3895, -6557, -3176, -1829 },
- { -3886, -8188, -87, -954 },
- { -7243, -6707, -2216, -316 },
- { -5592, -7606, 85, -432 },
- { -3957, -7945, -504, -144 },
- { -4617, -7624, 218, -312 },
- { -4797, -8737, -844, -1051 },
- { -4478, -8516, -1401, -454 },
- { -4557, -7058, -302, -2332 },
- { -6623, -7736, -271, -50 },
- { -3157, -7532, -1111, -2207 },
- { -3590, -7300, -1271, 517 },
- { -4442, -7306, -507, 590 },
- { -6458, -7524, -2807, 666 },
- { -4991, -8466, -3363, -785 },
- { -7474, -7541, -1056, -1839 },
- { -7501, -8316, -938, -180 },
- { -5329, -7739, -579, -2341 },
- { -4549, -7063, -176, -3539 },
- { -5191, -8612, -1504, -4250 },
- { -3083, -7058, -2251, 32 },
- { -4003, -7043, -1093, -791 },
- { -5523, -8093, -678, -114 },
- { -3022, -10265, -2070, -3109 },
- { -3905, -6274, -182, -3652 },
- { -3269, -9217, -551, -2650 },
- { -3138, -9314, -1726, -1704 },
- { -4420, -10339, -1744, -3459 },
- { -4163, -8609, -2298, -4113 },
- { -5566, -6505, -1241, -463 },
- { -3130, -9746, -2352, -4884 },
- { -7825, -3439, 1451, -1468 },
- { -8451, -3318, 2360, -435 },
- { -8462, -4130, 1438, -1024 },
- { -9425, -4564, 1328, -689 },
- { -11014, -3202, 2278, 2080 },
- { -8269, -2761, -146, -440 },
- { -7497, -2618, -166, 413 },
- { -8250, -3060, 522, -2133 },
- { -8365, -5366, 1347, -451 },
- { -8589, -3979, 2943, 714 },
- { -8111, -2572, 1272, -1748 },
- { -7830, -5193, 605, -1484 },
- { -8119, -4736, 2141, 256 },
- { -7724, -4769, 1463, -812 },
- { -7363, -3911, 2540, 4 },
- { -7974, -3397, 2363, 1366 },
- { -7359, -4204, 1752, -958 },
- { -7622, -3505, 660, 916 },
- { -9934, -3665, 3165, 828 },
- { -8721, -4162, 62, 1718 },
- { -9433, -4768, 2722, 1234 },
- { -7960, -4496, 138, 1528 },
- { -8198, -3454, -443, 631 },
- { -7756, -2246, 655, 1137 },
- { -8841, -3145, 1113, 829 },
- { -7817, -3298, 1251, 230 },
- { -9413, -2733, 323, -1862 },
- { -9408, -4168, 1270, 1549 },
- { -9037, -3892, -942, 283 },
- { -8255, -3849, 1301, 1762 },
- { -9057, -3987, -41, -682 },
- { -9441, -4187, 2019, -111 },
- { -9740, -3178, 1602, -871 },
- { -8344, -2474, 1461, 1506 },
- { -9752, -2925, 1996, 1243 },
- { -9199, -3796, 180, 537 },
- { -9060, -2405, 1140, -1562 },
- { -9348, -2376, 309, -162 },
- { -10786, -3182, -5, -1500 },
- { -8142, -4540, -434, -826 },
- { -7528, -2341, 1104, -73 },
- { -9360, -2658, 3062, 56 },
- { -8267, -2335, 2000, -1193 },
- { -12169, -3154, 1287, -640 },
- { -11398, -2120, 946, -1163 },
- { -8940, -4559, 328, -1696 },
- { -11025, -4213, 2813, 840 },
- { -9224, -3581, 2224, 2039 },
- { -8943, -3337, 1248, -1298 },
- { -7900, -4042, 485, -2080 },
- { -9221, -1947, 2191, -880 },
- { -10762, -1800, 2516, -324 },
- { -10095, -2238, 981, -1335 },
- { -11908, -2808, 3255, 645 },
- { -10640, -4105, 1283, -595 },
- { -7663, -2863, 2467, -797 },
- { -10712, -3854, 3710, 1538 },
- { -10823, -2893, 1408, -801 },
- { -9874, -3832, 256, -1638 },
- { -10394, -3391, 2315, -94 },
- { -11525, -4079, 4153, 2122 },
- { -9546, -2088, 1541, 481 },
- { -8731, -2433, 1042, 2160 },
- { -7852, -3977, -1370, 1677 },
- { 7072, -3420, 1398, -1741 },
- { 6180, -1976, 1280, -3557 },
- { 7692, -1793, 2844, -1700 },
- { 8363, -1773, 3104, -2679 },
- { 9213, -3266, 3756, -3542 },
- { 9650, -2644, 1426, -1318 },
- { 7712, -2796, 3686, -1975 },
- { 7316, -3517, 2821, -622 },
- { 7434, -2594, 2305, -2264 },
- { 7237, -1797, 255, -3114 },
- { 8663, -1983, 1338, -3056 },
- { 6616, -952, 4059, -2652 },
- { 8823, -1327, 1362, -1356 },
- { 9938, -1722, 1287, -2362 },
- { 7207, -1057, 1913, -1315 },
- { 7508, -1585, 870, -1982 },
- { 8217, -3680, 1417, -3170 },
- { 8329, -2541, 1684, -585 },
- { 8062, -2335, 252, -2800 },
- { 8204, -4108, 3097, -2569 },
- { 7701, -3367, 576, -3008 },
- { 7350, -786, 2414, -2129 },
- { 6948, -2568, 1607, -225 },
- { 7684, -2387, 1308, -3449 },
- { 8306, -3458, 2394, -1454 },
- { 8438, -2781, 1043, -1362 },
- { 9175, -2076, 2144, -1987 },
- { 8347, -2709, 3489, -4301 },
- { 5696, -2377, 2870, 851 },
- { 8825, -1243, 2219, -2603 },
- { 8801, -1614, 584, -2513 },
- { 8413, -384, 1421, -2244 },
- { 9228, -3050, 3279, -2164 },
- { 6342, -2698, 3547, -107 },
- { 10053, -2476, 2837, -3168 },
- { 7439, -604, 3177, -3991 },
- { 7749, -1064, 4329, -4855 },
- { 8655, -2177, 2252, -3519 },
- { 8490, -228, 1958, -3233 },
- { 10513, -2968, 1911, -2340 },
- { 8146, -862, 1884, -1723 },
- { 7788, -666, 3004, -2891 },
- { 7785, -1620, 4133, -3417 },
- { 10262, -3731, 3455, -2971 },
- { 8570, -905, 4519, -4649 },
- { 9129, -2562, 463, -2465 },
- { 9451, -3587, 1904, -3056 },
- { 6549, -2236, 3010, -4523 },
- { 7175, -2684, 2967, -3458 },
- { 9872, -3278, 1054, -2472 },
- { 9153, -931, 1217, -2565 },
- { 8789, -3469, 753, -2568 },
- { 6683, -3791, 1797, -3968 },
- { 6801, -1977, 2311, -452 },
- { 6336, -1572, 2612, -3264 },
- { 7996, -1008, 730, -2964 },
- { 7521, -1059, 1573, -3694 },
- { 8148, -3973, 2600, -3572 },
- { 7765, -1532, 2528, -3856 },
- { 7404, -3918, 4472, -143 },
- { 8894, -1398, 3299, -3685 },
- { 5768, -2041, 1487, -637 },
- { 5131, -2865, 2463, -811 },
- { 6439, -1568, 3500, -1550 },
- { -8878, -6798, -5319, -1452 },
- { -6332, -9713, -3112, -990 },
- { -8444, -6316, -3694, -687 },
- { -6123, -10840, -3637, -4358 },
- { -4784, -9580, -4577, -2581 },
- { -6108, -10515, -4859, -2524 },
- { -7605, -7518, -2327, -2797 },
- { -9662, -8775, -2467, -2010 },
- { -6494, -7523, -4715, -118 },
- { -8290, -8982, -1672, -317 },
- { -8798, -11051, -3888, -1426 },
- { -6273, -6623, -6791, -142 },
- { -8313, -7668, -2141, -1275 },
- { -6453, -8412, -3589, -4102 },
- { -6747, -7750, -5690, -2498 },
- { -7814, -6693, -3174, -2446 },
- { -10383, -10130, -3931, -2364 },
- { -10606, -8467, -5539, -2772 },
- { -9475, -6671, -3305, -2271 },
- { -8982, -9457, -5635, -4005 },
- { -10111, -7965, -6515, -4180 },
- { -7301, -6479, -5364, 720 },
- { -9543, -8999, -7921, -912 },
- { -9534, -8562, -3469, -384 },
- { -7601, -10344, -3205, -1127 },
- { -8088, -8620, -4954, -2888 },
- { -8202, -8406, -7038, -3775 },
- { -7312, -8324, -3334, -1775 },
- { -8566, -9262, -8071, -4174 },
- { -7068, -11300, -5573, -2907 },
- { -8295, -8952, -4366, -1544 },
- { -11104, -10210, -2285, -384 },
- { -5213, -7520, -5008, -1339 },
- { -5889, -7940, -5987, -1385 },
- { -10816, -8201, -4153, -1485 },
- { -10277, -8919, -6315, -1652 },
- { -5888, -10320, -3821, -1733 },
- { -10497, -7181, -6083, -3032 },
- { -7721, -9724, -6591, -5336 },
- { -5688, -7894, -3486, -2552 },
- { -10014, -10500, -3247, -820 },
- { -6301, -8765, -4506, -2923 },
- { -8261, -7847, -6213, -1552 },
- { -10212, -7481, -8113, -3954 },
- { -6938, -10874, -6074, -4703 },
- { -7183, -10968, -4446, -1773 },
- { -7120, -9193, -1966, -2509 },
- { -6234, -9263, -2313, -4284 },
- { -8503, -9857, -2429, -608 },
- { -9372, -7844, -8391, -2120 },
- { -7951, -7157, -6535, -11 },
- { -7256, -9473, -2172, -660 },
- { -10063, -9612, -2515, -15 },
- { -6684, -9134, -6109, -4206 },
- { -8204, -11932, -5220, -2306 },
- { -9710, -6706, -4115, -3275 },
- { -6855, -7078, -2409, -4447 },
- { -7344, -7673, -4479, -4116 },
- { -8851, -6842, -4927, -2948 },
- { -8927, -10452, -5633, -2194 },
- { -8627, -9002, -7176, -1575 },
- { -8209, -9722, -7021, -3324 },
- { -3770, -10249, -3623, -4816 },
- { -8183, -7465, -4090, 646 },
- { -8163, -7149, 200, 498 },
- { -8289, -6266, 686, -206 },
- { -10030, -6241, -1032, -1864 },
- { -8793, -8327, -773, -169 },
- { -9149, -6215, 969, -15 },
- { -8303, -5859, -7, 2006 },
- { -9682, -7283, 255, 1322 },
- { -9293, -7227, 71, -231 },
- { -8525, -6215, 287, -837 },
- { -10477, -5379, 1159, 1449 },
- { -10726, -7856, -130, 102 },
- { -8694, -7461, -1210, 690 },
- { -9367, -5324, 1103, 3170 },
- { -10686, -8055, -831, 1633 },
- { -9201, -6873, -2704, 2258 },
- { -8421, -5358, -1405, 226 },
- { -9066, -5830, -307, -1571 },
- { -11150, -7381, -2746, -900 },
- { -9978, -5925, -2006, -437 },
- { -9464, -4741, -273, 1061 },
- { -10543, -6684, -1113, 1660 },
- { -10073, -5576, 1083, -269 },
- { -8826, -5763, 1600, 1486 },
- { -10445, -9071, -1253, -64 },
- { -12085, -5799, 2, 769 },
- { -12939, -6663, 1650, 1437 },
- { -10932, -6434, -1252, -649 },
- { -11650, -7826, -2053, 710 },
- { -12122, -6733, -1889, -731 },
- { -9093, -6095, -2463, -842 },
- { -10977, -4364, 469, 420 },
- { -11488, -6908, -521, 893 },
- { -9669, -5478, -842, 337 },
- { -10606, -5203, -632, -1361 },
- { -10198, -6284, 1662, 1277 },
- { -10135, -5292, 2435, 3493 },
- { -11027, -6561, 655, 56 },
- { -10977, -5030, 1127, -358 },
- { -12766, -3986, 1348, -335 },
- { -14244, -7731, 264, 317 },
- { -15124, -10309, -508, 1447 },
- { -12821, -8638, -608, 137 },
- { -13076, -8693, -2852, -431 },
- { -11156, -5546, -2252, -1600 },
- { -8692, -7366, -819, -1223 },
- { -12507, -9816, -1714, -121 },
- { -10712, -6666, 544, 3349 },
- { -12462, -5890, -2491, -2318 },
- { -12468, -7226, 437, 232 },
- { -11300, -5226, 2068, 687 },
- { -11994, -8320, -626, 2728 },
- { -12222, -5476, 1142, 18 },
- { -10277, -8122, -2418, 2003 },
- { -13418, -6115, -3563, -2802 },
- { -14759, -9834, -1243, 21 },
- { -13699, -5665, 1525, 507 },
- { -16269, -9476, -701, 163 },
- { -12677, -5437, -247, -1019 },
- { -11827, -4295, -181, -1243 },
- { -12847, -4496, 2984, 1123 },
- { -13860, -7915, -1166, -547 },
- { -12276, -8145, -2290, -1527 },
- { -11417, -4830, 2983, 1854 },
- { -11793, -6002, 1163, 1940 },
- { 11443, -4920, -3235, 3151 },
- { 11300, -6616, -1506, 1175 },
- { 9198, -4628, -2060, 2390 },
- { 10532, -4027, -643, 912 },
- { 9902, -3573, -1606, 1327 },
- { 9653, -3536, -2240, 1869 },
- { 9948, -5171, -423, 2662 },
- { 12316, -4004, -1989, 281 },
- { 12125, -4800, -1265, -163 },
- { 10650, -2617, -2337, 1462 },
- { 9909, -4968, -2376, 916 },
- { 12944, -4647, -1958, 460 },
- { 12988, -5283, -1141, 41 },
- { 12321, -2915, -3621, 1025 },
- { 11449, -2894, -2728, 351 },
- { 12087, -3041, -2002, -32 },
- { 11558, -4031, -1343, -399 },
- { 12983, -3740, -3516, 1245 },
- { 12099, -2515, -2752, 225 },
- { 12515, -3465, -2701, 550 },
- { 14683, -5022, -5272, 2996 },
- { 12260, -3383, -1215, -528 },
- { 13810, -5422, -2443, 1166 },
- { 13421, -5378, -1886, 721 },
- { 12961, -4259, -2594, 796 },
- { 12266, -2104, -4768, 1591 },
- { 13523, -4710, -3045, 1342 },
- { 12437, -2099, -5610, 2117 },
- { 11850, -2183, -3497, 661 },
- { 12275, -3936, -597, -697 },
- { 12459, -5253, -517, -544 },
- { 12835, -4094, -1322, -168 },
- { 14360, -5677, -3305, 1859 },
- { 13905, -4552, -4309, 2117 },
- { 11559, -3412, -1847, -81 },
- { 13379, -3167, -5764, 2746 },
- { 11910, -1634, -4342, 1052 },
- { 12662, -4742, 71, -974 },
- { 13057, -3254, -4424, 1705 },
- { 15046, -5706, -4851, 3019 },
- { 14162, -4142, -5514, 2843 },
- { 12764, -1845, -6684, 2888 },
- { 13714, -2374, -7838, 3857 },
- { 13295, -1663, -8293, 4073 },
- { 10032, -4152, -3403, 1421 },
- { 10942, -5386, -2222, 950 },
- { 10532, -6385, -1750, 1925 },
- { 10273, -5972, -1534, 643 },
- { 10605, -4782, -1695, 27 },
- { 10988, -5153, -1123, -341 },
- { 11629, -5884, -1060, 48 },
- { 10441, -4045, -2431, 311 },
- { 10788, -3595, -4171, 1807 },
- { 12110, -5686, -2127, 976 },
- { 11746, -4773, -2639, 891 },
- { 11541, -5299, -3031, 1732 },
- { 11416, -2559, -5359, 2198 },
- { 11583, -5376, -704, 677 },
- { 10416, -3214, -3516, 872 },
- { 9651, -5435, -1618, 3255 },
- { 9973, -5133, -996, 3923 },
- { 11707, -4643, -430, -796 },
- { 10994, -2709, -3587, 2302 },
- { 10716, -5118, -645, 270 },
- { 14100, -10314, 1095, 1531 },
- { 12944, -8049, 1105, -741 },
- { 13276, -7035, -511, 274 },
- { 14008, -7254, -283, 139 },
- { 11594, -6536, -91, 1671 },
- { 11732, -8645, 746, 15 },
- { 14613, -7085, -1578, 1183 },
- { 13083, -6224, -750, -4 },
- { 13988, -6256, -1592, 820 },
- { 14678, -8683, 441, 126 },
- { 15571, -8872, -521, 1139 },
- { 15642, -9533, 341, 697 },
- { 15960, -9586, -168, 1121 },
- { 15464, -10239, 1433, -1 },
- { 14934, -7887, -1046, 1080 },
- { 15252, -7630, -1899, 1628 },
- { 15485, -8384, -1234, 1484 },
- { 15962, -8638, -1815, 1931 },
- { 16501, -10664, 398, 1167 },
- { 16146, -10145, 411, 918 },
- { 14573, -7475, -697, 601 },
- { 14302, -7996, 28, 257 },
- { 14769, -6792, -2286, 1574 },
- { 14144, -6137, -2169, 1257 },
- { 14770, -6271, -3111, 1933 },
- { 14110, -8312, 1083, -531 },
- { 15235, -6991, -2993, 2174 },
- { 13222, -5805, 547, -891 },
- { 14796, -8762, 1254, -246 },
- { 16040, -9181, -1005, 1551 },
- { 16487, -10086, -373, 1420 },
- { 15077, -9479, 966, 51 },
- { 13026, -6468, 932, -1080 },
- { 12703, -6152, -33, -573 },
- { 15641, -6810, -4128, 2874 },
- { 13282, -7673, 1583, -1283 },
- { 12373, -7150, 1512, -917 },
- { 12992, -7751, -678, 783 },
- { 10907, -6858, -313, 2597 },
- { 13026, -8963, 125, 2152 },
- { 12770, -9946, 1957, -505 },
- { 12482, -6849, -1268, 833 },
- { 13790, -6181, -138, -279 },
- { 12709, -8382, 2044, 227 },
- { 12244, -6630, 203, -457 },
- { 14209, -6816, -1032, 632 },
- { 15134, -8267, -288, 640 },
- { 13619, -6157, -1090, 356 },
- { 14044, -7413, 725, -484 },
- { 12958, -7753, 2585, -1980 },
- { 13188, -8396, 2306, -1558 },
- { 14379, -9980, 2132, -688 },
- { 14275, -9857, 1162, 179 },
- { 13690, -8648, 1621, -889 },
- { 11770, -6829, -746, 278 },
- { 12732, -8202, 286, 90 },
- { 13630, -10146, 1867, -207 },
- { 12072, -8740, 1299, -645 },
- { 12852, -9492, 1226, 62 },
- { 11792, -7382, -54, -116 },
- { 13779, -9014, 487, 351 },
- { 11951, -7729, 121, 834 },
- { 11970, -9781, 2276, -4 },
- { 12680, -7984, 2787, -787 },
- { 13300, -14488, 6408, -1927 },
- { 13635, -15355, 9153, -3073 },
- { 12804, -13566, 5517, -1625 },
- { 16624, -10854, 1690, 28 },
- { 20387, -18532, 6162, -261 },
- { 16515, -12642, 3392, -519 },
- { 15800, -11095, 2151, -202 },
- { 16824, -11790, 1651, 599 },
- { 17604, -13213, 2563, 538 },
- { 17892, -14177, 3562, 147 },
- { 16987, -11399, 869, 1052 },
- { 17003, -12456, 2442, 265 },
- { 21657, -21806, 9198, -1250 },
- { 16825, -13341, 3980, -686 },
- { 17525, -12714, 1887, 805 },
- { 16419, -11034, 1216, 617 },
- { 20931, -19939, 7469, -684 },
- { 18452, -15390, 4573, -191 },
- { 14778, -10077, 2841, -1209 },
- { 17402, -13319, 3042, 160 },
- { 19365, -17922, 7087, -1061 },
- { 16298, -11941, 2810, -351 },
- { 19087, -16176, 4775, -84 },
- { 17666, -12289, 938, 1224 },
- { 18581, -15894, 5132, -430 },
- { 19823, -16717, 4142, 545 },
- { 19960, -19423, 8400, -1492 },
- { 18973, -16817, 5906, -594 },
- { 19079, -15431, 3528, 503 },
- { 16667, -12485, 4467, -1302 },
- { 19791, -17797, 6196, -529 },
- { 20005, -17606, 5354, -20 },
- { 20123, -18599, 6886, -728 },
- { 19068, -14805, 2394, 1105 },
- { 14443, -13723, 5631, -2029 },
- { 14730, -14231, 5631, -1450 },
- { 16089, -15959, 7271, -2029 },
- { 13473, -11200, 3236, -924 },
- { 14413, -10902, 2347, -267 },
- { 17666, -18662, 11381, -3496 },
- { 14749, -11042, 3305, -275 },
- { 15304, -10486, 1869, -240 },
- { 14809, -12126, 3369, -616 },
- { 16896, -16561, 7307, -1845 },
- { 15782, -14336, 5380, -1264 },
- { 16395, -15520, 6415, -1588 },
- { 13681, -11114, 2584, -320 },
- { 14244, -12326, 4480, -1632 },
- { 15247, -13119, 4265, -898 },
- { 13987, -12091, 3469, -597 },
- { 13941, -12770, 4240, -839 },
- { 13771, -13627, 5252, -1384 },
- { 15010, -16074, 7592, -2249 },
- { 15852, -17226, 8619, -2655 },
- { 18921, -16916, 6875, -1501 },
- { 14909, -11678, 2768, -295 },
- { 18988, -18353, 8424, -2070 },
- { 15457, -15080, 6218, -1513 },
- { 14916, -15512, 6949, -1883 },
- { 18108, -14702, 4681, -701 },
- { 17600, -15733, 5616, -775 },
- { 14070, -13683, 6472, -2626 },
- { 13832, -11914, 5201, -2232 },
- { 18846, -19009, 9192, -1961 },
- { -11981, -10994, -6324, -2264 },
- { -10976, -9047, -6546, -3828 },
- { -11288, -10532, -7014, -4191 },
- { -10139, -10189, -7799, -2688 },
- { -10555, -9988, -9181, -2040 },
- { -11596, -11339, -10022, -2707 },
- { -13400, -13395, -11306, -4206 },
- { -9774, -12281, -7466, -4133 },
- { -10842, -13125, -8777, -4956 },
- { -11964, -15082, -9779, -5095 },
- { -9382, -10188, -9053, -4927 },
- { -11562, -11296, -3651, -985 },
- { -9287, -10083, -7918, -4069 },
- { -12821, -16556, -11410, -6195 },
- { -12628, -8959, -4521, -1113 },
- { -13845, -11581, -3649, -681 },
- { -12685, -10269, -5483, -1275 },
- { -14988, -12874, -5107, -1189 },
- { -13761, -11367, -6202, -1804 },
- { -13225, -11249, -7820, -3354 },
- { -14809, -11992, -3202, -312 },
- { -15620, -15519, -10210, -3433 },
- { -12954, -10200, -3139, -611 },
- { -11536, -9981, -5284, -923 },
- { -13034, -12417, -4612, -1098 },
- { -16911, -15505, -6123, -1352 },
- { -17396, -17685, -8330, -2171 },
- { -14120, -10764, -2265, -99 },
- { -12598, -7367, -5406, -3530 },
- { -14143, -12793, -10909, -5226 },
- { -14692, -16871, -11626, -5554 },
- { -12581, -11197, -9194, -3837 },
- { -16752, -16726, -9746, -2808 },
- { -10600, -10358, -6560, -1227 },
- { -14573, -13312, -8957, -3393 },
- { -10172, -8463, -8579, -3387 },
- { -11418, -12421, -5522, -1842 },
- { -11855, -14204, -6669, -2625 },
- { -13308, -8191, -3941, -2194 },
- { -10007, -12266, -5022, -1811 },
- { -13532, -15771, -9497, -3175 },
- { -11760, -11148, -10339, -5529 },
- { -12149, -12763, -11198, -3697 },
- { -12029, -12119, -8555, -1792 },
- { -16995, -19957, -11447, -3471 },
- { -13144, -14504, -9988, -3191 },
- { -9938, -11064, -6139, -3162 },
- { -8873, -11550, -8294, -6550 },
- { -9303, -13010, -6150, -2711 },
- { -15463, -10469, -1766, -170 },
- { -15985, -11693, -3007, -650 },
- { -17142, -10671, -1434, 47 },
- { -16063, -13858, -4817, -1058 },
- { -19446, -19599, -9594, -2464 },
- { -20076, -18744, -8313, -1889 },
- { -15047, -16085, -7590, -2250 },
- { -13481, -16195, -8552, -2998 },
- { -13829, -14869, -6704, -1932 },
- { -16357, -18484, -9802, -2959 },
- { -10551, -8393, -9303, -5070 },
- { -11345, -9156, -5641, -3107 },
- { -13217, -13449, -9270, -4541 },
- { -11988, -13732, -9995, -6374 },
- { -11007, -9519, -5168, -4107 },
- { 9930, -7858, 8061, -4375 },
- { 8274, -7867, 5992, -2096 },
- { 9692, -9675, 7621, -3670 },
- { 9589, -8110, 6509, -3010 },
- { 12617, -11976, 10122, -5360 },
- { 11867, -8895, 7948, -5323 },
- { 10388, -10482, 9234, -4324 },
- { 8188, -8220, 7810, -2737 },
- { 10407, -8787, 4806, -1930 },
- { 10348, -8845, 9233, -6614 },
- { 9422, -7091, 4820, -2878 },
- { 9758, -9796, 5584, -2256 },
- { 10188, -7994, 5347, -3343 },
- { 11133, -7455, 4015, -2306 },
- { 10676, -10744, 6093, -2629 },
- { 11522, -12184, 7848, -3375 },
- { 8805, -9883, 5317, -3071 },
- { 9498, -9654, 6555, -3592 },
- { 10488, -8008, 4066, -1252 },
- { 11261, -8930, 6068, -2738 },
- { 12180, -10397, 5027, -1531 },
- { 9138, -8531, 3601, -1959 },
- { 8107, -8380, 4970, -2061 },
- { 9737, -13248, 6438, -2617 },
- { 11178, -10423, 2622, -522 },
- { 9572, -12372, 5199, -2019 },
- { 12057, -12144, 4147, -1099 },
- { 9047, -9925, 2516, -665 },
- { 10790, -8030, 5882, -4386 },
- { 7199, -8426, 6337, -2841 },
- { 7778, -8285, 3529, -3442 },
- { 7559, -10569, 3484, -1332 },
- { 9404, -8115, 7484, -5541 },
- { 7792, -11976, 5546, -2573 },
- { 9313, -10264, 7661, -5195 },
- { 6701, -10725, 4370, -1784 },
- { 4918, -11361, 4507, -4527 },
- { 5147, -12305, 3978, -5556 },
- { 6525, -9899, 4481, -3129 },
- { 7538, -12855, 6060, -4826 },
- { 8659, -12111, 7159, -4430 },
- { 8440, -11304, 4547, -1747 },
- { 9216, -10918, 3507, -1195 },
- { 6165, -9254, 4771, -4677 },
- { 9163, -11019, 5637, -4935 },
- { 13441, -11509, 6676, -2434 },
- { 7912, -9398, 6663, -4048 },
- { 11723, -13745, 8131, -4148 },
- { 6065, -10257, 5005, -6327 },
- { 11618, -12417, 5336, -1894 },
- { 8891, -13924, 8407, -6131 },
- { 9622, -12563, 7908, -5109 },
- { 11479, -10315, 8349, -3991 },
- { 11676, -14103, 6611, -2330 },
- { 11951, -8953, 3829, -1550 },
- { 10486, -8044, 10493, -5920 },
- { 11801, -10769, 9763, -5305 },
- { 6109, -8676, 5827, -1346 },
- { 7030, -9611, 5624, -5761 },
- { 12808, -12886, 8683, -4148 },
- { 13213, -10464, 6381, -3189 },
- { 11796, -13681, 10703, -6075 },
- { 9639, -7949, 9625, -3944 },
- { 8538, -6997, 5309, 453 }
+ { 9928, -2618, -1093, -1263 },
+ { 11077, -2876, -1747, -308 },
+ { 10503, -1082, -1426, -1167 },
+ { 9337, -2403, -1495, 274 },
+ { 10698, -2529, -532, -1122 },
+ { 10368, -3974, -1264, -750 },
+ { 10070, -3667, 346, 863 },
+ { 10278, -3093, 311, -576 },
+ { 9894, -1330, -1428, -860 },
+ { 10544, -1923, -1058, -971 },
+ { 10996, -1632, -841, -1404 },
+ { 11832, -3465, 1658, -1990 },
+ { 10852, -688, -2658, -499 },
+ { 10546, -1749, -147, -1733 },
+ { 10801, -1004, -708, -1453 },
+ { 10588, -441, -2113, -952 },
+ { 10141, -3331, -582, -1432 },
+ { 9608, -2590, 383, 258 },
+ { 11422, -3265, 229, -1544 },
+ { 10460, -1338, -713, -1568 },
+ { 10306, -1721, -1660, -603 },
+ { 9580, -1812, -1235, -1061 },
+ { 11471, -2285, -1617, -607 },
+ { 10081, -2225, -1408, -868 },
+ { 10715, -2624, -1367, -704 },
+ { 10616, -1871, -2770, -35 },
+ { 9352, -2340, -1024, -1566 },
+ { 11065, -1458, -1926, -735 },
+ { 11334, -2056, -1041, -1144 },
+ { 9825, -2048, -794, -1536 },
+ { 11850, -2695, -1123, -867 },
+ { 10654, -2226, -1891, -373 },
+ { 10024, -1557, -808, -1069 },
+ { 11142, -1266, -3238, 128 },
+ { 11729, -3282, -514, -1011 },
+ { 11402, -2094, -2335, -189 },
+ { 10195, -3658, 181, -1875 },
+ { 11431, -2626, -404, -1377 },
+ { 11001, -3868, -619, -1077 },
+ { 10894, -2559, 274, -1758 },
+ { 9633, -1482, -2253, -773 },
+ { 11245, -3321, 830, -1972 },
+ { 9768, -2701, -199, -1859 },
+ { 10500, -2042, 525, -2043 },
+ { 11669, -4069, 293, -1468 },
+ { 9192, -1991, -583, -61 },
+ { 10057, -3220, -2015, -473 },
+ { 9497, -2315, -2490, -467 },
+ { 10455, -3069, -1194, -1007 },
+ { 9994, -1936, -60, -1225 },
+ { 9295, -2156, -1761, -1134 },
+ { 10085, -3748, -1026, 197 },
+ { 9334, -2360, 804, -351 },
+ { 11561, -2553, 1352, -2313 },
+ { 12837, -3998, 1195, -1958 },
+ { 10114, -1100, -2414, -394 },
+ { 9341, -2530, 315, 755 },
+ { 10131, -3164, 1411, -674 },
+ { 9535, -905, -1551, 579 },
+ { 11717, -1519, -3051, 91 },
+ { 9824, -2911, -2775, 192 },
+ { 9662, -2934, -561, 1450 },
+ { 11085, -3392, -1298, -659 },
+ { 8955, -2102, -1899, 703 },
+ { 8607, -1742, -4348, 814 },
+ { 7640, -2063, -3617, 52 },
+ { 7074, -826, -4325, 4375 },
+ { 7714, 584, -4238, 1927 },
+ { 6355, -952, -4912, 3127 },
+ { 7069, -660, -6413, 4087 },
+ { 8313, -132, -2964, -876 },
+ { 6952, -1422, -3962, -24 },
+ { 9299, -734, -3088, -263 },
+ { 9484, -574, -4513, 466 },
+ { 7246, -91, -3735, -704 },
+ { 8325, -1417, -3090, -530 },
+ { 6469, -1226, -4757, 829 },
+ { 6652, -368, -5682, 1393 },
+ { 7971, -1278, -2284, 1205 },
+ { 7229, -699, -3556, 1840 },
+ { 7994, 1284, -2729, 732 },
+ { 9005, -698, -4522, 2189 },
+ { 6963, 197, -2727, 380 },
+ { 8527, 135, -3991, -213 },
+ { 8840, 934, -3014, -567 },
+ { 10125, 418, -3284, -371 },
+ { 6367, 361, -2318, 2554 },
+ { 7892, 172, -5247, 4673 },
+ { 6674, 387, -5424, 4398 },
+ { 6240, 684, -4047, 1219 },
+ { 11170, -794, -5081, 1195 },
+ { 11765, -648, -6265, 2052 },
+ { 10845, -775, -3837, 366 },
+ { 12496, -689, -8260, 3562 },
+ { 7893, -1166, -4972, 988 },
+ { 8592, 1052, -5986, 3087 },
+ { 7277, 1874, -5685, 3579 },
+ { 6900, 2016, -4809, 3491 },
+ { 8530, -2405, -3250, 1986 },
+ { 9426, 494, -7067, 5038 },
+ { 10285, 564, -8210, 5370 },
+ { 8749, -2207, -3980, 2852 },
+ { 9653, -2686, -4300, 1400 },
+ { 9770, -2286, -5663, 4233 },
+ { 8490, -4, -7048, 4496 },
+ { 7697, -1209, -5328, 3183 },
+ { 6451, 801, -4324, -554 },
+ { 7387, 1806, -5265, 545 },
+ { 7450, -2302, -4445, 1418 },
+ { 8817, -1370, -5827, 2168 },
+ { 10324, -2406, -5629, 2579 },
+ { 8863, -2578, -3537, 467 },
+ { 6901, -1624, -3169, 3392 },
+ { 7846, 156, -6948, 3381 },
+ { 7928, -1115, -5972, 4816 },
+ { 6089, -599, -4368, -320 },
+ { 7833, 1246, -3960, -621 },
+ { 8931, 2521, -6768, 2052 },
+ { 8900, 1944, -4126, 40 },
+ { 7661, -34, -2855, 2480 },
+ { 5873, 474, -3262, 3712 },
+ { 7535, -234, -4699, 216 },
+ { 5856, 143, -5142, 73 },
+ { 8944, -106, -5874, 3663 },
+ { 7134, 426, -5879, 2895 },
+ { 10199, 1011, -4762, 369 },
+ { 8454, 264, -5971, 1291 },
+ { 7822, -2449, -4333, 4540 },
+ { 6200, -2758, -2632, 1497 },
+ { 6070, -4315, -2699, 414 },
+ { 7047, -3739, -3210, 1060 },
+ { 5675, -3801, -2717, -407 },
+ { 4789, -4063, -2628, -744 },
+ { 4023, -3366, -3133, -726 },
+ { 4296, -2407, -3381, -513 },
+ { 4388, -2931, -2820, 1512 },
+ { 4559, -4233, -1941, 1976 },
+ { 6702, -3208, -1755, 1680 },
+ { 4416, -3521, -1052, 2984 },
+ { 7154, -4266, -1203, 3732 },
+ { 3625, -4242, -3244, 1395 },
+ { 6518, -2856, -1304, 2887 },
+ { 6170, -1949, -3014, 3973 },
+ { 5189, -2451, -4020, 3477 },
+ { 6218, -2988, -1921, 3844 },
+ { 4827, -3688, -1928, 3343 },
+ { 6668, -3991, -2805, 3095 },
+ { 5297, -3115, -3684, 2390 },
+ { 5354, -4614, -2662, 1504 },
+ { 4196, -3091, -4147, 1135 },
+ { 3540, -2893, -4007, 100 },
+ { 5569, -1602, -4007, 1909 },
+ { 4341, -2091, -4272, 252 },
+ { 5559, -2878, -3832, 498 },
+ { 4548, -4479, -2898, -27 },
+ { 5176, -2494, -4635, 1476 },
+ { 3294, -3485, -3738, 716 },
+ { 4920, -1229, -4195, -365 },
+ { 3257, -3518, -3349, 2862 },
+ { 5286, -1948, -3485, -778 },
+ { 6502, -3051, -152, 2854 },
+ { 5864, -4192, -1076, 3451 },
+ { 4656, -3122, -3448, 179 },
+ { 5907, -754, -1596, 3116 },
+ { 7229, -3680, -1590, 2892 },
+ { 5107, -3888, -3364, 806 },
+ { 6764, -2635, -3450, 134 },
+ { 5258, -2827, -2844, -1052 },
+ { 5798, -1725, -4305, 205 },
+ { 5404, -1213, -3362, 449 },
+ { 6224, -2738, -3046, -581 },
+ { 4223, -2438, -2725, 3745 },
+ { 4751, -3411, -2123, 116 },
+ { 3868, -3000, -3954, 2297 },
+ { 6819, -2899, -4277, 2825 },
+ { 4207, -4754, -2808, 865 },
+ { 4804, -1494, -1997, 4688 },
+ { 5282, -2213, -548, 3559 },
+ { 5580, -1912, -566, 4370 },
+ { 6168, -2857, -672, 4053 },
+ { 6583, -4515, -2850, 1670 },
+ { 6511, -3093, -3988, 1421 },
+ { 4646, -1790, -1443, 3650 },
+ { 5915, -924, -2020, 896 },
+ { 7814, -4181, -3152, 2007 },
+ { 6190, -2238, -4817, 2279 },
+ { 4737, -4034, -3288, 1835 },
+ { 8161, -3633, -3423, 3137 },
+ { 7415, -2351, -2088, 4290 },
+ { 4106, -2517, -62, 2905 },
+ { 4909, -3145, -614, 4112 },
+ { 4938, -3281, -397, 1100 },
+ { -173, 919, 1589, -5363 },
+ { -13, 796, -295, -6655 },
+ { -1860, -829, 1141, -4555 },
+ { 2298, -838, -664, -5005 },
+ { -884, -1097, 2074, -4613 },
+ { -101, 281, 2846, -4535 },
+ { 1166, 453, 2429, -5910 },
+ { 879, -664, 2370, -5452 },
+ { 1415, -370, -1699, -4727 },
+ { -1413, 1277, -669, -6649 },
+ { 2133, 304, -968, -4624 },
+ { 380, 586, -2087, -4892 },
+ { 1336, 275, -82, -5789 },
+ { -2459, 1057, -34, -5416 },
+ { 2278, -1758, 866, -5653 },
+ { 1945, -2295, -149, -5302 },
+ { 1287, -3525, 996, -5255 },
+ { 2297, 803, 1177, -6067 },
+ { 187, -180, -619, -6202 },
+ { -793, -2537, 1554, -5057 },
+ { -2703, -204, -629, -5853 },
+ { -1007, -146, 313, -5582 },
+ { 830, 357, 869, -6363 },
+ { -228, -575, -3177, -4433 },
+ { -1001, -1553, -142, -5708 },
+ { -1644, 1683, 1721, -4533 },
+ { 893, 1924, -15, -5791 },
+ { 2195, 2061, -262, -5471 },
+ { 3031, 270, 311, -5096 },
+ { 1912, 1638, -1523, -4677 },
+ { -3142, -55, 253, -4914 },
+ { 356, -1680, 343, -6123 },
+ { -2241, -1734, -976, -5939 },
+ { -2196, -2893, 547, -4938 },
+ { -1245, 126, -1916, -5419 },
+ { -249, -3755, -1422, -5594 },
+ { 575, -2683, -1926, -4566 },
+ { -762, 1885, 192, -5880 },
+ { -811, -2562, -1068, -6013 },
+ { -2264, -3086, -976, -4775 },
+ { 70, -1215, 2880, -4410 },
+ { 714, -3760, 2916, -4691 },
+ { -244, -3404, 1740, -4493 },
+ { 684, -5137, -328, -5608 },
+ { -529, -3825, -1786, -4535 },
+ { -713, -4743, -1118, -5546 },
+ { 2718, -3788, 1798, -5708 },
+ { -1639, -3679, -1564, -6095 },
+ { 1693, -2642, -1389, -4539 },
+ { 505, -1573, -1651, -4878 },
+ { -835, -2256, -1941, -5352 },
+ { 1464, -411, 1993, -6441 },
+ { 493, -3184, -145, -6148 },
+ { -1413, 499, -1617, -6479 },
+ { -294, 1722, -1419, -5725 },
+ { -2937, -1528, -175, -4624 },
+ { -594, -5911, -56, -6146 },
+ { -300, -4275, 1156, -5947 },
+ { 552, -2643, 2669, -3959 },
+ { 905, -4158, 1789, -5809 },
+ { 1336, -2009, 2108, -5903 },
+ { 1555, -3600, 1110, -6759 },
+ { -1294, -3464, 77, -6084 },
+ { -1139, -4006, -1270, -4181 },
+ { -5094, -3296, 1092, -2847 },
+ { -5503, -2883, 1984, -2067 },
+ { -4671, -4218, -1417, -4132 },
+ { -3763, -3818, 1262, -3082 },
+ { -5132, -3430, 2928, -728 },
+ { -5957, -2877, 1251, -2446 },
+ { -4425, -2319, -212, -4276 },
+ { -6201, -1993, 1774, -2182 },
+ { -5500, -3836, 2201, -1396 },
+ { -6934, -2334, 2366, -1293 },
+ { -6124, -4140, 1337, -1977 },
+ { -6553, -4186, 1756, -1325 },
+ { -5126, -1258, 744, -3656 },
+ { -5167, -1390, 1581, -2895 },
+ { -4525, -3398, 2429, -1865 },
+ { -4076, -3183, 2027, -2510 },
+ { -6191, -3274, 1838, -1814 },
+ { -4454, -2753, 2723, -1185 },
+ { -6655, -4797, 251, -2595 },
+ { -6332, -2232, 1832, 217 },
+ { -5869, -1698, 134, 340 },
+ { -6614, -1045, 2126, -1932 },
+ { -4859, -2107, 2010, -2435 },
+ { -6274, -1622, 2808, -1374 },
+ { -3119, -3209, 521, -3988 },
+ { -5676, -2082, -420, -2711 },
+ { -7073, -3623, 696, -2343 },
+ { -5986, -4224, 572, -2454 },
+ { -4340, -4521, 882, -2771 },
+ { -6178, -1933, 535, -1444 },
+ { -4923, -4163, 1744, -2066 },
+ { -6410, -1519, 1058, -2683 },
+ { -5077, -1185, 856, -2216 },
+ { -7091, -2444, 687, -2597 },
+ { -5284, -2165, 3239, -993 },
+ { -4763, -1497, 197, -3179 },
+ { -4128, -4958, -396, -3578 },
+ { -5054, -3878, -647, -2672 },
+ { -7005, -3348, 1679, -1579 },
+ { -5767, -1017, 2582, -1915 },
+ { -7069, -2787, 1331, -2070 },
+ { -5532, -2296, 706, -2950 },
+ { -5059, -3543, -821, -3637 },
+ { -6639, -1835, 1016, -696 },
+ { -5611, -5220, -694, -3371 },
+ { -5994, -2803, 2933, -729 },
+ { -5948, -619, 1596, -2676 },
+ { -5486, -4419, 153, -3265 },
+ { -4329, -3440, 1646, -1439 },
+ { -4083, -3978, 177, -3569 },
+ { -4289, -2599, 1224, -3075 },
+ { -5707, -3253, 1912, -759 },
+ { -6606, -3437, 2562, -571 },
+ { -5254, -2444, 769, -352 },
+ { -6545, -3154, 582, -1103 },
+ { -5328, -2241, 2566, -1775 },
+ { -7216, -1936, 1538, -1983 },
+ { -3730, -2451, 426, -3869 },
+ { -5110, -1385, 2031, -1169 },
+ { -6470, -2715, 269, -3123 },
+ { -5806, -2480, -97, -3832 },
+ { -3683, -4916, -490, -4330 },
+ { -6341, -2083, -669, -115 },
+ { -4913, -4079, -837, -4673 },
+ { -3274, -2497, 2334, -2652 },
+ { -1286, -1731, 2550, -3756 },
+ { -3375, -877, 926, -3977 },
+ { -2525, -2079, 2879, -2625 },
+ { -5308, -504, 3111, -1607 },
+ { -4904, 460, 4093, -1232 },
+ { -1993, 1616, 4656, -1913 },
+ { -3481, -1176, 3119, -2236 },
+ { -4132, -1502, 2339, -2545 },
+ { -2542, 1151, 3569, -2550 },
+ { -4381, 430, 3147, -2082 },
+ { -3888, 867, 3899, -1657 },
+ { -2861, 1290, 4202, -1979 },
+ { -3893, -253, 2363, -2764 },
+ { -1705, 688, 3827, -2923 },
+ { -2223, 2312, 3700, -3148 },
+ { -1986, -720, 5021, -795 },
+ { -3177, 242, 1952, -3352 },
+ { -1854, 1509, 2528, -3815 },
+ { -3173, 97, 5019, -706 },
+ { -2689, -145, 1375, -3915 },
+ { -4838, -385, 2488, -2427 },
+ { -4557, -355, 1603, -3060 },
+ { -3522, 1832, 3292, -2674 },
+ { -3769, 780, 2378, -2704 },
+ { -4323, -1932, 3414, -1169 },
+ { -2740, 1158, 2729, -3273 },
+ { -3647, 210, 1464, -2892 },
+ { -2342, -2097, 1513, -3727 },
+ { -4422, -1242, 3130, -1833 },
+ { -1308, -1039, 4290, -1875 },
+ { -1754, -2535, 3298, -2314 },
+ { -4102, -186, 4037, -1094 },
+ { -1008, 1570, 3290, 171 },
+ { -3322, -2621, 2791, -1536 },
+ { -2539, -2597, 3442, -1672 },
+ { -3411, -2015, 3670, -1174 },
+ { -2097, 730, 5581, -1399 },
+ { -1510, -74, 4820, -2004 },
+ { -4086, -868, 4425, -771 },
+ { -956, -986, 3640, -2925 },
+ { -2087, -1250, 3464, -2458 },
+ { -3308, -2411, 1334, -3667 },
+ { -2264, -389, 4004, -1854 },
+ { -680, 239, 4058, -3388 },
+ { -1357, 30, 2993, -3658 },
+ { -3601, -552, 1177, -1136 },
+ { -2641, 442, 4374, -1625 },
+ { -2525, 770, 1640, -3895 },
+ { -3172, -891, 3893, -1608 },
+ { -2996, 13, 3277, -2414 },
+ { -899, 1055, 4470, -2501 },
+ { -422, -584, 3475, -3787 },
+ { -1978, -593, 2566, -3415 },
+ { -3150, -1280, 2362, -3047 },
+ { -3592, 224, 1026, -3932 },
+ { -4840, -1189, 3633, -879 },
+ { -3952, -2255, 2916, -1826 },
+ { -1695, 28, 1810, -349 },
+ { -745, -2484, 3308, -3293 },
+ { -1016, 1563, 5365, -1823 },
+ { -2172, -1787, 4266, -1287 },
+ { -1241, -1951, 3982, -2413 },
+ { -2009, -2639, 2330, -3480 },
+ { 5105, -1618, -2588, -2015 },
+ { 6497, -1523, -3218, -910 },
+ { 6526, -2305, -2029, -1790 },
+ { 5289, -99, -3436, -400 },
+ { 5781, -1623, -1577, -2617 },
+ { 5259, -670, -3125, -1700 },
+ { 6343, -1256, -331, -3222 },
+ { 7967, -678, -2195, -1462 },
+ { 6119, -695, -2988, -1538 },
+ { 6108, 494, -3359, -1548 },
+ { 5067, 969, -2328, -2707 },
+ { 7595, -435, -1497, -2056 },
+ { 6929, -719, -2420, -1665 },
+ { 5190, 584, -2982, -2103 },
+ { 6106, -444, -1411, -2739 },
+ { 5584, 289, -1804, -2803 },
+ { 5276, 227, -1180, -3361 },
+ { 7544, -1525, -1834, -1725 },
+ { 5986, -1470, -2606, -1701 },
+ { 5096, -765, -1712, -3006 },
+ { 5423, -149, -3933, -1157 },
+ { 7651, 26, -2445, -1507 },
+ { 4745, -464, -1735, -2362 },
+ { 5352, -1011, -1094, -1999 },
+ { 6300, -672, -542, -1950 },
+ { 6675, -1020, -1318, -1059 },
+ { 7218, -2036, -603, -2462 },
+ { 7755, -1514, -2430, -1229 },
+ { 5041, 449, -1056, -2405 },
+ { 6710, -2277, -1344, -2284 },
+ { 6824, -1347, -2254, 251 },
+ { 6068, -1857, -983, -1316 },
+ { 5603, -2177, -2730, -1477 },
+ { 5838, -1059, -3604, -970 },
+ { 5076, -789, -335, -2413 },
+ { 6191, -1634, -2000, -2129 },
+ { 5092, -1292, -2543, -1034 },
+ { 5305, 435, -1710, -1850 },
+ { 6140, 561, -2176, -2380 },
+ { 6752, 348, -2496, -1890 },
+ { 6405, 273, -1098, -2778 },
+ { 6942, -1340, -496, -1381 },
+ { 5238, -687, -2454, -2349 },
+ { 6959, -882, -1833, -2061 },
+ { 6292, -253, -2125, -2199 },
+ { 5838, -574, -759, -3215 },
+ { 6954, -1484, -640, -2771 },
+ { 7498, -1706, -1210, -2154 },
+ { 6772, -1003, -1235, -2532 },
+ { 6014, 228, -2154, -1108 },
+ { 6943, -2178, -2644, -1122 },
+ { 7262, -763, -3056, -1090 },
+ { 6273, -1478, -1072, 177 },
+ { 4734, 425, -2912, 357 },
+ { 7129, 168, -1537, -2327 },
+ { 7204, -434, -746, -2660 },
+ { 6879, 57, -3087, -1310 },
+ { 4623, -610, -718, -3459 },
+ { 6565, -543, -1998, -339 },
+ { 4752, -277, -2066, -1405 },
+ { 7435, -1416, -1904, -505 },
+ { 4076, 150, -1222, -3556 },
+ { 7082, -28, -1456, -1174 },
+ { 5941, -446, -1326, -1158 },
+ { 3870, -1648, -2474, -2589 },
+ { 858, 37, -3387, -3721 },
+ { 3557, -1503, -1664, -3383 },
+ { 3336, -1972, -3079, -2216 },
+ { 3186, 60, -4185, -863 },
+ { 3456, -773, -3066, -2457 },
+ { 4131, -913, -2060, -2601 },
+ { 4431, -691, -4114, -972 },
+ { 3461, -334, -3680, -1751 },
+ { 2006, -459, -2214, -3827 },
+ { 1322, 32, -2816, -3203 },
+ { 4425, -1897, -2791, -1946 },
+ { 4504, 23, -3421, -1909 },
+ { 3090, -885, -2366, -3264 },
+ { 3209, -2363, -3730, -834 },
+ { 3312, -1471, -3641, -1579 },
+ { 4184, -1669, -3323, -1248 },
+ { 2190, -931, -3302, -2944 },
+ { 2947, -229, -4791, -1195 },
+ { 2020, -1626, -2700, -3125 },
+ { 2214, -326, -4352, -1683 },
+ { 3286, -2619, -2412, -2458 },
+ { 1000, -2571, -4129, -2158 },
+ { 2496, -2627, -3611, -1433 },
+ { 2043, -2191, -2167, -3827 },
+ { 2571, -2544, -1915, -3222 },
+ { 2022, -1501, -3856, -2165 },
+ { 2685, -1180, -1461, -4038 },
+ { 1610, -2313, -4391, -1173 },
+ { 2340, -2490, -4215, -516 },
+ { 1742, -2615, -3632, -2146 },
+ { 523, -1293, -4246, -2442 },
+ { 3725, -2723, -3014, -1576 },
+ { 3554, -1381, -4200, -824 },
+ { 1291, -1594, -4777, -1430 },
+ { 1452, 515, -2960, -3830 },
+ { 4264, -894, -3305, -1826 },
+ { 2606, -1452, -4522, -966 },
+ { 1196, -830, -4807, -1816 },
+ { 1054, -775, -2616, -4071 },
+ { 4206, 415, -4344, -1132 },
+ { 3044, 491, -4126, -1934 },
+ { 988, -901, -3353, -3443 },
+ { 1729, -3063, -2267, -3370 },
+ { 3915, 912, -2989, -2387 },
+ { 3781, 300, -2457, -3050 },
+ { 2712, 924, -1350, -1206 },
+ { 4230, 405, -2343, 665 },
+ { 1878, -873, -225, -29 },
+ { 3510, 56, -1334, -3420 },
+ { 2850, 1447, -2651, -3150 },
+ { 1510, -706, -4125, -2483 },
+ { 3115, 793, -1692, -3894 },
+ { 2667, 213, -2973, -2786 },
+ { 1184, -2384, -3051, -3173 },
+ { 2139, 796, -2079, -3697 },
+ { 1464, -1483, -3726, -2754 },
+ { 2407, -1148, -3915, -1569 },
+ { 2612, -1779, -3217, -2271 },
+ { 2406, -2870, -2937, -2496 },
+ { 2140, 126, -3646, -2758 },
+ { 2952, -1036, 268, -1423 },
+ { 93, -1931, -3841, -3535 },
+ { 389, -2953, -3383, -3343 },
+ { 8652, -5511, -1662, 565 },
+ { 7427, -2791, -2535, -842 },
+ { 8541, -4253, -1407, -988 },
+ { 8018, -3203, -2998, 105 },
+ { 7231, -3926, -958, 1308 },
+ { 7331, -3690, -363, 2586 },
+ { 6803, -3646, -2226, -903 },
+ { 8163, -2811, -477, -2235 },
+ { 9356, -3818, -1685, -684 },
+ { 8466, -2854, -302, -698 },
+ { 8458, -3224, 517, 279 },
+ { 8074, -2619, -1326, 2596 },
+ { 8779, -2761, -2527, -441 },
+ { 6533, -2887, -899, -696 },
+ { 7394, -2305, -1642, -120 },
+ { 8281, -3780, -22, 1305 },
+ { 9158, -4413, -779, 901 },
+ { 9031, -5240, -1109, 1678 },
+ { 8717, -3650, 410, -1075 },
+ { 7317, -3197, -818, -2264 },
+ { 7934, -2385, -1214, -1886 },
+ { 8256, -4441, -291, -587 },
+ { 7358, -3395, 1090, -270 },
+ { 9446, -4910, -1343, -473 },
+ { 8187, -4726, -808, 1166 },
+ { 7504, -3845, -47, 267 },
+ { 8029, -2146, -1283, -383 },
+ { 7461, -2705, -853, 783 },
+ { 9367, -3636, -645, -354 },
+ { 8955, -3473, -308, -1947 },
+ { 8676, -2683, -2099, 1485 },
+ { 7481, -3003, -871, -444 },
+ { 8015, -2839, -1673, 1175 },
+ { 6947, -4643, -1527, -1047 },
+ { 7622, -2575, -137, -960 },
+ { 9388, -4279, -707, -1322 },
+ { 8382, -5259, -1283, -565 },
+ { 6856, -4138, -1030, 630 },
+ { 8659, -2571, -1124, -1666 },
+ { 8763, -3807, -537, 2543 },
+ { 8049, -3578, -2186, -604 },
+ { 8272, -2351, -1985, -1214 },
+ { 6855, -3796, -1527, -1631 },
+ { 7178, -2896, -1600, -1756 },
+ { 7040, -2888, -89, -1586 },
+ { 6261, -3403, -264, 998 },
+ { 7756, -4699, -1543, -834 },
+ { 7682, -4622, -758, -1721 },
+ { 8839, -4232, -2932, 1959 },
+ { 9363, -4679, -1956, 39 },
+ { 7883, -3616, -1414, -1432 },
+ { 8828, -3188, -1356, -1312 },
+ { 7746, -3987, -121, -2424 },
+ { 9262, -3256, -693, 818 },
+ { 7670, -3420, -148, 3504 },
+ { 7344, -3183, 608, 1595 },
+ { 8976, -4139, -1848, 1304 },
+ { 6708, -4131, 33, -852 },
+ { 7840, -4429, -2275, 79 },
+ { 8980, -3858, -2838, 453 },
+ { 7815, -4604, -2563, 944 },
+ { 8372, -4422, -1783, 3071 },
+ { 8623, -5128, -1754, 2888 },
+ { 7462, -3281, 889, 920 },
+ { 8416, -59, -1320, -1825 },
+ { 7928, -1488, -414, -2499 },
+ { 8110, -977, -1047, -2042 },
+ { 8278, -687, -1597, -1550 },
+ { 7988, -174, -977, -2106 },
+ { 8609, -1547, -1628, -1527 },
+ { 9000, -1798, -946, -1761 },
+ { 8954, -872, -1404, -1594 },
+ { 8939, 466, -748, -1212 },
+ { 9549, -329, -177, -1360 },
+ { 9411, -18, -1126, -1568 },
+ { 8859, -782, -488, -1338 },
+ { 8955, -218, -43, -1209 },
+ { 9131, -69, -453, -1001 },
+ { 9069, -1519, -1091, -1199 },
+ { 9247, -1309, -566, -1146 },
+ { 8528, -1617, -287, -1313 },
+ { 7763, -745, -149, -2040 },
+ { 8294, -343, 257, -2633 },
+ { 10149, -893, -552, -1649 },
+ { 9398, -915, 218, -2042 },
+ { 9703, -1194, -675, -1592 },
+ { 9586, -700, -427, -1710 },
+ { 8930, 497, -1445, -1218 },
+ { 9285, -1323, -163, -1552 },
+ { 8431, -1289, -985, -1404 },
+ { 8965, -655, 653, -1483 },
+ { 9542, -1001, -951, -1128 },
+ { 9205, -647, -37, -882 },
+ { 8603, -56, 514, -1793 },
+ { 9300, -12, -1324, -567 },
+ { 8773, 238, -184, -1456 },
+ { 9941, -1306, -69, -1792 },
+ { 9360, 279, -376, -1919 },
+ { 9180, -285, 95, -2170 },
+ { 9922, -501, -970, -1570 },
+ { 8341, -1493, -856, -2092 },
+ { 8780, -981, -850, -1014 },
+ { 9721, -548, -1504, -1094 },
+ { 9973, -1493, 482, -2105 },
+ { 8707, -333, -1027, -1087 },
+ { 9098, -469, -315, -1723 },
+ { 8879, -1050, -661, -2020 },
+ { 8857, 602, -866, -1918 },
+ { 8945, -1025, -2154, -1071 },
+ { 8484, -1930, -468, -2179 },
+ { 9177, -1903, -224, -2112 },
+ { 8652, -137, -2097, -1214 },
+ { 9063, -973, -1405, -772 },
+ { 9328, -456, 662, -2469 },
+ { 10101, -697, 127, -2113 },
+ { 9685, 811, -2359, -1024 },
+ { 8586, -94, -460, -1982 },
+ { 7924, -141, -509, -2513 },
+ { 7773, -669, -107, -2835 },
+ { 8636, -1064, -46, -2409 },
+ { 9748, 596, -1815, -1349 },
+ { 8924, 304, 547, -2614 },
+ { 9442, 746, -1153, -1679 },
+ { 9454, -278, -529, -1976 },
+ { 8488, 561, -32, -2160 },
+ { 10083, -63, -1544, -1364 },
+ { 9390, -1278, 568, -1131 },
+ { 9740, -49, -2253, -910 },
+ { 3636, -2391, -1115, -3614 },
+ { 6014, -3204, -1902, -1808 },
+ { 5787, -3497, -1116, -2590 },
+ { 4365, -3046, -1632, -2668 },
+ { 4733, -2192, -2029, -2468 },
+ { 5412, -2753, -1633, -2464 },
+ { 4455, -3375, -767, -3399 },
+ { 4456, -1644, -983, -2841 },
+ { 4039, -2523, 38, -3967 },
+ { 3406, -2662, 72, -4757 },
+ { 4279, -2005, 1055, -4399 },
+ { 4321, -1377, -860, -3786 },
+ { 3743, -5739, -651, -3047 },
+ { 3528, -5510, 361, -4060 },
+ { 6496, -4886, -136, -2689 },
+ { 4513, -5254, 551, -4010 },
+ { 6557, -3413, -92, -3063 },
+ { 4186, -2059, 187, 47 },
+ { 6210, -4117, -1256, -1985 },
+ { 6038, -4343, 351, -2124 },
+ { 4305, -4780, -2077, -1897 },
+ { 4480, -3815, -2228, -1533 },
+ { 5582, -3689, 1221, -3429 },
+ { 5532, -4874, 1195, -2765 },
+ { 6518, -2853, -905, -2568 },
+ { 5467, -2192, 470, -4115 },
+ { 4139, -1577, 240, -3493 },
+ { 5281, -1926, -729, -3340 },
+ { 5214, -2870, 1359, -4289 },
+ { 3046, -3510, -1536, -3214 },
+ { 5433, -2881, -1230, -1184 },
+ { 4861, -3932, -1071, -2791 },
+ { 5693, -4234, -1906, -1502 },
+ { 4004, -3935, -1804, -2383 },
+ { 3728, -3792, 681, -4773 },
+ { 3621, -3030, -1951, -2598 },
+ { 5133, -3903, 44, -3700 },
+ { 3561, -3451, 1183, -5301 },
+ { 5026, -2762, -2341, -1780 },
+ { 5841, -2492, -467, -3210 },
+ { 5591, -1791, 497, -2472 },
+ { 5054, -3898, -1822, -2097 },
+ { 5813, -2792, 83, -1469 },
+ { 4432, -4497, 1670, -5193 },
+ { 5338, -4653, -1109, -2200 },
+ { 3239, -4401, -648, -3655 },
+ { 2147, -3598, -1200, -4242 },
+ { 4417, -2271, -1552, -3210 },
+ { 6494, -4360, 852, -3565 },
+ { 2393, -6358, -856, -4524 },
+ { 4959, -4196, -847, -1403 },
+ { 4924, -5438, -226, -3026 },
+ { 4254, -5303, -1306, -2424 },
+ { 4121, -3126, -2334, -1981 },
+ { 3437, -4443, -1464, -2953 },
+ { 3203, -3459, -529, -4339 },
+ { 5896, -5945, 543, -3246 },
+ { 1987, -4733, -220, -4863 },
+ { 4358, -4431, -514, -3081 },
+ { 4583, -2416, -492, -2287 },
+ { 2943, -5035, 419, -4927 },
+ { 5358, -5129, 987, -4309 },
+ { 4460, -3392, 1752, -5634 },
+ { 3415, -4633, 1507, -5945 },
+ { 811, -4692, -445, 2333 },
+ { 1009, -5613, -1857, 1360 },
+ { 1338, -2712, -2720, 3036 },
+ { 1002, -3754, -2582, 2344 },
+ { 750, -4608, -2334, 714 },
+ { 2043, -3207, -2822, 2173 },
+ { -140, -4654, -2953, 357 },
+ { -54, -4026, -2376, 2695 },
+ { 1858, -5022, -717, 2287 },
+ { 2064, -3894, -722, 3255 },
+ { 2727, -4558, -332, 2603 },
+ { 1810, -5378, 283, 1826 },
+ { 3935, -4326, 762, 3383 },
+ { -767, -4697, -2510, 1922 },
+ { 2146, -4312, -3090, 1641 },
+ { 54, -5881, -2114, 921 },
+ { 1992, -5766, -640, 1574 },
+ { 1200, -5371, -1114, 1828 },
+ { 2973, -5337, 34, 2266 },
+ { 1531, -5018, -2817, 1192 },
+ { 3078, -4570, 117, 1990 },
+ { 924, -4286, -1388, 2713 },
+ { 142, -5058, -2848, 1487 },
+ { -106, -6180, -881, 842 },
+ { 673, -5433, -229, 1596 },
+ { 783, -5710, -2784, 562 },
+ { 1935, -5729, -2009, 856 },
+ { -410, -3375, -3326, 2734 },
+ { 234, -3000, -2628, 3260 },
+ { 733, -3405, -3806, 1589 },
+ { 771, -4285, -3544, 1314 },
+ { 1192, -3563, -3960, 2178 },
+ { 206, -5555, -1250, 1546 },
+ { -130, -3815, -1210, 3041 },
+ { 646, -3940, -393, 2992 },
+ { -184, -4931, -1767, 1925 },
+ { 2746, -5120, -2275, 1464 },
+ { 2440, -3731, -3352, 2729 },
+ { -490, -4942, -3779, 997 },
+ { 68, -2636, -4167, 3778 },
+ { 48, -3986, -4118, 2106 },
+ { -978, -5486, -1336, 1390 },
+ { 1126, -5297, -855, 640 },
+ { -472, -3975, -3622, 1557 },
+ { 2456, -5344, -1523, 1648 },
+ { -774, -5652, -2417, 1147 },
+ { 995, -6122, -812, 1132 },
+ { 3282, -4571, -1763, 2175 },
+ { 3655, -3862, -676, 3568 },
+ { 3038, -3647, -1672, 3381 },
+ { 2595, -2964, -2772, 3263 },
+ { 4176, -3353, -1148, 4354 },
+ { 1603, -3442, -1500, 3444 },
+ { 828, -6226, -1783, 678 },
+ { 1421, -3333, -3080, 3403 },
+ { 1121, -4727, -1924, 1984 },
+ { -186, -5083, -682, 1796 },
+ { 819, -2778, -3488, 530 },
+ { 421, -2873, -3832, 2596 },
+ { 2164, -4263, -1605, 2282 },
+ { 585, -4437, -682, -491 },
+ { -644, -4452, -1157, 2325 },
+ { 1991, -4299, 210, 2834 },
+ { 2135, -3632, -2113, 665 },
+ { -7482, -2724, -2662, -1380 },
+ { -6983, -2166, -3756, -3509 },
+ { -7085, -1439, -2397, -3112 },
+ { -7760, -3049, -3319, -2822 },
+ { -8413, -2760, -4406, -3298 },
+ { -5995, -3943, -1260, -3750 },
+ { -7879, -1554, -3464, -2606 },
+ { -6314, -2034, -3878, -1681 },
+ { -8849, -2084, -1399, -1231 },
+ { -7153, -2602, -1384, -817 },
+ { -8041, -2571, -407, -2785 },
+ { -7246, -2233, -1578, 260 },
+ { -7336, -3883, -4061, -1342 },
+ { -7619, -3908, -2342, 382 },
+ { -8684, -3724, -1662, -727 },
+ { -7850, -2922, -1770, -3449 },
+ { -6766, -2034, -1293, -1988 },
+ { -6895, -2116, -968, -3744 },
+ { -7136, -5147, -2618, -2809 },
+ { -8224, -3724, -2519, -1589 },
+ { -6711, -2750, -3021, -219 },
+ { -8059, -1638, -1102, -3175 },
+ { -8710, -4839, -3963, -3143 },
+ { -9363, -4965, -3257, -1002 },
+ { -6099, -1751, -3157, -395 },
+ { -6453, -3216, -4597, -483 },
+ { -7879, -5477, -839, -2638 },
+ { -7202, -4038, -526, -2856 },
+ { -8022, -1228, -1910, -1646 },
+ { -9117, -1393, -1582, -2535 },
+ { -9095, -2693, -636, -2605 },
+ { -9076, -2580, -3481, -2519 },
+ { -8327, -4859, -2422, 83 },
+ { -8368, -2129, -2324, -2173 },
+ { -8554, -4563, -3842, -2007 },
+ { -10462, -4261, -1934, -2084 },
+ { -9717, -3187, -2294, -1896 },
+ { -9625, -3889, -3020, -3224 },
+ { -9857, -4955, -4239, -2184 },
+ { -9752, -2351, -2277, -3129 },
+ { -7219, -1302, -2639, -1603 },
+ { -7477, -4360, -3718, -559 },
+ { -5680, -2033, -2326, -3078 },
+ { -10190, -5548, -4643, -3601 },
+ { -9431, -4121, -879, -2479 },
+ { -8365, -5450, -2020, -1439 },
+ { -6289, -5178, -1605, -3845 },
+ { -8319, -3866, -687, -2792 },
+ { -8131, -1031, -3608, -3947 },
+ { -10510, -2560, -1199, -2082 },
+ { -11015, -3640, -2748, -3041 },
+ { -8762, -5022, -5231, -1162 },
+ { -10153, -2715, -4648, -4859 },
+ { -7930, -5205, -1900, -3600 },
+ { -9561, -3548, -4812, -3722 },
+ { -7663, -4709, -1180, -1475 },
+ { -9073, -5707, -1815, -2980 },
+ { -8602, -2363, -2675, -3770 },
+ { -9967, -5614, -3575, -3838 },
+ { -8324, -1005, -2131, -3254 },
+ { -10331, -5737, -2550, -2940 },
+ { -8234, -3354, -3361, -4479 },
+ { -8140, -1951, -4526, -4545 },
+ { -6679, -2662, -2284, -4182 },
+ { -1122, -1514, -6427, -212 },
+ { 54, -1660, -5424, -1404 },
+ { 254, -2778, -5222, 846 },
+ { -267, -1661, -6577, 814 },
+ { -305, -2021, -5759, 1484 },
+ { -1791, -2446, -6867, -86 },
+ { -2929, -3158, -6603, -1799 },
+ { -1391, -3189, -5557, -1053 },
+ { -1602, -884, -6767, -1213 },
+ { -361, -318, -6219, -44 },
+ { -4078, -2635, -5523, -433 },
+ { -956, 478, -4382, 1470 },
+ { -3300, -2462, -6021, -2721 },
+ { 708, -2434, -5085, -540 },
+ { -2435, -3607, -5647, -2110 },
+ { -491, -1134, -4681, -2886 },
+ { 87, -3435, -4641, -1194 },
+ { -586, -2927, -4784, 366 },
+ { -1394, -2326, -6021, 350 },
+ { 97, -2519, -4678, -2120 },
+ { -1547, -1907, -5069, -2993 },
+ { 268, -3724, -4719, 127 },
+ { -827, -1190, -5912, 1144 },
+ { -3959, -2322, -6898, -1974 },
+ { -2728, -2228, -6426, -562 },
+ { -456, -666, -5785, -1609 },
+ { 531, -1096, -5731, -656 },
+ { -3569, -688, -3915, 110 },
+ { -4752, -1725, -4393, -377 },
+ { -3210, -3315, -6960, -840 },
+ { -688, -3416, -4971, 1221 },
+ { -1833, 77, -6491, -2434 },
+ { -239, -255, -6850, -886 },
+ { -2112, -1490, -6291, -2689 },
+ { -1544, -4579, -5198, -1261 },
+ { -2771, -4014, -5520, 683 },
+ { -1635, -2829, -5512, 1214 },
+ { -958, -2582, -4823, 2360 },
+ { -2077, -4566, -4642, 365 },
+ { -3112, -4214, -5960, -823 },
+ { -2467, -2510, -4858, 1467 },
+ { -1561, -3399, -5822, 211 },
+ { -775, -1081, -4424, 2636 },
+ { -1263, 25, -6378, -1392 },
+ { -3476, -366, -5417, -1393 },
+ { -3176, -1476, -4149, 1466 },
+ { -2479, 518, -4448, -257 },
+ { -2992, 158, -4660, -1279 },
+ { -1320, -3872, -4479, 1147 },
+ { -1475, -312, -5318, 539 },
+ { -3527, -1679, -5860, -1681 },
+ { -3397, -3438, -5593, 1866 },
+ { -4089, -2439, -4763, 1275 },
+ { -748, -4513, -4687, -48 },
+ { -2166, -4531, -4691, -2856 },
+ { -2385, -853, -6035, -627 },
+ { -1194, -4091, -4472, -1963 },
+ { -682, -3234, -4084, -3033 },
+ { -3255, -5015, -5328, -12 },
+ { -2313, -3436, -4601, -155 },
+ { -2792, -1038, -6947, -2019 },
+ { -1244, -1526, -5771, -1882 },
+ { -4679, -3731, -5506, 283 },
+ { -3062, -66, -3558, -758 },
+ { -4895, -1187, 4751, 3728 },
+ { -7600, -2752, 3320, 4613 },
+ { -5703, -2975, 3944, 2659 },
+ { -4972, -1257, -246, 2952 },
+ { -4221, -2487, 1702, 4295 },
+ { -2900, -1529, 2458, 4935 },
+ { -5061, 407, 2416, 4050 },
+ { -6931, -3478, 2761, 2213 },
+ { -6037, -3921, 3192, 1866 },
+ { -6113, -811, 2407, 3782 },
+ { -5878, -1716, 1207, 3478 },
+ { -5953, -2853, 2207, 2712 },
+ { -6807, -3223, 2749, 3595 },
+ { -3272, -3157, 1389, 3788 },
+ { -5368, -1904, 1980, 5077 },
+ { -7235, -1398, 3075, 4548 },
+ { -4765, -3487, 2755, 2796 },
+ { -7658, -4435, 2694, 2582 },
+ { -6997, -4282, 456, 3832 },
+ { -5563, -3115, -63, 3713 },
+ { -4244, -4220, 1450, 2767 },
+ { -3801, -2194, 190, 4303 },
+ { -5458, -4119, 1958, 2274 },
+ { -7300, -3469, 3514, 3193 },
+ { -4594, -2067, 775, 4752 },
+ { -3389, -1654, 1464, 5412 },
+ { -4845, -3483, 964, 3437 },
+ { -6007, -2818, 1666, 4659 },
+ { -8709, -5007, 1757, 3287 },
+ { -5833, -4389, 1025, 3171 },
+ { -5788, -1780, 3944, 3661 },
+ { -4430, -920, 1938, 4753 },
+ { -7066, -1857, 4591, 4538 },
+ { -3549, -513, 1427, 5317 },
+ { -7517, -1220, 2883, 3049 },
+ { -7605, -2687, 1874, 2735 },
+ { -8718, -4035, 2676, 3730 },
+ { -7990, -3907, 1185, 2607 },
+ { -6058, -1744, 3349, 5157 },
+ { -5954, 565, 3161, 3250 },
+ { -6478, -612, 1930, 2271 },
+ { -6535, -1445, -2, 1618 },
+ { -8963, -4151, 1192, 4044 },
+ { -7227, -3570, 1600, 4234 },
+ { -4674, 79, 595, 3015 },
+ { -3974, 430, 2727, 5137 },
+ { -5299, 9, 3714, 4779 },
+ { -6779, -2699, -8, 2436 },
+ { -7016, -1145, 1293, 2310 },
+ { -6955, -3312, 1534, 1801 },
+ { -4025, 740, 1850, 4054 },
+ { -9589, -3460, 4154, 5270 },
+ { -4404, -1181, 4298, 5173 },
+ { -7356, -4583, -18, 2644 },
+ { -6516, -1235, 4439, 6234 },
+ { -3453, -301, 4344, 4464 },
+ { -4643, 1530, 3315, 4340 },
+ { -4575, -2557, 3754, 3682 },
+ { -3643, -3501, 2051, 2997 },
+ { -5412, -2475, 2301, 1579 },
+ { -5846, 259, 1360, 2348 },
+ { -5258, -1358, 1050, 838 },
+ { -5542, -219, 6377, 5750 },
+ { -5713, -2952, 922, 899 },
+ { -2049, -1135, 5206, 1033 },
+ { -1693, -1886, 4835, -106 },
+ { -2344, -3504, 4232, -13 },
+ { -2475, -2334, 5043, 1126 },
+ { -787, -2549, 3880, 2138 },
+ { -3159, -2341, 4830, 2887 },
+ { -1780, -1009, 6240, 2061 },
+ { -4327, -3363, 2818, 886 },
+ { -3376, -2743, 4104, 207 },
+ { -3250, -4640, 2718, 1498 },
+ { -382, -1075, 4382, 3460 },
+ { -2416, -4168, 3530, 816 },
+ { -1756, -2708, 4861, 622 },
+ { -1879, -2097, 5156, 2889 },
+ { -2496, -2418, 3722, 2671 },
+ { -2717, -3252, 3341, 1944 },
+ { -4063, -4091, 3306, 267 },
+ { -3549, -3808, 3747, 842 },
+ { -2635, 546, 5794, 1894 },
+ { -1857, -1121, 4383, 3964 },
+ { -2226, -2166, 3489, 3678 },
+ { -3492, -660, 5323, 1063 },
+ { -3033, -3130, 4382, 1828 },
+ { -2703, -625, 6369, 2851 },
+ { -1656, -2842, 4584, -528 },
+ { -4781, -2622, 4390, 2097 },
+ { -413, -2045, 5081, 3035 },
+ { -3810, -2662, 4532, 1095 },
+ { -3144, -1858, 5215, 1880 },
+ { -3562, -1795, 4928, 670 },
+ { -4800, -1509, 5189, 1859 },
+ { -1085, -3832, 4169, 900 },
+ { -1969, -3270, 2857, 2878 },
+ { -4267, -4140, 3176, 1805 },
+ { -5145, -3727, 3524, 1168 },
+ { -1346, -1876, 5501, 1748 },
+ { -4998, -2945, 3699, 338 },
+ { -3458, -3096, 3406, -635 },
+ { -1751, -3209, 3508, 395 },
+ { -2507, 170, 5987, 705 },
+ { -3756, -1072, 5647, 3536 },
+ { -2870, -1439, 5026, 3212 },
+ { -3913, -3225, 3669, 2144 },
+ { -3739, 226, 5747, 764 },
+ { -2052, -820, 5266, 3093 },
+ { -3214, -3820, 2409, 2391 },
+ { -4398, -2588, 3501, -218 },
+ { -4484, -1763, 4180, -198 },
+ { -3368, -1525, 4362, -134 },
+ { -2407, 224, 4905, 3533 },
+ { -1369, -2937, 4728, 1788 },
+ { -4848, -1707, 4159, 851 },
+ { -3454, -1749, 4281, 3230 },
+ { -1990, -3853, 3487, 1735 },
+ { -3117, 92, 6155, 4075 },
+ { -2676, -2472, 4078, -589 },
+ { -1547, -2012, 2626, 1835 },
+ { -4275, -588, 4824, 725 },
+ { -601, -2249, 3736, 3548 },
+ { -4060, -61, 5333, 3097 },
+ { -4303, 7, 6551, 3054 },
+ { -5003, -1029, 5786, 3319 },
+ { -2810, -728, 5392, 199 },
+ { -1232, -200, 5228, 3121 },
+ { 2621, 165, -6255, 298 },
+ { 3669, 537, -6844, 1564 },
+ { 1598, -1190, -6235, 2523 },
+ { 2164, -32, -6894, 1383 },
+ { 853, -1597, -6069, 1449 },
+ { 1377, -1661, -5266, 108 },
+ { 2660, 48, -5172, -517 },
+ { 1903, -391, -5677, 1010 },
+ { 3792, 206, -5274, -11 },
+ { 1239, 2776, -2929, 2721 },
+ { 4071, 149, -7259, 3125 },
+ { 1436, -480, -6156, -196 },
+ { 1373, -1960, -5005, 3122 },
+ { 3413, -1271, -5176, 3283 },
+ { 3060, -68, -6495, 2238 },
+ { 2700, -2075, -4681, 91 },
+ { 2928, -1728, -5168, 1858 },
+ { 4424, 828, -4471, 88 },
+ { 2672, -2604, -4038, 2753 },
+ { 5223, -123, -6749, 2295 },
+ { 4237, -420, -5538, 1353 },
+ { 4744, -1281, -4097, 4708 },
+ { 1103, -2764, -4751, 2024 },
+ { 3747, -1913, -3911, 3960 },
+ { 2470, -1416, -5542, 615 },
+ { 4847, -1354, -5334, 1733 },
+ { 5336, 88, -7593, 4007 },
+ { 2388, -2880, -4807, 1037 },
+ { 4495, 1391, -5685, -139 },
+ { 5253, 1637, -6450, 1533 },
+ { 1199, 795, -5515, 1261 },
+ { 1397, -1259, -4252, 3838 },
+ { 746, 70, -6640, 604 },
+ { 1584, 166, -4972, 3072 },
+ { 380, -999, -5397, 2267 },
+ { 2974, 1707, -3242, 5360 },
+ { 5202, -403, -5453, 2832 },
+ { 3718, -1731, -4760, 714 },
+ { 4150, -975, -4792, 61 },
+ { 2925, -818, -4841, 15 },
+ { 5301, 577, -4006, 3259 },
+ { 5265, 1986, -5679, 3028 },
+ { 3752, 1928, -4509, 3729 },
+ { 3278, 1925, -6370, 1247 },
+ { 5107, 1721, -4853, 3127 },
+ { 3279, 2982, -2515, 4005 },
+ { 4622, 668, -6204, 759 },
+ { 6034, 317, -5763, 4818 },
+ { -558, 57, -3785, 2817 },
+ { 4476, 1616, -3965, 4536 },
+ { 5953, 2056, -8215, 2715 },
+ { 4387, 2613, -7463, 868 },
+ { 5834, 1088, -4736, 4924 },
+ { 6473, -856, -6991, 4172 },
+ { 4959, -293, -5162, 76 },
+ { 2731, -843, -6119, 3847 },
+ { 3245, 1202, -6833, 616 },
+ { 2553, 1383, -3829, 3859 },
+ { 4332, 2099, -3480, 3622 },
+ { 2110, 2683, -2728, 3990 },
+ { 876, 1167, -3290, 3466 },
+ { 3991, 1709, -2410, 4077 },
+ { 5105, 939, -2584, 3256 },
+ { 4719, 688, -1566, 3040 },
+ { -3632, 4335, 1266, -3303 },
+ { -4956, 3207, 1312, -2806 },
+ { -4669, 2627, 2663, -2435 },
+ { -4282, 3708, 2303, -3038 },
+ { -4536, 2297, -175, -3350 },
+ { -5234, 2503, -139, -880 },
+ { -3978, 1512, 1092, -3619 },
+ { -4519, 4649, 1363, -2455 },
+ { -5118, 3132, 1961, -1577 },
+ { -5196, 3379, -182, -1378 },
+ { -6420, 4486, 2397, -1993 },
+ { -5030, 5046, 1292, -1118 },
+ { -4559, 2573, -927, -1406 },
+ { -3501, 3730, 691, -4930 },
+ { -4364, 2758, 1007, -3909 },
+ { -4026, 2839, -1559, -2340 },
+ { -5037, 4053, 836, -1571 },
+ { -4727, 5136, 1110, -3588 },
+ { -5245, 2799, -999, -2164 },
+ { -4954, 1501, 422, -3963 },
+ { -5994, 2726, 1462, -2833 },
+ { -5621, 5159, 2038, -2512 },
+ { -4991, 2291, 1917, -3151 },
+ { -5469, 4382, -148, -2978 },
+ { -5858, 1983, 807, -2720 },
+ { -4709, 3556, 952, -467 },
+ { -2489, 2362, 1714, -4230 },
+ { -4717, 5004, -1180, -3672 },
+ { -5914, 3653, 1359, -1317 },
+ { -5506, 2995, 780, -1059 },
+ { -5287, 3945, 2480, -2293 },
+ { -3849, 4358, 322, -1770 },
+ { -3911, 3570, 252, -3185 },
+ { -3660, 5128, 158, -3719 },
+ { -4599, 3277, -503, -2727 },
+ { -3673, 3760, -1252, -3339 },
+ { -5161, 2337, 388, -1943 },
+ { -3529, 2216, 2156, -3080 },
+ { -4309, 4331, 1808, -1460 },
+ { -4782, 3820, 480, -2504 },
+ { -4166, 3544, -378, -1567 },
+ { -5572, 2466, -418, -2909 },
+ { -6096, 2930, 119, -1878 },
+ { -5963, 3554, 1011, -2233 },
+ { -6433, 4335, 935, -2930 },
+ { -5004, 3314, -1352, -3430 },
+ { -6042, 3463, -1008, -3940 },
+ { -4671, 2214, -640, -5040 },
+ { -2795, 3759, 1412, -3803 },
+ { -3647, 4436, 729, -515 },
+ { -3594, 1033, 56, -4148 },
+ { -2908, 3027, 2889, -3485 },
+ { -3338, 2234, 313, -4285 },
+ { -3825, 4497, -561, -2634 },
+ { -6167, 3012, -48, -3149 },
+ { -4828, 3515, -969, -4475 },
+ { -5789, 2757, -539, -4173 },
+ { -2452, 3067, 564, -4249 },
+ { -4921, 1358, 1331, -2889 },
+ { -3127, 4239, -1045, -1523 },
+ { -4780, 2326, -1118, -3446 },
+ { -3908, 5546, 152, -2622 },
+ { -6972, 2976, 337, -2809 },
+ { -4839, 4613, -35, -4077 },
+ { -1408, 4822, -1149, -4997 },
+ { -981, 4979, -912, -6304 },
+ { -2098, 5689, -888, -2878 },
+ { -3343, 4814, -657, -4434 },
+ { -2461, 3601, -967, -4869 },
+ { -2652, 3944, 87, -5520 },
+ { -1104, 6076, 174, -6407 },
+ { 355, 5370, -1721, -5869 },
+ { 1242, 4497, -1107, -5091 },
+ { -89, 4002, -1491, -5182 },
+ { 1059, 5693, -1591, -4905 },
+ { 1323, 4682, -2078, -4768 },
+ { 818, 3996, -549, -5468 },
+ { -287, 4529, 929, -5543 },
+ { -919, 5519, -2791, -2844 },
+ { -1407, 5679, -3289, -3974 },
+ { -189, 6530, -3547, -4002 },
+ { -900, 7039, -3371, -4855 },
+ { -2983, 7211, -363, -4835 },
+ { -814, 6503, -104, -5106 },
+ { -2386, 6896, 809, -4919 },
+ { 845, 4492, 352, -6621 },
+ { -1998, 7237, -1646, -4231 },
+ { -3380, 6251, 471, -4577 },
+ { -1908, 7059, 84, -5726 },
+ { -340, 6346, -803, -6265 },
+ { -2279, 5834, -47, -4633 },
+ { -1532, 5286, -1748, -1901 },
+ { -2757, 6188, -453, -3415 },
+ { -1255, 6405, -2043, -6357 },
+ { 918, 5581, -121, -5667 },
+ { 1840, 5336, -821, -5034 },
+ { -2475, 4992, -1825, -3104 },
+ { -2413, 5606, -1789, -4298 },
+ { 132, 5128, -2389, -4442 },
+ { 223, 6400, -2653, -4742 },
+ { -673, 5012, 680, -4582 },
+ { -1657, 6624, -349, -3596 },
+ { -755, 6289, -1860, -3978 },
+ { -572, 6894, -1946, -5207 },
+ { -1141, 4756, -2665, -5586 },
+ { -1073, 4269, -431, -4030 },
+ { 186, 5761, 916, -5868 },
+ { -1907, 4836, 1017, -5106 },
+ { -963, 3363, -1248, -6348 },
+ { -3262, 4774, -1818, -5858 },
+ { 847, 3812, -2538, -4302 },
+ { -1223, 5903, 1360, -5479 },
+ { -1094, 6923, -1244, -2381 },
+ { 267, 6276, -709, -2846 },
+ { -157, 5840, 1124, -4266 },
+ { 889, 3206, -910, -5305 },
+ { -1736, 3344, 582, -4838 },
+ { -2357, 5676, -2695, -6277 },
+ { -1916, 6901, -986, -5397 },
+ { -3062, 6028, -695, -5687 },
+ { 1836, 3566, -1357, -5226 },
+ { -2176, 4938, 646, -3872 },
+ { -2199, 3055, -208, -6124 },
+ { -236, 3032, -821, -5325 },
+ { -3989, 7277, -565, -3899 },
+ { -595, 4362, 74, -5975 },
+ { 684, 5874, -841, -4424 },
+ { -2731, 6305, -2389, -5465 },
+ { -5775, 1325, -56, -2528 },
+ { -7029, -534, -1890, -3278 },
+ { -5798, -15, -2734, -2210 },
+ { -5504, -1198, -353, -3659 },
+ { -5079, 960, -894, -4336 },
+ { -6073, -36, -133, -3014 },
+ { -5782, -259, -1025, -3986 },
+ { -6843, 1262, -807, -1639 },
+ { -5263, -918, -3290, -579 },
+ { -4840, 461, -2158, -533 },
+ { -6014, -50, -620, 504 },
+ { -5843, 241, -1359, -282 },
+ { -5898, 577, 769, -3271 },
+ { -6833, -946, -466, -3347 },
+ { -6026, 1459, -512, -729 },
+ { -7361, 747, -388, -1110 },
+ { -6391, 2142, -1160, -2513 },
+ { -6995, 304, 498, -2673 },
+ { -6757, 679, -386, -433 },
+ { -5222, 1688, -1093, -1032 },
+ { -5019, 575, 184, -3627 },
+ { -4237, 628, -3507, -1243 },
+ { -7479, -456, -1722, -1486 },
+ { -6464, 713, -1273, -1153 },
+ { -6255, 1682, -606, -3607 },
+ { -7033, 1497, -71, -1955 },
+ { -6694, 1556, -1721, -3214 },
+ { -6114, -356, 813, -2575 },
+ { -5308, 632, -1851, -1636 },
+ { -5742, -911, -1733, 383 },
+ { -6083, -387, -2313, -879 },
+ { -6535, -530, -1505, -2083 },
+ { -4896, 1223, -2750, -1816 },
+ { -6392, -463, -3247, -2093 },
+ { -5373, 1264, -2706, -3042 },
+ { -3894, -1390, -1020, -891 },
+ { -6179, 1168, -1966, -1922 },
+ { -5162, 1668, -1617, -1916 },
+ { -6453, 920, -1169, -2432 },
+ { -6130, 2005, -536, -1519 },
+ { -6552, -98, -518, -1938 },
+ { -7528, 355, -1101, -1772 },
+ { -5745, 610, -247, -1360 },
+ { -7003, 177, -2064, -1958 },
+ { -6956, -570, -2220, -4225 },
+ { -7830, 791, -1394, -2774 },
+ { -7634, 480, -3171, -4224 },
+ { -7913, 1154, -350, -2381 },
+ { -5063, 1704, -1804, -2977 },
+ { -4887, -524, -2703, 188 },
+ { -5551, 406, -1620, -3063 },
+ { -7109, 1342, 381, -3021 },
+ { -6846, 631, -458, -3398 },
+ { -4606, -605, 11, -3930 },
+ { -8134, -225, -1738, -2648 },
+ { -7043, 402, -2734, -3059 },
+ { -7417, 1825, -2545, -4389 },
+ { -6971, -236, -1031, -665 },
+ { -5752, 2111, -1632, -3808 },
+ { -7660, -78, -624, -3135 },
+ { -6358, 619, -1951, -3911 },
+ { -8134, 408, -1935, -3695 },
+ { -6335, 1911, -2368, -4505 },
+ { -7116, 2163, -344, -2753 },
+ { 2357, 4488, 2220, -5682 },
+ { 1385, 3206, 2300, -5305 },
+ { 1419, 2557, 5203, -3516 },
+ { 262, 4315, 3920, -1847 },
+ { 3316, 3187, 1612, -5609 },
+ { 1729, 2350, 1673, -6068 },
+ { 1603, 6126, 1467, -2839 },
+ { -1339, 3316, 3691, -3530 },
+ { -563, 4618, 3180, -4548 },
+ { 463, 4624, 3111, -5614 },
+ { 1246, 5455, 3356, -5720 },
+ { 480, 2149, 5422, -2893 },
+ { 1768, 4827, 913, -5579 },
+ { -149, 5381, 4366, -3297 },
+ { 985, 3672, 2644, -92 },
+ { -258, 2911, 5817, -2213 },
+ { 3428, 3289, 3351, -3541 },
+ { -666, 3295, 4727, -2869 },
+ { 35, 6641, 4160, -4052 },
+ { 623, 6787, 3156, -4560 },
+ { 2654, 4360, 4676, -4632 },
+ { 1386, 5246, 4834, -4497 },
+ { 3488, 4574, 3856, -5946 },
+ { 383, 4481, 4168, -4110 },
+ { 1753, 3652, 4288, -3326 },
+ { 1344, 4905, 2508, -4660 },
+ { 1580, 4106, 3104, -2224 },
+ { 2027, 5038, 1683, -1554 },
+ { 446, 3699, 5872, -3013 },
+ { 4637, 4087, 3578, -5018 },
+ { 2629, 3560, 5331, -4900 },
+ { 1527, 6674, 2523, -4131 },
+ { -1437, 2804, 2528, -4464 },
+ { -229, 3355, 2016, -5537 },
+ { 3666, 3418, 4374, -4581 },
+ { 1192, 3799, 923, -6596 },
+ { 2040, 2956, 448, -5322 },
+ { 2468, 5768, 4029, -5869 },
+ { 3438, 6516, 3529, -6667 },
+ { 2737, 5495, 680, -5535 },
+ { 3896, 5727, 1801, -4958 },
+ { 4988, 4957, 3592, -6518 },
+ { -542, 4416, 5794, -2787 },
+ { 4136, 4354, 2064, -4696 },
+ { 3067, 5936, 1207, -3396 },
+ { 2789, 4966, 2405, -3854 },
+ { 1731, 3270, 3251, -1063 },
+ { 1767, 5537, 2084, -2349 },
+ { 465, 3116, 4532, -837 },
+ { 1499, 2627, 4610, -2212 },
+ { 122, 3095, 3642, -3552 },
+ { 2542, 2866, 2705, -6402 },
+ { 3134, 4323, 698, -4785 },
+ { 731, 1859, 3112, -5242 },
+ { 2553, 2980, 3241, -4846 },
+ { 1329, 5310, 1607, -6624 },
+ { 2468, 1858, 3476, -1034 },
+ { -172, 4996, 2000, -5562 },
+ { 2621, 4220, 1574, -3386 },
+ { -333, 1832, 3362, -4117 },
+ { 2169, 6762, 3065, -6225 },
+ { 2844, 5528, 3223, -4765 },
+ { 526, 5175, 1644, -4267 },
+ { 2922, 4426, 2414, -2610 },
+ { 452, 1399, -4516, -2636 },
+ { 2872, 1720, -4667, -1435 },
+ { 1279, 702, -5424, -1984 },
+ { 2187, 870, -5021, -1341 },
+ { 583, -144, -4628, -2464 },
+ { 3, 2237, -5284, -2827 },
+ { -19, 1005, -5460, -1819 },
+ { 2897, 2084, -5885, -515 },
+ { -400, 3370, -5527, -2947 },
+ { 1505, 2593, -5518, -1802 },
+ { 1341, 4534, -5094, -1899 },
+ { 3241, 3670, -5493, -1252 },
+ { -1287, 921, -5994, -1675 },
+ { 627, 408, -6652, -364 },
+ { -260, 1127, -4849, -3247 },
+ { 371, 3400, -5976, -2285 },
+ { 1533, 1566, -6373, -610 },
+ { 2462, 4274, -6184, -1254 },
+ { 1782, 3363, -6222, -1381 },
+ { 572, 4650, -5673, -2754 },
+ { 2674, 3414, -4460, -2154 },
+ { 3614, 3820, -6883, -398 },
+ { 1136, -1, -5511, -1112 },
+ { -1773, 1137, -5647, -2377 },
+ { -753, 2104, -6085, -2565 },
+ { -204, 3025, -4731, -1418 },
+ { -1486, 1438, -4380, -216 },
+ { 302, 858, -5786, -264 },
+ { 3486, 1495, -5234, -783 },
+ { 888, 2327, -3423, -3720 },
+ { -259, 772, -6596, -1311 },
+ { -1197, 2073, -5174, -1826 },
+ { 1500, 3470, -4462, -2645 },
+ { 3072, 1960, -3277, -2264 },
+ { 1841, 952, -4324, -2340 },
+ { 1994, 2200, -3940, -2923 },
+ { -1782, 1699, -4667, -1075 },
+ { -1464, 2906, -3468, -375 },
+ { 366, 2380, -3747, 1467 },
+ { -545, 1645, -4619, 376 },
+ { 1724, 2350, -2374, -3512 },
+ { 3184, 2628, -2996, -3275 },
+ { 734, 2010, -6239, -1479 },
+ { 524, 3756, -4496, -3263 },
+ { 1492, 3570, -3494, -3600 },
+ { -932, 618, -5389, -2894 },
+ { -133, 2161, -4083, -3267 },
+ { 786, 774, -3279, -3731 },
+ { 1078, 803, -3843, -3007 },
+ { -332, 3405, -3347, 40 },
+ { -17, 6, -4005, -3690 },
+ { -189, 4372, -4488, -2561 },
+ { -450, 3846, -3790, -1370 },
+ { 362, 2212, -5272, -15 },
+ { -1529, 791, -6802, -2296 },
+ { 2145, 4241, -4474, 376 },
+ { 1813, 2426, -2932, -2726 },
+ { -542, 4557, -3140, -1080 },
+ { 1192, 3784, -4371, -20 },
+ { 2784, 5188, -6399, -1394 },
+ { 431, 4561, -3673, -1398 },
+ { 1382, 3096, -4083, 1253 },
+ { 1209, 4224, -2930, 1500 },
+ { 2798, 2684, -6676, -606 },
+ { -2396, 1510, -5381, -2713 },
+ { -2625, 2542, -4032, -2880 },
+ { -1231, 3967, -4098, -2886 },
+ { -1393, 2374, -3862, -4525 },
+ { -2495, 1665, -1637, -5445 },
+ { -3854, 1759, -1750, -4944 },
+ { -2373, 1668, -2856, -6251 },
+ { -2668, 1981, -886, -4557 },
+ { -2927, 4427, -3451, -6172 },
+ { -1925, 2596, -4696, -2527 },
+ { -3202, 2847, -3928, -5896 },
+ { -3332, 1665, -5025, -3412 },
+ { -3212, 3115, -4155, -4062 },
+ { -1013, 3205, -5133, -3751 },
+ { -2022, 4595, -3947, -5611 },
+ { -3556, 1755, -3715, -2300 },
+ { -1784, 4114, -2723, -1773 },
+ { -3586, 4081, -2733, -4942 },
+ { -1608, 3685, -4154, -4573 },
+ { -3368, 4042, -4452, -6227 },
+ { -1407, 3881, -5729, -3719 },
+ { -2751, 3281, -5077, -4999 },
+ { -3791, 2410, -4906, -5288 },
+ { -730, 2303, -4217, -3755 },
+ { -1812, 2311, -5492, -3709 },
+ { -610, 4336, -3915, -3783 },
+ { -2841, 4337, -4278, -4430 },
+ { -1662, 4666, -4661, -3964 },
+ { -589, 5209, -4923, -3682 },
+ { -4155, 2234, -4076, -4218 },
+ { -3951, 2770, -2665, -2805 },
+ { -2302, 3228, -3717, -1908 },
+ { -3129, 4373, -2264, -2851 },
+ { -447, 1363, -3578, -4323 },
+ { -2648, 4237, -3159, -3071 },
+ { -4072, 3241, -3541, -4605 },
+ { -4507, 3458, -2339, -3838 },
+ { -1646, 997, -4926, -3970 },
+ { -3025, 1614, -3940, -1242 },
+ { -1337, 1756, -3163, -5529 },
+ { -3203, 1865, -3282, -4354 },
+ { -1646, 2118, -2203, -6018 },
+ { 174, 1871, -2707, -4639 },
+ { -2607, 1485, -4778, -4750 },
+ { -2199, 3991, -3134, -4879 },
+ { -2962, 3323, -2816, -2419 },
+ { -5286, 2495, -4548, -5395 },
+ { -2810, 3710, -2274, -4211 },
+ { -330, 3006, -2993, -4678 },
+ { -1187, 2411, -2743, -5196 },
+ { -664, 4033, -3101, -5641 },
+ { -1458, 3602, -2816, -5371 },
+ { -4116, 4923, -3321, -5630 },
+ { -4165, 2528, -2592, -4798 },
+ { -2759, 3080, -2333, -5719 },
+ { -5157, 3011, -5526, -6348 },
+ { -3095, 2126, -5881, -4234 },
+ { -4377, 3849, -3600, -6099 },
+ { -1994, 4947, -5235, -4753 },
+ { -1067, 600, -3258, -5133 },
+ { -4992, 3302, -2208, -5051 },
+ { -3377, 2981, -1655, -4815 },
+ { -3325, 2446, -1787, -6116 },
+ { -2341, 2737, -3240, -6347 },
+ { -2258, -3732, 3710, -1235 },
+ { -1558, -3849, 2694, -3012 },
+ { -599, -4837, 3050, -2951 },
+ { -2246, -5433, 2798, -1910 },
+ { -2255, -4989, 3260, 270 },
+ { -3026, -5353, 2693, -1036 },
+ { -1151, -6097, 1097, -3782 },
+ { -3391, -6012, 2130, -1303 },
+ { -2850, -4422, 3375, -480 },
+ { -1138, -3779, 1491, -4162 },
+ { -551, -3892, 3787, -2082 },
+ { -3221, -3676, 3144, -1202 },
+ { -3023, -5196, 2650, 605 },
+ { -1756, -5729, 2646, 321 },
+ { -2693, -4409, 494, -4797 },
+ { -1913, -4573, 3372, -1730 },
+ { -1277, -3604, 4061, -993 },
+ { -420, -4993, 1351, -4796 },
+ { -3052, -5333, 1435, -1242 },
+ { -602, -5034, 3869, -1141 },
+ { -2436, -4680, 1665, -3019 },
+ { -2657, -3658, 1459, -3391 },
+ { -1220, -6246, 2749, -525 },
+ { -3838, -4844, 2265, -1735 },
+ { -1247, -5679, 3356, -1417 },
+ { -917, -5448, 3342, 105 },
+ { -1756, -6839, 2276, -2350 },
+ { -412, -5206, 1764, -3539 },
+ { -1439, -6915, 1442, -3750 },
+ { -1381, -4439, 3863, -282 },
+ { -3482, -4953, 2726, -336 },
+ { -1376, -5931, 1714, -1987 },
+ { -1716, -4405, 2608, 105 },
+ { -1590, -5191, 2652, -2704 },
+ { -2149, -6442, 2453, -1263 },
+ { -3426, -3832, 2334, -1829 },
+ { -2747, -5948, 2362, -173 },
+ { -2435, -3267, 2966, -1710 },
+ { -3979, -4282, 2705, -775 },
+ { -356, -4238, 2544, -4343 },
+ { -1363, -6471, 2817, -1836 },
+ { -2878, -5117, 218, -3149 },
+ { -3539, -5196, 1710, -2356 },
+ { -2888, -4537, 2746, -1701 },
+ { -1870, -4439, 1496, -4121 },
+ { -1486, -3388, 3349, -2145 },
+ { -3333, -4138, 1467, -2876 },
+ { -345, -5340, 1012, -1190 },
+ { -1672, -4992, 2289, -1029 },
+ { -2146, -5528, 3038, -635 },
+ { -316, -3656, 3426, -3152 },
+ { -2695, -5812, 2336, -2050 },
+ { -2067, -6052, 737, -3258 },
+ { -2664, -4205, -350, -1266 },
+ { -617, -5406, 80, -4853 },
+ { -2418, -3825, 1853, -1326 },
+ { -1961, -4339, 583, -4315 },
+ { -1495, -5141, -133, -5205 },
+ { -3208, -6440, 1691, -2069 },
+ { -2632, -3633, 2325, -2761 },
+ { -2624, -5670, 1252, -3676 },
+ { -3687, -5608, 687, -2833 },
+ { -3320, -5707, 16, -3877 },
+ { -2738, -6112, 84, -5135 },
+ { 2277, -5661, 3076, 843 },
+ { 1555, -5769, 2821, -5236 },
+ { 536, -6381, 603, -4910 },
+ { 734, -4609, 3314, -4092 },
+ { 1836, -4547, 3267, -4322 },
+ { -13, -5976, 3752, -1607 },
+ { 1423, -6318, 2336, 398 },
+ { 365, -7779, 1498, -534 },
+ { 2104, -8366, 2946, -1345 },
+ { 143, -5545, 1898, -3756 },
+ { 655, -6852, 1430, 148 },
+ { 4, -6653, 2397, -59 },
+ { 2346, -5996, 4562, -934 },
+ { 1229, -7104, 2963, -598 },
+ { -528, -7048, 2887, -1790 },
+ { 1451, -6857, 3900, -1637 },
+ { 554, -6018, 3336, 9 },
+ { 3278, -5758, 4034, 129 },
+ { 3541, -7145, 4905, -1575 },
+ { 2339, -6907, 3464, -301 },
+ { 2775, -7301, 1667, -3894 },
+ { 539, -7887, 991, -4156 },
+ { 2115, -7421, 3131, -3075 },
+ { 2803, -8546, 2564, -5836 },
+ { 2869, -5833, 1620, -4561 },
+ { 2591, -7281, 3215, -4719 },
+ { -1228, -8477, 706, -4782 },
+ { 1967, -5243, 4813, -1940 },
+ { 701, -7010, 2273, -3893 },
+ { 915, -8470, 1918, -5620 },
+ { -94, -6715, 156, -3873 },
+ { 1074, -5607, 4389, -1017 },
+ { 2739, -6551, 1227, -3521 },
+ { 725, -7835, 2701, -1291 },
+ { -493, -7475, 2263, -1075 },
+ { -412, -6508, 2984, -744 },
+ { 665, -5451, 3725, -2692 },
+ { 1499, -8129, 3564, -2072 },
+ { 2870, -6333, 4487, -2108 },
+ { 706, -5007, 3911, -152 },
+ { -482, -8660, 1483, -2900 },
+ { 2481, -6596, 2518, -1715 },
+ { 1403, -6414, 1398, -5387 },
+ { 652, -6267, 583, -5942 },
+ { 694, -7540, 646, -6272 },
+ { 2275, -7614, 256, -5015 },
+ { 1416, -9727, 1900, -3153 },
+ { 2760, -6433, 3875, -3771 },
+ { 2325, -11196, 2182, -5155 },
+ { 1223, -11061, 1377, -5097 },
+ { 108, -10603, 307, -4952 },
+ { -118, -8268, 1650, -1572 },
+ { 1839, -7943, 1755, -612 },
+ { 2501, -9056, 981, -2969 },
+ { 2902, -8476, 1491, -5780 },
+ { 1995, -11175, 1585, -3643 },
+ { 696, -8212, 828, -2474 },
+ { 1526, -8649, 1380, -1210 },
+ { 461, -7253, 3222, -2229 },
+ { 2966, -8641, 4121, -3271 },
+ { 833, -6039, 2361, -1086 },
+ { 3565, -7312, 1980, -5427 },
+ { 2850, -8671, 3760, -1846 },
+ { 2643, -7281, 2163, -173 },
+ { 3463, -3706, -3132, -923 },
+ { 1315, -3825, -3443, 2 },
+ { 2594, -4083, -3815, 670 },
+ { 1826, -4291, -2741, -155 },
+ { 868, -3749, -4175, -298 },
+ { 2008, -4237, -3897, -517 },
+ { 1242, -3493, -4335, -1335 },
+ { -88, -4142, -3390, -1529 },
+ { 2176, -3488, -3822, -975 },
+ { 1706, -5188, -3415, -637 },
+ { 2717, -6159, -2333, -882 },
+ { 1276, -3978, -4361, 537 },
+ { 2471, -5556, -2866, -208 },
+ { 799, -4673, -4086, 56 },
+ { 1901, -4786, -3533, 270 },
+ { 3036, -3902, -3606, -333 },
+ { 2249, -3317, -4319, -144 },
+ { 2594, -4207, -2105, -2930 },
+ { 4008, -4774, -2626, -902 },
+ { 1038, -3659, -3496, -2454 },
+ { 2725, -3597, -3298, -1535 },
+ { 1662, -5803, -2813, 175 },
+ { 705, -3757, -3441, -1484 },
+ { 1860, -5987, -2821, -886 },
+ { 3786, -4918, -2199, -1929 },
+ { 3683, -4235, -2547, -1287 },
+ { 2531, -4896, -2956, -1593 },
+ { 1005, -5585, -3324, -180 },
+ { 1625, -5229, -1756, -3642 },
+ { 1494, -5041, -2989, -2685 },
+ { 2718, -4655, -3224, -867 },
+ { 2374, -6640, -1745, -2975 },
+ { 2133, -6436, -2477, -1499 },
+ { 1833, -4418, -3523, -1512 },
+ { 1128, -4910, -2658, -1106 },
+ { 689, -4777, -2831, -2085 },
+ { 3593, -5280, -2627, -315 },
+ { 3264, -3771, -2673, -1861 },
+ { 3202, -5602, -2409, 402 },
+ { 552, -4618, -2221, -3002 },
+ { 3095, -5356, -2666, -1083 },
+ { 3401, -4609, -3146, 45 },
+ { 3051, -4662, -2192, -2232 },
+ { 2798, -5552, -2462, -1941 },
+ { 2354, -5815, -2223, -2619 },
+ { 192, -3708, -2807, -2658 },
+ { 1886, -4226, -1862, -3529 },
+ { 2526, -3976, -2819, -2332 },
+ { 1577, -3870, -2711, -2806 },
+ { 1288, -5588, -3382, -1403 },
+ { 2711, -5399, -1564, -3253 },
+ { 1459, -5492, -2222, -322 },
+ { 2823, -5091, -2886, 776 },
+ { 3559, -5821, -2109, -1360 },
+ { 1587, -6331, -2760, -1909 },
+ { 2139, -5213, -2874, -2120 },
+ { 1318, -4337, -3695, -2098 },
+ { 821, -4471, -1849, -565 },
+ { 3329, -4782, -1725, -89 },
+ { 582, -4914, -4105, -1119 },
+ { 417, -4144, -4072, -2529 },
+ { -199, -3803, -2765, -4042 },
+ { 2731, -4283, -2143, 1 },
+ { 2911, -6187, -1951, -2116 },
+ { 1573, -6094, -493, -2838 },
+ { 2081, -6927, -864, -3211 },
+ { 1058, -7826, 79, -364 },
+ { 3147, -5570, -684, -978 },
+ { 3572, -5856, 1060, 1824 },
+ { 1143, -6702, -1478, 338 },
+ { 2341, -7220, -88, 260 },
+ { 3639, -6861, 668, 815 },
+ { 2227, -6268, -1706, 446 },
+ { 3390, -6082, -353, 1302 },
+ { 1123, -7556, -1237, -430 },
+ { 1729, -7742, 729, -218 },
+ { 1457, -6774, 587, 579 },
+ { 505, -6919, -569, 371 },
+ { 1106, -7245, 78, 158 },
+ { 2755, -6745, -1122, 338 },
+ { 3069, -6040, -1415, 986 },
+ { 2174, -7064, -1430, -283 },
+ { 1390, -8626, -446, -3031 },
+ { 3534, -6890, -431, 547 },
+ { 2267, -9618, 475, -2994 },
+ { 3672, -7673, 75, -115 },
+ { 2131, -7560, -1206, -750 },
+ { 2972, -7477, -685, -262 },
+ { 1604, -6637, -672, 699 },
+ { 1666, -7577, -577, -240 },
+ { 1591, -6554, -2158, -94 },
+ { 2348, -6286, -353, 1123 },
+ { 2017, -8810, -412, -1805 },
+ { 2892, -6713, -1765, -554 },
+ { 2500, -6828, -1995, -1197 },
+ { 3877, -6639, -224, -1655 },
+ { 2392, -7872, -91, -333 },
+ { 3562, -7370, -532, -2836 },
+ { 2552, -7614, 164, -1805 },
+ { 990, -6104, 218, 438 },
+ { 910, -7861, 312, -1195 },
+ { 1472, -6327, 372, -640 },
+ { 1576, -7143, -1983, -843 },
+ { 422, -7625, -457, -278 },
+ { 1797, -8532, 405, -1011 },
+ { 1088, -7396, -238, -2277 },
+ { 3209, -6753, -1431, -2072 },
+ { 2617, -6839, 100, -2573 },
+ { 2575, -8573, -387, -3188 },
+ { 3618, -6971, -1190, -321 },
+ { 2205, -7361, -1695, -2008 },
+ { 2985, -6297, 1464, 1179 },
+ { 2804, -7310, 1053, 338 },
+ { 1362, -6074, -1163, -840 },
+ { 3336, -6325, -1794, 21 },
+ { 2836, -8109, 818, -329 },
+ { 2791, -5879, 560, 1546 },
+ { 2392, -6064, 135, 100 },
+ { 1838, -6194, 596, 1085 },
+ { 1926, -7515, -414, -4901 },
+ { 3225, -7298, -1202, -1189 },
+ { 3960, -7558, -659, -719 },
+ { 3442, -6647, -1692, -1095 },
+ { 3381, -6441, 262, -886 },
+ { 1431, -8150, -1186, -1406 },
+ { 340, -8498, -150, -899 },
+ { 3004, -8149, -260, -953 },
+ { 2749, -6611, 563, 873 },
+ { -6647, -1325, -4517, -4691 },
+ { -6005, -1657, -4089, -3797 },
+ { -3157, 588, -5213, -3068 },
+ { -3311, -1425, -6329, -3726 },
+ { -5866, -819, -3857, -2744 },
+ { -5001, -1799, -1075, -4621 },
+ { -5330, -2650, -2672, -4664 },
+ { -4930, -539, -2363, -4010 },
+ { -2984, 10, -3863, -5749 },
+ { -1055, -2106, -3713, -4267 },
+ { -5476, -502, -4279, -6504 },
+ { -5231, -1543, -5018, -6425 },
+ { -5134, -363, -3165, -5109 },
+ { -3953, -771, -4107, -6393 },
+ { -2159, -563, -3652, -5342 },
+ { -3888, -2321, -919, -5057 },
+ { -1236, -597, -4235, -4193 },
+ { -4053, 675, -3083, -6174 },
+ { -2793, -1089, -5396, -3460 },
+ { -3000, -44, -2209, -6575 },
+ { -3336, -1531, -4313, -5160 },
+ { -2127, 128, -4851, -3692 },
+ { -3321, 136, -2067, -5660 },
+ { -5215, 1404, -4374, -4356 },
+ { -2747, 400, -6340, -3691 },
+ { -3926, -599, -5361, -5006 },
+ { -2875, -2592, -5143, -4092 },
+ { -4991, -1958, -5322, -4891 },
+ { -4965, -1318, -6652, -5333 },
+ { -4920, -1691, -3388, -5561 },
+ { -3644, -3354, -2688, -5982 },
+ { -5076, -919, -4563, -2984 },
+ { -6114, 250, -3884, -3915 },
+ { -4014, 744, -3973, -1924 },
+ { -5543, -1041, -5557, -3847 },
+ { -4711, -1352, -5649, -2603 },
+ { -3362, 775, -5305, -4879 },
+ { -5001, 107, -3554, -2888 },
+ { -6258, -1651, -6356, -6566 },
+ { -4529, 407, -5003, -3865 },
+ { -5154, 550, -5278, -5465 },
+ { -4195, -467, -1894, -3129 },
+ { -5022, 1127, -3349, -3314 },
+ { -6075, 1250, -4313, -5641 },
+ { -2677, -2283, -2312, -5903 },
+ { -4113, 193, -1195, -4833 },
+ { -3940, -1048, -1389, -5079 },
+ { -3703, 917, -4043, -4451 },
+ { -3366, -4231, -1534, -5488 },
+ { -3326, -3583, -2091, -4903 },
+ { -5144, 1254, -2532, -4949 },
+ { -5982, -870, -2545, -4555 },
+ { -3925, -157, -5367, -2281 },
+ { -6419, -746, -5668, -4371 },
+ { -5787, 518, -7096, -5805 },
+ { -4258, 954, -6453, -4321 },
+ { -4771, -695, -4158, -1639 },
+ { -7078, -760, -5195, -5877 },
+ { -7348, 83, -4101, -4586 },
+ { -2430, 184, -2874, -1679 },
+ { -2284, -3943, -2924, -5034 },
+ { -1804, -1785, -3002, -4710 },
+ { -4399, -2772, -1815, -4637 },
+ { -6340, -2626, -2824, -5191 },
+ { -4998, -5168, -3480, 1905 },
+ { -3958, -5492, -1599, 1579 },
+ { -2471, -3755, -276, 3182 },
+ { -3033, -5779, -1063, 1554 },
+ { -2936, -4829, -1290, 2386 },
+ { -1835, -5073, -3051, 1299 },
+ { -1724, -3771, -3935, 2324 },
+ { -5070, -2550, -3692, 768 },
+ { -4326, -5333, -297, 1878 },
+ { -3472, -5619, -3094, 992 },
+ { -3027, -4384, -3038, 2265 },
+ { -3201, -5332, 67, 2200 },
+ { -1681, -4373, -1947, 2461 },
+ { -3221, -3329, -4238, 2564 },
+ { -1262, -2968, -2915, 3227 },
+ { -3419, -1878, -3373, 2110 },
+ { -2244, -5583, -2012, 1288 },
+ { -1971, -5266, -990, 1812 },
+ { -2975, -2778, -452, 4063 },
+ { -2198, -1165, -3298, 2965 },
+ { -4782, -4894, -4767, 664 },
+ { -6002, -3950, -2806, 2025 },
+ { -3142, -3162, -2859, 3295 },
+ { -3262, -3340, -4123, 1596 },
+ { -4014, -3918, -1955, 3361 },
+ { -1700, -3463, -1346, 3449 },
+ { -4245, -4445, -4743, 1644 },
+ { -4180, -3969, -401, 3281 },
+ { -2782, -5240, -4117, 1156 },
+ { -5744, -4040, -1439, 3470 },
+ { -5063, -4663, -323, 3172 },
+ { -4531, -3319, -844, 3988 },
+ { -6226, -5125, -2064, 2976 },
+ { -3115, -3267, -1531, 3898 },
+ { -4628, -4421, -2864, 2808 },
+ { -4559, -2989, -3442, 2024 },
+ { -1775, -4487, -656, 2477 },
+ { -2664, -1865, -1884, 4081 },
+ { -1828, -2575, -3894, 3378 },
+ { -6441, -3677, -2025, 1677 },
+ { -4141, -2156, -1191, 3474 },
+ { -4802, -1623, -1727, 2160 },
+ { -5474, -2745, -1475, 2498 },
+ { -3664, -1056, -1975, 2491 },
+ { -4672, -3062, -2235, 2933 },
+ { -4205, -5960, -2849, 1517 },
+ { -4995, -5708, -1739, 1805 },
+ { -4892, -6080, -4793, 872 },
+ { -4270, -4172, -4263, 2185 },
+ { -4687, -1470, -2905, 1023 },
+ { -6446, -5017, -3919, 1000 },
+ { -6046, -5538, -3943, 2006 },
+ { -6028, -3750, -3953, 771 },
+ { -5959, -4582, -5024, 824 },
+ { -5818, -2576, -2249, 1326 },
+ { -5659, -5345, -1119, 2500 },
+ { -3346, -4155, 606, 2749 },
+ { -5680, -4827, -2501, 1838 },
+ { -6193, -2543, -1295, 840 },
+ { -6871, -4925, -3512, 1801 },
+ { -5605, -1788, -1895, 779 },
+ { -3922, -5712, -4644, 510 },
+ { -4745, -3869, -4533, 99 },
+ { -2984, -4907, -399, 1497 },
+ { 1847, -478, 3061, -5812 },
+ { 4450, -1116, 3609, -6570 },
+ { 3139, 99, 3007, -5532 },
+ { 2590, -3782, 3138, -4770 },
+ { 1881, 1204, 5778, -3404 },
+ { 3631, 2060, 5566, -5038 },
+ { 3461, 1961, 5167, -3800 },
+ { 2947, 273, 4536, -4389 },
+ { 4453, -1730, 5788, -4370 },
+ { 4032, 1805, 2666, -4534 },
+ { 3487, -944, 2313, -6028 },
+ { 1313, 34, 4210, -4067 },
+ { 5632, -1502, 5825, -5855 },
+ { 7736, -547, 4879, -5476 },
+ { 4906, -1512, 4760, -5760 },
+ { 3843, 447, 1091, -4958 },
+ { 2982, -1135, 5442, -4386 },
+ { 3579, 271, 3031, -6770 },
+ { 3932, -211, 4688, -5507 },
+ { 4411, 1720, 2387, -5584 },
+ { 5379, -479, 4575, -6280 },
+ { 3613, -362, 2012, -4885 },
+ { 3744, -2013, 4493, -5073 },
+ { 5693, 109, 4379, -3362 },
+ { 5475, -621, 5317, -3985 },
+ { 6411, -673, 5708, -4752 },
+ { 4933, -796, 7262, -4290 },
+ { 2804, 444, 6276, -3655 },
+ { 4120, -517, 6078, -4531 },
+ { 5119, 841, 3486, -3910 },
+ { 4738, 1539, 3525, -2970 },
+ { 5086, 370, 5895, -5640 },
+ { 4235, 2716, 4589, -5044 },
+ { 3691, 682, 6199, -4700 },
+ { 6111, -570, 6271, -6528 },
+ { 2611, 1277, 3756, -4802 },
+ { 4395, 970, 3807, -5879 },
+ { 5225, 2299, 3242, -4333 },
+ { 5144, 1778, 4946, -5545 },
+ { 2989, -3016, 3247, -5495 },
+ { 2983, 920, 2071, -6059 },
+ { 5270, -903, 4434, -2350 },
+ { 6415, -585, 3970, -3554 },
+ { 3866, -197, 5216, -2884 },
+ { 3767, -1298, 6702, -3315 },
+ { 6299, 2620, 5284, -6824 },
+ { 6654, 646, 3653, -4927 },
+ { 4770, 3047, 5160, -6287 },
+ { 5364, 434, 2919, -5207 },
+ { 2998, 1344, 4801, -2456 },
+ { 3896, 1013, 3773, -1864 },
+ { 2115, 655, 2999, -6344 },
+ { 5170, -981, 2849, -4464 },
+ { 2735, -2159, 2717, -5776 },
+ { 2430, -1952, 4392, -4559 },
+ { 6143, -1180, 3659, -4746 },
+ { 4978, -1483, 1726, -4875 },
+ { 3486, -2383, 3306, -4301 },
+ { 1434, -1372, 4171, -4770 },
+ { 3354, -2627, 1525, -5093 },
+ { 6790, 2386, 3995, -5909 },
+ { 1475, -2674, 3451, -4204 },
+ { 1999, -3494, 3693, -5556 },
+ { 4764, -2848, 2856, -5589 },
+ { -3677, 5131, 2827, -2934 },
+ { -2844, 7078, 2852, -3580 },
+ { -3902, 6434, 4118, -1911 },
+ { -1769, 7530, 3492, -3541 },
+ { -1937, 5679, -447, -1127 },
+ { -2456, 4680, 4196, -2407 },
+ { -2778, 8241, 1698, -4288 },
+ { -2876, 6104, 5182, -2387 },
+ { -2802, 7341, 4463, -2938 },
+ { -1025, 6267, 4752, -3201 },
+ { -2349, 5413, 2041, -3794 },
+ { -2252, 8225, 2856, -4269 },
+ { -1465, 4967, 4976, -2500 },
+ { -636, 7565, 3517, -4233 },
+ { -1905, 5618, 3904, -2942 },
+ { -302, 6816, 3343, -3316 },
+ { -2210, 4156, 2817, -3511 },
+ { -717, 6568, 1863, -2951 },
+ { -3873, 5682, 2164, -575 },
+ { -2878, 5835, 440, -2597 },
+ { -3228, 7701, 2610, -2514 },
+ { -3608, 8888, 3377, -2468 },
+ { -2582, 9717, 2519, -3126 },
+ { -5238, 6202, 2866, -2831 },
+ { -3428, 7370, 3056, -335 },
+ { -1681, 8836, 1210, -2010 },
+ { -3276, 6724, 1156, -3930 },
+ { -894, 8149, 827, -1258 },
+ { -2965, 8631, 2549, -1320 },
+ { -3961, 6902, 3581, 55 },
+ { -1894, 7745, 1750, -841 },
+ { -821, 6844, 850, -676 },
+ { -608, 6948, -4, -1376 },
+ { 615, 6524, 1089, -1147 },
+ { -2972, 5668, 1091, -489 },
+ { -157, 4649, 2904, -413 },
+ { 673, 5121, 1498, -66 },
+ { -390, 5902, 1611, -245 },
+ { -2349, 5478, 4772, -1320 },
+ { 88, 6798, 1972, -1859 },
+ { -1213, 5120, 2991, 200 },
+ { -2347, 6040, 2839, 376 },
+ { -578, 5976, 3364, -1796 },
+ { -1391, 5872, 3002, -965 },
+ { -564, 4496, 3946, -1186 },
+ { -2299, 6386, 3135, -2176 },
+ { -2131, 5641, 2011, 1223 },
+ { -772, 5807, 1124, 895 },
+ { -2837, 6758, 2297, -740 },
+ { -3091, 6298, 1415, -2126 },
+ { -4197, 6036, 1843, -3022 },
+ { -41, 6459, 92, 344 },
+ { -2241, 6860, 2095, -4396 },
+ { -1931, 7088, 2117, -2135 },
+ { -2375, 4422, 1688, -3169 },
+ { -1742, 6674, 1538, -119 },
+ { -4818, 7749, 4192, -1577 },
+ { -2004, 5672, 193, -430 },
+ { -3825, 6042, 2128, -1898 },
+ { -1108, 8033, 2119, -3013 },
+ { -2370, 5453, 1721, 266 },
+ { -1570, 7134, 614, -2638 },
+ { -1519, 8752, 3503, -4330 },
+ { -2050, 3845, 2907, -1126 },
+ { 5085, 4412, -335, -1923 },
+ { 3618, 1423, -613, -4012 },
+ { 4481, 3729, 589, -4631 },
+ { 4270, 3216, -1763, -3168 },
+ { 4241, 1796, -1701, -2796 },
+ { 4787, 2338, -487, -3639 },
+ { 2915, 3429, -621, -4753 },
+ { 5175, 1660, -1265, -3223 },
+ { 4280, 4057, -684, -4079 },
+ { 4980, 4419, -1455, -2719 },
+ { 5436, 2464, 387, -4197 },
+ { 4507, 4018, 1121, -3314 },
+ { 6020, 2401, -413, -3201 },
+ { 4200, 3789, -333, -2813 },
+ { 5229, 2493, -1194, -1878 },
+ { 5851, 2695, -492, -2292 },
+ { 5743, 3288, -697, -1221 },
+ { 5692, 2612, 979, -2227 },
+ { 5085, 2067, 1046, -1214 },
+ { 3163, 2240, -2098, -3435 },
+ { 5228, 1898, 145, -2397 },
+ { 5860, 3976, -418, -2872 },
+ { 6008, 3399, 1027, -3506 },
+ { 4126, 2035, 1865, -893 },
+ { 5375, 3596, 511, -2362 },
+ { 1937, 1493, -852, -122 },
+ { 3473, 4849, 547, -2603 },
+ { 4631, 2977, 1141, -1768 },
+ { 6149, 3050, -71, -1886 },
+ { 4069, 4353, -289, -1429 },
+ { 2884, 1225, -1388, 365 },
+ { 5485, 2518, -235, -571 },
+ { 1216, 4375, 1443, 398 },
+ { 4988, 3106, 107, -1435 },
+ { 4511, 2801, 307, -444 },
+ { 3235, 4386, 327, -676 },
+ { 2055, 3708, 1657, -305 },
+ { 5839, 2374, 290, -1385 },
+ { 5110, 3305, 1936, -4206 },
+ { 6416, 2920, 338, -2736 },
+ { 3350, 2824, -1269, -3881 },
+ { 4840, 1815, 464, 186 },
+ { 2399, 3332, 238, 1238 },
+ { 3516, 1363, 1582, 688 },
+ { 3582, 1874, 154, -4770 },
+ { 3261, 2878, 886, 283 },
+ { 3877, 2658, -327, 884 },
+ { 4151, 3436, 2173, -2923 },
+ { 3592, 3674, 1281, -1295 },
+ { 4561, 3730, -1114, -1747 },
+ { 4595, 3625, -558, -575 },
+ { 2577, 2348, 2267, 120 },
+ { 5242, 3299, 32, -3412 },
+ { 4264, 3637, 709, -2320 },
+ { 6556, 3570, -838, -2472 },
+ { 5745, 4014, -940, -1973 },
+ { 5629, 4475, 477, -3328 },
+ { 5269, 3199, 1682, -3085 },
+ { 4432, 2416, 1145, -3299 },
+ { 4465, 2505, 2162, -2186 },
+ { 4643, 4941, -88, -2885 },
+ { 4568, 5231, 552, -3915 },
+ { 5667, 3075, -1406, -2963 },
+ { 5418, 5259, -771, -2818 },
+ { -256, -7875, 511, -471 },
+ { -1813, -7971, -424, -396 },
+ { -306, -7006, 862, 282 },
+ { -2306, -6422, -1440, 508 },
+ { -245, -6787, 375, -100 },
+ { -1309, -6065, -20, 779 },
+ { -1656, -6047, -641, 1307 },
+ { -1496, -6522, 964, 726 },
+ { -2291, -6588, -202, 795 },
+ { -762, -7522, 1454, -558 },
+ { -2270, -7004, -834, -580 },
+ { -1139, -7078, 259, 362 },
+ { -2535, -7568, -1040, 49 },
+ { -3786, -7280, 934, -476 },
+ { -3336, -6368, 606, 1056 },
+ { -3602, -6924, 52, 714 },
+ { -2278, -6550, 1674, 204 },
+ { -2855, -5765, 930, 1530 },
+ { -2889, -7325, -215, 305 },
+ { -2749, -6080, -237, 1452 },
+ { -985, -6667, 1577, 400 },
+ { -2036, -6083, 380, 1267 },
+ { -2077, -7460, 380, -30 },
+ { -1775, -7175, 1540, -386 },
+ { -3065, -6927, 989, 168 },
+ { -2836, -7602, 117, -3392 },
+ { -1058, -6396, 593, -3078 },
+ { -844, -6062, 999, -236 },
+ { -3261, -6951, 1491, -720 },
+ { -2186, -8484, 75, -1287 },
+ { -2882, -7756, 456, -510 },
+ { -1800, -6879, 960, -1183 },
+ { -2554, -7241, 1614, -1474 },
+ { -2608, -5305, 392, 851 },
+ { -2973, -6562, -859, 858 },
+ { -2640, -5989, 1031, -416 },
+ { -977, -8366, 705, -1434 },
+ { -1213, -7409, -77, -1390 },
+ { -1335, -6657, 2125, -123 },
+ { -2544, -6862, 1852, -737 },
+ { -3235, -6422, 1752, -103 },
+ { -1300, -7557, 939, -348 },
+ { -3476, -7579, 202, -109 },
+ { -2482, -6572, 753, 619 },
+ { -2554, -8136, -648, -429 },
+ { -1012, -7870, -3, -421 },
+ { -3604, -6247, 32, -3102 },
+ { -1486, -7271, 2013, -1021 },
+ { -578, -6799, -523, 405 },
+ { -2841, -5948, 1644, 911 },
+ { -2411, -7473, 1084, -484 },
+ { -2238, -6033, 294, -1059 },
+ { -3459, -6470, -201, -790 },
+ { -2027, -6009, 1833, 805 },
+ { -1433, -8047, 1531, -1754 },
+ { -3258, -7884, 763, -1422 },
+ { -1544, -6928, -729, 478 },
+ { -2314, -8415, 74, -3757 },
+ { -3201, -5684, 95, -2214 },
+ { -2423, -8694, 725, -3631 },
+ { -3545, -7071, 1162, -1798 },
+ { -294, -9662, 403, -2274 },
+ { -2290, -5460, 1196, 402 },
+ { -1603, -6713, 903, -2363 },
+ { 4121, 2491, -3142, -2482 },
+ { 4500, 3305, -3671, -1567 },
+ { 5973, 3172, -1348, -534 },
+ { 4830, 3379, -1549, 643 },
+ { 5214, 3938, -2641, -2302 },
+ { 4639, 4826, -5532, -847 },
+ { 5639, 2731, -2170, -963 },
+ { 6084, 3487, -3525, -1346 },
+ { 5971, 3154, -2190, -2316 },
+ { 5618, 4865, -6927, 116 },
+ { 5345, 3568, -7391, 709 },
+ { 5429, 5078, -3811, -1524 },
+ { 6960, 2037, -3515, -1096 },
+ { 7092, 2531, -4557, -588 },
+ { 6061, 4247, -5651, -478 },
+ { 4595, 3684, -4907, -827 },
+ { 7497, 3213, -3048, -424 },
+ { 5996, 2137, -3098, -1745 },
+ { 6198, 5199, -2223, -2274 },
+ { 6888, 2851, -2768, -1675 },
+ { 6114, 4210, -2316, -954 },
+ { 7127, 4242, -3041, -1408 },
+ { 6126, 3668, -1517, -1427 },
+ { 6245, 6129, -4225, -1186 },
+ { 6816, 3213, -2101, -964 },
+ { 5345, 5276, -2643, -847 },
+ { 6592, 4665, -4338, 484 },
+ { 6746, 3751, -3443, 124 },
+ { 5453, 1980, -2738, 2606 },
+ { 4662, 2179, -4226, -1059 },
+ { 5571, 3208, -3554, 174 },
+ { 5256, 4447, -1815, -1481 },
+ { 5400, 2570, -1210, 235 },
+ { 7056, 2549, -2674, 318 },
+ { 4574, 4340, -2892, -130 },
+ { 6203, 4587, -3273, -305 },
+ { 5103, 1925, -2715, -2137 },
+ { 3905, 4296, -1700, 247 },
+ { 4421, 4605, -3299, 811 },
+ { 5671, 1273, -3870, -924 },
+ { 5486, 1805, -4901, 133 },
+ { 6437, 2578, -1828, -106 },
+ { 5530, 5253, -5058, 1223 },
+ { 4816, 2025, -1215, 1443 },
+ { 3457, 3525, -2456, 3217 },
+ { 3316, 2595, -1108, 2459 },
+ { 3068, 3810, -2207, 1926 },
+ { 6351, 5436, -6470, 600 },
+ { 6324, 4240, -5365, 2416 },
+ { 4851, 4774, -4075, 1878 },
+ { 4900, 3679, -5198, 1078 },
+ { 8347, 3633, -4565, -171 },
+ { 5244, 5718, -3853, 173 },
+ { 3960, 3492, -2939, 2105 },
+ { 6070, 3473, -2351, 161 },
+ { 8228, 3034, -3360, -901 },
+ { 7006, 3985, -1940, -1926 },
+ { 7123, 4681, -4301, -878 },
+ { 5122, 4097, -1851, -449 },
+ { 6200, 2060, -2251, 1049 },
+ { 7106, 3844, -7209, 2625 },
+ { 7108, 3370, -6734, 533 },
+ { 6859, 2849, -3992, 1360 },
+ { 5458, 2278, -3253, 1131 },
+ { -1072, -2109, 4783, -1073 },
+ { -319, -2604, 4257, -2418 },
+ { 2466, 1300, 3476, -314 },
+ { 2847, -1502, 5296, -141 },
+ { 1667, -1273, 5559, -2725 },
+ { 2877, -3402, 6434, 204 },
+ { 53, -2637, 5275, -1181 },
+ { 1091, -2215, 5803, -1549 },
+ { 2397, -922, 4327, 1182 },
+ { 219, -3747, 4647, -1564 },
+ { -29, -2705, 4812, 1277 },
+ { 1499, -2608, 5648, 1407 },
+ { 2139, -2399, 4202, 2791 },
+ { -426, -2064, 5528, 151 },
+ { 2560, -2803, 6179, -2806 },
+ { 4537, -2479, 3797, 1095 },
+ { 888, -3357, 5341, -415 },
+ { 4460, -1814, 5388, -1227 },
+ { 3920, -3268, 6364, -703 },
+ { 3343, -4698, 4410, 784 },
+ { 309, -1897, 6306, 1223 },
+ { 958, -3318, 4254, -3167 },
+ { -99, 1596, 6018, -1983 },
+ { -429, -853, 6407, 878 },
+ { 1170, -1322, 6290, -417 },
+ { 2288, -505, 6303, -1999 },
+ { 3312, -1674, 6749, -2494 },
+ { -415, -3401, 4721, -371 },
+ { -189, -1210, 4844, -2002 },
+ { 888, -4142, 4377, 130 },
+ { 2469, -4381, 5398, -2492 },
+ { 2879, -2912, 5094, -2598 },
+ { -717, -617, 5650, -685 },
+ { 1470, -3863, 5352, -1684 },
+ { 3935, -96, 3823, -730 },
+ { 3769, -430, 3168, 694 },
+ { 2556, 385, 3539, 512 },
+ { 77, -1415, 5111, 2655 },
+ { 2724, -2158, 6715, -822 },
+ { 1832, 1001, 5385, -1900 },
+ { 900, 2198, 4464, -559 },
+ { 441, 69, 5921, -1743 },
+ { -1161, 738, 6732, -308 },
+ { 257, 2035, 4091, 736 },
+ { 1607, 1288, 4355, -23 },
+ { -13, 1316, 4180, 1672 },
+ { 1511, 1336, 3057, 1435 },
+ { 2189, -3813, 4530, 939 },
+ { 3632, -706, 2646, 1375 },
+ { 4266, -3761, 4241, 1077 },
+ { 3101, -427, 5273, -1202 },
+ { 2293, 276, 4810, -313 },
+ { 3430, -1851, 3101, 2045 },
+ { 3453, -2979, 5142, 942 },
+ { 1683, -3281, 4802, 2002 },
+ { 3954, -4715, 5611, 578 },
+ { 1272, -155, 5085, 454 },
+ { 128, -194, 5095, 1409 },
+ { 820, 880, 5797, -2658 },
+ { -1095, 656, 5774, 1095 },
+ { 813, -1669, 4320, -3251 },
+ { -119, 518, 6372, -651 },
+ { 2922, -4299, 6115, -877 },
+ { 4205, -4273, 4004, 2642 },
+ { -1211, -3892, 224, 3127 },
+ { -34, -4371, 1321, 2318 },
+ { 77, -6326, 1201, 828 },
+ { 3995, -3775, 1958, 3233 },
+ { 178, -3301, 1985, 3318 },
+ { 2330, -3801, 1033, 3195 },
+ { 1413, -5536, 826, 1709 },
+ { 2468, -3499, 3653, 3631 },
+ { 741, -4617, 1723, 2008 },
+ { 1246, -3043, 2978, 3949 },
+ { -343, -4308, 2258, 2189 },
+ { -682, -4640, 454, 2272 },
+ { 1236, -4829, 2491, 1642 },
+ { -512, -3766, 1182, 3052 },
+ { 119, -3939, 3712, 971 },
+ { -1145, -4624, 1360, 2281 },
+ { 101, -4746, 2866, 1255 },
+ { -1500, -5455, 539, 1637 },
+ { -969, -5909, 1414, 1128 },
+ { -1261, -4939, -231, 2022 },
+ { -226, -5345, 1207, 705 },
+ { 2712, -5109, 3205, 1866 },
+ { -476, -5913, 273, 1208 },
+ { -2039, -4464, 624, 2545 },
+ { -2351, -3930, 2019, 2673 },
+ { -2675, -4849, 1522, 1990 },
+ { -1524, -3461, 1446, 3204 },
+ { 477, -5314, 1710, 1577 },
+ { 656, -3729, 2346, 2511 },
+ { 550, -5917, 1975, 1040 },
+ { 1728, -4704, 3067, 1058 },
+ { -9, -5247, 506, 1760 },
+ { -574, -5135, 1675, 1672 },
+ { 2129, -3781, 3444, 2313 },
+ { 1144, -4439, 2214, 2529 },
+ { 1292, -4160, 3185, 1833 },
+ { 2445, -3262, 2534, 3227 },
+ { 2266, -4401, 2023, 2400 },
+ { -587, -3602, 3408, 2067 },
+ { -885, -4951, 3228, 1174 },
+ { -728, -2711, 2807, 3552 },
+ { 1019, -3043, 3195, 2954 },
+ { 1888, -4615, 1140, 2454 },
+ { 660, -5616, 754, 800 },
+ { -1975, -5371, 1649, 1585 },
+ { -1544, -5436, 2422, 1081 },
+ { -422, -5882, 2390, 750 },
+ { 1336, -5557, 2441, 1230 },
+ { 136, -4001, 267, 2854 },
+ { -522, -3289, 2226, 2728 },
+ { -971, -4580, 2471, 708 },
+ { 704, -5306, 3300, 1001 },
+ { 325, -3464, 3555, 2398 },
+ { 794, -3686, 848, 3169 },
+ { 660, -3017, 4584, 3242 },
+ { -1486, -3978, 2170, 1644 },
+ { -1615, -4650, 2688, 1844 },
+ { 750, -4578, 538, 2239 },
+ { 1668, -5849, 1455, 1031 },
+ { 3486, -4681, 2030, 2183 },
+ { 2642, -5429, 1696, 1761 },
+ { 4491, -4502, 3538, 2767 },
+ { 3545, -4528, 3514, 2982 },
+ { 3269, -3676, 2758, 3966 },
+ { 5572, 1146, 209, -3379 },
+ { 7459, 1053, 593, -1896 },
+ { 4480, 200, -310, -4259 },
+ { 5577, -939, 242, -3992 },
+ { 8142, 442, 1257, -3083 },
+ { 5442, 1261, 1424, -3236 },
+ { 6260, -183, 3125, -2532 },
+ { 7179, 889, 1618, -2548 },
+ { 6416, 932, 2379, -2487 },
+ { 7094, 2560, 961, -3392 },
+ { 7322, 463, 2732, -3735 },
+ { 6632, 1577, 1912, -3272 },
+ { 6312, 1349, 3028, -3460 },
+ { 6105, 386, 1213, -977 },
+ { 5478, 1158, 1114, -486 },
+ { 6493, 410, 1686, -2180 },
+ { 6378, 1881, 1333, -2240 },
+ { 5711, 812, 1958, -1300 },
+ { 6844, 877, 730, -1189 },
+ { 6824, -245, 2249, -2000 },
+ { 7515, 1521, 1251, -3058 },
+ { 6697, 1051, 1300, -1749 },
+ { 6476, 1425, 811, -2773 },
+ { 7350, 465, -76, -2849 },
+ { 6975, 2095, 567, -2492 },
+ { 4691, 1736, 2660, -2289 },
+ { 7837, 1456, 340, -2767 },
+ { 7930, 507, 838, -2074 },
+ { 6106, 1502, 766, -1110 },
+ { 4891, -659, 835, -3954 },
+ { 7250, 141, 1369, -1523 },
+ { 7651, 67, 1651, -2298 },
+ { 7364, -305, 601, -3132 },
+ { 7179, 193, 2491, -2871 },
+ { 6504, -272, 2167, -1322 },
+ { 4456, 983, 2300, -421 },
+ { 4817, 457, 1695, 371 },
+ { 6914, 555, 850, -3159 },
+ { 5904, 1030, 202, -1959 },
+ { 6258, 880, 2233, -4503 },
+ { 6029, 10, 2130, -3600 },
+ { 6449, 985, 1129, -3963 },
+ { 6616, -18, -111, -3285 },
+ { 4496, 775, 817, -4276 },
+ { 6134, 2338, 1470, -2973 },
+ { 6911, 152, 430, -1946 },
+ { 4053, 991, 3218, -1193 },
+ { 5435, 1285, 3124, -2412 },
+ { 5507, 1836, 1935, -1988 },
+ { 5240, 689, 2189, -2670 },
+ { 6638, 1719, 606, -1799 },
+ { 5556, -180, 129, -2595 },
+ { 5644, 1918, 1281, -4316 },
+ { 6410, 1088, -282, -3117 },
+ { 6503, 1841, 312, -3514 },
+ { 6947, 20, 1358, -3886 },
+ { 5464, 2109, 2398, -3194 },
+ { 5616, -407, 2140, -498 },
+ { 6121, 2707, 2379, -4096 },
+ { 7303, 1846, 2266, -4095 },
+ { 5444, 470, 2718, -1553 },
+ { 5817, -645, 3285, -1349 },
+ { 5625, 1427, 1103, -1991 },
+ { 6041, -806, 1196, -2943 },
+ { 3050, -5722, 4070, -5460 },
+ { 3420, -4386, 4078, -5155 },
+ { 6020, -3982, 7268, -2689 },
+ { 7502, -4317, 7894, -3973 },
+ { 4156, -3558, 5247, -4316 },
+ { 4725, -4401, 7290, -1540 },
+ { 6688, -5122, 8216, -3210 },
+ { 9176, -6576, 9276, -4963 },
+ { 8706, -5708, 7987, -4621 },
+ { 7060, -3535, 6532, -3308 },
+ { 5600, -2719, 5363, -1568 },
+ { 4661, -2803, 6263, -4716 },
+ { 3673, -3636, 6147, -3433 },
+ { 5305, -2585, 6073, -2638 },
+ { 7614, -1962, 6079, -5266 },
+ { 6760, -3366, 7382, -4322 },
+ { 6385, -3883, 4797, -1353 },
+ { 8182, -5120, 4298, -4641 },
+ { 9130, -6198, 4975, -3063 },
+ { 7421, -5436, 5576, -3713 },
+ { 3483, -4898, 5443, -2745 },
+ { 4907, -5643, 6390, -4105 },
+ { 8119, -7008, 7992, -6764 },
+ { 6528, -6122, 6967, -5590 },
+ { 5890, -4190, 6624, -5688 },
+ { 6815, -7934, 7275, -5456 },
+ { 5434, -4306, 5169, -5378 },
+ { 4364, -6436, 5376, -2604 },
+ { 8152, -3404, 5913, -5048 },
+ { 7983, -4863, 4262, -2461 },
+ { 8023, -6188, 6238, -5062 },
+ { 6753, -3692, 3935, -3723 },
+ { 6826, -4760, 3284, -4051 },
+ { 7224, -7423, 4492, -3875 },
+ { 6904, -2590, 6587, -6248 },
+ { 6106, -1944, 7345, -5506 },
+ { 4956, -2990, 7808, -3146 },
+ { 6908, -6885, 5949, -1288 },
+ { 7162, -6058, 3419, -3401 },
+ { 7015, -7080, 6907, -3018 },
+ { 6971, -6832, 5646, -3273 },
+ { 8014, -5546, 5471, -1544 },
+ { 6792, -2220, 5105, -2879 },
+ { 8494, -3974, 4408, -3999 },
+ { 9591, -4866, 6027, -4558 },
+ { 5264, -5161, 6101, -738 },
+ { 5803, -6141, 5197, -5231 },
+ { 4657, -6822, 3232, -5189 },
+ { 4791, -5135, 3809, -4665 },
+ { 6108, -5103, 2379, -3873 },
+ { 4680, -3909, 3234, -5093 },
+ { 5802, -3853, 3795, -4984 },
+ { 4360, -7483, 4802, -3877 },
+ { 5429, -7517, 5911, -3717 },
+ { 6866, -2280, 4880, -4634 },
+ { 10131, -4628, 4414, -4092 },
+ { 10811, -5189, 7746, -5337 },
+ { 5663, -8941, 5287, -5680 },
+ { 8023, -5991, 7403, -2796 },
+ { 9669, -6919, 6525, -4932 },
+ { 7275, -3796, 4962, -2547 },
+ { 8848, -4806, 5677, -3080 },
+ { 8128, -4308, 7749, -6569 },
+ { 4032, -5196, 2282, -6239 },
+ { 6593, 700, -229, 304 },
+ { 8260, 539, -66, -1259 },
+ { 6605, 176, -814, -109 },
+ { 8057, 0, -1, -136 },
+ { 7382, -38, -484, -1129 },
+ { 8373, -929, 682, -454 },
+ { 7674, 690, -1278, 546 },
+ { 7326, -517, 406, -1283 },
+ { 7612, -1715, -1167, 1175 },
+ { 8590, 441, -782, -710 },
+ { 8572, -1202, -291, 260 },
+ { 7308, -147, -1785, 414 },
+ { 6787, -353, -672, 934 },
+ { 5177, -133, 179, 82 },
+ { 4161, -34, 447, 1497 },
+ { 5997, -902, 1533, -121 },
+ { 5727, -871, -1370, 945 },
+ { 8386, -252, 293, -823 },
+ { 6573, -1354, 682, 616 },
+ { 7650, -2096, 725, 457 },
+ { 8122, 78, 636, -1400 },
+ { 8421, 428, -1620, 131 },
+ { 7341, -1292, -717, 186 },
+ { 7998, -49, -720, 266 },
+ { 5987, -351, 669, 844 },
+ { 7314, -1620, 250, -603 },
+ { 7219, -1562, -572, 1994 },
+ { 8682, -358, -290, -388 },
+ { 5810, 155, -178, 1199 },
+ { 7246, -12, 1042, -786 },
+ { 7357, -923, 1468, -475 },
+ { 7801, 621, -212, -724 },
+ { 5346, -514, 1210, 1356 },
+ { 8459, 36, -127, -779 },
+ { 6878, -2429, 854, 1750 },
+ { 7280, -1401, -1353, 2845 },
+ { 7579, -2148, -1463, 2087 },
+ { 6637, 946, -872, 750 },
+ { 4807, -1100, 1289, 2602 },
+ { 4495, 219, 1551, 1128 },
+ { 7639, 506, 446, -1107 },
+ { 6359, 188, 1009, -115 },
+ { 6641, -1820, 1655, 723 },
+ { 5394, -2382, 1604, 2542 },
+ { 6021, -2644, 2396, 1407 },
+ { 4698, 882, 245, 1525 },
+ { 8103, 573, -798, -349 },
+ { 8045, -519, 997, -1092 },
+ { 7571, -122, 227, -338 },
+ { 5347, -1200, 630, 1718 },
+ { 7070, 790, 218, -544 },
+ { 7440, 728, -527, -20 },
+ { 6402, -355, 197, -736 },
+ { 4031, 771, 866, 1895 },
+ { 6009, 896, 445, -31 },
+ { 5160, 1098, -856, 1784 },
+ { 7980, -886, -1293, 1396 },
+ { 6318, -1361, 2423, 252 },
+ { 7547, -699, 133, 506 },
+ { 8562, -2344, 940, 264 },
+ { 5890, 1187, -1425, 2194 },
+ { 6558, -645, -1311, 2621 },
+ { 4634, -1671, 2075, 1623 },
+ { 5614, 105, -816, 2376 },
+ { 6646, 1558, -1365, 630 },
+ { 6998, 1150, -2117, -990 },
+ { 6555, 2311, -1093, -1783 },
+ { 6682, 1430, -2391, -1940 },
+ { 7861, 1555, -2977, -1188 },
+ { 6745, 1723, -459, -2085 },
+ { 7504, 1229, -1666, -2060 },
+ { 7937, 671, -2128, -1529 },
+ { 7139, 991, -735, -2632 },
+ { 6867, 1592, -1303, -2324 },
+ { 6401, 2230, -1732, -2508 },
+ { 7201, 2184, -2169, -1988 },
+ { 6636, 2190, -995, -2840 },
+ { 7620, 2306, -2089, -651 },
+ { 7584, 1875, -1438, -631 },
+ { 9214, 1561, -2464, -1139 },
+ { 6154, 1318, -1237, -2917 },
+ { 7917, 2847, -1797, -1599 },
+ { 8309, 2029, -2555, -465 },
+ { 8204, 1282, -584, -2405 },
+ { 8440, 1035, -1147, -1137 },
+ { 7107, 1858, -60, -1568 },
+ { 6781, 2912, -873, -1463 },
+ { 7603, 1316, -319, -1249 },
+ { 7833, 1335, -78, -1849 },
+ { 7930, 1141, -1016, -695 },
+ { 7883, 1610, -1017, -1314 },
+ { 8069, 1409, -1811, -196 },
+ { 8319, 1031, -582, -1590 },
+ { 5948, 1537, -2153, -2373 },
+ { 8684, 1171, -1871, -850 },
+ { 8357, 2484, -2411, -1292 },
+ { 6516, 2092, -193, -1167 },
+ { 6112, 1697, 22, -525 },
+ { 7161, 703, -602, -1879 },
+ { 6047, 2351, -807, -219 },
+ { 8072, 1854, -1817, -1553 },
+ { 6956, 1304, 76, -1011 },
+ { 6607, 1481, -544, -162 },
+ { 6958, 2541, -265, -1938 },
+ { 6416, 2514, -777, -850 },
+ { 7272, 2110, -899, -1171 },
+ { 7741, 2153, -283, -2614 },
+ { 6482, 2041, -1758, -1221 },
+ { 6762, 940, -1862, -2281 },
+ { 5610, 1194, -1691, -1561 },
+ { 7833, 2164, -823, -1952 },
+ { 5460, 1438, -848, 1189 },
+ { 6011, 1377, -771, -1557 },
+ { 7679, 544, -1134, -2214 },
+ { 7209, 1292, -2714, -1564 },
+ { 5567, 1200, -404, -169 },
+ { 5853, 1461, -1465, -518 },
+ { 6782, 689, -844, -860 },
+ { 7330, 1337, -1152, -71 },
+ { 7189, 1506, -653, -685 },
+ { 6860, 2116, -1403, -240 },
+ { 8804, 1516, -1391, -1760 },
+ { 7210, 2689, -1498, -989 },
+ { 7030, 3022, -1441, -2083 },
+ { 5649, 1836, -407, 525 },
+ { 7451, 3099, -717, -2464 },
+ { 7384, 1656, -2007, 398 },
+ { 6504, 707, -1919, -134 },
+ { -1851, 3639, -2279, -695 },
+ { -4037, 1644, -77, 1329 },
+ { -4025, 1960, -1565, -567 },
+ { -3430, 2495, -795, 368 },
+ { -4771, 2480, 993, 756 },
+ { -3431, 2058, -2539, -971 },
+ { -3802, 3418, 380, 217 },
+ { -3074, 3350, -1652, -1056 },
+ { -3705, 326, -1650, 1535 },
+ { -3122, 1281, -1192, 1607 },
+ { -4601, 1367, -968, 53 },
+ { -3808, 958, 44, 2560 },
+ { -2079, 2530, -1485, 1166 },
+ { -3707, 343, -2889, 180 },
+ { -5249, 1431, -31, 688 },
+ { -4990, 125, -704, 1270 },
+ { -2771, 1334, -2446, 746 },
+ { -2292, 994, -1527, 2630 },
+ { -1261, 3070, -2519, 268 },
+ { -2544, 3890, -1057, -552 },
+ { -4421, 255, -1980, 530 },
+ { -2951, 454, -13, 3643 },
+ { -2262, 1815, -370, 2880 },
+ { -2383, 3657, -649, 576 },
+ { -3541, -161, -1389, 2550 },
+ { -4241, 1575, 1325, 2561 },
+ { -2767, 4037, 1221, 1578 },
+ { -3748, 2697, 1148, 1801 },
+ { -4686, 2385, -220, 0 },
+ { -1531, 1645, -2751, 1327 },
+ { -45, 4032, -799, 2298 },
+ { -2915, 2280, 709, 2495 },
+ { -1199, 3278, -406, 2346 },
+ { -2471, 116, -2706, 2060 },
+ { -2440, 2173, -2894, -344 },
+ { -3375, 2287, 1781, 3226 },
+ { -2153, 3568, 1827, 2918 },
+ { -862, 2267, -1626, 2527 },
+ { -2698, 1135, 301, 4239 },
+ { -2364, 2123, 1010, 3710 },
+ { -2447, 3281, -81, 1408 },
+ { -2660, 4735, 472, 258 },
+ { -1053, 3097, 2682, 2398 },
+ { -3366, -1037, -1152, -868 },
+ { -643, 4242, 2212, 1259 },
+ { 971, 3991, 934, 643 },
+ { -1617, 2002, 2139, 2195 },
+ { -4897, 972, 784, 1719 },
+ { -1275, 2992, 1039, 3821 },
+ { -392, 4973, -209, 1821 },
+ { -1028, 4718, -1479, -137 },
+ { 50, 3914, 553, 2210 },
+ { 678, 4364, 359, 1303 },
+ { -582, 4911, 514, 1671 },
+ { 1276, 3914, -1252, 2934 },
+ { -1496, 3984, 857, 2330 },
+ { 772, 4744, -655, 2332 },
+ { -799, 5283, -439, 624 },
+ { 1341, 2937, 650, 2027 },
+ { -1739, 4892, 1275, 1702 },
+ { -892, 2596, -151, 3951 },
+ { -3532, 1090, 1292, 32 },
+ { 321, 3146, 2647, 1475 },
+ { 264, 4199, -1591, 1317 },
+ { -452, -2357, 2266, 4192 },
+ { 3022, -1033, -2389, 5678 },
+ { -1162, -1342, 3543, 4990 },
+ { -474, -1477, -1223, 5016 },
+ { -699, -2857, 900, 3835 },
+ { -461, -2255, -117, 4626 },
+ { 1204, -2062, -1211, 4403 },
+ { 2192, -3035, -337, 3966 },
+ { 108, -831, 279, 5643 },
+ { 1457, -620, -2908, 5276 },
+ { -2527, -78, 1085, 5460 },
+ { -1978, -1918, -949, 4733 },
+ { 32, 367, -1904, 5166 },
+ { 1890, -1665, 440, 4752 },
+ { -518, -348, 2816, 4891 },
+ { 3695, -2490, -1374, 4603 },
+ { 246, -1965, 3549, 3969 },
+ { 1100, -3111, 656, 3737 },
+ { -1379, 870, -414, 4575 },
+ { 628, -357, -1227, 6179 },
+ { -1129, -1318, -2457, 4576 },
+ { -425, -98, -73, 6336 },
+ { 367, -887, 2990, 4207 },
+ { 2091, -1251, 2444, 3557 },
+ { -1759, -1610, 2046, 5273 },
+ { 3210, 1414, -20, 2616 },
+ { 3303, -2636, 1005, 4237 },
+ { -327, -3107, -640, 3687 },
+ { -197, 764, 572, 5486 },
+ { 646, -767, 1388, 5464 },
+ { 104, 2742, -228, 3907 },
+ { -236, 1829, -579, 4585 },
+ { -2150, -474, -1525, 4006 },
+ { -23, -2632, -2400, 3892 },
+ { -12, -1739, -2910, 4867 },
+ { -2310, -368, -102, 4583 },
+ { -1991, -2061, 533, 4531 },
+ { 3884, -1446, -153, 4393 },
+ { 1568, 14, -289, 5268 },
+ { -1376, -253, -2797, 3417 },
+ { 3193, -2577, 2475, 3566 },
+ { 3418, 617, 1350, 1857 },
+ { 3792, -24, -272, 3370 },
+ { 153, 1159, 2906, 2877 },
+ { 511, 2162, 1548, 2741 },
+ { 262, 819, -2791, 3734 },
+ { 4232, -2015, 1486, 3477 },
+ { 2943, -1110, -1014, 5480 },
+ { 2842, 369, 703, 3476 },
+ { 3011, 1634, -933, 3553 },
+ { 4412, -1548, -942, 5021 },
+ { -1405, 593, 2372, 5267 },
+ { 2093, 2129, 896, 2365 },
+ { 4845, -1980, 0, 3823 },
+ { -2140, 81, 3278, 5637 },
+ { 1484, 2665, -324, 3653 },
+ { 10, 192, 1620, 5291 },
+ { 2152, 738, -2269, 5000 },
+ { 2102, 2748, -1652, 4707 },
+ { 2855, -2131, -387, 5188 },
+ { 1173, 676, 1338, 3277 },
+ { 2340, -2329, -2064, 4095 },
+ { 861, -2024, 1296, 5055 },
+ { 2189, 3225, -695, 2626 },
+ { 6196, -7079, 1943, -822 },
+ { 4547, -4813, 3261, 1856 },
+ { 4243, -6904, 3443, 448 },
+ { 4581, -7503, 946, 506 },
+ { 6626, -7754, 3427, 470 },
+ { 3407, -9088, 3269, -1496 },
+ { 4079, -6464, 2304, 777 },
+ { 5621, -9336, 2684, -768 },
+ { 5351, -6464, 5238, -214 },
+ { 5961, -8007, 1724, -3091 },
+ { 4213, -8067, 603, -246 },
+ { 7208, -7403, 3168, -1738 },
+ { 6098, -7700, 329, -1379 },
+ { 6525, -6735, 4248, -1072 },
+ { 6073, -6241, 2167, -2378 },
+ { 4609, -9218, 3051, -1033 },
+ { 6813, -7283, 1581, -1897 },
+ { 6126, -6275, 2789, 681 },
+ { 4423, -6538, 1621, -1692 },
+ { 6272, -8298, 3167, -1855 },
+ { 6172, -8558, 4498, -1169 },
+ { 4844, -8588, 1647, -366 },
+ { 6209, -8807, 1581, -369 },
+ { 5389, -8059, 550, -192 },
+ { 6654, -9775, 2504, -1063 },
+ { 7103, -7998, 806, 530 },
+ { 5662, -6736, 1565, -3620 },
+ { 4165, -9564, 4191, -2131 },
+ { 4526, -7181, 576, -2875 },
+ { 4633, -8623, 2807, -4742 },
+ { 3709, -7794, 1815, 34 },
+ { 3634, -8622, 2313, -826 },
+ { 6991, -8447, 2063, -3198 },
+ { 7757, -9486, 2255, -558 },
+ { 4149, -7778, 4728, -1696 },
+ { 5767, -7427, 1113, 707 },
+ { 4592, -6261, 2329, 1864 },
+ { 3159, -10498, 1677, -4273 },
+ { 3534, -9010, 2437, -3565 },
+ { 4479, -10821, 2715, -4942 },
+ { 3207, -9805, 3054, -3886 },
+ { 4627, -8189, 3018, -2354 },
+ { 5527, -10566, 3244, -2749 },
+ { 4346, -10127, 3335, -3084 },
+ { 6132, -10085, 3316, -1308 },
+ { 5629, -9704, 2178, -3058 },
+ { 3603, -8538, 1246, -624 },
+ { 3737, -8488, 395, -3167 },
+ { 5465, -11414, 2810, -4640 },
+ { 5306, -7745, 2721, -3988 },
+ { 7000, -9111, 1695, -1409 },
+ { 6663, -7741, 2466, -4079 },
+ { 4083, -7175, 1836, -4831 },
+ { 3613, -9926, 1342, -3455 },
+ { 6588, -8033, 457, -258 },
+ { 4720, -8102, 17, -1209 },
+ { 7414, -8709, 1294, -344 },
+ { 5437, -10030, 4043, -1704 },
+ { 4862, -9281, 1558, -1431 },
+ { 6800, -6403, 5113, 862 },
+ { 4623, -8242, 2667, -228 },
+ { 5919, -5083, 3348, 2135 },
+ { 5985, -8889, 2733, -5105 },
+ { 5029, -5767, 4407, 719 },
+ { 354, -6158, -838, -3001 },
+ { 351, -5943, -2104, -1534 },
+ { -633, -7190, -25, -4798 },
+ { -1595, -7235, -3812, -1400 },
+ { 103, -6197, -2933, -78 },
+ { -1722, -5020, -3441, -4333 },
+ { -1963, -5644, -4365, -270 },
+ { -846, -5743, -3477, 196 },
+ { -191, -5348, -4054, -469 },
+ { -2515, -7754, -3495, -818 },
+ { -2090, -6710, -2701, 117 },
+ { -546, -7036, -1398, 163 },
+ { -278, -7091, -2662, -536 },
+ { -622, -7962, -2731, -1464 },
+ { -1555, -8118, -3612, -2057 },
+ { -1094, -6280, -2314, 505 },
+ { -2556, -8538, -4024, -2247 },
+ { 109, -7134, -3107, -1823 },
+ { -900, -6954, -3340, -717 },
+ { -605, -7113, -3656, -2154 },
+ { 837, -6263, -3211, -2177 },
+ { -417, -5810, -3871, -1469 },
+ { -1318, -5649, -4207, -3198 },
+ { 413, -6765, -2082, -33 },
+ { -3101, -6450, -4362, -766 },
+ { 755, -6489, -2967, -846 },
+ { 1117, -7106, -2452, -1352 },
+ { -1202, -8387, -3072, -2897 },
+ { -365, -4894, -3561, -2937 },
+ { -2372, -8776, -265, -4441 },
+ { -1224, -8678, -896, -5074 },
+ { -755, -10096, -600, -6623 },
+ { 300, -8206, -225, -4568 },
+ { -1176, -6824, -2633, -3527 },
+ { -2006, -5443, -1526, -5849 },
+ { -1115, -5540, -2363, -4785 },
+ { 1059, -6812, -2543, -2654 },
+ { -1976, -6861, -3062, -5508 },
+ { -379, -5328, -2321, -3624 },
+ { -2108, -5860, -4518, -1915 },
+ { -379, -7885, -1329, -594 },
+ { 774, -5389, -581, -5213 },
+ { -2601, -5083, -1849, -4921 },
+ { -176, -5580, 74, -5075 },
+ { -204, -6780, -190, -6232 },
+ { 418, -7594, -1987, -820 },
+ { -1873, -8529, -2926, -1609 },
+ { 1340, -6362, -919, -4975 },
+ { 577, -7990, -2044, -1873 },
+ { -2572, -7413, -1745, -2224 },
+ { -2037, -7030, -1461, -7138 },
+ { -2559, -8756, -2039, -5836 },
+ { -2079, -6764, -1209, -5669 },
+ { -1613, -7801, -2006, -685 },
+ { -1865, -6583, -722, -3529 },
+ { -589, -6358, -1377, -1003 },
+ { -540, -7514, -1331, -3542 },
+ { 419, -6192, -1677, -4927 },
+ { -2786, -8763, -2966, -5065 },
+ { -2172, -8411, -1726, -4675 },
+ { -3382, -9833, -3497, -5722 },
+ { -2433, -10169, -2077, -5775 },
+ { -424, -9451, -1096, -3658 },
+ { -537, -8522, -910, -1897 },
+ { -5550, 2807, 1683, -693 },
+ { -6395, 635, 3573, -1246 },
+ { -7544, 2280, 2140, 44 },
+ { -8751, 1136, 2951, -794 },
+ { -5605, 2709, 2052, 916 },
+ { -7650, 654, 869, 135 },
+ { -6939, 967, 1409, 870 },
+ { -7834, 2123, 3310, 974 },
+ { -6935, 2818, 1274, -1678 },
+ { -5605, 2233, 1013, 471 },
+ { -7095, 1849, 1648, 198 },
+ { -6636, 1634, 712, -37 },
+ { -7279, 978, 296, -315 },
+ { -7664, 3504, 3292, -216 },
+ { -7836, 1209, 1221, -257 },
+ { -7913, 2201, 1765, -1529 },
+ { -7077, 3783, 2632, -1407 },
+ { -5565, 1645, 1410, -622 },
+ { -6494, 2879, 1181, -759 },
+ { -7073, 3137, 3010, 550 },
+ { -7249, 1839, 847, -805 },
+ { -6630, 2197, 282, -1096 },
+ { -8836, 1573, 1988, -1090 },
+ { -7809, 1274, 836, -1198 },
+ { -7895, 2970, 3511, -1097 },
+ { -6960, 1664, 1356, -2442 },
+ { -6582, 2866, 2273, 307 },
+ { -7221, 821, 2851, -1435 },
+ { -6015, 1703, 2001, -2367 },
+ { -8082, 1034, 2103, 239 },
+ { -5952, 1912, 301, -465 },
+ { -6099, 841, 379, 567 },
+ { -6343, 50, 494, 658 },
+ { -6586, 983, 591, -893 },
+ { -5500, 869, 2187, -2479 },
+ { -6482, 60, 1545, -979 },
+ { -6705, 515, 1974, -53 },
+ { -6460, 1755, 1325, -1275 },
+ { -6093, 2617, 2465, -623 },
+ { -7330, 2161, 594, -2115 },
+ { -7324, 762, 1593, -2004 },
+ { -6385, 679, 1510, -2514 },
+ { -6159, 241, 2976, -1631 },
+ { -8583, 3030, 4045, -162 },
+ { -6299, 66, 2209, -2103 },
+ { -5428, 1279, 3267, -1846 },
+ { -6438, 1335, 2728, -1631 },
+ { -8012, 1070, 2428, -1151 },
+ { -6201, 2781, 2349, -1918 },
+ { -5918, 1139, 3121, -148 },
+ { -6314, 2481, 3137, -1808 },
+ { -7180, 1722, 2435, -1602 },
+ { -6750, 1829, 3763, -1145 },
+ { -6713, 1777, 2221, 1212 },
+ { -7479, 1835, 3627, -479 },
+ { -7299, 10, 2406, -1593 },
+ { -8249, 3129, 996, -2870 },
+ { -8374, 1534, 1333, -1882 },
+ { -7507, 3353, 1598, -2299 },
+ { -7379, 2701, 2326, -1167 },
+ { -8440, 2276, 2796, -542 },
+ { -10348, 1527, 2649, -1165 },
+ { -8184, 3614, 2574, -1738 },
+ { -5539, 1574, 1733, 1138 },
+ { 9404, -7652, 67, 79 },
+ { 8654, -3972, 1358, -60 },
+ { 8617, -4794, 117, 2318 },
+ { 7886, -4505, 1784, 1200 },
+ { 8636, -6125, 3879, -1003 },
+ { 9654, -6836, 1816, 205 },
+ { 9374, -6553, 913, 1875 },
+ { 8020, -6150, 1134, 2390 },
+ { 7786, -4970, 2078, -1857 },
+ { 8691, -6119, 711, 708 },
+ { 9039, -5568, 2944, -1902 },
+ { 9955, -5048, 1433, -601 },
+ { 8089, -6927, 3093, -2846 },
+ { 8487, -7024, 2415, 19 },
+ { 9388, -5287, 3577, -2655 },
+ { 8591, -7371, 2300, -996 },
+ { 9104, -4763, 1453, -2558 },
+ { 7615, -5457, 596, 164 },
+ { 9860, -7047, 3433, -614 },
+ { 8756, -4404, 2235, -964 },
+ { 9462, -4660, 299, -1822 },
+ { 10119, -5550, 2689, -1273 },
+ { 10915, -7471, 2705, -1007 },
+ { 11433, -7090, 1410, -1198 },
+ { 9882, -7431, 2965, -1895 },
+ { 7628, -5219, 769, -2661 },
+ { 8169, -5318, 2262, 70 },
+ { 8846, -6320, 1939, -754 },
+ { 7147, -5593, 1248, -971 },
+ { 10652, -5485, 935, 137 },
+ { 7778, -6533, 2564, -1932 },
+ { 8878, -5173, 1214, -361 },
+ { 9828, -4943, 282, 510 },
+ { 10042, -6134, 3895, -1914 },
+ { 7965, -6630, 3566, -433 },
+ { 8573, -4502, 3574, -1209 },
+ { 8398, -4801, 1031, -1347 },
+ { 10136, -7772, 2612, 1547 },
+ { 9890, -7280, 1768, -1083 },
+ { 8407, -6585, -706, -58 },
+ { 7976, -7582, 229, -131 },
+ { 10481, -8866, 1166, -147 },
+ { 10914, -4342, 3189, -2412 },
+ { 10440, -5198, -104, -1109 },
+ { 11227, -6530, 2381, -2449 },
+ { 8487, -8064, 1086, 230 },
+ { 9975, -6123, -857, -134 },
+ { 8339, -6498, 1232, -2337 },
+ { 11042, -4506, 1119, -2098 },
+ { 12563, -5592, 1837, -2062 },
+ { 11801, -5590, 632, -1296 },
+ { 10152, -5617, 1511, -1917 },
+ { 7800, -6473, 51, -1337 },
+ { 7941, -5560, 2438, -3270 },
+ { 6554, -3834, 2100, 1476 },
+ { 9065, -5520, -226, -1120 },
+ { 10794, -7120, -243, 122 },
+ { 10429, -6968, 272, -806 },
+ { 8942, -8914, 1442, -392 },
+ { 9969, -5051, 2033, -2953 },
+ { 7275, -4152, 3058, -64 },
+ { 11127, -5488, 4589, -3227 },
+ { 9626, -6666, 2739, -2958 },
+ { 6943, -5362, 4470, 1008 },
+ { -7456, -967, 2936, -1002 },
+ { -8622, -333, 6962, 2606 },
+ { -7486, -3392, 3668, 1287 },
+ { -8053, -827, 5148, 1097 },
+ { -6610, 454, 4952, 96 },
+ { -7701, -1982, 3161, -468 },
+ { -7307, -1132, 4071, -36 },
+ { -8125, -271, 5199, 3862 },
+ { -9182, -1950, 2813, 1878 },
+ { -9855, -952, 4794, 3010 },
+ { -7241, 1431, 4202, 2468 },
+ { -9646, 157, 4766, 1046 },
+ { -9371, 1230, 6009, 2958 },
+ { -11514, -64, 8630, 5248 },
+ { -6766, 565, 2766, 2140 },
+ { -8426, -9, 2852, 1271 },
+ { -11291, -1113, 5087, 2937 },
+ { -8297, 2092, 4495, 1264 },
+ { -9983, 735, 3809, -51 },
+ { -9048, -1000, 3191, -308 },
+ { -7331, -1987, 2655, 1391 },
+ { -7144, -21, 4333, 2161 },
+ { -6032, -1540, 3543, 896 },
+ { -7987, -1036, 1985, 1529 },
+ { -9264, 2004, 5194, 290 },
+ { -11308, -840, 5754, 1654 },
+ { -9130, -2398, 4292, 2973 },
+ { -6248, 838, 3563, 1223 },
+ { -6819, -2760, 3511, 119 },
+ { -7213, -2006, 4364, 762 },
+ { -5431, -1047, 4533, 166 },
+ { -7098, -641, 2021, 639 },
+ { -8628, -2249, 3588, 399 },
+ { -6352, -1498, 3560, -648 },
+ { -7033, -2190, 4870, 2562 },
+ { -7405, -46, 3772, -581 },
+ { -6104, 796, 5143, 1965 },
+ { -5787, 943, 5784, 3030 },
+ { -8367, 1465, 7192, 4097 },
+ { -8259, 789, 5694, 1963 },
+ { -10614, -1899, 5748, 2645 },
+ { -8258, -805, 3698, 2275 },
+ { -6877, -972, 6431, 3160 },
+ { -6483, 363, 7018, 3129 },
+ { -6283, -1358, 5191, 1524 },
+ { -8853, -3157, 4119, 1741 },
+ { -6086, -267, 3883, -835 },
+ { -7254, 1032, 6613, 4017 },
+ { -11470, -3350, 4649, 3426 },
+ { -6743, 481, 6148, 1239 },
+ { -5394, -166, 5309, 3165 },
+ { -7958, 1068, 4268, -240 },
+ { -10520, 2256, 7916, 2828 },
+ { -5132, -4, 5739, 1176 },
+ { -8643, 120, 3255, -629 },
+ { -9631, 1974, 8870, 4362 },
+ { -10663, -1221, 3733, 589 },
+ { -8224, -1843, 5806, 2655 },
+ { -8282, 1255, 8647, 3478 },
+ { -12311, -1505, 9043, 6256 },
+ { -11312, -856, 7136, 4681 },
+ { -11944, -722, 7941, 3309 },
+ { -7868, -463, 6846, 4196 },
+ { -8679, -241, 7410, 5347 },
+ { 6759, -4680, -508, 1220 },
+ { 5176, -6111, 944, 121 },
+ { 6843, -5667, -1368, -533 },
+ { 5616, -5884, -1471, -695 },
+ { 6030, -5089, -1808, -940 },
+ { 7444, -5463, -52, 1881 },
+ { 4207, -6079, -506, 1571 },
+ { 6785, -4410, -649, 3084 },
+ { 4838, -5214, 2026, 2998 },
+ { 4201, -5790, 645, 1811 },
+ { 6930, -5129, -1940, 1698 },
+ { 6332, -4627, 692, 3027 },
+ { 6285, -4314, -106, 3644 },
+ { 6255, -5450, -1975, 742 },
+ { 4199, -4676, -459, 1796 },
+ { 5592, -5500, 1345, 1300 },
+ { 4358, -5556, -2236, 114 },
+ { 4620, -5875, -1563, 888 },
+ { 4892, -7550, -327, -419 },
+ { 4734, -7085, 7, 613 },
+ { 3883, -5562, -1969, 1080 },
+ { 5610, -4990, -204, 834 },
+ { 4117, -6482, -1271, 341 },
+ { 6585, -5107, 892, 1169 },
+ { 6632, -3683, 302, 3002 },
+ { 6326, -5351, -983, -1250 },
+ { 4382, -7192, -730, -158 },
+ { 5227, -6540, -451, 1123 },
+ { 5468, -6472, -870, -1471 },
+ { 5191, -6402, -1365, -127 },
+ { 7407, -6317, -973, -336 },
+ { 4611, -6530, -820, -1980 },
+ { 4963, -5159, -2050, -966 },
+ { 4414, -5691, -211, -998 },
+ { 5954, -5873, 750, -1749 },
+ { 4394, -4796, -1268, 254 },
+ { 7161, -6214, -1010, 689 },
+ { 4965, -3598, 2372, 1711 },
+ { 6248, -6180, 981, 864 },
+ { 6473, -5336, 525, -600 },
+ { 4591, -6864, -1131, -900 },
+ { 6314, -6440, -1021, -375 },
+ { 5838, -6209, -1199, 944 },
+ { 5308, -5283, -2100, 1267 },
+ { 4342, -5860, -1637, -1356 },
+ { 5680, -4388, -1227, -104 },
+ { 4900, -4098, 1449, 4046 },
+ { 4677, -4284, -106, 3190 },
+ { 7574, -6173, -848, 1859 },
+ { 6493, -7207, -131, 726 },
+ { 5513, -5261, -2117, 4 },
+ { 6191, -7352, -193, -505 },
+ { 5885, -4333, 324, -134 },
+ { 6162, -6081, -312, -2044 },
+ { 4216, -6200, -1810, -572 },
+ { 5652, -7035, -696, -197 },
+ { 7131, -7189, -366, -60 },
+ { 5032, -4803, -1514, 2832 },
+ { 7386, -4610, -606, 3489 },
+ { 4211, -5031, 1221, 3047 },
+ { 4050, -4653, 1584, 1469 },
+ { 6852, -5302, -1861, 206 },
+ { 7736, -4816, -1794, 3359 },
+ { 6290, -3439, 1522, 2454 },
+ { 1768, 5990, -5560, -2594 },
+ { 3903, 5326, -1530, -1501 },
+ { 2472, 3738, -2117, -4240 },
+ { 3260, 5448, -904, -4733 },
+ { 1435, 7297, -3676, -4102 },
+ { 4096, 5951, -656, -3312 },
+ { 2178, 6009, -3146, -3724 },
+ { 3787, 5493, -5473, -1633 },
+ { 2998, 7286, -3334, -3571 },
+ { 2894, 6576, -4708, -2804 },
+ { 830, 6163, -4286, -3348 },
+ { 4755, 5569, -1730, -2739 },
+ { 4604, 6065, -3562, -2605 },
+ { 2749, 5141, -3986, -2775 },
+ { 3942, 4875, -2143, -3340 },
+ { 2819, 8517, -2004, -2724 },
+ { 2146, 6298, -689, -3093 },
+ { 5196, 6504, -3393, -1475 },
+ { 1851, 8386, -1748, -1420 },
+ { 3474, 8572, -3534, -2688 },
+ { 4503, 7560, -3561, -2245 },
+ { 4433, 6219, -2393, -1575 },
+ { 3506, 7248, -2275, -1977 },
+ { 3490, 7409, -3147, -604 },
+ { 4214, 6447, -3520, 516 },
+ { 619, 7034, -829, -1705 },
+ { 1732, 7395, -356, -2208 },
+ { 1226, 5204, -3294, -3732 },
+ { 2027, 5619, -1813, -4146 },
+ { 3078, 5877, 47, -2651 },
+ { 1654, 5458, 424, -682 },
+ { 3163, 5464, -2026, -270 },
+ { 2884, 5375, -685, -530 },
+ { 2950, 7286, -35, -2967 },
+ { 1986, 5066, -597, 482 },
+ { 3459, 4308, -3845, -2333 },
+ { 3155, 7037, -1346, -4345 },
+ { 2193, 6696, -717, -1319 },
+ { 3677, 5089, -3892, -487 },
+ { 2186, 5136, -4186, -1492 },
+ { 773, 5796, -917, 817 },
+ { 2489, 6546, -3570, -2117 },
+ { 1223, 6469, -1362, -33 },
+ { 271, 6061, -1466, -1725 },
+ { 2540, 5171, -1847, 1032 },
+ { 2548, 5251, -2697, 1677 },
+ { 771, 7600, -768, -632 },
+ { 4710, 6647, -4736, -1275 },
+ { 1369, 5917, -2971, -1056 },
+ { 163, 5239, -3499, -2275 },
+ { 2104, 4285, -3211, -3286 },
+ { 1107, 7411, -1972, -1671 },
+ { 2196, 7262, -2310, -1926 },
+ { -244, 6439, -1745, -839 },
+ { 3293, 3832, -2890, -3000 },
+ { 419, 6443, -379, -407 },
+ { 3077, 4930, -1156, -2869 },
+ { 2131, 5874, -2330, 224 },
+ { 690, 6538, -2212, -2841 },
+ { 1602, 4421, -2515, 1542 },
+ { 3318, 9373, -3032, -3477 },
+ { 5646, 7462, -5153, -1463 },
+ { 4139, 7137, -1539, -3321 },
+ { 3481, 9077, -1645, -3653 },
+ { -7747, 375, -106, -543 },
+ { -8587, -1379, -586, -461 },
+ { -10146, -892, 2094, 694 },
+ { -8103, 382, 504, -325 },
+ { -8548, -92, 94, -656 },
+ { -7460, 38, 152, 388 },
+ { -8266, -271, -459, -883 },
+ { -7935, -664, -1026, -802 },
+ { -8341, -109, 853, 161 },
+ { -8802, -1355, 1099, 630 },
+ { -8957, -6, 1108, -669 },
+ { -7260, -1520, -43, -407 },
+ { -7555, -174, 668, -2562 },
+ { -9014, -126, 227, -1191 },
+ { -8184, 769, 290, -1375 },
+ { -9476, 55, 962, -1528 },
+ { -8679, 541, 755, -1030 },
+ { -9842, -1626, 838, -1588 },
+ { -8513, -702, 788, -1998 },
+ { -10101, -1558, -366, -1841 },
+ { -8135, 78, 1479, -1813 },
+ { -9128, -454, 313, -1786 },
+ { -7554, -1084, 831, -2442 },
+ { -7576, -701, 2068, -1665 },
+ { -7791, -1481, 1587, -1808 },
+ { -6701, -596, -97, 802 },
+ { -7418, -15, 684, -963 },
+ { -7127, -477, -139, -426 },
+ { -8097, -110, -36, -264 },
+ { -7620, -1922, -590, -101 },
+ { -7647, -1201, 279, 660 },
+ { -7856, -1974, 758, -2271 },
+ { -8496, -167, 2232, -1143 },
+ { -8506, -1359, 624, -740 },
+ { -7274, -1052, 1062, -139 },
+ { -7800, -217, 91, -1794 },
+ { -7030, -1694, -955, 615 },
+ { -9020, -1864, 101, -2182 },
+ { -9400, -740, 598, -667 },
+ { -8448, -1184, 2024, -1272 },
+ { -8812, -570, -897, -2384 },
+ { -10559, -1286, 538, -1536 },
+ { -8728, -888, -1089, -1397 },
+ { -7080, -1185, 636, -1252 },
+ { -9880, 233, 2344, -782 },
+ { -7952, -1326, -378, -1947 },
+ { -7207, -378, 1408, -2237 },
+ { -8467, -1545, 902, -1987 },
+ { -9163, -1474, 924, -1739 },
+ { -8159, -992, -77, -2744 },
+ { -8343, 148, -423, -1573 },
+ { -9105, -649, -254, -1214 },
+ { -8939, 456, 281, -1905 },
+ { -8837, 179, -394, -2634 },
+ { -9145, 757, 1547, -1319 },
+ { -9775, -723, 441, -1680 },
+ { -8910, -686, 1529, -1525 },
+ { -9492, -1134, 2064, -938 },
+ { -6111, -943, 677, -31 },
+ { -7411, -613, -814, 46 },
+ { -9479, -922, -430, -2061 },
+ { -11298, -1268, 1318, -1117 },
+ { -8190, 832, 671, -2214 },
+ { -10453, -550, 1672, -886 },
+ { 1044, 9353, -1651, -5423 },
+ { 1034, 8149, -455, -6166 },
+ { 761, 8293, -3214, -4838 },
+ { 938, 8077, 164, -5130 },
+ { 1295, 8673, 2582, -5490 },
+ { -314, 7973, -2395, -5231 },
+ { -507, 9012, -2497, -5775 },
+ { 2396, 8314, -1022, -4673 },
+ { -1516, 8501, 1950, -4969 },
+ { -308, 7401, 1549, -4866 },
+ { -112, 8340, 3003, -4920 },
+ { -50, 9315, 1371, -5666 },
+ { -659, 9449, 2496, -5547 },
+ { 2573, 9148, -2270, -4783 },
+ { 830, 7104, -438, -3907 },
+ { 522, 10672, -677, -6483 },
+ { -1190, 10108, -510, -6518 },
+ { -427, 8271, -579, -6315 },
+ { 1602, 8113, -1927, -4418 },
+ { -2266, 8180, 448, -5190 },
+ { -1633, 8816, -226, -5771 },
+ { 759, 9481, -105, -5813 },
+ { 2254, 6679, -466, -5662 },
+ { -88, 6946, 895, -5958 },
+ { -1705, 10009, 1394, -5574 },
+ { 748, 7943, 540, -6692 },
+ { 1411, 7009, 232, -6145 },
+ { 697, 7290, -1221, -5342 },
+ { -1764, 10580, 1944, -3981 },
+ { -1334, 9124, 1195, -3903 },
+ { -905, 10067, 635, -5039 },
+ { 664, 10680, 49, -4625 },
+ { 1374, 9536, -777, -3591 },
+ { 252, 9698, -597, -2931 },
+ { 824, 9164, -1014, -2144 },
+ { 2438, 10569, -2289, -4424 },
+ { 2101, 7102, 507, -3614 },
+ { 294, 8051, -432, -1518 },
+ { -665, 10337, 547, -2852 },
+ { 1168, 11989, -492, -5427 },
+ { 1344, 6416, 302, -5061 },
+ { -1727, 12264, 1507, -4543 },
+ { 674, 10889, -902, -3605 },
+ { -582, 9504, 300, -3618 },
+ { 641, 7654, 689, -2109 },
+ { 2065, 9243, 508, -4367 },
+ { 1055, 8373, 688, -3144 },
+ { -641, 8185, 986, -3307 },
+ { 1120, 7426, 1785, -3757 },
+ { 1660, 8070, -593, -3104 },
+ { 2002, 9467, -1722, -3475 },
+ { 2361, 8368, 100, -3709 },
+ { -772, 7845, -613, -4988 },
+ { 1485, 7430, 1896, -6127 },
+ { -432, 7823, -947, -2882 },
+ { 313, 11122, -760, -4871 },
+ { 412, 8412, -283, -4231 },
+ { 1585, 10402, -1884, -3267 },
+ { 321, 6952, 773, -3016 },
+ { -105, 9014, 121, -2249 },
+ { 1585, 10313, -977, -4812 },
+ { 1619, 11869, 1306, -6876 },
+ { -1168, 8886, -81, -2500 },
+ { -395, 10886, 733, -6490 },
+ { -4949, 4274, 3992, -1054 },
+ { -4241, 5299, 4262, -1584 },
+ { -2710, 3862, 4552, -1673 },
+ { -4608, 2472, 3672, -1715 },
+ { -2843, 2816, 4003, -2326 },
+ { -5229, 2964, 5636, 90 },
+ { -4924, 3442, 5015, -1096 },
+ { -1281, 3313, 5537, -2066 },
+ { -3808, 1939, 4351, -919 },
+ { -1915, 2585, 4939, -1614 },
+ { -3470, 1843, 5562, -682 },
+ { -3800, 870, 5827, 144 },
+ { -4985, 1452, 4728, -709 },
+ { -3745, 2750, 7220, 259 },
+ { -1875, 1900, 6514, -826 },
+ { -4329, 1574, 7192, 1304 },
+ { -5408, 1444, 6208, 631 },
+ { -3327, 5312, 5707, -1541 },
+ { -6966, 3334, 4034, 1028 },
+ { -7484, 4245, 4218, -212 },
+ { -6567, 5839, 4539, -512 },
+ { -5715, 5935, 3747, -1186 },
+ { -6410, 4881, 3356, -1610 },
+ { -5146, 2590, 2850, 2172 },
+ { -5196, 4095, 2569, -373 },
+ { -5043, 6025, 4318, 692 },
+ { -5525, 4884, 3513, 370 },
+ { -6804, 7533, 5812, -488 },
+ { -5657, 2480, 4061, 1234 },
+ { -3155, 1472, 6071, 1188 },
+ { -3427, 5217, 3442, 858 },
+ { -4698, 3013, 5517, 2586 },
+ { -4449, 2226, 5418, 3580 },
+ { -6395, 3547, 5487, 2028 },
+ { -3500, 5019, 4787, 1 },
+ { -4038, 2578, 3073, 3151 },
+ { -2750, 1955, 4469, 3856 },
+ { -5696, 1659, 6118, 2469 },
+ { -4350, 1241, 6840, 3126 },
+ { -5565, 5058, 5196, 1314 },
+ { -1642, 4190, 3948, 607 },
+ { -1233, 4108, 4850, -640 },
+ { -997, 3428, 3239, 1378 },
+ { -6488, 2741, 6926, 2792 },
+ { -4188, 3763, 4235, 2018 },
+ { -3210, 3224, 5646, 1427 },
+ { -5526, 6909, 5070, -627 },
+ { -2815, 3994, 3425, 1903 },
+ { -2163, 2734, 5423, 145 },
+ { -4149, 4247, 2355, 734 },
+ { -410, 2521, 4138, -16 },
+ { -2411, 2385, 4927, 2105 },
+ { -6077, 3591, 3114, 594 },
+ { -4186, 4834, 5926, -1004 },
+ { -7315, 3369, 5966, 448 },
+ { -7042, 5721, 5771, 238 },
+ { -4466, 3907, 3535, -1751 },
+ { -2116, 3970, 6163, -1392 },
+ { -7239, 2143, 8407, 3630 },
+ { -5431, 4486, 6486, -42 },
+ { -1874, 1617, 6333, 519 },
+ { -6478, 2629, 4634, -505 },
+ { -7784, 2342, 7216, 1365 },
+ { -1154, 1432, 4831, 1544 },
+ { -4964, -5801, 1797, 506 },
+ { -4436, -6905, 1059, -1237 },
+ { -5400, -6886, 884, -290 },
+ { -6259, -7103, 523, -227 },
+ { -4819, -6450, 1412, -450 },
+ { -4056, -6213, 1725, -943 },
+ { -5642, -6091, 1357, 605 },
+ { -4196, -5678, 2187, -173 },
+ { -4726, -5126, 2470, 321 },
+ { -6642, -5091, 1507, -1005 },
+ { -5304, -5250, 1944, 1579 },
+ { -7179, -5520, 1468, -425 },
+ { -6033, -4895, 1876, -955 },
+ { -6595, -5143, 2207, 1291 },
+ { -4224, -4943, 1846, 1792 },
+ { -7128, -6950, 539, 724 },
+ { -4369, -4901, 2590, 1103 },
+ { -7413, -5696, 1712, 1440 },
+ { -5885, -6821, 418, 871 },
+ { -6828, -5599, 710, -1563 },
+ { -6123, -5817, 1358, 1631 },
+ { -5291, -5622, 578, 2138 },
+ { -7171, -6004, 347, 2208 },
+ { -6083, -5251, 2132, 425 },
+ { -4329, -5721, 407, -2993 },
+ { -5326, -5056, 1119, -1837 },
+ { -5485, -5856, 185, -2389 },
+ { -6529, -5178, 403, -697 },
+ { -6719, -4412, 2726, 871 },
+ { -5126, -5629, 1835, -771 },
+ { -5622, -4361, 2973, 858 },
+ { -5282, -5895, 45, -335 },
+ { -4357, -5656, 1696, -1558 },
+ { -7139, -6659, 627, -409 },
+ { -4415, -6328, 35, 1306 },
+ { -7639, -6110, 1134, 197 },
+ { -3626, -5592, 2019, 901 },
+ { -3547, -5064, 1176, 1738 },
+ { -5075, -3899, 2087, 266 },
+ { -4086, -6311, 1479, 360 },
+ { -6210, -5220, -199, -1477 },
+ { -3910, -5063, 1356, -15 },
+ { -7616, -4977, 461, 2401 },
+ { -6118, -6131, 1258, -563 },
+ { -6127, -4968, 1286, -27 },
+ { -4121, -5852, 1113, 1476 },
+ { -5157, -4881, 1162, -662 },
+ { -4637, -5031, 1179, 709 },
+ { -5509, -5452, -397, 1224 },
+ { -4597, -6861, 646, 467 },
+ { -6247, -4043, 468, 278 },
+ { -5336, -6465, 874, -1472 },
+ { -6998, -6346, 78, -1798 },
+ { -4915, -4530, 2756, -203 },
+ { -6048, -4373, 1468, 1052 },
+ { -4273, -7100, 942, -323 },
+ { -6552, -4287, 2351, 69 },
+ { -6954, -4613, 722, 1521 },
+ { -4201, -5361, 763, -1562 },
+ { -6881, -5596, -748, 669 },
+ { -6695, -3547, -34, 1299 },
+ { -3981, -5728, 84, 111 },
+ { -4663, -4809, 2173, -1031 },
+ { -6599, -6077, 1303, 256 },
+ { -7596, -4265, -5791, -4140 },
+ { -6610, -2758, -5288, -3936 },
+ { -5880, -3865, -6563, -3088 },
+ { -7228, -5510, -7677, -3912 },
+ { -8854, -6553, -8318, -5361 },
+ { -9362, -5249, -6413, -4319 },
+ { -4418, -3110, -6368, -4358 },
+ { -5544, -4203, -6863, -5013 },
+ { -3056, -4316, -5567, -3181 },
+ { -3078, -5999, -5051, -2657 },
+ { -5884, -6292, -5756, -4013 },
+ { -4825, -4549, -5535, -4053 },
+ { -4443, -6126, -5316, -1368 },
+ { -3972, -6341, -6098, -2686 },
+ { -5751, -2781, -5398, -6230 },
+ { -4466, -6135, -5570, -3679 },
+ { -4291, -5992, -3564, -5189 },
+ { -7189, -4429, -7279, -6082 },
+ { -5076, -4433, -2748, -5366 },
+ { -6225, -2825, -6833, -5663 },
+ { -2989, -4792, -3960, -4492 },
+ { -7836, -7773, -7722, -5741 },
+ { -6559, -5703, -5844, -5589 },
+ { -7612, -5438, -4136, -3774 },
+ { -4218, -4176, -6591, -2333 },
+ { -4837, -5063, -6581, 322 },
+ { -6590, -5990, -2980, -3847 },
+ { -5558, -2971, -5489, -1932 },
+ { -7001, -5323, -4975, -1697 },
+ { -4694, -2688, -6904, -3044 },
+ { -8511, -5379, -5767, -2549 },
+ { -7548, -5412, -6522, -2572 },
+ { -6597, -4973, -6423, -1274 },
+ { -6415, -4022, -5168, -1072 },
+ { -5528, -5530, -7218, -2345 },
+ { -4845, -4805, -5943, -1227 },
+ { -6049, -7150, -6744, -2161 },
+ { -9061, -7299, -8542, -4375 },
+ { -5010, -5546, -5416, -82 },
+ { -4135, -4205, -5109, -3373 },
+ { -3311, -5869, -4007, -5061 },
+ { -5993, -6472, -3962, -4718 },
+ { -2966, -5832, -2821, -6305 },
+ { -4851, -5152, -2067, -3930 },
+ { -3620, -4441, -3362, -5836 },
+ { -4469, -5221, -4534, -5592 },
+ { -4022, -6335, -4321, -6107 },
+ { -4899, -4503, -3084, -3725 },
+ { -4490, -8276, -4620, -6236 },
+ { -6591, -4342, -7365, -4063 },
+ { -6498, -5057, -5553, 485 },
+ { -6060, -2714, -7093, -4144 },
+ { -6199, -7774, -7094, -4057 },
+ { -7536, -6424, -6415, -4265 },
+ { -7439, -2454, -6348, -4827 },
+ { -5333, -7565, -4417, -4639 },
+ { -4353, -7103, -4197, -2689 },
+ { -5229, -6549, -5129, -6804 },
+ { -6129, -7701, -5236, -4836 },
+ { -6797, -3983, -3884, -4406 },
+ { -6624, -4467, -4745, -5052 },
+ { -3324, -7596, -2720, -6553 },
+ { -5473, -6284, -1704, -4511 },
+ { -4131, -7263, -3180, -5196 },
+ { -7116, -5565, -3469, 685 },
+ { -6002, -6021, -3858, 576 },
+ { -3144, -8203, -1291, -434 },
+ { -6096, -7027, -4004, 1353 },
+ { -3943, -7709, -2344, -36 },
+ { -4510, -6767, -2642, 631 },
+ { -3657, -11541, -2570, -3984 },
+ { -5959, -8854, -1333, -867 },
+ { -6699, -8866, -1606, -344 },
+ { -3836, -7961, -2334, -2028 },
+ { -3430, -8045, -3037, -672 },
+ { -3868, -9184, -3635, -1819 },
+ { -4258, -9060, -2621, -1008 },
+ { -3595, -8693, -2022, -752 },
+ { -4573, -8048, -3166, -2622 },
+ { -4852, -7903, -1405, 256 },
+ { -4591, -7057, -1560, 965 },
+ { -6963, -7655, -980, 808 },
+ { -5179, -6641, -3356, 1196 },
+ { -7102, -6941, -2798, 2123 },
+ { -6867, -5834, -3320, -770 },
+ { -5977, -7369, -2500, -778 },
+ { -6160, -6400, -934, -2543 },
+ { -6741, -7608, -355, -1289 },
+ { -6856, -6466, -1433, -1643 },
+ { -4786, -6292, -4970, 376 },
+ { -5407, -8866, -2255, -400 },
+ { -3814, -6506, -1387, -3620 },
+ { -4998, -6137, -1200, -4092 },
+ { -5123, -9557, -2849, -1306 },
+ { -4259, -6444, -4395, -338 },
+ { -5221, -6810, -883, 1225 },
+ { -6137, -6215, -2165, 554 },
+ { -3895, -6557, -3176, -1829 },
+ { -3886, -8188, -87, -954 },
+ { -7243, -6707, -2216, -316 },
+ { -5592, -7606, 85, -432 },
+ { -3957, -7945, -504, -144 },
+ { -4617, -7624, 218, -312 },
+ { -4797, -8737, -844, -1051 },
+ { -4478, -8516, -1401, -454 },
+ { -4557, -7058, -302, -2332 },
+ { -6623, -7736, -271, -50 },
+ { -3157, -7532, -1111, -2207 },
+ { -3590, -7300, -1271, 517 },
+ { -4442, -7306, -507, 590 },
+ { -6458, -7524, -2807, 666 },
+ { -4991, -8466, -3363, -785 },
+ { -7474, -7541, -1056, -1839 },
+ { -7501, -8316, -938, -180 },
+ { -5329, -7739, -579, -2341 },
+ { -4549, -7063, -176, -3539 },
+ { -5191, -8612, -1504, -4250 },
+ { -3083, -7058, -2251, 32 },
+ { -4003, -7043, -1093, -791 },
+ { -5523, -8093, -678, -114 },
+ { -3022, -10265, -2070, -3109 },
+ { -3905, -6274, -182, -3652 },
+ { -3269, -9217, -551, -2650 },
+ { -3138, -9314, -1726, -1704 },
+ { -4420, -10339, -1744, -3459 },
+ { -4163, -8609, -2298, -4113 },
+ { -5566, -6505, -1241, -463 },
+ { -3130, -9746, -2352, -4884 },
+ { -7825, -3439, 1451, -1468 },
+ { -8451, -3318, 2360, -435 },
+ { -8462, -4130, 1438, -1024 },
+ { -9425, -4564, 1328, -689 },
+ { -11014, -3202, 2278, 2080 },
+ { -8269, -2761, -146, -440 },
+ { -7497, -2618, -166, 413 },
+ { -8250, -3060, 522, -2133 },
+ { -8365, -5366, 1347, -451 },
+ { -8589, -3979, 2943, 714 },
+ { -8111, -2572, 1272, -1748 },
+ { -7830, -5193, 605, -1484 },
+ { -8119, -4736, 2141, 256 },
+ { -7724, -4769, 1463, -812 },
+ { -7363, -3911, 2540, 4 },
+ { -7974, -3397, 2363, 1366 },
+ { -7359, -4204, 1752, -958 },
+ { -7622, -3505, 660, 916 },
+ { -9934, -3665, 3165, 828 },
+ { -8721, -4162, 62, 1718 },
+ { -9433, -4768, 2722, 1234 },
+ { -7960, -4496, 138, 1528 },
+ { -8198, -3454, -443, 631 },
+ { -7756, -2246, 655, 1137 },
+ { -8841, -3145, 1113, 829 },
+ { -7817, -3298, 1251, 230 },
+ { -9413, -2733, 323, -1862 },
+ { -9408, -4168, 1270, 1549 },
+ { -9037, -3892, -942, 283 },
+ { -8255, -3849, 1301, 1762 },
+ { -9057, -3987, -41, -682 },
+ { -9441, -4187, 2019, -111 },
+ { -9740, -3178, 1602, -871 },
+ { -8344, -2474, 1461, 1506 },
+ { -9752, -2925, 1996, 1243 },
+ { -9199, -3796, 180, 537 },
+ { -9060, -2405, 1140, -1562 },
+ { -9348, -2376, 309, -162 },
+ { -10786, -3182, -5, -1500 },
+ { -8142, -4540, -434, -826 },
+ { -7528, -2341, 1104, -73 },
+ { -9360, -2658, 3062, 56 },
+ { -8267, -2335, 2000, -1193 },
+ { -12169, -3154, 1287, -640 },
+ { -11398, -2120, 946, -1163 },
+ { -8940, -4559, 328, -1696 },
+ { -11025, -4213, 2813, 840 },
+ { -9224, -3581, 2224, 2039 },
+ { -8943, -3337, 1248, -1298 },
+ { -7900, -4042, 485, -2080 },
+ { -9221, -1947, 2191, -880 },
+ { -10762, -1800, 2516, -324 },
+ { -10095, -2238, 981, -1335 },
+ { -11908, -2808, 3255, 645 },
+ { -10640, -4105, 1283, -595 },
+ { -7663, -2863, 2467, -797 },
+ { -10712, -3854, 3710, 1538 },
+ { -10823, -2893, 1408, -801 },
+ { -9874, -3832, 256, -1638 },
+ { -10394, -3391, 2315, -94 },
+ { -11525, -4079, 4153, 2122 },
+ { -9546, -2088, 1541, 481 },
+ { -8731, -2433, 1042, 2160 },
+ { -7852, -3977, -1370, 1677 },
+ { 7072, -3420, 1398, -1741 },
+ { 6180, -1976, 1280, -3557 },
+ { 7692, -1793, 2844, -1700 },
+ { 8363, -1773, 3104, -2679 },
+ { 9213, -3266, 3756, -3542 },
+ { 9650, -2644, 1426, -1318 },
+ { 7712, -2796, 3686, -1975 },
+ { 7316, -3517, 2821, -622 },
+ { 7434, -2594, 2305, -2264 },
+ { 7237, -1797, 255, -3114 },
+ { 8663, -1983, 1338, -3056 },
+ { 6616, -952, 4059, -2652 },
+ { 8823, -1327, 1362, -1356 },
+ { 9938, -1722, 1287, -2362 },
+ { 7207, -1057, 1913, -1315 },
+ { 7508, -1585, 870, -1982 },
+ { 8217, -3680, 1417, -3170 },
+ { 8329, -2541, 1684, -585 },
+ { 8062, -2335, 252, -2800 },
+ { 8204, -4108, 3097, -2569 },
+ { 7701, -3367, 576, -3008 },
+ { 7350, -786, 2414, -2129 },
+ { 6948, -2568, 1607, -225 },
+ { 7684, -2387, 1308, -3449 },
+ { 8306, -3458, 2394, -1454 },
+ { 8438, -2781, 1043, -1362 },
+ { 9175, -2076, 2144, -1987 },
+ { 8347, -2709, 3489, -4301 },
+ { 5696, -2377, 2870, 851 },
+ { 8825, -1243, 2219, -2603 },
+ { 8801, -1614, 584, -2513 },
+ { 8413, -384, 1421, -2244 },
+ { 9228, -3050, 3279, -2164 },
+ { 6342, -2698, 3547, -107 },
+ { 10053, -2476, 2837, -3168 },
+ { 7439, -604, 3177, -3991 },
+ { 7749, -1064, 4329, -4855 },
+ { 8655, -2177, 2252, -3519 },
+ { 8490, -228, 1958, -3233 },
+ { 10513, -2968, 1911, -2340 },
+ { 8146, -862, 1884, -1723 },
+ { 7788, -666, 3004, -2891 },
+ { 7785, -1620, 4133, -3417 },
+ { 10262, -3731, 3455, -2971 },
+ { 8570, -905, 4519, -4649 },
+ { 9129, -2562, 463, -2465 },
+ { 9451, -3587, 1904, -3056 },
+ { 6549, -2236, 3010, -4523 },
+ { 7175, -2684, 2967, -3458 },
+ { 9872, -3278, 1054, -2472 },
+ { 9153, -931, 1217, -2565 },
+ { 8789, -3469, 753, -2568 },
+ { 6683, -3791, 1797, -3968 },
+ { 6801, -1977, 2311, -452 },
+ { 6336, -1572, 2612, -3264 },
+ { 7996, -1008, 730, -2964 },
+ { 7521, -1059, 1573, -3694 },
+ { 8148, -3973, 2600, -3572 },
+ { 7765, -1532, 2528, -3856 },
+ { 7404, -3918, 4472, -143 },
+ { 8894, -1398, 3299, -3685 },
+ { 5768, -2041, 1487, -637 },
+ { 5131, -2865, 2463, -811 },
+ { 6439, -1568, 3500, -1550 },
+ { -8878, -6798, -5319, -1452 },
+ { -6332, -9713, -3112, -990 },
+ { -8444, -6316, -3694, -687 },
+ { -6123, -10840, -3637, -4358 },
+ { -4784, -9580, -4577, -2581 },
+ { -6108, -10515, -4859, -2524 },
+ { -7605, -7518, -2327, -2797 },
+ { -9662, -8775, -2467, -2010 },
+ { -6494, -7523, -4715, -118 },
+ { -8290, -8982, -1672, -317 },
+ { -8798, -11051, -3888, -1426 },
+ { -6273, -6623, -6791, -142 },
+ { -8313, -7668, -2141, -1275 },
+ { -6453, -8412, -3589, -4102 },
+ { -6747, -7750, -5690, -2498 },
+ { -7814, -6693, -3174, -2446 },
+ { -10383, -10130, -3931, -2364 },
+ { -10606, -8467, -5539, -2772 },
+ { -9475, -6671, -3305, -2271 },
+ { -8982, -9457, -5635, -4005 },
+ { -10111, -7965, -6515, -4180 },
+ { -7301, -6479, -5364, 720 },
+ { -9543, -8999, -7921, -912 },
+ { -9534, -8562, -3469, -384 },
+ { -7601, -10344, -3205, -1127 },
+ { -8088, -8620, -4954, -2888 },
+ { -8202, -8406, -7038, -3775 },
+ { -7312, -8324, -3334, -1775 },
+ { -8566, -9262, -8071, -4174 },
+ { -7068, -11300, -5573, -2907 },
+ { -8295, -8952, -4366, -1544 },
+ { -11104, -10210, -2285, -384 },
+ { -5213, -7520, -5008, -1339 },
+ { -5889, -7940, -5987, -1385 },
+ { -10816, -8201, -4153, -1485 },
+ { -10277, -8919, -6315, -1652 },
+ { -5888, -10320, -3821, -1733 },
+ { -10497, -7181, -6083, -3032 },
+ { -7721, -9724, -6591, -5336 },
+ { -5688, -7894, -3486, -2552 },
+ { -10014, -10500, -3247, -820 },
+ { -6301, -8765, -4506, -2923 },
+ { -8261, -7847, -6213, -1552 },
+ { -10212, -7481, -8113, -3954 },
+ { -6938, -10874, -6074, -4703 },
+ { -7183, -10968, -4446, -1773 },
+ { -7120, -9193, -1966, -2509 },
+ { -6234, -9263, -2313, -4284 },
+ { -8503, -9857, -2429, -608 },
+ { -9372, -7844, -8391, -2120 },
+ { -7951, -7157, -6535, -11 },
+ { -7256, -9473, -2172, -660 },
+ { -10063, -9612, -2515, -15 },
+ { -6684, -9134, -6109, -4206 },
+ { -8204, -11932, -5220, -2306 },
+ { -9710, -6706, -4115, -3275 },
+ { -6855, -7078, -2409, -4447 },
+ { -7344, -7673, -4479, -4116 },
+ { -8851, -6842, -4927, -2948 },
+ { -8927, -10452, -5633, -2194 },
+ { -8627, -9002, -7176, -1575 },
+ { -8209, -9722, -7021, -3324 },
+ { -3770, -10249, -3623, -4816 },
+ { -8183, -7465, -4090, 646 },
+ { -8163, -7149, 200, 498 },
+ { -8289, -6266, 686, -206 },
+ { -10030, -6241, -1032, -1864 },
+ { -8793, -8327, -773, -169 },
+ { -9149, -6215, 969, -15 },
+ { -8303, -5859, -7, 2006 },
+ { -9682, -7283, 255, 1322 },
+ { -9293, -7227, 71, -231 },
+ { -8525, -6215, 287, -837 },
+ { -10477, -5379, 1159, 1449 },
+ { -10726, -7856, -130, 102 },
+ { -8694, -7461, -1210, 690 },
+ { -9367, -5324, 1103, 3170 },
+ { -10686, -8055, -831, 1633 },
+ { -9201, -6873, -2704, 2258 },
+ { -8421, -5358, -1405, 226 },
+ { -9066, -5830, -307, -1571 },
+ { -11150, -7381, -2746, -900 },
+ { -9978, -5925, -2006, -437 },
+ { -9464, -4741, -273, 1061 },
+ { -10543, -6684, -1113, 1660 },
+ { -10073, -5576, 1083, -269 },
+ { -8826, -5763, 1600, 1486 },
+ { -10445, -9071, -1253, -64 },
+ { -12085, -5799, 2, 769 },
+ { -12939, -6663, 1650, 1437 },
+ { -10932, -6434, -1252, -649 },
+ { -11650, -7826, -2053, 710 },
+ { -12122, -6733, -1889, -731 },
+ { -9093, -6095, -2463, -842 },
+ { -10977, -4364, 469, 420 },
+ { -11488, -6908, -521, 893 },
+ { -9669, -5478, -842, 337 },
+ { -10606, -5203, -632, -1361 },
+ { -10198, -6284, 1662, 1277 },
+ { -10135, -5292, 2435, 3493 },
+ { -11027, -6561, 655, 56 },
+ { -10977, -5030, 1127, -358 },
+ { -12766, -3986, 1348, -335 },
+ { -14244, -7731, 264, 317 },
+ { -15124, -10309, -508, 1447 },
+ { -12821, -8638, -608, 137 },
+ { -13076, -8693, -2852, -431 },
+ { -11156, -5546, -2252, -1600 },
+ { -8692, -7366, -819, -1223 },
+ { -12507, -9816, -1714, -121 },
+ { -10712, -6666, 544, 3349 },
+ { -12462, -5890, -2491, -2318 },
+ { -12468, -7226, 437, 232 },
+ { -11300, -5226, 2068, 687 },
+ { -11994, -8320, -626, 2728 },
+ { -12222, -5476, 1142, 18 },
+ { -10277, -8122, -2418, 2003 },
+ { -13418, -6115, -3563, -2802 },
+ { -14759, -9834, -1243, 21 },
+ { -13699, -5665, 1525, 507 },
+ { -16269, -9476, -701, 163 },
+ { -12677, -5437, -247, -1019 },
+ { -11827, -4295, -181, -1243 },
+ { -12847, -4496, 2984, 1123 },
+ { -13860, -7915, -1166, -547 },
+ { -12276, -8145, -2290, -1527 },
+ { -11417, -4830, 2983, 1854 },
+ { -11793, -6002, 1163, 1940 },
+ { 11443, -4920, -3235, 3151 },
+ { 11300, -6616, -1506, 1175 },
+ { 9198, -4628, -2060, 2390 },
+ { 10532, -4027, -643, 912 },
+ { 9902, -3573, -1606, 1327 },
+ { 9653, -3536, -2240, 1869 },
+ { 9948, -5171, -423, 2662 },
+ { 12316, -4004, -1989, 281 },
+ { 12125, -4800, -1265, -163 },
+ { 10650, -2617, -2337, 1462 },
+ { 9909, -4968, -2376, 916 },
+ { 12944, -4647, -1958, 460 },
+ { 12988, -5283, -1141, 41 },
+ { 12321, -2915, -3621, 1025 },
+ { 11449, -2894, -2728, 351 },
+ { 12087, -3041, -2002, -32 },
+ { 11558, -4031, -1343, -399 },
+ { 12983, -3740, -3516, 1245 },
+ { 12099, -2515, -2752, 225 },
+ { 12515, -3465, -2701, 550 },
+ { 14683, -5022, -5272, 2996 },
+ { 12260, -3383, -1215, -528 },
+ { 13810, -5422, -2443, 1166 },
+ { 13421, -5378, -1886, 721 },
+ { 12961, -4259, -2594, 796 },
+ { 12266, -2104, -4768, 1591 },
+ { 13523, -4710, -3045, 1342 },
+ { 12437, -2099, -5610, 2117 },
+ { 11850, -2183, -3497, 661 },
+ { 12275, -3936, -597, -697 },
+ { 12459, -5253, -517, -544 },
+ { 12835, -4094, -1322, -168 },
+ { 14360, -5677, -3305, 1859 },
+ { 13905, -4552, -4309, 2117 },
+ { 11559, -3412, -1847, -81 },
+ { 13379, -3167, -5764, 2746 },
+ { 11910, -1634, -4342, 1052 },
+ { 12662, -4742, 71, -974 },
+ { 13057, -3254, -4424, 1705 },
+ { 15046, -5706, -4851, 3019 },
+ { 14162, -4142, -5514, 2843 },
+ { 12764, -1845, -6684, 2888 },
+ { 13714, -2374, -7838, 3857 },
+ { 13295, -1663, -8293, 4073 },
+ { 10032, -4152, -3403, 1421 },
+ { 10942, -5386, -2222, 950 },
+ { 10532, -6385, -1750, 1925 },
+ { 10273, -5972, -1534, 643 },
+ { 10605, -4782, -1695, 27 },
+ { 10988, -5153, -1123, -341 },
+ { 11629, -5884, -1060, 48 },
+ { 10441, -4045, -2431, 311 },
+ { 10788, -3595, -4171, 1807 },
+ { 12110, -5686, -2127, 976 },
+ { 11746, -4773, -2639, 891 },
+ { 11541, -5299, -3031, 1732 },
+ { 11416, -2559, -5359, 2198 },
+ { 11583, -5376, -704, 677 },
+ { 10416, -3214, -3516, 872 },
+ { 9651, -5435, -1618, 3255 },
+ { 9973, -5133, -996, 3923 },
+ { 11707, -4643, -430, -796 },
+ { 10994, -2709, -3587, 2302 },
+ { 10716, -5118, -645, 270 },
+ { 14100, -10314, 1095, 1531 },
+ { 12944, -8049, 1105, -741 },
+ { 13276, -7035, -511, 274 },
+ { 14008, -7254, -283, 139 },
+ { 11594, -6536, -91, 1671 },
+ { 11732, -8645, 746, 15 },
+ { 14613, -7085, -1578, 1183 },
+ { 13083, -6224, -750, -4 },
+ { 13988, -6256, -1592, 820 },
+ { 14678, -8683, 441, 126 },
+ { 15571, -8872, -521, 1139 },
+ { 15642, -9533, 341, 697 },
+ { 15960, -9586, -168, 1121 },
+ { 15464, -10239, 1433, -1 },
+ { 14934, -7887, -1046, 1080 },
+ { 15252, -7630, -1899, 1628 },
+ { 15485, -8384, -1234, 1484 },
+ { 15962, -8638, -1815, 1931 },
+ { 16501, -10664, 398, 1167 },
+ { 16146, -10145, 411, 918 },
+ { 14573, -7475, -697, 601 },
+ { 14302, -7996, 28, 257 },
+ { 14769, -6792, -2286, 1574 },
+ { 14144, -6137, -2169, 1257 },
+ { 14770, -6271, -3111, 1933 },
+ { 14110, -8312, 1083, -531 },
+ { 15235, -6991, -2993, 2174 },
+ { 13222, -5805, 547, -891 },
+ { 14796, -8762, 1254, -246 },
+ { 16040, -9181, -1005, 1551 },
+ { 16487, -10086, -373, 1420 },
+ { 15077, -9479, 966, 51 },
+ { 13026, -6468, 932, -1080 },
+ { 12703, -6152, -33, -573 },
+ { 15641, -6810, -4128, 2874 },
+ { 13282, -7673, 1583, -1283 },
+ { 12373, -7150, 1512, -917 },
+ { 12992, -7751, -678, 783 },
+ { 10907, -6858, -313, 2597 },
+ { 13026, -8963, 125, 2152 },
+ { 12770, -9946, 1957, -505 },
+ { 12482, -6849, -1268, 833 },
+ { 13790, -6181, -138, -279 },
+ { 12709, -8382, 2044, 227 },
+ { 12244, -6630, 203, -457 },
+ { 14209, -6816, -1032, 632 },
+ { 15134, -8267, -288, 640 },
+ { 13619, -6157, -1090, 356 },
+ { 14044, -7413, 725, -484 },
+ { 12958, -7753, 2585, -1980 },
+ { 13188, -8396, 2306, -1558 },
+ { 14379, -9980, 2132, -688 },
+ { 14275, -9857, 1162, 179 },
+ { 13690, -8648, 1621, -889 },
+ { 11770, -6829, -746, 278 },
+ { 12732, -8202, 286, 90 },
+ { 13630, -10146, 1867, -207 },
+ { 12072, -8740, 1299, -645 },
+ { 12852, -9492, 1226, 62 },
+ { 11792, -7382, -54, -116 },
+ { 13779, -9014, 487, 351 },
+ { 11951, -7729, 121, 834 },
+ { 11970, -9781, 2276, -4 },
+ { 12680, -7984, 2787, -787 },
+ { 13300, -14488, 6408, -1927 },
+ { 13635, -15355, 9153, -3073 },
+ { 12804, -13566, 5517, -1625 },
+ { 16624, -10854, 1690, 28 },
+ { 20387, -18532, 6162, -261 },
+ { 16515, -12642, 3392, -519 },
+ { 15800, -11095, 2151, -202 },
+ { 16824, -11790, 1651, 599 },
+ { 17604, -13213, 2563, 538 },
+ { 17892, -14177, 3562, 147 },
+ { 16987, -11399, 869, 1052 },
+ { 17003, -12456, 2442, 265 },
+ { 21657, -21806, 9198, -1250 },
+ { 16825, -13341, 3980, -686 },
+ { 17525, -12714, 1887, 805 },
+ { 16419, -11034, 1216, 617 },
+ { 20931, -19939, 7469, -684 },
+ { 18452, -15390, 4573, -191 },
+ { 14778, -10077, 2841, -1209 },
+ { 17402, -13319, 3042, 160 },
+ { 19365, -17922, 7087, -1061 },
+ { 16298, -11941, 2810, -351 },
+ { 19087, -16176, 4775, -84 },
+ { 17666, -12289, 938, 1224 },
+ { 18581, -15894, 5132, -430 },
+ { 19823, -16717, 4142, 545 },
+ { 19960, -19423, 8400, -1492 },
+ { 18973, -16817, 5906, -594 },
+ { 19079, -15431, 3528, 503 },
+ { 16667, -12485, 4467, -1302 },
+ { 19791, -17797, 6196, -529 },
+ { 20005, -17606, 5354, -20 },
+ { 20123, -18599, 6886, -728 },
+ { 19068, -14805, 2394, 1105 },
+ { 14443, -13723, 5631, -2029 },
+ { 14730, -14231, 5631, -1450 },
+ { 16089, -15959, 7271, -2029 },
+ { 13473, -11200, 3236, -924 },
+ { 14413, -10902, 2347, -267 },
+ { 17666, -18662, 11381, -3496 },
+ { 14749, -11042, 3305, -275 },
+ { 15304, -10486, 1869, -240 },
+ { 14809, -12126, 3369, -616 },
+ { 16896, -16561, 7307, -1845 },
+ { 15782, -14336, 5380, -1264 },
+ { 16395, -15520, 6415, -1588 },
+ { 13681, -11114, 2584, -320 },
+ { 14244, -12326, 4480, -1632 },
+ { 15247, -13119, 4265, -898 },
+ { 13987, -12091, 3469, -597 },
+ { 13941, -12770, 4240, -839 },
+ { 13771, -13627, 5252, -1384 },
+ { 15010, -16074, 7592, -2249 },
+ { 15852, -17226, 8619, -2655 },
+ { 18921, -16916, 6875, -1501 },
+ { 14909, -11678, 2768, -295 },
+ { 18988, -18353, 8424, -2070 },
+ { 15457, -15080, 6218, -1513 },
+ { 14916, -15512, 6949, -1883 },
+ { 18108, -14702, 4681, -701 },
+ { 17600, -15733, 5616, -775 },
+ { 14070, -13683, 6472, -2626 },
+ { 13832, -11914, 5201, -2232 },
+ { 18846, -19009, 9192, -1961 },
+ { -11981, -10994, -6324, -2264 },
+ { -10976, -9047, -6546, -3828 },
+ { -11288, -10532, -7014, -4191 },
+ { -10139, -10189, -7799, -2688 },
+ { -10555, -9988, -9181, -2040 },
+ { -11596, -11339, -10022, -2707 },
+ { -13400, -13395, -11306, -4206 },
+ { -9774, -12281, -7466, -4133 },
+ { -10842, -13125, -8777, -4956 },
+ { -11964, -15082, -9779, -5095 },
+ { -9382, -10188, -9053, -4927 },
+ { -11562, -11296, -3651, -985 },
+ { -9287, -10083, -7918, -4069 },
+ { -12821, -16556, -11410, -6195 },
+ { -12628, -8959, -4521, -1113 },
+ { -13845, -11581, -3649, -681 },
+ { -12685, -10269, -5483, -1275 },
+ { -14988, -12874, -5107, -1189 },
+ { -13761, -11367, -6202, -1804 },
+ { -13225, -11249, -7820, -3354 },
+ { -14809, -11992, -3202, -312 },
+ { -15620, -15519, -10210, -3433 },
+ { -12954, -10200, -3139, -611 },
+ { -11536, -9981, -5284, -923 },
+ { -13034, -12417, -4612, -1098 },
+ { -16911, -15505, -6123, -1352 },
+ { -17396, -17685, -8330, -2171 },
+ { -14120, -10764, -2265, -99 },
+ { -12598, -7367, -5406, -3530 },
+ { -14143, -12793, -10909, -5226 },
+ { -14692, -16871, -11626, -5554 },
+ { -12581, -11197, -9194, -3837 },
+ { -16752, -16726, -9746, -2808 },
+ { -10600, -10358, -6560, -1227 },
+ { -14573, -13312, -8957, -3393 },
+ { -10172, -8463, -8579, -3387 },
+ { -11418, -12421, -5522, -1842 },
+ { -11855, -14204, -6669, -2625 },
+ { -13308, -8191, -3941, -2194 },
+ { -10007, -12266, -5022, -1811 },
+ { -13532, -15771, -9497, -3175 },
+ { -11760, -11148, -10339, -5529 },
+ { -12149, -12763, -11198, -3697 },
+ { -12029, -12119, -8555, -1792 },
+ { -16995, -19957, -11447, -3471 },
+ { -13144, -14504, -9988, -3191 },
+ { -9938, -11064, -6139, -3162 },
+ { -8873, -11550, -8294, -6550 },
+ { -9303, -13010, -6150, -2711 },
+ { -15463, -10469, -1766, -170 },
+ { -15985, -11693, -3007, -650 },
+ { -17142, -10671, -1434, 47 },
+ { -16063, -13858, -4817, -1058 },
+ { -19446, -19599, -9594, -2464 },
+ { -20076, -18744, -8313, -1889 },
+ { -15047, -16085, -7590, -2250 },
+ { -13481, -16195, -8552, -2998 },
+ { -13829, -14869, -6704, -1932 },
+ { -16357, -18484, -9802, -2959 },
+ { -10551, -8393, -9303, -5070 },
+ { -11345, -9156, -5641, -3107 },
+ { -13217, -13449, -9270, -4541 },
+ { -11988, -13732, -9995, -6374 },
+ { -11007, -9519, -5168, -4107 },
+ { 9930, -7858, 8061, -4375 },
+ { 8274, -7867, 5992, -2096 },
+ { 9692, -9675, 7621, -3670 },
+ { 9589, -8110, 6509, -3010 },
+ { 12617, -11976, 10122, -5360 },
+ { 11867, -8895, 7948, -5323 },
+ { 10388, -10482, 9234, -4324 },
+ { 8188, -8220, 7810, -2737 },
+ { 10407, -8787, 4806, -1930 },
+ { 10348, -8845, 9233, -6614 },
+ { 9422, -7091, 4820, -2878 },
+ { 9758, -9796, 5584, -2256 },
+ { 10188, -7994, 5347, -3343 },
+ { 11133, -7455, 4015, -2306 },
+ { 10676, -10744, 6093, -2629 },
+ { 11522, -12184, 7848, -3375 },
+ { 8805, -9883, 5317, -3071 },
+ { 9498, -9654, 6555, -3592 },
+ { 10488, -8008, 4066, -1252 },
+ { 11261, -8930, 6068, -2738 },
+ { 12180, -10397, 5027, -1531 },
+ { 9138, -8531, 3601, -1959 },
+ { 8107, -8380, 4970, -2061 },
+ { 9737, -13248, 6438, -2617 },
+ { 11178, -10423, 2622, -522 },
+ { 9572, -12372, 5199, -2019 },
+ { 12057, -12144, 4147, -1099 },
+ { 9047, -9925, 2516, -665 },
+ { 10790, -8030, 5882, -4386 },
+ { 7199, -8426, 6337, -2841 },
+ { 7778, -8285, 3529, -3442 },
+ { 7559, -10569, 3484, -1332 },
+ { 9404, -8115, 7484, -5541 },
+ { 7792, -11976, 5546, -2573 },
+ { 9313, -10264, 7661, -5195 },
+ { 6701, -10725, 4370, -1784 },
+ { 4918, -11361, 4507, -4527 },
+ { 5147, -12305, 3978, -5556 },
+ { 6525, -9899, 4481, -3129 },
+ { 7538, -12855, 6060, -4826 },
+ { 8659, -12111, 7159, -4430 },
+ { 8440, -11304, 4547, -1747 },
+ { 9216, -10918, 3507, -1195 },
+ { 6165, -9254, 4771, -4677 },
+ { 9163, -11019, 5637, -4935 },
+ { 13441, -11509, 6676, -2434 },
+ { 7912, -9398, 6663, -4048 },
+ { 11723, -13745, 8131, -4148 },
+ { 6065, -10257, 5005, -6327 },
+ { 11618, -12417, 5336, -1894 },
+ { 8891, -13924, 8407, -6131 },
+ { 9622, -12563, 7908, -5109 },
+ { 11479, -10315, 8349, -3991 },
+ { 11676, -14103, 6611, -2330 },
+ { 11951, -8953, 3829, -1550 },
+ { 10486, -8044, 10493, -5920 },
+ { 11801, -10769, 9763, -5305 },
+ { 6109, -8676, 5827, -1346 },
+ { 7030, -9611, 5624, -5761 },
+ { 12808, -12886, 8683, -4148 },
+ { 13213, -10464, 6381, -3189 },
+ { 11796, -13681, 10703, -6075 },
+ { 9639, -7949, 9625, -3944 },
+ { 8538, -6997, 5309, 453 }
};
/* quantization tables */
@@ -4226,2054 +4226,2054 @@ static const float lossless_quant_d[32] = {
static const int8_t high_freq_vq[1024][32] =
{
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { -4, -2, 2, 1, -16, -10, 1, 3, 1, 0, 6, 1, -3, 7, 1, -22,
- 2, -4, -3, 11, 14, 6, -1, 1, -13, 29, -28, 10, 10, -8, 0, -9 },
- { -8, 8, -7, 10, -3, -12, -5, -8, 1, -2, 9, -2, -5, -18, 1, 9,
- -8, -8, 3, 41, 7, -9, -9, 22, -42, -29, 14, -18, -14, -32, 1, -15 },
- { -16, 8, 15, 16, -16, 5, 2, 7, -6, -16, -7, 1, 1, -3, -2, 0,
- 8, 20, -26, -11, 2, -17, 0, -3, -34, -37, 10, 44, -2, 22, 2, -4 },
- { 7, 14, 5, 6, 15, -1, 3, -3, -9, -23, -5, -14, 8, -1, -14, -6,
- -5, -8, 54, 31, -6, 18, 2, -19, -2, -11, -30, -6, -19, 2, -2, -14 },
- { 1, 2, -2, -1, -3, -3, 1, -5, 1, -3, -4, -8, 5, -4, 0, 1,
- 3, 7, -5, -4, -3, -12, 3, -2, -3, 12, -53, -51, 6, -1, 6, 8 },
- { 0, -1, 5, 1, -6, -8, 7, 5, -18, -4, -1, 1, 0, -3, -3, -14,
- -1, -6, 0, -14, -1, -1, 5, -3, -11, 1, -20, 10, 2, 19, -2, -2 },
- { 2, 4, 3, 0, 5, 0, 3, 1, -2, 0, -6, -3, -4, -5, -3, -3,
- -7, 0, -34, 4, -43, 17, 0, -53, -13, -7, 24, 14, 5, -18, 9, -20 },
- { 1, 0, -3, 2, 3, -5, -2, 7, -21, 5, -25, 23, 11, -28, 2, 1,
- -11, 9, 13, -6, -12, 5, 7, 2, 4, -11, -6, -1, 8, 0, 1, -2 },
- { 2, -4, -6, -4, 0, -5, -29, 13, -6, -22, -3, -43, 12, -41, 5, 24,
- 18, -9, -36, -6, 4, -7, -4, 13, 4, -15, -1, -5, 1, 2, -5, 4 },
- { 0, -1, 13, -6, -5, 1, 0, -3, 1, -5, 19, -22, 31, -27, 4, -15,
- -6, 15, 9, -13, 1, -9, 10, -17, 4, -1, -1, 4, 2, 0, -3, -5 },
- { -7, 3, -8, 13, 19, -12, 8, -19, -3, -2, -24, 31, 14, 0, 7, -13,
- -18, 0, 3, 6, 13, -2, 1, -12, -21, 9, -2, 30, 21, -14, 2, -14 },
- { -3, -7, 8, -1, -2, -9, 6, 1, -7, 7, 13, 3, -1, -10, 30, 4,
- -10, 12, 5, 6, -13, -7, -4, -2, -2, 7, -3, -6, 3, 4, 1, 2 },
- { -8, 9, 2, -3, -5, 2, 0, 9, 3, 7, -4, -16, -13, 3, 23, -27,
- 18, 46, -38, 6, 4, 43, -1, 0, 8, -7, -4, -1, 11, -7, 6, -3 },
- { 1, 1, 18, -8, -6, 0, 3, 4, 22, -3, -4, -2, -4, -11, 40, -7,
- -3, -13, -14, -7, -10, 14, 7, 5, -14, 11, -5, 7, 21, -2, 9, -3 },
- { 0, 0, -2, 4, -2, 0, 2, 0, -1, 2, -1, 0, 0, 2, 2, 2,
- -1, 1, -3, -1, -15, -2, -63, -27, -21, -47, -14, 1, -14, 10, 0, 2 },
- { 1, 0, -4, 0, -3, -9, 4, 2, 6, -6, 0, -5, 11, -7, -15, 6,
- -7, -6, 3, 7, -15, -5, 23, -13, -6, 12, -8, 9, 2, -3, 3, 4 },
- { 6, 0, 3, 0, -2, -4, 2, 1, 1, -1, 1, -2, -1, -4, -22, -15,
- -46, -66, 10, 20, 2, -17, 12, -6, 1, -2, -2, 0, 1, -5, 1, 2 },
- { -1, 0, 0, 1, 0, -4, 0, 1, -10, -3, -8, 5, 7, -11, 2, -11,
- 29, -25, 11, 10, 0, -1, 5, -7, -2, -5, -2, 4, 4, -3, 5, -2 },
- { 1, -1, -1, -3, -2, 1, -8, -3, 2, -2, 4, -5, -1, -7, -2, 1,
- -14, -7, 3, -30, -15, -14, 3, -4, -1, 3, -13, -1, -3, 1, 2, 3 },
- { -1, -2, -3, 2, 2, -3, 3, 1, -3, 2, 0, -4, 6, 5, -5, 10,
- -57, 3, 22, -50, 1, -2, -5, -6, -1, 5, 1, 2, 2, 1, -2, 2 },
- { 2, 0, -1, -7, 2, 1, 3, 2, 0, 4, 3, -2, 3, -3, 4, -4,
- 24, -35, -3, 38, -6, -5, 15, 20, 3, 16, -7, -5, 0, -4, -5, 0 },
- { 0, 1, 0, 0, 0, -1, -1, 1, 1, -1, 1, -2, 0, 0, 0, 0,
- 0, -1, -2, -1, -5, -2, -43, -3, 46, -52, -10, 7, -8, 11, -2, -1 },
- { 0, 0, -1, 0, -1, 2, -41, 33, -44, -48, -15, -26, -9, 6, 3, 3,
- -3, 2, 2, 2, 2, -1, -1, -2, 1, 3, 0, 0, 5, 2, 3, 1 },
- { -4, 1, 6, 1, -6, -1, -2, 1, -14, -4, 0, -5, -2, 2, -2, 0,
- -6, 1, 0, 8, -21, 32, -3, -36, -6, -2, -1, -7, 3, 0, 1, -6 },
- { -3, -2, 3, 0, 2, 2, 8, -4, -4, 6, 2, 1, 3, -6, 4, 3,
- 13, 0, -12, -1, 25, -20, -2, -23, -15, 7, -3, -11, -3, 6, -1, 0 },
- { 0, 0, -3, -1, 0, 0, -2, -1, -2, -2, 1, -1, 0, 0, 10, 3,
- -2, 3, 3, -7, -6, -5, 0, -4, -60, -16, -6, 38, 5, 6, -5, 0 },
- { 0, 1, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 1, 0, 0, 1,
- 0, 0, -1, 0, -8, 2, -9, 10, 40, 31, -56, -21, 4, 20, -4, 7 },
- { -2, -2, 0, 4, -3, -1, 7, 3, 1, 3, -8, 0, 3, 1, 2, 5,
- 1, -2, 14, 5, 4, 5, 5, 5, -5, 9, -66, 0, -20, -2, -8, 4 },
- { -2, -1, 4, -1, -8, -2, -4, -1, -3, -3, 2, -7, -3, 5, 7, -2,
- 45, 31, -17, -16, -2, -2, -1, -22, 1, -1, -3, 3, 5, -3, 5, -1 },
- { -4, 0, 7, 5, 8, 7, 2, 9, -9, -9, -7, -11, -3, -8, 17, -4,
- 34, 32, 18, 22, 1, 2, 1, -7, -5, 6, -1, 6, 4, 10, -2, -7 },
- { 6, 0, 14, 9, 6, -1, -2, -3, 4, -6, -8, 4, 7, -1, 28, 38,
- 15, -1, 16, -11, 5, 8, 4, -10, 3, -10, -17, 5, 3, 3, 3, 1 },
- { 1, 1, 2, -1, 2, 1, 0, 0, -1, 0, 0, -2, 1, -3, 0, 1,
- 2, -2, -4, -2, 0, -1, 1, -3, 1, 1, 1, -1, 8, 8, 66, 33 },
- { -5, 2, -3, -7, 2, -8, -4, 10, 17, -18, -7, 4, -4, -7, -6, -6,
- -5, 5, -12, 2, 0, 6, 8, -2, 1, 4, -11, 2, 1, 8, 31, 19 },
- { 6, 9, 16, -6, -6, -1, -2, -3, -11, -2, 7, 7, 17, 3, 4, 10,
- 2, 5, -13, 8, 7, 1, 4, 5, 7, 6, 7, -8, 9, -8, 33, 6 },
- { 3, -1, 1, 0, -7, -5, 0, 14, -7, 1, -7, 1, 2, -4, 7, 10,
- -16, 12, 1, -6, 3, 8, -1, 10, -13, -6, -12, -23, 12, -3, 30, 14 },
- { -2, -15, 0, 8, 3, -19, 5, -3, 2, 3, 13, 7, 14, -3, -10, 0,
- 8, 5, -6, -16, -8, -8, 14, 2, -1, 1, -9, -11, 11, -5, 27, 9 },
- { -8, 6, -4, 4, -4, -1, 5, 4, 1, -7, -5, -4, -15, 1, 9, 0,
- 8, 4, 1, -17, 11, -2, -19, -1, -6, -8, 3, -12, 3, -17, 33, -10 },
- { -3, -1, 2, 7, 7, -2, 9, 8, -18, -1, -13, -10, -3, -3, 11, 8,
- -2, -12, -8, 1, 4, 9, 14, 10, -3, 0, 2, 1, -2, 3, 31, 10 },
- { -3, -10, 8, -1, -5, -11, 7, -5, 3, 6, 1, 4, -16, 10, 5, -4,
- -2, -10, -1, 13, 6, -5, -7, 12, 7, -3, -17, 1, 12, -4, 29, 8 },
- { 1, 2, 5, 2, -6, -7, 0, -1, 6, -1, 10, 6, -4, 5, 2, 2,
- -2, -8, -6, -11, 14, -13, 27, 3, -2, -12, 5, -16, 2, -26, 20, 15 },
- { -1, -3, -5, -3, -3, 6, -1, 3, -5, 1, 7, 2, 1, 0, -1, -1,
- 0, -1, 9, 7, -6, -3, 4, -5, -4, 8, -8, -25, -8, -4, 34, 23 },
- { -1, -2, 1, 1, -1, -2, -1, 1, -1, 0, 0, 0, 0, -2, -1, 1,
- 0, 2, 1, -1, 4, 0, 0, 1, -1, 0, 5, 3, 12, -9, 68, -16 },
- { 10, 0, -8, 14, -6, 1, -12, 0, 0, -3, -5, -11, -6, 12, 9, -10,
- -3, 5, 0, 7, 11, 2, 4, -3, -8, -3, 7, 4, 3, -3, 34, 4 },
- { -12, 13, -5, 7, -11, -2, -1, 1, -4, -14, -21, 3, -3, -3, -4, -7,
- -9, -4, 3, -17, -2, -13, 10, -2, 12, -4, 0, -9, 1, -5, 31, 10 },
- { -10, 6, 5, 6, 4, -7, 10, 0, -28, -3, 0, -11, -1, -5, 16, -10,
- -16, 7, 20, 2, -4, 2, -5, 0, 15, 6, 5, -10, 7, -9, 20, 4 },
- { 1, -7, -2, -7, 4, -3, -2, -7, -1, -14, 6, -16, 4, -5, -4, -6,
- -5, 0, -2, 2, -6, 9, -5, 4, -18, 8, -10, 8, 15, 0, 32, 1 },
- { -5, 7, -3, 7, 15, -4, 0, -16, 9, 5, -5, 5, 4, -3, -12, -9,
- -18, 10, 2, 2, -3, 7, 3, -1, 6, -9, -10, 3, 15, -4, 35, -7 },
- { -1, -10, 2, 2, -4, -2, 10, 2, -1, 2, -2, 1, -1, -14, -11, 3,
- -8, 5, -8, -2, 6, -1, -7, 1, 7, 5, 7, 8, 30, -4, 30, 14 },
- { 2, -2, 1, 2, 3, -8, 3, 0, -2, 0, -9, 2, 1, 4, -6, -1,
- -2, 5, 0, 1, -2, 12, 6, -3, 9, -3, 4, -12, 21, -39, 24, -2 },
- { 3, 5, 1, -2, -2, -2, -3, 6, -8, -2, -11, -8, -1, 4, 2, 2,
- -4, -10, 12, -5, -11, 1, -15, -34, -11, -7, -11, -1, 7, -14, 38, -1 },
- { -4, 4, 8, 9, 8, 1, -5, -9, 4, -2, 15, -4, 11, -15, 20, -1,
- -1, -3, 4, -9, -2, -2, -2, 8, 6, 12, -5, 0, 11, -12, 27, -4 },
- { 0, 8, -4, 3, -11, 6, -11, 2, 3, 0, 5, -8, -7, -6, -9, -21,
- 4, -11, -1, -16, -7, 16, -3, 7, -7, 4, -5, 0, 11, -7, 31, 3 },
- { 1, 3, 4, 11, -11, -2, -3, -6, 6, 5, 0, 3, -9, -6, 4, -4,
- 0, 4, -8, 13, -6, -13, -1, -5, -1, 4, 0, 0, 9, -22, 24, 18 },
- { -7, 3, 10, -13, -6, 6, -6, 6, 22, 1, 0, -14, 2, 3, 7, -1,
- 8, 20, -1, 5, -4, 13, 9, -9, -9, 6, 0, -4, 0, -8, 31, -4 },
- { -3, -4, 0, 1, 7, 3, -7, 0, 5, -2, 1, 3, 3, 1, -5, -2,
- 5, 2, -11, 4, 0, -1, 12, 0, -3, -13, 15, 8, -6, -27, 34, 0 },
- { -3, -3, 10, -4, 2, -1, -3, 0, -1, -1, -4, 2, 6, -2, 12, 1,
- 3, -6, -7, -6, -5, 4, -19, -6, -8, -34, -4, -8, 10, -7, 23, 10 },
- { -7, 0, -1, -6, 8, 4, -4, 2, -5, -8, -7, -9, -8, 5, 9, 7,
- -6, 1, -12, -12, -1, -16, 5, 0, 16, 3, -7, -8, 27, -4, 23, 15 },
- { -8, 4, 8, 5, 6, 11, -3, 5, 3, -1, -11, 6, -5, 0, 2, -6,
- -3, -6, 4, -1, 5, -5, -12, -6, 7, -5, 9, 3, 6, -7, 29, 1 },
- { 1, 3, -2, -2, -6, -2, 1, 6, -6, -3, 1, 2, 3, 4, 1, 5,
- -1, 0, 4, 2, 11, 6, 2, -3, 13, -9, -19, 18, -15, -10, 36, 21 },
- { -3, -3, 2, -1, -7, 6, -4, 1, -3, -1, -2, 2, 3, -7, -3, 0,
- -2, 0, -2, 6, -19, 3, -8, 2, -6, 7, -1, 0, 29, -6, 28, -10 },
- { -5, 1, -3, -7, -12, -4, 1, 1, -1, 13, -10, -1, -9, -5, -13, 6,
- 13, 3, -4, 2, 3, 11, 2, 6, -25, -16, -6, 0, 14, -1, 27, 16 },
- { -6, -1, -7, -5, -2, -5, -5, -1, 9, 1, 0, 3, -8, -12, -6, 5,
- -6, 5, 3, -9, 1, 4, -7, -10, -9, -7, -17, -5, -15, -23, 25, 3 },
- { -8, -2, 9, -3, -4, 3, -1, 8, -7, -7, -5, -4, -2, 9, 4, -1,
- -7, -4, -5, -16, 3, -6, 18, -13, -9, 16, -15, 8, 15, -10, 24, 5 },
- { 1, -38, 2, 34, 9, 10, 11, 2, 2, -6, 3, 2, -2, 5, 4, -7,
- -1, 1, 4, 0, 3, 1, -8, -1, -6, 5, 4, 2, -4, 5, 2, -1 },
- { 1, -22, 15, 18, -2, 10, -16, -9, -8, -11, 8, 4, 0, 7, -14, -5,
- -1, -7, 12, 17, 9, 5, -7, -4, -12, -6, 7, 0, 7, 2, -2, 1 },
- { -11, -29, 7, 10, 19, -1, -8, -9, 7, 1, 9, 6, 8, -7, -14, 8,
- -3, -11, -13, 0, -7, -23, -2, -8, 12, 9, 2, 14, 19, 1, -1, 5 },
- { -24, -27, -11, 36, 2, 6, -3, 4, -6, 8, 0, 12, -1, -4, -6, 3,
- 4, -1, 2, -3, -2, 3, 2, -1, -2, -4, 0, -1, -2, 7, 2, 3 },
- { -9, -24, 11, 13, -10, -12, 12, -2, 7, 4, 8, 13, -3, -3, 2, 9,
- -3, -4, 4, 13, 5, 13, -6, -3, 1, 15, 7, -3, 0, 19, -2, -9 },
- { -8, -15, 7, 14, -4, -5, 2, -18, -19, -2, 2, 17, 16, 6, -10, 10,
- -9, 14, -1, -5, -1, -6, -7, 2, 9, 11, 13, 6, -5, -12, 3, 2 },
- { -10, -37, 13, 1, 3, -14, 0, -20, 4, -3, 8, 2, -2, -3, -9, -5,
- -3, -17, -1, 13, -11, 2, -6, 4, 4, 0, 3, 1, -9, -4, -5, -4 },
- { -2, -22, -5, 46, -8, 5, 9, -11, 8, 7, 7, -1, -1, -2, -7, 2,
- -3, 3, -1, -2, 7, 0, 2, -1, 1, -2, -2, -3, 6, 0, -4, -6 },
- { -16, -27, 15, 16, -4, 14, -7, -26, 2, -2, 6, 5, -3, 11, 0, 2,
- 3, 9, -7, -1, 2, -4, -4, -1, 6, 10, 1, 1, -3, -2, 3, 0 },
- { -3, -22, 10, 26, 1, 2, -3, 3, 17, -3, -7, 9, 1, -21, -4, 5,
- 3, 0, -7, -6, 3, 3, -8, -7, -9, 3, 7, 1, -8, 12, 6, -7 },
- { -9, -25, 3, 18, 9, -6, -11, 0, -5, -12, 9, -8, -7, -6, -6, 22,
- 2, -6, -3, 15, 3, 2, -2, 9, 14, -10, -7, 15, 13, 6, -2, 11 },
- { 5, -20, -5, 28, 11, 10, -4, -4, 0, -7, 3, 5, 2, -5, -8, 2,
- 6, 10, 9, -9, -18, 3, 14, 1, 3, -3, -1, -6, 7, 7, 2, -1 },
- { -8, -30, 7, 12, 10, 8, 7, -13, -16, 0, 1, -1, -6, -11, -15, 4,
- 1, -2, 10, -15, 1, 11, -2, 8, 9, -7, -7, 9, -5, 2, 7, -18 },
- { -10, -32, 10, 11, 3, -1, 3, -5, 5, 2, 14, -6, 3, 1, 5, -15,
- -11, 6, 20, 4, 0, -12, -7, 3, 1, -1, 10, 6, -1, -9, -4, -1 },
- { 1, -25, -14, 12, -11, 9, 9, -16, -24, -17, 22, -9, 11, -30, -3, -4,
- 6, -7, 9, 2, -1, -5, -6, 2, -1, -1, 10, 1, -3, 3, 4, 8 },
- { -14, -26, -6, 9, 8, 17, -11, -24, -7, -4, -8, -2, 10, 2, 2, -1,
- 2, 13, 12, -7, 4, -6, -10, 6, 6, -13, -11, -7, -16, 0, -2, 5 },
- { -4, -30, -13, 12, 16, -6, 12, -16, -13, 5, 15, -2, -2, -10, -7, 7,
- 11, -1, -4, -2, -4, 7, 4, -8, 1, 3, 0, 11, 3, -2, -5, 4 },
- { -4, -21, 20, 22, 2, 20, -8, 1, -12, -5, -9, 4, -10, -17, -3, -8,
- -3, 3, -12, 1, -3, 0, 7, 4, 7, 7, -3, 7, 5, 3, 1, -5 },
- { -12, -20, 2, 29, 11, -6, 9, -7, -6, -4, 0, 6, 17, -13, -2, -10,
- -17, -1, -18, 2, 0, 14, -6, 1, 0, 3, 2, -10, 1, -5, -2, 5 },
- { 16, -37, -1, 26, -2, -14, 1, -5, -14, 2, 2, 3, 6, 1, 1, 4,
- 0, -1, 0, -2, -2, 4, 9, -6, 0, -2, 10, -7, -2, 4, 1, 0 },
- { -9, -24, -12, 5, 5, 3, -17, -14, 4, 3, 2, -4, 10, -22, -8, -3,
- 6, 1, 12, -8, 4, 1, 9, -1, 18, -3, 6, 5, 3, -5, 9, -5 },
- { -14, -33, -2, 20, -13, -10, 2, -7, -1, 11, -9, -8, 18, -3, 1, 8,
- 0, -2, 10, 7, -2, -13, 9, -3, -4, 5, -2, -2, -1, -5, 1, -7 },
- { -10, -23, 8, 14, 1, 7, 1, -3, -7, 4, 1, 1, 8, -7, 15, -14,
- 13, 14, 2, 5, -13, -5, -8, -1, 6, 3, 6, 9, 6, 15, 14, 5 },
- { -13, -25, -10, 13, -17, -24, -7, -13, -6, -10, -8, 2, 0, -13, -10, -4,
- -8, 4, -9, 9, -4, 4, -3, -3, 3, 3, -5, -9, 1, -2, 11, 2 },
- { -12, -23, 1, 18, -11, -2, 5, 9, -5, 5, 14, -9, -3, -2, -6, 2,
- -2, 11, -13, 1, -3, 11, -9, -4, -2, -6, 8, 10, 1, 4, 2, 1 },
- { -5, -18, 16, 22, 2, 0, 8, -6, -9, -7, 10, -16, 23, 10, -11, -1,
- 7, 2, 7, 2, 1, -5, 6, 1, 0, -4, 9, 2, -3, 1, 0, -4 },
- { -3, -26, 14, 11, 2, -9, 17, -2, -1, -5, -16, -9, -5, 10, -13, 1,
- 6, 12, 10, 11, 0, 0, -3, -14, 6, -2, 0, 4, -5, -1, -7, -1 },
- { -10, -33, 1, 8, 11, -5, 1, -6, 7, 4, 5, 6, 1, -2, -10, -5,
- -6, 12, -11, 5, -10, 4, 12, -1, -1, -3, 4, -1, 9, 0, 16, -17 },
- { -14, -37, 7, 7, -2, 5, -8, -11, 2, -13, 4, -19, 1, 8, 8, 4,
- -9, 2, -4, 3, 12, 2, 4, -4, -8, 8, 1, 4, 8, -1, 6, -2 },
- { -6, -30, 18, 17, 1, -22, -3, 4, -7, -10, 7, 0, -8, 8, -1, 4,
- 2, 8, 6, -2, 2, 7, 4, 4, 3, -6, 2, 1, -3, 1, -1, -5 },
- { -17, -18, -3, 22, -8, 1, 9, -2, -17, 20, -5, -5, -12, -5, 4, -5,
- -9, 8, -2, 16, -3, 0, 19, -8, 8, 1, 2, -4, 0, 11, 0, -3 },
- { -9, -23, 3, 10, 4, 4, -3, -2, -2, -2, 1, -22, 11, 0, -2, 5,
- -2, 14, -9, -11, -4, 7, 5, 32, 1, -3, -7, 0, 21, -9, 7, -6 },
- { 0, 0, 0, 2, -1, 1, 0, 1, 3, 0, 0, 1, 0, 1, 0, 1,
- -3, 0, -1, -2, 0, -1, -1, -3, -1, 1, -4, 1, -1, -5, -69, -19 },
- { -3, -5, -8, -12, 4, -3, -19, -11, -5, 0, -14, 7, 18, -6, 7, 22,
- 8, 14, 15, 10, 3, -1, -3, 5, -1, 7, -7, 1, -6, 3, -26, -11 },
- { -1, -6, 4, -4, -5, -16, 0, -6, -3, 11, 1, 0, 9, 5, 16, 3,
- -4, -33, -4, 4, -7, 0, 1, 6, -11, -2, -13, -2, -18, 20, -25, -16 },
- { 4, 0, -1, 0, -5, 1, 0, 2, 0, 11, -10, 4, -10, 7, 16, 2,
- 16, 15, 2, -1, 2, 9, 2, 8, -3, -5, -2, 0, -3, 0, -33, -2 },
- { -3, -15, 10, 10, -9, -1, 7, 3, 5, -5, -8, -8, -3, 15, -9, 4,
- 12, 13, -13, -14, 10, -6, 9, 22, -27, 23, -1, 5, -24, 2, -30, 5 },
- { 0, -2, 7, -5, -5, 3, 5, 3, -3, -5, 2, 1, -4, 3, -3, -1,
- 1, -2, 10, 22, -3, -4, -2, -2, -7, 3, 8, 1, 14, 4, -37, 9 },
- { -3, -4, -1, 1, -4, 0, 6, 2, 6, -7, -10, -10, -1, -4, 11, -3,
- 7, -6, 4, -12, -1, 5, 1, -7, 10, -6, 17, -4, 8, 3, -40, 13 },
- { 2, 12, 4, -7, 14, -3, 16, -2, 18, 2, 13, 5, 5, 1, 11, -1,
- 0, 9, 2, -6, -1, 2, -6, 2, -5, 3, 5, 1, -1, 1, -32, -7 },
- { -16, 11, 7, -4, 2, -5, -9, 9, 11, 11, 15, -13, -11, 11, 9, 4,
- 3, -8, -10, 12, 12, 0, 0, -16, -9, 13, 2, 9, 4, -13, -33, 3 },
- { 6, 4, 5, 4, 3, -1, 5, 6, 4, 2, -11, -1, -15, -11, -1, 1,
- 11, -3, -2, 24, -4, -6, -25, -10, -15, -8, 0, 0, -5, 4, -30, 2 },
- { 10, -3, -6, 1, -9, -5, 6, 9, -10, -3, 8, -1, 4, -1, 11, -11,
- 3, 9, 11, -3, 6, -17, 5, -8, -33, 9, -13, 19, -2, 9, -25, 2 },
- { 0, 0, -1, -3, 0, -2, 1, 0, 0, 2, 1, 0, -2, 0, -1, 2,
- 0, -1, 4, -1, 2, -3, 4, -2, 3, 3, 1, 0, -15, 12, -63, 27 },
- { -2, 14, 9, -1, 3, 0, 1, 1, -19, 15, 3, 4, 0, -10, 1, -5,
- 3, 0, -5, -10, 2, -16, -4, 8, -12, -6, 7, -5, -10, -1, -33, -4 },
- { 0, 3, 1, 3, 1, 2, 4, 4, 9, -6, -8, -5, 1, -12, 3, 8,
- -10, 6, -1, 1, 13, -5, -5, 2, -4, 13, -18, -10, -7, -9, -33, 10 },
- { -6, -3, -12, 5, -1, 11, -6, 0, -2, 1, 2, -7, 3, 1, 3, -2,
- 1, 8, -10, 7, -1, -3, 3, 0, 13, 1, 6, 7, -16, -7, -39, 8 },
- { -6, -1, 11, 6, -3, 8, 3, -5, 3, 0, -5, -2, -6, -3, -4, 2,
- -3, 13, -11, 1, 7, 5, 19, -5, -3, -15, -1, 7, -1, 6, -33, 8 },
- { -7, 3, -4, -3, -4, 1, 6, -5, -5, 6, -8, -1, -7, 4, -1, -6,
- -2, 1, 7, 0, 1, 1, -5, 2, -2, 0, -13, -2, -31, -14, -39, -12 },
- { -10, 9, 0, -3, 1, -1, -1, 0, 1, -5, -1, -4, -2, 5, 2, -7,
- 18, -8, -2, -19, -7, -7, -12, -14, -11, -1, -9, -13, -7, -12, -31, -9 },
- { -3, -16, 10, 9, 1, -10, -12, 2, -2, 2, 7, -3, -3, 1, -4, -5,
- -9, 5, 7, 3, -1, 4, -11, -8, 4, 13, -10, 13, 10, -4, -36, 1 },
- { -7, -12, 4, -20, -7, -7, 2, 11, -1, -2, 3, -12, 1, 0, -6, -7,
- 6, 4, 13, 3, -3, 4, 3, -6, -12, 5, -5, -22, -13, -8, -37, -6 },
- { -7, 5, 3, 5, 7, 9, -14, -3, 10, 17, -1, 1, -12, 5, -6, 0,
- -4, -9, 0, -11, -14, 3, 13, 6, -25, -8, -12, 4, -10, 18, -30, -1 },
- { -10, 6, -10, 6, 6, 1, -10, 0, -7, 5, -2, 17, -18, -4, 0, -3,
- -16, -6, -3, -8, 5, 1, -4, 6, -7, 16, 6, 10, -1, 0, -32, -11 },
- { -1, 9, 9, -5, 4, 9, 6, 9, -4, -2, 7, 11, 4, 2, -5, -4,
- -6, 0, 2, -3, -1, 5, 10, 0, 12, -10, -18, -3, -1, 14, -33, 2 },
- { 4, -8, -18, -4, -5, -11, 4, -10, -4, 9, 13, -12, 1, -6, 1, 2,
- 4, -9, 8, 3, -6, 21, 13, -1, -2, 1, -2, 6, -7, 0, -30, 1 },
- { 6, -1, 2, -3, -1, -4, 6, -4, 0, 4, 2, 2, -9, 2, 6, 3,
- -2, 4, -1, 9, -6, 0, 7, -8, 5, 19, -2, 9, -5, 2, -33, -8 },
- { 2, 1, 12, -5, -8, 8, 3, -2, -4, 1, -2, 5, -4, -9, -8, -8,
- 7, -11, -4, 6, -10, 7, -1, -1, -2, -1, 16, 32, -7, 20, -33, -6 },
- { -18, 2, 6, 13, 9, 9, -1, 3, -17, 24, -2, -6, 28, 8, -2, 6,
- 3, -10, -34, -16, -13, -4, -15, -11, -12, -3, -10, 4, -8, 4, -31, -4 },
- { -11, 0, 18, 2, -16, -9, -13, -2, -2, -12, -3, -22, 30, 0, 8, 3,
- 9, -4, -16, 1, 0, -11, 15, -2, -4, 6, -5, 6, 1, 2, -25, -12 },
- { 14, -1, 5, 7, 3, -15, -8, 1, 5, -2, 12, 13, 11, -25, 3, 1,
- 0, -2, -4, -16, -23, 0, -5, -17, 7, 5, -9, 6, -5, 2, -32, -7 },
- { 3, -1, 6, 14, 2, -12, -9, -9, 4, 7, 4, 6, 5, -8, 4, 2,
- 4, 5, -2, 8, 8, -6, 0, 10, -20, -1, 3, -1, 8, 23, -33, -5 },
- { -3, 11, -6, 3, -4, 5, 7, 3, 4, 5, -2, 3, -1, 30, 6, 1,
- 8, -6, 0, 0, -9, 6, -9, 4, 2, 9, -6, 1, -12, 0, -34, 18 },
- { -17, 13, 0, 1, 9, -4, -11, 0, 7, 0, -10, -4, -1, 6, -6, 4,
- 1, 6, -9, 3, -5, -6, -11, 2, -4, 14, 23, -3, 2, 5, -30, 12 },
- { -14, 5, -27, 2, 0, 7, 1, 4, 30, 8, 7, 5, 1, -1, 0, 5,
- 8, -10, 48, -11, 12, 33, 6, 8, -15, 20, -2, -5, 32, 5, -19, 10 },
- { -16, -4, -12, -7, -2, 0, 8, -6, -20, -18, 16, -3, 0, 31, -2, 11,
- 2, -9, 49, -19, -12, -23, 10, 26, 16, -2, 4, -21, -14, 13, -11, -9 },
- { -5, -9, -1, 3, -5, -21, 2, 10, 0, 0, 10, -21, -7, 7, -26, -9,
- 22, 32, 58, 11, -3, 11, -5, -8, -13, 6, -5, -9, 1, 10, 14, -8 },
- { 7, 7, 10, 3, -2, -1, -11, -11, -6, -43, -3, 14, -19, -18, 19, 18,
- -32, 10, 45, -6, 6, 21, -20, -12, 2, 4, 6, 6, -4, 3, 3, 1 },
- { 21, 22, -3, -2, -11, -6, -1, -2, 8, 8, 32, -21, 7, 28, -4, -6,
- -3, -2, 50, 2, 2, 27, -5, -8, 12, 7, -5, -1, -4, -17, 27, 6 },
- { 13, 7, 2, -6, -12, 2, -10, -5, -17, 11, 4, 17, -12, -2, 5, -17,
- 37, -16, 48, -14, -18, 29, 8, 24, 11, -5, -9, 11, -1, 1, -13, -3 },
- { 1, 1, -1, 2, 0, 0, 0, -1, 1, -1, 7, 2, -3, 3, 0, 6,
- 2, 10, 54, -25, 7, 54, -5, -6, -1, -15, 9, 13, -24, -15, -12, 3 },
- { 21, 5, 8, 3, -3, -4, -2, -4, 3, -11, -5, -8, 9, 16, 8, -9,
- -10, -3, 46, -46, 2, 1, -10, 10, 17, 11, -20, -36, 10, 14, 0, -5 },
- { 7, -13, -6, -9, -24, 45, 2, 8, 8, 0, 17, 20, 12, -24, 1, -7,
- -15, -3, 46, -13, -2, 20, 1, -13, -11, -13, 2, 15, 1, 10, -1, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, -1,
- -16, -9, 31, -69, -34, 26, 7, 17, -1, -6, -1, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4,
- -5, -20, 18, -82, 22, 3, -7, 9, 4, 6, 2, -4, -1, 0, -2, 2 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, -1,
- 15, -5, 62, -36, 4, 52, -7, 5, 0, 6, 1, 2, 1, 1, -1, 0 },
- { 3, -19, 19, -20, 13, -4, -11, 8, 8, -16, 10, 1, -14, 30, 1, -33,
- 10, -11, 45, -30, 3, -4, -3, -13, 7, 12, 3, -22, 3, -2, -4, -2 },
- { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1,
- 11, 8, 70, 48, -10, 21, 4, 9, -9, -9, -4, -6, 0, -1, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
- 2, -1, 80, 2, -15, -36, -10, -5, -2, 8, -2, 2, 0, 0, 0, 0 },
- { 10, 8, -8, -8, -24, 12, -1, 0, 20, 9, -1, -2, 2, -2, 12, -10,
- -2, -13, 35, -43, 44, 15, -10, -25, 4, 10, -3, -5, -5, 7, -1, 3 },
- { 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -2, -1,
- -18, 9, 49, -72, 7, -8, 7, -5, 2, 3, 2, -2, 1, -2, -3, 1 },
- { -1, 4, -3, 10, 19, 4, 3, 20, 6, -24, 6, 9, 8, 15, 18, 18,
- -36, 19, 57, -11, 4, -3, 8, 7, 2, -3, -2, -9, -15, -2, 12, -4 },
- { 20, 3, 11, -9, -4, 22, 42, -25, 1, 5, -10, -19, 0, 9, -16, 5,
- 2, 10, 44, -29, 17, -3, -9, -2, -1, 8, 14, -7, -1, 16, -5, 1 },
- { -7, 16, -11, 12, 6, 33, -15, 14, -23, 2, -26, 8, 2, 10, 0, -5,
- 8, -8, 38, -38, -4, 5, 5, 5, 1, 22, -15, 7, 6, 0, 4, 28 },
- { -1, -12, 2, 10, -2, 0, 7, 17, 12, 22, -4, 10, 25, 29, 5, 18,
- 4, 1, 27, -39, 31, 17, 2, 2, 22, -23, 13, 16, 1, -7, -4, -5 },
- { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, 0, -14, 0,
- -7, -11, 49, -22, -4, 19, 17, -39, 4, -29, 10, 2, 36, -4, 23, -1 },
- { -2, -2, -2, -2, 1, 15, -5, -7, -16, -8, -19, 16, -3, -20, 36, -9,
- -3, 20, 39, -20, 0, 2, 27, -16, 10, 10, -14, -22, -16, -3, 13, -8 },
- { 5, -9, 6, -25, 7, 37, 13, -10, -5, 3, -5, 7, 18, -22, -7, 9,
- -5, -4, 50, -11, -4, -5, -5, 8, -4, -2, -4, -27, 14, 20, 7, -9 },
- { 0, -14, -10, -27, -14, -17, -6, 26, 10, 2, 14, -12, -5, 0, 8, 9,
- 0, -28, 55, -7, -12, -7, 4, -10, 10, 7, -12, 11, 3, 5, 9, -8 },
- { 2, 23, 4, -2, -1, -20, -2, 14, 10, -9, -9, -24, 10, 0, 11, -12,
- 12, 11, 49, -25, -2, 29, 7, -13, 21, -10, 11, -17, 3, 1, -8, 5 },
- { 3, 0, -14, -6, 18, -2, 17, -9, -19, 9, -5, 9, 14, 6, 19, -3,
- 27, 1, 41, -21, 20, -15, 33, 0, 26, 14, 7, 10, 3, 20, -3, -12 },
- { -1, 16, 15, -8, 3, -8, -8, 21, -5, -16, -29, 4, 1, -6, -4, -28,
- 2, 31, 37, -26, -2, 13, 24, 8, -9, -6, -29, 10, 7, 2, 7, 8 },
- { -10, -10, 11, 13, -32, 2, 16, 9, 14, 23, -15, -13, 24, 13, 4, -27,
- 14, 12, 31, -18, 17, 23, -2, -7, -14, 9, -17, -6, -10, 20, 9, 6 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
- 5, 1, 89, 8, 10, -6, 2, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1,
- 4, -7, 64, -50, 7, 37, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0 },
- { -2, 5, 3, -4, -4, -3, 2, -3, 3, -3, 5, 4, 1, -6, -1, 1,
- 6, -2, 50, -35, -7, 43, 7, -7, -5, -26, 24, 21, 3, -15, 5, 6 },
- { -8, 21, -19, 33, -8, 22, -11, 17, 3, 0, 0, -2, 1, -3, 6, -1,
- 10, -8, 4, -11, -4, -5, 0, 8, -4, 3, 1, -4, 4, 2, 8, 4 },
- { -7, 5, -20, 9, -22, 3, -14, 1, 6, 13, 23, -2, -4, -7, 2, 0,
- 11, 4, 6, 3, -7, -11, -7, 4, 5, 5, -12, 8, 2, 4, 7, -3 },
- { -7, 6, -4, 20, -20, 16, -2, 7, 6, 16, 11, 12, -7, -7, 5, 3,
- -9, -4, 1, 2, 5, 2, 1, -9, -2, -17, -4, 6, -10, 7, -7, -6 },
- { -9, 18, -17, 12, -24, 1, -1, 4, 14, 9, 4, 3, 2, 8, -12, -14,
- 4, -8, -4, 7, 7, 6, -1, 13, -9, -4, -1, 1, 0, -4, 15, 8 },
- { -25, 2, -11, 6, -5, 24, -28, -5, 8, 12, -2, 6, 8, -3, 8, -9,
- -1, -5, -1, -5, 6, -1, -1, -1, -4, 8, -12, -2, -13, 7, 2, 1 },
- { -14, 14, -18, 20, -10, 12, -2, 9, 1, 0, 12, -2, 15, -10, 26, -17,
- 16, -11, 10, -10, 9, -2, 4, -8, 2, -3, 4, 4, 2, -3, -5, 1 },
- { -18, 12, -18, 21, -6, 12, -6, 13, -25, 18, 1, 11, -9, -5, 0, 10,
- -5, 3, -3, 8, -9, 7, 4, 2, -9, 0, 5, 0, 2, -3, 9, -8 },
- { -4, 16, 1, 18, -30, 9, 1, 6, -8, 13, 13, -12, -6, -1, 13, 7,
- 6, 2, -15, -3, 5, 5, 1, -6, 1, -5, 0, 2, -16, 0, 3, -4 },
- { -21, 1, -2, 6, -43, 18, -1, 5, -1, 4, 6, -2, -1, -3, -1, -3,
- 0, 1, 2, -9, 0, -1, 0, -2, 0, -1, -1, -2, 6, 0, 1, -2 },
- { -23, 10, 4, 7, -32, -11, -18, 2, -2, -7, -6, -3, -3, -12, 19, 3,
- -5, -6, 16, -6, 16, 2, 16, 16, 8, -2, 13, 8, -15, -11, 2, 10 },
- { -8, 2, -13, 2, -29, 24, -20, 19, 1, 10, -4, 10, 1, 2, -9, 11,
- -1, -2, 9, -5, 19, -7, 16, -9, -2, -18, 11, 1, 1, 0, 7, -3 },
- { -6, 3, 4, 13, -26, 10, -10, 28, -7, 28, 1, 7, 0, -14, 5, 7,
- 4, -4, 3, -2, 3, 3, -11, 7, 6, 4, 0, -1, 2, -1, -3, 2 },
- { -6, 16, -31, 13, -10, 17, -6, 4, -14, 4, 4, -1, -10, 12, -5, 1,
- -14, 15, 0, -8, 1, -5, 3, 3, 9, -5, 7, -20, 7, 4, 11, -5 },
- { -19, 3, -17, 14, -12, 16, -22, 18, 14, 8, -2, 4, 10, 12, -14, 4,
- -3, 2, 3, 7, -7, 7, -6, 2, -2, -4, -5, 0, -5, -2, 2, 1 },
- { -9, -7, -11, 24, -36, -9, -11, 5, 7, -12, -13, 18, -2, 20, 1, -4,
- -1, -10, 15, -6, 14, 1, 0, 2, 1, 2, -9, -16, -11, 7, 13, 0 },
- { -24, 24, -18, 18, -22, 14, -11, 13, -12, 11, -10, 11, -7, 11, -5, -4,
- -1, 1, 5, 2, 3, -1, 1, -5, 7, -4, 5, -6, 8, -7, 8, -6 },
- { -6, 18, -22, 22, 5, 11, -1, 6, 19, 22, 8, 4, -8, 20, -2, 15,
- -6, -18, 0, -33, -9, -12, -1, 6, 5, 2, 5, 5, -5, -17, -3, -3 },
- { 1, 11, -16, 9, -18, 11, -4, 18, 20, 26, -10, 8, 1, -11, 8, -4,
- 0, 7, 3, 5, 2, 2, 10, -2, -4, 4, -4, -2, 1, -4, -5, -1 },
- { -10, 6, -1, 18, -17, 27, -3, 10, -2, 12, -7, -9, 1, 1, -1, 7,
- -12, -1, -7, -6, -1, 8, 3, -15, 8, 9, 3, -7, 4, -1, 1, -1 },
- { -14, 6, -16, 22, 2, 5, 0, 5, -18, 11, 6, -3, 22, -20, -9, -3,
- 6, -6, -7, -15, 1, 15, -8, 11, 8, -3, -8, 1, -8, 2, 6, -2 },
- { -21, 5, -19, 19, -7, 4, -7, 0, -8, 6, 12, 5, -3, -22, -13, -6,
- -1, -3, -2, -14, 6, -3, 1, -8, -7, -5, -6, 11, -3, -10, -5, 2 },
- { -1, 9, -12, 15, -6, 6, -19, 14, -9, 11, 3, 12, -17, -3, 8, -4,
- -3, -4, 1, -5, 4, 5, -7, -15, -7, 15, -6, -5, 1, -5, -3, 1 },
- { -12, 20, -15, 20, -14, 3, -14, 9, -6, 33, -13, 6, -2, 8, -6, 7,
- -5, -6, -3, -3, 0, 8, -3, -3, 1, -2, 2, 2, 6, -5, -5, -2 },
- { -7, 12, -18, 12, -18, 10, -4, 8, 2, 4, 8, 9, 0, 3, -8, 3,
- 6, -12, -4, 1, 25, -5, -9, 6, -7, 0, -9, -7, 3, -5, -4, -4 },
- { -18, 12, -10, 11, -22, 0, -15, 5, -2, 2, -3, 6, -4, -4, -3, -15,
- -2, -3, 21, 6, -12, -11, 19, 3, 3, -14, 7, 0, -11, -22, -10, 0 },
- { -15, 2, -30, 15, -17, 13, -16, 8, -7, 10, -8, 2, 11, 3, 10, -7,
- 7, -22, 12, -10, 3, -12, 6, -10, 12, -10, 7, -8, 5, 2, 9, 1 },
- { -9, 11, -14, 6, -10, 21, 5, 12, -5, 5, 7, 21, 6, 2, -2, -1,
- -1, 4, 2, -20, -18, -1, -14, 3, -1, 4, -7, 10, 1, 11, 4, -4 },
- { -22, 8, -30, 13, -21, -4, 4, -1, 12, 9, -2, -3, 2, -6, 4, -13,
- -2, 8, 8, 1, -7, 3, -4, -5, -1, -7, -2, 8, 8, 7, 8, 0 },
- { -6, -4, -35, 16, -13, 15, -11, 14, -7, 9, -1, 11, 7, 0, 13, 10,
- -1, 8, 1, 1, -2, 8, -1, 2, 2, 3, -10, -1, 7, -13, -3, -7 },
- { -15, 7, -16, 14, -18, 17, -6, 14, 3, 4, 7, -3, 10, -22, 5, -15,
- 4, -4, -11, 15, -15, 11, -11, 20, 1, 0, 2, 1, 11, -3, 11, -7 },
- { -12, 3, 5, 16, -37, -1, 15, 15, -15, 10, 3, -10, 1, 15, 7, -15,
- -13, 8, 9, -3, 2, 12, -8, 2, -5, 0, -3, 4, 5, -9, -4, 5 },
- { -16, 26, -4, 14, -22, 26, 6, -3, -8, 4, 21, 6, 16, -4, -11, 7,
- -10, 3, 3, 7, -4, 2, -9, 8, -2, 2, 5, -2, -4, -2, 7, -1 },
- { -7, -10, 4, 3, 2, -4, -12, -10, -4, -5, 16, 19, -16, 1, 2, -9,
- -10, 0, 9, 7, -8, 3, 12, 8, -6, -11, -13, -1, -3, -20, 6, -5 },
- { -14, -17, 3, -5, 14, -12, -12, 8, -6, -25, 21, 21, 10, -8, -12, 4,
- 10, -4, 3, -9, 11, 9, 0, 4, 2, -15, 1, -14, 4, 1, 0, -4 },
- { -4, -9, -3, -1, 6, 3, -6, 6, -10, -4, 14, 8, 2, -3, -12, -19,
- 0, 11, -20, 1, 6, -2, -27, -6, 10, -17, -14, -17, -9, 8, -8, 3 },
- { -12, -13, 16, -4, -2, 12, -7, -11, 2, -13, 3, 7, -16, -18, -1, -12,
- -2, 1, -12, -9, -2, -6, 2, 9, -22, -3, -4, -14, -7, 7, -1, 2 },
- { -7, -8, -8, 15, 15, 18, 15, 16, -4, -37, 11, 15, -12, -1, -3, 3,
- 6, 6, 0, -5, -3, -5, 9, 1, 1, -11, -1, -8, -6, 2, 3, 0 },
- { -6, 7, -5, -12, 13, 10, -18, -4, -3, -21, 6, 16, -15, -7, -12, -9,
- 1, -12, -1, 10, -2, -1, -3, 4, -4, 1, -16, -1, 12, -9, 5, 9 },
- { -14, -5, 9, 3, 4, 26, -28, 3, -6, -24, 4, 5, 3, 13, 5, -1,
- 3, -1, 3, 1, 1, -5, 3, 0, -7, -8, -7, -3, 3, -5, 4, 0 },
- { -4, 2, -10, -6, 25, 26, -6, 10, -6, -8, 15, 11, -6, -3, 2, -7,
- 5, 14, 9, -1, 0, -12, 4, -4, -10, 1, -3, 3, -2, -2, -6, -1 },
- { -10, 8, -15, -10, 19, 17, -8, 0, -3, -7, 7, 5, -13, -1, 7, -7,
- 1, 13, -12, -13, 17, -12, 1, 26, -18, -3, -5, -6, 4, 5, 8, 1 },
- { 2, -5, 3, 0, 0, 0, 2, -3, -2, -5, 7, 13, -4, 9, 0, -5,
- 4, -1, -11, -8, -4, 0, -13, 2, -47, -23, -8, -11, -4, 4, -2, -3 },
- { -18, -4, 4, 5, -1, 17, -12, -8, 1, -12, 7, 20, -12, 3, -2, -11,
- 16, 12, -6, 1, -13, -16, -6, -3, -3, -5, 4, -12, -5, -9, 10, 1 },
- { -11, 0, 4, 7, 7, 8, 3, -1, 3, -19, 32, 8, -19, -8, 2, 4,
- -12, 15, -16, 3, 1, 9, -2, 1, -2, 8, 5, 6, -4, -1, 11, -8 },
- { 3, -1, 4, -2, 14, 32, -9, -23, -10, -12, 22, 15, -1, -2, 10, 0,
- 4, 6, -8, 4, -15, -2, -1, -4, 0, -8, 4, 1, -8, 3, 4, 1 },
- { -17, -12, 6, -8, 16, 13, -20, -8, -1, -16, 10, 21, -19, 11, -9, -5,
- 7, 18, -6, 7, -7, -18, 13, 2, -2, 8, -12, -9, 2, 4, -5, 16 },
- { 4, 0, 17, -11, 12, 7, -12, 5, -1, -25, 30, -8, -7, -6, -4, -7,
- 9, 8, 7, 3, 3, -16, 8, 0, -2, -2, -18, -3, -4, -5, 1, 4 },
- { -3, -6, 6, -16, 17, 6, -3, 2, -9, -17, 12, 11, 11, 2, -20, 8,
- 1, 1, 0, 2, -2, -6, -21, -13, -9, -15, -1, -8, -6, -8, 0, -2 },
- { -11, -7, 6, -9, 3, 6, 8, 16, 4, -5, 23, 26, -10, -3, 4, 0,
- 2, 2, -4, 4, -2, -12, 12, 10, -11, 0, -10, -16, 3, 0, 0, -10 },
- { -5, -16, 10, -6, 27, 13, -3, 4, -2, -13, 15, 5, 2, 5, 3, -4,
- 13, 12, -11, -7, 0, 1, 11, 12, 2, 13, -15, -8, 9, -2, 3, 8 },
- { -5, -8, 4, 3, 9, 3, -11, 10, 14, -25, 14, 8, -2, 5, -12, -21,
- 2, 10, -7, 2, -3, 2, 0, 2, -1, -3, -5, -6, -1, -16, 2, 8 },
- { -1, 5, 1, -11, 5, 9, -7, 8, -13, -12, 4, 12, -4, 1, -1, -1,
- 27, 29, 10, 15, 2, -6, -3, 4, -21, 10, -9, -11, -6, -1, -9, -3 },
- { -6, -3, -1, -6, 11, -5, 0, -2, -5, -31, 11, 3, -1, 5, -3, 4,
- 5, 7, -10, 5, -10, -13, 4, 12, -15, -2, 2, -7, 1, -9, -3, -10 },
- { -3, -7, 17, -8, -5, 36, 8, -7, -8, -20, 12, 8, 1, -1, 3, 0,
- 1, 4, -10, 3, 1, 4, -2, -3, -2, -3, -10, 4, -1, -7, 3, 2 },
- { -13, -3, -5, 9, 22, 6, -23, 3, -10, -7, 17, 17, 18, -14, -8, -8,
- 2, 4, -8, 2, -3, -8, 6, 4, -1, 7, 0, 0, -3, 0, -12, -3 },
- { -3, -10, -15, -3, 9, 3, -23, -9, -13, -18, 12, 13, -2, 0, 1, 8,
- -1, 2, -7, -12, -5, 14, 2, 1, -22, 6, -10, -8, -9, 28, -7, -14 },
- { -3, 1, 2, -1, 13, 7, -2, -7, 1, -3, 6, 9, -3, -2, 4, -2,
- 2, 1, -10, -2, -2, -22, -2, -7, -10, -5, -11, -27, -12, -16, 4, -7 },
- { 2, -6, -3, 1, 8, 0, -2, 12, -3, -4, 58, 15, -10, -4, -2, 2,
- -2, 0, -2, -6, 2, 4, -1, 1, -4, 1, -1, -5, -4, -3, 3, 1 },
- { 10, -1, 0, 5, 21, 7, -14, 6, -3, -16, 15, 17, -16, 13, 3, -6,
- -4, 6, -12, -5, 1, -4, -7, -8, 2, 3, -6, 6, -1, -8, 5, 4 },
- { -6, -2, -8, -11, 15, 10, 0, 8, -6, -15, 33, 8, -2, 18, -15, -11,
- 5, -1, 0, 15, -15, -4, -4, -1, 10, 7, -13, 4, -4, 0, 8, 3 },
- { -7, -2, 0, -2, 0, -2, -4, -5, -14, -16, 12, 38, 7, 12, 6, -4,
- 0, -1, 0, 3, -2, -6, 0, 2, -9, 1, 0, -1, 0, -2, 4, 1 },
- { -8, -4, 18, 1, 14, 5, -12, -3, 20, -17, 5, 19, -11, -8, 11, -3,
- 3, 9, -7, -8, 9, -17, 2, 15, -10, -11, 5, -5, 7, 15, -6, -2 },
- { -7, 2, 38, 5, 19, 16, -5, 4, -13, -20, 0, 4, -4, 6, 4, 2,
- -7, 6, -8, -2, -5, -7, 6, 3, -4, -3, -2, -3, 7, -6, -4, 0 },
- { -11, -12, 8, -15, -3, 14, -7, -22, -11, 2, 22, 14, -19, 2, -19, -6,
- 1, 3, -18, 14, 2, -6, -2, -8, -3, -6, 5, -7, -8, -4, 1, 1 },
- { 8, 7, 25, -21, 12, -6, -5, -4, -10, 6, 0, 10, 1, -12, 18, -5,
- -15, 4, 1, 14, -1, 5, 8, -7, 1, -7, -3, 9, 10, 1, -1, 0 },
- { 9, 10, 32, -15, 8, 2, 11, -7, -18, -8, 2, -6, -9, -16, -3, 3,
- -1, 3, 1, -5, 4, -2, 1, -8, 0, -6, -3, -11, 1, 5, 0, 0 },
- { 14, 0, 23, -25, 22, 3, 7, 10, 0, -2, 7, 8, 0, 10, 0, 0,
- 3, 2, 3, -10, 0, 10, 0, -7, 0, 10, -1, -5, -7, 1, -1, 2 },
- { 12, 0, 25, -18, -5, -4, 13, -10, 3, -6, 7, 21, 0, -16, 3, -10,
- -6, 5, -7, -3, 2, 5, 3, -6, 4, 9, -8, 12, -2, 3, 2, 4 },
- { 31, 15, 27, -20, 10, -7, 15, -10, 9, -8, 4, -5, 3, -3, 5, 6,
- 11, -2, -12, -2, 6, -2, 1, 2, -1, -1, 1, 1, 3, 1, 1, 2 },
- { 12, -4, 13, -23, 12, -6, 2, 4, -3, 13, 6, -7, 5, -19, -7, 18,
- 1, -7, 7, 1, 16, -7, 3, 0, 3, 0, -12, 8, -11, 9, 4, 7 },
- { 29, 1, 3, -22, -5, 6, 0, 12, -14, 11, 1, 6, -3, 4, 6, -2,
- 4, -13, 12, 1, 1, 3, -11, 9, -10, -1, -7, 16, -11, -1, 3, 9 },
- { 4, 4, 36, -23, -5, -8, -15, 1, -6, 3, 13, -1, -5, -7, 4, 9,
- 2, -11, -3, 5, 1, 3, -6, -1, -4, -4, -2, 2, 3, -1, -5, -2 },
- { 19, 10, 6, -17, 2, -4, -2, -4, -3, 13, 2, 2, -13, -7, -3, -11,
- 9, -6, 1, -9, -5, 4, -5, -9, -18, -7, -11, 9, 4, -11, 8, 4 },
- { 16, -3, 9, -16, 18, -2, -12, -16, -11, 11, -18, 16, -13, 6, 2, 8,
- 3, 8, -4, -16, 10, -11, -1, -3, -8, 5, -9, -4, 9, -4, 0, -3 },
- { 14, 15, 3, -23, -5, 7, -8, -6, 2, 17, 2, 12, -8, -12, 13, -1,
- -9, 3, 1, 1, 19, 15, 4, -1, 1, 2, -3, 2, -3, 1, 5, 3 },
- { 32, 5, -10, -47, -5, -1, 4, 11, -7, 0, 2, -2, 1, -7, 6, -4,
- 6, 2, -4, -2, 2, -2, 0, -4, 1, -6, -5, 2, -2, -1, -3, -4 },
- { 20, 8, 10, -21, -7, -9, -16, 12, 1, 4, 6, -5, 9, -11, -7, 4,
- -11, 28, -3, 2, 4, -6, 10, -8, -5, -5, -9, 9, -2, -1, 6, -5 },
- { 38, 3, 23, -25, -6, -18, 3, -10, -8, 6, -10, 1, -10, 2, 2, 0,
- -7, 2, -4, 5, -1, 8, -3, 0, 3, 3, -1, 1, 0, -4, -4, 0 },
- { 20, 5, 16, -22, 24, -18, 2, -12, -14, -7, -3, 10, 2, 7, -10, 2,
- -8, 1, 8, -1, 4, 1, 4, -2, 5, -9, -18, -8, -13, 5, -11, 10 },
- { 14, 8, -12, -16, 9, -11, -3, -6, -25, -7, 6, 5, -7, -16, 10, 2,
- -7, -1, -9, -3, 16, 4, 3, 3, -3, -3, -15, 13, -3, 4, 13, -7 },
- { 16, -9, 19, -23, 7, -19, -3, -5, -15, 11, -21, 21, -16, 18, -1, 6,
- 10, -10, 18, -14, 16, -15, 6, -5, -9, 5, -17, 13, -10, 13, 0, 10 },
- { 8, -4, 4, -24, 8, -21, -18, 9, -11, 4, -6, 17, 5, -9, -2, -2,
- 2, 15, -2, -3, -2, 1, 7, -13, 15, -10, -8, -11, 3, 3, -1, -1 },
- { 14, 17, 6, -32, 5, -17, -2, 0, 15, -1, -5, 16, 1, -5, -2, 9,
- -3, 8, 4, -2, -2, -4, -3, 1, 0, 7, -3, 4, -5, 0, -7, 2 },
- { 24, 6, 22, -12, 8, 3, -14, 4, -7, 8, 6, 5, 6, 1, 6, -12,
- 15, 10, 4, 11, 9, 6, -7, -4, 10, -9, 2, -1, -5, 11, 15, 3 },
- { 17, 12, 3, -23, 5, -1, -2, 1, -9, -1, -3, 1, 8, 1, -5, 17,
- 11, 0, -2, -11, 7, 4, 0, -27, -7, 1, 2, -8, 9, 7, 5, 3 },
- { 12, 10, 12, -10, -4, 5, -1, 2, -24, 5, -8, 2, 6, -17, 19, 5,
- 12, -2, 16, -7, -6, -14, 4, 1, -3, 13, -16, 5, -1, 4, 1, 1 },
- { 31, 9, 11, -17, 10, -3, -7, 7, 1, 2, 2, 4, -3, -1, 11, 4,
- -5, -8, 1, 4, 15, -6, -28, 1, 8, 3, -6, 5, 17, -2, 2, -4 },
- { 11, 19, 16, -26, 0, -7, -7, 2, -13, -15, -12, 9, -3, 27, 8, 4,
- -6, 1, 4, -6, 11, -1, -6, -7, -3, 0, -6, 4, -6, -7, -3, -1 },
- { 10, 18, 16, -32, 19, -9, -4, -3, -7, 8, 8, -3, -11, -2, -6, -16,
- 13, 13, -6, -1, 10, -2, -2, -9, 0, -3, 9, 4, 11, -2, -6, 6 },
- { 9, 4, 19, -33, 4, 7, -12, 36, -3, -1, 8, -2, 2, -8, -9, -4,
- -8, 0, 1, -1, 0, -4, -4, 3, 0, 3, 6, 0, -6, 2, 0, -2 },
- { 25, 7, 15, -12, 2, -24, -1, 24, -4, 4, 9, 0, -2, -9, 4, 6,
- 3, 13, -3, 1, 5, -1, -3, -5, -1, 7, -2, 3, 4, 4, 1, 0 },
- { 19, 6, 8, -20, 9, -9, 5, -4, -13, 7, 11, -3, 5, -13, -9, 6,
- -11, -1, 0, 4, 11, 26, 3, 6, -7, 12, 6, -3, 1, -9, 7, 1 },
- { 15, 6, 19, -23, -3, -9, 3, 16, -6, -4, 6, -5, -10, 1, 16, -14,
- 2, 0, 2, -13, -3, 8, -6, 3, 1, 1, 2, -5, 12, -4, -8, -3 },
- { 14, 4, 16, -20, 1, 12, 0, 6, -3, 9, 4, 16, 10, -16, 5, 7,
- 5, -4, -4, -18, -3, -11, -4, 4, -7, 3, 13, 7, 3, 3, 2, -7 },
- { 22, 3, -1, -30, 18, -3, -9, 9, -2, 11, -16, -2, -14, 12, 0, 4,
- -5, 4, -1, 3, -20, 12, 4, -10, -2, -2, -12, -12, 10, 6, 11, -3 },
- { 15, 7, 2, -21, 5, 4, 9, -9, -33, 7, 7, 3, -6, -14, -8, 10,
- 12, 0, 2, -1, 5, 4, -2, 0, -7, 0, 2, 4, 0, 1, -3, 8 },
- { -7, 0, 12, 3, 0, -6, 8, -4, 0, 2, 14, -15, 2, -7, -31, -3,
- 14, 0, 14, -15, -1, -4, -15, 10, 1, -3, 1, 2, 5, 2, -8, 1 },
- { -2, 5, 1, 0, -3, 3, 3, -6, -1, 2, -4, 1, -19, 0, -11, 18,
- 11, 10, 21, 5, 6, 2, 10, 3, -6, 0, -2, 13, 5, -1, -2, 9 },
- { -9, 1, -5, 0, 0, -15, 8, 4, 8, 3, 8, 12, -13, -2, -39, -2,
- 4, -4, 5, -3, -4, 3, -3, 3, 10, 5, 3, 2, -3, 5, -2, 8 },
- { -9, 6, 6, -8, 12, -12, 23, -18, 4, -15, -5, 2, -20, 13, -7, 7,
- 7, -12, 14, -12, 6, 1, 1, -3, -8, 9, 0, 1, -7, 3, 7, -6 },
- { -18, 13, 4, 3, -10, -30, -10, -6, -14, 1, -7, -4, -35, 5, -25, 11,
- 9, 8, 19, -4, -7, -3, -18, -8, 1, 5, 10, -4, -14, -9, 3, -4 },
- { -6, -1, 4, -9, -9, 4, 20, 0, 0, 3, 11, 7, -16, -17, -20, 11,
- -6, -14, 1, 4, 19, 2, -8, 6, -15, 3, 6, -5, -14, 3, 7, 2 },
- { 1, 6, -2, -8, -5, -3, 3, -8, 21, 1, 3, 16, -14, -2, -9, -4,
- 13, -2, 18, 14, 14, 19, -13, 5, -10, 2, -3, 3, 5, 5, 1, -1 },
- { -1, -5, -6, -2, -11, -7, 5, -4, 5, -1, 0, 3, -3, 2, -19, 18,
- 16, 4, 14, -22, -2, -11, -22, 1, -1, 11, 1, 2, 11, -10, 7, -12 },
- { 1, 4, 5, -1, -9, -5, 1, 12, 5, 6, 12, 9, -24, 23, 1, 20,
- 14, -11, 13, 5, -2, -2, 5, 6, 2, 1, -9, 6, 10, 5, -4, 11 },
- { -1, -1, 1, 7, -3, -4, 8, -16, 15, -1, -7, 9, -22, -11, -11, 10,
- 16, 9, -2, 4, 13, 10, 6, 16, 4, 7, 1, -8, -7, -14, -7, 4 },
- { 1, 3, -6, 0, 15, -9, -4, 0, 4, 6, 12, 9, -6, -5, -22, 17,
- 7, -11, 15, -5, 1, 3, -19, 0, -15, -3, 16, 5, 5, -7, -11, 12 },
- { -2, -1, 13, 2, 4, -24, 37, -5, -2, -6, 12, 7, -2, -23, -4, 9,
- 2, -3, 3, 2, 3, 3, -14, 11, 0, -4, -2, -2, 3, 10, -10, 4 },
- { 2, 9, 8, -6, -28, 14, 28, -11, 18, -11, 0, 2, -2, 4, -12, 3,
- 6, 0, 7, -7, -6, 2, 5, -1, -1, -1, 5, 2, 3, 0, -3, 9 },
- { -7, 14, 5, -10, -3, 7, 4, -5, 7, -8, -7, 4, -12, 14, -16, 25,
- 3, 0, 1, -5, 12, -10, 0, -10, 0, 12, 12, 17, 12, 10, -1, 0 },
- { -4, -2, 5, -2, -17, -3, 5, -5, 7, -17, 1, 5, -4, 4, -20, 0,
- 11, -15, 13, -8, 10, 1, 1, 5, -12, 9, -8, 0, 6, -1, -11, 4 },
- { -3, 12, 13, -15, -7, -7, 0, 5, 33, 3, 3, -6, -13, -7, -15, 10,
- 3, 3, 3, -5, 2, 7, -1, 0, -12, 2, 11, -6, -9, 0, 5, 11 },
- { -8, 5, 10, -7, -14, -4, 13, 0, 18, -3, -6, 7, 1, -6, 0, 21,
- 8, -7, 10, -8, -3, 17, -9, 0, -5, 1, 4, 8, -3, 11, -5, 0 },
- { -8, 8, -3, -8, 8, -11, 16, -16, 17, 0, 8, 16, -17, 10, -16, 10,
- -8, 6, 11, 0, 10, 7, 4, 5, 7, -5, -5, -6, -7, -5, -1, 16 },
- { -6, 0, 6, 1, -8, -8, 8, -7, -5, -10, -11, 8, -19, 6, -7, 13,
- 5, -3, 4, -8, 7, -1, -18, 9, 0, -5, 6, 26, 3, 8, 2, 4 },
- { -2, -2, 23, -2, -20, 2, 7, -7, -6, -15, 3, 9, -19, -2, -10, 7,
- -2, 7, 9, 11, 0, 4, -4, 6, 9, -2, 4, -3, 4, 3, 2, 8 },
- { -6, 12, 10, -10, -7, 4, 17, 11, -6, 1, 12, 11, -18, 8, -12, 4,
- 1, 13, 6, -13, 23, 9, -5, 8, -2, -5, 1, 3, 0, -2, -4, 4 },
- { 7, 1, 7, -17, -8, 8, -1, -7, 5, -6, 4, -3, -16, 9, -24, 18,
- -3, 10, 13, -11, -6, -11, -4, 10, 0, 11, 8, 2, 6, -5, -11, 4 },
- { -4, 1, -5, -10, 0, -3, 9, -2, 4, -1, 1, 5, -41, -10, -7, 4,
- -3, 3, 1, 0, -12, 4, -3, 0, 2, -1, -2, -5, 3, 2, -7, 5 },
- { -2, 1, 4, 4, -3, -6, 1, 0, 12, -5, 11, 0, -17, -3, -1, 11,
- 4, 1, 27, -12, 0, -14, 2, -15, -3, -9, 0, -7, -3, 15, -8, 6 },
- { -6, 4, 9, 2, 4, 3, 7, -10, 28, 1, -2, 48, 7, 0, -10, 10,
- 1, -9, 2, -1, 0, 3, -5, 5, -4, -2, 7, 7, 1, 3, 2, 5 },
- { -3, 3, -1, 3, -9, 0, -1, 3, 2, -6, 39, -14, -12, 5, -19, 21,
- 7, -6, 4, -1, -4, 0, -4, 1, 0, -9, 1, 10, 0, -2, 0, 7 },
- { 4, 2, -29, 12, 5, -3, 16, -6, 15, -13, -4, -1, -13, 22, -16, 17,
- 16, 4, 9, -4, 4, -6, -4, 11, -8, 7, 8, 4, 3, -3, -7, -13 },
- { 0, 3, 3, -6, -4, 0, 9, 0, 5, 0, 10, 10, 4, -13, -12, 16,
- 23, -4, -12, -6, -4, 20, 2, 0, -4, 23, 1, 8, 11, -4, -5, 15 },
- { -6, 4, -15, -9, -1, -19, 12, -30, -17, -4, 1, -13, -13, 4, -3, 26,
- 5, -25, 11, -14, -6, -13, 0, -7, 9, 2, 8, -1, -8, 1, -8, 13 },
- { 1, 6, 1, -4, -4, 1, 2, 0, -3, 2, 10, 6, -6, -2, -11, 4,
- 32, 15, 15, -47, -8, 3, -12, 4, -5, 4, -1, 0, -5, 5, 1, -7 },
- { 2, -1, 0, 0, -1, -6, 0, -6, 4, -4, 5, 9, -5, 1, -3, 51,
- 4, -5, 4, -14, -1, -4, -3, 1, -4, -1, 0, 2, -8, 0, 1, 2 },
- { 0, 4, -2, -7, -2, -9, 6, -8, 11, -3, -6, 3, -11, -8, -12, 8,
- 11, 5, 19, 3, -24, 19, -14, 11, -5, -18, -8, -12, -5, -4, -1, 4 },
- { 16, 9, 10, 14, -18, -2, -18, -27, 10, -5, 12, 14, 4, 0, -2, -6,
- -12, -7, -1, 3, 4, 7, 11, 10, 5, -5, -7, -16, -3, -6, 6, 9 },
- { 7, 15, -9, 10, -19, 4, -5, -37, -2, -4, 8, 2, 4, -1, 1, 9,
- -5, -5, -12, 1, -1, -8, 3, -3, 4, 6, 9, 3, 3, -1, 2, 4 },
- { 13, 17, 3, 9, -7, -7, -15, -17, -8, -13, -4, -8, 19, 2, 16, 25,
- 7, 15, 2, 16, -5, -6, -10, -9, -7, -6, -2, -7, 7, 2, 4, 5 },
- { 24, 7, 9, 8, -13, -2, 0, -4, 1, -13, 3, 6, 7, 10, -4, 15,
- 5, 7, -4, 5, -5, 3, 13, -7, 5, 15, -11, -2, 7, 5, 8, 6 },
- { 17, 6, -15, 23, -2, -1, -6, -2, 0, -4, 11, -3, 12, 15, 6, -8,
- -15, 10, -9, 7, -1, -11, 2, -8, -4, 3, 4, -10, 4, 4, 11, 1 },
- { 21, 12, -3, 6, -8, 8, -11, -8, -5, -5, 3, 7, -1, -5, 12, 15,
- -10, -11, 3, 15, 8, 4, 2, -15, 0, 14, 1, -8, -1, 3, 10, -7 },
- { 16, 12, 5, 13, -6, 15, -23, 0, -17, -9, 0, 4, -9, 13, 6, 18,
- 0, 0, -4, -1, 0, 14, 5, -1, 8, -4, -8, -6, 5, -2, -2, 0 },
- { 14, 16, -1, 12, -15, -9, -6, -20, 4, 6, 8, 9, 3, 1, -9, -4,
- -1, -11, 9, 11, -12, 1, -14, -7, 2, -8, 11, 9, -4, 10, 4, -16 },
- { 13, 10, 3, 7, 0, -8, -33, -6, 4, -4, 19, -2, 14, 6, 5, 7,
- 6, -3, -1, -10, -10, -9, 4, -3, 5, 9, 2, 2, 10, 9, -2, -3 },
- { 11, 10, 25, 18, -1, -6, -21, -21, -11, -16, 6, 5, 14, 4, 8, 7,
- 0, -10, -7, -9, -5, -4, 3, -1, 1, 6, -1, 6, -2, 2, -3, -9 },
- { 15, 9, 5, 22, -17, 15, -9, 7, 7, -9, 13, 9, 10, -1, 8, -3,
- -2, 6, 1, 17, 8, -14, 7, -3, 12, 9, 1, 0, 1, -5, 17, -18 },
- { 25, 19, -17, 12, -4, -10, 1, -13, -19, -7, -3, 9, 6, -2, 3, 1,
- 4, -2, -11, -14, -1, -7, -5, -9, 7, -1, -3, 4, -5, 1, 0, -1 },
- { 20, 8, -3, -10, -24, 3, -6, -2, 0, -12, 14, 6, 7, 11, 4, 7,
- -12, -5, -8, -10, 5, -1, -4, 4, 16, 7, -14, 6, -1, -2, -7, -11 },
- { 16, 18, 17, 1, -15, -6, -5, -3, -1, -19, 8, -2, 2, 8, 12, -19,
- -12, 8, 0, -3, -1, -1, 4, -14, 9, -1, -12, -1, -7, 10, -3, 5 },
- { 18, 12, -7, 7, 0, -3, -13, 0, -1, -4, 9, -2, 6, -1, 0, 1,
- 15, -21, 1, -8, 25, -19, 13, -9, 2, 12, 5, -7, -3, -1, -3, 1 },
- { 13, 16, -4, 9, -2, 2, -1, -19, -7, -4, 18, -6, 14, 18, -5, 4,
- -6, -3, -19, -14, -1, -12, 10, 6, 7, 17, -12, -13, -10, -4, 5, 4 },
- { 27, 17, 4, 14, -9, -2, -4, -8, 0, -6, 14, -11, -7, 2, -3, -3,
- -2, -3, -13, 12, 16, 1, -5, -9, -10, -11, -2, 3, -7, 5, 11, -7 },
- { 7, 17, -16, -2, -14, -28, -7, -8, 15, -10, 7, 15, 8, 17, 13, -1,
- 4, -7, -12, -11, 0, 0, 2, 3, -3, 7, -6, 6, 1, -16, 1, -2 },
- { 23, 11, -9, 15, -23, -4, -6, -4, 2, -9, -7, 9, -8, 3, -13, -4,
- 8, 18, -6, -2, 1, -5, 6, -14, -5, -2, -6, -5, -3, -2, 4, -5 },
- { 12, 13, 18, 18, -35, 2, 7, -17, 3, -11, 6, 9, -3, -2, 10, -4,
- 3, 3, -2, -7, 0, 2, -4, 0, -4, 0, -6, 5, 10, 4, -3, -1 },
- { 19, 11, 1, 20, -14, 4, -9, -13, -2, 11, 0, 17, -1, -1, -1, -1,
- -5, -8, 0, 5, -1, -8, 5, -1, 3, 2, -12, 21, -2, -24, 5, 7 },
- { 15, 15, -15, 17, -14, -22, 3, -4, -11, -3, -7, 1, 18, 10, 1, 10,
- -6, -3, 8, 2, -7, 0, -2, 1, 1, 2, -9, -2, 1, 2, -3, 4 },
- { 45, 13, 8, 17, -5, 2, -16, 2, 8, -2, 8, -15, 4, 5, -1, 7,
- -6, -2, -6, 2, -3, 0, 0, -9, -1, 7, 2, 3, -3, -3, -1, 5 },
- { 1, 18, -8, 18, -12, -10, 3, 4, -22, -12, 20, 8, -3, 9, 2, 10,
- -10, -3, 9, 3, 6, -3, 10, -1, -3, 2, -2, 4, 2, 3, -3, -18 },
- { 9, 10, -5, 9, -35, -21, -18, -16, -1, -12, -6, -7, -15, -19, 12, 4,
- 4, 9, -7, 2, 14, 1, 4, 0, -1, 6, -7, 2, 1, 1, -4, 4 },
- { 31, 8, -17, 35, -8, 1, -5, -6, -7, -6, 10, -2, -3, 6, 9, 3,
- -6, -2, 3, 3, 5, -3, 0, 6, 0, 1, -5, -3, -2, -4, -1, 0 },
- { 18, 4, -8, 7, -8, -15, -1, -16, 12, 18, 3, 19, 2, 4, 8, 8,
- 0, -5, -8, -12, 10, -5, 0, 1, 0, 4, -3, 16, 11, 11, -2, -6 },
- { 27, 15, -17, -10, -23, -22, -1, -14, -4, -7, 20, -2, -7, 6, 15, -5,
- 32, 4, 9, -11, -3, -8, 11, -4, -1, -4, -8, -6, -4, -5, -2, -7 },
- { 22, 4, -7, 2, -15, -11, -17, -10, 2, 0, 15, 11, 7, 12, -8, 6,
- -10, -18, -6, -12, 7, 3, 22, 3, -7, 14, -5, -2, -13, -7, -1, -7 },
- { 18, 13, 9, 24, -4, -19, -9, -11, 13, 8, 2, 4, -1, 8, 14, 10,
- -12, 0, 0, 5, 10, 5, 4, -1, 5, 1, -1, 11, 2, -4, 0, -9 },
- { 15, 19, -5, 1, -4, -10, -8, -27, 6, 8, 5, 10, 4, 11, 5, -5,
- -11, 0, -11, -14, -4, -9, -8, -8, 6, -9, 4, -5, -1, 1, 5, -4 },
- { 18, 1, -13, 14, -14, 9, -15, -7, 12, 1, 13, -4, -20, 12, 10, 12,
- -12, 7, 1, -13, 10, -6, 5, -3, 4, 8, 10, -13, -3, -6, 9, -3 },
- { 19, -14, 5, -8, -6, 2, -5, 5, -3, -1, -28, 11, 18, -6, -4, -2,
- 11, 14, -43, -42, 9, 2, 20, -23, 6, 32, 0, 5, 0, 6, 9, 5 },
- { 8, 11, -14, -1, 7, 12, -7, 2, -16, 2, 10, -3, -1, -7, -7, -1,
- 1, -10, -60, -23, -18, 42, -13, 9, 18, -11, 0, 1, 0, 2, -5, 1 },
- { -5, -1, 2, 0, 3, -3, 3, -2, -6, 0, -3, -3, 7, 2, 0, -2,
- -2, 3, -34, -15, 37, 47, 10, 20, 9, 1, 3, -21, -25, -33, -14, 8 },
- { 5, 6, 2, -2, -2, -2, 6, 5, -5, 7, -3, 1, -5, -13, 9, 3,
- -17, -19, -2, -79, -12, -7, -8, -6, -2, -2, -1, -1, -7, -13, 6, -1 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1,
- 0, 3, 4, -87, 6, -11, 16, -9, -1, 8, 0, 5, 0, 1, 2, 1 },
- { -5, 6, 2, -24, 5, -9, -7, 0, 7, 3, -3, 16, -14, -16, 0, 18,
- 15, -9, -14, -28, -17, 53, 14, -6, -28, -1, -3, -10, -7, -14, 19, -15 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0,
- -13, 0, -53, 3, -22, 63, 19, 16, 1, -11, 0, -3, 0, -3, 0, 1 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -1, -6, -43, -43, -2, 65, -13, -4, 9, 1, 1, 2, 1, 0, 0, 1 },
- { 0, 1, 0, 0, -1, 0, 1, 1, 0, 0, 1, 2, -1, -1, -3, -1,
- -23, 1, -61, -55, 3, -28, -6, -4, -4, 8, 2, 1, 1, -1, 0, 0 },
- { 0, 1, -1, 1, -1, 0, -1, 0, 1, -1, 0, 1, -1, 0, -9, -4,
- -48, -19, -52, -46, 11, -12, 5, -14, 0, -10, 0, 0, -1, -2, -1, 0 },
- { 0, -3, -1, -4, 2, -1, -7, 3, 1, 3, -1, 1, -3, 0, -7, 0,
- 3, -7, -61, -51, -4, -21, -16, -21, -11, 14, -7, 8, 3, -5, 1, 2 },
- { 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 9, -3,
- 56, -11, -6, -67, -1, 13, 0, 7, 1, -9, -1, -1, 0, 0, 1, 0 },
- { 14, 9, -2, 14, -10, -10, 9, -5, 1, -8, -23, 30, 8, -7, 23, 8,
- 2, 10, -1, -27, -17, 57, 22, 4, -5, 2, -12, -6, 2, -7, -4, -9 },
- { 1, 5, 12, -2, -2, -3, 2, -3, 6, 0, 4, -2, -8, -6, 0, 16,
- -15, 29, -55, -29, -24, 29, 3, 10, 6, 13, 10, -5, 21, 11, -14, 5 },
- { 4, 2, 26, -6, 10, 11, -23, -10, -27, -20, 3, -24, -11, -10, -13, 25,
- -10, 5, -9, -36, -7, 43, 3, -13, 6, 13, -2, 0, 1, 3, -3, -4 },
- { -1, 0, -1, 0, 0, 0, 0, -1, 1, 0, -1, 0, 0, 0, -1, 1,
- -12, 12, -26, -64, -15, 29, 37, -7, -3, -12, -5, 14, 8, -8, -10, -2 },
- { 19, -4, -11, -16, 8, 14, 5, 19, 3, 22, -11, -21, -1, -6, -11, 11,
- 10, -24, -23, -40, -8, 20, 17, 5, 13, -6, 3, 14, -20, -8, 3, 28 },
- { 2, -12, 10, -14, -18, 26, -22, 4, -2, 5, -21, 8, 3, 1, 19, 0,
- -12, 24, -14, -40, 15, 29, -15, 6, 15, 1, -19, 2, 4, 7, -12, -3 },
- { 0, 17, 13, 7, -5, -11, 2, -19, 3, 38, -21, -3, -6, -4, 7, 1,
- 1, -5, -40, -10, -2, 35, 8, 8, -10, -8, -9, 33, 4, 4, 0, -2 },
- { -2, -12, 7, 29, -24, 2, 16, -1, -7, 16, 10, -2, -2, -2, 13, -2,
- -37, 15, -22, -40, -11, 33, 10, -1, 8, 10, 6, 8, 9, 0, -12, 2 },
- { 15, -8, -9, -2, 7, -17, 7, 19, 14, 4, 12, 27, 11, 10, 4, 11,
- -15, 14, -13, -48, 5, 18, 0, -9, -36, -11, 2, 4, 5, 5, -15, -12 },
- { -12, 0, 3, 4, 7, -5, 5, -14, -24, -18, -6, -15, -8, -20, 1, -7,
- -33, -28, -40, -38, -18, -10, -5, 17, -12, 4, 3, -5, 5, -13, 4, -7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9, -49, -60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9, -49, -60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 3, -2, 9, -29, -11, 55, 8, 32, -36, -13, -7, 37, 4, 11, 0, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, -1, -39, -4, -30, 63, 28, -17, -6, 10, 7, -14, -9, 11, 9, 7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 13, -2, -50, -32, 22, 51, 4, 7, 6, 11, -20, -13, 9, -5, 21, -4 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9, -49, -60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9, -49, -60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 3, -2, 9, -29, -11, 55, 8, 32, -36, -13, -7, 37, 4, 11, 0, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, -1, -39, -4, -30, 63, 28, -17, -6, 10, 7, -14, -9, 11, 9, 7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 13, -2, -50, -32, 22, 51, 4, 7, 6, 11, -20, -13, 9, -5, 21, -4 },
- { -8, 2, 1, 22, -31, -6, -25, -3, -3, 1, -15, -11, -2, -3, 4, -13,
- -9, 15, -18, 37, -7, -37, 12, -13, -11, -25, -10, -11, -22, 7, 16, 7 },
- { 14, 10, 4, -10, -1, -5, -7, -3, 16, 13, -5, -15, 5, 11, -1, 8,
- -27, 7, -12, 49, 17, -22, 9, -2, -9, -1, 2, -15, -1, 41, -18, -17 },
- { -4, -9, -15, -3, 3, 4, 4, 2, 7, -3, -7, -8, -5, 17, -19, -7,
- 36, -9, -38, 17, 1, -48, 11, -18, -13, -2, -8, 4, -10, -5, 21, 11 },
- { 15, -13, 4, 2, 1, -5, -2, 1, -10, 7, -1, 3, -6, 0, 11, -11,
- 8, 20, -17, 51, -17, -41, 2, 15, 4, 8, -2, 16, -32, -1, 17, 6 },
- { -8, 8, -18, -5, 4, 6, -3, 8, 0, -4, 2, 0, -1, -4, 5, 8,
- 30, 30, -8, 70, 2, 8, 2, 0, 7, 1, 13, -1, -6, -7, -11, 2 },
- { -8, -7, 9, -10, -13, 6, -11, -14, 13, 25, -26, 5, 2, -5, -5, 5,
- -8, 4, 0, 33, 12, -38, -4, 6, 13, 6, 25, 34, -1, 25, -19, -5 },
- { 18, 3, -17, 4, -8, 7, 20, 1, -1, 5, -5, -2, -8, 8, -35, 15,
- 24, 43, -5, 51, 5, -12, -3, 1, -2, 3, -3, -3, -9, 8, -9, 2 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- 2, 10, 24, 76, -2, -22, 11, -1, 4, 33, 4, 1, -1, 1, 2, 0 },
- { 0, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0,
- 24, 13, 32, 70, 26, 5, -21, -9, -6, -15, 2, -2, 2, 4, 1, 1 },
- { 5, -4, -11, 4, -4, 22, 10, -2, 13, -11, -4, -21, -17, 0, -7, 4,
- 10, -34, 11, 52, 2, -46, -5, 0, 0, -1, 2, 4, -9, 1, 1, -7 },
- { 0, 1, 1, 0, -1, 0, 1, 0, 1, 1, 0, 1, 0, 0, -3, 1,
- -8, 9, -1, 64, -13, -61, -3, 3, -5, 10, 1, 3, -1, -1, -1, -1 },
- { 0, 1, 0, -1, 0, -1, 0, 0, 1, 0, 0, 0, 1, 1, 2, 1,
- 10, -2, -31, 79, -10, 27, 0, -1, 3, 8, 1, 1, 0, -1, 0, -1 },
- { 3, 12, 10, 26, -19, 10, -9, 6, -4, -15, 10, 3, -16, 6, 11, -19,
- 3, 10, 18, 44, 5, -30, 5, -9, 21, 4, 20, 10, 14, -25, 8, -17 },
- { 0, 0, 0, 1, -1, 0, -1, 0, 1, 0, 1, 1, 0, 0, -6, -2,
- 8, -8, 13, 69, 26, -19, -25, -17, 16, 6, -12, 22, 2, -6, 9, 5 },
- { 0, -1, 0, 1, 0, -1, -1, 0, 0, 1, -2, 1, 0, 0, -4, -1,
- -34, -15, -33, 56, 9, -42, 9, 10, 6, 9, -8, -11, 0, -6, 15, 5 },
- { 10, 2, -14, -3, -15, -35, -1, 7, -18, 14, 8, -1, -15, -26, 6, -15,
- -18, 22, 9, 33, 0, -32, -9, 3, -11, 7, 4, -1, 5, 30, 9, 1 },
- { 4, 15, 0, 6, -5, -11, 9, 6, 6, 6, 14, 2, -1, 10, -24, -25,
- -2, -4, -1, 37, 2, -29, 14, -9, 22, 17, -2, 33, 10, -25, 11, -11 },
- { 0, 5, 2, 18, -12, 21, 22, 33, -7, 21, -9, -7, 7, -15, -7, 16,
- 7, 0, -14, 44, 10, -25, 5, -4, 15, -8, 10, -4, 5, 9, -1, 16 },
- { 3, 13, 12, 12, 8, 25, -23, 8, -22, -3, -18, -8, 15, 12, 9, 19,
- 0, 0, -9, 49, -27, -15, -9, -15, 12, -8, -16, -7, 13, 5, 13, 2 },
- { 12, -6, 7, -2, 20, -9, -14, 12, 13, -5, -17, 22, -8, -4, 2, 7,
- -13, -2, -15, 43, -5, -30, 27, 4, 10, -27, 5, 27, -10, -10, -18, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, 10, -18, 70, -2, -52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, 10, -18, 70, -2, -52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 15, -13, -20, 16, 2, 13, 5, -11, -8, -5, -3, 2, 24, -23, 30, -7,
- 11, 30, -15, 43, 5, -15, 15, -3, -14, 1, -23, 8, 3, 9, 4, -11 },
- { 0, -1, 0, 1, 0, -1, -1, 0, 0, 1, -2, 1, 0, 0, -4, -1,
- -34, -15, -33, 56, 9, -42, 9, 10, 6, 9, -8, -11, 0, -6, 15, 5 },
- { 10, 2, -14, -3, -15, -35, -1, 7, -18, 14, 8, -1, -15, -26, 6, -15,
- -18, 22, 9, 33, 0, -32, -9, 3, -11, 7, 4, -1, 5, 30, 9, 1 },
- { 4, 15, 0, 6, -5, -11, 9, 6, 6, 6, 14, 2, -1, 10, -24, -25,
- -2, -4, -1, 37, 2, -29, 14, -9, 22, 17, -2, 33, 10, -25, 11, -11 },
- { 0, 5, 2, 18, -12, 21, 22, 33, -7, 21, -9, -7, 7, -15, -7, 16,
- 7, 0, -14, 44, 10, -25, 5, -4, 15, -8, 10, -4, 5, 9, -1, 16 },
- { 3, 13, 12, 12, 8, 25, -23, 8, -22, -3, -18, -8, 15, 12, 9, 19,
- 0, 0, -9, 49, -27, -15, -9, -15, 12, -8, -16, -7, 13, 5, 13, 2 },
- { 12, -6, 7, -2, 20, -9, -14, 12, 13, -5, -17, 22, -8, -4, 2, 7,
- -13, -2, -15, 43, -5, -30, 27, 4, 10, -27, 5, 27, -10, -10, -18, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, 10, -18, 70, -2, -52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, 10, -18, 70, -2, -52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 15, -13, -20, 16, 2, 13, 5, -11, -8, -5, -3, 2, 24, -23, 30, -7,
- 11, 30, -15, 43, 5, -15, 15, -3, -14, 1, -23, 8, 3, 9, 4, -11 },
- { 16, -18, 7, -4, 31, -15, -9, -13, 20, -12, -6, 0, 12, -6, -2, 4,
- 3, -3, -1, 0, 1, 3, 3, -2, 1, 6, 4, 0, -3, 2, -5, 1 },
- { 38, -5, -13, -4, 8, -15, 11, 1, 2, -4, -1, 9, 13, 4, -12, -7,
- 0, -2, 7, 2, -6, -2, -3, -2, 3, -4, 6, 15, 1, 1, -11, -2 },
- { 47, -22, 9, -26, 3, -5, 2, -7, 4, -2, 2, -2, 3, 0, 3, -4,
- 3, -3, 2, -3, 7, -3, -1, 1, 1, -5, 5, 0, 2, -5, -3, -2 },
- { 14, -16, 2, -6, 7, -2, -7, -4, -4, -7, 14, -3, 7, -19, -14, -17,
- -29, 6, 26, 16, -5, 13, -4, -1, 21, 14, 1, 3, -6, 0, -7, -1 },
- { 29, -11, 5, -3, 4, 11, 4, -10, 1, -22, -3, -10, 5, 4, 2, 8,
- -2, -7, -12, -12, -8, -3, -18, -2, -9, -5, -1, -3, 2, -14, -14, 7 },
- { 28, -12, 5, 3, 9, -7, 0, -2, 2, 1, 4, 0, -7, -3, -2, 4,
- 4, 14, 8, -1, -4, 14, -7, 17, -2, -2, -9, 2, 19, -7, 9, -8 },
- { 31, -18, -22, 8, 15, -5, -10, -15, 1, 10, 6, 7, 6, -8, 2, -1,
- 12, -3, 3, -1, 1, 5, -6, -4, 0, 1, 7, -10, -2, 4, -3, -4 },
- { 53, -30, -4, 12, 2, 3, -3, -3, 0, 1, 6, 5, -5, -4, -7, 1,
- 0, 2, 1, 3, 1, 5, 0, 2, 2, -1, 0, 4, 2, 0, -2, 0 },
- { 27, -18, -3, -2, 4, -8, 3, -2, -11, 2, 10, -8, -8, -4, 0, -2,
- 8, 0, 9, 0, -16, 11, 1, -6, 13, -3, -10, -13, -15, 25, 1, 0 },
- { 35, -5, -1, -8, 23, 11, -14, -3, 2, -2, 8, -6, 17, -2, 7, 0,
- -2, 10, -17, 13, -2, -2, 11, 11, -14, 2, -2, -3, -8, -1, -12, -5 },
- { 29, -9, 7, 3, 2, -10, 0, 3, 9, 0, -3, 5, 1, -10, 10, -5,
- 3, 6, -20, -9, -6, -4, 1, 0, 12, 17, -8, 9, 3, -1, -9, 0 },
- { 15, -16, 18, -19, 16, -15, 17, -18, 13, -16, 17, -14, 15, -9, 13, -17,
- 9, -7, 4, -5, 3, -4, -3, 0, -6, 7, -9, 7, -2, 7, -9, 9 },
- { 21, -10, 7, -2, 12, -7, 13, -17, 11, -2, 20, 3, 5, -11, -6, -6,
- -15, 0, -9, 5, -11, 7, -1, 7, 8, -10, -9, 3, -5, 9, -8, -2 },
- { 23, -22, 15, -5, 16, -4, -3, -12, 9, 3, -1, -2, -8, 2, -2, -16,
- 3, 4, -2, -6, -7, 12, -8, 2, -14, 2, -7, 11, -2, 6, -4, -1 },
- { 34, -17, -4, 8, 4, -6, 1, 8, 4, 16, 3, 6, 12, -1, -1, -15,
- 6, 4, -7, -6, 6, 0, 2, 1, -2, 2, 3, 3, -3, -2, 8, -6 },
- { 18, -18, 2, -2, 10, 1, 18, -23, -3, -10, 0, 4, 20, -19, -3, -4,
- 2, 8, 6, 1, -3, 1, 1, 3, 5, -1, -11, 3, -7, 5, -1, 1 },
- { 15, -14, 2, 3, 10, -8, 12, -13, 13, -15, 6, -8, -4, -10, 14, -9,
- 24, 2, -7, -18, 13, -11, 8, 14, -6, -2, 3, -1, -4, 7, -7, -4 },
- { 20, -12, 13, 5, -1, -10, 15, -6, 8, -1, -3, -10, 17, 0, -6, -19,
- 2, -1, 8, -3, -16, 0, -3, 2, -2, 0, 8, -9, 0, 1, -10, -9 },
- { 32, 0, -9, -5, -1, 5, 13, -11, 8, 3, 11, -11, 0, -8, -2, -14,
- 7, 10, 6, -5, 1, 10, 2, 12, -10, 4, 4, 6, 4, 0, -7, -10 },
- { 16, -14, 10, -7, 11, -11, 11, -11, 18, -13, 8, -15, 16, -11, 13, -9,
- 8, -7, 12, -11, 7, -6, 3, -5, 9, -5, 4, -1, 7, -4, 8, -3 },
- { 24, -27, -1, 5, 8, -5, 12, 7, 4, -3, 3, -1, -9, -11, -13, -5,
- 10, 0, -13, 7, 1, -5, 4, -9, 7, -3, 13, 2, -5, -3, -17, -2 },
- { 23, -19, 15, 1, -10, -18, -12, -6, 8, -3, 12, 0, -12, -10, -4, -4,
- 8, -10, 4, 2, -2, -8, 13, -3, -2, -6, 2, -3, 5, -2, 2, 11 },
- { 25, -12, 4, 2, 24, -3, 3, -6, 14, 11, 0, -21, -3, -3, 1, -8,
- 7, 0, 0, 3, 3, -6, -7, 6, 2, 1, -4, 5, -1, 10, -2, 9 },
- { 24, -8, -6, 7, 16, -12, 13, -1, 11, -21, 2, -6, 3, -12, 0, 9,
- 4, 11, -7, 1, 4, 1, -8, 3, 3, -6, 3, 3, 0, -8, 8, 4 },
- { 25, -21, 13, 14, 13, -18, 4, -3, 0, -5, -4, 5, -3, 0, 4, 12,
- 7, 3, 5, -5, 2, -2, 3, -10, 2, -9, -15, 6, 1, 7, -5, 1 },
- { 23, -16, -2, 10, 4, -1, 3, 1, 32, 3, -5, -2, 9, 10, -1, -4,
- -6, 2, 9, -1, 14, 12, -6, -1, -17, -2, -4, -9, -7, -6, -8, 3 },
- { 50, -8, 5, 2, -11, 10, 0, 0, 6, -3, 7, 0, -3, -2, -3, 0,
- 6, -4, 2, -5, -9, 0, 3, 10, 1, -7, -2, -3, -6, -9, 1, -2 },
- { 28, -17, 0, -2, 2, -9, 1, 5, -4, -1, 0, 0, 19, -27, 5, -12,
- 7, -14, -3, -6, 10, -2, -4, -2, 4, -5, -2, -7, 1, 7, -9, 4 },
- { 22, -19, -6, -6, 3, -22, 3, 5, 20, -8, -14, -5, 1, 1, 20, 2,
- 16, 6, 3, 14, 4, 3, 5, 1, 5, -7, -10, -6, 3, -6, 1, -14 },
- { 29, -14, -8, 13, 8, -10, -6, 4, 4, -6, 5, -7, 1, 12, 14, 11,
- -7, 1, 2, -9, -11, -9, 0, 4, -1, 7, 10, 4, 4, 20, -1, -11 },
- { 18, -9, 4, 1, 7, -29, 12, 1, -1, -9, -2, -1, -2, 2, 9, -8,
- -13, 5, 4, -13, -4, 2, -5, -7, -6, 14, -10, -34, -3, 1, -3, -13 },
- { 38, -9, 24, 8, 11, 4, -6, -11, -2, -12, 1, 1, -11, -8, -5, -2,
- -15, -8, 8, 0, 1, -7, 5, 4, -1, 8, -2, 11, -3, -1, -5, -5 },
- { -20, 11, -4, 24, -11, 1, 15, 4, 0, -28, -10, -1, 10, 10, -6, 5,
- -6, 2, 7, -2, 1, -2, -6, -3, -7, 1, 2, 12, -1, 7, 0, -2 },
- { -9, 10, -23, 27, -4, -17, 20, -6, 14, -17, 5, -1, 5, -9, -7, 5,
- -6, 4, -2, 9, 0, 8, 0, 1, -3, -3, -5, -8, 5, -2, -2, 12 },
- { -10, 19, 4, 9, 1, -16, 17, -2, 9, -29, -16, -11, -4, 7, -5, 4,
- -1, -3, 3, 2, 3, -4, 5, -12, -2, 6, 5, -4, 4, 1, 4, 10 },
- { -20, 10, -24, 14, -5, 11, 9, 0, 16, -20, 10, -5, -6, -6, -1, 2,
- -4, 5, -16, 8, -2, 5, 5, -11, 9, -11, 4, -11, -1, -1, 4, 3 },
- { -9, 11, 3, 19, 24, 4, 5, -14, 30, -17, -4, -2, -17, 7, 2, 3,
- 1, 3, -7, -4, 2, -3, 1, 4, -1, -1, 3, -12, -2, 3, -3, 10 },
- { -19, 18, 11, 19, 19, 19, 10, 4, 13, 6, 5, 4, 8, 3, -2, 12,
- -6, -2, 7, -6, 15, 12, 16, 16, 18, -3, -4, -20, 0, 10, -9, -3 },
- { -21, 9, 20, 12, 0, -3, 5, -9, 15, -13, 5, -5, -6, 24, 2, 9,
- -5, 2, -7, 2, 5, 7, -5, 2, 15, 3, 1, -1, -4, -2, 7, 0 },
- { -18, 16, 13, 15, 2, -10, 14, -11, 4, -11, 5, 12, 12, 20, 8, 30,
- 2, 11, -9, 7, 0, -3, -16, -5, -6, 5, -4, -21, 0, 5, 6, 1 },
- { -26, 8, -13, 9, 6, -10, 2, -11, 7, -4, 6, -19, -11, -6, -12, 16,
- 0, 5, -7, 8, 5, 6, 17, -9, 10, -10, 5, -3, -11, 2, 4, 10 },
- { -11, 17, -3, 22, -5, 18, 3, 1, 4, -5, 14, -27, 5, -7, -4, -5,
- -10, 11, 1, 15, 1, 1, -6, -5, 10, -22, -7, -7, -15, 13, -4, 5 },
- { -17, 14, -7, 13, 3, 0, 13, -6, 9, -14, -22, -1, 1, 19, 14, -3,
- 4, -13, -13, 2, -4, 8, -2, -2, 13, -12, 13, -12, -7, -5, -3, 6 },
- { -17, 17, -1, 33, 6, 3, 9, -16, 3, -14, -8, 6, -17, 8, 3, 13,
- 8, -6, 3, 1, -2, 0, -2, 8, 4, 9, 13, -10, 4, -17, 0, -6 },
- { -20, 7, 7, 21, 1, -3, 7, -3, -2, -12, 9, -7, 2, -3, 14, 1,
- -1, -7, 12, -10, 5, -20, 11, -2, 0, -24, -17, 6, 6, -4, 3, -1 },
- { -8, 10, 6, 7, -1, -6, 28, -6, 10, -33, 1, -20, 0, -12, 10, 1,
- -6, 8, -3, -1, -10, 8, 5, 0, 10, -2, 8, 16, -5, -3, -7, 4 },
- { -17, 13, 3, 15, 1, -5, 27, -5, 6, -6, 12, 2, -4, 8, -1, -3,
- -2, 12, -15, 3, 4, 1, 2, -9, 0, -16, -21, 2, -4, 16, -7, 4 },
- { -15, 20, 8, 17, 5, -14, 15, -11, 21, -11, 13, -13, 2, -15, -13, 1,
- -5, 5, 2, 10, -9, 4, -1, 3, 2, -4, 13, -5, 1, -4, 5, -3 },
- { -21, 8, 2, 16, -1, 2, 15, -16, 13, -12, -12, -7, -8, 2, -7, 11,
- -8, 5, 2, -7, 16, -4, 1, -7, 3, -15, 6, -5, -8, 2, -8, 5 },
- { -15, 17, -6, 3, -3, 3, 9, -7, 14, -23, 11, 1, -1, 4, 7, 6,
- -1, -14, 7, 6, -8, 5, 1, -15, 10, -9, 2, -3, -1, 4, -10, -4 },
- { -10, 18, 3, 11, 1, 4, 14, -14, 7, -4, 15, -10, 10, -11, 10, -4,
- 5, -14, 10, 4, 15, -12, 15, -13, 20, -15, 14, -15, 8, -11, 4, -6 },
- { -7, 23, 2, 20, 7, 8, 19, -5, 9, -16, -8, -17, -5, 1, 5, -6,
- -8, 1, -6, -4, 10, 6, 6, 2, -11, -4, 0, 2, 4, 7, 9, -4 },
- { -15, 20, -5, 22, 11, -8, 9, -5, 10, -13, -8, 8, 2, -2, -3, 7,
- 6, 10, 1, 2, -5, -9, 1, 10, 16, -22, -7, 0, 7, 7, 6, 1 },
- { -26, 19, -5, 3, 5, 25, 18, -5, 9, -14, -8, -6, -2, -6, 2, 3,
- -8, -2, -7, 7, -3, 7, 3, 4, -8, 0, 1, -8, -4, -2, -2, 1 },
- { -20, 14, -10, 6, -3, 7, 8, -32, -2, -7, -2, -10, 16, -12, -9, 15,
- -2, -5, -6, 2, -7, 5, 9, 1, 6, -7, -1, 0, -2, -4, -7, 3 },
- { -14, 16, 4, 11, -8, 1, 23, -4, 17, -13, -10, 1, 12, 9, 12, -4,
- 7, -1, -1, 5, -8, -6, 3, 3, -6, -3, -18, 0, 18, 20, 4, -2 },
- { -33, 19, -10, 30, 15, 2, -3, -1, -4, -14, 7, -7, -1, 7, -8, 9,
- -1, -3, -5, 2, 2, 4, 0, 5, 0, 0, 2, 3, 3, -3, -3, 4 },
- { -6, 20, 0, 5, 17, -10, 18, -17, 9, -16, 4, -13, -6, 2, -14, 14,
- -28, 9, -12, 25, -4, 7, 7, -8, 6, -6, -2, -10, 2, -11, -1, 2 },
- { -12, 14, 12, 52, -3, 5, -5, 4, 8, -13, 2, -5, -4, 2, -2, -1,
- -2, 3, 3, 5, 2, 3, 0, 1, -5, 2, -4, -3, 1, -5, -2, 0 },
- { -13, 6, 9, 24, 0, 8, 14, -15, 18, -9, -11, -8, 3, 15, -2, -4,
- -9, 4, -3, 12, 14, -13, 11, -4, 2, -4, 0, -6, -6, -6, -14, -1 },
- { -10, 28, 3, 12, 9, 3, 11, -28, 6, -11, -7, 4, 0, 7, 8, -9,
- 0, -6, 0, -16, 4, 7, 4, 4, 7, 3, 4, -7, 0, -3, -10, 6 },
- { -11, 14, -2, 19, -1, -1, 7, 9, -2, -27, 10, -14, 15, -4, 12, -4,
- 2, -2, -6, 12, -6, 0, -5, -4, -5, 1, 3, -11, 5, -9, 3, -8 },
- { -18, 7, 13, 16, -4, 3, 9, -10, 10, -10, -3, -22, -4, -12, 3, -16,
- 0, -3, -16, 8, -11, 1, 10, -7, 15, 3, 0, -1, -13, 8, 1, 6 },
- { -20, 10, -10, 10, 8, -1, 6, 0, 16, -12, 9, -10, -1, -5, -4, -13,
- 13, 16, -8, 12, -2, 14, 18, 13, 0, -16, 2, -5, -5, -5, -4, 3 },
- { -14, 5, -7, -17, 5, -13, 23, 20, -4, -1, 1, -6, 13, 5, -1, 4,
- -14, -2, -7, 8, 3, 2, 2, -7, 2, -1, 4, 7, 3, -9, -1, -5 },
- { -19, 3, -24, -28, -9, -7, 19, 3, 2, 19, 7, 5, -13, 8, -15, -17,
- 3, -11, 4, 13, 3, 2, -1, -3, -4, -4, 2, 0, -5, -6, 6, 2 },
- { -17, 18, -30, -20, -2, -3, 1, 15, -1, -11, 6, -4, 11, 11, -4, -5,
- -10, 0, 0, 1, 3, -7, 8, 2, 5, 1, 5, -5, 1, 6, 4, 1 },
- { -6, 1, -30, -25, -1, -8, -2, -9, -17, 16, 3, -1, -2, -9, -6, -7,
- -3, 12, 6, -4, -10, 0, 10, -8, -6, -5, -3, -11, -4, 0, -1, -3 },
- { -1, -1, -34, -28, 1, -10, 2, 9, 4, 16, 2, 6, 14, 17, 0, 7,
- -4, 4, 4, 4, 0, 1, -1, -5, 8, 1, -4, 1, -9, -2, 5, 6 },
- { -11, 14, 1, -31, -7, -24, 9, 7, 6, 5, -13, 1, -1, 3, 4, -1,
- -2, -8, -6, 3, 5, -4, -6, 7, -2, 5, 3, 3, 0, 0, -5, 2 },
- { -25, 8, -11, -18, 1, -4, 8, -3, -4, 15, 6, -5, 8, 2, 3, 4,
- -4, 5, 6, 8, -7, 6, 1, -11, -15, -13, 9, -4, -14, 10, 12, 7 },
- { -20, 11, -15, -25, 3, 4, 18, 13, -4, -5, -9, -1, -5, -2, -2, -7,
- 16, 5, -4, -5, -7, -2, -3, -9, 11, -2, 0, -7, -17, -6, -11, 6 },
- { -11, 18, -5, -20, -15, -3, 9, 11, -20, 12, 5, 5, 11, -3, 7, 1,
- 10, -6, -3, -3, 3, 3, 14, -7, 10, -17, 9, -11, -2, -6, 7, -12 },
- { -20, 8, -14, -17, -9, -13, -3, 0, -27, -14, -3, -14, 4, 3, 6, -6,
- 7, 4, 23, 9, 11, 9, 3, -4, 9, 2, 4, -1, -6, 1, -8, -11 },
- { -9, 14, 2, -37, -7, 13, 6, -11, -6, 9, 18, -11, -6, 2, 12, 4,
- -1, 3, 1, -2, -2, 1, -9, -4, -2, -3, 3, 5, -6, 0, -2, -8 },
- { -29, 8, -1, -13, -2, 8, 23, 2, -10, 7, 13, -6, -5, 11, 13, 0,
- -10, -13, 11, -12, -10, 6, 4, 6, 4, 3, 6, -5, -9, -2, -1, 3 },
- { -18, 6, -10, -55, -4, -11, -2, 0, 1, -3, -9, -6, 3, -2, -1, 6,
- 3, -1, 3, 1, -4, -7, -2, 6, 3, -2, -1, -3, -2, 0, 4, 1 },
- { -14, 5, 3, -21, -8, -16, -4, -2, -11, 27, 15, -20, 3, 0, 1, 1,
- 2, -5, -5, 4, 1, -9, 5, -3, 3, 0, -4, -2, -11, -4, -3, 7 },
- { -17, -1, -9, -17, -8, -18, 12, -13, -9, 13, -3, 3, 3, -3, 1, -2,
- 0, 16, -9, 6, 12, 9, 5, 11, 2, -15, 1, -4, -16, 7, -4, -12 },
- { -18, 8, -6, -11, -8, -7, 13, 7, 1, 6, 8, -1, 21, -4, 14, 15,
- 18, -4, -3, 15, 0, 9, 4, 7, 3, -1, 9, -2, 0, 7, -8, 2 },
- { -10, 7, -18, -29, 3, 12, 12, 9, 11, 4, -1, -15, 1, -1, 8, -2,
- -2, 10, -15, -1, 0, 6, 12, -6, -1, 10, -6, -3, -11, -4, 9, -6 },
- { -14, 14, -9, -21, -12, -2, -1, -7, -5, -10, 5, -8, 0, 6, 9, -11,
- 11, -3, -5, 3, 8, 15, -2, -4, -22, 4, -6, 12, 2, 13, 6, -7 },
- { -12, 11, -5, -29, -25, 4, 12, -13, -11, -7, 4, 2, 2, -5, 5, 8,
- 7, -5, -5, 6, 3, -10, 1, -6, 6, -6, -5, -1, -2, -4, 7, 6 },
- { -15, 11, -5, -16, 0, -13, 26, -23, -6, -3, 5, -2, -2, 21, -6, -3,
- -5, -1, 6, -1, 0, -13, 2, -3, -9, -1, -4, -3, 5, -4, 12, -16 },
- { -9, 9, -1, -17, -3, -6, 12, 6, -18, -2, 11, -14, -6, 3, 14, -12,
- -11, -5, 14, 2, 5, -8, -4, -11, 2, -5, 16, 6, -7, -4, 8, 13 },
- { -13, 5, 3, -28, -14, 0, 6, 23, 5, 4, -1, -17, 1, -3, 0, 0,
- 5, 4, 0, -18, 14, 10, 4, 2, 5, -2, 4, -3, 2, 0, 2, 0 },
- { -15, 4, -13, -16, -3, -12, -2, 2, 7, 10, 9, 3, 11, 4, 23, 14,
- 9, 16, 4, 1, -12, -3, 4, -7, -15, -7, -10, -14, -6, -8, -1, -6 },
- { -7, 10, -5, -10, -3, -13, 16, -1, -12, 7, -3, -12, 2, 13, 13, 2,
- 17, 15, -13, 1, -5, -2, 3, -1, 1, -3, 6, -3, -12, -16, 7, -7 },
- { -11, -5, -12, -30, -6, -22, 1, 4, -6, -3, 12, 6, 7, 0, 16, 6,
- -2, 0, -22, -2, -9, 2, -13, 8, 6, -8, 4, -7, -1, -6, 4, 6 },
- { -14, 5, 1, -27, -4, 2, 1, 14, -11, -7, -8, -4, 1, 8, 0, -6,
- -13, 11, -12, -7, -5, 1, 10, 7, 3, -2, 0, 6, -8, 2, 10, -1 },
- { -10, 10, -25, -13, -20, -4, 19, 3, 13, 5, 5, 7, -8, 2, 4, 2,
- 3, -1, -1, -9, 14, 10, 9, 14, 3, 3, -6, 0, -5, 4, 1, -1 },
- { -9, 15, -18, -17, 4, -11, 6, 7, -12, 8, -1, -11, 2, 3, 7, 16,
- -3, -9, 7, -12, 23, 0, 6, 7, -14, -9, 8, 1, -2, 6, -2, -1 },
- { -6, 9, -16, -26, -14, -11, 9, -6, 5, -2, 13, 17, 21, 7, 18, -19,
- 6, -23, -2, -15, -2, 2, -10, -8, 2, 1, -2, 4, -3, -4, -5, -4 },
- { 0, 6, -5, -28, -17, -32, 2, -10, 11, 3, -5, 9, 10, 3, 11, 11,
- -3, 12, -2, 2, 4, -6, 9, -4, -4, -4, -4, -9, 2, 0, 2, 4 },
- { 0, -8, -18, -34, -9, -7, -4, -11, 10, 15, 11, -1, -8, 15, 6, -13,
- 9, 2, -4, -12, 0, -1, 19, 12, 6, 5, 0, -3, -10, -12, 3, -5 },
- { -10, 6, -9, -17, -12, -11, 9, -6, 11, 11, 18, -7, 0, 16, 4, 2,
- -6, 3, -12, -1, 0, 1, -5, -22, -2, -12, 0, 6, 17, 5, 5, 6 },
- { 12, -5, 7, 1, -5, -2, -1, 2, 2, -4, -3, -3, -3, -2, -29, 11,
- 5, -13, -73, 24, 12, 4, -14, -10, 5, 1, 0, -11, -7, -7, 7, 3 },
- { 10, -3, -1, -3, 4, -11, -5, -2, -8, 7, 9, 2, -8, -6, 6, 7,
- 21, 17, -54, 47, -14, -10, 14, 19, 13, 21, -4, 3, 1, 2, -4, 2 },
- { -12, 4, -16, -12, 5, -9, -4, 19, -7, -22, -22, -17, 3, 0, -6, 8,
- 23, -4, -55, -28, 2, -26, 2, 1, 4, 0, -13, 6, 0, 10, -7, -11 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,
- 35, -1, -67, -35, -24, -24, -6, 2, 2, -2, 1, 3, 2, 0, -1, 1 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 0,
- 41, -4, -73, -15, 18, 4, 17, 8, -1, -16, -1, -2, 1, 0, 0, 0 },
- { -4, -4, 4, 6, -1, 2, -16, -10, -15, -10, 21, -2, -6, -2, 14, -7,
- 10, -5, -55, 34, -12, 11, -13, -2, 2, 28, -26, 0, 7, 4, 21, -7 },
- { 2, 1, 15, -22, 10, -3, 14, -6, -2, 15, -2, -7, 20, 6, -15, -7,
- 23, 10, -60, 8, -4, 29, -22, 2, -13, 9, -10, 12, -1, -3, 4, 7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 11, -5,
- -21, -11, -60, -27, -17, -39, 6, 36, 0, -8, 2, 2, 0, 0, -2, 3 },
- { 2, -5, 9, -17, -1, 2, -3, -6, 8, 12, 7, -6, -33, -11, -14, -40,
- 10, 36, -46, 0, -19, 5, 0, -10, 3, 12, -6, -8, 6, -12, -7, 1 },
- { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 1, 0, -2, 0,
- 4, -2, -87, -3, -2, 2, -2, 20, 2, 6, -1, 6, 0, 0, 2, -1 },
- { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1,
- 1, 7, -76, 41, -7, -24, 0, -6, 3, 6, 0, -2, -1, 1, 0, 0 },
- { 0, -3, 4, 2, 3, 2, 2, 0, 3, -1, 4, 0, -1, 4, -2, -4,
- -32, -11, -64, -29, -9, -43, 2, -11, -1, -7, 0, -4, -2, -2, -2, 2 },
- { 10, -20, 3, -3, 13, 13, 0, -4, 2, 7, -8, 7, -2, 2, -20, -20,
- -19, 3, -47, -18, -16, -6, -15, -42, -17, 14, -6, 8, 12, -10, 11, -12 },
- { -3, -2, -2, -1, -1, 4, -3, -1, -6, -2, 3, 2, -3, 6, -1, -9,
- 10, 13, -68, -9, 26, 3, 5, 3, -21, 10, -15, 21, -22, 19, 11, -14 },
- { 1, 5, 18, -19, -29, -13, -2, 18, -10, 20, 2, 10, -10, 11, 1, 8,
- -16, -17, -41, 10, -14, -25, 0, -14, -19, 17, 7, -12, 14, -11, 14, 5 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1, -43, 5,
- 6, -12, -48, 19, 8, -38, -8, -3, 22, -21, -10, 15, 20, -9, -5, 8 },
- { 0, 0, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 6, -3,
- 22, -14, -71, -24, -2, -33, 23, 7, -8, 7, -3, 2, -4, 1, -8, -2 },
- { 1, 0, -1, 2, 0, -2, 0, 0, -1, 0, 4, 0, 26, -1, 10, -11,
- -17, -32, -58, 14, -14, -11, -2, 15, 2, -8, 12, 10, -9, 13, -33, -14 },
- { 15, -17, -19, 7, -8, -15, -32, -22, 7, 12, 18, 0, 0, -15, -4, 16,
- 37, -2, -46, 11, 2, -8, -10, -8, 14, 9, -4, 5, 7, -17, 4, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3, -85, 23, -9, -17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3, -85, 23, -9, -17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1,
- 1, 7, -76, 41, -7, -24, 0, -6, 3, 6, 0, -2, -1, 1, 0, 0 },
- { 0, -3, 4, 2, 3, 2, 2, 0, 3, -1, 4, 0, -1, 4, -2, -4,
- -32, -11, -64, -29, -9, -43, 2, -11, -1, -7, 0, -4, -2, -2, -2, 2 },
- { 10, -20, 3, -3, 13, 13, 0, -4, 2, 7, -8, 7, -2, 2, -20, -20,
- -19, 3, -47, -18, -16, -6, -15, -42, -17, 14, -6, 8, 12, -10, 11, -12 },
- { -3, -2, -2, -1, -1, 4, -3, -1, -6, -2, 3, 2, -3, 6, -1, -9,
- 10, 13, -68, -9, 26, 3, 5, 3, -21, 10, -15, 21, -22, 19, 11, -14 },
- { 1, 5, 18, -19, -29, -13, -2, 18, -10, 20, 2, 10, -10, 11, 1, 8,
- -16, -17, -41, 10, -14, -25, 0, -14, -19, 17, 7, -12, 14, -11, 14, 5 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1, -43, 5,
- 6, -12, -48, 19, 8, -38, -8, -3, 22, -21, -10, 15, 20, -9, -5, 8 },
- { 0, 0, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 6, -3,
- 22, -14, -71, -24, -2, -33, 23, 7, -8, 7, -3, 2, -4, 1, -8, -2 },
- { 1, 0, -1, 2, 0, -2, 0, 0, -1, 0, 4, 0, 26, -1, 10, -11,
- -17, -32, -58, 14, -14, -11, -2, 15, 2, -8, 12, 10, -9, 13, -33, -14 },
- { 15, -17, -19, 7, -8, -15, -32, -22, 7, 12, 18, 0, 0, -15, -4, 16,
- 37, -2, -46, 11, 2, -8, -10, -8, 14, 9, -4, 5, 7, -17, 4, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3, -85, 23, -9, -17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3, -85, 23, -9, -17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 16, 65, -2, -2, 4, 3, 0, -7, 3, 1, 3, 1, 0, 5, 1, -5,
- 0, 2, -1, 3, 0, 0, -1, -2, 6, 0, -2, 0, 0, -1, 1, 1 },
- { 5, 37, -4, 8, -4, -1, 9, 17, 6, -7, 5, -1, 11, 6, -4, 7,
- -2, 4, 1, -3, 11, 3, 3, -9, 6, 0, -2, -4, -5, 4, -12, -11 },
- { 15, 24, -14, 2, 6, 17, 26, 5, 8, 11, -9, -7, -6, -8, 3, -5,
- 9, 10, -3, 10, 0, 1, 4, -9, 4, 9, 3, 0, 4, 0, -5, 3 },
- { 9, 36, -9, -8, 7, 7, 4, 3, -1, -16, -2, 7, -5, -6, 6, 12,
- -11, -12, 9, -1, -3, -9, 12, 6, -6, 2, 2, 5, 0, 5, 6, -6 },
- { 25, 39, -5, 24, 3, 10, 3, -6, 13, -8, 3, -7, 2, -10, -5, 2,
- -2, 3, 5, -2, 1, 5, -2, 3, -4, 1, -5, -4, 0, 1, -2, 0 },
- { 16, 27, -1, 0, -14, 6, 4, -5, 7, -2, -6, 0, -3, -5, 2, -1,
- -1, -19, 5, -8, 0, 11, 12, 5, 0, 3, 10, 6, -14, 14, -13, -15 },
- { 12, 23, -14, 2, 1, 4, -3, 16, 7, -8, 2, -8, 8, 6, -8, -7,
- -3, 0, 2, 8, -13, 7, 13, -6, -4, 6, -13, -16, 14, 11, -7, 5 },
- { 16, 28, -7, -1, 6, -3, 9, 0, -7, 3, 0, 3, -12, 20, 8, 9,
- 8, 23, 8, -13, -2, 4, 9, 3, -5, 13, 5, -2, 12, 14, 5, -1 },
- { 19, 37, 19, 5, 7, 5, 10, 5, 19, 10, 14, 0, 2, 5, 1, -4,
- -4, 2, 2, -5, -2, -1, 2, -6, -4, -4, -5, -3, 2, -2, -2, -2 },
- { 24, 21, 1, -11, -10, 17, -14, 14, 6, -1, -6, -1, 0, -13, -1, -12,
- -2, -5, 6, -4, -12, 14, 5, -2, -8, -8, 15, -7, -30, -12, 4, 0 },
- { 11, 26, -3, 3, 5, -1, -2, 3, -2, 10, 15, -4, 10, -28, 10, -17,
- -8, 1, 2, -7, -1, -6, -15, -1, 4, 5, -7, 9, 0, -5, -4, 4 },
- { 18, 32, 1, 2, -7, 4, 15, 2, -9, -2, 12, -11, 7, 11, 13, 2,
- 0, 5, 9, -10, 16, 3, -3, 5, -9, -23, 2, -2, -1, 5, 2, 11 },
- { 35, 24, -20, 2, 4, -1, 5, 14, -10, -9, 8, -7, 0, 5, -7, -7,
- 11, 1, 5, 3, 2, 0, -2, 3, 0, 1, 4, 0, -2, -8, 0, -4 },
- { 9, 35, -1, 2, -1, -19, -3, 12, -1, 8, 8, -13, -1, -2, 2, 5,
- -8, -1, 13, -2, 11, 1, 0, -10, 0, -3, -7, 2, 1, -12, 3, 12 },
- { 20, 27, -12, -12, 7, 4, -1, -13, -1, -9, 2, 13, -11, 5, 7, -9,
- 9, 1, 1, 8, -9, 0, -6, 7, 4, 2, -2, 7, 3, -2, 1, -9 },
- { 8, 37, -20, -5, 0, -21, 10, -8, 3, 19, -9, 7, -3, -8, 10, -2,
- 0, 5, 6, -4, -2, -1, 0, -7, 6, 1, 0, 4, -5, 6, -8, 2 },
- { 8, 27, 1, -3, -5, 1, 6, 0, 15, 2, 17, -1, 3, -17, 10, 5,
- 5, -6, -6, 6, -10, 18, -5, 0, 0, 13, 7, 10, -5, -6, -2, -4 },
- { 14, 29, -20, -4, -3, 1, -5, -1, 2, 12, -10, -3, 4, -18, 4, 14,
- -4, -1, -9, 15, -2, 2, -5, -3, 2, 9, -2, -14, -3, 4, -4, -7 },
- { 23, 23, -23, -11, 27, 4, 4, -1, 7, 0, -5, 9, 2, -11, 3, 7,
- -2, -5, 2, -7, -7, 13, -3, -6, 2, 3, 3, -4, -1, -8, 5, -2 },
- { 16, 26, -6, 8, -9, -1, -2, -1, -8, 4, -2, 0, -12, 9, -1, 0,
- -17, -9, 30, -5, -15, -16, -13, 0, 10, -11, -7, -3, -1, 0, -11, -2 },
- { 12, 32, -4, -5, 10, 19, -10, 4, -12, 5, -6, 9, -12, -6, -6, -8,
- 4, 1, 3, 0, 8, 0, -3, -4, -7, -4, 10, 8, 6, 5, -1, 4 },
- { 46, 42, -3, -14, -2, -6, 6, -2, -5, -1, -3, -3, 1, -1, 3, 1,
- 1, 4, -1, 2, 3, 1, -2, 6, 0, -1, -2, 4, -2, -1, 2, 2 },
- { 9, 33, -13, 4, -11, 3, -8, 22, 12, -2, 4, 0, -16, 5, 4, -1,
- 7, -6, -9, 1, 7, 5, 0, -5, 5, -1, 10, 3, -2, -1, 3, -2 },
- { 9, 30, 6, -3, 6, 1, -7, 5, 11, 14, 7, 1, 0, 2, 2, -1,
- 8, 7, -6, -13, -10, -2, 1, -6, 10, 7, 6, 5, -2, -5, -1, -16 },
- { 9, 28, -11, -10, 9, -10, 15, 8, 4, 9, -4, -7, 0, -5, 9, 8,
- -7, 2, -15, -23, 4, -4, 4, 16, -8, -3, 0, -8, 14, 5, -3, 15 },
- { 17, 26, -5, -5, -1, -8, 20, 18, -7, -2, 4, -7, -8, -5, -4, 16,
- 0, 0, -7, -2, -13, -5, -2, 3, 12, 1, 3, -5, 2, 2, 0, -1 },
- { 11, 37, 7, -23, 6, -1, 15, 13, 4, -9, 7, 5, 3, -3, -5, -8,
- -2, 3, -5, -1, -8, 7, 2, 13, 1, 3, 0, -3, -1, 2, 0, -2 },
- { 21, 33, 7, 20, 21, -10, 6, -5, -5, -6, -9, 2, 10, 0, 8, -4,
- 10, 2, -2, -2, 0, -10, -6, -2, 0, -5, 3, -11, 3, -9, -3, 1 },
- { 6, 30, -15, -8, 16, 1, 4, 6, 4, 5, 8, -3, 8, -9, -1, -6,
- 8, 2, -2, 4, -2, 5, 11, -21, 3, -10, 16, -11, 24, 10, 14, -6 },
- { 15, 36, -3, -9, -20, 12, 0, -7, -18, -4, -8, -9, 9, -7, -3, -1,
- 2, 7, -5, -8, 6, 2, 2, -1, 7, 1, 1, -3, 3, -4, -8, 1 },
- { 16, 34, 21, 3, -9, 10, 7, 9, -7, 1, -4, -9, -4, -5, -5, 3,
- 3, -19, 1, 5, 4, -2, -6, -5, -10, -11, -8, -2, 2, -5, -8, -7 },
- { 28, 29, -3, 18, -2, 0, -6, 12, -2, 10, -11, -4, -13, -12, -6, -4,
- 0, 4, -1, -8, 6, 4, 12, 11, 10, 10, -3, -6, 1, 2, 1, 7 },
- { 3, 8, 22, -8, 3, 36, -8, -1, 9, 6, -13, -14, 8, -1, 1, 2,
- -2, -8, 0, 3, 1, 2, -1, 5, -1, -8, 0, -2, 2, 2, -1, 1 },
- { 0, 6, 0, 0, 4, 13, -7, -16, -6, 15, -14, -21, -9, -10, -10, -6,
- -21, 5, 4, 2, 12, 4, 12, 11, -4, -6, -6, -10, -7, -18, 1, 4 },
- { -1, 3, 10, 1, -1, 15, 4, -7, -16, 3, 0, -22, 10, 2, -3, -2,
- 13, 5, -8, 16, -5, 4, 0, -11, -10, -22, 0, -4, -17, 5, 2, 1 },
- { 12, 8, -4, -9, 14, 40, -21, 0, 1, -15, -10, -12, 12, 6, -10, 2,
- 8, 6, -12, -10, -11, 1, 0, -11, 2, 1, 13, 0, 6, 3, 8, 4 },
- { -10, 3, 5, -4, -3, 3, 0, -9, 2, 8, -22, -23, 17, 8, -17, -3,
- 14, -8, -4, 1, -8, 3, 0, 5, -1, -3, -2, -4, 1, -10, 0, -2 },
- { 0, -1, 5, -7, 4, 12, -2, 0, -7, 2, -16, -15, 12, 21, -7, -4,
- 7, -7, -11, -15, -7, -9, -5, -8, 0, -6, 8, -3, -8, 22, -7, -9 },
- { 7, 19, 4, -9, 24, 22, 2, -6, 8, 13, -14, -20, -4, 11, 8, -4,
- -1, 2, 0, -7, 5, -17, -3, 3, -6, 5, 3, 4, -5, -7, -3, 14 },
- { -2, 6, 2, 8, -2, 5, -4, -2, -10, 3, -45, -30, -3, -3, -12, -4,
- -3, -3, -1, 9, -6, -6, 5, -4, 0, 5, -1, -2, -1, 0, -6, -1 },
- { -3, 14, -16, -10, 10, 0, -2, -40, -9, 12, 2, -19, 15, -4, 4, 3,
- 3, -4, 7, 1, -4, -5, 0, 4, -1, 0, -9, -2, -4, -1, -2, 0 },
- { 7, 16, 2, -7, 8, 2, 0, 1, 5, 21, -10, -26, 7, 2, -9, -7,
- -3, -16, 8, 5, 5, -6, 10, 4, -14, -6, 5, 3, -2, -2, -4, 1 },
- { -9, 14, -1, 3, 3, 11, 1, -5, -3, 13, -16, -18, 20, 6, -5, 0,
- -3, 2, 8, 4, -19, -9, 12, 0, -8, 2, 2, 1, 6, 13, -7, -11 },
- { 2, 5, 16, -4, 19, 15, 4, 0, -11, 7, -10, -10, -16, 18, -11, -12,
- -9, -4, 7, -4, -4, -17, 1, 1, -8, -3, -3, 5, -2, -6, -11, -5 },
- { 2, 12, 0, -9, -10, 14, 6, 2, -3, 2, -12, -28, 12, 1, -1, 2,
- 0, -3, -4, 7, 16, 5, -7, 8, -4, -3, -1, 3, -12, 4, -17, -5 },
- { -4, 7, 11, 6, 1, 14, -4, -6, 5, 5, -6, -24, 23, -9, -15, 13,
- -7, -9, -15, 10, -1, 8, -5, 1, 12, 6, 2, 0, 4, -2, 9, -10 },
- { 1, 5, 11, 3, 6, 12, -3, 8, -21, 5, -7, -20, 12, -2, -9, -3,
- 17, -7, -8, -9, -14, 3, -13, 18, -8, 9, 2, -8, 4, -8, -5, -2 },
- { -3, -3, -1, 5, -2, 15, 3, 2, 1, -8, 1, -39, -6, 13, -13, 0,
- -2, -5, -6, -3, 0, -5, -2, 15, -9, 5, -3, -6, -2, 7, 0, -13 },
- { 2, 8, 5, -12, -13, 22, 8, -16, 11, 5, -2, -32, -2, -4, 11, 5,
- 5, -6, 1, 3, 1, 5, 3, 6, -5, 4, 4, -8, 8, 4, 1, 3 },
- { 13, 9, 5, -4, 9, 18, -11, 2, -1, 15, -10, -19, -2, 14, 0, -10,
- 1, 1, -18, 3, 2, -6, -8, 20, 7, -8, 16, 9, 9, -13, -3, -2 },
- { -13, 11, 11, -9, -10, 13, -3, -18, 2, 10, 5, -21, 6, 15, -11, -21,
- 3, 14, 0, -12, 9, -1, -2, -4, 3, -3, -9, -8, -5, -2, -8, 2 },
- { 3, 3, 11, 4, 0, 13, 1, -8, 10, 13, -6, -26, 2, 12, -3, -5,
- 12, -2, 1, 8, -7, -17, -19, 5, 10, 7, -3, 2, -3, 0, 5, 0 },
- { 5, 0, 3, -3, -9, 5, -15, -5, -5, 17, -5, -31, 0, 13, 13, 5,
- -1, -6, -14, 7, -8, 9, -14, -2, -16, -4, -4, -6, 6, -6, -10, 6 },
- { 13, 3, 1, 7, -3, 4, -1, -2, -1, 4, -8, -32, -1, -4, 0, 3,
- -10, 7, 10, -10, 4, -1, 6, 2, -16, -9, 4, 3, 13, -23, -3, -4 },
- { 4, 11, -4, -9, 4, 11, -12, -12, -12, 6, 1, -28, -3, 14, 18, -2,
- -12, 7, 15, -3, -5, -7, -3, 2, -6, 4, 4, -2, -5, -3, 2, -13 },
- { 8, 7, -7, 0, 13, 7, -8, -7, 8, 36, -10, -22, 3, 23, -3, -10,
- -3, 11, 1, -7, 3, 3, -1, -7, -4, 2, 3, 2, 5, 3, -4, -1 },
- { -1, 1, 13, 1, -6, -1, -6, -9, -18, 17, -5, -37, -1, -1, -6, -4,
- 1, -6, -15, 2, 17, -9, 0, -3, 0, 4, 0, -5, 0, 4, 1, -5 },
- { 0, 14, 5, 0, -7, 2, -6, 17, -6, -9, 7, -16, -5, 23, -14, -13,
- 8, -15, 11, 10, -11, -13, -33, -5, -2, 1, 6, 8, 0, -13, -9, 5 },
- { 11, 7, -2, -8, 9, 11, 25, -14, 7, 3, -1, -33, 14, 8, -6, -19,
- 3, 3, 2, -1, -3, -1, -2, -10, -3, 1, 2, 1, 4, 2, -3, 4 },
- { -2, 8, 4, -2, 9, 13, -4, -2, -15, -3, 19, -37, 9, 25, -9, 2,
- -5, -2, -2, -4, 4, 2, 2, 0, 3, 3, 3, 5, -2, -3, -4, -3 },
- { 10, 13, -1, -15, 4, 6, -18, -4, 25, 1, -23, -17, 15, 13, -8, -8,
- 7, 4, -5, 3, 6, 9, -7, 6, 0, -5, 8, 0, -6, -1, -2, -2 },
- { 1, 3, 9, -5, 27, 15, -9, -31, -1, 23, -2, -9, 1, 8, -1, -7,
- -2, -8, -4, -4, -2, -1, 3, 5, 0, 0, -1, 1, -7, 7, -3, -3 },
- { -8, 7, 3, -6, 8, 3, -11, -2, 36, 14, 1, -30, 6, 10, -12, -6,
- -6, -2, -4, -3, -5, 0, 9, 4, -5, -5, -8, 12, 4, -3, 1, -8 },
- { -2, 9, 33, 0, 12, -3, -7, -4, -4, -1, 6, -25, 11, -6, -9, -11,
- -2, -4, -2, 6, -1, -3, -6, 15, -6, 3, 10, -4, 1, 0, 5, 8 },
- { -22, -21, -9, -19, -5, -7, -12, -15, -8, 9, -19, 14, -7, -4, 5, -8,
- -2, 7, 1, -3, 4, -4, 6, 11, 2, 6, -3, -5, 2, -2, 0, -3 },
- { -32, -13, 3, -24, 3, -8, 4, 1, -10, 14, -15, 0, 4, 6, -1, 6,
- 7, -1, 6, 4, -3, -17, 1, 4, -6, -1, 1, 0, 3, 3, -7, -4 },
- { -32, -11, 7, -8, -12, 13, -5, -22, -4, 12, -16, 2, 0, 4, 0, 1,
- 0, 6, -5, -8, 2, 6, 5, 0, -3, -6, 5, 6, 5, 5, 13, -4 },
- { -44, -33, 6, -4, 2, 0, -9, 10, 3, 4, 7, 0, -1, 7, 5, 1,
- 1, -3, 1, 6, -1, 0, 2, 3, -4, 0, 0, 1, 0, -1, -2, -1 },
- { -30, -18, -24, -8, 5, 0, -2, 14, 7, 0, 1, 12, 6, 4, -9, 7,
- 5, 7, -11, -5, 1, -8, -1, 2, 2, -9, 7, -1, 7, 5, 6, 6 },
- { -22, -20, -13, -9, 20, -3, 10, -8, 6, -4, 2, -7, 10, 8, 0, -1,
- 2, -3, 6, -19, 2, 4, 3, 3, -7, 2, -1, -6, 1, 1, 6, -2 },
- { -27, -8, -1, 3, -1, -11, 24, 4, -1, 1, -8, 8, 5, -11, 15, -3,
- -15, -1, -1, -13, -1, 1, -5, 5, 2, 3, -9, 0, 4, 3, -7, 6 },
- { -33, -16, -1, -8, 10, -23, 6, 13, -1, -3, -9, 0, 5, -7, -5, -12,
- -2, 3, 3, 6, -2, -3, 2, -3, 9, -6, -3, -2, 0, 5, -3, -4 },
- { -22, -17, 11, -3, 3, 1, -1, -5, 17, 2, -15, -2, 10, -9, 6, 14,
- -16, -12, 20, -1, -7, 6, -3, -12, 1, 10, -10, -1, 7, -3, -1, 10 },
- { -28, -13, 1, -3, -1, -1, 0, 3, 3, 5, 1, 10, -10, -3, 7, 2,
- 4, 19, -1, -1, 10, 5, -8, 1, 11, -15, -4, -3, -5, 4, -13, 3 },
- { -22, -13, 42, -20, 5, -13, 7, -11, 1, 1, -1, 1, 6, 3, 6, -11,
- 3, 3, -2, 0, -4, 4, -3, -1, -5, 2, 0, 0, -9, -1, 4, 4 },
- { -26, -15, -2, -6, -4, -2, 16, 8, 21, 8, 1, -3, -10, 7, -8, -12,
- -5, 12, -9, 3, -2, -3, 18, 1, -12, -15, -4, 5, -3, 0, 12, 7 },
- { -26, -16, 5, 6, 14, -3, 15, 6, 1, -7, -13, 16, -15, 5, 11, -2,
- 9, -7, -4, -2, 0, 0, -2, 7, -8, -6, -5, 2, 7, -3, 2, 12 },
- { -31, -17, -8, -30, 4, 14, 6, -6, 6, -11, 0, 3, -4, 0, 0, -4,
- 0, -4, 1, 4, 3, 4, 0, -5, 3, 2, 2, 0, 2, 1, 3, 5 },
- { -61, -10, 4, 10, 4, 7, 0, -3, 0, 1, 0, -3, 0, 1, 0, -2,
- -1, 1, 2, -2, 4, -3, 1, 1, -1, 1, -2, -4, -4, 4, 0, 0 },
- { -28, -13, -8, -4, 3, -3, 2, 1, 11, 14, 3, 9, 1, 13, 3, 5,
- -3, -2, -2, -12, -14, -9, -11, -15, -12, -5, -4, -12, 3, -3, 0, -5 },
- { -41, 0, 12, -24, 13, 4, 5, 16, -5, -4, 0, 0, 13, -4, 1, -9,
- 9, -6, -1, 6, -2, 5, 2, 9, 6, -9, -8, 8, -2, -3, -6, -4 },
- { -26, -19, -2, -15, 4, -14, 6, 0, 26, 20, 8, 9, 9, 3, -4, -5,
- -8, 1, 0, -1, 5, 9, 3, 4, 4, 7, 1, 3, -2, -2, -10, 0 },
- { -29, -18, 9, -4, 1, -5, -14, -12, 5, -10, -5, 4, -5, 0, -1, -1,
- 4, -5, 7, -16, -11, 2, 7, -15, 2, -4, 6, -4, -6, 7, -3, 7 },
- { -27, -16, 9, -14, 3, -8, 9, 0, 7, -4, -3, -7, 0, -10, -1, 2,
- 1, -2, 15, -10, 14, 7, 6, 17, 3, -4, 3, -10, 8, -8, 3, 11 },
- { -21, -20, -8, -8, 4, 5, -3, -2, 0, -5, 14, -10, 11, -4, 13, 0,
- 5, -11, 19, -18, 18, 3, -5, -3, -4, -8, 11, -10, 10, 3, 4, -9 },
- { -35, -15, 13, -12, 4, 0, -2, -4, -12, -3, -8, -24, -7, 1, 7, 8,
- -3, 0, -2, -1, 3, -2, -2, -6, 8, 1, 0, 1, -6, -1, 2, -6 },
- { -19, -14, 13, -10, 9, -1, 1, 3, -12, 5, -16, 7, 13, 9, 4, -4,
- 6, -5, 4, 9, -3, 17, -4, 12, -11, -6, -5, -6, 13, 2, 7, -9 },
- { -34, -8, -4, 1, 2, -1, 3, 6, -20, -11, 8, -1, 4, 2, -9, 4,
- -4, -5, 16, 10, -4, 14, -13, 1, -6, 0, 2, -10, 0, -3, -3, 7 },
- { -36, -10, -8, -3, 2, -2, 14, -4, -1, -7, -4, 10, -1, -3, 15, -11,
- 0, 2, 3, -1, 4, 0, 8, -1, 0, 18, -11, -5, 15, -5, 13, -12 },
- { -22, -13, 14, -20, 15, 25, 16, 10, 8, -2, -10, -5, -1, -8, 11, 8,
- -1, -2, -4, 1, 2, -1, -7, 0, 0, 0, -3, 0, 2, -1, 0, 2 },
- { -31, -22, 7, 6, -2, 5, -20, 14, -6, 7, 0, 14, 3, -7, 3, -6,
- -2, 1, -3, -5, 1, -10, 1, -24, 6, -2, 3, -7, 1, -7, 8, 7 },
- { -25, -20, -3, -9, 10, 6, 12, 7, 5, 4, -3, 6, -1, -5, -6, -8,
- 3, 5, 6, 5, -10, 10, -4, -15, -15, -2, -9, 2, 18, 1, 8, 12 },
- { -24, -19, -2, -4, -7, 11, 6, 9, 16, 2, -7, 18, 6, -7, 6, 6,
- -2, -9, 3, 12, -2, 3, -1, 6, 7, 8, 0, 8, -11, 8, 4, 2 },
- { -26, -20, -12, -12, -2, -3, 1, -5, -1, -2, 0, 3, 7, 9, -2, 2,
- 9, 22, 13, 4, -4, -1, -2, -14, 5, 15, -8, -5, -7, -11, -14, -6 },
- { -21, -18, -1, -4, 0, 3, 7, -2, 10, 8, -8, -1, 15, 1, -9, 3,
- 1, 3, -5, -2, 2, 4, 0, -1, 10, 2, -19, -8, 8, 30, -7, 8 },
- { -25, -6, 26, 4, -8, 4, -2, 21, 5, -4, -16, 5, 13, 4, -10, -1,
- -6, -2, 2, -10, -13, 1, 3, -3, -6, -8, 2, 11, 1, -7, 0, 5 },
- { 0, -1, -2, 19, -12, -48, -6, 11, 8, -2, -4, -2, -7, 5, -3, 2,
- -2, -1, -1, -7, 0, -3, -3, -4, -4, 4, 1, 3, -3, -1, -2, -5 },
- { -11, -8, -28, 18, 16, -24, -8, 19, 4, 8, -12, 9, -4, -2, 4, -7,
- 6, 2, 3, 3, -4, 0, 1, -6, -4, -2, 2, 6, 0, -3, 1, -16 },
- { -9, -5, -26, 7, -3, -37, -16, -2, 2, -7, 4, -13, 0, -4, -6, -5,
- -6, -4, 0, 3, 4, -3, -4, -4, 4, -3, 9, -4, -2, 2, 7, -4 },
- { 2, 9, -18, 7, 29, -24, -1, 7, 14, 10, 3, -3, -2, -5, 6, -10,
- -6, -3, -8, 0, 5, 1, 4, 3, -12, 2, 6, 1, 3, 4, 1, -3 },
- { -20, 2, 8, 20, -9, -24, -4, 18, 3, 11, -1, -11, 6, 9, -1, -3,
- 1, -1, -15, 3, 15, 9, 3, 2, -13, 2, -8, 8, 1, -1, 1, -8 },
- { -12, 5, -11, 6, 19, -26, -17, -6, 4, 14, 6, -8, 9, 5, -6, -5,
- 2, -1, 20, 1, -11, -10, -18, 20, -7, 0, -3, 4, 2, 0, 10, 4 },
- { -15, 1, -2, 13, -8, -21, -22, 4, 4, 3, 3, -7, -31, 4, -10, -14,
- 0, 8, 4, 5, 8, 11, 2, -8, 6, 7, 0, -2, 6, 8, 8, 7 },
- { -13, -10, -9, 12, 19, -16, -3, -2, 9, 2, 11, -29, -1, 9, 4, -3,
- 1, -10, -10, 16, 1, 7, -7, -6, -4, -1, -5, 3, 6, 0, 3, 1 },
- { -17, -1, -5, 19, 12, -9, -21, -5, 2, 12, -7, -7, -3, 8, 7, -2,
- 6, -9, -9, 1, -4, 1, 1, 3, -14, 2, -8, 0, 10, 1, -12, -6 },
- { -13, -5, 8, 15, 0, -20, -2, 20, 8, -8, 8, -19, 12, 10, 2, -11,
- 0, 12, 1, -11, 0, -11, -15, 5, -11, 2, 4, -4, -11, 5, -4, -5 },
- { 3, -11, -7, 8, 0, -17, -26, 15, 19, -7, 10, -9, -5, -5, 14, -25,
- 0, -8, 2, -9, -3, 9, 1, -6, 4, -4, 3, -9, -1, 6, 2, 2 },
- { -12, 5, 5, 9, 14, -18, -19, 4, 2, 16, 14, -21, -15, -9, -1, 16,
- 12, -11, -10, -5, -7, 4, 15, -8, -5, -1, 1, 14, 13, -7, -1, -4 },
- { -10, -5, -1, 8, 7, -23, -10, 14, 6, 11, 10, -16, -3, 16, 6, 0,
- 0, 9, 6, -2, -7, 1, 22, 5, 3, -8, 0, 3, -2, -10, 3, 0 },
- { -2, -14, 2, 16, 15, -17, -17, 6, 19, 4, -10, -15, -1, 15, 11, -14,
- -8, 5, 8, 8, -2, -8, -11, 10, 10, -8, -14, 2, 13, 4, -2, -12 },
- { -10, 3, 6, 4, 19, -23, -19, 1, 4, -9, -30, 3, -6, 18, 0, 2,
- 0, -11, 0, 3, 7, -2, 8, 5, 2, -3, 6, -9, 1, -4, 7, -6 },
- { 9, 5, -2, 21, 20, -33, -13, 7, -10, 8, 8, -15, -6, -4, 1, 5,
- 3, 7, -2, -9, -1, 4, -6, 1, 0, 9, -1, -5, 2, 1, -3, 3 },
- { -9, -3, 3, 15, -3, -30, -7, -7, -25, 6, 2, -6, 1, 19, 1, -12,
- 1, -8, -13, 9, 13, 1, 8, 2, 5, 15, -2, 3, -9, 0, -4, 4 },
- { -6, -12, -17, 25, 22, -13, -10, 9, 2, 11, -7, -16, 4, 6, 1, 0,
- 0, 18, -4, -5, 4, -2, -1, -5, 0, -4, 6, 1, 6, -1, 7, 0 },
- { -1, 0, -10, 8, 8, -27, 0, -2, 29, 16, -2, -4, 9, -1, 2, 0,
- 6, 10, 6, 4, 2, -7, 9, -18, 3, 3, 3, -10, 17, 10, 9, -6 },
- { -3, -12, -6, 11, 20, -32, 5, 21, 3, -4, -9, 2, -10, 1, 7, -4,
- 5, 0, 0, -1, -8, -9, -7, 4, -10, 5, 0, 2, -5, 4, 9, 1 },
- { -5, -1, -5, 1, 2, -19, -13, 1, 6, 12, 2, -16, -17, 11, 10, 13,
- 16, -12, -11, 3, -6, 0, 6, 4, -3, 1, 8, 2, 5, -11, 3, -14 },
- { -19, 5, 10, 11, 2, -23, -9, 16, -2, 7, 0, -11, -7, 10, 6, -7,
- 26, -15, -4, 8, 6, -4, 7, -9, -15, 1, 8, -4, 4, 2, -12, 16 },
- { -11, 1, 11, -4, 1, -31, -13, -1, 8, 5, 4, -2, 0, 13, 7, -17,
- 7, -10, -6, 1, 4, -1, 2, -9, -4, 9, 3, 3, -4, -5, 3, 4 },
- { -3, 1, 10, -1, 0, -15, -22, 4, 40, -11, -4, -3, -14, 9, 11, -1,
- 9, -1, -6, 6, 3, -6, 0, 0, -12, 7, -2, 0, 9, 3, 1, 3 },
- { -1, -1, -1, 14, 8, -24, -14, -8, 5, 8, 5, -12, -17, 8, 2, 7,
- 10, -8, 0, 4, -6, -6, -10, 8, 4, -12, 3, -9, -12, 5, 4, -3 },
- { -5, 1, -11, 8, 9, -24, 0, 2, 2, 14, -12, -13, 1, 6, 7, 0,
- 7, -6, 9, 26, 11, -14, 8, 10, 1, 9, 0, 11, -2, 6, 2, -10 },
- { -13, 1, 4, 34, 19, -17, -15, 0, 3, -2, -7, -1, 0, -3, -3, -1,
- 1, -1, -10, 8, 5, 0, -8, 4, -17, 9, -2, 0, 0, 6, 2, -3 },
- { -6, -4, 1, 2, 2, -14, -29, 0, 9, 34, -3, -5, -14, 6, -10, -9,
- -5, -1, 0, 3, 3, 0, 1, -1, -2, -1, -1, -3, -3, -4, 3, -3 },
- { -4, 6, 3, 14, 14, -8, -29, 31, 11, 14, -4, -5, -6, 10, 6, -9,
- -1, -11, -7, 1, 7, 4, 1, -6, 4, 0, 10, -7, -5, -1, 2, 4 },
- { -4, -4, -2, 14, 6, -32, -6, -14, 14, -5, -11, 10, -18, -4, 6, -8,
- 9, 5, -4, 1, -4, 5, -2, -9, 3, 5, 2, -10, -6, -17, 3, 17 },
- { -16, 9, 21, 19, 4, -20, -17, 14, 9, 15, -6, -17, -1, 1, 6, -3,
- 1, 1, 8, -3, -6, 6, 9, 4, 9, -9, -5, 1, -1, 0, -1, 2 },
- { -7, -5, 3, 19, 1, -20, -9, 14, 21, -7, -18, -9, 26, -7, -17, -7,
- 12, 6, 0, -9, -6, 14, 9, -9, -8, 4, 15, -7, -9, -1, 9, 1 },
- { -20, 30, -6, 11, 24, -4, 0, -6, -2, 8, -4, 12, -8, -17, 0, 5,
- -4, 1, -1, 3, -3, 5, 3, 3, 7, -2, -3, -2, 4, 0, 0, -1 },
- { -35, 17, 6, 1, -9, -1, -16, 3, -20, -13, 8, 7, -4, -7, -4, -20,
- 7, 12, -5, 5, -5, -11, 12, -1, 15, -9, -6, 16, -4, -9, -13, 4 },
- { -21, 36, -19, 9, 0, -7, -8, 9, -4, -3, 3, 0, 7, -8, -2, -2,
- -11, 13, -1, 5, -3, 7, 2, 3, -1, -2, -5, 1, -1, -2, -5, -3 },
- { -12, 33, -4, 1, -12, -9, 0, -13, -1, 2, -8, 4, -10, 6, -16, -7,
- -1, -4, -10, 15, -1, 0, -5, -8, 5, 5, -3, 0, 2, -7, 1, -7 },
- { -14, 32, 5, -7, -15, 3, -5, 8, 14, 5, 9, 13, 3, 18, -3, 7,
- 4, -10, -10, 10, -1, 2, 0, -2, -11, 5, -3, -4, 2, 2, 7, 4 },
- { -14, 34, 1, 20, -1, -12, 0, -3, -7, -4, 7, 18, 9, -3, 14, -7,
- -9, -20, -7, -4, -13, 12, 1, 12, 5, -6, 2, -4, 0, -15, 1, 3 },
- { -21, 23, 7, -8, 3, -13, -3, 0, -6, -2, -7, 6, -12, 9, -6, -2,
- -2, -4, -1, 6, 9, 5, -9, 15, 0, 8, -8, 7, 6, -15, 3, -5 },
- { -27, 32, -1, -4, -2, 4, -10, 12, -3, 8, 13, 7, 0, -15, 4, -2,
- 3, 5, 7, -4, 9, -12, -1, -2, -1, -4, 0, -4, 2, -5, 6, -6 },
- { -17, 29, 15, 0, -1, -4, -10, 13, 12, -1, -8, -10, -10, 4, 7, -2,
- 6, -5, -13, 19, 6, 1, -7, 2, -9, -2, 12, -4, -8, -3, 2, 4 },
- { -38, 27, 16, -15, -6, 3, -7, -4, 0, -1, 6, -2, -3, -6, 6, -6,
- -3, 0, 2, 0, -4, 6, 1, -1, 0, 4, -1, 3, 4, 1, -2, 5 },
- { -33, 40, -4, 2, 1, 0, 0, -10, -14, 0, -7, 4, -1, 3, -2, 5,
- 7, 6, -1, 4, 1, 3, 1, -7, 1, -4, 5, 7, 0, 4, 3, -4 },
- { -20, 25, 12, -4, 16, -4, 2, 2, -14, -2, -3, 29, -1, 1, 3, 1,
- 9, -5, 2, -8, -3, 1, -7, -2, -7, 1, 0, 4, 16, -2, -1, -1 },
- { -10, 30, 17, 3, -5, -2, 0, -5, -22, 4, 5, 5, -3, -18, -6, 10,
- -5, -7, 2, 8, 7, -7, -11, -2, 0, -3, 3, 2, 11, -4, 4, -4 },
- { -11, 30, 11, 4, -3, -8, 1, -2, 4, 18, 3, 1, -1, 0, -8, -4,
- -3, 10, 13, 14, 5, -5, 1, 1, -10, 2, 15, 4, 9, -1, -5, -3 },
- { -17, 32, 18, -18, -3, -5, 6, 10, 1, -15, -5, 9, 8, -12, -10, -6,
- 11, 9, -5, -8, -7, 10, 5, -10, -14, -4, -3, 1, 9, -11, 2, 1 },
- { -13, 28, -11, -1, 2, -16, -2, 7, -24, 0, 3, 6, 3, -1, -8, -7,
- -12, 2, 2, -20, 10, 4, 0, -13, -2, -2, 1, 8, -14, 0, 4, 1 },
- { -14, 23, 12, 8, 8, -26, 2, -4, -14, 13, -14, 15, 3, -9, -1, -13,
- -10, -2, -10, 6, -16, 12, 8, 0, 9, -10, -7, -4, -4, 7, -8, 8 },
- { -20, 45, 10, -14, 4, 16, 8, -9, 1, -8, 10, 5, -7, -2, 2, -5,
- -1, 0, -5, 4, -6, -2, 4, 1, 3, 4, -4, 2, -2, -2, 5, 1 },
- { -20, 26, -4, 1, 7, 4, -8, 1, -5, -13, 2, 13, -7, -3, 6, -6,
- 22, 0, 5, 11, -4, -11, 8, -9, 2, -2, -4, -2, 2, -13, -4, -8 },
- { -28, 18, 17, 3, -8, -23, -16, -6, 5, -10, 14, 10, 5, -1, -8, 4,
- -2, 13, -3, -2, 3, 4, 3, -2, -3, -4, 0, 1, 3, 4, 0, 4 },
- { -12, 32, -6, -16, 18, 12, -16, 0, 7, 13, -4, 5, -8, -1, -3, 4,
- 6, -2, -1, -13, 4, -1, 3, 12, -3, -10, 1, 6, 8, -11, -2, 4 },
- { -18, 26, 2, 5, 0, -9, -17, 14, 5, 1, 7, -3, -8, -3, 11, 7,
- -5, -12, -8, 7, 0, -7, 2, -12, -9, 13, -11, 9, 6, -11, -5, 11 },
- { -24, 22, -15, -9, 8, 1, -7, -12, -9, 3, 11, 15, 14, -11, 12, -15,
- -5, 7, -2, 0, -8, 3, 3, -1, 2, 11, -11, 14, -6, 13, 1, -6 },
- { -20, 28, 18, -4, -6, -5, 12, 14, 2, 10, -13, -6, -8, -6, -13, -1,
- -26, 22, -3, -14, 6, 0, 10, -15, -13, -9, 6, -7, 1, -5, -4, -1 },
- { -19, 26, -8, -3, -14, -6, -9, -4, -8, 15, -8, 3, -12, -4, -2, -7,
- -5, 3, 13, -3, -4, -25, 4, -1, 5, -12, -1, -13, 5, 2, 0, 6 },
- { -18, 43, 14, -8, 1, -23, -2, -2, 1, 3, -7, 0, 0, 8, -1, -3,
- -5, 1, 5, 2, 0, -2, -2, -2, 1, -1, -1, -7, 0, 3, -3, 9 },
- { -11, 30, 10, -14, 3, 1, 10, -11, 1, -7, -4, 14, 2, 1, -9, 1,
- -11, -2, -7, 5, -11, 1, 3, 14, 1, -16, -8, 3, -5, 7, -4, 4 },
- { -18, 24, 6, 3, 8, 7, -22, -7, -7, 3, -8, 4, 23, 9, 3, -1,
- 3, 6, 7, -1, -7, 6, 4, 1, -3, 1, -6, -1, 2, -7, 3, 3 },
- { -15, 38, -7, -1, -11, 2, -17, -24, 24, 8, 7, -4, -5, 2, 2, -7,
- 1, 4, 0, -9, 5, 0, -1, 1, -1, -5, -6, 3, 0, 7, 8, -3 },
- { -14, 22, 1, -5, 9, -12, -9, -5, -6, 5, 7, 8, -1, -4, -9, -3,
- -33, -16, -9, -1, 12, -11, 17, -7, -3, -1, -7, 3, 2, -3, 16, -4 },
- { -14, 20, 6, 4, -10, -4, -4, -4, 1, -7, 2, 6, 8, -12, 4, 1,
- -1, 12, 10, 3, -14, -10, -3, 18, -2, 33, -5, -17, 17, -5, 9, 7 },
- { -12, 23, 13, 0, -11, -8, -11, 12, -5, -9, -16, 11, 6, 4, 12, -5,
- 5, -13, 7, -12, -3, 1, 2, 12, 1, -4, -1, 5, 4, 11, -12, -3 },
- { 15, 2, 14, 7, 1, 2, 1, 12, 10, 23, 4, 6, -20, -10, 4, 26,
- -6, 13, 4, 3, 2, -11, 5, -7, -10, 4, 9, 1, 10, -4, 11, 4 },
- { 17, 15, 31, 17, 18, 16, 11, 24, 2, 4, 2, 3, -8, -3, 7, -3,
- -5, -7, -2, -6, -4, -5, -4, -1, -4, -2, -5, -6, 2, -1, 4, -2 },
- { 16, 8, 15, 14, 3, 7, 21, 9, 8, 15, 21, 6, 8, 12, 5, -5,
- 7, -3, 10, 2, -3, 8, 6, 0, 5, 5, 6, -3, 2, 4, 0, -5 },
- { 5, -4, 6, 12, 6, 13, 24, 17, -5, 17, -1, -6, -7, -10, -8, -18,
- 3, -2, 2, 7, -15, -11, 12, -3, -2, -2, -4, -7, 2, 0, 5, 5 },
- { 10, -6, 8, 11, 12, 20, 22, -11, -3, 15, -3, 15, -2, -2, 0, 2,
- 5, -8, 4, -5, -9, -4, -1, 2, -1, -3, 1, 3, 13, -1, 9, 7 },
- { -5, 8, 5, 11, 14, -5, 14, -9, 2, 35, 8, 15, 1, -2, 2, -2,
- 4, -9, -3, -14, -12, -2, -2, -4, -2, -8, -3, 1, -6, 3, 10, 0 },
- { 16, 0, -6, 15, -3, 4, 4, 3, 3, 20, 5, -4, 10, 9, -9, -3,
- -10, -2, -7, 11, -11, -10, 17, -1, 3, -15, 2, 9, -15, -10, 16, 10 },
- { 14, 4, -7, 19, 3, 0, 19, 8, 16, 34, -9, 6, -13, -1, 6, 5,
- -1, -2, 4, 3, 2, 1, 1, -1, 0, -7, 2, -1, 1, 0, 6, -1 },
- { 1, 6, 9, 13, 9, 10, 15, 16, 10, 18, 13, 17, 3, -1, -7, 2,
- -15, -11, -10, -4, -13, -6, -17, -13, -6, -14, 1, -10, 6, 4, -1, -1 },
- { 13, 1, 7, 10, 14, 13, -7, 5, 5, 28, 14, 14, -2, 2, 3, -3,
- -13, -4, 10, -9, 19, -4, -3, 4, -5, -5, 0, 5, -5, 0, 3, -4 },
- { 1, 0, 6, 22, 9, 18, 18, -3, 5, 10, 12, -2, 1, -3, -8, -12,
- 9, -10, -7, 1, -1, 19, 0, 2, -8, -11, -10, 9, 6, 11, 0, 3 },
- { 10, 11, 19, 44, 0, 14, 1, -7, 6, 22, 2, -1, 9, 2, 0, -4,
- 4, 0, -6, -6, 3, 0, 0, -2, 2, -5, 1, -2, 0, 1, 1, 1 },
- { 5, 7, 0, 32, 30, 26, 5, 4, -7, -3, 15, -6, 3, -10, 7, 6,
- -8, -7, 2, -13, -5, -1, -3, 7, 3, -2, -8, 0, 6, 4, 5, 0 },
- { 9, 8, -2, 4, 2, 11, 4, 29, -5, 14, 8, -5, -14, 8, 0, 9,
- 8, -10, 5, -15, -6, -9, 9, -1, 18, -16, 9, -21, -3, -13, -2, 8 },
- { 25, 7, -9, 23, 20, 18, 6, 16, -9, 8, 8, -5, 11, 13, -8, 7,
- 4, 10, -2, -1, -7, -9, -7, -9, -4, 1, 1, -5, -10, 8, 4, -5 },
- { 9, 2, 16, 14, -5, 14, 1, 0, -21, 17, -1, 9, 12, -3, -3, 4,
- -4, 14, 10, 3, 0, -10, 7, 4, 4, -11, 2, 4, -1, -3, 9, -1 },
- { 17, 8, 11, 26, 15, -3, 14, -1, 12, 9, 10, -8, 8, -18, -11, -3,
- -14, -7, 7, -3, -3, -4, 1, -7, -3, 2, -3, 16, 10, 0, 9, 6 },
- { 9, 8, 3, 8, 18, 14, 11, 1, 10, 6, 1, -4, -16, -2, 14, -2,
- 1, 8, 12, 14, 3, -3, 8, 8, 12, -15, 3, -3, 3, -2, 14, 10 },
- { 22, -3, -11, 13, -7, 11, 4, 11, 3, 14, 0, -6, -2, -9, 4, 2,
- -2, 0, -5, -27, -10, 3, -1, 5, 8, -24, -3, -11, -3, 2, 11, -1 },
- { 19, 2, 8, 36, 5, -6, 3, 15, -3, -4, -5, 14, -10, 1, -12, -10,
- -3, -4, 3, -2, 1, -8, 4, 3, 5, -3, 0, 4, 8, -2, 8, 4 },
- { 8, 14, 15, 9, -4, 10, 5, 11, 9, 10, 8, 9, -15, 15, 6, -8,
- -10, -13, 5, -8, -20, -13, -6, -11, -1, -3, -6, -4, -1, 0, 13, 15 },
- { -2, -1, 9, 12, 2, 2, 13, 3, -23, 33, 15, 2, -4, -1, 3, 8,
- 8, 6, 6, -7, 8, 6, 9, -1, 3, -8, 0, -4, 1, -8, 11, -1 },
- { 6, 5, -6, 16, 2, -3, 31, 21, -9, 12, 0, -1, -4, 1, -12, 3,
- -13, -18, 2, -11, -9, 2, -8, -6, 11, -3, -1, 0, -1, 0, 13, 5 },
- { 5, -1, 2, 0, 25, 5, 10, 16, -5, 21, 14, 12, 13, 2, -5, 5,
- 5, -3, -2, -14, 0, -12, 7, 11, -1, -7, 19, -1, -1, -1, 8, -1 },
- { 10, 7, 3, 11, 0, 8, 22, 3, 3, 19, -4, 12, 15, 9, 5, 15,
- 2, 1, 2, -10, -10, 0, 2, -1, 0, 1, -12, -1, 21, 16, 9, -7 },
- { 11, -4, -5, 24, -7, 11, 20, 11, -15, 18, 5, -13, -15, 0, -5, 9,
- 1, 0, -1, -9, 4, -8, 6, -8, 1, -2, -7, 20, 9, 3, 9, 3 },
- { 20, 0, -12, -6, 9, 31, 9, 12, 8, 27, 15, 7, -16, 5, -3, -7,
- -1, -9, -2, -7, -3, 4, -8, -3, 3, -6, -2, -2, -3, -6, -1, 2 },
- { 6, -6, 48, 8, -3, 19, 12, 11, -7, 2, 3, 0, -1, 1, 8, -4,
- 4, -6, 0, -4, -4, -3, 3, 6, 3, -13, -8, 5, -3, -7, 8, 5 },
- { 7, -2, 6, 11, 12, 2, 14, 4, -5, 12, 2, 9, 4, 2, 0, -1,
- 2, 0, -15, -9, -16, -2, 8, -17, -5, -22, -19, -5, -1, -10, 1, -2 },
- { 11, -9, 3, 12, 6, 6, 1, 17, -6, 19, 14, 7, -7, -1, -1, -9,
- 9, -11, -17, 0, -6, 16, 0, 1, 9, -24, 3, 3, -9, -3, 3, -2 },
- { 9, 0, 1, 8, 1, 7, 2, -5, -3, 8, -1, 7, 2, 6, -3, -6,
- 5, -2, 6, -2, -4, -3, 0, -3, 13, -50, 1, -2, 2, 4, 4, 3 },
- { 7, 0, 26, 21, -4, 2, 17, 8, 7, 11, -7, 1, -1, -15, -1, -15,
- -11, -4, -17, -4, 1, -7, 3, 6, 3, -9, 2, 3, 6, 10, 6, 12 },
- { 1, -2, 2, -1, -10, -4, 6, -3, -5, -2, -8, 2, 2, 2, 8, 0,
- 1, 1, 6, 0, 11, 13, 3, 4, 0, -12, 11, -5, 19, 20, 2, 5 },
- { 5, 3, -13, -2, 1, -12, 11, -7, -12, 7, 10, 0, 7, 0, -2, 4,
- -6, -9, -11, -12, -23, 12, 10, -3, 0, 6, 19, -1, 24, 18, 9, 12 },
- { 6, -3, 2, 5, 2, 2, -2, -5, -8, -11, -4, 3, -8, -4, 5, -3,
- -16, -4, 3, -12, -4, 3, 32, 7, 2, 8, 32, -18, -1, 12, 1, 7 },
- { 0, -8, -1, 0, -8, 7, -8, -1, -1, 4, -12, -1, 3, 0, 1, -18,
- 8, 8, -14, -10, -11, 19, 9, 5, -7, 6, 8, -4, 26, 12, -1, 6 },
- { 3, 5, -14, 7, 14, 8, 20, -13, -16, -10, -2, 17, -7, 4, -8, -9,
- 14, -5, 3, -4, -12, 7, 14, -10, -19, -20, 35, 8, 13, 14, -2, 9 },
- { -2, -4, -1, 1, -3, 0, -1, 1, 2, 2, 6, 0, 0, 4, 5, -2,
- 3, 3, 3, -2, -7, -3, -3, -1, 6, -2, 29, 22, 13, 34, 0, 14 },
- { -3, -9, 3, 1, 5, -4, 2, 0, 7, -9, 0, 2, -5, -3, 0, 6,
- -1, -1, -1, 2, 2, 4, 8, 7, 20, -6, 7, 16, 33, 20, 6, -1 },
- { -11, 1, -3, -3, -11, 3, -9, -25, -1, -16, 4, -8, 15, 1, -2, 7,
- 8, 23, 2, 18, -13, 16, 3, -7, 6, 3, 16, -8, 12, 16, 3, 4 },
- { 0, 5, 5, -5, 1, -1, 2, -3, -2, 1, -13, 2, 2, 10, 6, 7,
- 18, 18, 7, 9, 8, 9, 21, 14, 7, 12, 15, 14, 15, 12, 11, 5 },
- { 1, -5, 11, -2, 17, 8, 3, 0, -1, 6, 11, -7, 6, 6, 7, 5,
- -15, 14, 1, 11, 4, 10, 12, 1, 2, 4, 30, 1, 11, 1, 6, 13 },
- { 2, 4, 3, -7, 5, 8, -11, 7, -5, 9, -10, 6, 8, -10, -3, 10,
- 1, -29, -4, -26, 5, -8, 13, 4, 3, 6, 35, 1, 3, 6, 3, 0 },
- { -2, 1, 0, 0, -1, -3, -7, -3, -9, -3, -1, -6, 3, 4, 4, 0,
- 5, -1, -2, -2, -1, -4, -10, 8, 0, -6, 10, -4, 46, 12, 2, 28 },
- { 4, -1, 4, 1, 0, 4, -2, -2, -2, -1, 2, -4, 1, 5, 0, -3,
- 1, 1, -2, 0, 1, -2, -1, -1, 3, -6, 35, -11, 13, 53, -3, -1 },
- { -5, -2, 0, -13, -16, 5, -12, -11, 1, -30, 3, -18, -24, -8, -5, -19,
- 1, -3, -8, 7, -7, -8, 15, -19, 4, 10, 30, 24, 6, 1, -9, 10 },
- { -4, 8, -7, -4, -6, 12, -1, -9, -4, 2, -9, 3, 2, -2, 4, 2,
- 22, 9, 4, -5, 0, 5, -2, -9, -3, 1, 18, -12, 18, 16, 4, 16 },
- { -5, -8, -3, -5, -3, 6, -7, -3, -2, -5, -3, 1, 2, 2, 4, -6,
- 10, 3, 12, -3, 20, 0, 27, -4, 16, 5, 18, -3, 23, 4, 12, 11 },
- { 0, 1, 0, 1, -2, 1, 2, 1, -1, 0, -2, 2, -2, -4, 1, -2,
- -2, -1, -5, -2, 0, 0, -2, 2, 9, 7, 63, 5, 12, -1, 1, 0 },
- { 4, -3, -7, -5, -11, -5, -12, -10, -10, -12, -15, -12, -14, -14, 1, 1,
- 10, -10, 16, 6, 2, 9, 11, 9, 9, 8, 12, -1, 13, 12, 6, 3 },
- { 7, -3, -2, 4, 6, -8, 2, -3, -12, -5, -9, -8, -10, 15, -2, -4,
- 8, 9, 7, -13, -18, 34, -5, 7, 12, 22, 16, -11, 13, 25, -15, -11 },
- { -3, -2, 0, -4, 1, 0, -3, -13, -7, 13, 12, -7, -10, 13, 19, 6,
- 16, 15, -12, -15, -3, 34, 1, 5, 1, -9, 11, 21, 8, 17, -5, -6 },
- { 3, -5, 0, -4, 0, 4, -11, 4, -7, -3, -1, -8, 3, -2, 2, 1,
- 11, 5, 6, 14, -3, 2, -4, -7, 0, 31, 15, -2, 24, 11, 5, 4 },
- { -1, -4, -9, 5, -8, -18, -4, -9, -20, -18, 7, -14, -16, 3, 8, -3,
- 29, 11, -13, -13, 7, 1, 17, 6, 6, 21, 11, 1, 14, -8, 2, 5 },
- { -3, 8, -10, -6, 12, 2, 1, 3, 3, 3, 3, -6, -8, -14, 15, -5,
- 16, 4, 16, 0, 7, -1, 0, 16, 2, 1, 22, 4, 19, 13, -11, 1 },
- { 2, -3, 10, 20, -4, -1, -8, 5, -8, -9, -6, -2, -4, -7, 8, -10,
- 0, 8, -6, 1, -8, 14, 13, 5, 17, -6, 26, -1, 7, -1, 0, 12 },
- { -4, -7, -31, -2, -7, -1, 5, -5, -5, -12, 4, -7, -6, 3, 15, -2,
- 5, -2, 7, -1, 10, 7, 8, -1, 14, 20, 14, 9, 16, 16, 8, 24 },
- { -7, 0, -3, -6, 1, 3, -13, -6, -4, -4, -5, -9, -1, -10, -4, -8,
- 2, 0, -1, 1, 24, 24, 21, 31, 5, 2, 11, 12, 7, 4, 3, 6 },
- { -3, -5, 6, -4, -3, -1, 2, -1, -2, 1, 0, -8, -1, 2, 0, -4,
- 6, 22, -1, -5, 8, 12, -1, -2, 28, 27, 20, -27, 14, 1, 2, -3 },
- { 1, -5, -2, -2, 6, -2, 9, 1, -2, -5, 3, 4, 11, 5, 2, 8,
- -3, -1, 1, -2, -3, -5, 5, 8, 49, 12, 8, -3, 9, 20, 12, 17 },
- { -6, 0, 1, 7, 0, 9, -2, -4, 8, 0, -2, -10, 0, 7, 21, -1,
- 0, 1, 17, -7, -5, 2, 4, 16, -2, 17, 14, -20, 15, 14, 4, 15 },
- { 0, 3, -4, 9, -4, 0, 6, 4, -6, -6, -5, -7, 2, -9, -10, -2,
- -5, 0, -3, -21, 9, 14, -11, 13, 29, 2, 25, 4, 22, -1, 2, -3 },
- { 2, 12, -11, 2, 16, 9, -4, 7, 1, -10, -15, 11, -4, 3, -2, 4,
- 4, -5, -10, 1, 4, 19, -15, 6, -4, -2, 30, -7, 11, 21, -12, 5 },
- { -2, -3, -2, 4, -1, -5, -3, -7, -5, 1, 0, -6, 1, -6, 7, 0,
- 8, -7, -3, -2, 2, 14, 2, -3, -26, -1, 26, 22, 32, 1, -2, 6 },
- { 1, -38, -1, -20, -2, -3, -6, -4, 2, 2, 7, 0, 3, 5, 3, 10,
- 6, 1, -3, -5, 7, 5, -5, -4, 8, 3, 1, -14, -1, -9, -5, -4 },
- { -5, -26, -7, -19, -10, -5, -11, 5, -11, -25, -8, -14, -9, -16, -8, -6,
- -17, -14, -1, -1, 6, 2, 2, 2, 3, 0, 2, 8, -8, 3, 0, -3 },
- { 17, -49, -3, -23, -1, 11, 7, 3, 4, -4, 0, 0, -1, 4, 2, 4,
- -2, -4, 2, -2, -1, -2, 2, 0, 0, -1, 0, 0, 1, 2, 0, 0 },
- { 4, -34, -6, -9, 1, 21, -7, 3, -2, -1, -3, 18, 2, -16, 7, -3,
- 8, 7, -5, 7, 2, 4, 8, -6, -7, -2, -5, -1, 4, 1, 2, -4 },
- { 5, -29, 13, -2, -14, 3, 1, 18, -15, 4, -8, 8, -10, 8, 2, 1,
- -8, 15, 3, -10, -4, -4, -2, 0, -3, -4, 2, -3, -4, -3, 12, -6 },
- { 13, -20, 3, -18, -17, 4, -14, 13, 28, 11, -8, -6, 16, 6, 0, 10,
- 3, 4, -9, 13, 5, -7, 12, -5, 0, -7, 5, 1, 3, 3, 2, 1 },
- { 3, -27, -5, -11, -21, -11, -12, 0, -5, 7, -22, 1, 3, 5, 0, -5,
- 8, 7, 1, -5, -7, 2, -5, 4, 1, 3, -8, -2, 0, 4, -2, 6 },
- { 31, -45, 0, -1, -12, 1, 2, -6, 4, 3, -1, 3, 3, 0, 5, 3,
- -5, 12, 4, 6, 2, 1, -2, 1, 3, 2, 5, 2, 2, 2, 3, -1 },
- { 9, -45, 6, 5, -1, -17, -2, 18, -3, 2, 0, 1, 0, -1, 10, 8,
- -7, -2, -5, -8, 6, -1, 0, 4, 6, -3, 12, -1, -2, 0, 5, -7 },
- { 3, -26, -2, -12, -12, 2, -10, 16, -3, 12, 4, 5, 11, 8, -16, -17,
- -2, -3, -3, 2, 5, -9, 13, 1, 10, 11, 3, 5, -2, 2, 2, -7 },
- { 8, -26, 32, -7, -5, 22, 2, 14, -10, -8, -7, 3, 3, 7, 0, -5,
- 0, -1, -3, 0, 8, 4, -5, -7, 6, -1, 4, 8, 1, 1, 7, -6 },
- { 4, -31, 2, -14, 2, 0, 1, 8, -6, -1, 17, -3, 13, -6, 5, -10,
- -2, -10, -2, -10, -3, 7, 1, 5, -8, 8, -14, -3, -15, 7, -10, -6 },
- { 16, -27, 13, -4, -23, 7, -9, 6, -7, 5, 4, 2, -1, -3, 23, -18,
- 7, 0, -3, 4, -3, 9, -6, -2, -1, 8, -6, 2, 6, -3, 2, -2 },
- { -1, -35, -2, -8, 11, -1, -7, -3, -2, 11, 7, 6, -6, -10, 9, 6,
- -3, -5, -6, -3, 9, 16, -16, -9, -20, 12, 3, 5, -3, 1, -9, 4 },
- { 2, -24, 1, -12, -16, 5, -4, 3, -4, -1, -11, -11, -8, -14, 14, 10,
- -8, 20, 8, -3, -11, 1, 1, -4, -4, -7, -3, 15, 2, -6, -2, 7 },
- { 9, -21, 2, -19, -7, -5, -8, 25, 3, 17, 5, -3, 9, -12, 8, 2,
- -4, 3, 3, 1, 11, -9, -4, -3, 4, 3, -22, 6, 4, 6, 11, -5 },
- { 16, -23, 13, -17, -21, -12, 5, 9, -20, 7, 6, -6, 0, 2, -9, 6,
- -6, -13, -7, -1, 5, -3, 5, -7, -10, 1, 0, 8, -9, 11, 0, -8 },
- { 10, -26, -9, -7, -19, -4, 6, 16, -7, 5, -4, 4, 8, 0, 4, -1,
- 6, -7, 1, -8, -11, 10, -14, 0, -16, 6, -3, 5, -1, 14, 12, 1 },
- { 8, -27, 12, -14, -1, -1, -19, 10, -11, 21, -14, 9, -8, -3, 8, -1,
- 12, -13, 3, -4, -2, 0, -9, 0, -7, 2, -3, 12, 1, -3, 3, 1 },
- { 18, -20, -14, -14, -16, -3, -24, 6, -17, 2, -3, -11, 2, -3, 12, 10,
- 10, 1, 10, 7, 8, 5, 5, 4, -1, 7, 2, 2, 0, 4, 7, 0 },
- { 0, -30, 9, -16, -18, 15, 12, -3, 4, -4, -5, -11, -4, -12, -10, 0,
- 2, -2, -4, -1, 2, 0, -1, -6, 2, -3, 4, -5, 7, 3, 5, 7 },
- { 25, -24, -1, -6, -9, 6, -13, -2, 3, 15, -3, 11, 4, -8, -11, 2,
- 0, -9, -2, 7, 4, 8, 5, -8, 5, 6, -1, -11, -15, -5, 0, 11 },
- { 0, -34, -7, -11, -7, 9, -3, 19, 4, -8, 3, -11, 11, -3, -9, 12,
- 9, 9, 2, 1, -7, 1, -3, 0, -6, -2, -1, 3, 0, -7, -2, -5 },
- { 6, -34, -4, -5, -3, -9, 2, 9, -1, 9, -5, -3, -26, -12, 8, -6,
- -7, 11, -8, 4, 4, 1, -1, 0, 8, 9, -4, 7, -1, 1, -3, -1 },
- { 3, -30, 5, 6, -10, 3, -7, 6, 3, 3, -26, -19, -3, 1, 7, 5,
- -4, -5, 6, 10, 13, -10, 4, -7, -4, 5, -3, 9, -6, 3, 9, 5 },
- { 4, -24, 9, -19, 2, -4, -5, 8, -3, 2, 0, -15, -1, 9, -4, 22,
- 6, 9, 3, 7, 11, -9, 0, -3, 4, 5, -5, 10, -8, 5, -7, -3 },
- { 8, -27, 7, -3, -1, 2, -9, 13, 7, 12, -4, -6, -6, 5, 0, 7,
- 5, 1, 15, -3, -4, 0, -5, -2, 7, -5, -7, 1, -2, 13, -8, 13 },
- { 17, -22, -15, -11, -8, 16, -14, 18, 2, -1, 14, -7, 14, -6, -6, -7,
- -8, 17, 6, 4, 4, -7, -5, -9, -14, -6, -1, 9, -3, 1, 6, -5 },
- { 25, -30, 2, -12, -13, 18, -18, 16, 8, -3, 10, -8, -3, -1, -6, 3,
- -5, -7, 4, 6, 7, 1, 1, -11, -5, 6, 2, -4, 9, -1, -5, -2 },
- { 7, -23, 7, -15, -1, -3, -1, 0, -10, 12, 2, 5, -4, 0, 4, 6,
- -1, 5, -9, -1, -1, -7, 1, 17, 9, -17, -16, 8, 4, -14, 11, 14 },
- { 0, -31, 7, -13, 3, -11, -7, 6, 1, -11, 8, -7, 15, -3, 16, -11,
- -1, -15, 16, -3, 5, 0, -2, -2, -6, 11, 5, 6, 5, -5, 6, 3 },
- { 13, -24, -2, -20, -10, 7, -3, -1, 15, 2, 6, -5, -7, -10, -20, 1,
- -4, 14, 8, -2, 3, -13, -3, 1, -4, 1, -3, 2, 8, -7, 16, -4 },
- { 1, -2, -2, -3, -4, -7, 0, 3, 6, 7, 3, 2, 1, -2, -1, 0,
- -6, 4, 2, -4, -3, -4, 5, 9, 5, 0, -3, -3, -4, -7, -31, -50 },
- { -1, -3, 7, 2, -1, 2, 4, 6, 0, 10, -2, 0, -20, -6, -3, 9,
- -20, -22, -1, -1, 15, 9, -12, 10, -13, -20, 12, 3, 5, 6, -7, -26 },
- { 0, 4, -2, -14, -12, 6, -13, 11, -10, 3, 22, 6, 16, -2, -5, 1,
- -3, -11, 0, -7, 5, -5, 0, 1, -1, -6, 8, 8, 10, 9, -5, -27 },
- { -5, 10, -2, 7, 9, -9, 5, -9, 5, 4, -15, 14, 1, 3, -10, 5,
- 0, -2, 7, 3, -13, 6, 9, -6, 5, -14, -17, -1, 11, 14, -2, -26 },
- { 0, 6, -3, 0, -8, 6, 0, 1, 4, -8, 2, -5, 4, 7, 15, 11,
- 9, 19, -2, 14, -8, 7, -1, 3, -3, -3, -10, -2, 12, -2, -12, -29 },
- { -12, -5, 0, -3, -2, 6, 3, -3, 2, -2, 1, 11, 2, -7, 5, 1,
- 2, -2, -14, 0, -1, -5, 3, 8, -28, -26, 6, -6, 3, 8, -10, -27 },
- { -1, -3, 6, 2, 4, 15, 1, 0, 2, -2, -2, 13, 3, 6, 0, 6,
- -1, -4, -1, -5, 8, -1, 5, -5, -15, 11, -8, -5, 14, -6, -14, -29 },
- { -5, -6, 0, 1, 0, 6, -3, 2, -5, -1, 5, -3, 2, -10, 3, 4,
- 3, 0, 13, -3, -1, 4, -4, -6, 2, 9, 8, 2, -3, 28, -11, -31 },
- { 1, -4, -10, -9, -4, -3, -15, -6, 1, 5, -3, -6, 5, -6, -22, 27,
- -13, 5, 3, -7, -4, 20, -7, -12, -1, -24, -4, -13, -8, -11, -15, -21 },
- { -6, -4, 19, -6, 2, 11, -6, 1, -3, -10, 9, -9, 12, -10, 2, 1,
- -9, 1, 15, 7, -5, 5, -29, -35, 4, -30, 9, 9, 19, 17, 2, -17 },
- { -3, 3, -3, 1, 2, 5, -1, 5, -2, -3, 1, -3, -8, 3, -4, -2,
- -4, -1, 12, 0, 2, -8, -6, -4, 16, -1, -14, -2, 25, -6, -15, -36 },
- { 0, -1, 3, -4, -4, -1, 7, -4, 8, 0, 10, 9, -4, 1, 10, -1,
- -3, -13, -5, -4, -1, -4, 8, 11, 14, -7, -5, 16, 12, 13, -1, -28 },
- { 1, -2, 2, -3, -8, 10, 4, 9, 12, 3, 5, 0, 8, -3, -6, 2,
- 16, -11, 11, 0, 1, 6, 1, 18, -10, -16, -1, -4, 5, -14, -15, -20 },
- { 1, -12, 5, 4, -7, 8, -1, -17, -2, -9, -14, -11, 6, -9, 5, -4,
- 3, -2, 7, 18, -5, 5, 6, -1, -11, -2, -10, -3, 8, -3, -2, -32 },
- { -12, 5, 20, -5, -6, -11, -6, -6, -13, 4, -6, 19, -8, 2, 3, -9,
- -4, -4, -1, 9, -1, 21, -1, 7, 15, -10, -1, -3, 9, -3, 2, -24 },
- { 0, -3, 2, -6, 4, -1, -9, -2, -1, -3, 6, -1, -5, -6, -5, -8,
- 0, -2, -6, 9, -4, 3, 2, -13, 1, -7, 23, -13, 4, -3, -15, -33 },
- { -7, 2, -15, 11, -10, 14, 0, -11, 3, -1, 12, -4, -4, 9, 11, -13,
- -13, -3, -14, 1, 3, 6, -5, 8, 0, 5, 5, -10, 4, 5, -6, -30 },
- { -6, 4, 0, -5, 4, 1, -1, -1, 3, 6, 5, -2, -5, 0, -2, 5,
- -4, -2, -4, -2, 4, 7, -7, -1, 1, -4, -3, -19, 37, 12, 10, -40 },
- { -7, 2, -7, -12, 17, 11, -7, 2, 2, 3, 1, -1, 3, 4, -2, -5,
- 9, -9, 6, 4, 9, 12, 11, -5, 2, -1, 0, 9, 5, -7, -2, -24 },
- { -7, 6, 1, 3, 1, 0, 6, 0, 4, -12, -2, -2, 1, -9, 10, -2,
- 11, -1, 21, -12, 15, -5, 10, -5, 5, -5, 14, -6, 5, -7, -3, -29 },
- { -2, 0, -5, -2, -3, 1, -3, 0, 4, 2, 3, 0, 2, -2, 7, -2,
- 3, -5, 2, -1, 6, -4, 0, -3, 8, -11, 19, -8, 22, -34, 13, -35 },
- { -1, -3, -1, 9, 11, -3, -3, -1, 7, 18, 11, -5, 2, -12, -11, 18,
- 9, -5, 1, -6, -9, 12, 1, -3, -3, -9, -14, 9, 9, 8, -6, -26 },
- { 0, 5, -5, -1, -1, -2, 4, 6, 8, 2, -1, -2, 5, 1, -5, -4,
- 1, 1, 18, 1, 7, -10, 3, -2, 12, -1, -15, 9, 12, -14, 13, -38 },
- { 3, 0, -8, -1, 0, 8, -9, -3, -8, 16, 3, 16, -5, -9, 0, -1,
- -7, -1, -4, 13, 7, 0, 1, 2, -1, -16, 0, -2, 1, 8, -8, -28 },
- { 7, 9, -5, -3, -2, 2, 0, 3, 11, -6, -4, -2, -2, -5, 28, -18,
- -6, 2, 15, -10, -15, -10, -2, 0, -2, -2, 4, -3, 7, 11, 5, -30 },
- { 9, 0, -7, -1, -4, -7, 2, 2, 9, -2, 2, 3, -8, -6, -6, 3,
- -10, 4, 10, 5, 21, -4, 14, -18, 1, 3, -10, -2, 6, 14, -8, -26 },
- { -14, -1, 2, 3, -3, 7, 1, -22, -1, -1, 0, 1, 12, -14, 3, -5,
- 0, 10, -3, 1, -5, 12, -3, 10, -8, -22, -11, -13, -7, -10, -13, -25 },
- { -2, -5, -4, -4, -9, -18, 9, -3, -5, 17, 13, 5, 6, 11, 3, 8,
- 20, 4, 2, 9, 8, 5, 6, 1, 7, -7, -6, -2, -7, 0, -17, -23 },
- { -5, -5, 2, 0, 6, 2, -2, 2, -3, 4, 4, 0, -5, -2, -4, 6,
- 8, 10, -1, 1, -5, 5, -14, -2, -11, 8, 6, 25, 7, -1, 0, -43 },
- { -4, 0, 4, -2, 7, 0, 3, 17, 5, 2, -5, 1, 21, 3, -2, -10,
- -16, -9, 7, -12, 9, -8, 2, 5, -5, -10, -2, -11, -5, -1, -9, -30 },
- { -2, 3, 1, -4, -1, 0, 8, 1, 12, 4, -1, -1, 3, -17, 13, 9,
- 0, 7, -6, -5, 9, 1, 5, 4, -10, -18, 0, 14, 11, -4, -16, -28 },
- { -1, 0, 2, -1, 4, 1, -1, 1, -1, -2, -1, -2, 3, 0, 0, -1,
- -1, 1, 2, -2, 3, 3, -2, 4, -2, -1, -6, 1, -1, -1, 6, -70 },
- { 7, 3, -11, -1, 12, -4, -14, 4, 4, -4, 4, -2, 2, -12, -4, 15,
- -17, -4, -3, 6, 8, -5, 22, -22, 5, -11, 15, -4, 4, -1, -21, -1 },
- { 10, -2, -13, 11, 4, 14, 4, 9, 8, 8, 19, 15, 14, 15, 5, 10,
- 8, 15, -5, 4, 14, -8, 1, 1, 2, 1, -1, -3, 21, 8, -29, 13 },
- { -6, 0, -6, 6, -1, 2, 8, -4, -5, 4, -4, -5, 0, -2, -4, 0,
- 9, -2, 1, -2, 26, -19, 21, -10, 4, 1, -8, 5, 22, -10, -13, 15 },
- { 11, -5, 1, 0, 6, 3, 7, -2, -2, -3, -5, -1, -2, -6, 1, 1,
- -8, -5, -13, 13, -2, -3, -1, -9, -28, 4, 2, -11, 18, -20, -24, 9 },
- { 7, 4, -3, 6, 6, -6, -7, -5, -7, -4, -4, 0, -7, -5, -6, -5,
- 2, -13, -12, 2, 0, 5, 18, 15, -13, -7, 13, -20, 16, -10, -19, 6 },
- { 5, -8, -1, 5, 10, 2, -1, -10, -11, 23, 8, -5, -8, 4, -5, -4,
- -5, -5, -11, -8, 5, 1, 7, -9, -9, -6, 12, 14, 17, -12, -22, 3 },
- { -5, -8, -3, 3, 12, -1, 0, -4, -5, 1, 1, 6, 1, 5, -5, 7,
- -2, 7, 1, 6, 6, 2, 0, -5, 17, -4, -5, -24, 13, -20, -27, 14 },
- { -1, 2, -3, 1, -3, 1, -3, 0, -2, 3, -2, 1, 2, -1, -2, -1,
- -2, -5, 5, -2, 0, -7, 1, -6, 8, 8, 11, -5, 24, -43, -13, 2 },
- { -2, 4, 7, -3, -4, 4, 13, -4, 0, 0, -2, 9, 0, -3, -6, 1,
- -7, 1, -1, 10, 0, 5, -1, -24, 25, -15, 7, 2, 22, -10, -21, 0 },
- { -5, 2, 6, -2, 13, 3, 5, -12, -11, 16, 6, 10, -5, 0, -3, 6,
- 5, -5, -5, 10, 12, 10, 11, -7, 8, -14, 2, -15, 13, -14, -8, -3 },
- { 5, 6, -7, -5, 5, 2, 9, 5, 0, -1, -4, 2, 8, 0, 3, 5,
- -12, 3, -3, -6, 2, -1, -5, 14, 11, -20, -21, -25, 24, -1, -10, 6 },
- { -5, 5, -2, 9, 4, -4, -1, -6, 11, -6, 5, 0, 2, -3, 6, -1,
- -17, -18, -4, -13, 9, -1, 9, -7, -4, -8, 2, -3, 12, -31, -18, 5 },
- { -7, -11, 6, -8, 4, -3, -12, 0, -1, -6, -3, 0, 5, 9, 7, 2,
- 1, -8, -6, 8, 2, -5, 7, -1, 16, -10, 16, -12, 18, -1, -25, -12 },
- { 3, -12, 1, 2, -2, -18, -8, -15, -10, -9, 2, -7, 11, -11, 2, -1,
- -1, -1, -9, -6, 3, -14, -2, -1, 2, -13, -7, -9, 19, -5, -17, 2 },
- { 7, 1, -8, 7, 17, -13, -10, 5, 7, 1, -6, 4, 9, -4, 0, 3,
- 8, 1, -14, -9, 4, 7, -9, 0, 6, -5, -12, -2, 25, -2, -19, 1 },
- { 7, -3, 6, -3, 1, 6, -7, 0, 10, 0, 4, -5, -17, -4, 4, -1,
- 0, -3, -7, 19, 24, -1, 21, 8, 10, 9, 8, -1, 23, -2, -18, -2 },
- { 3, -3, 0, 5, 8, -2, -9, 2, 9, 6, 19, 8, 2, 6, -9, -2,
- -4, -3, -8, 7, -7, -8, 5, 4, 26, -6, 7, 18, 24, 0, -13, 4 },
- { 0, -13, -11, -1, 3, -9, 5, 4, -7, 3, 0, 2, -1, 4, -5, 2,
- 9, -2, -11, 15, 1, -21, 1, -1, 0, 4, -14, -4, 24, -16, -13, 1 },
- { 1, -9, -8, 0, 0, -4, 11, -1, 14, 16, 0, 17, -2, -9, -12, 0,
- -1, -14, -9, -14, 0, -2, 19, 4, 6, 4, 4, -11, 8, -17, -19, -5 },
- { -3, 1, 2, 12, -4, -18, -1, -4, -7, 14, -3, 2, 0, -7, -8, 12,
- -5, -9, 14, 12, -9, -2, 4, -6, 4, 18, -1, -25, 22, 2, -23, -5 },
- { -2, 0, 0, 0, 1, 3, 5, -1, 5, -2, -2, 2, -3, 0, 1, 2,
- 0, -1, 2, -1, -9, -6, -7, -4, -2, 4, -7, -5, 64, -3, -25, 4 },
- { 12, -2, -3, 0, 8, -9, 13, -7, 6, -3, -12, 12, 15, -9, -4, 2,
- 9, -4, -12, 3, 14, 1, 7, -15, 15, 0, -6, -12, 0, -3, -20, 6 },
- { 2, -1, -4, 5, 9, 6, -7, 2, -2, -7, -2, 0, -1, -18, -4, -6,
- -15, -5, 11, 5, -10, -1, 2, 7, 12, -19, -7, 8, 21, -4, -15, 4 },
- { 4, 2, 5, 5, -5, 1, 3, 2, -8, 13, 0, -5, -2, -14, -11, 6,
- 2, 17, 8, -13, 26, -2, 5, -15, -4, -14, 12, -9, 13, -21, -23, -4 },
- { 2, -3, -2, -3, 3, -2, 6, 9, -9, 13, 4, 2, 12, -3, -3, 1,
- -17, -22, -3, 4, 3, -2, 1, -9, 1, -6, 11, -13, 14, 0, -15, 6 },
- { -16, -4, 17, -2, -20, -11, 11, 10, 5, -8, 16, 2, -17, -14, 11, 11,
- -6, -11, -7, 12, 12, -10, -6, 5, 8, -4, -2, -5, 28, 3, -13, 4 },
- { 0, -3, 3, -7, 6, 8, -12, 20, -19, 18, -11, 10, -5, 0, -9, 11,
- 3, 0, -2, 9, -7, -5, 18, 3, -2, -16, 1, 6, 12, -7, -16, 1 },
- { 4, 1, 5, -5, 15, 2, -8, 3, 5, -11, 15, -3, 8, -8, -1, 7,
- 4, 7, -2, 6, -9, 5, 12, 2, 33, -2, -6, -18, 4, 0, -18, 11 },
- { 3, -1, 1, -1, 0, 1, 4, -1, -5, 0, 1, 0, 4, 2, -1, 4,
- -3, 2, 0, -2, 4, 6, -1, 6, 42, 19, -4, -37, 19, 1, -15, -4 },
- { 2, 0, -5, 0, 10, 0, 0, -5, 3, 0, 0, -3, -3, 0, 2, -4,
- -10, 2, -6, 4, 4, 1, 27, -7, 17, -34, 5, -9, 15, -16, -7, -5 },
- { -2, 7, 7, -2, 9, -2, -15, 11, 11, 7, 5, 1, 15, 1, -9, 31,
- 2, -15, 2, 4, 3, 4, -1, -8, 2, -7, 6, -17, 11, -14, -11, 2 },
- { 1, 1, -11, 9, 9, -6, -14, -11, -10, 8, -3, 11, 16, -9, -8, -13,
- -8, 9, 0, 6, 6, -2, 13, -8, -2, 3, 13, -3, 10, -6, -17, 4 },
- { 14, 5, 4, -6, -12, 10, -7, 8, 21, -8, -30, 15, -2, 1, 11, -9,
- -5, 1, 0, -1, -1, -6, -2, 3, -5, 7, 9, 5, -5, 2, 0, 1 },
- { -1, 2, 20, -17, -15, 3, 3, 7, 11, -17, -13, -6, -3, 18, 17, -15,
- -4, -4, -5, 22, 14, -14, -2, -10, -7, 11, 8, -7, -3, 0, -7, 11 },
- { 7, -11, -7, -8, -14, 22, 5, 2, 6, 13, -12, -2, 10, 3, 0, -21,
- -4, 20, 3, 10, 21, -10, -12, 8, 11, 2, -5, 2, 1, 3, -1, 15 },
- { -1, -2, -1, -2, -13, 8, -4, 0, 7, -2, -17, 8, 18, 5, 3, 8,
- -8, -2, 3, -4, 14, -18, -13, 14, 15, -13, -1, -2, 4, 11, 1, 12 },
- { 13, -6, -4, -16, -17, 16, 21, -2, 5, -11, -9, 19, 21, -17, -3, -17,
- 3, 12, 8, -12, -6, 1, -7, 9, 9, -7, -5, -1, -3, 5, -6, -4 },
- { 11, 5, 12, -20, -6, 10, 4, 12, 8, -5, -10, 15, 13, 14, 10, -15,
- -13, 1, 6, 14, 15, -17, -13, 4, -5, 10, 7, -6, -8, -3, -4, 12 },
- { 25, -1, 7, -5, -7, 11, 1, 17, 13, -15, -14, -4, 5, 3, 8, -3,
- -2, 2, 0, 6, 16, -12, -6, -4, 4, -3, 7, -10, -3, -7, -13, 7 },
- { -8, 10, -3, -13, 5, 2, 4, 9, 9, -17, -13, 2, 11, 1, 6, -4,
- 8, -10, 4, 1, 19, -15, -4, 12, 31, 7, -5, -17, -4, 9, -2, 7 },
- { 14, -6, -6, -6, -14, 13, 17, -5, 4, -14, -9, 7, 7, -9, 3, -16,
- -15, 11, 11, 6, 4, -11, -19, 3, 5, 8, 13, -14, -14, 3, -4, 12 },
- { -2, -4, 10, -4, -7, -1, 27, 5, 2, -16, -18, 4, 12, -2, -3, -2,
- -1, 1, -8, -12, 3, -4, 8, 15, 2, 4, 9, -13, -14, 9, -7, 5 },
- { 4, 2, -10, -5, -7, 2, 1, 4, -1, -6, -15, 6, 1, 10, 5, -10,
- -9, -1, 13, -3, 5, -21, -11, 8, 8, 5, 27, -21, -18, -5, -1, 15 },
- { 11, 1, -16, -8, -11, 0, 5, -8, -12, -13, -17, 22, 4, -6, -1, -18,
- -10, 0, 19, 2, -2, -8, -7, -3, 2, -2, -9, -17, -5, 4, 4, 10 },
- { 8, -6, -19, -5, -4, 12, 14, 15, 10, -9, -1, -9, 19, 12, 0, -1,
- 2, 4, 7, 9, 16, -16, -14, 9, -4, 3, 1, 0, -2, 10, -1, -1 },
- { 12, -8, 12, -9, 0, 25, 7, 9, 2, -31, -9, -4, 15, 4, -5, 1,
- -10, 11, 8, 10, 0, -6, 5, 11, -1, -6, 4, -10, -9, 6, 4, 5 },
- { 14, 6, -17, -2, 17, 12, -9, 2, 0, -25, -14, 5, 20, 14, 8, -20,
- 5, 2, -2, -3, 9, -13, -3, -1, -6, 3, 7, -6, 0, 2, 3, 1 },
- { 8, 4, -15, -3, 10, 18, -4, 13, 8, -22, -10, 9, 19, -15, 7, -5,
- -13, 12, -4, 9, 2, -9, -6, 0, 2, 1, -9, -6, 6, 1, -1, 11 },
- { 4, 1, 4, -5, -10, 18, 7, 2, -4, -9, -11, 0, 32, -7, 4, -16,
- -1, 0, 6, 3, 6, -3, -14, 16, 9, -2, 7, -1, 0, -5, 5, -3 },
- { -3, 2, 3, -8, -6, 4, 6, 2, 4, -12, -15, 2, 8, 8, 9, -3,
- -18, 6, 34, 11, 12, -15, -1, 2, 9, 2, -4, -4, 2, 4, 2, -3 },
- { 18, -6, -12, -8, -1, 15, 20, -4, -1, -11, -5, 6, 6, -11, -15, -7,
- 3, 7, 10, 2, 8, -10, -5, 8, 15, -5, 5, -17, -13, 13, 11, 7 },
- { 8, -4, -6, -1, -14, -3, 6, -2, 1, -5, -1, 10, 10, -15, 5, 0,
- -10, -4, -3, 7, -4, -19, -15, 27, 11, 18, 3, -19, -2, 6, 0, 12 },
- { 12, 0, -5, 0, 4, -5, 1, 5, 10, -7, -11, 21, 29, 1, -2, 1,
- -4, -11, -1, 13, 11, -20, -1, 4, 4, 4, -5, 6, -13, -2, 11, 9 },
- { 2, -7, -7, -3, -10, -1, 20, 12, 1, -19, -19, -1, 5, 4, -7, -25,
- 14, 1, -3, 2, 12, -4, -3, -3, -2, 6, 1, 0, 3, 2, 5, -1 },
- { 12, -8, 3, -12, -10, 10, 13, 0, 23, -14, -18, 10, 0, 15, 3, -12,
- -3, -5, 5, -4, 2, -14, -10, 8, 2, 9, -1, -11, -3, 5, 13, 2 },
- { 9, -6, 7, -7, -30, 17, 6, 13, 1, -14, 0, -1, 6, -9, 8, 3,
- -4, 0, -1, -7, -5, -13, -19, -3, -4, 4, -6, -2, -13, 1, -2, 3 },
- { 10, 1, 3, -18, -26, 17, 4, -16, 4, -3, -13, -4, -6, -11, -4, -21,
- 7, 8, 2, 5, 13, -6, 1, 5, 8, 7, 9, -6, -6, 1, -1, 2 },
- { -3, -1, 0, -2, -2, 0, -1, 3, 4, -14, -8, -9, 13, 2, 50, -23,
- -8, 8, 7, 11, 16, 3, -7, 0, -2, 6, 5, -1, 1, -2, 4, 3 },
- { 1, 3, 1, 1, -6, 3, 6, 6, 2, -2, -3, 10, 2, -8, -5, -5,
- 5, 4, 4, -2, 10, -8, -40, -1, 21, 8, 3, -4, -1, 13, 4, 7 },
- { 2, 0, -4, -8, 5, 2, 7, -5, 5, -8, -4, -1, 12, 2, 12, -13,
- -9, 0, 1, -12, 9, -43, 1, -5, 12, 1, 3, 6, 1, -1, 3, -2 },
- { 6, -2, -1, 1, 0, 4, 8, 14, 4, -7, -23, -5, 23, -17, -6, -15,
- -8, 7, 10, -1, 7, -16, 4, -6, 2, 3, -3, -3, -1, 8, -1, 4 },
- { 10, 4, -4, 1, 7, -3, 2, 11, 4, -6, -3, 8, 5, 4, 1, -45,
- -6, -4, 4, 2, 1, -14, -10, 1, 1, 6, 2, -8, -1, -3, 3, 3 },
- { 1, -1, 2, -3, -8, 9, 3, 3, -2, -5, -8, 8, 7, -7, -4, -6,
- 5, -9, 11, -2, 46, -5, -1, 9, -2, 0, 3, -5, -3, -5, 7, 0 },
- { -4, 1, -2, -1, -11, 11, 8, -3, -2, -10, 0, 4, 9, 9, -17, -17,
- -34, -4, -5, -7, -3, -12, -3, 11, 18, 3, -2, -5, -18, -5, -3, 6 },
- { 7, -5, -3, 1, -4, -3, -5, -1, 2, 5, -2, 3, -10, 12, -18, -5,
- -10, 12, -9, 4, -6, 2, 0, 16, -17, 15, 14, -12, -10, -2, -9, -1 },
- { 4, -5, -3, -5, -3, -1, 7, 18, -7, 12, 3, 5, -8, -4, -20, 1,
- -25, 1, -8, 13, -10, 8, -19, -1, -8, 10, 6, -9, -1, 0, 12, 4 },
- { -4, 5, 0, -1, 2, 5, -8, -2, -6, 4, -8, 9, 3, 2, -7, 4,
- -25, 13, -23, 10, 14, 15, -11, 3, -18, 4, 16, -4, 1, -10, -10, 3 },
- { 5, -3, -1, -3, 4, 1, -3, -4, -5, 1, -12, 14, -7, 11, -15, 6,
- -6, 24, -4, 13, -1, 15, -13, 8, 3, 7, -5, 2, 2, 0, 3, -7 },
- { -3, 1, 0, 8, 6, -1, 6, 5, -5, -2, -12, 4, 0, -2, -3, 5,
- -6, 0, -8, 9, -10, 4, -28, 12, -20, 11, -13, 7, -18, 1, -11, 1 },
- { 1, -4, -15, 5, 0, -13, -5, 13, -11, 4, -4, -5, 5, -14, -16, 0,
- -14, 5, -20, 12, 10, -7, -5, 6, 6, 22, 6, -4, -2, 3, 8, 11 },
- { 13, -11, -2, 16, 16, -7, 0, 20, -7, -1, 0, 5, -9, 12, -2, -5,
- -22, 5, -10, 12, -6, 11, 9, 21, -8, 15, 4, 0, -8, -4, -4, 10 },
- { 18, -4, -13, 0, 1, -15, -1, -3, 2, 10, -1, 6, 1, -4, -20, -5,
- -8, 6, -8, 17, -5, 5, -10, 8, -22, 6, -5, -2, 8, -17, 8, 2 },
- { 1, -2, -9, 6, -31, -8, -8, 8, 0, 5, -9, -4, 2, 3, -12, 11,
- -18, 10, -5, 3, -11, 13, -6, 11, -3, 12, -7, 3, -9, -1, 2, 11 },
- { -9, -6, 21, -8, -15, 4, -11, 12, -11, 17, -1, 2, -6, 0, -15, 13,
- -12, 19, 0, 2, -6, -3, -9, 10, 3, 17, -2, 5, -10, -3, 0, 1 },
- { 4, -6, 5, -10, 1, -5, 1, 0, 0, 0, 2, 7, -2, 2, -2, 0,
- -4, 3, -4, 1, -12, 6, -49, 16, -10, 13, 0, -2, 8, 6, 1, 8 },
- { 5, -8, -7, 9, 13, -5, 7, 0, 10, 11, -4, -3, -1, 13, -14, 6,
- -15, -6, -14, 16, 15, 1, -18, -4, -20, 20, -7, -1, -9, -2, -10, 10 },
- { -12, 4, 0, 10, 0, 3, 8, 4, -27, -1, -2, 19, -4, 2, -13, 3,
- 1, 9, -12, 1, -22, 19, -5, 4, -9, 12, 2, -9, -8, 11, -3, 7 },
- { 4, -5, 11, -6, 17, -17, 5, -4, -2, -6, 1, -5, 2, 4, -14, 6,
- -20, 19, -20, 12, -21, 5, -14, 13, -2, 11, 4, -3, 0, -10, -4, -2 },
- { -2, -1, -3, 8, -9, -7, -22, -3, -24, 13, -2, 10, -15, 5, -9, 4,
- -7, 0, -5, 15, -8, 11, -13, 6, -4, 19, -8, 12, -4, 6, 9, 7 },
- { 2, -3, 2, -1, 0, 3, 1, 2, 1, -4, -2, -3, 1, 5, -12, 6,
- -16, 14, -23, 10, -14, 17, -15, 16, -2, 9, -25, 9, -10, 16, 4, 9 },
- { -3, 7, -8, -3, 2, 2, -4, -8, -9, 10, 3, -11, 25, -10, -28, 27,
- -9, 7, -13, 9, -2, 4, -12, -8, -14, 6, 7, -10, 3, 3, -3, 5 },
- { -8, -3, 1, -10, 8, -3, -9, -4, 13, 7, 2, 4, -10, 4, 3, 7,
- -18, 2, -22, 15, 4, 20, -7, 5, -6, 13, -1, 4, -7, -6, 6, 13 },
- { -2, 3, 0, 2, -4, -2, 0, 0, 1, 2, -2, -5, 0, 1, -4, 0,
- -2, -3, 1, 2, -1, 2, -8, -1, -24, 68, -3, 8, 3, 3, -1, -1 },
- { -15, -2, -9, -7, -1, 8, -14, 8, 3, 6, 0, -1, -8, 8, -23, 2,
- -14, 17, -15, 8, -4, 7, -18, 0, -8, -3, -1, -4, -10, 4, -1, 4 },
- { 8, 0, 2, -7, 0, 5, 1, 3, -11, 4, -8, 14, 3, 20, 1, 26,
- -11, 13, -13, 20, -2, 0, -8, 2, -6, 6, -1, 9, 3, -6, -3, 10 },
- { 5, 0, -1, -7, 10, 1, -3, 5, 4, 7, -5, -1, -3, -1, 12, -3,
- -15, 7, -9, 22, -19, 8, -9, 4, -23, 13, -14, 6, -6, -14, -4, 7 },
- { 14, -5, -8, -10, 25, 3, -23, -7, -28, 0, -1, -9, 4, 1, -13, 20,
- -8, 10, -16, 8, 12, -13, -21, 5, -13, 11, -2, 1, 12, -7, 2, -10 },
- { -5, -4, 9, 5, -6, 35, -7, 8, 15, 2, -1, -9, -6, 2, -18, 7,
- -15, 6, -3, 2, 8, 12, -30, 7, -4, 20, 2, 6, 13, -6, -4, 0 },
- { 1, 8, -9, 9, -5, 12, -9, 16, -9, 16, -17, 14, -13, 15, -18, 14,
- -15, 17, -12, 14, -13, 7, -16, 13, -9, 5, -11, 10, -9, 6, -12, 13 },
- { -10, -4, 5, 3, 1, 6, 8, -14, -5, 15, 7, 4, 8, 7, -22, 8,
- -7, -8, -15, 26, 1, 13, -3, 17, -5, 9, -2, 4, -6, 3, -8, 9 },
- { 8, -3, 2, 3, 3, 1, -2, -1, -11, 8, -4, 0, -6, -5, -1, 13,
- -37, 9, 1, -6, -10, -2, -10, 11, 8, 13, -3, -2, -6, 8, -4, 13 },
- { 3, 2, -3, -4, -4, 7, -8, 9, -8, 9, -20, 12, -19, 15, -18, 17,
- -15, 7, -1, 20, -11, 6, -6, 3, 1, 9, 2, -14, -2, -2, 2, 1 },
- { -7, 1, -1, -3, -6, 4, 4, -3, 3, -1, 5, -4, 3, 2, -1, 9,
- -59, 5, -4, 30, 3, 3, -2, -3, -1, 2, 2, 1, -1, -1, -2, 1 },
- { 0, -3, 2, 0, -1, -8, 0, 2, -3, 4, -4, 1, 10, 6, -6, 8,
- -7, 4, 10, 11, -41, 27, -20, 3, -3, 8, 1, 11, -5, -8, 0, 4 },
- { 5, 1, 4, -2, 1, 2, -1, 6, -7, 2, 11, 4, 0, 0, -8, 7,
- -10, 0, 0, 8, 2, 10, -1, 1, -2, 44, -2, -21, -12, -3, -1, 2 },
- { -4, 4, -2, -2, 6, -8, 2, 1, -10, 14, 8, 6, 5, 1, -2, 4,
- -13, 4, 2, 5, 10, -2, -21, 32, -3, 18, 9, -6, -9, -9, 10, 2 },
- { 9, -16, -6, -2, 1, 4, 22, 2, -2, 1, -3, -2, -9, 3, 16, 19,
- -24, -6, -6, -5, -8, -7, 8, -7, -1, -12, 5, -3, 0, 4, 2, -3 },
- { 10, 3, -16, -4, -1, 13, 4, 4, 1, -3, 1, -6, -14, 18, 3, 8,
- -8, -28, -16, 4, 4, 2, 12, 7, 9, -4, -4, 5, -1, -1, 2, 2 },
- { -5, -13, -22, -3, -8, 21, -2, -9, 21, -4, -9, 5, -8, 15, 5, 1,
- -5, -9, -7, -2, -5, -5, -1, -5, -5, -5, 3, 10, -4, 0, -7, -2 },
- { 5, -10, -18, 2, 20, 4, 13, -10, 8, -15, -11, -3, -1, 16, 10, 9,
- -8, 6, 7, -5, 6, 11, 5, 17, -4, 7, -11, 5, -3, -6, 2, 1 },
- { 3, -5, -19, 1, 1, -3, -2, -25, -11, -17, 0, -13, -4, 10, 10, 2,
- -5, 4, 0, 3, -3, -5, -10, -2, 13, -22, 0, 3, -11, -5, 7, -1 },
- { 12, -14, -29, 6, -1, 10, 7, -17, -12, 14, 3, 9, -9, 9, 7, 6,
- -3, -13, 0, 5, 3, -1, -6, -1, 0, 2, 4, -12, -5, -1, 2, 11 },
- { 12, -15, -7, -2, -12, 17, 20, -16, -2, -12, -6, 15, -6, 12, 11, 9,
- 7, -6, 7, -4, -19, 6, 2, 2, 3, -11, -10, -4, -5, -3, 3, 2 },
- { 11, -22, -6, 0, 8, 18, 3, -11, -4, -7, -15, -17, -12, 6, 16, 4,
- -9, 4, -5, 3, 6, -16, 10, -7, -7, -3, 5, 0, 1, -15, -4, 5 },
- { 12, -22, -16, 5, -6, 8, 12, -4, -9, -17, -11, 3, 5, 8, -17, 0,
- 11, -4, -13, -6, 2, -1, -1, 3, 3, -11, -12, -1, 1, 1, 12, -2 },
- { 8, -10, -33, -5, -3, -6, 1, -7, -8, -4, -6, -1, 5, -4, -6, -12,
- -16, -8, 11, 8, -14, 7, 12, 11, 4, -14, -3, 6, -7, -5, -3, 3 },
- { 0, -8, -7, 2, -4, 24, 2, -9, -11, -3, -7, 11, -12, 17, 1, -1,
- 3, -5, -7, 12, 4, 11, 0, 3, 2, -18, -3, 4, 7, -6, 3, 15 },
- { 10, -15, -16, -2, -4, -9, 7, -15, -6, 2, -16, 13, -8, 7, 19, -21,
- -4, -12, -9, -3, -3, 6, 11, -3, -1, -19, 3, -7, -9, -4, 3, -6 },
- { -5, -10, -21, 0, -3, -7, 18, -21, 15, -5, -12, -4, -13, 2, 6, -9,
- -9, -11, -4, 13, -3, 6, 4, -1, 7, -9, -4, 9, 5, 2, 6, 3 },
- { 15, -1, -27, -2, 10, 3, 7, -8, 9, -2, 7, 1, -2, -5, 18, 9,
- -11, -17, -2, 7, -9, 11, 10, 0, -8, 6, -16, -3, 2, -7, 3, 11 },
- { 4, -9, -39, 19, 6, -13, 13, -5, -5, -15, -2, 9, 0, 4, 14, 6,
- -10, -4, -5, 2, -4, -2, 5, -11, 3, 3, -2, -2, -7, 9, 7, -10 },
- { 5, -11, -8, 10, -2, 12, 16, 0, 12, -2, -6, 8, 14, 8, 7, 1,
- 18, -30, 4, 10, -4, -6, 2, -11, 9, -10, -8, 5, 0, 0, -7, 6 },
- { -1, -16, -10, 11, 0, 13, 12, -4, -4, -5, -21, 12, 4, 13, 14, -7,
- 6, -16, -13, 8, 2, 9, 15, -12, 1, -9, -22, 10, -9, 9, 9, -7 },
- { 4, -12, -27, 1, -2, 11, 15, 3, 14, -14, -9, 0, -9, 16, 22, 10,
- 16, -10, 5, -5, -9, 1, 1, 6, 6, -4, 2, -17, -5, -6, -15, -1 },
- { 7, -12, -17, 1, -9, 5, 20, -7, 3, 23, -8, -8, -8, -1, 13, 17,
- -7, -13, 4, -4, 7, 14, 8, 11, -3, -3, 4, 0, 4, 6, -1, -9 },
- { 7, -15, -15, -4, 10, 12, 3, -13, 6, 14, 9, -8, -15, 14, 23, -5,
- -10, -5, 1, 15, -10, -7, 1, 9, 4, -13, -10, 10, 7, -3, 2, 3 },
- { 4, -10, -14, 0, 3, 4, 0, -9, -3, -4, -11, 2, -17, 8, 2, 15,
- 6, -12, -12, 15, -5, 17, 18, 3, -3, -3, -4, -6, -8, 13, 4, 10 },
- { -2, -18, -26, 10, -4, 10, 13, 4, -4, -16, -7, -17, -3, 5, -4, 2,
- -15, -10, -1, -8, -7, -3, 2, 2, 8, -10, -7, 2, 2, -4, 4, -1 },
- { 4, -19, -5, -1, -1, -6, 2, -8, 10, -16, -28, -6, 8, -1, 11, 28,
- 2, -10, -4, 6, -6, 6, 11, 15, -4, -2, 7, 3, 7, -7, 4, 1 },
- { -3, -6, -10, -5, 13, 18, 10, -15, -5, -3, -13, 5, 1, 2, 18, -5,
- -10, -10, -7, 4, 2, 1, 5, 4, 2, 5, 4, 8, -9, -17, 7, 7 },
- { 20, -12, -2, -4, 5, 14, 7, -11, -1, -16, -6, -4, -11, 17, 14, 0,
- -8, -10, -8, 10, 3, 5, 10, -16, 3, -8, -14, 10, 3, 9, 0, 3 },
- { 12, -10, -36, 0, 7, 15, 2, -16, 2, -1, 0, -1, 5, 4, 5, -3,
- 1, -10, 5, -1, -15, -3, -12, 12, 2, 5, -1, 5, 6, -3, -2, 2 },
- { 17, -15, -31, 23, -4, 15, -2, -3, 6, -7, -5, 1, -12, 4, 6, 8,
- -10, 8, 3, 5, -4, 1, 5, 3, -1, -4, -3, 1, 10, -4, -2, -2 },
- { 6, -18, -5, 12, 10, 12, 14, -11, 15, 2, -9, -6, -5, -2, -9, 4,
- -5, -28, -4, 14, 0, -16, 9, 14, -1, 3, -4, -4, 2, 1, 0, 4 },
- { -5, -14, -31, 8, 16, 7, 13, -13, 5, 6, -16, 10, -5, 2, -2, 2,
- 14, -5, 8, -5, 7, -16, 6, -13, -5, 0, -5, 8, -3, -1, 4, 3 },
- { 1, -2, -1, 0, 6, 5, 2, -4, -3, -1, 0, 1, 4, 2, 43, 28,
- -12, -35, -2, -2, -7, -1, 0, 2, -1, -2, -2, 1, -4, 0, -2, 3 },
- { 2, -9, -22, 12, 3, 3, -7, -4, -19, -22, -14, -4, -1, 21, 9, -3,
- -15, -16, -13, 1, -11, 4, -9, 1, -7, -1, -1, 0, -2, 9, -13, -3 },
- { -1, -3, -23, 0, 2, 12, 3, -9, -4, 7, 3, 9, -10, 1, 27, 28,
- 0, 9, -15, -2, -2, 1, 6, 8, -8, 7, -3, 20, 0, 0, -1, -6 },
- { -1, 11, 8, -2, 1, 5, -6, -1, 4, 2, -4, 0, -1, -5, 4, -6,
- -10, -12, 19, 1, -7, 9, -8, -9, -16, -11, -2, 12, 14, 4, 4, 34 },
- { 17, 7, -6, 1, 4, -10, -5, 4, -11, 3, -18, 4, 14, -13, -3, 1,
- 0, 0, -11, 0, 7, -17, -4, 4, -11, -6, -8, 18, 0, 0, 0, 26 },
- { -6, -7, -1, -1, 11, -8, 1, 3, 2, 11, -6, -6, 10, -3, 1, -3,
- 7, 4, -12, -8, 0, -9, 8, -22, -5, 0, -6, 22, -2, 11, -13, 24 },
- { -3, 4, 0, 3, 9, 10, -1, 3, -9, -12, 1, -5, 18, 0, -3, 8,
- 25, 15, -8, 2, 2, -2, 4, 8, 9, -1, -5, 10, -3, 1, -1, 23 },
- { -5, 2, -9, -1, -3, 0, 3, -1, -10, -4, 0, -13, 16, 9, -1, -14,
- 2, 6, -2, -6, -5, -2, -7, 7, 5, 3, 11, -2, -14, 0, -9, 30 },
- { 4, 6, 6, 5, -3, -1, 4, 5, 10, 0, 5, -4, 7, -11, 14, 14,
- 7, 34, -9, 0, -10, 22, -7, -1, 7, -9, 2, -8, 0, -7, -5, 29 },
- { -4, 3, -1, -4, -3, 5, 1, -4, 0, 2, 4, 2, 1, -1, -10, 1,
- 6, -6, -4, 1, 4, -3, -3, -5, 0, 3, 7, -12, 0, -2, -10, 55 },
- { 5, 9, -1, 0, 4, 9, -21, -9, 4, 2, 6, -7, 11, -7, 1, -5,
- 0, -4, 2, -3, -13, -8, 0, -9, -4, 2, 16, -2, -15, -7, -11, 31 },
- { 8, 2, -1, 0, 3, -5, -5, 5, 1, -1, -9, 1, 0, -6, -2, -1,
- 5, 2, 0, 0, 12, 20, -19, 1, 8, -12, -11, 0, 6, -5, 2, 31 },
- { -1, -1, -2, 1, -1, 3, -9, -5, 8, -2, 5, -1, 0, -2, 4, -2,
- -3, -12, 0, -2, 3, 0, 9, 4, -1, 21, -8, 3, -4, 9, -6, 30 },
- { -4, 0, -7, 17, 10, -12, -2, -10, -12, -3, 10, 0, 11, -4, -13, -3,
- 5, 6, 10, 7, -8, 0, -7, -13, 1, 0, -2, 7, -12, 4, -3, 24 },
- { -13, 9, 4, -2, 2, -4, -14, -1, -3, -5, -10, 4, 13, -2, 5, 13,
- 8, 3, -2, 1, 5, -6, 7, -18, -10, 1, -1, 5, 4, 1, 0, 25 },
- { -5, -1, 18, 12, 8, 8, -16, -1, 1, 1, 1, -4, -5, 3, 3, 4,
- 4, -11, -12, -16, -6, 2, 12, -13, 0, 9, 7, 9, -9, 0, -10, 24 },
- { -4, 1, -3, 0, 2, -4, 4, 1, 5, 0, -3, 2, -3, -2, 2, -1,
- 1, 4, -1, -2, -2, 1, -1, -1, -4, -1, -4, -2, -6, 6, 12, 69 },
- { 8, 5, 11, 0, -15, -4, 13, 6, 0, -4, 9, 1, -5, -3, 15, 0,
- 1, 6, -5, 0, 1, 6, 5, 8, 0, 7, 1, -1, -4, -11, -9, 41 },
- { -4, -9, 32, -6, 0, 7, -4, 6, -6, 1, -6, -2, 4, -8, -5, -3,
- -16, -1, -2, -6, 1, 15, 0, 21, 3, -3, -4, 3, -12, 16, 2, 27 },
- { -6, -5, 1, -9, -5, 3, 7, -3, 5, 5, 14, 13, 20, -7, -1, 12,
- -1, 10, -11, -11, -7, -4, -14, 7, -14, 13, 22, 18, -1, 0, 14, 28 },
- { -8, 3, -2, 0, 5, 6, -1, -4, 1, 3, -7, 3, 1, -15, 4, -9,
- 22, -10, -9, -4, 1, 8, -4, 9, -15, 2, -6, -4, -16, 12, -10, 23 },
- { 0, 0, 2, 0, -1, 3, -3, -1, 3, -5, 7, 1, 5, -5, -8, 1,
- 13, -15, -5, -7, 12, -6, -2, 3, 10, -5, -8, 17, -5, -11, -14, 23 },
- { -7, -4, 6, -4, 5, -6, -5, 2, -4, 11, 9, -4, 2, -2, -4, 6,
- 15, 3, -3, 18, -15, -2, -6, 3, 3, -20, 17, 11, -4, 2, 3, 29 },
- { 6, 1, -6, 2, 3, 0, 0, -3, 3, 3, -1, 3, -4, -6, -6, -7,
- -3, -2, -7, -2, -4, 5, 3, -5, -20, -13, -4, 10, -14, -29, 14, 37 },
- { 3, 4, 3, -6, -4, 5, 0, 3, 2, 3, 0, -2, 4, 0, -3, -5,
- -4, 4, -4, 4, 4, 3, 1, -4, -4, -9, -14, 20, -30, 3, -18, 33 },
- { 0, 2, 5, -2, -4, -2, -1, 2, -6, -3, -2, -2, 2, -5, -1, 4,
- 3, 2, -3, 0, -1, -1, -10, -7, 2, -4, -18, 2, -37, -1, 12, 40 },
- { -7, 2, -1, 0, -2, 4, -8, 1, -4, 12, 7, 4, 15, -7, 1, -9,
- 18, 0, 12, -17, -3, -1, 0, 0, 0, 2, -6, 0, -4, -3, -1, 26 },
- { -6, 4, 8, -5, -6, -2, 2, -1, 1, -1, -15, 8, 7, -1, -17, -4,
- 1, 5, 6, -11, -6, 14, 17, -5, -15, 11, 8, 0, -3, -15, -6, 28 },
- { -1, 0, 0, 0, 1, 0, -1, 0, 1, 3, 2, -2, 3, -1, -1, 2,
- 2, -1, -1, -7, 1, 2, -9, 0, -1, -4, -18, 7, -10, 49, -13, 32 },
- { -1, -3, 4, 1, 2, -5, 1, -7, -1, 5, -9, 4, 4, 25, 1, -1,
- 2, -5, 2, -7, 17, -2, 10, -5, 0, 2, -15, 3, -9, 7, -9, 30 },
- { -5, -1, 0, 2, 1, -1, 2, 5, -33, 3, -5, 14, 11, 7, 5, -3,
- 2, -8, -4, -2, -7, -6, 4, -8, -1, -8, 2, -2, -8, -1, -4, 27 },
- { -1, 0, -1, -2, 1, -1, -2, -1, 2, 0, 1, 2, 2, 4, 1, 3,
- 4, 2, 1, -7, -4, 1, -3, -4, -35, -25, 17, 10, -3, -26, -7, 32 },
- { -5, 1, 6, -2, 6, 6, -9, 3, -1, -4, 5, -4, -2, -2, -9, 2,
- -5, 2, 2, 4, 3, 5, -5, -16, -31, -12, -11, 2, -19, 20, -2, 21 },
- { -5, 2, 7, -7, -7, 5, -7, 2, 0, 0, -4, 3, -1, 0, -1, -2,
- 0, -3, 5, -11, -8, -3, -7, -7, 28, -11, -7, 0, -16, -11, -4, 29 },
- { 2, 1, -3, -2, -1, 3, 4, 0, 1, 0, -1, -5, 4, -5, -12, 2,
- -2, -5, -22, -2, -1, 11, 8, -7, -12, 0, -34, 6, -5, 11, -8, 19 },
- { -1, -3, 5, 11, 18, -2, -2, -5, -2, 4, -1, 8, 5, -6, 1, -1,
- 2, 8, 4, -5, -8, -2, 5, -18, 7, 12, 7, 19, -18, 2, -6, -13 },
- { 9, 0, 0, 5, 4, 3, -6, 4, 1, -4, 5, -1, -4, 8, 8, 6,
- -8, -6, 0, 6, -3, 3, 5, -3, 17, 31, 16, 10, -13, 0, -9, -19 },
- { 12, -10, 2, -2, -2, -1, -3, 6, -12, -5, -2, 14, -16, 4, 12, 12,
- 17, 4, 7, -16, 7, -6, 11, 7, 7, 2, -25, 23, -24, 5, -7, -9 },
- { 10, 4, 13, 10, 10, 3, -6, 3, 3, 2, -1, -6, 8, 4, 10, 0,
- 1, 2, -4, 2, -3, -8, 0, -1, 9, 9, -10, -3, -29, 1, -1, -27 },
- { 2, 2, 0, 7, 9, -2, -10, -1, -1, 1, -9, -5, 8, 4, 1, 2,
- -10, 1, 13, 12, -3, 15, -9, 2, -7, 1, -10, 23, -20, -18, -9, -15 },
- { -3, -5, -1, 8, 0, -5, -1, 4, 7, -1, -7, 2, -8, -5, 11, 7,
- -6, 3, -3, -9, 7, 9, -22, 1, 6, -4, 14, 27, -25, -14, 3, -5 },
- { 1, 3, 8, 4, 7, 6, 12, -17, -15, 1, -8, -10, 7, -14, -8, 6,
- -2, -2, -11, -11, -7, 13, -2, -2, 4, 5, -5, 13, -23, -6, -17, -8 },
- { -5, 4, -14, -5, -4, -5, 6, 5, -8, -5, -2, -11, -7, -12, 3, -11,
- 2, -6, 4, -10, -5, -7, 14, 5, 23, 11, 7, 12, -16, -6, -4, -16 },
- { 5, 6, 2, 5, -2, -5, -5, -6, -5, -19, -13, -1, -3, -13, 5, 0,
- 6, -2, -2, -6, -7, -7, -1, -9, 4, 14, 17, -12, -27, 3, 0, -1 },
- { 7, -1, 9, -10, 8, 2, -7, -2, 5, 2, -3, -7, 3, 0, 6, 4,
- 12, 5, 11, 14, -13, -1, 8, 1, 13, 9, 12, 12, -18, -14, -11, -16 },
- { -7, -5, -6, -5, 0, -1, -3, 2, 2, 1, 4, 9, 2, 3, 5, -2,
- 2, 1, 8, 0, 3, 0, -2, 2, 1, 7, 29, 0, -36, -5, -9, -21 },
- { 14, -6, -9, 0, -1, -8, -8, -11, 2, 2, -9, -12, 12, -4, 5, 3,
- -5, -9, 11, -1, -3, 12, -21, -3, 12, 5, 3, 11, -18, -15, 1, -2 },
- { -1, 3, -9, -3, 7, -7, -18, 2, 4, 12, -10, 2, 8, -3, -14, 13,
- 17, -5, 5, -9, 13, -3, -7, -18, 17, -2, 5, 7, -20, -3, -6, -11 },
- { -3, 3, 3, -1, 1, -6, -5, 1, 5, -3, -14, -6, -5, -8, 14, -6,
- 7, -1, 5, 1, 15, -1, -7, -4, 6, -11, 9, -2, -37, 16, -7, -3 },
- { -1, 0, 6, 1, -3, -9, 0, 11, -8, 2, -2, 0, 5, 2, 12, -10,
- 10, 13, 2, 7, -6, 2, -10, -10, 21, -5, 5, 5, -12, -23, 3, -14 },
- { 6, 0, -2, 1, 0, 1, 0, -4, 1, 1, 8, -2, 2, -5, -2, 1,
- 8, -4, -1, -1, 4, -1, 2, 6, 32, 1, -5, -20, -40, -4, -18, -14 },
- { 2, 2, -7, -2, 4, 4, -1, 2, 0, -2, -4, -7, 3, 5, 0, -5,
- 1, 2, -6, 4, -1, -2, -1, -15, 8, 3, 9, 46, -7, -18, 6, -11 },
- { 5, 5, 16, 21, 3, -11, -4, 11, -12, 2, 4, -12, -1, 11, 8, 1,
- -4, 11, -11, -21, 1, 1, -11, 3, 13, 1, 5, 12, -25, 1, -3, -2 },
- { 1, 6, -7, 4, 2, 3, 1, -5, 8, 9, -15, 3, -3, -14, 17, 4,
- -8, 14, -2, -8, -4, 5, 8, -7, 8, 9, 7, 6, -29, -17, 8, 4 },
- { -7, -7, 4, 0, 13, 1, 0, 4, 4, -16, -10, -7, 5, 9, -15, -10,
- -10, 8, -4, -1, -11, -1, -10, -15, 3, 3, 14, 10, -19, 2, -18, -12 },
- { -4, 0, 2, 0, 5, -2, -9, 0, 4, -4, 2, -1, -2, 2, -4, 9,
- 2, -6, -4, -2, -1, -3, -3, -1, 2, 5, -1, 11, -24, -44, -9, -15 },
- { -1, -10, 6, 21, 11, 15, -7, 10, -14, -9, -8, -8, 4, 6, 19, 1,
- -6, 1, -5, -17, -8, -10, 9, 5, 11, 18, -1, 10, -16, -7, -9, -8 },
- { 3, -5, 0, 0, -2, -2, -6, 4, -4, 1, -1, 0, 7, -3, 4, -4,
- -7, 7, 17, -20, 6, 4, 1, -6, -12, 31, 13, 19, -14, -10, -7, -2 },
- { -2, 6, -10, 3, 9, 6, -14, 15, 2, -5, 2, -11, 9, -8, 4, 6,
- 20, -15, -3, -3, -1, 32, -21, 6, 1, 9, 11, 17, -19, 6, -1, -3 },
- { 8, 10, -2, 0, -8, -16, 7, 7, 6, 10, 4, -14, 7, -6, 21, -7,
- 10, 5, 5, 0, -7, 2, -6, 0, -7, 11, -9, 15, -20, -7, -11, 2 },
- { 0, -7, 5, 2, 0, -3, -6, -4, -2, -1, -4, -5, -13, -1, 27, -9,
- -6, -11, -7, 1, 11, -4, -4, -14, -2, 11, 6, 10, -19, -6, -15, 2 },
- { 0, 7, -1, 2, -7, -15, -2, -3, 13, -5, -5, 12, 3, 0, 5, -5,
- -22, 2, 7, 22, 13, 0, -1, 2, 3, 2, -7, 7, -27, -4, -4, -12 },
- { 11, 1, -16, 6, -15, 1, 3, 2, 0, 2, -3, 2, 5, -2, -5, 9,
- 5, -3, 3, -2, -11, 3, 9, 6, 9, 3, -1, 12, -41, 8, -6, 9 },
- { 3, -7, 3, 2, 5, 5, 0, -1, 1, 3, -5, -2, -13, 7, -1, -2,
- -2, -6, 4, -6, 0, 2, -2, 2, 4, 1, -4, 1, -47, -21, 7, -6 },
- { 3, 16, -7, 13, -4, -2, 10, -3, -1, 18, -13, 7, -13, -4, 8, 4,
- 8, 9, -5, 13, 8, -5, 3, -6, 7, 18, -8, 10, -25, -3, -12, -12 },
- { 1, -1, -1, 0, 2, 5, -5, -3, 0, -5, -1, 0, -4, -8, -2, 3,
- 2, -2, -17, -6, -4, 1, 33, -6, -20, -6, 8, 31, -26, -8, -1, -4 },
- { 3, -3, -3, 5, -3, -2, 1, 7, 0, 3, 6, 3, 6, -2, 9, 15,
- -10, -3, -15, -5, -3, -4, -6, -30, 17, -8, -2, 2, -20, 0, -8, -2 },
- { -2, -1, -1, -1, 3, -5, -2, -3, 4, -2, 0, 5, 8, -3, 1, -4,
- 1, 1, -3, 4, 4, -14, 3, 11, -5, 3, -3, 7, -3, 13, 23, -16 },
- { 2, -6, 1, -3, 5, 0, -6, -11, -7, -4, -1, 2, -7, -1, -1, 7,
- 1, -2, 6, 12, -6, 8, -13, 17, 25, -23, -19, -7, -12, 9, 16, -17 },
- { 9, 4, 4, 4, -3, -1, 6, -2, -3, 0, 13, -4, -7, 14, 1, -7,
- 0, -5, 3, -19, -3, 5, 3, 9, -1, 9, -13, 13, -17, 4, 21, -26 },
- { 0, -5, 0, 0, -4, -5, 2, -6, -4, 5, -7, 10, 0, 2, 0, -2,
- -2, 0, 4, -6, 7, -2, 6, 5, -5, 2, -12, 1, -29, 29, 27, 12 },
- { 9, -10, -22, 6, -1, -1, 9, -14, -12, -2, 1, -1, 10, -11, -16, 0,
- 3, 11, 13, -14, -9, -2, -1, 6, 4, -14, 0, -10, -2, 16, 17, -11 },
- { 2, 0, -1, -2, 4, 3, -6, -2, 1, -1, 1, 3, -4, 1, 3, -4,
- -1, -1, 4, -1, 1, 0, 1, 6, -5, -7, 2, 1, -47, -3, 50, -17 },
- { 8, -4, -11, -7, 11, 11, 14, -7, 12, -7, 6, 2, 13, -6, -3, -2,
- -14, 6, 6, 6, 0, 2, -1, 5, -20, 2, -1, 4, -5, 6, 21, -11 },
- { -2, -9, 3, 0, -6, 7, 8, -8, 1, -3, 4, 1, 5, -2, -3, -7,
- 4, 7, -12, -9, -2, 10, -6, 13, 6, 5, 20, 2, -15, 9, 28, -7 },
- { 0, -5, -6, -6, -6, 1, -6, 6, -2, 4, 8, -3, 12, -1, -4, -2,
- 6, 16, -14, 9, -14, -2, -8, -27, -3, 18, -1, -7, -3, 8, 23, -23 },
- { 1, 4, -9, -1, -5, 10, -2, 1, -11, 1, -9, 4, 7, 14, -9, -2,
- -3, 2, -5, -1, -6, -10, -7, 11, 20, 2, 3, -19, 3, 15, 30, -9 },
- { 7, 2, -14, -4, 0, -2, 5, 2, 5, -2, 8, -3, -7, 6, 6, -11,
- -14, 1, 10, -1, -7, -8, 1, 10, 3, -6, -15, -12, -17, 4, 30, -6 },
- { 4, 2, 1, -2, 3, 0, 1, 0, 2, 0, 1, 6, -7, 0, 3, 4,
- 4, -4, -2, -5, -2, 2, -1, -2, 0, -2, -11, -7, -3, 42, 24, -14 },
- { 4, 1, 3, 2, 0, -2, -3, -2, 2, -1, 4, 11, -2, 2, 3, -4,
- -5, 9, 2, -4, -9, 5, 8, -1, -7, 1, 24, -13, -28, 20, 15, -22 },
- { -3, 7, 6, 3, -2, -5, -10, -2, -2, -1, -6, -6, -2, -14, -16, -6,
- -5, 0, 18, 0, 9, 1, 7, -13, -5, -6, -9, 11, -15, 9, 22, -11 },
- { 9, -2, 6, 5, 2, 9, -10, 1, 1, 5, -4, 12, 2, 2, -10, -7,
- -4, -6, 7, 9, 6, 15, 6, 6, -10, 10, 5, -13, -5, 6, 24, -12 },
- { 1, 3, -3, -3, 8, 1, -6, 2, -5, -3, 7, 2, 14, 6, 9, -6,
- -5, -4, 27, 7, -3, 8, -6, 3, -8, 8, 22, -5, -6, -2, 22, -17 },
- { -2, -2, 3, 10, 9, 9, 12, -15, -1, -11, -13, 3, -2, 1, -3, -11,
- 7, 9, 16, -3, -10, -5, -5, 1, 8, -3, 9, 9, -5, 3, 31, -12 },
- { 7, -5, 10, -4, -8, 2, 16, -2, 10, 10, -3, -2, 3, -8, -3, 3,
- -13, -6, 15, 20, -9, -3, -12, 1, -2, -16, 8, 8, -1, 16, 22, -5 },
- { 5, -3, -15, -2, 12, -8, 8, -5, 2, -8, 20, -18, 14, -4, 3, 3,
- 7, -13, -16, 1, -10, 7, 16, 7, 4, -14, -4, -5, -9, 8, 23, -6 },
- { 5, -4, -5, -4, 1, 8, 4, -7, -5, 8, 10, 6, -6, -10, -2, 6,
- 9, -17, -14, 11, 12, -3, -13, -7, 2, 18, 3, -25, -16, 18, 22, -5 },
- { 5, 6, -7, -20, -4, 2, 8, 4, -24, -4, 1, 4, -5, -2, 1, -10,
- -2, 9, 3, -4, -3, -4, -4, -4, 10, 10, 3, 0, -6, 25, 21, -11 },
- { 0, 7, -1, 14, -6, -4, -10, 5, 4, 4, 4, -5, 3, 4, -1, -7,
- 8, -19, 0, 6, 2, 3, -18, -3, -6, 2, 8, 14, -26, 22, 27, -13 },
- { -2, -6, 7, -5, 12, -7, 8, -1, 3, -2, 4, 1, 8, -2, 0, 14,
- 6, -5, 6, -4, -7, 7, -21, 8, 1, 8, -9, -4, -3, 11, 25, -13 },
- { 4, 4, -1, -6, 4, 9, -8, 1, -3, -10, -2, 0, 15, -9, -16, 11,
- 1, 1, 6, 3, -9, -5, 16, 26, 1, -14, 1, -3, -14, 7, 15, -9 },
- { -12, -2, -9, -13, 2, 6, 14, 0, 1, 0, -1, -13, 0, 10, -1, 6,
- 9, -7, 8, 8, 19, 6, -1, 9, 10, -4, 1, -7, -22, -2, 29, -7 },
- { 2, 4, 13, -12, -8, -4, -5, 13, 12, -5, -3, -3, -4, 1, -1, 10,
- 15, -6, -1, -11, -30, 4, 15, -1, 9, -7, 0, -2, -7, 10, 25, -16 },
- { 7, -15, -7, -7, -1, -5, -5, -11, -20, 10, 3, -10, -3, 5, 20, -4,
- 0, -2, -2, 17, 2, 0, -3, 3, 6, 5, -1, -12, -3, 15, 22, -16 },
- { 4, -1, 3, 4, -5, 0, -1, -5, -24, -29, 4, -9, 1, -3, 0, 0,
- 0, -4, 7, -4, -4, -4, 3, 1, -6, 5, -3, -5, -10, 3, 25, -10 },
- { -2, -1, -1, 4, 4, -1, 2, 0, -4, -4, 2, -1, -3, -1, -2, -2,
- 1, -3, -5, -1, 2, -3, -4, -4, -3, 5, -9, 1, -11, 7, 46, -46 },
- { 0, -9, 3, 4, 4, 3, -5, -6, 5, -4, 4, -2, 1, 7, -4, -10,
- 13, 1, 3, -6, 4, -4, 7, 2, -19, -25, -3, -16, -12, 16, 20, -1 },
- { 18, 6, 4, -12, 0, -14, 9, -6, -1, -4, -5, 2, 1, 12, 4, 2,
- 7, 0, 2, 5, -11, -5, -2, 2, -4, 10, 0, -9, -7, 9, 25, -8 },
- { 5, 0, -6, 5, 6, 3, 3, -10, -5, 1, -1, 4, 3, -11, -8, 5,
- 4, -5, 5, -5, -7, -5, 11, 5, 20, -8, -16, 21, -4, 27, 23, -5 }
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { -4, -2, 2, 1,-16,-10, 1, 3, 1, 0, 6, 1, -3, 7, 1,-22,
+ 2, -4, -3, 11, 14, 6, -1, 1,-13, 29,-28, 10, 10, -8, 0, -9 },
+ { -8, 8, -7, 10, -3,-12, -5, -8, 1, -2, 9, -2, -5,-18, 1, 9,
+ -8, -8, 3, 41, 7, -9, -9, 22,-42,-29, 14,-18,-14,-32, 1,-15 },
+ {-16, 8, 15, 16,-16, 5, 2, 7, -6,-16, -7, 1, 1, -3, -2, 0,
+ 8, 20,-26,-11, 2,-17, 0, -3,-34,-37, 10, 44, -2, 22, 2, -4 },
+ { 7, 14, 5, 6, 15, -1, 3, -3, -9,-23, -5,-14, 8, -1,-14, -6,
+ -5, -8, 54, 31, -6, 18, 2,-19, -2,-11,-30, -6,-19, 2, -2,-14 },
+ { 1, 2, -2, -1, -3, -3, 1, -5, 1, -3, -4, -8, 5, -4, 0, 1,
+ 3, 7, -5, -4, -3,-12, 3, -2, -3, 12,-53,-51, 6, -1, 6, 8 },
+ { 0, -1, 5, 1, -6, -8, 7, 5,-18, -4, -1, 1, 0, -3, -3,-14,
+ -1, -6, 0,-14, -1, -1, 5, -3,-11, 1,-20, 10, 2, 19, -2, -2 },
+ { 2, 4, 3, 0, 5, 0, 3, 1, -2, 0, -6, -3, -4, -5, -3, -3,
+ -7, 0,-34, 4,-43, 17, 0,-53,-13, -7, 24, 14, 5,-18, 9,-20 },
+ { 1, 0, -3, 2, 3, -5, -2, 7,-21, 5,-25, 23, 11,-28, 2, 1,
+ -11, 9, 13, -6,-12, 5, 7, 2, 4,-11, -6, -1, 8, 0, 1, -2 },
+ { 2, -4, -6, -4, 0, -5,-29, 13, -6,-22, -3,-43, 12,-41, 5, 24,
+ 18, -9,-36, -6, 4, -7, -4, 13, 4,-15, -1, -5, 1, 2, -5, 4 },
+ { 0, -1, 13, -6, -5, 1, 0, -3, 1, -5, 19,-22, 31,-27, 4,-15,
+ -6, 15, 9,-13, 1, -9, 10,-17, 4, -1, -1, 4, 2, 0, -3, -5 },
+ { -7, 3, -8, 13, 19,-12, 8,-19, -3, -2,-24, 31, 14, 0, 7,-13,
+ -18, 0, 3, 6, 13, -2, 1,-12,-21, 9, -2, 30, 21,-14, 2,-14 },
+ { -3, -7, 8, -1, -2, -9, 6, 1, -7, 7, 13, 3, -1,-10, 30, 4,
+ -10, 12, 5, 6,-13, -7, -4, -2, -2, 7, -3, -6, 3, 4, 1, 2 },
+ { -8, 9, 2, -3, -5, 2, 0, 9, 3, 7, -4,-16,-13, 3, 23,-27,
+ 18, 46,-38, 6, 4, 43, -1, 0, 8, -7, -4, -1, 11, -7, 6, -3 },
+ { 1, 1, 18, -8, -6, 0, 3, 4, 22, -3, -4, -2, -4,-11, 40, -7,
+ -3,-13,-14, -7,-10, 14, 7, 5,-14, 11, -5, 7, 21, -2, 9, -3 },
+ { 0, 0, -2, 4, -2, 0, 2, 0, -1, 2, -1, 0, 0, 2, 2, 2,
+ -1, 1, -3, -1,-15, -2,-63,-27,-21,-47,-14, 1,-14, 10, 0, 2 },
+ { 1, 0, -4, 0, -3, -9, 4, 2, 6, -6, 0, -5, 11, -7,-15, 6,
+ -7, -6, 3, 7,-15, -5, 23,-13, -6, 12, -8, 9, 2, -3, 3, 4 },
+ { 6, 0, 3, 0, -2, -4, 2, 1, 1, -1, 1, -2, -1, -4,-22,-15,
+ -46,-66, 10, 20, 2,-17, 12, -6, 1, -2, -2, 0, 1, -5, 1, 2 },
+ { -1, 0, 0, 1, 0, -4, 0, 1,-10, -3, -8, 5, 7,-11, 2,-11,
+ 29,-25, 11, 10, 0, -1, 5, -7, -2, -5, -2, 4, 4, -3, 5, -2 },
+ { 1, -1, -1, -3, -2, 1, -8, -3, 2, -2, 4, -5, -1, -7, -2, 1,
+ -14, -7, 3,-30,-15,-14, 3, -4, -1, 3,-13, -1, -3, 1, 2, 3 },
+ { -1, -2, -3, 2, 2, -3, 3, 1, -3, 2, 0, -4, 6, 5, -5, 10,
+ -57, 3, 22,-50, 1, -2, -5, -6, -1, 5, 1, 2, 2, 1, -2, 2 },
+ { 2, 0, -1, -7, 2, 1, 3, 2, 0, 4, 3, -2, 3, -3, 4, -4,
+ 24,-35, -3, 38, -6, -5, 15, 20, 3, 16, -7, -5, 0, -4, -5, 0 },
+ { 0, 1, 0, 0, 0, -1, -1, 1, 1, -1, 1, -2, 0, 0, 0, 0,
+ 0, -1, -2, -1, -5, -2,-43, -3, 46,-52,-10, 7, -8, 11, -2, -1 },
+ { 0, 0, -1, 0, -1, 2,-41, 33,-44,-48,-15,-26, -9, 6, 3, 3,
+ -3, 2, 2, 2, 2, -1, -1, -2, 1, 3, 0, 0, 5, 2, 3, 1 },
+ { -4, 1, 6, 1, -6, -1, -2, 1,-14, -4, 0, -5, -2, 2, -2, 0,
+ -6, 1, 0, 8,-21, 32, -3,-36, -6, -2, -1, -7, 3, 0, 1, -6 },
+ { -3, -2, 3, 0, 2, 2, 8, -4, -4, 6, 2, 1, 3, -6, 4, 3,
+ 13, 0,-12, -1, 25,-20, -2,-23,-15, 7, -3,-11, -3, 6, -1, 0 },
+ { 0, 0, -3, -1, 0, 0, -2, -1, -2, -2, 1, -1, 0, 0, 10, 3,
+ -2, 3, 3, -7, -6, -5, 0, -4,-60,-16, -6, 38, 5, 6, -5, 0 },
+ { 0, 1, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 1, 0, 0, 1,
+ 0, 0, -1, 0, -8, 2, -9, 10, 40, 31,-56,-21, 4, 20, -4, 7 },
+ { -2, -2, 0, 4, -3, -1, 7, 3, 1, 3, -8, 0, 3, 1, 2, 5,
+ 1, -2, 14, 5, 4, 5, 5, 5, -5, 9,-66, 0,-20, -2, -8, 4 },
+ { -2, -1, 4, -1, -8, -2, -4, -1, -3, -3, 2, -7, -3, 5, 7, -2,
+ 45, 31,-17,-16, -2, -2, -1,-22, 1, -1, -3, 3, 5, -3, 5, -1 },
+ { -4, 0, 7, 5, 8, 7, 2, 9, -9, -9, -7,-11, -3, -8, 17, -4,
+ 34, 32, 18, 22, 1, 2, 1, -7, -5, 6, -1, 6, 4, 10, -2, -7 },
+ { 6, 0, 14, 9, 6, -1, -2, -3, 4, -6, -8, 4, 7, -1, 28, 38,
+ 15, -1, 16,-11, 5, 8, 4,-10, 3,-10,-17, 5, 3, 3, 3, 1 },
+ { 1, 1, 2, -1, 2, 1, 0, 0, -1, 0, 0, -2, 1, -3, 0, 1,
+ 2, -2, -4, -2, 0, -1, 1, -3, 1, 1, 1, -1, 8, 8, 66, 33 },
+ { -5, 2, -3, -7, 2, -8, -4, 10, 17,-18, -7, 4, -4, -7, -6, -6,
+ -5, 5,-12, 2, 0, 6, 8, -2, 1, 4,-11, 2, 1, 8, 31, 19 },
+ { 6, 9, 16, -6, -6, -1, -2, -3,-11, -2, 7, 7, 17, 3, 4, 10,
+ 2, 5,-13, 8, 7, 1, 4, 5, 7, 6, 7, -8, 9, -8, 33, 6 },
+ { 3, -1, 1, 0, -7, -5, 0, 14, -7, 1, -7, 1, 2, -4, 7, 10,
+ -16, 12, 1, -6, 3, 8, -1, 10,-13, -6,-12,-23, 12, -3, 30, 14 },
+ { -2,-15, 0, 8, 3,-19, 5, -3, 2, 3, 13, 7, 14, -3,-10, 0,
+ 8, 5, -6,-16, -8, -8, 14, 2, -1, 1, -9,-11, 11, -5, 27, 9 },
+ { -8, 6, -4, 4, -4, -1, 5, 4, 1, -7, -5, -4,-15, 1, 9, 0,
+ 8, 4, 1,-17, 11, -2,-19, -1, -6, -8, 3,-12, 3,-17, 33,-10 },
+ { -3, -1, 2, 7, 7, -2, 9, 8,-18, -1,-13,-10, -3, -3, 11, 8,
+ -2,-12, -8, 1, 4, 9, 14, 10, -3, 0, 2, 1, -2, 3, 31, 10 },
+ { -3,-10, 8, -1, -5,-11, 7, -5, 3, 6, 1, 4,-16, 10, 5, -4,
+ -2,-10, -1, 13, 6, -5, -7, 12, 7, -3,-17, 1, 12, -4, 29, 8 },
+ { 1, 2, 5, 2, -6, -7, 0, -1, 6, -1, 10, 6, -4, 5, 2, 2,
+ -2, -8, -6,-11, 14,-13, 27, 3, -2,-12, 5,-16, 2,-26, 20, 15 },
+ { -1, -3, -5, -3, -3, 6, -1, 3, -5, 1, 7, 2, 1, 0, -1, -1,
+ 0, -1, 9, 7, -6, -3, 4, -5, -4, 8, -8,-25, -8, -4, 34, 23 },
+ { -1, -2, 1, 1, -1, -2, -1, 1, -1, 0, 0, 0, 0, -2, -1, 1,
+ 0, 2, 1, -1, 4, 0, 0, 1, -1, 0, 5, 3, 12, -9, 68,-16 },
+ { 10, 0, -8, 14, -6, 1,-12, 0, 0, -3, -5,-11, -6, 12, 9,-10,
+ -3, 5, 0, 7, 11, 2, 4, -3, -8, -3, 7, 4, 3, -3, 34, 4 },
+ {-12, 13, -5, 7,-11, -2, -1, 1, -4,-14,-21, 3, -3, -3, -4, -7,
+ -9, -4, 3,-17, -2,-13, 10, -2, 12, -4, 0, -9, 1, -5, 31, 10 },
+ {-10, 6, 5, 6, 4, -7, 10, 0,-28, -3, 0,-11, -1, -5, 16,-10,
+ -16, 7, 20, 2, -4, 2, -5, 0, 15, 6, 5,-10, 7, -9, 20, 4 },
+ { 1, -7, -2, -7, 4, -3, -2, -7, -1,-14, 6,-16, 4, -5, -4, -6,
+ -5, 0, -2, 2, -6, 9, -5, 4,-18, 8,-10, 8, 15, 0, 32, 1 },
+ { -5, 7, -3, 7, 15, -4, 0,-16, 9, 5, -5, 5, 4, -3,-12, -9,
+ -18, 10, 2, 2, -3, 7, 3, -1, 6, -9,-10, 3, 15, -4, 35, -7 },
+ { -1,-10, 2, 2, -4, -2, 10, 2, -1, 2, -2, 1, -1,-14,-11, 3,
+ -8, 5, -8, -2, 6, -1, -7, 1, 7, 5, 7, 8, 30, -4, 30, 14 },
+ { 2, -2, 1, 2, 3, -8, 3, 0, -2, 0, -9, 2, 1, 4, -6, -1,
+ -2, 5, 0, 1, -2, 12, 6, -3, 9, -3, 4,-12, 21,-39, 24, -2 },
+ { 3, 5, 1, -2, -2, -2, -3, 6, -8, -2,-11, -8, -1, 4, 2, 2,
+ -4,-10, 12, -5,-11, 1,-15,-34,-11, -7,-11, -1, 7,-14, 38, -1 },
+ { -4, 4, 8, 9, 8, 1, -5, -9, 4, -2, 15, -4, 11,-15, 20, -1,
+ -1, -3, 4, -9, -2, -2, -2, 8, 6, 12, -5, 0, 11,-12, 27, -4 },
+ { 0, 8, -4, 3,-11, 6,-11, 2, 3, 0, 5, -8, -7, -6, -9,-21,
+ 4,-11, -1,-16, -7, 16, -3, 7, -7, 4, -5, 0, 11, -7, 31, 3 },
+ { 1, 3, 4, 11,-11, -2, -3, -6, 6, 5, 0, 3, -9, -6, 4, -4,
+ 0, 4, -8, 13, -6,-13, -1, -5, -1, 4, 0, 0, 9,-22, 24, 18 },
+ { -7, 3, 10,-13, -6, 6, -6, 6, 22, 1, 0,-14, 2, 3, 7, -1,
+ 8, 20, -1, 5, -4, 13, 9, -9, -9, 6, 0, -4, 0, -8, 31, -4 },
+ { -3, -4, 0, 1, 7, 3, -7, 0, 5, -2, 1, 3, 3, 1, -5, -2,
+ 5, 2,-11, 4, 0, -1, 12, 0, -3,-13, 15, 8, -6,-27, 34, 0 },
+ { -3, -3, 10, -4, 2, -1, -3, 0, -1, -1, -4, 2, 6, -2, 12, 1,
+ 3, -6, -7, -6, -5, 4,-19, -6, -8,-34, -4, -8, 10, -7, 23, 10 },
+ { -7, 0, -1, -6, 8, 4, -4, 2, -5, -8, -7, -9, -8, 5, 9, 7,
+ -6, 1,-12,-12, -1,-16, 5, 0, 16, 3, -7, -8, 27, -4, 23, 15 },
+ { -8, 4, 8, 5, 6, 11, -3, 5, 3, -1,-11, 6, -5, 0, 2, -6,
+ -3, -6, 4, -1, 5, -5,-12, -6, 7, -5, 9, 3, 6, -7, 29, 1 },
+ { 1, 3, -2, -2, -6, -2, 1, 6, -6, -3, 1, 2, 3, 4, 1, 5,
+ -1, 0, 4, 2, 11, 6, 2, -3, 13, -9,-19, 18,-15,-10, 36, 21 },
+ { -3, -3, 2, -1, -7, 6, -4, 1, -3, -1, -2, 2, 3, -7, -3, 0,
+ -2, 0, -2, 6,-19, 3, -8, 2, -6, 7, -1, 0, 29, -6, 28,-10 },
+ { -5, 1, -3, -7,-12, -4, 1, 1, -1, 13,-10, -1, -9, -5,-13, 6,
+ 13, 3, -4, 2, 3, 11, 2, 6,-25,-16, -6, 0, 14, -1, 27, 16 },
+ { -6, -1, -7, -5, -2, -5, -5, -1, 9, 1, 0, 3, -8,-12, -6, 5,
+ -6, 5, 3, -9, 1, 4, -7,-10, -9, -7,-17, -5,-15,-23, 25, 3 },
+ { -8, -2, 9, -3, -4, 3, -1, 8, -7, -7, -5, -4, -2, 9, 4, -1,
+ -7, -4, -5,-16, 3, -6, 18,-13, -9, 16,-15, 8, 15,-10, 24, 5 },
+ { 1,-38, 2, 34, 9, 10, 11, 2, 2, -6, 3, 2, -2, 5, 4, -7,
+ -1, 1, 4, 0, 3, 1, -8, -1, -6, 5, 4, 2, -4, 5, 2, -1 },
+ { 1,-22, 15, 18, -2, 10,-16, -9, -8,-11, 8, 4, 0, 7,-14, -5,
+ -1, -7, 12, 17, 9, 5, -7, -4,-12, -6, 7, 0, 7, 2, -2, 1 },
+ {-11,-29, 7, 10, 19, -1, -8, -9, 7, 1, 9, 6, 8, -7,-14, 8,
+ -3,-11,-13, 0, -7,-23, -2, -8, 12, 9, 2, 14, 19, 1, -1, 5 },
+ {-24,-27,-11, 36, 2, 6, -3, 4, -6, 8, 0, 12, -1, -4, -6, 3,
+ 4, -1, 2, -3, -2, 3, 2, -1, -2, -4, 0, -1, -2, 7, 2, 3 },
+ { -9,-24, 11, 13,-10,-12, 12, -2, 7, 4, 8, 13, -3, -3, 2, 9,
+ -3, -4, 4, 13, 5, 13, -6, -3, 1, 15, 7, -3, 0, 19, -2, -9 },
+ { -8,-15, 7, 14, -4, -5, 2,-18,-19, -2, 2, 17, 16, 6,-10, 10,
+ -9, 14, -1, -5, -1, -6, -7, 2, 9, 11, 13, 6, -5,-12, 3, 2 },
+ {-10,-37, 13, 1, 3,-14, 0,-20, 4, -3, 8, 2, -2, -3, -9, -5,
+ -3,-17, -1, 13,-11, 2, -6, 4, 4, 0, 3, 1, -9, -4, -5, -4 },
+ { -2,-22, -5, 46, -8, 5, 9,-11, 8, 7, 7, -1, -1, -2, -7, 2,
+ -3, 3, -1, -2, 7, 0, 2, -1, 1, -2, -2, -3, 6, 0, -4, -6 },
+ {-16,-27, 15, 16, -4, 14, -7,-26, 2, -2, 6, 5, -3, 11, 0, 2,
+ 3, 9, -7, -1, 2, -4, -4, -1, 6, 10, 1, 1, -3, -2, 3, 0 },
+ { -3,-22, 10, 26, 1, 2, -3, 3, 17, -3, -7, 9, 1,-21, -4, 5,
+ 3, 0, -7, -6, 3, 3, -8, -7, -9, 3, 7, 1, -8, 12, 6, -7 },
+ { -9,-25, 3, 18, 9, -6,-11, 0, -5,-12, 9, -8, -7, -6, -6, 22,
+ 2, -6, -3, 15, 3, 2, -2, 9, 14,-10, -7, 15, 13, 6, -2, 11 },
+ { 5,-20, -5, 28, 11, 10, -4, -4, 0, -7, 3, 5, 2, -5, -8, 2,
+ 6, 10, 9, -9,-18, 3, 14, 1, 3, -3, -1, -6, 7, 7, 2, -1 },
+ { -8,-30, 7, 12, 10, 8, 7,-13,-16, 0, 1, -1, -6,-11,-15, 4,
+ 1, -2, 10,-15, 1, 11, -2, 8, 9, -7, -7, 9, -5, 2, 7,-18 },
+ {-10,-32, 10, 11, 3, -1, 3, -5, 5, 2, 14, -6, 3, 1, 5,-15,
+ -11, 6, 20, 4, 0,-12, -7, 3, 1, -1, 10, 6, -1, -9, -4, -1 },
+ { 1,-25,-14, 12,-11, 9, 9,-16,-24,-17, 22, -9, 11,-30, -3, -4,
+ 6, -7, 9, 2, -1, -5, -6, 2, -1, -1, 10, 1, -3, 3, 4, 8 },
+ {-14,-26, -6, 9, 8, 17,-11,-24, -7, -4, -8, -2, 10, 2, 2, -1,
+ 2, 13, 12, -7, 4, -6,-10, 6, 6,-13,-11, -7,-16, 0, -2, 5 },
+ { -4,-30,-13, 12, 16, -6, 12,-16,-13, 5, 15, -2, -2,-10, -7, 7,
+ 11, -1, -4, -2, -4, 7, 4, -8, 1, 3, 0, 11, 3, -2, -5, 4 },
+ { -4,-21, 20, 22, 2, 20, -8, 1,-12, -5, -9, 4,-10,-17, -3, -8,
+ -3, 3,-12, 1, -3, 0, 7, 4, 7, 7, -3, 7, 5, 3, 1, -5 },
+ {-12,-20, 2, 29, 11, -6, 9, -7, -6, -4, 0, 6, 17,-13, -2,-10,
+ -17, -1,-18, 2, 0, 14, -6, 1, 0, 3, 2,-10, 1, -5, -2, 5 },
+ { 16,-37, -1, 26, -2,-14, 1, -5,-14, 2, 2, 3, 6, 1, 1, 4,
+ 0, -1, 0, -2, -2, 4, 9, -6, 0, -2, 10, -7, -2, 4, 1, 0 },
+ { -9,-24,-12, 5, 5, 3,-17,-14, 4, 3, 2, -4, 10,-22, -8, -3,
+ 6, 1, 12, -8, 4, 1, 9, -1, 18, -3, 6, 5, 3, -5, 9, -5 },
+ {-14,-33, -2, 20,-13,-10, 2, -7, -1, 11, -9, -8, 18, -3, 1, 8,
+ 0, -2, 10, 7, -2,-13, 9, -3, -4, 5, -2, -2, -1, -5, 1, -7 },
+ {-10,-23, 8, 14, 1, 7, 1, -3, -7, 4, 1, 1, 8, -7, 15,-14,
+ 13, 14, 2, 5,-13, -5, -8, -1, 6, 3, 6, 9, 6, 15, 14, 5 },
+ {-13,-25,-10, 13,-17,-24, -7,-13, -6,-10, -8, 2, 0,-13,-10, -4,
+ -8, 4, -9, 9, -4, 4, -3, -3, 3, 3, -5, -9, 1, -2, 11, 2 },
+ {-12,-23, 1, 18,-11, -2, 5, 9, -5, 5, 14, -9, -3, -2, -6, 2,
+ -2, 11,-13, 1, -3, 11, -9, -4, -2, -6, 8, 10, 1, 4, 2, 1 },
+ { -5,-18, 16, 22, 2, 0, 8, -6, -9, -7, 10,-16, 23, 10,-11, -1,
+ 7, 2, 7, 2, 1, -5, 6, 1, 0, -4, 9, 2, -3, 1, 0, -4 },
+ { -3,-26, 14, 11, 2, -9, 17, -2, -1, -5,-16, -9, -5, 10,-13, 1,
+ 6, 12, 10, 11, 0, 0, -3,-14, 6, -2, 0, 4, -5, -1, -7, -1 },
+ {-10,-33, 1, 8, 11, -5, 1, -6, 7, 4, 5, 6, 1, -2,-10, -5,
+ -6, 12,-11, 5,-10, 4, 12, -1, -1, -3, 4, -1, 9, 0, 16,-17 },
+ {-14,-37, 7, 7, -2, 5, -8,-11, 2,-13, 4,-19, 1, 8, 8, 4,
+ -9, 2, -4, 3, 12, 2, 4, -4, -8, 8, 1, 4, 8, -1, 6, -2 },
+ { -6,-30, 18, 17, 1,-22, -3, 4, -7,-10, 7, 0, -8, 8, -1, 4,
+ 2, 8, 6, -2, 2, 7, 4, 4, 3, -6, 2, 1, -3, 1, -1, -5 },
+ {-17,-18, -3, 22, -8, 1, 9, -2,-17, 20, -5, -5,-12, -5, 4, -5,
+ -9, 8, -2, 16, -3, 0, 19, -8, 8, 1, 2, -4, 0, 11, 0, -3 },
+ { -9,-23, 3, 10, 4, 4, -3, -2, -2, -2, 1,-22, 11, 0, -2, 5,
+ -2, 14, -9,-11, -4, 7, 5, 32, 1, -3, -7, 0, 21, -9, 7, -6 },
+ { 0, 0, 0, 2, -1, 1, 0, 1, 3, 0, 0, 1, 0, 1, 0, 1,
+ -3, 0, -1, -2, 0, -1, -1, -3, -1, 1, -4, 1, -1, -5,-69,-19 },
+ { -3, -5, -8,-12, 4, -3,-19,-11, -5, 0,-14, 7, 18, -6, 7, 22,
+ 8, 14, 15, 10, 3, -1, -3, 5, -1, 7, -7, 1, -6, 3,-26,-11 },
+ { -1, -6, 4, -4, -5,-16, 0, -6, -3, 11, 1, 0, 9, 5, 16, 3,
+ -4,-33, -4, 4, -7, 0, 1, 6,-11, -2,-13, -2,-18, 20,-25,-16 },
+ { 4, 0, -1, 0, -5, 1, 0, 2, 0, 11,-10, 4,-10, 7, 16, 2,
+ 16, 15, 2, -1, 2, 9, 2, 8, -3, -5, -2, 0, -3, 0,-33, -2 },
+ { -3,-15, 10, 10, -9, -1, 7, 3, 5, -5, -8, -8, -3, 15, -9, 4,
+ 12, 13,-13,-14, 10, -6, 9, 22,-27, 23, -1, 5,-24, 2,-30, 5 },
+ { 0, -2, 7, -5, -5, 3, 5, 3, -3, -5, 2, 1, -4, 3, -3, -1,
+ 1, -2, 10, 22, -3, -4, -2, -2, -7, 3, 8, 1, 14, 4,-37, 9 },
+ { -3, -4, -1, 1, -4, 0, 6, 2, 6, -7,-10,-10, -1, -4, 11, -3,
+ 7, -6, 4,-12, -1, 5, 1, -7, 10, -6, 17, -4, 8, 3,-40, 13 },
+ { 2, 12, 4, -7, 14, -3, 16, -2, 18, 2, 13, 5, 5, 1, 11, -1,
+ 0, 9, 2, -6, -1, 2, -6, 2, -5, 3, 5, 1, -1, 1,-32, -7 },
+ {-16, 11, 7, -4, 2, -5, -9, 9, 11, 11, 15,-13,-11, 11, 9, 4,
+ 3, -8,-10, 12, 12, 0, 0,-16, -9, 13, 2, 9, 4,-13,-33, 3 },
+ { 6, 4, 5, 4, 3, -1, 5, 6, 4, 2,-11, -1,-15,-11, -1, 1,
+ 11, -3, -2, 24, -4, -6,-25,-10,-15, -8, 0, 0, -5, 4,-30, 2 },
+ { 10, -3, -6, 1, -9, -5, 6, 9,-10, -3, 8, -1, 4, -1, 11,-11,
+ 3, 9, 11, -3, 6,-17, 5, -8,-33, 9,-13, 19, -2, 9,-25, 2 },
+ { 0, 0, -1, -3, 0, -2, 1, 0, 0, 2, 1, 0, -2, 0, -1, 2,
+ 0, -1, 4, -1, 2, -3, 4, -2, 3, 3, 1, 0,-15, 12,-63, 27 },
+ { -2, 14, 9, -1, 3, 0, 1, 1,-19, 15, 3, 4, 0,-10, 1, -5,
+ 3, 0, -5,-10, 2,-16, -4, 8,-12, -6, 7, -5,-10, -1,-33, -4 },
+ { 0, 3, 1, 3, 1, 2, 4, 4, 9, -6, -8, -5, 1,-12, 3, 8,
+ -10, 6, -1, 1, 13, -5, -5, 2, -4, 13,-18,-10, -7, -9,-33, 10 },
+ { -6, -3,-12, 5, -1, 11, -6, 0, -2, 1, 2, -7, 3, 1, 3, -2,
+ 1, 8,-10, 7, -1, -3, 3, 0, 13, 1, 6, 7,-16, -7,-39, 8 },
+ { -6, -1, 11, 6, -3, 8, 3, -5, 3, 0, -5, -2, -6, -3, -4, 2,
+ -3, 13,-11, 1, 7, 5, 19, -5, -3,-15, -1, 7, -1, 6,-33, 8 },
+ { -7, 3, -4, -3, -4, 1, 6, -5, -5, 6, -8, -1, -7, 4, -1, -6,
+ -2, 1, 7, 0, 1, 1, -5, 2, -2, 0,-13, -2,-31,-14,-39,-12 },
+ {-10, 9, 0, -3, 1, -1, -1, 0, 1, -5, -1, -4, -2, 5, 2, -7,
+ 18, -8, -2,-19, -7, -7,-12,-14,-11, -1, -9,-13, -7,-12,-31, -9 },
+ { -3,-16, 10, 9, 1,-10,-12, 2, -2, 2, 7, -3, -3, 1, -4, -5,
+ -9, 5, 7, 3, -1, 4,-11, -8, 4, 13,-10, 13, 10, -4,-36, 1 },
+ { -7,-12, 4,-20, -7, -7, 2, 11, -1, -2, 3,-12, 1, 0, -6, -7,
+ 6, 4, 13, 3, -3, 4, 3, -6,-12, 5, -5,-22,-13, -8,-37, -6 },
+ { -7, 5, 3, 5, 7, 9,-14, -3, 10, 17, -1, 1,-12, 5, -6, 0,
+ -4, -9, 0,-11,-14, 3, 13, 6,-25, -8,-12, 4,-10, 18,-30, -1 },
+ {-10, 6,-10, 6, 6, 1,-10, 0, -7, 5, -2, 17,-18, -4, 0, -3,
+ -16, -6, -3, -8, 5, 1, -4, 6, -7, 16, 6, 10, -1, 0,-32,-11 },
+ { -1, 9, 9, -5, 4, 9, 6, 9, -4, -2, 7, 11, 4, 2, -5, -4,
+ -6, 0, 2, -3, -1, 5, 10, 0, 12,-10,-18, -3, -1, 14,-33, 2 },
+ { 4, -8,-18, -4, -5,-11, 4,-10, -4, 9, 13,-12, 1, -6, 1, 2,
+ 4, -9, 8, 3, -6, 21, 13, -1, -2, 1, -2, 6, -7, 0,-30, 1 },
+ { 6, -1, 2, -3, -1, -4, 6, -4, 0, 4, 2, 2, -9, 2, 6, 3,
+ -2, 4, -1, 9, -6, 0, 7, -8, 5, 19, -2, 9, -5, 2,-33, -8 },
+ { 2, 1, 12, -5, -8, 8, 3, -2, -4, 1, -2, 5, -4, -9, -8, -8,
+ 7,-11, -4, 6,-10, 7, -1, -1, -2, -1, 16, 32, -7, 20,-33, -6 },
+ {-18, 2, 6, 13, 9, 9, -1, 3,-17, 24, -2, -6, 28, 8, -2, 6,
+ 3,-10,-34,-16,-13, -4,-15,-11,-12, -3,-10, 4, -8, 4,-31, -4 },
+ {-11, 0, 18, 2,-16, -9,-13, -2, -2,-12, -3,-22, 30, 0, 8, 3,
+ 9, -4,-16, 1, 0,-11, 15, -2, -4, 6, -5, 6, 1, 2,-25,-12 },
+ { 14, -1, 5, 7, 3,-15, -8, 1, 5, -2, 12, 13, 11,-25, 3, 1,
+ 0, -2, -4,-16,-23, 0, -5,-17, 7, 5, -9, 6, -5, 2,-32, -7 },
+ { 3, -1, 6, 14, 2,-12, -9, -9, 4, 7, 4, 6, 5, -8, 4, 2,
+ 4, 5, -2, 8, 8, -6, 0, 10,-20, -1, 3, -1, 8, 23,-33, -5 },
+ { -3, 11, -6, 3, -4, 5, 7, 3, 4, 5, -2, 3, -1, 30, 6, 1,
+ 8, -6, 0, 0, -9, 6, -9, 4, 2, 9, -6, 1,-12, 0,-34, 18 },
+ {-17, 13, 0, 1, 9, -4,-11, 0, 7, 0,-10, -4, -1, 6, -6, 4,
+ 1, 6, -9, 3, -5, -6,-11, 2, -4, 14, 23, -3, 2, 5,-30, 12 },
+ {-14, 5,-27, 2, 0, 7, 1, 4, 30, 8, 7, 5, 1, -1, 0, 5,
+ 8,-10, 48,-11, 12, 33, 6, 8,-15, 20, -2, -5, 32, 5,-19, 10 },
+ {-16, -4,-12, -7, -2, 0, 8, -6,-20,-18, 16, -3, 0, 31, -2, 11,
+ 2, -9, 49,-19,-12,-23, 10, 26, 16, -2, 4,-21,-14, 13,-11, -9 },
+ { -5, -9, -1, 3, -5,-21, 2, 10, 0, 0, 10,-21, -7, 7,-26, -9,
+ 22, 32, 58, 11, -3, 11, -5, -8,-13, 6, -5, -9, 1, 10, 14, -8 },
+ { 7, 7, 10, 3, -2, -1,-11,-11, -6,-43, -3, 14,-19,-18, 19, 18,
+ -32, 10, 45, -6, 6, 21,-20,-12, 2, 4, 6, 6, -4, 3, 3, 1 },
+ { 21, 22, -3, -2,-11, -6, -1, -2, 8, 8, 32,-21, 7, 28, -4, -6,
+ -3, -2, 50, 2, 2, 27, -5, -8, 12, 7, -5, -1, -4,-17, 27, 6 },
+ { 13, 7, 2, -6,-12, 2,-10, -5,-17, 11, 4, 17,-12, -2, 5,-17,
+ 37,-16, 48,-14,-18, 29, 8, 24, 11, -5, -9, 11, -1, 1,-13, -3 },
+ { 1, 1, -1, 2, 0, 0, 0, -1, 1, -1, 7, 2, -3, 3, 0, 6,
+ 2, 10, 54,-25, 7, 54, -5, -6, -1,-15, 9, 13,-24,-15,-12, 3 },
+ { 21, 5, 8, 3, -3, -4, -2, -4, 3,-11, -5, -8, 9, 16, 8, -9,
+ -10, -3, 46,-46, 2, 1,-10, 10, 17, 11,-20,-36, 10, 14, 0, -5 },
+ { 7,-13, -6, -9,-24, 45, 2, 8, 8, 0, 17, 20, 12,-24, 1, -7,
+ -15, -3, 46,-13, -2, 20, 1,-13,-11,-13, 2, 15, 1, 10, -1, 3 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, -1,
+ -16, -9, 31,-69,-34, 26, 7, 17, -1, -6, -1, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4,
+ -5,-20, 18,-82, 22, 3, -7, 9, 4, 6, 2, -4, -1, 0, -2, 2 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, -1,
+ 15, -5, 62,-36, 4, 52, -7, 5, 0, 6, 1, 2, 1, 1, -1, 0 },
+ { 3,-19, 19,-20, 13, -4,-11, 8, 8,-16, 10, 1,-14, 30, 1,-33,
+ 10,-11, 45,-30, 3, -4, -3,-13, 7, 12, 3,-22, 3, -2, -4, -2 },
+ { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1,
+ 11, 8, 70, 48,-10, 21, 4, 9, -9, -9, -4, -6, 0, -1, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
+ 2, -1, 80, 2,-15,-36,-10, -5, -2, 8, -2, 2, 0, 0, 0, 0 },
+ { 10, 8, -8, -8,-24, 12, -1, 0, 20, 9, -1, -2, 2, -2, 12,-10,
+ -2,-13, 35,-43, 44, 15,-10,-25, 4, 10, -3, -5, -5, 7, -1, 3 },
+ { 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -2, -1,
+ -18, 9, 49,-72, 7, -8, 7, -5, 2, 3, 2, -2, 1, -2, -3, 1 },
+ { -1, 4, -3, 10, 19, 4, 3, 20, 6,-24, 6, 9, 8, 15, 18, 18,
+ -36, 19, 57,-11, 4, -3, 8, 7, 2, -3, -2, -9,-15, -2, 12, -4 },
+ { 20, 3, 11, -9, -4, 22, 42,-25, 1, 5,-10,-19, 0, 9,-16, 5,
+ 2, 10, 44,-29, 17, -3, -9, -2, -1, 8, 14, -7, -1, 16, -5, 1 },
+ { -7, 16,-11, 12, 6, 33,-15, 14,-23, 2,-26, 8, 2, 10, 0, -5,
+ 8, -8, 38,-38, -4, 5, 5, 5, 1, 22,-15, 7, 6, 0, 4, 28 },
+ { -1,-12, 2, 10, -2, 0, 7, 17, 12, 22, -4, 10, 25, 29, 5, 18,
+ 4, 1, 27,-39, 31, 17, 2, 2, 22,-23, 13, 16, 1, -7, -4, -5 },
+ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, 0,-14, 0,
+ -7,-11, 49,-22, -4, 19, 17,-39, 4,-29, 10, 2, 36, -4, 23, -1 },
+ { -2, -2, -2, -2, 1, 15, -5, -7,-16, -8,-19, 16, -3,-20, 36, -9,
+ -3, 20, 39,-20, 0, 2, 27,-16, 10, 10,-14,-22,-16, -3, 13, -8 },
+ { 5, -9, 6,-25, 7, 37, 13,-10, -5, 3, -5, 7, 18,-22, -7, 9,
+ -5, -4, 50,-11, -4, -5, -5, 8, -4, -2, -4,-27, 14, 20, 7, -9 },
+ { 0,-14,-10,-27,-14,-17, -6, 26, 10, 2, 14,-12, -5, 0, 8, 9,
+ 0,-28, 55, -7,-12, -7, 4,-10, 10, 7,-12, 11, 3, 5, 9, -8 },
+ { 2, 23, 4, -2, -1,-20, -2, 14, 10, -9, -9,-24, 10, 0, 11,-12,
+ 12, 11, 49,-25, -2, 29, 7,-13, 21,-10, 11,-17, 3, 1, -8, 5 },
+ { 3, 0,-14, -6, 18, -2, 17, -9,-19, 9, -5, 9, 14, 6, 19, -3,
+ 27, 1, 41,-21, 20,-15, 33, 0, 26, 14, 7, 10, 3, 20, -3,-12 },
+ { -1, 16, 15, -8, 3, -8, -8, 21, -5,-16,-29, 4, 1, -6, -4,-28,
+ 2, 31, 37,-26, -2, 13, 24, 8, -9, -6,-29, 10, 7, 2, 7, 8 },
+ {-10,-10, 11, 13,-32, 2, 16, 9, 14, 23,-15,-13, 24, 13, 4,-27,
+ 14, 12, 31,-18, 17, 23, -2, -7,-14, 9,-17, -6,-10, 20, 9, 6 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
+ 5, 1, 89, 8, 10, -6, 2, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1,
+ 4, -7, 64,-50, 7, 37, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { -2, 5, 3, -4, -4, -3, 2, -3, 3, -3, 5, 4, 1, -6, -1, 1,
+ 6, -2, 50,-35, -7, 43, 7, -7, -5,-26, 24, 21, 3,-15, 5, 6 },
+ { -8, 21,-19, 33, -8, 22,-11, 17, 3, 0, 0, -2, 1, -3, 6, -1,
+ 10, -8, 4,-11, -4, -5, 0, 8, -4, 3, 1, -4, 4, 2, 8, 4 },
+ { -7, 5,-20, 9,-22, 3,-14, 1, 6, 13, 23, -2, -4, -7, 2, 0,
+ 11, 4, 6, 3, -7,-11, -7, 4, 5, 5,-12, 8, 2, 4, 7, -3 },
+ { -7, 6, -4, 20,-20, 16, -2, 7, 6, 16, 11, 12, -7, -7, 5, 3,
+ -9, -4, 1, 2, 5, 2, 1, -9, -2,-17, -4, 6,-10, 7, -7, -6 },
+ { -9, 18,-17, 12,-24, 1, -1, 4, 14, 9, 4, 3, 2, 8,-12,-14,
+ 4, -8, -4, 7, 7, 6, -1, 13, -9, -4, -1, 1, 0, -4, 15, 8 },
+ {-25, 2,-11, 6, -5, 24,-28, -5, 8, 12, -2, 6, 8, -3, 8, -9,
+ -1, -5, -1, -5, 6, -1, -1, -1, -4, 8,-12, -2,-13, 7, 2, 1 },
+ {-14, 14,-18, 20,-10, 12, -2, 9, 1, 0, 12, -2, 15,-10, 26,-17,
+ 16,-11, 10,-10, 9, -2, 4, -8, 2, -3, 4, 4, 2, -3, -5, 1 },
+ {-18, 12,-18, 21, -6, 12, -6, 13,-25, 18, 1, 11, -9, -5, 0, 10,
+ -5, 3, -3, 8, -9, 7, 4, 2, -9, 0, 5, 0, 2, -3, 9, -8 },
+ { -4, 16, 1, 18,-30, 9, 1, 6, -8, 13, 13,-12, -6, -1, 13, 7,
+ 6, 2,-15, -3, 5, 5, 1, -6, 1, -5, 0, 2,-16, 0, 3, -4 },
+ {-21, 1, -2, 6,-43, 18, -1, 5, -1, 4, 6, -2, -1, -3, -1, -3,
+ 0, 1, 2, -9, 0, -1, 0, -2, 0, -1, -1, -2, 6, 0, 1, -2 },
+ {-23, 10, 4, 7,-32,-11,-18, 2, -2, -7, -6, -3, -3,-12, 19, 3,
+ -5, -6, 16, -6, 16, 2, 16, 16, 8, -2, 13, 8,-15,-11, 2, 10 },
+ { -8, 2,-13, 2,-29, 24,-20, 19, 1, 10, -4, 10, 1, 2, -9, 11,
+ -1, -2, 9, -5, 19, -7, 16, -9, -2,-18, 11, 1, 1, 0, 7, -3 },
+ { -6, 3, 4, 13,-26, 10,-10, 28, -7, 28, 1, 7, 0,-14, 5, 7,
+ 4, -4, 3, -2, 3, 3,-11, 7, 6, 4, 0, -1, 2, -1, -3, 2 },
+ { -6, 16,-31, 13,-10, 17, -6, 4,-14, 4, 4, -1,-10, 12, -5, 1,
+ -14, 15, 0, -8, 1, -5, 3, 3, 9, -5, 7,-20, 7, 4, 11, -5 },
+ {-19, 3,-17, 14,-12, 16,-22, 18, 14, 8, -2, 4, 10, 12,-14, 4,
+ -3, 2, 3, 7, -7, 7, -6, 2, -2, -4, -5, 0, -5, -2, 2, 1 },
+ { -9, -7,-11, 24,-36, -9,-11, 5, 7,-12,-13, 18, -2, 20, 1, -4,
+ -1,-10, 15, -6, 14, 1, 0, 2, 1, 2, -9,-16,-11, 7, 13, 0 },
+ {-24, 24,-18, 18,-22, 14,-11, 13,-12, 11,-10, 11, -7, 11, -5, -4,
+ -1, 1, 5, 2, 3, -1, 1, -5, 7, -4, 5, -6, 8, -7, 8, -6 },
+ { -6, 18,-22, 22, 5, 11, -1, 6, 19, 22, 8, 4, -8, 20, -2, 15,
+ -6,-18, 0,-33, -9,-12, -1, 6, 5, 2, 5, 5, -5,-17, -3, -3 },
+ { 1, 11,-16, 9,-18, 11, -4, 18, 20, 26,-10, 8, 1,-11, 8, -4,
+ 0, 7, 3, 5, 2, 2, 10, -2, -4, 4, -4, -2, 1, -4, -5, -1 },
+ {-10, 6, -1, 18,-17, 27, -3, 10, -2, 12, -7, -9, 1, 1, -1, 7,
+ -12, -1, -7, -6, -1, 8, 3,-15, 8, 9, 3, -7, 4, -1, 1, -1 },
+ {-14, 6,-16, 22, 2, 5, 0, 5,-18, 11, 6, -3, 22,-20, -9, -3,
+ 6, -6, -7,-15, 1, 15, -8, 11, 8, -3, -8, 1, -8, 2, 6, -2 },
+ {-21, 5,-19, 19, -7, 4, -7, 0, -8, 6, 12, 5, -3,-22,-13, -6,
+ -1, -3, -2,-14, 6, -3, 1, -8, -7, -5, -6, 11, -3,-10, -5, 2 },
+ { -1, 9,-12, 15, -6, 6,-19, 14, -9, 11, 3, 12,-17, -3, 8, -4,
+ -3, -4, 1, -5, 4, 5, -7,-15, -7, 15, -6, -5, 1, -5, -3, 1 },
+ {-12, 20,-15, 20,-14, 3,-14, 9, -6, 33,-13, 6, -2, 8, -6, 7,
+ -5, -6, -3, -3, 0, 8, -3, -3, 1, -2, 2, 2, 6, -5, -5, -2 },
+ { -7, 12,-18, 12,-18, 10, -4, 8, 2, 4, 8, 9, 0, 3, -8, 3,
+ 6,-12, -4, 1, 25, -5, -9, 6, -7, 0, -9, -7, 3, -5, -4, -4 },
+ {-18, 12,-10, 11,-22, 0,-15, 5, -2, 2, -3, 6, -4, -4, -3,-15,
+ -2, -3, 21, 6,-12,-11, 19, 3, 3,-14, 7, 0,-11,-22,-10, 0 },
+ {-15, 2,-30, 15,-17, 13,-16, 8, -7, 10, -8, 2, 11, 3, 10, -7,
+ 7,-22, 12,-10, 3,-12, 6,-10, 12,-10, 7, -8, 5, 2, 9, 1 },
+ { -9, 11,-14, 6,-10, 21, 5, 12, -5, 5, 7, 21, 6, 2, -2, -1,
+ -1, 4, 2,-20,-18, -1,-14, 3, -1, 4, -7, 10, 1, 11, 4, -4 },
+ {-22, 8,-30, 13,-21, -4, 4, -1, 12, 9, -2, -3, 2, -6, 4,-13,
+ -2, 8, 8, 1, -7, 3, -4, -5, -1, -7, -2, 8, 8, 7, 8, 0 },
+ { -6, -4,-35, 16,-13, 15,-11, 14, -7, 9, -1, 11, 7, 0, 13, 10,
+ -1, 8, 1, 1, -2, 8, -1, 2, 2, 3,-10, -1, 7,-13, -3, -7 },
+ {-15, 7,-16, 14,-18, 17, -6, 14, 3, 4, 7, -3, 10,-22, 5,-15,
+ 4, -4,-11, 15,-15, 11,-11, 20, 1, 0, 2, 1, 11, -3, 11, -7 },
+ {-12, 3, 5, 16,-37, -1, 15, 15,-15, 10, 3,-10, 1, 15, 7,-15,
+ -13, 8, 9, -3, 2, 12, -8, 2, -5, 0, -3, 4, 5, -9, -4, 5 },
+ {-16, 26, -4, 14,-22, 26, 6, -3, -8, 4, 21, 6, 16, -4,-11, 7,
+ -10, 3, 3, 7, -4, 2, -9, 8, -2, 2, 5, -2, -4, -2, 7, -1 },
+ { -7,-10, 4, 3, 2, -4,-12,-10, -4, -5, 16, 19,-16, 1, 2, -9,
+ -10, 0, 9, 7, -8, 3, 12, 8, -6,-11,-13, -1, -3,-20, 6, -5 },
+ {-14,-17, 3, -5, 14,-12,-12, 8, -6,-25, 21, 21, 10, -8,-12, 4,
+ 10, -4, 3, -9, 11, 9, 0, 4, 2,-15, 1,-14, 4, 1, 0, -4 },
+ { -4, -9, -3, -1, 6, 3, -6, 6,-10, -4, 14, 8, 2, -3,-12,-19,
+ 0, 11,-20, 1, 6, -2,-27, -6, 10,-17,-14,-17, -9, 8, -8, 3 },
+ {-12,-13, 16, -4, -2, 12, -7,-11, 2,-13, 3, 7,-16,-18, -1,-12,
+ -2, 1,-12, -9, -2, -6, 2, 9,-22, -3, -4,-14, -7, 7, -1, 2 },
+ { -7, -8, -8, 15, 15, 18, 15, 16, -4,-37, 11, 15,-12, -1, -3, 3,
+ 6, 6, 0, -5, -3, -5, 9, 1, 1,-11, -1, -8, -6, 2, 3, 0 },
+ { -6, 7, -5,-12, 13, 10,-18, -4, -3,-21, 6, 16,-15, -7,-12, -9,
+ 1,-12, -1, 10, -2, -1, -3, 4, -4, 1,-16, -1, 12, -9, 5, 9 },
+ {-14, -5, 9, 3, 4, 26,-28, 3, -6,-24, 4, 5, 3, 13, 5, -1,
+ 3, -1, 3, 1, 1, -5, 3, 0, -7, -8, -7, -3, 3, -5, 4, 0 },
+ { -4, 2,-10, -6, 25, 26, -6, 10, -6, -8, 15, 11, -6, -3, 2, -7,
+ 5, 14, 9, -1, 0,-12, 4, -4,-10, 1, -3, 3, -2, -2, -6, -1 },
+ {-10, 8,-15,-10, 19, 17, -8, 0, -3, -7, 7, 5,-13, -1, 7, -7,
+ 1, 13,-12,-13, 17,-12, 1, 26,-18, -3, -5, -6, 4, 5, 8, 1 },
+ { 2, -5, 3, 0, 0, 0, 2, -3, -2, -5, 7, 13, -4, 9, 0, -5,
+ 4, -1,-11, -8, -4, 0,-13, 2,-47,-23, -8,-11, -4, 4, -2, -3 },
+ {-18, -4, 4, 5, -1, 17,-12, -8, 1,-12, 7, 20,-12, 3, -2,-11,
+ 16, 12, -6, 1,-13,-16, -6, -3, -3, -5, 4,-12, -5, -9, 10, 1 },
+ {-11, 0, 4, 7, 7, 8, 3, -1, 3,-19, 32, 8,-19, -8, 2, 4,
+ -12, 15,-16, 3, 1, 9, -2, 1, -2, 8, 5, 6, -4, -1, 11, -8 },
+ { 3, -1, 4, -2, 14, 32, -9,-23,-10,-12, 22, 15, -1, -2, 10, 0,
+ 4, 6, -8, 4,-15, -2, -1, -4, 0, -8, 4, 1, -8, 3, 4, 1 },
+ {-17,-12, 6, -8, 16, 13,-20, -8, -1,-16, 10, 21,-19, 11, -9, -5,
+ 7, 18, -6, 7, -7,-18, 13, 2, -2, 8,-12, -9, 2, 4, -5, 16 },
+ { 4, 0, 17,-11, 12, 7,-12, 5, -1,-25, 30, -8, -7, -6, -4, -7,
+ 9, 8, 7, 3, 3,-16, 8, 0, -2, -2,-18, -3, -4, -5, 1, 4 },
+ { -3, -6, 6,-16, 17, 6, -3, 2, -9,-17, 12, 11, 11, 2,-20, 8,
+ 1, 1, 0, 2, -2, -6,-21,-13, -9,-15, -1, -8, -6, -8, 0, -2 },
+ {-11, -7, 6, -9, 3, 6, 8, 16, 4, -5, 23, 26,-10, -3, 4, 0,
+ 2, 2, -4, 4, -2,-12, 12, 10,-11, 0,-10,-16, 3, 0, 0,-10 },
+ { -5,-16, 10, -6, 27, 13, -3, 4, -2,-13, 15, 5, 2, 5, 3, -4,
+ 13, 12,-11, -7, 0, 1, 11, 12, 2, 13,-15, -8, 9, -2, 3, 8 },
+ { -5, -8, 4, 3, 9, 3,-11, 10, 14,-25, 14, 8, -2, 5,-12,-21,
+ 2, 10, -7, 2, -3, 2, 0, 2, -1, -3, -5, -6, -1,-16, 2, 8 },
+ { -1, 5, 1,-11, 5, 9, -7, 8,-13,-12, 4, 12, -4, 1, -1, -1,
+ 27, 29, 10, 15, 2, -6, -3, 4,-21, 10, -9,-11, -6, -1, -9, -3 },
+ { -6, -3, -1, -6, 11, -5, 0, -2, -5,-31, 11, 3, -1, 5, -3, 4,
+ 5, 7,-10, 5,-10,-13, 4, 12,-15, -2, 2, -7, 1, -9, -3,-10 },
+ { -3, -7, 17, -8, -5, 36, 8, -7, -8,-20, 12, 8, 1, -1, 3, 0,
+ 1, 4,-10, 3, 1, 4, -2, -3, -2, -3,-10, 4, -1, -7, 3, 2 },
+ {-13, -3, -5, 9, 22, 6,-23, 3,-10, -7, 17, 17, 18,-14, -8, -8,
+ 2, 4, -8, 2, -3, -8, 6, 4, -1, 7, 0, 0, -3, 0,-12, -3 },
+ { -3,-10,-15, -3, 9, 3,-23, -9,-13,-18, 12, 13, -2, 0, 1, 8,
+ -1, 2, -7,-12, -5, 14, 2, 1,-22, 6,-10, -8, -9, 28, -7,-14 },
+ { -3, 1, 2, -1, 13, 7, -2, -7, 1, -3, 6, 9, -3, -2, 4, -2,
+ 2, 1,-10, -2, -2,-22, -2, -7,-10, -5,-11,-27,-12,-16, 4, -7 },
+ { 2, -6, -3, 1, 8, 0, -2, 12, -3, -4, 58, 15,-10, -4, -2, 2,
+ -2, 0, -2, -6, 2, 4, -1, 1, -4, 1, -1, -5, -4, -3, 3, 1 },
+ { 10, -1, 0, 5, 21, 7,-14, 6, -3,-16, 15, 17,-16, 13, 3, -6,
+ -4, 6,-12, -5, 1, -4, -7, -8, 2, 3, -6, 6, -1, -8, 5, 4 },
+ { -6, -2, -8,-11, 15, 10, 0, 8, -6,-15, 33, 8, -2, 18,-15,-11,
+ 5, -1, 0, 15,-15, -4, -4, -1, 10, 7,-13, 4, -4, 0, 8, 3 },
+ { -7, -2, 0, -2, 0, -2, -4, -5,-14,-16, 12, 38, 7, 12, 6, -4,
+ 0, -1, 0, 3, -2, -6, 0, 2, -9, 1, 0, -1, 0, -2, 4, 1 },
+ { -8, -4, 18, 1, 14, 5,-12, -3, 20,-17, 5, 19,-11, -8, 11, -3,
+ 3, 9, -7, -8, 9,-17, 2, 15,-10,-11, 5, -5, 7, 15, -6, -2 },
+ { -7, 2, 38, 5, 19, 16, -5, 4,-13,-20, 0, 4, -4, 6, 4, 2,
+ -7, 6, -8, -2, -5, -7, 6, 3, -4, -3, -2, -3, 7, -6, -4, 0 },
+ {-11,-12, 8,-15, -3, 14, -7,-22,-11, 2, 22, 14,-19, 2,-19, -6,
+ 1, 3,-18, 14, 2, -6, -2, -8, -3, -6, 5, -7, -8, -4, 1, 1 },
+ { 8, 7, 25,-21, 12, -6, -5, -4,-10, 6, 0, 10, 1,-12, 18, -5,
+ -15, 4, 1, 14, -1, 5, 8, -7, 1, -7, -3, 9, 10, 1, -1, 0 },
+ { 9, 10, 32,-15, 8, 2, 11, -7,-18, -8, 2, -6, -9,-16, -3, 3,
+ -1, 3, 1, -5, 4, -2, 1, -8, 0, -6, -3,-11, 1, 5, 0, 0 },
+ { 14, 0, 23,-25, 22, 3, 7, 10, 0, -2, 7, 8, 0, 10, 0, 0,
+ 3, 2, 3,-10, 0, 10, 0, -7, 0, 10, -1, -5, -7, 1, -1, 2 },
+ { 12, 0, 25,-18, -5, -4, 13,-10, 3, -6, 7, 21, 0,-16, 3,-10,
+ -6, 5, -7, -3, 2, 5, 3, -6, 4, 9, -8, 12, -2, 3, 2, 4 },
+ { 31, 15, 27,-20, 10, -7, 15,-10, 9, -8, 4, -5, 3, -3, 5, 6,
+ 11, -2,-12, -2, 6, -2, 1, 2, -1, -1, 1, 1, 3, 1, 1, 2 },
+ { 12, -4, 13,-23, 12, -6, 2, 4, -3, 13, 6, -7, 5,-19, -7, 18,
+ 1, -7, 7, 1, 16, -7, 3, 0, 3, 0,-12, 8,-11, 9, 4, 7 },
+ { 29, 1, 3,-22, -5, 6, 0, 12,-14, 11, 1, 6, -3, 4, 6, -2,
+ 4,-13, 12, 1, 1, 3,-11, 9,-10, -1, -7, 16,-11, -1, 3, 9 },
+ { 4, 4, 36,-23, -5, -8,-15, 1, -6, 3, 13, -1, -5, -7, 4, 9,
+ 2,-11, -3, 5, 1, 3, -6, -1, -4, -4, -2, 2, 3, -1, -5, -2 },
+ { 19, 10, 6,-17, 2, -4, -2, -4, -3, 13, 2, 2,-13, -7, -3,-11,
+ 9, -6, 1, -9, -5, 4, -5, -9,-18, -7,-11, 9, 4,-11, 8, 4 },
+ { 16, -3, 9,-16, 18, -2,-12,-16,-11, 11,-18, 16,-13, 6, 2, 8,
+ 3, 8, -4,-16, 10,-11, -1, -3, -8, 5, -9, -4, 9, -4, 0, -3 },
+ { 14, 15, 3,-23, -5, 7, -8, -6, 2, 17, 2, 12, -8,-12, 13, -1,
+ -9, 3, 1, 1, 19, 15, 4, -1, 1, 2, -3, 2, -3, 1, 5, 3 },
+ { 32, 5,-10,-47, -5, -1, 4, 11, -7, 0, 2, -2, 1, -7, 6, -4,
+ 6, 2, -4, -2, 2, -2, 0, -4, 1, -6, -5, 2, -2, -1, -3, -4 },
+ { 20, 8, 10,-21, -7, -9,-16, 12, 1, 4, 6, -5, 9,-11, -7, 4,
+ -11, 28, -3, 2, 4, -6, 10, -8, -5, -5, -9, 9, -2, -1, 6, -5 },
+ { 38, 3, 23,-25, -6,-18, 3,-10, -8, 6,-10, 1,-10, 2, 2, 0,
+ -7, 2, -4, 5, -1, 8, -3, 0, 3, 3, -1, 1, 0, -4, -4, 0 },
+ { 20, 5, 16,-22, 24,-18, 2,-12,-14, -7, -3, 10, 2, 7,-10, 2,
+ -8, 1, 8, -1, 4, 1, 4, -2, 5, -9,-18, -8,-13, 5,-11, 10 },
+ { 14, 8,-12,-16, 9,-11, -3, -6,-25, -7, 6, 5, -7,-16, 10, 2,
+ -7, -1, -9, -3, 16, 4, 3, 3, -3, -3,-15, 13, -3, 4, 13, -7 },
+ { 16, -9, 19,-23, 7,-19, -3, -5,-15, 11,-21, 21,-16, 18, -1, 6,
+ 10,-10, 18,-14, 16,-15, 6, -5, -9, 5,-17, 13,-10, 13, 0, 10 },
+ { 8, -4, 4,-24, 8,-21,-18, 9,-11, 4, -6, 17, 5, -9, -2, -2,
+ 2, 15, -2, -3, -2, 1, 7,-13, 15,-10, -8,-11, 3, 3, -1, -1 },
+ { 14, 17, 6,-32, 5,-17, -2, 0, 15, -1, -5, 16, 1, -5, -2, 9,
+ -3, 8, 4, -2, -2, -4, -3, 1, 0, 7, -3, 4, -5, 0, -7, 2 },
+ { 24, 6, 22,-12, 8, 3,-14, 4, -7, 8, 6, 5, 6, 1, 6,-12,
+ 15, 10, 4, 11, 9, 6, -7, -4, 10, -9, 2, -1, -5, 11, 15, 3 },
+ { 17, 12, 3,-23, 5, -1, -2, 1, -9, -1, -3, 1, 8, 1, -5, 17,
+ 11, 0, -2,-11, 7, 4, 0,-27, -7, 1, 2, -8, 9, 7, 5, 3 },
+ { 12, 10, 12,-10, -4, 5, -1, 2,-24, 5, -8, 2, 6,-17, 19, 5,
+ 12, -2, 16, -7, -6,-14, 4, 1, -3, 13,-16, 5, -1, 4, 1, 1 },
+ { 31, 9, 11,-17, 10, -3, -7, 7, 1, 2, 2, 4, -3, -1, 11, 4,
+ -5, -8, 1, 4, 15, -6,-28, 1, 8, 3, -6, 5, 17, -2, 2, -4 },
+ { 11, 19, 16,-26, 0, -7, -7, 2,-13,-15,-12, 9, -3, 27, 8, 4,
+ -6, 1, 4, -6, 11, -1, -6, -7, -3, 0, -6, 4, -6, -7, -3, -1 },
+ { 10, 18, 16,-32, 19, -9, -4, -3, -7, 8, 8, -3,-11, -2, -6,-16,
+ 13, 13, -6, -1, 10, -2, -2, -9, 0, -3, 9, 4, 11, -2, -6, 6 },
+ { 9, 4, 19,-33, 4, 7,-12, 36, -3, -1, 8, -2, 2, -8, -9, -4,
+ -8, 0, 1, -1, 0, -4, -4, 3, 0, 3, 6, 0, -6, 2, 0, -2 },
+ { 25, 7, 15,-12, 2,-24, -1, 24, -4, 4, 9, 0, -2, -9, 4, 6,
+ 3, 13, -3, 1, 5, -1, -3, -5, -1, 7, -2, 3, 4, 4, 1, 0 },
+ { 19, 6, 8,-20, 9, -9, 5, -4,-13, 7, 11, -3, 5,-13, -9, 6,
+ -11, -1, 0, 4, 11, 26, 3, 6, -7, 12, 6, -3, 1, -9, 7, 1 },
+ { 15, 6, 19,-23, -3, -9, 3, 16, -6, -4, 6, -5,-10, 1, 16,-14,
+ 2, 0, 2,-13, -3, 8, -6, 3, 1, 1, 2, -5, 12, -4, -8, -3 },
+ { 14, 4, 16,-20, 1, 12, 0, 6, -3, 9, 4, 16, 10,-16, 5, 7,
+ 5, -4, -4,-18, -3,-11, -4, 4, -7, 3, 13, 7, 3, 3, 2, -7 },
+ { 22, 3, -1,-30, 18, -3, -9, 9, -2, 11,-16, -2,-14, 12, 0, 4,
+ -5, 4, -1, 3,-20, 12, 4,-10, -2, -2,-12,-12, 10, 6, 11, -3 },
+ { 15, 7, 2,-21, 5, 4, 9, -9,-33, 7, 7, 3, -6,-14, -8, 10,
+ 12, 0, 2, -1, 5, 4, -2, 0, -7, 0, 2, 4, 0, 1, -3, 8 },
+ { -7, 0, 12, 3, 0, -6, 8, -4, 0, 2, 14,-15, 2, -7,-31, -3,
+ 14, 0, 14,-15, -1, -4,-15, 10, 1, -3, 1, 2, 5, 2, -8, 1 },
+ { -2, 5, 1, 0, -3, 3, 3, -6, -1, 2, -4, 1,-19, 0,-11, 18,
+ 11, 10, 21, 5, 6, 2, 10, 3, -6, 0, -2, 13, 5, -1, -2, 9 },
+ { -9, 1, -5, 0, 0,-15, 8, 4, 8, 3, 8, 12,-13, -2,-39, -2,
+ 4, -4, 5, -3, -4, 3, -3, 3, 10, 5, 3, 2, -3, 5, -2, 8 },
+ { -9, 6, 6, -8, 12,-12, 23,-18, 4,-15, -5, 2,-20, 13, -7, 7,
+ 7,-12, 14,-12, 6, 1, 1, -3, -8, 9, 0, 1, -7, 3, 7, -6 },
+ {-18, 13, 4, 3,-10,-30,-10, -6,-14, 1, -7, -4,-35, 5,-25, 11,
+ 9, 8, 19, -4, -7, -3,-18, -8, 1, 5, 10, -4,-14, -9, 3, -4 },
+ { -6, -1, 4, -9, -9, 4, 20, 0, 0, 3, 11, 7,-16,-17,-20, 11,
+ -6,-14, 1, 4, 19, 2, -8, 6,-15, 3, 6, -5,-14, 3, 7, 2 },
+ { 1, 6, -2, -8, -5, -3, 3, -8, 21, 1, 3, 16,-14, -2, -9, -4,
+ 13, -2, 18, 14, 14, 19,-13, 5,-10, 2, -3, 3, 5, 5, 1, -1 },
+ { -1, -5, -6, -2,-11, -7, 5, -4, 5, -1, 0, 3, -3, 2,-19, 18,
+ 16, 4, 14,-22, -2,-11,-22, 1, -1, 11, 1, 2, 11,-10, 7,-12 },
+ { 1, 4, 5, -1, -9, -5, 1, 12, 5, 6, 12, 9,-24, 23, 1, 20,
+ 14,-11, 13, 5, -2, -2, 5, 6, 2, 1, -9, 6, 10, 5, -4, 11 },
+ { -1, -1, 1, 7, -3, -4, 8,-16, 15, -1, -7, 9,-22,-11,-11, 10,
+ 16, 9, -2, 4, 13, 10, 6, 16, 4, 7, 1, -8, -7,-14, -7, 4 },
+ { 1, 3, -6, 0, 15, -9, -4, 0, 4, 6, 12, 9, -6, -5,-22, 17,
+ 7,-11, 15, -5, 1, 3,-19, 0,-15, -3, 16, 5, 5, -7,-11, 12 },
+ { -2, -1, 13, 2, 4,-24, 37, -5, -2, -6, 12, 7, -2,-23, -4, 9,
+ 2, -3, 3, 2, 3, 3,-14, 11, 0, -4, -2, -2, 3, 10,-10, 4 },
+ { 2, 9, 8, -6,-28, 14, 28,-11, 18,-11, 0, 2, -2, 4,-12, 3,
+ 6, 0, 7, -7, -6, 2, 5, -1, -1, -1, 5, 2, 3, 0, -3, 9 },
+ { -7, 14, 5,-10, -3, 7, 4, -5, 7, -8, -7, 4,-12, 14,-16, 25,
+ 3, 0, 1, -5, 12,-10, 0,-10, 0, 12, 12, 17, 12, 10, -1, 0 },
+ { -4, -2, 5, -2,-17, -3, 5, -5, 7,-17, 1, 5, -4, 4,-20, 0,
+ 11,-15, 13, -8, 10, 1, 1, 5,-12, 9, -8, 0, 6, -1,-11, 4 },
+ { -3, 12, 13,-15, -7, -7, 0, 5, 33, 3, 3, -6,-13, -7,-15, 10,
+ 3, 3, 3, -5, 2, 7, -1, 0,-12, 2, 11, -6, -9, 0, 5, 11 },
+ { -8, 5, 10, -7,-14, -4, 13, 0, 18, -3, -6, 7, 1, -6, 0, 21,
+ 8, -7, 10, -8, -3, 17, -9, 0, -5, 1, 4, 8, -3, 11, -5, 0 },
+ { -8, 8, -3, -8, 8,-11, 16,-16, 17, 0, 8, 16,-17, 10,-16, 10,
+ -8, 6, 11, 0, 10, 7, 4, 5, 7, -5, -5, -6, -7, -5, -1, 16 },
+ { -6, 0, 6, 1, -8, -8, 8, -7, -5,-10,-11, 8,-19, 6, -7, 13,
+ 5, -3, 4, -8, 7, -1,-18, 9, 0, -5, 6, 26, 3, 8, 2, 4 },
+ { -2, -2, 23, -2,-20, 2, 7, -7, -6,-15, 3, 9,-19, -2,-10, 7,
+ -2, 7, 9, 11, 0, 4, -4, 6, 9, -2, 4, -3, 4, 3, 2, 8 },
+ { -6, 12, 10,-10, -7, 4, 17, 11, -6, 1, 12, 11,-18, 8,-12, 4,
+ 1, 13, 6,-13, 23, 9, -5, 8, -2, -5, 1, 3, 0, -2, -4, 4 },
+ { 7, 1, 7,-17, -8, 8, -1, -7, 5, -6, 4, -3,-16, 9,-24, 18,
+ -3, 10, 13,-11, -6,-11, -4, 10, 0, 11, 8, 2, 6, -5,-11, 4 },
+ { -4, 1, -5,-10, 0, -3, 9, -2, 4, -1, 1, 5,-41,-10, -7, 4,
+ -3, 3, 1, 0,-12, 4, -3, 0, 2, -1, -2, -5, 3, 2, -7, 5 },
+ { -2, 1, 4, 4, -3, -6, 1, 0, 12, -5, 11, 0,-17, -3, -1, 11,
+ 4, 1, 27,-12, 0,-14, 2,-15, -3, -9, 0, -7, -3, 15, -8, 6 },
+ { -6, 4, 9, 2, 4, 3, 7,-10, 28, 1, -2, 48, 7, 0,-10, 10,
+ 1, -9, 2, -1, 0, 3, -5, 5, -4, -2, 7, 7, 1, 3, 2, 5 },
+ { -3, 3, -1, 3, -9, 0, -1, 3, 2, -6, 39,-14,-12, 5,-19, 21,
+ 7, -6, 4, -1, -4, 0, -4, 1, 0, -9, 1, 10, 0, -2, 0, 7 },
+ { 4, 2,-29, 12, 5, -3, 16, -6, 15,-13, -4, -1,-13, 22,-16, 17,
+ 16, 4, 9, -4, 4, -6, -4, 11, -8, 7, 8, 4, 3, -3, -7,-13 },
+ { 0, 3, 3, -6, -4, 0, 9, 0, 5, 0, 10, 10, 4,-13,-12, 16,
+ 23, -4,-12, -6, -4, 20, 2, 0, -4, 23, 1, 8, 11, -4, -5, 15 },
+ { -6, 4,-15, -9, -1,-19, 12,-30,-17, -4, 1,-13,-13, 4, -3, 26,
+ 5,-25, 11,-14, -6,-13, 0, -7, 9, 2, 8, -1, -8, 1, -8, 13 },
+ { 1, 6, 1, -4, -4, 1, 2, 0, -3, 2, 10, 6, -6, -2,-11, 4,
+ 32, 15, 15,-47, -8, 3,-12, 4, -5, 4, -1, 0, -5, 5, 1, -7 },
+ { 2, -1, 0, 0, -1, -6, 0, -6, 4, -4, 5, 9, -5, 1, -3, 51,
+ 4, -5, 4,-14, -1, -4, -3, 1, -4, -1, 0, 2, -8, 0, 1, 2 },
+ { 0, 4, -2, -7, -2, -9, 6, -8, 11, -3, -6, 3,-11, -8,-12, 8,
+ 11, 5, 19, 3,-24, 19,-14, 11, -5,-18, -8,-12, -5, -4, -1, 4 },
+ { 16, 9, 10, 14,-18, -2,-18,-27, 10, -5, 12, 14, 4, 0, -2, -6,
+ -12, -7, -1, 3, 4, 7, 11, 10, 5, -5, -7,-16, -3, -6, 6, 9 },
+ { 7, 15, -9, 10,-19, 4, -5,-37, -2, -4, 8, 2, 4, -1, 1, 9,
+ -5, -5,-12, 1, -1, -8, 3, -3, 4, 6, 9, 3, 3, -1, 2, 4 },
+ { 13, 17, 3, 9, -7, -7,-15,-17, -8,-13, -4, -8, 19, 2, 16, 25,
+ 7, 15, 2, 16, -5, -6,-10, -9, -7, -6, -2, -7, 7, 2, 4, 5 },
+ { 24, 7, 9, 8,-13, -2, 0, -4, 1,-13, 3, 6, 7, 10, -4, 15,
+ 5, 7, -4, 5, -5, 3, 13, -7, 5, 15,-11, -2, 7, 5, 8, 6 },
+ { 17, 6,-15, 23, -2, -1, -6, -2, 0, -4, 11, -3, 12, 15, 6, -8,
+ -15, 10, -9, 7, -1,-11, 2, -8, -4, 3, 4,-10, 4, 4, 11, 1 },
+ { 21, 12, -3, 6, -8, 8,-11, -8, -5, -5, 3, 7, -1, -5, 12, 15,
+ -10,-11, 3, 15, 8, 4, 2,-15, 0, 14, 1, -8, -1, 3, 10, -7 },
+ { 16, 12, 5, 13, -6, 15,-23, 0,-17, -9, 0, 4, -9, 13, 6, 18,
+ 0, 0, -4, -1, 0, 14, 5, -1, 8, -4, -8, -6, 5, -2, -2, 0 },
+ { 14, 16, -1, 12,-15, -9, -6,-20, 4, 6, 8, 9, 3, 1, -9, -4,
+ -1,-11, 9, 11,-12, 1,-14, -7, 2, -8, 11, 9, -4, 10, 4,-16 },
+ { 13, 10, 3, 7, 0, -8,-33, -6, 4, -4, 19, -2, 14, 6, 5, 7,
+ 6, -3, -1,-10,-10, -9, 4, -3, 5, 9, 2, 2, 10, 9, -2, -3 },
+ { 11, 10, 25, 18, -1, -6,-21,-21,-11,-16, 6, 5, 14, 4, 8, 7,
+ 0,-10, -7, -9, -5, -4, 3, -1, 1, 6, -1, 6, -2, 2, -3, -9 },
+ { 15, 9, 5, 22,-17, 15, -9, 7, 7, -9, 13, 9, 10, -1, 8, -3,
+ -2, 6, 1, 17, 8,-14, 7, -3, 12, 9, 1, 0, 1, -5, 17,-18 },
+ { 25, 19,-17, 12, -4,-10, 1,-13,-19, -7, -3, 9, 6, -2, 3, 1,
+ 4, -2,-11,-14, -1, -7, -5, -9, 7, -1, -3, 4, -5, 1, 0, -1 },
+ { 20, 8, -3,-10,-24, 3, -6, -2, 0,-12, 14, 6, 7, 11, 4, 7,
+ -12, -5, -8,-10, 5, -1, -4, 4, 16, 7,-14, 6, -1, -2, -7,-11 },
+ { 16, 18, 17, 1,-15, -6, -5, -3, -1,-19, 8, -2, 2, 8, 12,-19,
+ -12, 8, 0, -3, -1, -1, 4,-14, 9, -1,-12, -1, -7, 10, -3, 5 },
+ { 18, 12, -7, 7, 0, -3,-13, 0, -1, -4, 9, -2, 6, -1, 0, 1,
+ 15,-21, 1, -8, 25,-19, 13, -9, 2, 12, 5, -7, -3, -1, -3, 1 },
+ { 13, 16, -4, 9, -2, 2, -1,-19, -7, -4, 18, -6, 14, 18, -5, 4,
+ -6, -3,-19,-14, -1,-12, 10, 6, 7, 17,-12,-13,-10, -4, 5, 4 },
+ { 27, 17, 4, 14, -9, -2, -4, -8, 0, -6, 14,-11, -7, 2, -3, -3,
+ -2, -3,-13, 12, 16, 1, -5, -9,-10,-11, -2, 3, -7, 5, 11, -7 },
+ { 7, 17,-16, -2,-14,-28, -7, -8, 15,-10, 7, 15, 8, 17, 13, -1,
+ 4, -7,-12,-11, 0, 0, 2, 3, -3, 7, -6, 6, 1,-16, 1, -2 },
+ { 23, 11, -9, 15,-23, -4, -6, -4, 2, -9, -7, 9, -8, 3,-13, -4,
+ 8, 18, -6, -2, 1, -5, 6,-14, -5, -2, -6, -5, -3, -2, 4, -5 },
+ { 12, 13, 18, 18,-35, 2, 7,-17, 3,-11, 6, 9, -3, -2, 10, -4,
+ 3, 3, -2, -7, 0, 2, -4, 0, -4, 0, -6, 5, 10, 4, -3, -1 },
+ { 19, 11, 1, 20,-14, 4, -9,-13, -2, 11, 0, 17, -1, -1, -1, -1,
+ -5, -8, 0, 5, -1, -8, 5, -1, 3, 2,-12, 21, -2,-24, 5, 7 },
+ { 15, 15,-15, 17,-14,-22, 3, -4,-11, -3, -7, 1, 18, 10, 1, 10,
+ -6, -3, 8, 2, -7, 0, -2, 1, 1, 2, -9, -2, 1, 2, -3, 4 },
+ { 45, 13, 8, 17, -5, 2,-16, 2, 8, -2, 8,-15, 4, 5, -1, 7,
+ -6, -2, -6, 2, -3, 0, 0, -9, -1, 7, 2, 3, -3, -3, -1, 5 },
+ { 1, 18, -8, 18,-12,-10, 3, 4,-22,-12, 20, 8, -3, 9, 2, 10,
+ -10, -3, 9, 3, 6, -3, 10, -1, -3, 2, -2, 4, 2, 3, -3,-18 },
+ { 9, 10, -5, 9,-35,-21,-18,-16, -1,-12, -6, -7,-15,-19, 12, 4,
+ 4, 9, -7, 2, 14, 1, 4, 0, -1, 6, -7, 2, 1, 1, -4, 4 },
+ { 31, 8,-17, 35, -8, 1, -5, -6, -7, -6, 10, -2, -3, 6, 9, 3,
+ -6, -2, 3, 3, 5, -3, 0, 6, 0, 1, -5, -3, -2, -4, -1, 0 },
+ { 18, 4, -8, 7, -8,-15, -1,-16, 12, 18, 3, 19, 2, 4, 8, 8,
+ 0, -5, -8,-12, 10, -5, 0, 1, 0, 4, -3, 16, 11, 11, -2, -6 },
+ { 27, 15,-17,-10,-23,-22, -1,-14, -4, -7, 20, -2, -7, 6, 15, -5,
+ 32, 4, 9,-11, -3, -8, 11, -4, -1, -4, -8, -6, -4, -5, -2, -7 },
+ { 22, 4, -7, 2,-15,-11,-17,-10, 2, 0, 15, 11, 7, 12, -8, 6,
+ -10,-18, -6,-12, 7, 3, 22, 3, -7, 14, -5, -2,-13, -7, -1, -7 },
+ { 18, 13, 9, 24, -4,-19, -9,-11, 13, 8, 2, 4, -1, 8, 14, 10,
+ -12, 0, 0, 5, 10, 5, 4, -1, 5, 1, -1, 11, 2, -4, 0, -9 },
+ { 15, 19, -5, 1, -4,-10, -8,-27, 6, 8, 5, 10, 4, 11, 5, -5,
+ -11, 0,-11,-14, -4, -9, -8, -8, 6, -9, 4, -5, -1, 1, 5, -4 },
+ { 18, 1,-13, 14,-14, 9,-15, -7, 12, 1, 13, -4,-20, 12, 10, 12,
+ -12, 7, 1,-13, 10, -6, 5, -3, 4, 8, 10,-13, -3, -6, 9, -3 },
+ { 19,-14, 5, -8, -6, 2, -5, 5, -3, -1,-28, 11, 18, -6, -4, -2,
+ 11, 14,-43,-42, 9, 2, 20,-23, 6, 32, 0, 5, 0, 6, 9, 5 },
+ { 8, 11,-14, -1, 7, 12, -7, 2,-16, 2, 10, -3, -1, -7, -7, -1,
+ 1,-10,-60,-23,-18, 42,-13, 9, 18,-11, 0, 1, 0, 2, -5, 1 },
+ { -5, -1, 2, 0, 3, -3, 3, -2, -6, 0, -3, -3, 7, 2, 0, -2,
+ -2, 3,-34,-15, 37, 47, 10, 20, 9, 1, 3,-21,-25,-33,-14, 8 },
+ { 5, 6, 2, -2, -2, -2, 6, 5, -5, 7, -3, 1, -5,-13, 9, 3,
+ -17,-19, -2,-79,-12, -7, -8, -6, -2, -2, -1, -1, -7,-13, 6, -1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1,
+ 0, 3, 4,-87, 6,-11, 16, -9, -1, 8, 0, 5, 0, 1, 2, 1 },
+ { -5, 6, 2,-24, 5, -9, -7, 0, 7, 3, -3, 16,-14,-16, 0, 18,
+ 15, -9,-14,-28,-17, 53, 14, -6,-28, -1, -3,-10, -7,-14, 19,-15 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0,
+ -13, 0,-53, 3,-22, 63, 19, 16, 1,-11, 0, -3, 0, -3, 0, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
+ -1, -6,-43,-43, -2, 65,-13, -4, 9, 1, 1, 2, 1, 0, 0, 1 },
+ { 0, 1, 0, 0, -1, 0, 1, 1, 0, 0, 1, 2, -1, -1, -3, -1,
+ -23, 1,-61,-55, 3,-28, -6, -4, -4, 8, 2, 1, 1, -1, 0, 0 },
+ { 0, 1, -1, 1, -1, 0, -1, 0, 1, -1, 0, 1, -1, 0, -9, -4,
+ -48,-19,-52,-46, 11,-12, 5,-14, 0,-10, 0, 0, -1, -2, -1, 0 },
+ { 0, -3, -1, -4, 2, -1, -7, 3, 1, 3, -1, 1, -3, 0, -7, 0,
+ 3, -7,-61,-51, -4,-21,-16,-21,-11, 14, -7, 8, 3, -5, 1, 2 },
+ { 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 9, -3,
+ 56,-11, -6,-67, -1, 13, 0, 7, 1, -9, -1, -1, 0, 0, 1, 0 },
+ { 14, 9, -2, 14,-10,-10, 9, -5, 1, -8,-23, 30, 8, -7, 23, 8,
+ 2, 10, -1,-27,-17, 57, 22, 4, -5, 2,-12, -6, 2, -7, -4, -9 },
+ { 1, 5, 12, -2, -2, -3, 2, -3, 6, 0, 4, -2, -8, -6, 0, 16,
+ -15, 29,-55,-29,-24, 29, 3, 10, 6, 13, 10, -5, 21, 11,-14, 5 },
+ { 4, 2, 26, -6, 10, 11,-23,-10,-27,-20, 3,-24,-11,-10,-13, 25,
+ -10, 5, -9,-36, -7, 43, 3,-13, 6, 13, -2, 0, 1, 3, -3, -4 },
+ { -1, 0, -1, 0, 0, 0, 0, -1, 1, 0, -1, 0, 0, 0, -1, 1,
+ -12, 12,-26,-64,-15, 29, 37, -7, -3,-12, -5, 14, 8, -8,-10, -2 },
+ { 19, -4,-11,-16, 8, 14, 5, 19, 3, 22,-11,-21, -1, -6,-11, 11,
+ 10,-24,-23,-40, -8, 20, 17, 5, 13, -6, 3, 14,-20, -8, 3, 28 },
+ { 2,-12, 10,-14,-18, 26,-22, 4, -2, 5,-21, 8, 3, 1, 19, 0,
+ -12, 24,-14,-40, 15, 29,-15, 6, 15, 1,-19, 2, 4, 7,-12, -3 },
+ { 0, 17, 13, 7, -5,-11, 2,-19, 3, 38,-21, -3, -6, -4, 7, 1,
+ 1, -5,-40,-10, -2, 35, 8, 8,-10, -8, -9, 33, 4, 4, 0, -2 },
+ { -2,-12, 7, 29,-24, 2, 16, -1, -7, 16, 10, -2, -2, -2, 13, -2,
+ -37, 15,-22,-40,-11, 33, 10, -1, 8, 10, 6, 8, 9, 0,-12, 2 },
+ { 15, -8, -9, -2, 7,-17, 7, 19, 14, 4, 12, 27, 11, 10, 4, 11,
+ -15, 14,-13,-48, 5, 18, 0, -9,-36,-11, 2, 4, 5, 5,-15,-12 },
+ {-12, 0, 3, 4, 7, -5, 5,-14,-24,-18, -6,-15, -8,-20, 1, -7,
+ -33,-28,-40,-38,-18,-10, -5, 17,-12, 4, 3, -5, 5,-13, 4, -7 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
+ -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
+ -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
+ 3, -2, 9,-29,-11, 55, 8, 32,-36,-13, -7, 37, 4, 11, 0, 3 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 4, -1,-39, -4,-30, 63, 28,-17, -6, 10, 7,-14, -9, 11, 9, 7 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
+ 13, -2,-50,-32, 22, 51, 4, 7, 6, 11,-20,-13, 9, -5, 21, -4 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
+ -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
+ -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
+ 3, -2, 9,-29,-11, 55, 8, 32,-36,-13, -7, 37, 4, 11, 0, 3 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 4, -1,-39, -4,-30, 63, 28,-17, -6, 10, 7,-14, -9, 11, 9, 7 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
+ 13, -2,-50,-32, 22, 51, 4, 7, 6, 11,-20,-13, 9, -5, 21, -4 },
+ { -8, 2, 1, 22,-31, -6,-25, -3, -3, 1,-15,-11, -2, -3, 4,-13,
+ -9, 15,-18, 37, -7,-37, 12,-13,-11,-25,-10,-11,-22, 7, 16, 7 },
+ { 14, 10, 4,-10, -1, -5, -7, -3, 16, 13, -5,-15, 5, 11, -1, 8,
+ -27, 7,-12, 49, 17,-22, 9, -2, -9, -1, 2,-15, -1, 41,-18,-17 },
+ { -4, -9,-15, -3, 3, 4, 4, 2, 7, -3, -7, -8, -5, 17,-19, -7,
+ 36, -9,-38, 17, 1,-48, 11,-18,-13, -2, -8, 4,-10, -5, 21, 11 },
+ { 15,-13, 4, 2, 1, -5, -2, 1,-10, 7, -1, 3, -6, 0, 11,-11,
+ 8, 20,-17, 51,-17,-41, 2, 15, 4, 8, -2, 16,-32, -1, 17, 6 },
+ { -8, 8,-18, -5, 4, 6, -3, 8, 0, -4, 2, 0, -1, -4, 5, 8,
+ 30, 30, -8, 70, 2, 8, 2, 0, 7, 1, 13, -1, -6, -7,-11, 2 },
+ { -8, -7, 9,-10,-13, 6,-11,-14, 13, 25,-26, 5, 2, -5, -5, 5,
+ -8, 4, 0, 33, 12,-38, -4, 6, 13, 6, 25, 34, -1, 25,-19, -5 },
+ { 18, 3,-17, 4, -8, 7, 20, 1, -1, 5, -5, -2, -8, 8,-35, 15,
+ 24, 43, -5, 51, 5,-12, -3, 1, -2, 3, -3, -3, -9, 8, -9, 2 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 2, 10, 24, 76, -2,-22, 11, -1, 4, 33, 4, 1, -1, 1, 2, 0 },
+ { 0, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0,
+ 24, 13, 32, 70, 26, 5,-21, -9, -6,-15, 2, -2, 2, 4, 1, 1 },
+ { 5, -4,-11, 4, -4, 22, 10, -2, 13,-11, -4,-21,-17, 0, -7, 4,
+ 10,-34, 11, 52, 2,-46, -5, 0, 0, -1, 2, 4, -9, 1, 1, -7 },
+ { 0, 1, 1, 0, -1, 0, 1, 0, 1, 1, 0, 1, 0, 0, -3, 1,
+ -8, 9, -1, 64,-13,-61, -3, 3, -5, 10, 1, 3, -1, -1, -1, -1 },
+ { 0, 1, 0, -1, 0, -1, 0, 0, 1, 0, 0, 0, 1, 1, 2, 1,
+ 10, -2,-31, 79,-10, 27, 0, -1, 3, 8, 1, 1, 0, -1, 0, -1 },
+ { 3, 12, 10, 26,-19, 10, -9, 6, -4,-15, 10, 3,-16, 6, 11,-19,
+ 3, 10, 18, 44, 5,-30, 5, -9, 21, 4, 20, 10, 14,-25, 8,-17 },
+ { 0, 0, 0, 1, -1, 0, -1, 0, 1, 0, 1, 1, 0, 0, -6, -2,
+ 8, -8, 13, 69, 26,-19,-25,-17, 16, 6,-12, 22, 2, -6, 9, 5 },
+ { 0, -1, 0, 1, 0, -1, -1, 0, 0, 1, -2, 1, 0, 0, -4, -1,
+ -34,-15,-33, 56, 9,-42, 9, 10, 6, 9, -8,-11, 0, -6, 15, 5 },
+ { 10, 2,-14, -3,-15,-35, -1, 7,-18, 14, 8, -1,-15,-26, 6,-15,
+ -18, 22, 9, 33, 0,-32, -9, 3,-11, 7, 4, -1, 5, 30, 9, 1 },
+ { 4, 15, 0, 6, -5,-11, 9, 6, 6, 6, 14, 2, -1, 10,-24,-25,
+ -2, -4, -1, 37, 2,-29, 14, -9, 22, 17, -2, 33, 10,-25, 11,-11 },
+ { 0, 5, 2, 18,-12, 21, 22, 33, -7, 21, -9, -7, 7,-15, -7, 16,
+ 7, 0,-14, 44, 10,-25, 5, -4, 15, -8, 10, -4, 5, 9, -1, 16 },
+ { 3, 13, 12, 12, 8, 25,-23, 8,-22, -3,-18, -8, 15, 12, 9, 19,
+ 0, 0, -9, 49,-27,-15, -9,-15, 12, -8,-16, -7, 13, 5, 13, 2 },
+ { 12, -6, 7, -2, 20, -9,-14, 12, 13, -5,-17, 22, -8, -4, 2, 7,
+ -13, -2,-15, 43, -5,-30, 27, 4, 10,-27, 5, 27,-10,-10,-18, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, 10,-18, 70, -2,-52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, 10,-18, 70, -2,-52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 15,-13,-20, 16, 2, 13, 5,-11, -8, -5, -3, 2, 24,-23, 30, -7,
+ 11, 30,-15, 43, 5,-15, 15, -3,-14, 1,-23, 8, 3, 9, 4,-11 },
+ { 0, -1, 0, 1, 0, -1, -1, 0, 0, 1, -2, 1, 0, 0, -4, -1,
+ -34,-15,-33, 56, 9,-42, 9, 10, 6, 9, -8,-11, 0, -6, 15, 5 },
+ { 10, 2,-14, -3,-15,-35, -1, 7,-18, 14, 8, -1,-15,-26, 6,-15,
+ -18, 22, 9, 33, 0,-32, -9, 3,-11, 7, 4, -1, 5, 30, 9, 1 },
+ { 4, 15, 0, 6, -5,-11, 9, 6, 6, 6, 14, 2, -1, 10,-24,-25,
+ -2, -4, -1, 37, 2,-29, 14, -9, 22, 17, -2, 33, 10,-25, 11,-11 },
+ { 0, 5, 2, 18,-12, 21, 22, 33, -7, 21, -9, -7, 7,-15, -7, 16,
+ 7, 0,-14, 44, 10,-25, 5, -4, 15, -8, 10, -4, 5, 9, -1, 16 },
+ { 3, 13, 12, 12, 8, 25,-23, 8,-22, -3,-18, -8, 15, 12, 9, 19,
+ 0, 0, -9, 49,-27,-15, -9,-15, 12, -8,-16, -7, 13, 5, 13, 2 },
+ { 12, -6, 7, -2, 20, -9,-14, 12, 13, -5,-17, 22, -8, -4, 2, 7,
+ -13, -2,-15, 43, -5,-30, 27, 4, 10,-27, 5, 27,-10,-10,-18, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, 10,-18, 70, -2,-52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ -1, 10,-18, 70, -2,-52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 15,-13,-20, 16, 2, 13, 5,-11, -8, -5, -3, 2, 24,-23, 30, -7,
+ 11, 30,-15, 43, 5,-15, 15, -3,-14, 1,-23, 8, 3, 9, 4,-11 },
+ { 16,-18, 7, -4, 31,-15, -9,-13, 20,-12, -6, 0, 12, -6, -2, 4,
+ 3, -3, -1, 0, 1, 3, 3, -2, 1, 6, 4, 0, -3, 2, -5, 1 },
+ { 38, -5,-13, -4, 8,-15, 11, 1, 2, -4, -1, 9, 13, 4,-12, -7,
+ 0, -2, 7, 2, -6, -2, -3, -2, 3, -4, 6, 15, 1, 1,-11, -2 },
+ { 47,-22, 9,-26, 3, -5, 2, -7, 4, -2, 2, -2, 3, 0, 3, -4,
+ 3, -3, 2, -3, 7, -3, -1, 1, 1, -5, 5, 0, 2, -5, -3, -2 },
+ { 14,-16, 2, -6, 7, -2, -7, -4, -4, -7, 14, -3, 7,-19,-14,-17,
+ -29, 6, 26, 16, -5, 13, -4, -1, 21, 14, 1, 3, -6, 0, -7, -1 },
+ { 29,-11, 5, -3, 4, 11, 4,-10, 1,-22, -3,-10, 5, 4, 2, 8,
+ -2, -7,-12,-12, -8, -3,-18, -2, -9, -5, -1, -3, 2,-14,-14, 7 },
+ { 28,-12, 5, 3, 9, -7, 0, -2, 2, 1, 4, 0, -7, -3, -2, 4,
+ 4, 14, 8, -1, -4, 14, -7, 17, -2, -2, -9, 2, 19, -7, 9, -8 },
+ { 31,-18,-22, 8, 15, -5,-10,-15, 1, 10, 6, 7, 6, -8, 2, -1,
+ 12, -3, 3, -1, 1, 5, -6, -4, 0, 1, 7,-10, -2, 4, -3, -4 },
+ { 53,-30, -4, 12, 2, 3, -3, -3, 0, 1, 6, 5, -5, -4, -7, 1,
+ 0, 2, 1, 3, 1, 5, 0, 2, 2, -1, 0, 4, 2, 0, -2, 0 },
+ { 27,-18, -3, -2, 4, -8, 3, -2,-11, 2, 10, -8, -8, -4, 0, -2,
+ 8, 0, 9, 0,-16, 11, 1, -6, 13, -3,-10,-13,-15, 25, 1, 0 },
+ { 35, -5, -1, -8, 23, 11,-14, -3, 2, -2, 8, -6, 17, -2, 7, 0,
+ -2, 10,-17, 13, -2, -2, 11, 11,-14, 2, -2, -3, -8, -1,-12, -5 },
+ { 29, -9, 7, 3, 2,-10, 0, 3, 9, 0, -3, 5, 1,-10, 10, -5,
+ 3, 6,-20, -9, -6, -4, 1, 0, 12, 17, -8, 9, 3, -1, -9, 0 },
+ { 15,-16, 18,-19, 16,-15, 17,-18, 13,-16, 17,-14, 15, -9, 13,-17,
+ 9, -7, 4, -5, 3, -4, -3, 0, -6, 7, -9, 7, -2, 7, -9, 9 },
+ { 21,-10, 7, -2, 12, -7, 13,-17, 11, -2, 20, 3, 5,-11, -6, -6,
+ -15, 0, -9, 5,-11, 7, -1, 7, 8,-10, -9, 3, -5, 9, -8, -2 },
+ { 23,-22, 15, -5, 16, -4, -3,-12, 9, 3, -1, -2, -8, 2, -2,-16,
+ 3, 4, -2, -6, -7, 12, -8, 2,-14, 2, -7, 11, -2, 6, -4, -1 },
+ { 34,-17, -4, 8, 4, -6, 1, 8, 4, 16, 3, 6, 12, -1, -1,-15,
+ 6, 4, -7, -6, 6, 0, 2, 1, -2, 2, 3, 3, -3, -2, 8, -6 },
+ { 18,-18, 2, -2, 10, 1, 18,-23, -3,-10, 0, 4, 20,-19, -3, -4,
+ 2, 8, 6, 1, -3, 1, 1, 3, 5, -1,-11, 3, -7, 5, -1, 1 },
+ { 15,-14, 2, 3, 10, -8, 12,-13, 13,-15, 6, -8, -4,-10, 14, -9,
+ 24, 2, -7,-18, 13,-11, 8, 14, -6, -2, 3, -1, -4, 7, -7, -4 },
+ { 20,-12, 13, 5, -1,-10, 15, -6, 8, -1, -3,-10, 17, 0, -6,-19,
+ 2, -1, 8, -3,-16, 0, -3, 2, -2, 0, 8, -9, 0, 1,-10, -9 },
+ { 32, 0, -9, -5, -1, 5, 13,-11, 8, 3, 11,-11, 0, -8, -2,-14,
+ 7, 10, 6, -5, 1, 10, 2, 12,-10, 4, 4, 6, 4, 0, -7,-10 },
+ { 16,-14, 10, -7, 11,-11, 11,-11, 18,-13, 8,-15, 16,-11, 13, -9,
+ 8, -7, 12,-11, 7, -6, 3, -5, 9, -5, 4, -1, 7, -4, 8, -3 },
+ { 24,-27, -1, 5, 8, -5, 12, 7, 4, -3, 3, -1, -9,-11,-13, -5,
+ 10, 0,-13, 7, 1, -5, 4, -9, 7, -3, 13, 2, -5, -3,-17, -2 },
+ { 23,-19, 15, 1,-10,-18,-12, -6, 8, -3, 12, 0,-12,-10, -4, -4,
+ 8,-10, 4, 2, -2, -8, 13, -3, -2, -6, 2, -3, 5, -2, 2, 11 },
+ { 25,-12, 4, 2, 24, -3, 3, -6, 14, 11, 0,-21, -3, -3, 1, -8,
+ 7, 0, 0, 3, 3, -6, -7, 6, 2, 1, -4, 5, -1, 10, -2, 9 },
+ { 24, -8, -6, 7, 16,-12, 13, -1, 11,-21, 2, -6, 3,-12, 0, 9,
+ 4, 11, -7, 1, 4, 1, -8, 3, 3, -6, 3, 3, 0, -8, 8, 4 },
+ { 25,-21, 13, 14, 13,-18, 4, -3, 0, -5, -4, 5, -3, 0, 4, 12,
+ 7, 3, 5, -5, 2, -2, 3,-10, 2, -9,-15, 6, 1, 7, -5, 1 },
+ { 23,-16, -2, 10, 4, -1, 3, 1, 32, 3, -5, -2, 9, 10, -1, -4,
+ -6, 2, 9, -1, 14, 12, -6, -1,-17, -2, -4, -9, -7, -6, -8, 3 },
+ { 50, -8, 5, 2,-11, 10, 0, 0, 6, -3, 7, 0, -3, -2, -3, 0,
+ 6, -4, 2, -5, -9, 0, 3, 10, 1, -7, -2, -3, -6, -9, 1, -2 },
+ { 28,-17, 0, -2, 2, -9, 1, 5, -4, -1, 0, 0, 19,-27, 5,-12,
+ 7,-14, -3, -6, 10, -2, -4, -2, 4, -5, -2, -7, 1, 7, -9, 4 },
+ { 22,-19, -6, -6, 3,-22, 3, 5, 20, -8,-14, -5, 1, 1, 20, 2,
+ 16, 6, 3, 14, 4, 3, 5, 1, 5, -7,-10, -6, 3, -6, 1,-14 },
+ { 29,-14, -8, 13, 8,-10, -6, 4, 4, -6, 5, -7, 1, 12, 14, 11,
+ -7, 1, 2, -9,-11, -9, 0, 4, -1, 7, 10, 4, 4, 20, -1,-11 },
+ { 18, -9, 4, 1, 7,-29, 12, 1, -1, -9, -2, -1, -2, 2, 9, -8,
+ -13, 5, 4,-13, -4, 2, -5, -7, -6, 14,-10,-34, -3, 1, -3,-13 },
+ { 38, -9, 24, 8, 11, 4, -6,-11, -2,-12, 1, 1,-11, -8, -5, -2,
+ -15, -8, 8, 0, 1, -7, 5, 4, -1, 8, -2, 11, -3, -1, -5, -5 },
+ {-20, 11, -4, 24,-11, 1, 15, 4, 0,-28,-10, -1, 10, 10, -6, 5,
+ -6, 2, 7, -2, 1, -2, -6, -3, -7, 1, 2, 12, -1, 7, 0, -2 },
+ { -9, 10,-23, 27, -4,-17, 20, -6, 14,-17, 5, -1, 5, -9, -7, 5,
+ -6, 4, -2, 9, 0, 8, 0, 1, -3, -3, -5, -8, 5, -2, -2, 12 },
+ {-10, 19, 4, 9, 1,-16, 17, -2, 9,-29,-16,-11, -4, 7, -5, 4,
+ -1, -3, 3, 2, 3, -4, 5,-12, -2, 6, 5, -4, 4, 1, 4, 10 },
+ {-20, 10,-24, 14, -5, 11, 9, 0, 16,-20, 10, -5, -6, -6, -1, 2,
+ -4, 5,-16, 8, -2, 5, 5,-11, 9,-11, 4,-11, -1, -1, 4, 3 },
+ { -9, 11, 3, 19, 24, 4, 5,-14, 30,-17, -4, -2,-17, 7, 2, 3,
+ 1, 3, -7, -4, 2, -3, 1, 4, -1, -1, 3,-12, -2, 3, -3, 10 },
+ {-19, 18, 11, 19, 19, 19, 10, 4, 13, 6, 5, 4, 8, 3, -2, 12,
+ -6, -2, 7, -6, 15, 12, 16, 16, 18, -3, -4,-20, 0, 10, -9, -3 },
+ {-21, 9, 20, 12, 0, -3, 5, -9, 15,-13, 5, -5, -6, 24, 2, 9,
+ -5, 2, -7, 2, 5, 7, -5, 2, 15, 3, 1, -1, -4, -2, 7, 0 },
+ {-18, 16, 13, 15, 2,-10, 14,-11, 4,-11, 5, 12, 12, 20, 8, 30,
+ 2, 11, -9, 7, 0, -3,-16, -5, -6, 5, -4,-21, 0, 5, 6, 1 },
+ {-26, 8,-13, 9, 6,-10, 2,-11, 7, -4, 6,-19,-11, -6,-12, 16,
+ 0, 5, -7, 8, 5, 6, 17, -9, 10,-10, 5, -3,-11, 2, 4, 10 },
+ {-11, 17, -3, 22, -5, 18, 3, 1, 4, -5, 14,-27, 5, -7, -4, -5,
+ -10, 11, 1, 15, 1, 1, -6, -5, 10,-22, -7, -7,-15, 13, -4, 5 },
+ {-17, 14, -7, 13, 3, 0, 13, -6, 9,-14,-22, -1, 1, 19, 14, -3,
+ 4,-13,-13, 2, -4, 8, -2, -2, 13,-12, 13,-12, -7, -5, -3, 6 },
+ {-17, 17, -1, 33, 6, 3, 9,-16, 3,-14, -8, 6,-17, 8, 3, 13,
+ 8, -6, 3, 1, -2, 0, -2, 8, 4, 9, 13,-10, 4,-17, 0, -6 },
+ {-20, 7, 7, 21, 1, -3, 7, -3, -2,-12, 9, -7, 2, -3, 14, 1,
+ -1, -7, 12,-10, 5,-20, 11, -2, 0,-24,-17, 6, 6, -4, 3, -1 },
+ { -8, 10, 6, 7, -1, -6, 28, -6, 10,-33, 1,-20, 0,-12, 10, 1,
+ -6, 8, -3, -1,-10, 8, 5, 0, 10, -2, 8, 16, -5, -3, -7, 4 },
+ {-17, 13, 3, 15, 1, -5, 27, -5, 6, -6, 12, 2, -4, 8, -1, -3,
+ -2, 12,-15, 3, 4, 1, 2, -9, 0,-16,-21, 2, -4, 16, -7, 4 },
+ {-15, 20, 8, 17, 5,-14, 15,-11, 21,-11, 13,-13, 2,-15,-13, 1,
+ -5, 5, 2, 10, -9, 4, -1, 3, 2, -4, 13, -5, 1, -4, 5, -3 },
+ {-21, 8, 2, 16, -1, 2, 15,-16, 13,-12,-12, -7, -8, 2, -7, 11,
+ -8, 5, 2, -7, 16, -4, 1, -7, 3,-15, 6, -5, -8, 2, -8, 5 },
+ {-15, 17, -6, 3, -3, 3, 9, -7, 14,-23, 11, 1, -1, 4, 7, 6,
+ -1,-14, 7, 6, -8, 5, 1,-15, 10, -9, 2, -3, -1, 4,-10, -4 },
+ {-10, 18, 3, 11, 1, 4, 14,-14, 7, -4, 15,-10, 10,-11, 10, -4,
+ 5,-14, 10, 4, 15,-12, 15,-13, 20,-15, 14,-15, 8,-11, 4, -6 },
+ { -7, 23, 2, 20, 7, 8, 19, -5, 9,-16, -8,-17, -5, 1, 5, -6,
+ -8, 1, -6, -4, 10, 6, 6, 2,-11, -4, 0, 2, 4, 7, 9, -4 },
+ {-15, 20, -5, 22, 11, -8, 9, -5, 10,-13, -8, 8, 2, -2, -3, 7,
+ 6, 10, 1, 2, -5, -9, 1, 10, 16,-22, -7, 0, 7, 7, 6, 1 },
+ {-26, 19, -5, 3, 5, 25, 18, -5, 9,-14, -8, -6, -2, -6, 2, 3,
+ -8, -2, -7, 7, -3, 7, 3, 4, -8, 0, 1, -8, -4, -2, -2, 1 },
+ {-20, 14,-10, 6, -3, 7, 8,-32, -2, -7, -2,-10, 16,-12, -9, 15,
+ -2, -5, -6, 2, -7, 5, 9, 1, 6, -7, -1, 0, -2, -4, -7, 3 },
+ {-14, 16, 4, 11, -8, 1, 23, -4, 17,-13,-10, 1, 12, 9, 12, -4,
+ 7, -1, -1, 5, -8, -6, 3, 3, -6, -3,-18, 0, 18, 20, 4, -2 },
+ {-33, 19,-10, 30, 15, 2, -3, -1, -4,-14, 7, -7, -1, 7, -8, 9,
+ -1, -3, -5, 2, 2, 4, 0, 5, 0, 0, 2, 3, 3, -3, -3, 4 },
+ { -6, 20, 0, 5, 17,-10, 18,-17, 9,-16, 4,-13, -6, 2,-14, 14,
+ -28, 9,-12, 25, -4, 7, 7, -8, 6, -6, -2,-10, 2,-11, -1, 2 },
+ {-12, 14, 12, 52, -3, 5, -5, 4, 8,-13, 2, -5, -4, 2, -2, -1,
+ -2, 3, 3, 5, 2, 3, 0, 1, -5, 2, -4, -3, 1, -5, -2, 0 },
+ {-13, 6, 9, 24, 0, 8, 14,-15, 18, -9,-11, -8, 3, 15, -2, -4,
+ -9, 4, -3, 12, 14,-13, 11, -4, 2, -4, 0, -6, -6, -6,-14, -1 },
+ {-10, 28, 3, 12, 9, 3, 11,-28, 6,-11, -7, 4, 0, 7, 8, -9,
+ 0, -6, 0,-16, 4, 7, 4, 4, 7, 3, 4, -7, 0, -3,-10, 6 },
+ {-11, 14, -2, 19, -1, -1, 7, 9, -2,-27, 10,-14, 15, -4, 12, -4,
+ 2, -2, -6, 12, -6, 0, -5, -4, -5, 1, 3,-11, 5, -9, 3, -8 },
+ {-18, 7, 13, 16, -4, 3, 9,-10, 10,-10, -3,-22, -4,-12, 3,-16,
+ 0, -3,-16, 8,-11, 1, 10, -7, 15, 3, 0, -1,-13, 8, 1, 6 },
+ {-20, 10,-10, 10, 8, -1, 6, 0, 16,-12, 9,-10, -1, -5, -4,-13,
+ 13, 16, -8, 12, -2, 14, 18, 13, 0,-16, 2, -5, -5, -5, -4, 3 },
+ {-14, 5, -7,-17, 5,-13, 23, 20, -4, -1, 1, -6, 13, 5, -1, 4,
+ -14, -2, -7, 8, 3, 2, 2, -7, 2, -1, 4, 7, 3, -9, -1, -5 },
+ {-19, 3,-24,-28, -9, -7, 19, 3, 2, 19, 7, 5,-13, 8,-15,-17,
+ 3,-11, 4, 13, 3, 2, -1, -3, -4, -4, 2, 0, -5, -6, 6, 2 },
+ {-17, 18,-30,-20, -2, -3, 1, 15, -1,-11, 6, -4, 11, 11, -4, -5,
+ -10, 0, 0, 1, 3, -7, 8, 2, 5, 1, 5, -5, 1, 6, 4, 1 },
+ { -6, 1,-30,-25, -1, -8, -2, -9,-17, 16, 3, -1, -2, -9, -6, -7,
+ -3, 12, 6, -4,-10, 0, 10, -8, -6, -5, -3,-11, -4, 0, -1, -3 },
+ { -1, -1,-34,-28, 1,-10, 2, 9, 4, 16, 2, 6, 14, 17, 0, 7,
+ -4, 4, 4, 4, 0, 1, -1, -5, 8, 1, -4, 1, -9, -2, 5, 6 },
+ {-11, 14, 1,-31, -7,-24, 9, 7, 6, 5,-13, 1, -1, 3, 4, -1,
+ -2, -8, -6, 3, 5, -4, -6, 7, -2, 5, 3, 3, 0, 0, -5, 2 },
+ {-25, 8,-11,-18, 1, -4, 8, -3, -4, 15, 6, -5, 8, 2, 3, 4,
+ -4, 5, 6, 8, -7, 6, 1,-11,-15,-13, 9, -4,-14, 10, 12, 7 },
+ {-20, 11,-15,-25, 3, 4, 18, 13, -4, -5, -9, -1, -5, -2, -2, -7,
+ 16, 5, -4, -5, -7, -2, -3, -9, 11, -2, 0, -7,-17, -6,-11, 6 },
+ {-11, 18, -5,-20,-15, -3, 9, 11,-20, 12, 5, 5, 11, -3, 7, 1,
+ 10, -6, -3, -3, 3, 3, 14, -7, 10,-17, 9,-11, -2, -6, 7,-12 },
+ {-20, 8,-14,-17, -9,-13, -3, 0,-27,-14, -3,-14, 4, 3, 6, -6,
+ 7, 4, 23, 9, 11, 9, 3, -4, 9, 2, 4, -1, -6, 1, -8,-11 },
+ { -9, 14, 2,-37, -7, 13, 6,-11, -6, 9, 18,-11, -6, 2, 12, 4,
+ -1, 3, 1, -2, -2, 1, -9, -4, -2, -3, 3, 5, -6, 0, -2, -8 },
+ {-29, 8, -1,-13, -2, 8, 23, 2,-10, 7, 13, -6, -5, 11, 13, 0,
+ -10,-13, 11,-12,-10, 6, 4, 6, 4, 3, 6, -5, -9, -2, -1, 3 },
+ {-18, 6,-10,-55, -4,-11, -2, 0, 1, -3, -9, -6, 3, -2, -1, 6,
+ 3, -1, 3, 1, -4, -7, -2, 6, 3, -2, -1, -3, -2, 0, 4, 1 },
+ {-14, 5, 3,-21, -8,-16, -4, -2,-11, 27, 15,-20, 3, 0, 1, 1,
+ 2, -5, -5, 4, 1, -9, 5, -3, 3, 0, -4, -2,-11, -4, -3, 7 },
+ {-17, -1, -9,-17, -8,-18, 12,-13, -9, 13, -3, 3, 3, -3, 1, -2,
+ 0, 16, -9, 6, 12, 9, 5, 11, 2,-15, 1, -4,-16, 7, -4,-12 },
+ {-18, 8, -6,-11, -8, -7, 13, 7, 1, 6, 8, -1, 21, -4, 14, 15,
+ 18, -4, -3, 15, 0, 9, 4, 7, 3, -1, 9, -2, 0, 7, -8, 2 },
+ {-10, 7,-18,-29, 3, 12, 12, 9, 11, 4, -1,-15, 1, -1, 8, -2,
+ -2, 10,-15, -1, 0, 6, 12, -6, -1, 10, -6, -3,-11, -4, 9, -6 },
+ {-14, 14, -9,-21,-12, -2, -1, -7, -5,-10, 5, -8, 0, 6, 9,-11,
+ 11, -3, -5, 3, 8, 15, -2, -4,-22, 4, -6, 12, 2, 13, 6, -7 },
+ {-12, 11, -5,-29,-25, 4, 12,-13,-11, -7, 4, 2, 2, -5, 5, 8,
+ 7, -5, -5, 6, 3,-10, 1, -6, 6, -6, -5, -1, -2, -4, 7, 6 },
+ {-15, 11, -5,-16, 0,-13, 26,-23, -6, -3, 5, -2, -2, 21, -6, -3,
+ -5, -1, 6, -1, 0,-13, 2, -3, -9, -1, -4, -3, 5, -4, 12,-16 },
+ { -9, 9, -1,-17, -3, -6, 12, 6,-18, -2, 11,-14, -6, 3, 14,-12,
+ -11, -5, 14, 2, 5, -8, -4,-11, 2, -5, 16, 6, -7, -4, 8, 13 },
+ {-13, 5, 3,-28,-14, 0, 6, 23, 5, 4, -1,-17, 1, -3, 0, 0,
+ 5, 4, 0,-18, 14, 10, 4, 2, 5, -2, 4, -3, 2, 0, 2, 0 },
+ {-15, 4,-13,-16, -3,-12, -2, 2, 7, 10, 9, 3, 11, 4, 23, 14,
+ 9, 16, 4, 1,-12, -3, 4, -7,-15, -7,-10,-14, -6, -8, -1, -6 },
+ { -7, 10, -5,-10, -3,-13, 16, -1,-12, 7, -3,-12, 2, 13, 13, 2,
+ 17, 15,-13, 1, -5, -2, 3, -1, 1, -3, 6, -3,-12,-16, 7, -7 },
+ {-11, -5,-12,-30, -6,-22, 1, 4, -6, -3, 12, 6, 7, 0, 16, 6,
+ -2, 0,-22, -2, -9, 2,-13, 8, 6, -8, 4, -7, -1, -6, 4, 6 },
+ {-14, 5, 1,-27, -4, 2, 1, 14,-11, -7, -8, -4, 1, 8, 0, -6,
+ -13, 11,-12, -7, -5, 1, 10, 7, 3, -2, 0, 6, -8, 2, 10, -1 },
+ {-10, 10,-25,-13,-20, -4, 19, 3, 13, 5, 5, 7, -8, 2, 4, 2,
+ 3, -1, -1, -9, 14, 10, 9, 14, 3, 3, -6, 0, -5, 4, 1, -1 },
+ { -9, 15,-18,-17, 4,-11, 6, 7,-12, 8, -1,-11, 2, 3, 7, 16,
+ -3, -9, 7,-12, 23, 0, 6, 7,-14, -9, 8, 1, -2, 6, -2, -1 },
+ { -6, 9,-16,-26,-14,-11, 9, -6, 5, -2, 13, 17, 21, 7, 18,-19,
+ 6,-23, -2,-15, -2, 2,-10, -8, 2, 1, -2, 4, -3, -4, -5, -4 },
+ { 0, 6, -5,-28,-17,-32, 2,-10, 11, 3, -5, 9, 10, 3, 11, 11,
+ -3, 12, -2, 2, 4, -6, 9, -4, -4, -4, -4, -9, 2, 0, 2, 4 },
+ { 0, -8,-18,-34, -9, -7, -4,-11, 10, 15, 11, -1, -8, 15, 6,-13,
+ 9, 2, -4,-12, 0, -1, 19, 12, 6, 5, 0, -3,-10,-12, 3, -5 },
+ {-10, 6, -9,-17,-12,-11, 9, -6, 11, 11, 18, -7, 0, 16, 4, 2,
+ -6, 3,-12, -1, 0, 1, -5,-22, -2,-12, 0, 6, 17, 5, 5, 6 },
+ { 12, -5, 7, 1, -5, -2, -1, 2, 2, -4, -3, -3, -3, -2,-29, 11,
+ 5,-13,-73, 24, 12, 4,-14,-10, 5, 1, 0,-11, -7, -7, 7, 3 },
+ { 10, -3, -1, -3, 4,-11, -5, -2, -8, 7, 9, 2, -8, -6, 6, 7,
+ 21, 17,-54, 47,-14,-10, 14, 19, 13, 21, -4, 3, 1, 2, -4, 2 },
+ {-12, 4,-16,-12, 5, -9, -4, 19, -7,-22,-22,-17, 3, 0, -6, 8,
+ 23, -4,-55,-28, 2,-26, 2, 1, 4, 0,-13, 6, 0, 10, -7,-11 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,
+ 35, -1,-67,-35,-24,-24, -6, 2, 2, -2, 1, 3, 2, 0, -1, 1 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 0,
+ 41, -4,-73,-15, 18, 4, 17, 8, -1,-16, -1, -2, 1, 0, 0, 0 },
+ { -4, -4, 4, 6, -1, 2,-16,-10,-15,-10, 21, -2, -6, -2, 14, -7,
+ 10, -5,-55, 34,-12, 11,-13, -2, 2, 28,-26, 0, 7, 4, 21, -7 },
+ { 2, 1, 15,-22, 10, -3, 14, -6, -2, 15, -2, -7, 20, 6,-15, -7,
+ 23, 10,-60, 8, -4, 29,-22, 2,-13, 9,-10, 12, -1, -3, 4, 7 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 11, -5,
+ -21,-11,-60,-27,-17,-39, 6, 36, 0, -8, 2, 2, 0, 0, -2, 3 },
+ { 2, -5, 9,-17, -1, 2, -3, -6, 8, 12, 7, -6,-33,-11,-14,-40,
+ 10, 36,-46, 0,-19, 5, 0,-10, 3, 12, -6, -8, 6,-12, -7, 1 },
+ { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 1, 0, -2, 0,
+ 4, -2,-87, -3, -2, 2, -2, 20, 2, 6, -1, 6, 0, 0, 2, -1 },
+ { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1,
+ 1, 7,-76, 41, -7,-24, 0, -6, 3, 6, 0, -2, -1, 1, 0, 0 },
+ { 0, -3, 4, 2, 3, 2, 2, 0, 3, -1, 4, 0, -1, 4, -2, -4,
+ -32,-11,-64,-29, -9,-43, 2,-11, -1, -7, 0, -4, -2, -2, -2, 2 },
+ { 10,-20, 3, -3, 13, 13, 0, -4, 2, 7, -8, 7, -2, 2,-20,-20,
+ -19, 3,-47,-18,-16, -6,-15,-42,-17, 14, -6, 8, 12,-10, 11,-12 },
+ { -3, -2, -2, -1, -1, 4, -3, -1, -6, -2, 3, 2, -3, 6, -1, -9,
+ 10, 13,-68, -9, 26, 3, 5, 3,-21, 10,-15, 21,-22, 19, 11,-14 },
+ { 1, 5, 18,-19,-29,-13, -2, 18,-10, 20, 2, 10,-10, 11, 1, 8,
+ -16,-17,-41, 10,-14,-25, 0,-14,-19, 17, 7,-12, 14,-11, 14, 5 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,-43, 5,
+ 6,-12,-48, 19, 8,-38, -8, -3, 22,-21,-10, 15, 20, -9, -5, 8 },
+ { 0, 0, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 6, -3,
+ 22,-14,-71,-24, -2,-33, 23, 7, -8, 7, -3, 2, -4, 1, -8, -2 },
+ { 1, 0, -1, 2, 0, -2, 0, 0, -1, 0, 4, 0, 26, -1, 10,-11,
+ -17,-32,-58, 14,-14,-11, -2, 15, 2, -8, 12, 10, -9, 13,-33,-14 },
+ { 15,-17,-19, 7, -8,-15,-32,-22, 7, 12, 18, 0, 0,-15, -4, 16,
+ 37, -2,-46, 11, 2, -8,-10, -8, 14, 9, -4, 5, 7,-17, 4, 3 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
+ -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
+ -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1,
+ 1, 7,-76, 41, -7,-24, 0, -6, 3, 6, 0, -2, -1, 1, 0, 0 },
+ { 0, -3, 4, 2, 3, 2, 2, 0, 3, -1, 4, 0, -1, 4, -2, -4,
+ -32,-11,-64,-29, -9,-43, 2,-11, -1, -7, 0, -4, -2, -2, -2, 2 },
+ { 10,-20, 3, -3, 13, 13, 0, -4, 2, 7, -8, 7, -2, 2,-20,-20,
+ -19, 3,-47,-18,-16, -6,-15,-42,-17, 14, -6, 8, 12,-10, 11,-12 },
+ { -3, -2, -2, -1, -1, 4, -3, -1, -6, -2, 3, 2, -3, 6, -1, -9,
+ 10, 13,-68, -9, 26, 3, 5, 3,-21, 10,-15, 21,-22, 19, 11,-14 },
+ { 1, 5, 18,-19,-29,-13, -2, 18,-10, 20, 2, 10,-10, 11, 1, 8,
+ -16,-17,-41, 10,-14,-25, 0,-14,-19, 17, 7,-12, 14,-11, 14, 5 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,-43, 5,
+ 6,-12,-48, 19, 8,-38, -8, -3, 22,-21,-10, 15, 20, -9, -5, 8 },
+ { 0, 0, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 6, -3,
+ 22,-14,-71,-24, -2,-33, 23, 7, -8, 7, -3, 2, -4, 1, -8, -2 },
+ { 1, 0, -1, 2, 0, -2, 0, 0, -1, 0, 4, 0, 26, -1, 10,-11,
+ -17,-32,-58, 14,-14,-11, -2, 15, 2, -8, 12, 10, -9, 13,-33,-14 },
+ { 15,-17,-19, 7, -8,-15,-32,-22, 7, 12, 18, 0, 0,-15, -4, 16,
+ 37, -2,-46, 11, 2, -8,-10, -8, 14, 9, -4, 5, 7,-17, 4, 3 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
+ -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
+ -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 16, 65, -2, -2, 4, 3, 0, -7, 3, 1, 3, 1, 0, 5, 1, -5,
+ 0, 2, -1, 3, 0, 0, -1, -2, 6, 0, -2, 0, 0, -1, 1, 1 },
+ { 5, 37, -4, 8, -4, -1, 9, 17, 6, -7, 5, -1, 11, 6, -4, 7,
+ -2, 4, 1, -3, 11, 3, 3, -9, 6, 0, -2, -4, -5, 4,-12,-11 },
+ { 15, 24,-14, 2, 6, 17, 26, 5, 8, 11, -9, -7, -6, -8, 3, -5,
+ 9, 10, -3, 10, 0, 1, 4, -9, 4, 9, 3, 0, 4, 0, -5, 3 },
+ { 9, 36, -9, -8, 7, 7, 4, 3, -1,-16, -2, 7, -5, -6, 6, 12,
+ -11,-12, 9, -1, -3, -9, 12, 6, -6, 2, 2, 5, 0, 5, 6, -6 },
+ { 25, 39, -5, 24, 3, 10, 3, -6, 13, -8, 3, -7, 2,-10, -5, 2,
+ -2, 3, 5, -2, 1, 5, -2, 3, -4, 1, -5, -4, 0, 1, -2, 0 },
+ { 16, 27, -1, 0,-14, 6, 4, -5, 7, -2, -6, 0, -3, -5, 2, -1,
+ -1,-19, 5, -8, 0, 11, 12, 5, 0, 3, 10, 6,-14, 14,-13,-15 },
+ { 12, 23,-14, 2, 1, 4, -3, 16, 7, -8, 2, -8, 8, 6, -8, -7,
+ -3, 0, 2, 8,-13, 7, 13, -6, -4, 6,-13,-16, 14, 11, -7, 5 },
+ { 16, 28, -7, -1, 6, -3, 9, 0, -7, 3, 0, 3,-12, 20, 8, 9,
+ 8, 23, 8,-13, -2, 4, 9, 3, -5, 13, 5, -2, 12, 14, 5, -1 },
+ { 19, 37, 19, 5, 7, 5, 10, 5, 19, 10, 14, 0, 2, 5, 1, -4,
+ -4, 2, 2, -5, -2, -1, 2, -6, -4, -4, -5, -3, 2, -2, -2, -2 },
+ { 24, 21, 1,-11,-10, 17,-14, 14, 6, -1, -6, -1, 0,-13, -1,-12,
+ -2, -5, 6, -4,-12, 14, 5, -2, -8, -8, 15, -7,-30,-12, 4, 0 },
+ { 11, 26, -3, 3, 5, -1, -2, 3, -2, 10, 15, -4, 10,-28, 10,-17,
+ -8, 1, 2, -7, -1, -6,-15, -1, 4, 5, -7, 9, 0, -5, -4, 4 },
+ { 18, 32, 1, 2, -7, 4, 15, 2, -9, -2, 12,-11, 7, 11, 13, 2,
+ 0, 5, 9,-10, 16, 3, -3, 5, -9,-23, 2, -2, -1, 5, 2, 11 },
+ { 35, 24,-20, 2, 4, -1, 5, 14,-10, -9, 8, -7, 0, 5, -7, -7,
+ 11, 1, 5, 3, 2, 0, -2, 3, 0, 1, 4, 0, -2, -8, 0, -4 },
+ { 9, 35, -1, 2, -1,-19, -3, 12, -1, 8, 8,-13, -1, -2, 2, 5,
+ -8, -1, 13, -2, 11, 1, 0,-10, 0, -3, -7, 2, 1,-12, 3, 12 },
+ { 20, 27,-12,-12, 7, 4, -1,-13, -1, -9, 2, 13,-11, 5, 7, -9,
+ 9, 1, 1, 8, -9, 0, -6, 7, 4, 2, -2, 7, 3, -2, 1, -9 },
+ { 8, 37,-20, -5, 0,-21, 10, -8, 3, 19, -9, 7, -3, -8, 10, -2,
+ 0, 5, 6, -4, -2, -1, 0, -7, 6, 1, 0, 4, -5, 6, -8, 2 },
+ { 8, 27, 1, -3, -5, 1, 6, 0, 15, 2, 17, -1, 3,-17, 10, 5,
+ 5, -6, -6, 6,-10, 18, -5, 0, 0, 13, 7, 10, -5, -6, -2, -4 },
+ { 14, 29,-20, -4, -3, 1, -5, -1, 2, 12,-10, -3, 4,-18, 4, 14,
+ -4, -1, -9, 15, -2, 2, -5, -3, 2, 9, -2,-14, -3, 4, -4, -7 },
+ { 23, 23,-23,-11, 27, 4, 4, -1, 7, 0, -5, 9, 2,-11, 3, 7,
+ -2, -5, 2, -7, -7, 13, -3, -6, 2, 3, 3, -4, -1, -8, 5, -2 },
+ { 16, 26, -6, 8, -9, -1, -2, -1, -8, 4, -2, 0,-12, 9, -1, 0,
+ -17, -9, 30, -5,-15,-16,-13, 0, 10,-11, -7, -3, -1, 0,-11, -2 },
+ { 12, 32, -4, -5, 10, 19,-10, 4,-12, 5, -6, 9,-12, -6, -6, -8,
+ 4, 1, 3, 0, 8, 0, -3, -4, -7, -4, 10, 8, 6, 5, -1, 4 },
+ { 46, 42, -3,-14, -2, -6, 6, -2, -5, -1, -3, -3, 1, -1, 3, 1,
+ 1, 4, -1, 2, 3, 1, -2, 6, 0, -1, -2, 4, -2, -1, 2, 2 },
+ { 9, 33,-13, 4,-11, 3, -8, 22, 12, -2, 4, 0,-16, 5, 4, -1,
+ 7, -6, -9, 1, 7, 5, 0, -5, 5, -1, 10, 3, -2, -1, 3, -2 },
+ { 9, 30, 6, -3, 6, 1, -7, 5, 11, 14, 7, 1, 0, 2, 2, -1,
+ 8, 7, -6,-13,-10, -2, 1, -6, 10, 7, 6, 5, -2, -5, -1,-16 },
+ { 9, 28,-11,-10, 9,-10, 15, 8, 4, 9, -4, -7, 0, -5, 9, 8,
+ -7, 2,-15,-23, 4, -4, 4, 16, -8, -3, 0, -8, 14, 5, -3, 15 },
+ { 17, 26, -5, -5, -1, -8, 20, 18, -7, -2, 4, -7, -8, -5, -4, 16,
+ 0, 0, -7, -2,-13, -5, -2, 3, 12, 1, 3, -5, 2, 2, 0, -1 },
+ { 11, 37, 7,-23, 6, -1, 15, 13, 4, -9, 7, 5, 3, -3, -5, -8,
+ -2, 3, -5, -1, -8, 7, 2, 13, 1, 3, 0, -3, -1, 2, 0, -2 },
+ { 21, 33, 7, 20, 21,-10, 6, -5, -5, -6, -9, 2, 10, 0, 8, -4,
+ 10, 2, -2, -2, 0,-10, -6, -2, 0, -5, 3,-11, 3, -9, -3, 1 },
+ { 6, 30,-15, -8, 16, 1, 4, 6, 4, 5, 8, -3, 8, -9, -1, -6,
+ 8, 2, -2, 4, -2, 5, 11,-21, 3,-10, 16,-11, 24, 10, 14, -6 },
+ { 15, 36, -3, -9,-20, 12, 0, -7,-18, -4, -8, -9, 9, -7, -3, -1,
+ 2, 7, -5, -8, 6, 2, 2, -1, 7, 1, 1, -3, 3, -4, -8, 1 },
+ { 16, 34, 21, 3, -9, 10, 7, 9, -7, 1, -4, -9, -4, -5, -5, 3,
+ 3,-19, 1, 5, 4, -2, -6, -5,-10,-11, -8, -2, 2, -5, -8, -7 },
+ { 28, 29, -3, 18, -2, 0, -6, 12, -2, 10,-11, -4,-13,-12, -6, -4,
+ 0, 4, -1, -8, 6, 4, 12, 11, 10, 10, -3, -6, 1, 2, 1, 7 },
+ { 3, 8, 22, -8, 3, 36, -8, -1, 9, 6,-13,-14, 8, -1, 1, 2,
+ -2, -8, 0, 3, 1, 2, -1, 5, -1, -8, 0, -2, 2, 2, -1, 1 },
+ { 0, 6, 0, 0, 4, 13, -7,-16, -6, 15,-14,-21, -9,-10,-10, -6,
+ -21, 5, 4, 2, 12, 4, 12, 11, -4, -6, -6,-10, -7,-18, 1, 4 },
+ { -1, 3, 10, 1, -1, 15, 4, -7,-16, 3, 0,-22, 10, 2, -3, -2,
+ 13, 5, -8, 16, -5, 4, 0,-11,-10,-22, 0, -4,-17, 5, 2, 1 },
+ { 12, 8, -4, -9, 14, 40,-21, 0, 1,-15,-10,-12, 12, 6,-10, 2,
+ 8, 6,-12,-10,-11, 1, 0,-11, 2, 1, 13, 0, 6, 3, 8, 4 },
+ {-10, 3, 5, -4, -3, 3, 0, -9, 2, 8,-22,-23, 17, 8,-17, -3,
+ 14, -8, -4, 1, -8, 3, 0, 5, -1, -3, -2, -4, 1,-10, 0, -2 },
+ { 0, -1, 5, -7, 4, 12, -2, 0, -7, 2,-16,-15, 12, 21, -7, -4,
+ 7, -7,-11,-15, -7, -9, -5, -8, 0, -6, 8, -3, -8, 22, -7, -9 },
+ { 7, 19, 4, -9, 24, 22, 2, -6, 8, 13,-14,-20, -4, 11, 8, -4,
+ -1, 2, 0, -7, 5,-17, -3, 3, -6, 5, 3, 4, -5, -7, -3, 14 },
+ { -2, 6, 2, 8, -2, 5, -4, -2,-10, 3,-45,-30, -3, -3,-12, -4,
+ -3, -3, -1, 9, -6, -6, 5, -4, 0, 5, -1, -2, -1, 0, -6, -1 },
+ { -3, 14,-16,-10, 10, 0, -2,-40, -9, 12, 2,-19, 15, -4, 4, 3,
+ 3, -4, 7, 1, -4, -5, 0, 4, -1, 0, -9, -2, -4, -1, -2, 0 },
+ { 7, 16, 2, -7, 8, 2, 0, 1, 5, 21,-10,-26, 7, 2, -9, -7,
+ -3,-16, 8, 5, 5, -6, 10, 4,-14, -6, 5, 3, -2, -2, -4, 1 },
+ { -9, 14, -1, 3, 3, 11, 1, -5, -3, 13,-16,-18, 20, 6, -5, 0,
+ -3, 2, 8, 4,-19, -9, 12, 0, -8, 2, 2, 1, 6, 13, -7,-11 },
+ { 2, 5, 16, -4, 19, 15, 4, 0,-11, 7,-10,-10,-16, 18,-11,-12,
+ -9, -4, 7, -4, -4,-17, 1, 1, -8, -3, -3, 5, -2, -6,-11, -5 },
+ { 2, 12, 0, -9,-10, 14, 6, 2, -3, 2,-12,-28, 12, 1, -1, 2,
+ 0, -3, -4, 7, 16, 5, -7, 8, -4, -3, -1, 3,-12, 4,-17, -5 },
+ { -4, 7, 11, 6, 1, 14, -4, -6, 5, 5, -6,-24, 23, -9,-15, 13,
+ -7, -9,-15, 10, -1, 8, -5, 1, 12, 6, 2, 0, 4, -2, 9,-10 },
+ { 1, 5, 11, 3, 6, 12, -3, 8,-21, 5, -7,-20, 12, -2, -9, -3,
+ 17, -7, -8, -9,-14, 3,-13, 18, -8, 9, 2, -8, 4, -8, -5, -2 },
+ { -3, -3, -1, 5, -2, 15, 3, 2, 1, -8, 1,-39, -6, 13,-13, 0,
+ -2, -5, -6, -3, 0, -5, -2, 15, -9, 5, -3, -6, -2, 7, 0,-13 },
+ { 2, 8, 5,-12,-13, 22, 8,-16, 11, 5, -2,-32, -2, -4, 11, 5,
+ 5, -6, 1, 3, 1, 5, 3, 6, -5, 4, 4, -8, 8, 4, 1, 3 },
+ { 13, 9, 5, -4, 9, 18,-11, 2, -1, 15,-10,-19, -2, 14, 0,-10,
+ 1, 1,-18, 3, 2, -6, -8, 20, 7, -8, 16, 9, 9,-13, -3, -2 },
+ {-13, 11, 11, -9,-10, 13, -3,-18, 2, 10, 5,-21, 6, 15,-11,-21,
+ 3, 14, 0,-12, 9, -1, -2, -4, 3, -3, -9, -8, -5, -2, -8, 2 },
+ { 3, 3, 11, 4, 0, 13, 1, -8, 10, 13, -6,-26, 2, 12, -3, -5,
+ 12, -2, 1, 8, -7,-17,-19, 5, 10, 7, -3, 2, -3, 0, 5, 0 },
+ { 5, 0, 3, -3, -9, 5,-15, -5, -5, 17, -5,-31, 0, 13, 13, 5,
+ -1, -6,-14, 7, -8, 9,-14, -2,-16, -4, -4, -6, 6, -6,-10, 6 },
+ { 13, 3, 1, 7, -3, 4, -1, -2, -1, 4, -8,-32, -1, -4, 0, 3,
+ -10, 7, 10,-10, 4, -1, 6, 2,-16, -9, 4, 3, 13,-23, -3, -4 },
+ { 4, 11, -4, -9, 4, 11,-12,-12,-12, 6, 1,-28, -3, 14, 18, -2,
+ -12, 7, 15, -3, -5, -7, -3, 2, -6, 4, 4, -2, -5, -3, 2,-13 },
+ { 8, 7, -7, 0, 13, 7, -8, -7, 8, 36,-10,-22, 3, 23, -3,-10,
+ -3, 11, 1, -7, 3, 3, -1, -7, -4, 2, 3, 2, 5, 3, -4, -1 },
+ { -1, 1, 13, 1, -6, -1, -6, -9,-18, 17, -5,-37, -1, -1, -6, -4,
+ 1, -6,-15, 2, 17, -9, 0, -3, 0, 4, 0, -5, 0, 4, 1, -5 },
+ { 0, 14, 5, 0, -7, 2, -6, 17, -6, -9, 7,-16, -5, 23,-14,-13,
+ 8,-15, 11, 10,-11,-13,-33, -5, -2, 1, 6, 8, 0,-13, -9, 5 },
+ { 11, 7, -2, -8, 9, 11, 25,-14, 7, 3, -1,-33, 14, 8, -6,-19,
+ 3, 3, 2, -1, -3, -1, -2,-10, -3, 1, 2, 1, 4, 2, -3, 4 },
+ { -2, 8, 4, -2, 9, 13, -4, -2,-15, -3, 19,-37, 9, 25, -9, 2,
+ -5, -2, -2, -4, 4, 2, 2, 0, 3, 3, 3, 5, -2, -3, -4, -3 },
+ { 10, 13, -1,-15, 4, 6,-18, -4, 25, 1,-23,-17, 15, 13, -8, -8,
+ 7, 4, -5, 3, 6, 9, -7, 6, 0, -5, 8, 0, -6, -1, -2, -2 },
+ { 1, 3, 9, -5, 27, 15, -9,-31, -1, 23, -2, -9, 1, 8, -1, -7,
+ -2, -8, -4, -4, -2, -1, 3, 5, 0, 0, -1, 1, -7, 7, -3, -3 },
+ { -8, 7, 3, -6, 8, 3,-11, -2, 36, 14, 1,-30, 6, 10,-12, -6,
+ -6, -2, -4, -3, -5, 0, 9, 4, -5, -5, -8, 12, 4, -3, 1, -8 },
+ { -2, 9, 33, 0, 12, -3, -7, -4, -4, -1, 6,-25, 11, -6, -9,-11,
+ -2, -4, -2, 6, -1, -3, -6, 15, -6, 3, 10, -4, 1, 0, 5, 8 },
+ {-22,-21, -9,-19, -5, -7,-12,-15, -8, 9,-19, 14, -7, -4, 5, -8,
+ -2, 7, 1, -3, 4, -4, 6, 11, 2, 6, -3, -5, 2, -2, 0, -3 },
+ {-32,-13, 3,-24, 3, -8, 4, 1,-10, 14,-15, 0, 4, 6, -1, 6,
+ 7, -1, 6, 4, -3,-17, 1, 4, -6, -1, 1, 0, 3, 3, -7, -4 },
+ {-32,-11, 7, -8,-12, 13, -5,-22, -4, 12,-16, 2, 0, 4, 0, 1,
+ 0, 6, -5, -8, 2, 6, 5, 0, -3, -6, 5, 6, 5, 5, 13, -4 },
+ {-44,-33, 6, -4, 2, 0, -9, 10, 3, 4, 7, 0, -1, 7, 5, 1,
+ 1, -3, 1, 6, -1, 0, 2, 3, -4, 0, 0, 1, 0, -1, -2, -1 },
+ {-30,-18,-24, -8, 5, 0, -2, 14, 7, 0, 1, 12, 6, 4, -9, 7,
+ 5, 7,-11, -5, 1, -8, -1, 2, 2, -9, 7, -1, 7, 5, 6, 6 },
+ {-22,-20,-13, -9, 20, -3, 10, -8, 6, -4, 2, -7, 10, 8, 0, -1,
+ 2, -3, 6,-19, 2, 4, 3, 3, -7, 2, -1, -6, 1, 1, 6, -2 },
+ {-27, -8, -1, 3, -1,-11, 24, 4, -1, 1, -8, 8, 5,-11, 15, -3,
+ -15, -1, -1,-13, -1, 1, -5, 5, 2, 3, -9, 0, 4, 3, -7, 6 },
+ {-33,-16, -1, -8, 10,-23, 6, 13, -1, -3, -9, 0, 5, -7, -5,-12,
+ -2, 3, 3, 6, -2, -3, 2, -3, 9, -6, -3, -2, 0, 5, -3, -4 },
+ {-22,-17, 11, -3, 3, 1, -1, -5, 17, 2,-15, -2, 10, -9, 6, 14,
+ -16,-12, 20, -1, -7, 6, -3,-12, 1, 10,-10, -1, 7, -3, -1, 10 },
+ {-28,-13, 1, -3, -1, -1, 0, 3, 3, 5, 1, 10,-10, -3, 7, 2,
+ 4, 19, -1, -1, 10, 5, -8, 1, 11,-15, -4, -3, -5, 4,-13, 3 },
+ {-22,-13, 42,-20, 5,-13, 7,-11, 1, 1, -1, 1, 6, 3, 6,-11,
+ 3, 3, -2, 0, -4, 4, -3, -1, -5, 2, 0, 0, -9, -1, 4, 4 },
+ {-26,-15, -2, -6, -4, -2, 16, 8, 21, 8, 1, -3,-10, 7, -8,-12,
+ -5, 12, -9, 3, -2, -3, 18, 1,-12,-15, -4, 5, -3, 0, 12, 7 },
+ {-26,-16, 5, 6, 14, -3, 15, 6, 1, -7,-13, 16,-15, 5, 11, -2,
+ 9, -7, -4, -2, 0, 0, -2, 7, -8, -6, -5, 2, 7, -3, 2, 12 },
+ {-31,-17, -8,-30, 4, 14, 6, -6, 6,-11, 0, 3, -4, 0, 0, -4,
+ 0, -4, 1, 4, 3, 4, 0, -5, 3, 2, 2, 0, 2, 1, 3, 5 },
+ {-61,-10, 4, 10, 4, 7, 0, -3, 0, 1, 0, -3, 0, 1, 0, -2,
+ -1, 1, 2, -2, 4, -3, 1, 1, -1, 1, -2, -4, -4, 4, 0, 0 },
+ {-28,-13, -8, -4, 3, -3, 2, 1, 11, 14, 3, 9, 1, 13, 3, 5,
+ -3, -2, -2,-12,-14, -9,-11,-15,-12, -5, -4,-12, 3, -3, 0, -5 },
+ {-41, 0, 12,-24, 13, 4, 5, 16, -5, -4, 0, 0, 13, -4, 1, -9,
+ 9, -6, -1, 6, -2, 5, 2, 9, 6, -9, -8, 8, -2, -3, -6, -4 },
+ {-26,-19, -2,-15, 4,-14, 6, 0, 26, 20, 8, 9, 9, 3, -4, -5,
+ -8, 1, 0, -1, 5, 9, 3, 4, 4, 7, 1, 3, -2, -2,-10, 0 },
+ {-29,-18, 9, -4, 1, -5,-14,-12, 5,-10, -5, 4, -5, 0, -1, -1,
+ 4, -5, 7,-16,-11, 2, 7,-15, 2, -4, 6, -4, -6, 7, -3, 7 },
+ {-27,-16, 9,-14, 3, -8, 9, 0, 7, -4, -3, -7, 0,-10, -1, 2,
+ 1, -2, 15,-10, 14, 7, 6, 17, 3, -4, 3,-10, 8, -8, 3, 11 },
+ {-21,-20, -8, -8, 4, 5, -3, -2, 0, -5, 14,-10, 11, -4, 13, 0,
+ 5,-11, 19,-18, 18, 3, -5, -3, -4, -8, 11,-10, 10, 3, 4, -9 },
+ {-35,-15, 13,-12, 4, 0, -2, -4,-12, -3, -8,-24, -7, 1, 7, 8,
+ -3, 0, -2, -1, 3, -2, -2, -6, 8, 1, 0, 1, -6, -1, 2, -6 },
+ {-19,-14, 13,-10, 9, -1, 1, 3,-12, 5,-16, 7, 13, 9, 4, -4,
+ 6, -5, 4, 9, -3, 17, -4, 12,-11, -6, -5, -6, 13, 2, 7, -9 },
+ {-34, -8, -4, 1, 2, -1, 3, 6,-20,-11, 8, -1, 4, 2, -9, 4,
+ -4, -5, 16, 10, -4, 14,-13, 1, -6, 0, 2,-10, 0, -3, -3, 7 },
+ {-36,-10, -8, -3, 2, -2, 14, -4, -1, -7, -4, 10, -1, -3, 15,-11,
+ 0, 2, 3, -1, 4, 0, 8, -1, 0, 18,-11, -5, 15, -5, 13,-12 },
+ {-22,-13, 14,-20, 15, 25, 16, 10, 8, -2,-10, -5, -1, -8, 11, 8,
+ -1, -2, -4, 1, 2, -1, -7, 0, 0, 0, -3, 0, 2, -1, 0, 2 },
+ {-31,-22, 7, 6, -2, 5,-20, 14, -6, 7, 0, 14, 3, -7, 3, -6,
+ -2, 1, -3, -5, 1,-10, 1,-24, 6, -2, 3, -7, 1, -7, 8, 7 },
+ {-25,-20, -3, -9, 10, 6, 12, 7, 5, 4, -3, 6, -1, -5, -6, -8,
+ 3, 5, 6, 5,-10, 10, -4,-15,-15, -2, -9, 2, 18, 1, 8, 12 },
+ {-24,-19, -2, -4, -7, 11, 6, 9, 16, 2, -7, 18, 6, -7, 6, 6,
+ -2, -9, 3, 12, -2, 3, -1, 6, 7, 8, 0, 8,-11, 8, 4, 2 },
+ {-26,-20,-12,-12, -2, -3, 1, -5, -1, -2, 0, 3, 7, 9, -2, 2,
+ 9, 22, 13, 4, -4, -1, -2,-14, 5, 15, -8, -5, -7,-11,-14, -6 },
+ {-21,-18, -1, -4, 0, 3, 7, -2, 10, 8, -8, -1, 15, 1, -9, 3,
+ 1, 3, -5, -2, 2, 4, 0, -1, 10, 2,-19, -8, 8, 30, -7, 8 },
+ {-25, -6, 26, 4, -8, 4, -2, 21, 5, -4,-16, 5, 13, 4,-10, -1,
+ -6, -2, 2,-10,-13, 1, 3, -3, -6, -8, 2, 11, 1, -7, 0, 5 },
+ { 0, -1, -2, 19,-12,-48, -6, 11, 8, -2, -4, -2, -7, 5, -3, 2,
+ -2, -1, -1, -7, 0, -3, -3, -4, -4, 4, 1, 3, -3, -1, -2, -5 },
+ {-11, -8,-28, 18, 16,-24, -8, 19, 4, 8,-12, 9, -4, -2, 4, -7,
+ 6, 2, 3, 3, -4, 0, 1, -6, -4, -2, 2, 6, 0, -3, 1,-16 },
+ { -9, -5,-26, 7, -3,-37,-16, -2, 2, -7, 4,-13, 0, -4, -6, -5,
+ -6, -4, 0, 3, 4, -3, -4, -4, 4, -3, 9, -4, -2, 2, 7, -4 },
+ { 2, 9,-18, 7, 29,-24, -1, 7, 14, 10, 3, -3, -2, -5, 6,-10,
+ -6, -3, -8, 0, 5, 1, 4, 3,-12, 2, 6, 1, 3, 4, 1, -3 },
+ {-20, 2, 8, 20, -9,-24, -4, 18, 3, 11, -1,-11, 6, 9, -1, -3,
+ 1, -1,-15, 3, 15, 9, 3, 2,-13, 2, -8, 8, 1, -1, 1, -8 },
+ {-12, 5,-11, 6, 19,-26,-17, -6, 4, 14, 6, -8, 9, 5, -6, -5,
+ 2, -1, 20, 1,-11,-10,-18, 20, -7, 0, -3, 4, 2, 0, 10, 4 },
+ {-15, 1, -2, 13, -8,-21,-22, 4, 4, 3, 3, -7,-31, 4,-10,-14,
+ 0, 8, 4, 5, 8, 11, 2, -8, 6, 7, 0, -2, 6, 8, 8, 7 },
+ {-13,-10, -9, 12, 19,-16, -3, -2, 9, 2, 11,-29, -1, 9, 4, -3,
+ 1,-10,-10, 16, 1, 7, -7, -6, -4, -1, -5, 3, 6, 0, 3, 1 },
+ {-17, -1, -5, 19, 12, -9,-21, -5, 2, 12, -7, -7, -3, 8, 7, -2,
+ 6, -9, -9, 1, -4, 1, 1, 3,-14, 2, -8, 0, 10, 1,-12, -6 },
+ {-13, -5, 8, 15, 0,-20, -2, 20, 8, -8, 8,-19, 12, 10, 2,-11,
+ 0, 12, 1,-11, 0,-11,-15, 5,-11, 2, 4, -4,-11, 5, -4, -5 },
+ { 3,-11, -7, 8, 0,-17,-26, 15, 19, -7, 10, -9, -5, -5, 14,-25,
+ 0, -8, 2, -9, -3, 9, 1, -6, 4, -4, 3, -9, -1, 6, 2, 2 },
+ {-12, 5, 5, 9, 14,-18,-19, 4, 2, 16, 14,-21,-15, -9, -1, 16,
+ 12,-11,-10, -5, -7, 4, 15, -8, -5, -1, 1, 14, 13, -7, -1, -4 },
+ {-10, -5, -1, 8, 7,-23,-10, 14, 6, 11, 10,-16, -3, 16, 6, 0,
+ 0, 9, 6, -2, -7, 1, 22, 5, 3, -8, 0, 3, -2,-10, 3, 0 },
+ { -2,-14, 2, 16, 15,-17,-17, 6, 19, 4,-10,-15, -1, 15, 11,-14,
+ -8, 5, 8, 8, -2, -8,-11, 10, 10, -8,-14, 2, 13, 4, -2,-12 },
+ {-10, 3, 6, 4, 19,-23,-19, 1, 4, -9,-30, 3, -6, 18, 0, 2,
+ 0,-11, 0, 3, 7, -2, 8, 5, 2, -3, 6, -9, 1, -4, 7, -6 },
+ { 9, 5, -2, 21, 20,-33,-13, 7,-10, 8, 8,-15, -6, -4, 1, 5,
+ 3, 7, -2, -9, -1, 4, -6, 1, 0, 9, -1, -5, 2, 1, -3, 3 },
+ { -9, -3, 3, 15, -3,-30, -7, -7,-25, 6, 2, -6, 1, 19, 1,-12,
+ 1, -8,-13, 9, 13, 1, 8, 2, 5, 15, -2, 3, -9, 0, -4, 4 },
+ { -6,-12,-17, 25, 22,-13,-10, 9, 2, 11, -7,-16, 4, 6, 1, 0,
+ 0, 18, -4, -5, 4, -2, -1, -5, 0, -4, 6, 1, 6, -1, 7, 0 },
+ { -1, 0,-10, 8, 8,-27, 0, -2, 29, 16, -2, -4, 9, -1, 2, 0,
+ 6, 10, 6, 4, 2, -7, 9,-18, 3, 3, 3,-10, 17, 10, 9, -6 },
+ { -3,-12, -6, 11, 20,-32, 5, 21, 3, -4, -9, 2,-10, 1, 7, -4,
+ 5, 0, 0, -1, -8, -9, -7, 4,-10, 5, 0, 2, -5, 4, 9, 1 },
+ { -5, -1, -5, 1, 2,-19,-13, 1, 6, 12, 2,-16,-17, 11, 10, 13,
+ 16,-12,-11, 3, -6, 0, 6, 4, -3, 1, 8, 2, 5,-11, 3,-14 },
+ {-19, 5, 10, 11, 2,-23, -9, 16, -2, 7, 0,-11, -7, 10, 6, -7,
+ 26,-15, -4, 8, 6, -4, 7, -9,-15, 1, 8, -4, 4, 2,-12, 16 },
+ {-11, 1, 11, -4, 1,-31,-13, -1, 8, 5, 4, -2, 0, 13, 7,-17,
+ 7,-10, -6, 1, 4, -1, 2, -9, -4, 9, 3, 3, -4, -5, 3, 4 },
+ { -3, 1, 10, -1, 0,-15,-22, 4, 40,-11, -4, -3,-14, 9, 11, -1,
+ 9, -1, -6, 6, 3, -6, 0, 0,-12, 7, -2, 0, 9, 3, 1, 3 },
+ { -1, -1, -1, 14, 8,-24,-14, -8, 5, 8, 5,-12,-17, 8, 2, 7,
+ 10, -8, 0, 4, -6, -6,-10, 8, 4,-12, 3, -9,-12, 5, 4, -3 },
+ { -5, 1,-11, 8, 9,-24, 0, 2, 2, 14,-12,-13, 1, 6, 7, 0,
+ 7, -6, 9, 26, 11,-14, 8, 10, 1, 9, 0, 11, -2, 6, 2,-10 },
+ {-13, 1, 4, 34, 19,-17,-15, 0, 3, -2, -7, -1, 0, -3, -3, -1,
+ 1, -1,-10, 8, 5, 0, -8, 4,-17, 9, -2, 0, 0, 6, 2, -3 },
+ { -6, -4, 1, 2, 2,-14,-29, 0, 9, 34, -3, -5,-14, 6,-10, -9,
+ -5, -1, 0, 3, 3, 0, 1, -1, -2, -1, -1, -3, -3, -4, 3, -3 },
+ { -4, 6, 3, 14, 14, -8,-29, 31, 11, 14, -4, -5, -6, 10, 6, -9,
+ -1,-11, -7, 1, 7, 4, 1, -6, 4, 0, 10, -7, -5, -1, 2, 4 },
+ { -4, -4, -2, 14, 6,-32, -6,-14, 14, -5,-11, 10,-18, -4, 6, -8,
+ 9, 5, -4, 1, -4, 5, -2, -9, 3, 5, 2,-10, -6,-17, 3, 17 },
+ {-16, 9, 21, 19, 4,-20,-17, 14, 9, 15, -6,-17, -1, 1, 6, -3,
+ 1, 1, 8, -3, -6, 6, 9, 4, 9, -9, -5, 1, -1, 0, -1, 2 },
+ { -7, -5, 3, 19, 1,-20, -9, 14, 21, -7,-18, -9, 26, -7,-17, -7,
+ 12, 6, 0, -9, -6, 14, 9, -9, -8, 4, 15, -7, -9, -1, 9, 1 },
+ {-20, 30, -6, 11, 24, -4, 0, -6, -2, 8, -4, 12, -8,-17, 0, 5,
+ -4, 1, -1, 3, -3, 5, 3, 3, 7, -2, -3, -2, 4, 0, 0, -1 },
+ {-35, 17, 6, 1, -9, -1,-16, 3,-20,-13, 8, 7, -4, -7, -4,-20,
+ 7, 12, -5, 5, -5,-11, 12, -1, 15, -9, -6, 16, -4, -9,-13, 4 },
+ {-21, 36,-19, 9, 0, -7, -8, 9, -4, -3, 3, 0, 7, -8, -2, -2,
+ -11, 13, -1, 5, -3, 7, 2, 3, -1, -2, -5, 1, -1, -2, -5, -3 },
+ {-12, 33, -4, 1,-12, -9, 0,-13, -1, 2, -8, 4,-10, 6,-16, -7,
+ -1, -4,-10, 15, -1, 0, -5, -8, 5, 5, -3, 0, 2, -7, 1, -7 },
+ {-14, 32, 5, -7,-15, 3, -5, 8, 14, 5, 9, 13, 3, 18, -3, 7,
+ 4,-10,-10, 10, -1, 2, 0, -2,-11, 5, -3, -4, 2, 2, 7, 4 },
+ {-14, 34, 1, 20, -1,-12, 0, -3, -7, -4, 7, 18, 9, -3, 14, -7,
+ -9,-20, -7, -4,-13, 12, 1, 12, 5, -6, 2, -4, 0,-15, 1, 3 },
+ {-21, 23, 7, -8, 3,-13, -3, 0, -6, -2, -7, 6,-12, 9, -6, -2,
+ -2, -4, -1, 6, 9, 5, -9, 15, 0, 8, -8, 7, 6,-15, 3, -5 },
+ {-27, 32, -1, -4, -2, 4,-10, 12, -3, 8, 13, 7, 0,-15, 4, -2,
+ 3, 5, 7, -4, 9,-12, -1, -2, -1, -4, 0, -4, 2, -5, 6, -6 },
+ {-17, 29, 15, 0, -1, -4,-10, 13, 12, -1, -8,-10,-10, 4, 7, -2,
+ 6, -5,-13, 19, 6, 1, -7, 2, -9, -2, 12, -4, -8, -3, 2, 4 },
+ {-38, 27, 16,-15, -6, 3, -7, -4, 0, -1, 6, -2, -3, -6, 6, -6,
+ -3, 0, 2, 0, -4, 6, 1, -1, 0, 4, -1, 3, 4, 1, -2, 5 },
+ {-33, 40, -4, 2, 1, 0, 0,-10,-14, 0, -7, 4, -1, 3, -2, 5,
+ 7, 6, -1, 4, 1, 3, 1, -7, 1, -4, 5, 7, 0, 4, 3, -4 },
+ {-20, 25, 12, -4, 16, -4, 2, 2,-14, -2, -3, 29, -1, 1, 3, 1,
+ 9, -5, 2, -8, -3, 1, -7, -2, -7, 1, 0, 4, 16, -2, -1, -1 },
+ {-10, 30, 17, 3, -5, -2, 0, -5,-22, 4, 5, 5, -3,-18, -6, 10,
+ -5, -7, 2, 8, 7, -7,-11, -2, 0, -3, 3, 2, 11, -4, 4, -4 },
+ {-11, 30, 11, 4, -3, -8, 1, -2, 4, 18, 3, 1, -1, 0, -8, -4,
+ -3, 10, 13, 14, 5, -5, 1, 1,-10, 2, 15, 4, 9, -1, -5, -3 },
+ {-17, 32, 18,-18, -3, -5, 6, 10, 1,-15, -5, 9, 8,-12,-10, -6,
+ 11, 9, -5, -8, -7, 10, 5,-10,-14, -4, -3, 1, 9,-11, 2, 1 },
+ {-13, 28,-11, -1, 2,-16, -2, 7,-24, 0, 3, 6, 3, -1, -8, -7,
+ -12, 2, 2,-20, 10, 4, 0,-13, -2, -2, 1, 8,-14, 0, 4, 1 },
+ {-14, 23, 12, 8, 8,-26, 2, -4,-14, 13,-14, 15, 3, -9, -1,-13,
+ -10, -2,-10, 6,-16, 12, 8, 0, 9,-10, -7, -4, -4, 7, -8, 8 },
+ {-20, 45, 10,-14, 4, 16, 8, -9, 1, -8, 10, 5, -7, -2, 2, -5,
+ -1, 0, -5, 4, -6, -2, 4, 1, 3, 4, -4, 2, -2, -2, 5, 1 },
+ {-20, 26, -4, 1, 7, 4, -8, 1, -5,-13, 2, 13, -7, -3, 6, -6,
+ 22, 0, 5, 11, -4,-11, 8, -9, 2, -2, -4, -2, 2,-13, -4, -8 },
+ {-28, 18, 17, 3, -8,-23,-16, -6, 5,-10, 14, 10, 5, -1, -8, 4,
+ -2, 13, -3, -2, 3, 4, 3, -2, -3, -4, 0, 1, 3, 4, 0, 4 },
+ {-12, 32, -6,-16, 18, 12,-16, 0, 7, 13, -4, 5, -8, -1, -3, 4,
+ 6, -2, -1,-13, 4, -1, 3, 12, -3,-10, 1, 6, 8,-11, -2, 4 },
+ {-18, 26, 2, 5, 0, -9,-17, 14, 5, 1, 7, -3, -8, -3, 11, 7,
+ -5,-12, -8, 7, 0, -7, 2,-12, -9, 13,-11, 9, 6,-11, -5, 11 },
+ {-24, 22,-15, -9, 8, 1, -7,-12, -9, 3, 11, 15, 14,-11, 12,-15,
+ -5, 7, -2, 0, -8, 3, 3, -1, 2, 11,-11, 14, -6, 13, 1, -6 },
+ {-20, 28, 18, -4, -6, -5, 12, 14, 2, 10,-13, -6, -8, -6,-13, -1,
+ -26, 22, -3,-14, 6, 0, 10,-15,-13, -9, 6, -7, 1, -5, -4, -1 },
+ {-19, 26, -8, -3,-14, -6, -9, -4, -8, 15, -8, 3,-12, -4, -2, -7,
+ -5, 3, 13, -3, -4,-25, 4, -1, 5,-12, -1,-13, 5, 2, 0, 6 },
+ {-18, 43, 14, -8, 1,-23, -2, -2, 1, 3, -7, 0, 0, 8, -1, -3,
+ -5, 1, 5, 2, 0, -2, -2, -2, 1, -1, -1, -7, 0, 3, -3, 9 },
+ {-11, 30, 10,-14, 3, 1, 10,-11, 1, -7, -4, 14, 2, 1, -9, 1,
+ -11, -2, -7, 5,-11, 1, 3, 14, 1,-16, -8, 3, -5, 7, -4, 4 },
+ {-18, 24, 6, 3, 8, 7,-22, -7, -7, 3, -8, 4, 23, 9, 3, -1,
+ 3, 6, 7, -1, -7, 6, 4, 1, -3, 1, -6, -1, 2, -7, 3, 3 },
+ {-15, 38, -7, -1,-11, 2,-17,-24, 24, 8, 7, -4, -5, 2, 2, -7,
+ 1, 4, 0, -9, 5, 0, -1, 1, -1, -5, -6, 3, 0, 7, 8, -3 },
+ {-14, 22, 1, -5, 9,-12, -9, -5, -6, 5, 7, 8, -1, -4, -9, -3,
+ -33,-16, -9, -1, 12,-11, 17, -7, -3, -1, -7, 3, 2, -3, 16, -4 },
+ {-14, 20, 6, 4,-10, -4, -4, -4, 1, -7, 2, 6, 8,-12, 4, 1,
+ -1, 12, 10, 3,-14,-10, -3, 18, -2, 33, -5,-17, 17, -5, 9, 7 },
+ {-12, 23, 13, 0,-11, -8,-11, 12, -5, -9,-16, 11, 6, 4, 12, -5,
+ 5,-13, 7,-12, -3, 1, 2, 12, 1, -4, -1, 5, 4, 11,-12, -3 },
+ { 15, 2, 14, 7, 1, 2, 1, 12, 10, 23, 4, 6,-20,-10, 4, 26,
+ -6, 13, 4, 3, 2,-11, 5, -7,-10, 4, 9, 1, 10, -4, 11, 4 },
+ { 17, 15, 31, 17, 18, 16, 11, 24, 2, 4, 2, 3, -8, -3, 7, -3,
+ -5, -7, -2, -6, -4, -5, -4, -1, -4, -2, -5, -6, 2, -1, 4, -2 },
+ { 16, 8, 15, 14, 3, 7, 21, 9, 8, 15, 21, 6, 8, 12, 5, -5,
+ 7, -3, 10, 2, -3, 8, 6, 0, 5, 5, 6, -3, 2, 4, 0, -5 },
+ { 5, -4, 6, 12, 6, 13, 24, 17, -5, 17, -1, -6, -7,-10, -8,-18,
+ 3, -2, 2, 7,-15,-11, 12, -3, -2, -2, -4, -7, 2, 0, 5, 5 },
+ { 10, -6, 8, 11, 12, 20, 22,-11, -3, 15, -3, 15, -2, -2, 0, 2,
+ 5, -8, 4, -5, -9, -4, -1, 2, -1, -3, 1, 3, 13, -1, 9, 7 },
+ { -5, 8, 5, 11, 14, -5, 14, -9, 2, 35, 8, 15, 1, -2, 2, -2,
+ 4, -9, -3,-14,-12, -2, -2, -4, -2, -8, -3, 1, -6, 3, 10, 0 },
+ { 16, 0, -6, 15, -3, 4, 4, 3, 3, 20, 5, -4, 10, 9, -9, -3,
+ -10, -2, -7, 11,-11,-10, 17, -1, 3,-15, 2, 9,-15,-10, 16, 10 },
+ { 14, 4, -7, 19, 3, 0, 19, 8, 16, 34, -9, 6,-13, -1, 6, 5,
+ -1, -2, 4, 3, 2, 1, 1, -1, 0, -7, 2, -1, 1, 0, 6, -1 },
+ { 1, 6, 9, 13, 9, 10, 15, 16, 10, 18, 13, 17, 3, -1, -7, 2,
+ -15,-11,-10, -4,-13, -6,-17,-13, -6,-14, 1,-10, 6, 4, -1, -1 },
+ { 13, 1, 7, 10, 14, 13, -7, 5, 5, 28, 14, 14, -2, 2, 3, -3,
+ -13, -4, 10, -9, 19, -4, -3, 4, -5, -5, 0, 5, -5, 0, 3, -4 },
+ { 1, 0, 6, 22, 9, 18, 18, -3, 5, 10, 12, -2, 1, -3, -8,-12,
+ 9,-10, -7, 1, -1, 19, 0, 2, -8,-11,-10, 9, 6, 11, 0, 3 },
+ { 10, 11, 19, 44, 0, 14, 1, -7, 6, 22, 2, -1, 9, 2, 0, -4,
+ 4, 0, -6, -6, 3, 0, 0, -2, 2, -5, 1, -2, 0, 1, 1, 1 },
+ { 5, 7, 0, 32, 30, 26, 5, 4, -7, -3, 15, -6, 3,-10, 7, 6,
+ -8, -7, 2,-13, -5, -1, -3, 7, 3, -2, -8, 0, 6, 4, 5, 0 },
+ { 9, 8, -2, 4, 2, 11, 4, 29, -5, 14, 8, -5,-14, 8, 0, 9,
+ 8,-10, 5,-15, -6, -9, 9, -1, 18,-16, 9,-21, -3,-13, -2, 8 },
+ { 25, 7, -9, 23, 20, 18, 6, 16, -9, 8, 8, -5, 11, 13, -8, 7,
+ 4, 10, -2, -1, -7, -9, -7, -9, -4, 1, 1, -5,-10, 8, 4, -5 },
+ { 9, 2, 16, 14, -5, 14, 1, 0,-21, 17, -1, 9, 12, -3, -3, 4,
+ -4, 14, 10, 3, 0,-10, 7, 4, 4,-11, 2, 4, -1, -3, 9, -1 },
+ { 17, 8, 11, 26, 15, -3, 14, -1, 12, 9, 10, -8, 8,-18,-11, -3,
+ -14, -7, 7, -3, -3, -4, 1, -7, -3, 2, -3, 16, 10, 0, 9, 6 },
+ { 9, 8, 3, 8, 18, 14, 11, 1, 10, 6, 1, -4,-16, -2, 14, -2,
+ 1, 8, 12, 14, 3, -3, 8, 8, 12,-15, 3, -3, 3, -2, 14, 10 },
+ { 22, -3,-11, 13, -7, 11, 4, 11, 3, 14, 0, -6, -2, -9, 4, 2,
+ -2, 0, -5,-27,-10, 3, -1, 5, 8,-24, -3,-11, -3, 2, 11, -1 },
+ { 19, 2, 8, 36, 5, -6, 3, 15, -3, -4, -5, 14,-10, 1,-12,-10,
+ -3, -4, 3, -2, 1, -8, 4, 3, 5, -3, 0, 4, 8, -2, 8, 4 },
+ { 8, 14, 15, 9, -4, 10, 5, 11, 9, 10, 8, 9,-15, 15, 6, -8,
+ -10,-13, 5, -8,-20,-13, -6,-11, -1, -3, -6, -4, -1, 0, 13, 15 },
+ { -2, -1, 9, 12, 2, 2, 13, 3,-23, 33, 15, 2, -4, -1, 3, 8,
+ 8, 6, 6, -7, 8, 6, 9, -1, 3, -8, 0, -4, 1, -8, 11, -1 },
+ { 6, 5, -6, 16, 2, -3, 31, 21, -9, 12, 0, -1, -4, 1,-12, 3,
+ -13,-18, 2,-11, -9, 2, -8, -6, 11, -3, -1, 0, -1, 0, 13, 5 },
+ { 5, -1, 2, 0, 25, 5, 10, 16, -5, 21, 14, 12, 13, 2, -5, 5,
+ 5, -3, -2,-14, 0,-12, 7, 11, -1, -7, 19, -1, -1, -1, 8, -1 },
+ { 10, 7, 3, 11, 0, 8, 22, 3, 3, 19, -4, 12, 15, 9, 5, 15,
+ 2, 1, 2,-10,-10, 0, 2, -1, 0, 1,-12, -1, 21, 16, 9, -7 },
+ { 11, -4, -5, 24, -7, 11, 20, 11,-15, 18, 5,-13,-15, 0, -5, 9,
+ 1, 0, -1, -9, 4, -8, 6, -8, 1, -2, -7, 20, 9, 3, 9, 3 },
+ { 20, 0,-12, -6, 9, 31, 9, 12, 8, 27, 15, 7,-16, 5, -3, -7,
+ -1, -9, -2, -7, -3, 4, -8, -3, 3, -6, -2, -2, -3, -6, -1, 2 },
+ { 6, -6, 48, 8, -3, 19, 12, 11, -7, 2, 3, 0, -1, 1, 8, -4,
+ 4, -6, 0, -4, -4, -3, 3, 6, 3,-13, -8, 5, -3, -7, 8, 5 },
+ { 7, -2, 6, 11, 12, 2, 14, 4, -5, 12, 2, 9, 4, 2, 0, -1,
+ 2, 0,-15, -9,-16, -2, 8,-17, -5,-22,-19, -5, -1,-10, 1, -2 },
+ { 11, -9, 3, 12, 6, 6, 1, 17, -6, 19, 14, 7, -7, -1, -1, -9,
+ 9,-11,-17, 0, -6, 16, 0, 1, 9,-24, 3, 3, -9, -3, 3, -2 },
+ { 9, 0, 1, 8, 1, 7, 2, -5, -3, 8, -1, 7, 2, 6, -3, -6,
+ 5, -2, 6, -2, -4, -3, 0, -3, 13,-50, 1, -2, 2, 4, 4, 3 },
+ { 7, 0, 26, 21, -4, 2, 17, 8, 7, 11, -7, 1, -1,-15, -1,-15,
+ -11, -4,-17, -4, 1, -7, 3, 6, 3, -9, 2, 3, 6, 10, 6, 12 },
+ { 1, -2, 2, -1,-10, -4, 6, -3, -5, -2, -8, 2, 2, 2, 8, 0,
+ 1, 1, 6, 0, 11, 13, 3, 4, 0,-12, 11, -5, 19, 20, 2, 5 },
+ { 5, 3,-13, -2, 1,-12, 11, -7,-12, 7, 10, 0, 7, 0, -2, 4,
+ -6, -9,-11,-12,-23, 12, 10, -3, 0, 6, 19, -1, 24, 18, 9, 12 },
+ { 6, -3, 2, 5, 2, 2, -2, -5, -8,-11, -4, 3, -8, -4, 5, -3,
+ -16, -4, 3,-12, -4, 3, 32, 7, 2, 8, 32,-18, -1, 12, 1, 7 },
+ { 0, -8, -1, 0, -8, 7, -8, -1, -1, 4,-12, -1, 3, 0, 1,-18,
+ 8, 8,-14,-10,-11, 19, 9, 5, -7, 6, 8, -4, 26, 12, -1, 6 },
+ { 3, 5,-14, 7, 14, 8, 20,-13,-16,-10, -2, 17, -7, 4, -8, -9,
+ 14, -5, 3, -4,-12, 7, 14,-10,-19,-20, 35, 8, 13, 14, -2, 9 },
+ { -2, -4, -1, 1, -3, 0, -1, 1, 2, 2, 6, 0, 0, 4, 5, -2,
+ 3, 3, 3, -2, -7, -3, -3, -1, 6, -2, 29, 22, 13, 34, 0, 14 },
+ { -3, -9, 3, 1, 5, -4, 2, 0, 7, -9, 0, 2, -5, -3, 0, 6,
+ -1, -1, -1, 2, 2, 4, 8, 7, 20, -6, 7, 16, 33, 20, 6, -1 },
+ {-11, 1, -3, -3,-11, 3, -9,-25, -1,-16, 4, -8, 15, 1, -2, 7,
+ 8, 23, 2, 18,-13, 16, 3, -7, 6, 3, 16, -8, 12, 16, 3, 4 },
+ { 0, 5, 5, -5, 1, -1, 2, -3, -2, 1,-13, 2, 2, 10, 6, 7,
+ 18, 18, 7, 9, 8, 9, 21, 14, 7, 12, 15, 14, 15, 12, 11, 5 },
+ { 1, -5, 11, -2, 17, 8, 3, 0, -1, 6, 11, -7, 6, 6, 7, 5,
+ -15, 14, 1, 11, 4, 10, 12, 1, 2, 4, 30, 1, 11, 1, 6, 13 },
+ { 2, 4, 3, -7, 5, 8,-11, 7, -5, 9,-10, 6, 8,-10, -3, 10,
+ 1,-29, -4,-26, 5, -8, 13, 4, 3, 6, 35, 1, 3, 6, 3, 0 },
+ { -2, 1, 0, 0, -1, -3, -7, -3, -9, -3, -1, -6, 3, 4, 4, 0,
+ 5, -1, -2, -2, -1, -4,-10, 8, 0, -6, 10, -4, 46, 12, 2, 28 },
+ { 4, -1, 4, 1, 0, 4, -2, -2, -2, -1, 2, -4, 1, 5, 0, -3,
+ 1, 1, -2, 0, 1, -2, -1, -1, 3, -6, 35,-11, 13, 53, -3, -1 },
+ { -5, -2, 0,-13,-16, 5,-12,-11, 1,-30, 3,-18,-24, -8, -5,-19,
+ 1, -3, -8, 7, -7, -8, 15,-19, 4, 10, 30, 24, 6, 1, -9, 10 },
+ { -4, 8, -7, -4, -6, 12, -1, -9, -4, 2, -9, 3, 2, -2, 4, 2,
+ 22, 9, 4, -5, 0, 5, -2, -9, -3, 1, 18,-12, 18, 16, 4, 16 },
+ { -5, -8, -3, -5, -3, 6, -7, -3, -2, -5, -3, 1, 2, 2, 4, -6,
+ 10, 3, 12, -3, 20, 0, 27, -4, 16, 5, 18, -3, 23, 4, 12, 11 },
+ { 0, 1, 0, 1, -2, 1, 2, 1, -1, 0, -2, 2, -2, -4, 1, -2,
+ -2, -1, -5, -2, 0, 0, -2, 2, 9, 7, 63, 5, 12, -1, 1, 0 },
+ { 4, -3, -7, -5,-11, -5,-12,-10,-10,-12,-15,-12,-14,-14, 1, 1,
+ 10,-10, 16, 6, 2, 9, 11, 9, 9, 8, 12, -1, 13, 12, 6, 3 },
+ { 7, -3, -2, 4, 6, -8, 2, -3,-12, -5, -9, -8,-10, 15, -2, -4,
+ 8, 9, 7,-13,-18, 34, -5, 7, 12, 22, 16,-11, 13, 25,-15,-11 },
+ { -3, -2, 0, -4, 1, 0, -3,-13, -7, 13, 12, -7,-10, 13, 19, 6,
+ 16, 15,-12,-15, -3, 34, 1, 5, 1, -9, 11, 21, 8, 17, -5, -6 },
+ { 3, -5, 0, -4, 0, 4,-11, 4, -7, -3, -1, -8, 3, -2, 2, 1,
+ 11, 5, 6, 14, -3, 2, -4, -7, 0, 31, 15, -2, 24, 11, 5, 4 },
+ { -1, -4, -9, 5, -8,-18, -4, -9,-20,-18, 7,-14,-16, 3, 8, -3,
+ 29, 11,-13,-13, 7, 1, 17, 6, 6, 21, 11, 1, 14, -8, 2, 5 },
+ { -3, 8,-10, -6, 12, 2, 1, 3, 3, 3, 3, -6, -8,-14, 15, -5,
+ 16, 4, 16, 0, 7, -1, 0, 16, 2, 1, 22, 4, 19, 13,-11, 1 },
+ { 2, -3, 10, 20, -4, -1, -8, 5, -8, -9, -6, -2, -4, -7, 8,-10,
+ 0, 8, -6, 1, -8, 14, 13, 5, 17, -6, 26, -1, 7, -1, 0, 12 },
+ { -4, -7,-31, -2, -7, -1, 5, -5, -5,-12, 4, -7, -6, 3, 15, -2,
+ 5, -2, 7, -1, 10, 7, 8, -1, 14, 20, 14, 9, 16, 16, 8, 24 },
+ { -7, 0, -3, -6, 1, 3,-13, -6, -4, -4, -5, -9, -1,-10, -4, -8,
+ 2, 0, -1, 1, 24, 24, 21, 31, 5, 2, 11, 12, 7, 4, 3, 6 },
+ { -3, -5, 6, -4, -3, -1, 2, -1, -2, 1, 0, -8, -1, 2, 0, -4,
+ 6, 22, -1, -5, 8, 12, -1, -2, 28, 27, 20,-27, 14, 1, 2, -3 },
+ { 1, -5, -2, -2, 6, -2, 9, 1, -2, -5, 3, 4, 11, 5, 2, 8,
+ -3, -1, 1, -2, -3, -5, 5, 8, 49, 12, 8, -3, 9, 20, 12, 17 },
+ { -6, 0, 1, 7, 0, 9, -2, -4, 8, 0, -2,-10, 0, 7, 21, -1,
+ 0, 1, 17, -7, -5, 2, 4, 16, -2, 17, 14,-20, 15, 14, 4, 15 },
+ { 0, 3, -4, 9, -4, 0, 6, 4, -6, -6, -5, -7, 2, -9,-10, -2,
+ -5, 0, -3,-21, 9, 14,-11, 13, 29, 2, 25, 4, 22, -1, 2, -3 },
+ { 2, 12,-11, 2, 16, 9, -4, 7, 1,-10,-15, 11, -4, 3, -2, 4,
+ 4, -5,-10, 1, 4, 19,-15, 6, -4, -2, 30, -7, 11, 21,-12, 5 },
+ { -2, -3, -2, 4, -1, -5, -3, -7, -5, 1, 0, -6, 1, -6, 7, 0,
+ 8, -7, -3, -2, 2, 14, 2, -3,-26, -1, 26, 22, 32, 1, -2, 6 },
+ { 1,-38, -1,-20, -2, -3, -6, -4, 2, 2, 7, 0, 3, 5, 3, 10,
+ 6, 1, -3, -5, 7, 5, -5, -4, 8, 3, 1,-14, -1, -9, -5, -4 },
+ { -5,-26, -7,-19,-10, -5,-11, 5,-11,-25, -8,-14, -9,-16, -8, -6,
+ -17,-14, -1, -1, 6, 2, 2, 2, 3, 0, 2, 8, -8, 3, 0, -3 },
+ { 17,-49, -3,-23, -1, 11, 7, 3, 4, -4, 0, 0, -1, 4, 2, 4,
+ -2, -4, 2, -2, -1, -2, 2, 0, 0, -1, 0, 0, 1, 2, 0, 0 },
+ { 4,-34, -6, -9, 1, 21, -7, 3, -2, -1, -3, 18, 2,-16, 7, -3,
+ 8, 7, -5, 7, 2, 4, 8, -6, -7, -2, -5, -1, 4, 1, 2, -4 },
+ { 5,-29, 13, -2,-14, 3, 1, 18,-15, 4, -8, 8,-10, 8, 2, 1,
+ -8, 15, 3,-10, -4, -4, -2, 0, -3, -4, 2, -3, -4, -3, 12, -6 },
+ { 13,-20, 3,-18,-17, 4,-14, 13, 28, 11, -8, -6, 16, 6, 0, 10,
+ 3, 4, -9, 13, 5, -7, 12, -5, 0, -7, 5, 1, 3, 3, 2, 1 },
+ { 3,-27, -5,-11,-21,-11,-12, 0, -5, 7,-22, 1, 3, 5, 0, -5,
+ 8, 7, 1, -5, -7, 2, -5, 4, 1, 3, -8, -2, 0, 4, -2, 6 },
+ { 31,-45, 0, -1,-12, 1, 2, -6, 4, 3, -1, 3, 3, 0, 5, 3,
+ -5, 12, 4, 6, 2, 1, -2, 1, 3, 2, 5, 2, 2, 2, 3, -1 },
+ { 9,-45, 6, 5, -1,-17, -2, 18, -3, 2, 0, 1, 0, -1, 10, 8,
+ -7, -2, -5, -8, 6, -1, 0, 4, 6, -3, 12, -1, -2, 0, 5, -7 },
+ { 3,-26, -2,-12,-12, 2,-10, 16, -3, 12, 4, 5, 11, 8,-16,-17,
+ -2, -3, -3, 2, 5, -9, 13, 1, 10, 11, 3, 5, -2, 2, 2, -7 },
+ { 8,-26, 32, -7, -5, 22, 2, 14,-10, -8, -7, 3, 3, 7, 0, -5,
+ 0, -1, -3, 0, 8, 4, -5, -7, 6, -1, 4, 8, 1, 1, 7, -6 },
+ { 4,-31, 2,-14, 2, 0, 1, 8, -6, -1, 17, -3, 13, -6, 5,-10,
+ -2,-10, -2,-10, -3, 7, 1, 5, -8, 8,-14, -3,-15, 7,-10, -6 },
+ { 16,-27, 13, -4,-23, 7, -9, 6, -7, 5, 4, 2, -1, -3, 23,-18,
+ 7, 0, -3, 4, -3, 9, -6, -2, -1, 8, -6, 2, 6, -3, 2, -2 },
+ { -1,-35, -2, -8, 11, -1, -7, -3, -2, 11, 7, 6, -6,-10, 9, 6,
+ -3, -5, -6, -3, 9, 16,-16, -9,-20, 12, 3, 5, -3, 1, -9, 4 },
+ { 2,-24, 1,-12,-16, 5, -4, 3, -4, -1,-11,-11, -8,-14, 14, 10,
+ -8, 20, 8, -3,-11, 1, 1, -4, -4, -7, -3, 15, 2, -6, -2, 7 },
+ { 9,-21, 2,-19, -7, -5, -8, 25, 3, 17, 5, -3, 9,-12, 8, 2,
+ -4, 3, 3, 1, 11, -9, -4, -3, 4, 3,-22, 6, 4, 6, 11, -5 },
+ { 16,-23, 13,-17,-21,-12, 5, 9,-20, 7, 6, -6, 0, 2, -9, 6,
+ -6,-13, -7, -1, 5, -3, 5, -7,-10, 1, 0, 8, -9, 11, 0, -8 },
+ { 10,-26, -9, -7,-19, -4, 6, 16, -7, 5, -4, 4, 8, 0, 4, -1,
+ 6, -7, 1, -8,-11, 10,-14, 0,-16, 6, -3, 5, -1, 14, 12, 1 },
+ { 8,-27, 12,-14, -1, -1,-19, 10,-11, 21,-14, 9, -8, -3, 8, -1,
+ 12,-13, 3, -4, -2, 0, -9, 0, -7, 2, -3, 12, 1, -3, 3, 1 },
+ { 18,-20,-14,-14,-16, -3,-24, 6,-17, 2, -3,-11, 2, -3, 12, 10,
+ 10, 1, 10, 7, 8, 5, 5, 4, -1, 7, 2, 2, 0, 4, 7, 0 },
+ { 0,-30, 9,-16,-18, 15, 12, -3, 4, -4, -5,-11, -4,-12,-10, 0,
+ 2, -2, -4, -1, 2, 0, -1, -6, 2, -3, 4, -5, 7, 3, 5, 7 },
+ { 25,-24, -1, -6, -9, 6,-13, -2, 3, 15, -3, 11, 4, -8,-11, 2,
+ 0, -9, -2, 7, 4, 8, 5, -8, 5, 6, -1,-11,-15, -5, 0, 11 },
+ { 0,-34, -7,-11, -7, 9, -3, 19, 4, -8, 3,-11, 11, -3, -9, 12,
+ 9, 9, 2, 1, -7, 1, -3, 0, -6, -2, -1, 3, 0, -7, -2, -5 },
+ { 6,-34, -4, -5, -3, -9, 2, 9, -1, 9, -5, -3,-26,-12, 8, -6,
+ -7, 11, -8, 4, 4, 1, -1, 0, 8, 9, -4, 7, -1, 1, -3, -1 },
+ { 3,-30, 5, 6,-10, 3, -7, 6, 3, 3,-26,-19, -3, 1, 7, 5,
+ -4, -5, 6, 10, 13,-10, 4, -7, -4, 5, -3, 9, -6, 3, 9, 5 },
+ { 4,-24, 9,-19, 2, -4, -5, 8, -3, 2, 0,-15, -1, 9, -4, 22,
+ 6, 9, 3, 7, 11, -9, 0, -3, 4, 5, -5, 10, -8, 5, -7, -3 },
+ { 8,-27, 7, -3, -1, 2, -9, 13, 7, 12, -4, -6, -6, 5, 0, 7,
+ 5, 1, 15, -3, -4, 0, -5, -2, 7, -5, -7, 1, -2, 13, -8, 13 },
+ { 17,-22,-15,-11, -8, 16,-14, 18, 2, -1, 14, -7, 14, -6, -6, -7,
+ -8, 17, 6, 4, 4, -7, -5, -9,-14, -6, -1, 9, -3, 1, 6, -5 },
+ { 25,-30, 2,-12,-13, 18,-18, 16, 8, -3, 10, -8, -3, -1, -6, 3,
+ -5, -7, 4, 6, 7, 1, 1,-11, -5, 6, 2, -4, 9, -1, -5, -2 },
+ { 7,-23, 7,-15, -1, -3, -1, 0,-10, 12, 2, 5, -4, 0, 4, 6,
+ -1, 5, -9, -1, -1, -7, 1, 17, 9,-17,-16, 8, 4,-14, 11, 14 },
+ { 0,-31, 7,-13, 3,-11, -7, 6, 1,-11, 8, -7, 15, -3, 16,-11,
+ -1,-15, 16, -3, 5, 0, -2, -2, -6, 11, 5, 6, 5, -5, 6, 3 },
+ { 13,-24, -2,-20,-10, 7, -3, -1, 15, 2, 6, -5, -7,-10,-20, 1,
+ -4, 14, 8, -2, 3,-13, -3, 1, -4, 1, -3, 2, 8, -7, 16, -4 },
+ { 1, -2, -2, -3, -4, -7, 0, 3, 6, 7, 3, 2, 1, -2, -1, 0,
+ -6, 4, 2, -4, -3, -4, 5, 9, 5, 0, -3, -3, -4, -7,-31,-50 },
+ { -1, -3, 7, 2, -1, 2, 4, 6, 0, 10, -2, 0,-20, -6, -3, 9,
+ -20,-22, -1, -1, 15, 9,-12, 10,-13,-20, 12, 3, 5, 6, -7,-26 },
+ { 0, 4, -2,-14,-12, 6,-13, 11,-10, 3, 22, 6, 16, -2, -5, 1,
+ -3,-11, 0, -7, 5, -5, 0, 1, -1, -6, 8, 8, 10, 9, -5,-27 },
+ { -5, 10, -2, 7, 9, -9, 5, -9, 5, 4,-15, 14, 1, 3,-10, 5,
+ 0, -2, 7, 3,-13, 6, 9, -6, 5,-14,-17, -1, 11, 14, -2,-26 },
+ { 0, 6, -3, 0, -8, 6, 0, 1, 4, -8, 2, -5, 4, 7, 15, 11,
+ 9, 19, -2, 14, -8, 7, -1, 3, -3, -3,-10, -2, 12, -2,-12,-29 },
+ {-12, -5, 0, -3, -2, 6, 3, -3, 2, -2, 1, 11, 2, -7, 5, 1,
+ 2, -2,-14, 0, -1, -5, 3, 8,-28,-26, 6, -6, 3, 8,-10,-27 },
+ { -1, -3, 6, 2, 4, 15, 1, 0, 2, -2, -2, 13, 3, 6, 0, 6,
+ -1, -4, -1, -5, 8, -1, 5, -5,-15, 11, -8, -5, 14, -6,-14,-29 },
+ { -5, -6, 0, 1, 0, 6, -3, 2, -5, -1, 5, -3, 2,-10, 3, 4,
+ 3, 0, 13, -3, -1, 4, -4, -6, 2, 9, 8, 2, -3, 28,-11,-31 },
+ { 1, -4,-10, -9, -4, -3,-15, -6, 1, 5, -3, -6, 5, -6,-22, 27,
+ -13, 5, 3, -7, -4, 20, -7,-12, -1,-24, -4,-13, -8,-11,-15,-21 },
+ { -6, -4, 19, -6, 2, 11, -6, 1, -3,-10, 9, -9, 12,-10, 2, 1,
+ -9, 1, 15, 7, -5, 5,-29,-35, 4,-30, 9, 9, 19, 17, 2,-17 },
+ { -3, 3, -3, 1, 2, 5, -1, 5, -2, -3, 1, -3, -8, 3, -4, -2,
+ -4, -1, 12, 0, 2, -8, -6, -4, 16, -1,-14, -2, 25, -6,-15,-36 },
+ { 0, -1, 3, -4, -4, -1, 7, -4, 8, 0, 10, 9, -4, 1, 10, -1,
+ -3,-13, -5, -4, -1, -4, 8, 11, 14, -7, -5, 16, 12, 13, -1,-28 },
+ { 1, -2, 2, -3, -8, 10, 4, 9, 12, 3, 5, 0, 8, -3, -6, 2,
+ 16,-11, 11, 0, 1, 6, 1, 18,-10,-16, -1, -4, 5,-14,-15,-20 },
+ { 1,-12, 5, 4, -7, 8, -1,-17, -2, -9,-14,-11, 6, -9, 5, -4,
+ 3, -2, 7, 18, -5, 5, 6, -1,-11, -2,-10, -3, 8, -3, -2,-32 },
+ {-12, 5, 20, -5, -6,-11, -6, -6,-13, 4, -6, 19, -8, 2, 3, -9,
+ -4, -4, -1, 9, -1, 21, -1, 7, 15,-10, -1, -3, 9, -3, 2,-24 },
+ { 0, -3, 2, -6, 4, -1, -9, -2, -1, -3, 6, -1, -5, -6, -5, -8,
+ 0, -2, -6, 9, -4, 3, 2,-13, 1, -7, 23,-13, 4, -3,-15,-33 },
+ { -7, 2,-15, 11,-10, 14, 0,-11, 3, -1, 12, -4, -4, 9, 11,-13,
+ -13, -3,-14, 1, 3, 6, -5, 8, 0, 5, 5,-10, 4, 5, -6,-30 },
+ { -6, 4, 0, -5, 4, 1, -1, -1, 3, 6, 5, -2, -5, 0, -2, 5,
+ -4, -2, -4, -2, 4, 7, -7, -1, 1, -4, -3,-19, 37, 12, 10,-40 },
+ { -7, 2, -7,-12, 17, 11, -7, 2, 2, 3, 1, -1, 3, 4, -2, -5,
+ 9, -9, 6, 4, 9, 12, 11, -5, 2, -1, 0, 9, 5, -7, -2,-24 },
+ { -7, 6, 1, 3, 1, 0, 6, 0, 4,-12, -2, -2, 1, -9, 10, -2,
+ 11, -1, 21,-12, 15, -5, 10, -5, 5, -5, 14, -6, 5, -7, -3,-29 },
+ { -2, 0, -5, -2, -3, 1, -3, 0, 4, 2, 3, 0, 2, -2, 7, -2,
+ 3, -5, 2, -1, 6, -4, 0, -3, 8,-11, 19, -8, 22,-34, 13,-35 },
+ { -1, -3, -1, 9, 11, -3, -3, -1, 7, 18, 11, -5, 2,-12,-11, 18,
+ 9, -5, 1, -6, -9, 12, 1, -3, -3, -9,-14, 9, 9, 8, -6,-26 },
+ { 0, 5, -5, -1, -1, -2, 4, 6, 8, 2, -1, -2, 5, 1, -5, -4,
+ 1, 1, 18, 1, 7,-10, 3, -2, 12, -1,-15, 9, 12,-14, 13,-38 },
+ { 3, 0, -8, -1, 0, 8, -9, -3, -8, 16, 3, 16, -5, -9, 0, -1,
+ -7, -1, -4, 13, 7, 0, 1, 2, -1,-16, 0, -2, 1, 8, -8,-28 },
+ { 7, 9, -5, -3, -2, 2, 0, 3, 11, -6, -4, -2, -2, -5, 28,-18,
+ -6, 2, 15,-10,-15,-10, -2, 0, -2, -2, 4, -3, 7, 11, 5,-30 },
+ { 9, 0, -7, -1, -4, -7, 2, 2, 9, -2, 2, 3, -8, -6, -6, 3,
+ -10, 4, 10, 5, 21, -4, 14,-18, 1, 3,-10, -2, 6, 14, -8,-26 },
+ {-14, -1, 2, 3, -3, 7, 1,-22, -1, -1, 0, 1, 12,-14, 3, -5,
+ 0, 10, -3, 1, -5, 12, -3, 10, -8,-22,-11,-13, -7,-10,-13,-25 },
+ { -2, -5, -4, -4, -9,-18, 9, -3, -5, 17, 13, 5, 6, 11, 3, 8,
+ 20, 4, 2, 9, 8, 5, 6, 1, 7, -7, -6, -2, -7, 0,-17,-23 },
+ { -5, -5, 2, 0, 6, 2, -2, 2, -3, 4, 4, 0, -5, -2, -4, 6,
+ 8, 10, -1, 1, -5, 5,-14, -2,-11, 8, 6, 25, 7, -1, 0,-43 },
+ { -4, 0, 4, -2, 7, 0, 3, 17, 5, 2, -5, 1, 21, 3, -2,-10,
+ -16, -9, 7,-12, 9, -8, 2, 5, -5,-10, -2,-11, -5, -1, -9,-30 },
+ { -2, 3, 1, -4, -1, 0, 8, 1, 12, 4, -1, -1, 3,-17, 13, 9,
+ 0, 7, -6, -5, 9, 1, 5, 4,-10,-18, 0, 14, 11, -4,-16,-28 },
+ { -1, 0, 2, -1, 4, 1, -1, 1, -1, -2, -1, -2, 3, 0, 0, -1,
+ -1, 1, 2, -2, 3, 3, -2, 4, -2, -1, -6, 1, -1, -1, 6,-70 },
+ { 7, 3,-11, -1, 12, -4,-14, 4, 4, -4, 4, -2, 2,-12, -4, 15,
+ -17, -4, -3, 6, 8, -5, 22,-22, 5,-11, 15, -4, 4, -1,-21, -1 },
+ { 10, -2,-13, 11, 4, 14, 4, 9, 8, 8, 19, 15, 14, 15, 5, 10,
+ 8, 15, -5, 4, 14, -8, 1, 1, 2, 1, -1, -3, 21, 8,-29, 13 },
+ { -6, 0, -6, 6, -1, 2, 8, -4, -5, 4, -4, -5, 0, -2, -4, 0,
+ 9, -2, 1, -2, 26,-19, 21,-10, 4, 1, -8, 5, 22,-10,-13, 15 },
+ { 11, -5, 1, 0, 6, 3, 7, -2, -2, -3, -5, -1, -2, -6, 1, 1,
+ -8, -5,-13, 13, -2, -3, -1, -9,-28, 4, 2,-11, 18,-20,-24, 9 },
+ { 7, 4, -3, 6, 6, -6, -7, -5, -7, -4, -4, 0, -7, -5, -6, -5,
+ 2,-13,-12, 2, 0, 5, 18, 15,-13, -7, 13,-20, 16,-10,-19, 6 },
+ { 5, -8, -1, 5, 10, 2, -1,-10,-11, 23, 8, -5, -8, 4, -5, -4,
+ -5, -5,-11, -8, 5, 1, 7, -9, -9, -6, 12, 14, 17,-12,-22, 3 },
+ { -5, -8, -3, 3, 12, -1, 0, -4, -5, 1, 1, 6, 1, 5, -5, 7,
+ -2, 7, 1, 6, 6, 2, 0, -5, 17, -4, -5,-24, 13,-20,-27, 14 },
+ { -1, 2, -3, 1, -3, 1, -3, 0, -2, 3, -2, 1, 2, -1, -2, -1,
+ -2, -5, 5, -2, 0, -7, 1, -6, 8, 8, 11, -5, 24,-43,-13, 2 },
+ { -2, 4, 7, -3, -4, 4, 13, -4, 0, 0, -2, 9, 0, -3, -6, 1,
+ -7, 1, -1, 10, 0, 5, -1,-24, 25,-15, 7, 2, 22,-10,-21, 0 },
+ { -5, 2, 6, -2, 13, 3, 5,-12,-11, 16, 6, 10, -5, 0, -3, 6,
+ 5, -5, -5, 10, 12, 10, 11, -7, 8,-14, 2,-15, 13,-14, -8, -3 },
+ { 5, 6, -7, -5, 5, 2, 9, 5, 0, -1, -4, 2, 8, 0, 3, 5,
+ -12, 3, -3, -6, 2, -1, -5, 14, 11,-20,-21,-25, 24, -1,-10, 6 },
+ { -5, 5, -2, 9, 4, -4, -1, -6, 11, -6, 5, 0, 2, -3, 6, -1,
+ -17,-18, -4,-13, 9, -1, 9, -7, -4, -8, 2, -3, 12,-31,-18, 5 },
+ { -7,-11, 6, -8, 4, -3,-12, 0, -1, -6, -3, 0, 5, 9, 7, 2,
+ 1, -8, -6, 8, 2, -5, 7, -1, 16,-10, 16,-12, 18, -1,-25,-12 },
+ { 3,-12, 1, 2, -2,-18, -8,-15,-10, -9, 2, -7, 11,-11, 2, -1,
+ -1, -1, -9, -6, 3,-14, -2, -1, 2,-13, -7, -9, 19, -5,-17, 2 },
+ { 7, 1, -8, 7, 17,-13,-10, 5, 7, 1, -6, 4, 9, -4, 0, 3,
+ 8, 1,-14, -9, 4, 7, -9, 0, 6, -5,-12, -2, 25, -2,-19, 1 },
+ { 7, -3, 6, -3, 1, 6, -7, 0, 10, 0, 4, -5,-17, -4, 4, -1,
+ 0, -3, -7, 19, 24, -1, 21, 8, 10, 9, 8, -1, 23, -2,-18, -2 },
+ { 3, -3, 0, 5, 8, -2, -9, 2, 9, 6, 19, 8, 2, 6, -9, -2,
+ -4, -3, -8, 7, -7, -8, 5, 4, 26, -6, 7, 18, 24, 0,-13, 4 },
+ { 0,-13,-11, -1, 3, -9, 5, 4, -7, 3, 0, 2, -1, 4, -5, 2,
+ 9, -2,-11, 15, 1,-21, 1, -1, 0, 4,-14, -4, 24,-16,-13, 1 },
+ { 1, -9, -8, 0, 0, -4, 11, -1, 14, 16, 0, 17, -2, -9,-12, 0,
+ -1,-14, -9,-14, 0, -2, 19, 4, 6, 4, 4,-11, 8,-17,-19, -5 },
+ { -3, 1, 2, 12, -4,-18, -1, -4, -7, 14, -3, 2, 0, -7, -8, 12,
+ -5, -9, 14, 12, -9, -2, 4, -6, 4, 18, -1,-25, 22, 2,-23, -5 },
+ { -2, 0, 0, 0, 1, 3, 5, -1, 5, -2, -2, 2, -3, 0, 1, 2,
+ 0, -1, 2, -1, -9, -6, -7, -4, -2, 4, -7, -5, 64, -3,-25, 4 },
+ { 12, -2, -3, 0, 8, -9, 13, -7, 6, -3,-12, 12, 15, -9, -4, 2,
+ 9, -4,-12, 3, 14, 1, 7,-15, 15, 0, -6,-12, 0, -3,-20, 6 },
+ { 2, -1, -4, 5, 9, 6, -7, 2, -2, -7, -2, 0, -1,-18, -4, -6,
+ -15, -5, 11, 5,-10, -1, 2, 7, 12,-19, -7, 8, 21, -4,-15, 4 },
+ { 4, 2, 5, 5, -5, 1, 3, 2, -8, 13, 0, -5, -2,-14,-11, 6,
+ 2, 17, 8,-13, 26, -2, 5,-15, -4,-14, 12, -9, 13,-21,-23, -4 },
+ { 2, -3, -2, -3, 3, -2, 6, 9, -9, 13, 4, 2, 12, -3, -3, 1,
+ -17,-22, -3, 4, 3, -2, 1, -9, 1, -6, 11,-13, 14, 0,-15, 6 },
+ {-16, -4, 17, -2,-20,-11, 11, 10, 5, -8, 16, 2,-17,-14, 11, 11,
+ -6,-11, -7, 12, 12,-10, -6, 5, 8, -4, -2, -5, 28, 3,-13, 4 },
+ { 0, -3, 3, -7, 6, 8,-12, 20,-19, 18,-11, 10, -5, 0, -9, 11,
+ 3, 0, -2, 9, -7, -5, 18, 3, -2,-16, 1, 6, 12, -7,-16, 1 },
+ { 4, 1, 5, -5, 15, 2, -8, 3, 5,-11, 15, -3, 8, -8, -1, 7,
+ 4, 7, -2, 6, -9, 5, 12, 2, 33, -2, -6,-18, 4, 0,-18, 11 },
+ { 3, -1, 1, -1, 0, 1, 4, -1, -5, 0, 1, 0, 4, 2, -1, 4,
+ -3, 2, 0, -2, 4, 6, -1, 6, 42, 19, -4,-37, 19, 1,-15, -4 },
+ { 2, 0, -5, 0, 10, 0, 0, -5, 3, 0, 0, -3, -3, 0, 2, -4,
+ -10, 2, -6, 4, 4, 1, 27, -7, 17,-34, 5, -9, 15,-16, -7, -5 },
+ { -2, 7, 7, -2, 9, -2,-15, 11, 11, 7, 5, 1, 15, 1, -9, 31,
+ 2,-15, 2, 4, 3, 4, -1, -8, 2, -7, 6,-17, 11,-14,-11, 2 },
+ { 1, 1,-11, 9, 9, -6,-14,-11,-10, 8, -3, 11, 16, -9, -8,-13,
+ -8, 9, 0, 6, 6, -2, 13, -8, -2, 3, 13, -3, 10, -6,-17, 4 },
+ { 14, 5, 4, -6,-12, 10, -7, 8, 21, -8,-30, 15, -2, 1, 11, -9,
+ -5, 1, 0, -1, -1, -6, -2, 3, -5, 7, 9, 5, -5, 2, 0, 1 },
+ { -1, 2, 20,-17,-15, 3, 3, 7, 11,-17,-13, -6, -3, 18, 17,-15,
+ -4, -4, -5, 22, 14,-14, -2,-10, -7, 11, 8, -7, -3, 0, -7, 11 },
+ { 7,-11, -7, -8,-14, 22, 5, 2, 6, 13,-12, -2, 10, 3, 0,-21,
+ -4, 20, 3, 10, 21,-10,-12, 8, 11, 2, -5, 2, 1, 3, -1, 15 },
+ { -1, -2, -1, -2,-13, 8, -4, 0, 7, -2,-17, 8, 18, 5, 3, 8,
+ -8, -2, 3, -4, 14,-18,-13, 14, 15,-13, -1, -2, 4, 11, 1, 12 },
+ { 13, -6, -4,-16,-17, 16, 21, -2, 5,-11, -9, 19, 21,-17, -3,-17,
+ 3, 12, 8,-12, -6, 1, -7, 9, 9, -7, -5, -1, -3, 5, -6, -4 },
+ { 11, 5, 12,-20, -6, 10, 4, 12, 8, -5,-10, 15, 13, 14, 10,-15,
+ -13, 1, 6, 14, 15,-17,-13, 4, -5, 10, 7, -6, -8, -3, -4, 12 },
+ { 25, -1, 7, -5, -7, 11, 1, 17, 13,-15,-14, -4, 5, 3, 8, -3,
+ -2, 2, 0, 6, 16,-12, -6, -4, 4, -3, 7,-10, -3, -7,-13, 7 },
+ { -8, 10, -3,-13, 5, 2, 4, 9, 9,-17,-13, 2, 11, 1, 6, -4,
+ 8,-10, 4, 1, 19,-15, -4, 12, 31, 7, -5,-17, -4, 9, -2, 7 },
+ { 14, -6, -6, -6,-14, 13, 17, -5, 4,-14, -9, 7, 7, -9, 3,-16,
+ -15, 11, 11, 6, 4,-11,-19, 3, 5, 8, 13,-14,-14, 3, -4, 12 },
+ { -2, -4, 10, -4, -7, -1, 27, 5, 2,-16,-18, 4, 12, -2, -3, -2,
+ -1, 1, -8,-12, 3, -4, 8, 15, 2, 4, 9,-13,-14, 9, -7, 5 },
+ { 4, 2,-10, -5, -7, 2, 1, 4, -1, -6,-15, 6, 1, 10, 5,-10,
+ -9, -1, 13, -3, 5,-21,-11, 8, 8, 5, 27,-21,-18, -5, -1, 15 },
+ { 11, 1,-16, -8,-11, 0, 5, -8,-12,-13,-17, 22, 4, -6, -1,-18,
+ -10, 0, 19, 2, -2, -8, -7, -3, 2, -2, -9,-17, -5, 4, 4, 10 },
+ { 8, -6,-19, -5, -4, 12, 14, 15, 10, -9, -1, -9, 19, 12, 0, -1,
+ 2, 4, 7, 9, 16,-16,-14, 9, -4, 3, 1, 0, -2, 10, -1, -1 },
+ { 12, -8, 12, -9, 0, 25, 7, 9, 2,-31, -9, -4, 15, 4, -5, 1,
+ -10, 11, 8, 10, 0, -6, 5, 11, -1, -6, 4,-10, -9, 6, 4, 5 },
+ { 14, 6,-17, -2, 17, 12, -9, 2, 0,-25,-14, 5, 20, 14, 8,-20,
+ 5, 2, -2, -3, 9,-13, -3, -1, -6, 3, 7, -6, 0, 2, 3, 1 },
+ { 8, 4,-15, -3, 10, 18, -4, 13, 8,-22,-10, 9, 19,-15, 7, -5,
+ -13, 12, -4, 9, 2, -9, -6, 0, 2, 1, -9, -6, 6, 1, -1, 11 },
+ { 4, 1, 4, -5,-10, 18, 7, 2, -4, -9,-11, 0, 32, -7, 4,-16,
+ -1, 0, 6, 3, 6, -3,-14, 16, 9, -2, 7, -1, 0, -5, 5, -3 },
+ { -3, 2, 3, -8, -6, 4, 6, 2, 4,-12,-15, 2, 8, 8, 9, -3,
+ -18, 6, 34, 11, 12,-15, -1, 2, 9, 2, -4, -4, 2, 4, 2, -3 },
+ { 18, -6,-12, -8, -1, 15, 20, -4, -1,-11, -5, 6, 6,-11,-15, -7,
+ 3, 7, 10, 2, 8,-10, -5, 8, 15, -5, 5,-17,-13, 13, 11, 7 },
+ { 8, -4, -6, -1,-14, -3, 6, -2, 1, -5, -1, 10, 10,-15, 5, 0,
+ -10, -4, -3, 7, -4,-19,-15, 27, 11, 18, 3,-19, -2, 6, 0, 12 },
+ { 12, 0, -5, 0, 4, -5, 1, 5, 10, -7,-11, 21, 29, 1, -2, 1,
+ -4,-11, -1, 13, 11,-20, -1, 4, 4, 4, -5, 6,-13, -2, 11, 9 },
+ { 2, -7, -7, -3,-10, -1, 20, 12, 1,-19,-19, -1, 5, 4, -7,-25,
+ 14, 1, -3, 2, 12, -4, -3, -3, -2, 6, 1, 0, 3, 2, 5, -1 },
+ { 12, -8, 3,-12,-10, 10, 13, 0, 23,-14,-18, 10, 0, 15, 3,-12,
+ -3, -5, 5, -4, 2,-14,-10, 8, 2, 9, -1,-11, -3, 5, 13, 2 },
+ { 9, -6, 7, -7,-30, 17, 6, 13, 1,-14, 0, -1, 6, -9, 8, 3,
+ -4, 0, -1, -7, -5,-13,-19, -3, -4, 4, -6, -2,-13, 1, -2, 3 },
+ { 10, 1, 3,-18,-26, 17, 4,-16, 4, -3,-13, -4, -6,-11, -4,-21,
+ 7, 8, 2, 5, 13, -6, 1, 5, 8, 7, 9, -6, -6, 1, -1, 2 },
+ { -3, -1, 0, -2, -2, 0, -1, 3, 4,-14, -8, -9, 13, 2, 50,-23,
+ -8, 8, 7, 11, 16, 3, -7, 0, -2, 6, 5, -1, 1, -2, 4, 3 },
+ { 1, 3, 1, 1, -6, 3, 6, 6, 2, -2, -3, 10, 2, -8, -5, -5,
+ 5, 4, 4, -2, 10, -8,-40, -1, 21, 8, 3, -4, -1, 13, 4, 7 },
+ { 2, 0, -4, -8, 5, 2, 7, -5, 5, -8, -4, -1, 12, 2, 12,-13,
+ -9, 0, 1,-12, 9,-43, 1, -5, 12, 1, 3, 6, 1, -1, 3, -2 },
+ { 6, -2, -1, 1, 0, 4, 8, 14, 4, -7,-23, -5, 23,-17, -6,-15,
+ -8, 7, 10, -1, 7,-16, 4, -6, 2, 3, -3, -3, -1, 8, -1, 4 },
+ { 10, 4, -4, 1, 7, -3, 2, 11, 4, -6, -3, 8, 5, 4, 1,-45,
+ -6, -4, 4, 2, 1,-14,-10, 1, 1, 6, 2, -8, -1, -3, 3, 3 },
+ { 1, -1, 2, -3, -8, 9, 3, 3, -2, -5, -8, 8, 7, -7, -4, -6,
+ 5, -9, 11, -2, 46, -5, -1, 9, -2, 0, 3, -5, -3, -5, 7, 0 },
+ { -4, 1, -2, -1,-11, 11, 8, -3, -2,-10, 0, 4, 9, 9,-17,-17,
+ -34, -4, -5, -7, -3,-12, -3, 11, 18, 3, -2, -5,-18, -5, -3, 6 },
+ { 7, -5, -3, 1, -4, -3, -5, -1, 2, 5, -2, 3,-10, 12,-18, -5,
+ -10, 12, -9, 4, -6, 2, 0, 16,-17, 15, 14,-12,-10, -2, -9, -1 },
+ { 4, -5, -3, -5, -3, -1, 7, 18, -7, 12, 3, 5, -8, -4,-20, 1,
+ -25, 1, -8, 13,-10, 8,-19, -1, -8, 10, 6, -9, -1, 0, 12, 4 },
+ { -4, 5, 0, -1, 2, 5, -8, -2, -6, 4, -8, 9, 3, 2, -7, 4,
+ -25, 13,-23, 10, 14, 15,-11, 3,-18, 4, 16, -4, 1,-10,-10, 3 },
+ { 5, -3, -1, -3, 4, 1, -3, -4, -5, 1,-12, 14, -7, 11,-15, 6,
+ -6, 24, -4, 13, -1, 15,-13, 8, 3, 7, -5, 2, 2, 0, 3, -7 },
+ { -3, 1, 0, 8, 6, -1, 6, 5, -5, -2,-12, 4, 0, -2, -3, 5,
+ -6, 0, -8, 9,-10, 4,-28, 12,-20, 11,-13, 7,-18, 1,-11, 1 },
+ { 1, -4,-15, 5, 0,-13, -5, 13,-11, 4, -4, -5, 5,-14,-16, 0,
+ -14, 5,-20, 12, 10, -7, -5, 6, 6, 22, 6, -4, -2, 3, 8, 11 },
+ { 13,-11, -2, 16, 16, -7, 0, 20, -7, -1, 0, 5, -9, 12, -2, -5,
+ -22, 5,-10, 12, -6, 11, 9, 21, -8, 15, 4, 0, -8, -4, -4, 10 },
+ { 18, -4,-13, 0, 1,-15, -1, -3, 2, 10, -1, 6, 1, -4,-20, -5,
+ -8, 6, -8, 17, -5, 5,-10, 8,-22, 6, -5, -2, 8,-17, 8, 2 },
+ { 1, -2, -9, 6,-31, -8, -8, 8, 0, 5, -9, -4, 2, 3,-12, 11,
+ -18, 10, -5, 3,-11, 13, -6, 11, -3, 12, -7, 3, -9, -1, 2, 11 },
+ { -9, -6, 21, -8,-15, 4,-11, 12,-11, 17, -1, 2, -6, 0,-15, 13,
+ -12, 19, 0, 2, -6, -3, -9, 10, 3, 17, -2, 5,-10, -3, 0, 1 },
+ { 4, -6, 5,-10, 1, -5, 1, 0, 0, 0, 2, 7, -2, 2, -2, 0,
+ -4, 3, -4, 1,-12, 6,-49, 16,-10, 13, 0, -2, 8, 6, 1, 8 },
+ { 5, -8, -7, 9, 13, -5, 7, 0, 10, 11, -4, -3, -1, 13,-14, 6,
+ -15, -6,-14, 16, 15, 1,-18, -4,-20, 20, -7, -1, -9, -2,-10, 10 },
+ {-12, 4, 0, 10, 0, 3, 8, 4,-27, -1, -2, 19, -4, 2,-13, 3,
+ 1, 9,-12, 1,-22, 19, -5, 4, -9, 12, 2, -9, -8, 11, -3, 7 },
+ { 4, -5, 11, -6, 17,-17, 5, -4, -2, -6, 1, -5, 2, 4,-14, 6,
+ -20, 19,-20, 12,-21, 5,-14, 13, -2, 11, 4, -3, 0,-10, -4, -2 },
+ { -2, -1, -3, 8, -9, -7,-22, -3,-24, 13, -2, 10,-15, 5, -9, 4,
+ -7, 0, -5, 15, -8, 11,-13, 6, -4, 19, -8, 12, -4, 6, 9, 7 },
+ { 2, -3, 2, -1, 0, 3, 1, 2, 1, -4, -2, -3, 1, 5,-12, 6,
+ -16, 14,-23, 10,-14, 17,-15, 16, -2, 9,-25, 9,-10, 16, 4, 9 },
+ { -3, 7, -8, -3, 2, 2, -4, -8, -9, 10, 3,-11, 25,-10,-28, 27,
+ -9, 7,-13, 9, -2, 4,-12, -8,-14, 6, 7,-10, 3, 3, -3, 5 },
+ { -8, -3, 1,-10, 8, -3, -9, -4, 13, 7, 2, 4,-10, 4, 3, 7,
+ -18, 2,-22, 15, 4, 20, -7, 5, -6, 13, -1, 4, -7, -6, 6, 13 },
+ { -2, 3, 0, 2, -4, -2, 0, 0, 1, 2, -2, -5, 0, 1, -4, 0,
+ -2, -3, 1, 2, -1, 2, -8, -1,-24, 68, -3, 8, 3, 3, -1, -1 },
+ {-15, -2, -9, -7, -1, 8,-14, 8, 3, 6, 0, -1, -8, 8,-23, 2,
+ -14, 17,-15, 8, -4, 7,-18, 0, -8, -3, -1, -4,-10, 4, -1, 4 },
+ { 8, 0, 2, -7, 0, 5, 1, 3,-11, 4, -8, 14, 3, 20, 1, 26,
+ -11, 13,-13, 20, -2, 0, -8, 2, -6, 6, -1, 9, 3, -6, -3, 10 },
+ { 5, 0, -1, -7, 10, 1, -3, 5, 4, 7, -5, -1, -3, -1, 12, -3,
+ -15, 7, -9, 22,-19, 8, -9, 4,-23, 13,-14, 6, -6,-14, -4, 7 },
+ { 14, -5, -8,-10, 25, 3,-23, -7,-28, 0, -1, -9, 4, 1,-13, 20,
+ -8, 10,-16, 8, 12,-13,-21, 5,-13, 11, -2, 1, 12, -7, 2,-10 },
+ { -5, -4, 9, 5, -6, 35, -7, 8, 15, 2, -1, -9, -6, 2,-18, 7,
+ -15, 6, -3, 2, 8, 12,-30, 7, -4, 20, 2, 6, 13, -6, -4, 0 },
+ { 1, 8, -9, 9, -5, 12, -9, 16, -9, 16,-17, 14,-13, 15,-18, 14,
+ -15, 17,-12, 14,-13, 7,-16, 13, -9, 5,-11, 10, -9, 6,-12, 13 },
+ {-10, -4, 5, 3, 1, 6, 8,-14, -5, 15, 7, 4, 8, 7,-22, 8,
+ -7, -8,-15, 26, 1, 13, -3, 17, -5, 9, -2, 4, -6, 3, -8, 9 },
+ { 8, -3, 2, 3, 3, 1, -2, -1,-11, 8, -4, 0, -6, -5, -1, 13,
+ -37, 9, 1, -6,-10, -2,-10, 11, 8, 13, -3, -2, -6, 8, -4, 13 },
+ { 3, 2, -3, -4, -4, 7, -8, 9, -8, 9,-20, 12,-19, 15,-18, 17,
+ -15, 7, -1, 20,-11, 6, -6, 3, 1, 9, 2,-14, -2, -2, 2, 1 },
+ { -7, 1, -1, -3, -6, 4, 4, -3, 3, -1, 5, -4, 3, 2, -1, 9,
+ -59, 5, -4, 30, 3, 3, -2, -3, -1, 2, 2, 1, -1, -1, -2, 1 },
+ { 0, -3, 2, 0, -1, -8, 0, 2, -3, 4, -4, 1, 10, 6, -6, 8,
+ -7, 4, 10, 11,-41, 27,-20, 3, -3, 8, 1, 11, -5, -8, 0, 4 },
+ { 5, 1, 4, -2, 1, 2, -1, 6, -7, 2, 11, 4, 0, 0, -8, 7,
+ -10, 0, 0, 8, 2, 10, -1, 1, -2, 44, -2,-21,-12, -3, -1, 2 },
+ { -4, 4, -2, -2, 6, -8, 2, 1,-10, 14, 8, 6, 5, 1, -2, 4,
+ -13, 4, 2, 5, 10, -2,-21, 32, -3, 18, 9, -6, -9, -9, 10, 2 },
+ { 9,-16, -6, -2, 1, 4, 22, 2, -2, 1, -3, -2, -9, 3, 16, 19,
+ -24, -6, -6, -5, -8, -7, 8, -7, -1,-12, 5, -3, 0, 4, 2, -3 },
+ { 10, 3,-16, -4, -1, 13, 4, 4, 1, -3, 1, -6,-14, 18, 3, 8,
+ -8,-28,-16, 4, 4, 2, 12, 7, 9, -4, -4, 5, -1, -1, 2, 2 },
+ { -5,-13,-22, -3, -8, 21, -2, -9, 21, -4, -9, 5, -8, 15, 5, 1,
+ -5, -9, -7, -2, -5, -5, -1, -5, -5, -5, 3, 10, -4, 0, -7, -2 },
+ { 5,-10,-18, 2, 20, 4, 13,-10, 8,-15,-11, -3, -1, 16, 10, 9,
+ -8, 6, 7, -5, 6, 11, 5, 17, -4, 7,-11, 5, -3, -6, 2, 1 },
+ { 3, -5,-19, 1, 1, -3, -2,-25,-11,-17, 0,-13, -4, 10, 10, 2,
+ -5, 4, 0, 3, -3, -5,-10, -2, 13,-22, 0, 3,-11, -5, 7, -1 },
+ { 12,-14,-29, 6, -1, 10, 7,-17,-12, 14, 3, 9, -9, 9, 7, 6,
+ -3,-13, 0, 5, 3, -1, -6, -1, 0, 2, 4,-12, -5, -1, 2, 11 },
+ { 12,-15, -7, -2,-12, 17, 20,-16, -2,-12, -6, 15, -6, 12, 11, 9,
+ 7, -6, 7, -4,-19, 6, 2, 2, 3,-11,-10, -4, -5, -3, 3, 2 },
+ { 11,-22, -6, 0, 8, 18, 3,-11, -4, -7,-15,-17,-12, 6, 16, 4,
+ -9, 4, -5, 3, 6,-16, 10, -7, -7, -3, 5, 0, 1,-15, -4, 5 },
+ { 12,-22,-16, 5, -6, 8, 12, -4, -9,-17,-11, 3, 5, 8,-17, 0,
+ 11, -4,-13, -6, 2, -1, -1, 3, 3,-11,-12, -1, 1, 1, 12, -2 },
+ { 8,-10,-33, -5, -3, -6, 1, -7, -8, -4, -6, -1, 5, -4, -6,-12,
+ -16, -8, 11, 8,-14, 7, 12, 11, 4,-14, -3, 6, -7, -5, -3, 3 },
+ { 0, -8, -7, 2, -4, 24, 2, -9,-11, -3, -7, 11,-12, 17, 1, -1,
+ 3, -5, -7, 12, 4, 11, 0, 3, 2,-18, -3, 4, 7, -6, 3, 15 },
+ { 10,-15,-16, -2, -4, -9, 7,-15, -6, 2,-16, 13, -8, 7, 19,-21,
+ -4,-12, -9, -3, -3, 6, 11, -3, -1,-19, 3, -7, -9, -4, 3, -6 },
+ { -5,-10,-21, 0, -3, -7, 18,-21, 15, -5,-12, -4,-13, 2, 6, -9,
+ -9,-11, -4, 13, -3, 6, 4, -1, 7, -9, -4, 9, 5, 2, 6, 3 },
+ { 15, -1,-27, -2, 10, 3, 7, -8, 9, -2, 7, 1, -2, -5, 18, 9,
+ -11,-17, -2, 7, -9, 11, 10, 0, -8, 6,-16, -3, 2, -7, 3, 11 },
+ { 4, -9,-39, 19, 6,-13, 13, -5, -5,-15, -2, 9, 0, 4, 14, 6,
+ -10, -4, -5, 2, -4, -2, 5,-11, 3, 3, -2, -2, -7, 9, 7,-10 },
+ { 5,-11, -8, 10, -2, 12, 16, 0, 12, -2, -6, 8, 14, 8, 7, 1,
+ 18,-30, 4, 10, -4, -6, 2,-11, 9,-10, -8, 5, 0, 0, -7, 6 },
+ { -1,-16,-10, 11, 0, 13, 12, -4, -4, -5,-21, 12, 4, 13, 14, -7,
+ 6,-16,-13, 8, 2, 9, 15,-12, 1, -9,-22, 10, -9, 9, 9, -7 },
+ { 4,-12,-27, 1, -2, 11, 15, 3, 14,-14, -9, 0, -9, 16, 22, 10,
+ 16,-10, 5, -5, -9, 1, 1, 6, 6, -4, 2,-17, -5, -6,-15, -1 },
+ { 7,-12,-17, 1, -9, 5, 20, -7, 3, 23, -8, -8, -8, -1, 13, 17,
+ -7,-13, 4, -4, 7, 14, 8, 11, -3, -3, 4, 0, 4, 6, -1, -9 },
+ { 7,-15,-15, -4, 10, 12, 3,-13, 6, 14, 9, -8,-15, 14, 23, -5,
+ -10, -5, 1, 15,-10, -7, 1, 9, 4,-13,-10, 10, 7, -3, 2, 3 },
+ { 4,-10,-14, 0, 3, 4, 0, -9, -3, -4,-11, 2,-17, 8, 2, 15,
+ 6,-12,-12, 15, -5, 17, 18, 3, -3, -3, -4, -6, -8, 13, 4, 10 },
+ { -2,-18,-26, 10, -4, 10, 13, 4, -4,-16, -7,-17, -3, 5, -4, 2,
+ -15,-10, -1, -8, -7, -3, 2, 2, 8,-10, -7, 2, 2, -4, 4, -1 },
+ { 4,-19, -5, -1, -1, -6, 2, -8, 10,-16,-28, -6, 8, -1, 11, 28,
+ 2,-10, -4, 6, -6, 6, 11, 15, -4, -2, 7, 3, 7, -7, 4, 1 },
+ { -3, -6,-10, -5, 13, 18, 10,-15, -5, -3,-13, 5, 1, 2, 18, -5,
+ -10,-10, -7, 4, 2, 1, 5, 4, 2, 5, 4, 8, -9,-17, 7, 7 },
+ { 20,-12, -2, -4, 5, 14, 7,-11, -1,-16, -6, -4,-11, 17, 14, 0,
+ -8,-10, -8, 10, 3, 5, 10,-16, 3, -8,-14, 10, 3, 9, 0, 3 },
+ { 12,-10,-36, 0, 7, 15, 2,-16, 2, -1, 0, -1, 5, 4, 5, -3,
+ 1,-10, 5, -1,-15, -3,-12, 12, 2, 5, -1, 5, 6, -3, -2, 2 },
+ { 17,-15,-31, 23, -4, 15, -2, -3, 6, -7, -5, 1,-12, 4, 6, 8,
+ -10, 8, 3, 5, -4, 1, 5, 3, -1, -4, -3, 1, 10, -4, -2, -2 },
+ { 6,-18, -5, 12, 10, 12, 14,-11, 15, 2, -9, -6, -5, -2, -9, 4,
+ -5,-28, -4, 14, 0,-16, 9, 14, -1, 3, -4, -4, 2, 1, 0, 4 },
+ { -5,-14,-31, 8, 16, 7, 13,-13, 5, 6,-16, 10, -5, 2, -2, 2,
+ 14, -5, 8, -5, 7,-16, 6,-13, -5, 0, -5, 8, -3, -1, 4, 3 },
+ { 1, -2, -1, 0, 6, 5, 2, -4, -3, -1, 0, 1, 4, 2, 43, 28,
+ -12,-35, -2, -2, -7, -1, 0, 2, -1, -2, -2, 1, -4, 0, -2, 3 },
+ { 2, -9,-22, 12, 3, 3, -7, -4,-19,-22,-14, -4, -1, 21, 9, -3,
+ -15,-16,-13, 1,-11, 4, -9, 1, -7, -1, -1, 0, -2, 9,-13, -3 },
+ { -1, -3,-23, 0, 2, 12, 3, -9, -4, 7, 3, 9,-10, 1, 27, 28,
+ 0, 9,-15, -2, -2, 1, 6, 8, -8, 7, -3, 20, 0, 0, -1, -6 },
+ { -1, 11, 8, -2, 1, 5, -6, -1, 4, 2, -4, 0, -1, -5, 4, -6,
+ -10,-12, 19, 1, -7, 9, -8, -9,-16,-11, -2, 12, 14, 4, 4, 34 },
+ { 17, 7, -6, 1, 4,-10, -5, 4,-11, 3,-18, 4, 14,-13, -3, 1,
+ 0, 0,-11, 0, 7,-17, -4, 4,-11, -6, -8, 18, 0, 0, 0, 26 },
+ { -6, -7, -1, -1, 11, -8, 1, 3, 2, 11, -6, -6, 10, -3, 1, -3,
+ 7, 4,-12, -8, 0, -9, 8,-22, -5, 0, -6, 22, -2, 11,-13, 24 },
+ { -3, 4, 0, 3, 9, 10, -1, 3, -9,-12, 1, -5, 18, 0, -3, 8,
+ 25, 15, -8, 2, 2, -2, 4, 8, 9, -1, -5, 10, -3, 1, -1, 23 },
+ { -5, 2, -9, -1, -3, 0, 3, -1,-10, -4, 0,-13, 16, 9, -1,-14,
+ 2, 6, -2, -6, -5, -2, -7, 7, 5, 3, 11, -2,-14, 0, -9, 30 },
+ { 4, 6, 6, 5, -3, -1, 4, 5, 10, 0, 5, -4, 7,-11, 14, 14,
+ 7, 34, -9, 0,-10, 22, -7, -1, 7, -9, 2, -8, 0, -7, -5, 29 },
+ { -4, 3, -1, -4, -3, 5, 1, -4, 0, 2, 4, 2, 1, -1,-10, 1,
+ 6, -6, -4, 1, 4, -3, -3, -5, 0, 3, 7,-12, 0, -2,-10, 55 },
+ { 5, 9, -1, 0, 4, 9,-21, -9, 4, 2, 6, -7, 11, -7, 1, -5,
+ 0, -4, 2, -3,-13, -8, 0, -9, -4, 2, 16, -2,-15, -7,-11, 31 },
+ { 8, 2, -1, 0, 3, -5, -5, 5, 1, -1, -9, 1, 0, -6, -2, -1,
+ 5, 2, 0, 0, 12, 20,-19, 1, 8,-12,-11, 0, 6, -5, 2, 31 },
+ { -1, -1, -2, 1, -1, 3, -9, -5, 8, -2, 5, -1, 0, -2, 4, -2,
+ -3,-12, 0, -2, 3, 0, 9, 4, -1, 21, -8, 3, -4, 9, -6, 30 },
+ { -4, 0, -7, 17, 10,-12, -2,-10,-12, -3, 10, 0, 11, -4,-13, -3,
+ 5, 6, 10, 7, -8, 0, -7,-13, 1, 0, -2, 7,-12, 4, -3, 24 },
+ {-13, 9, 4, -2, 2, -4,-14, -1, -3, -5,-10, 4, 13, -2, 5, 13,
+ 8, 3, -2, 1, 5, -6, 7,-18,-10, 1, -1, 5, 4, 1, 0, 25 },
+ { -5, -1, 18, 12, 8, 8,-16, -1, 1, 1, 1, -4, -5, 3, 3, 4,
+ 4,-11,-12,-16, -6, 2, 12,-13, 0, 9, 7, 9, -9, 0,-10, 24 },
+ { -4, 1, -3, 0, 2, -4, 4, 1, 5, 0, -3, 2, -3, -2, 2, -1,
+ 1, 4, -1, -2, -2, 1, -1, -1, -4, -1, -4, -2, -6, 6, 12, 69 },
+ { 8, 5, 11, 0,-15, -4, 13, 6, 0, -4, 9, 1, -5, -3, 15, 0,
+ 1, 6, -5, 0, 1, 6, 5, 8, 0, 7, 1, -1, -4,-11, -9, 41 },
+ { -4, -9, 32, -6, 0, 7, -4, 6, -6, 1, -6, -2, 4, -8, -5, -3,
+ -16, -1, -2, -6, 1, 15, 0, 21, 3, -3, -4, 3,-12, 16, 2, 27 },
+ { -6, -5, 1, -9, -5, 3, 7, -3, 5, 5, 14, 13, 20, -7, -1, 12,
+ -1, 10,-11,-11, -7, -4,-14, 7,-14, 13, 22, 18, -1, 0, 14, 28 },
+ { -8, 3, -2, 0, 5, 6, -1, -4, 1, 3, -7, 3, 1,-15, 4, -9,
+ 22,-10, -9, -4, 1, 8, -4, 9,-15, 2, -6, -4,-16, 12,-10, 23 },
+ { 0, 0, 2, 0, -1, 3, -3, -1, 3, -5, 7, 1, 5, -5, -8, 1,
+ 13,-15, -5, -7, 12, -6, -2, 3, 10, -5, -8, 17, -5,-11,-14, 23 },
+ { -7, -4, 6, -4, 5, -6, -5, 2, -4, 11, 9, -4, 2, -2, -4, 6,
+ 15, 3, -3, 18,-15, -2, -6, 3, 3,-20, 17, 11, -4, 2, 3, 29 },
+ { 6, 1, -6, 2, 3, 0, 0, -3, 3, 3, -1, 3, -4, -6, -6, -7,
+ -3, -2, -7, -2, -4, 5, 3, -5,-20,-13, -4, 10,-14,-29, 14, 37 },
+ { 3, 4, 3, -6, -4, 5, 0, 3, 2, 3, 0, -2, 4, 0, -3, -5,
+ -4, 4, -4, 4, 4, 3, 1, -4, -4, -9,-14, 20,-30, 3,-18, 33 },
+ { 0, 2, 5, -2, -4, -2, -1, 2, -6, -3, -2, -2, 2, -5, -1, 4,
+ 3, 2, -3, 0, -1, -1,-10, -7, 2, -4,-18, 2,-37, -1, 12, 40 },
+ { -7, 2, -1, 0, -2, 4, -8, 1, -4, 12, 7, 4, 15, -7, 1, -9,
+ 18, 0, 12,-17, -3, -1, 0, 0, 0, 2, -6, 0, -4, -3, -1, 26 },
+ { -6, 4, 8, -5, -6, -2, 2, -1, 1, -1,-15, 8, 7, -1,-17, -4,
+ 1, 5, 6,-11, -6, 14, 17, -5,-15, 11, 8, 0, -3,-15, -6, 28 },
+ { -1, 0, 0, 0, 1, 0, -1, 0, 1, 3, 2, -2, 3, -1, -1, 2,
+ 2, -1, -1, -7, 1, 2, -9, 0, -1, -4,-18, 7,-10, 49,-13, 32 },
+ { -1, -3, 4, 1, 2, -5, 1, -7, -1, 5, -9, 4, 4, 25, 1, -1,
+ 2, -5, 2, -7, 17, -2, 10, -5, 0, 2,-15, 3, -9, 7, -9, 30 },
+ { -5, -1, 0, 2, 1, -1, 2, 5,-33, 3, -5, 14, 11, 7, 5, -3,
+ 2, -8, -4, -2, -7, -6, 4, -8, -1, -8, 2, -2, -8, -1, -4, 27 },
+ { -1, 0, -1, -2, 1, -1, -2, -1, 2, 0, 1, 2, 2, 4, 1, 3,
+ 4, 2, 1, -7, -4, 1, -3, -4,-35,-25, 17, 10, -3,-26, -7, 32 },
+ { -5, 1, 6, -2, 6, 6, -9, 3, -1, -4, 5, -4, -2, -2, -9, 2,
+ -5, 2, 2, 4, 3, 5, -5,-16,-31,-12,-11, 2,-19, 20, -2, 21 },
+ { -5, 2, 7, -7, -7, 5, -7, 2, 0, 0, -4, 3, -1, 0, -1, -2,
+ 0, -3, 5,-11, -8, -3, -7, -7, 28,-11, -7, 0,-16,-11, -4, 29 },
+ { 2, 1, -3, -2, -1, 3, 4, 0, 1, 0, -1, -5, 4, -5,-12, 2,
+ -2, -5,-22, -2, -1, 11, 8, -7,-12, 0,-34, 6, -5, 11, -8, 19 },
+ { -1, -3, 5, 11, 18, -2, -2, -5, -2, 4, -1, 8, 5, -6, 1, -1,
+ 2, 8, 4, -5, -8, -2, 5,-18, 7, 12, 7, 19,-18, 2, -6,-13 },
+ { 9, 0, 0, 5, 4, 3, -6, 4, 1, -4, 5, -1, -4, 8, 8, 6,
+ -8, -6, 0, 6, -3, 3, 5, -3, 17, 31, 16, 10,-13, 0, -9,-19 },
+ { 12,-10, 2, -2, -2, -1, -3, 6,-12, -5, -2, 14,-16, 4, 12, 12,
+ 17, 4, 7,-16, 7, -6, 11, 7, 7, 2,-25, 23,-24, 5, -7, -9 },
+ { 10, 4, 13, 10, 10, 3, -6, 3, 3, 2, -1, -6, 8, 4, 10, 0,
+ 1, 2, -4, 2, -3, -8, 0, -1, 9, 9,-10, -3,-29, 1, -1,-27 },
+ { 2, 2, 0, 7, 9, -2,-10, -1, -1, 1, -9, -5, 8, 4, 1, 2,
+ -10, 1, 13, 12, -3, 15, -9, 2, -7, 1,-10, 23,-20,-18, -9,-15 },
+ { -3, -5, -1, 8, 0, -5, -1, 4, 7, -1, -7, 2, -8, -5, 11, 7,
+ -6, 3, -3, -9, 7, 9,-22, 1, 6, -4, 14, 27,-25,-14, 3, -5 },
+ { 1, 3, 8, 4, 7, 6, 12,-17,-15, 1, -8,-10, 7,-14, -8, 6,
+ -2, -2,-11,-11, -7, 13, -2, -2, 4, 5, -5, 13,-23, -6,-17, -8 },
+ { -5, 4,-14, -5, -4, -5, 6, 5, -8, -5, -2,-11, -7,-12, 3,-11,
+ 2, -6, 4,-10, -5, -7, 14, 5, 23, 11, 7, 12,-16, -6, -4,-16 },
+ { 5, 6, 2, 5, -2, -5, -5, -6, -5,-19,-13, -1, -3,-13, 5, 0,
+ 6, -2, -2, -6, -7, -7, -1, -9, 4, 14, 17,-12,-27, 3, 0, -1 },
+ { 7, -1, 9,-10, 8, 2, -7, -2, 5, 2, -3, -7, 3, 0, 6, 4,
+ 12, 5, 11, 14,-13, -1, 8, 1, 13, 9, 12, 12,-18,-14,-11,-16 },
+ { -7, -5, -6, -5, 0, -1, -3, 2, 2, 1, 4, 9, 2, 3, 5, -2,
+ 2, 1, 8, 0, 3, 0, -2, 2, 1, 7, 29, 0,-36, -5, -9,-21 },
+ { 14, -6, -9, 0, -1, -8, -8,-11, 2, 2, -9,-12, 12, -4, 5, 3,
+ -5, -9, 11, -1, -3, 12,-21, -3, 12, 5, 3, 11,-18,-15, 1, -2 },
+ { -1, 3, -9, -3, 7, -7,-18, 2, 4, 12,-10, 2, 8, -3,-14, 13,
+ 17, -5, 5, -9, 13, -3, -7,-18, 17, -2, 5, 7,-20, -3, -6,-11 },
+ { -3, 3, 3, -1, 1, -6, -5, 1, 5, -3,-14, -6, -5, -8, 14, -6,
+ 7, -1, 5, 1, 15, -1, -7, -4, 6,-11, 9, -2,-37, 16, -7, -3 },
+ { -1, 0, 6, 1, -3, -9, 0, 11, -8, 2, -2, 0, 5, 2, 12,-10,
+ 10, 13, 2, 7, -6, 2,-10,-10, 21, -5, 5, 5,-12,-23, 3,-14 },
+ { 6, 0, -2, 1, 0, 1, 0, -4, 1, 1, 8, -2, 2, -5, -2, 1,
+ 8, -4, -1, -1, 4, -1, 2, 6, 32, 1, -5,-20,-40, -4,-18,-14 },
+ { 2, 2, -7, -2, 4, 4, -1, 2, 0, -2, -4, -7, 3, 5, 0, -5,
+ 1, 2, -6, 4, -1, -2, -1,-15, 8, 3, 9, 46, -7,-18, 6,-11 },
+ { 5, 5, 16, 21, 3,-11, -4, 11,-12, 2, 4,-12, -1, 11, 8, 1,
+ -4, 11,-11,-21, 1, 1,-11, 3, 13, 1, 5, 12,-25, 1, -3, -2 },
+ { 1, 6, -7, 4, 2, 3, 1, -5, 8, 9,-15, 3, -3,-14, 17, 4,
+ -8, 14, -2, -8, -4, 5, 8, -7, 8, 9, 7, 6,-29,-17, 8, 4 },
+ { -7, -7, 4, 0, 13, 1, 0, 4, 4,-16,-10, -7, 5, 9,-15,-10,
+ -10, 8, -4, -1,-11, -1,-10,-15, 3, 3, 14, 10,-19, 2,-18,-12 },
+ { -4, 0, 2, 0, 5, -2, -9, 0, 4, -4, 2, -1, -2, 2, -4, 9,
+ 2, -6, -4, -2, -1, -3, -3, -1, 2, 5, -1, 11,-24,-44, -9,-15 },
+ { -1,-10, 6, 21, 11, 15, -7, 10,-14, -9, -8, -8, 4, 6, 19, 1,
+ -6, 1, -5,-17, -8,-10, 9, 5, 11, 18, -1, 10,-16, -7, -9, -8 },
+ { 3, -5, 0, 0, -2, -2, -6, 4, -4, 1, -1, 0, 7, -3, 4, -4,
+ -7, 7, 17,-20, 6, 4, 1, -6,-12, 31, 13, 19,-14,-10, -7, -2 },
+ { -2, 6,-10, 3, 9, 6,-14, 15, 2, -5, 2,-11, 9, -8, 4, 6,
+ 20,-15, -3, -3, -1, 32,-21, 6, 1, 9, 11, 17,-19, 6, -1, -3 },
+ { 8, 10, -2, 0, -8,-16, 7, 7, 6, 10, 4,-14, 7, -6, 21, -7,
+ 10, 5, 5, 0, -7, 2, -6, 0, -7, 11, -9, 15,-20, -7,-11, 2 },
+ { 0, -7, 5, 2, 0, -3, -6, -4, -2, -1, -4, -5,-13, -1, 27, -9,
+ -6,-11, -7, 1, 11, -4, -4,-14, -2, 11, 6, 10,-19, -6,-15, 2 },
+ { 0, 7, -1, 2, -7,-15, -2, -3, 13, -5, -5, 12, 3, 0, 5, -5,
+ -22, 2, 7, 22, 13, 0, -1, 2, 3, 2, -7, 7,-27, -4, -4,-12 },
+ { 11, 1,-16, 6,-15, 1, 3, 2, 0, 2, -3, 2, 5, -2, -5, 9,
+ 5, -3, 3, -2,-11, 3, 9, 6, 9, 3, -1, 12,-41, 8, -6, 9 },
+ { 3, -7, 3, 2, 5, 5, 0, -1, 1, 3, -5, -2,-13, 7, -1, -2,
+ -2, -6, 4, -6, 0, 2, -2, 2, 4, 1, -4, 1,-47,-21, 7, -6 },
+ { 3, 16, -7, 13, -4, -2, 10, -3, -1, 18,-13, 7,-13, -4, 8, 4,
+ 8, 9, -5, 13, 8, -5, 3, -6, 7, 18, -8, 10,-25, -3,-12,-12 },
+ { 1, -1, -1, 0, 2, 5, -5, -3, 0, -5, -1, 0, -4, -8, -2, 3,
+ 2, -2,-17, -6, -4, 1, 33, -6,-20, -6, 8, 31,-26, -8, -1, -4 },
+ { 3, -3, -3, 5, -3, -2, 1, 7, 0, 3, 6, 3, 6, -2, 9, 15,
+ -10, -3,-15, -5, -3, -4, -6,-30, 17, -8, -2, 2,-20, 0, -8, -2 },
+ { -2, -1, -1, -1, 3, -5, -2, -3, 4, -2, 0, 5, 8, -3, 1, -4,
+ 1, 1, -3, 4, 4,-14, 3, 11, -5, 3, -3, 7, -3, 13, 23,-16 },
+ { 2, -6, 1, -3, 5, 0, -6,-11, -7, -4, -1, 2, -7, -1, -1, 7,
+ 1, -2, 6, 12, -6, 8,-13, 17, 25,-23,-19, -7,-12, 9, 16,-17 },
+ { 9, 4, 4, 4, -3, -1, 6, -2, -3, 0, 13, -4, -7, 14, 1, -7,
+ 0, -5, 3,-19, -3, 5, 3, 9, -1, 9,-13, 13,-17, 4, 21,-26 },
+ { 0, -5, 0, 0, -4, -5, 2, -6, -4, 5, -7, 10, 0, 2, 0, -2,
+ -2, 0, 4, -6, 7, -2, 6, 5, -5, 2,-12, 1,-29, 29, 27, 12 },
+ { 9,-10,-22, 6, -1, -1, 9,-14,-12, -2, 1, -1, 10,-11,-16, 0,
+ 3, 11, 13,-14, -9, -2, -1, 6, 4,-14, 0,-10, -2, 16, 17,-11 },
+ { 2, 0, -1, -2, 4, 3, -6, -2, 1, -1, 1, 3, -4, 1, 3, -4,
+ -1, -1, 4, -1, 1, 0, 1, 6, -5, -7, 2, 1,-47, -3, 50,-17 },
+ { 8, -4,-11, -7, 11, 11, 14, -7, 12, -7, 6, 2, 13, -6, -3, -2,
+ -14, 6, 6, 6, 0, 2, -1, 5,-20, 2, -1, 4, -5, 6, 21,-11 },
+ { -2, -9, 3, 0, -6, 7, 8, -8, 1, -3, 4, 1, 5, -2, -3, -7,
+ 4, 7,-12, -9, -2, 10, -6, 13, 6, 5, 20, 2,-15, 9, 28, -7 },
+ { 0, -5, -6, -6, -6, 1, -6, 6, -2, 4, 8, -3, 12, -1, -4, -2,
+ 6, 16,-14, 9,-14, -2, -8,-27, -3, 18, -1, -7, -3, 8, 23,-23 },
+ { 1, 4, -9, -1, -5, 10, -2, 1,-11, 1, -9, 4, 7, 14, -9, -2,
+ -3, 2, -5, -1, -6,-10, -7, 11, 20, 2, 3,-19, 3, 15, 30, -9 },
+ { 7, 2,-14, -4, 0, -2, 5, 2, 5, -2, 8, -3, -7, 6, 6,-11,
+ -14, 1, 10, -1, -7, -8, 1, 10, 3, -6,-15,-12,-17, 4, 30, -6 },
+ { 4, 2, 1, -2, 3, 0, 1, 0, 2, 0, 1, 6, -7, 0, 3, 4,
+ 4, -4, -2, -5, -2, 2, -1, -2, 0, -2,-11, -7, -3, 42, 24,-14 },
+ { 4, 1, 3, 2, 0, -2, -3, -2, 2, -1, 4, 11, -2, 2, 3, -4,
+ -5, 9, 2, -4, -9, 5, 8, -1, -7, 1, 24,-13,-28, 20, 15,-22 },
+ { -3, 7, 6, 3, -2, -5,-10, -2, -2, -1, -6, -6, -2,-14,-16, -6,
+ -5, 0, 18, 0, 9, 1, 7,-13, -5, -6, -9, 11,-15, 9, 22,-11 },
+ { 9, -2, 6, 5, 2, 9,-10, 1, 1, 5, -4, 12, 2, 2,-10, -7,
+ -4, -6, 7, 9, 6, 15, 6, 6,-10, 10, 5,-13, -5, 6, 24,-12 },
+ { 1, 3, -3, -3, 8, 1, -6, 2, -5, -3, 7, 2, 14, 6, 9, -6,
+ -5, -4, 27, 7, -3, 8, -6, 3, -8, 8, 22, -5, -6, -2, 22,-17 },
+ { -2, -2, 3, 10, 9, 9, 12,-15, -1,-11,-13, 3, -2, 1, -3,-11,
+ 7, 9, 16, -3,-10, -5, -5, 1, 8, -3, 9, 9, -5, 3, 31,-12 },
+ { 7, -5, 10, -4, -8, 2, 16, -2, 10, 10, -3, -2, 3, -8, -3, 3,
+ -13, -6, 15, 20, -9, -3,-12, 1, -2,-16, 8, 8, -1, 16, 22, -5 },
+ { 5, -3,-15, -2, 12, -8, 8, -5, 2, -8, 20,-18, 14, -4, 3, 3,
+ 7,-13,-16, 1,-10, 7, 16, 7, 4,-14, -4, -5, -9, 8, 23, -6 },
+ { 5, -4, -5, -4, 1, 8, 4, -7, -5, 8, 10, 6, -6,-10, -2, 6,
+ 9,-17,-14, 11, 12, -3,-13, -7, 2, 18, 3,-25,-16, 18, 22, -5 },
+ { 5, 6, -7,-20, -4, 2, 8, 4,-24, -4, 1, 4, -5, -2, 1,-10,
+ -2, 9, 3, -4, -3, -4, -4, -4, 10, 10, 3, 0, -6, 25, 21,-11 },
+ { 0, 7, -1, 14, -6, -4,-10, 5, 4, 4, 4, -5, 3, 4, -1, -7,
+ 8,-19, 0, 6, 2, 3,-18, -3, -6, 2, 8, 14,-26, 22, 27,-13 },
+ { -2, -6, 7, -5, 12, -7, 8, -1, 3, -2, 4, 1, 8, -2, 0, 14,
+ 6, -5, 6, -4, -7, 7,-21, 8, 1, 8, -9, -4, -3, 11, 25,-13 },
+ { 4, 4, -1, -6, 4, 9, -8, 1, -3,-10, -2, 0, 15, -9,-16, 11,
+ 1, 1, 6, 3, -9, -5, 16, 26, 1,-14, 1, -3,-14, 7, 15, -9 },
+ {-12, -2, -9,-13, 2, 6, 14, 0, 1, 0, -1,-13, 0, 10, -1, 6,
+ 9, -7, 8, 8, 19, 6, -1, 9, 10, -4, 1, -7,-22, -2, 29, -7 },
+ { 2, 4, 13,-12, -8, -4, -5, 13, 12, -5, -3, -3, -4, 1, -1, 10,
+ 15, -6, -1,-11,-30, 4, 15, -1, 9, -7, 0, -2, -7, 10, 25,-16 },
+ { 7,-15, -7, -7, -1, -5, -5,-11,-20, 10, 3,-10, -3, 5, 20, -4,
+ 0, -2, -2, 17, 2, 0, -3, 3, 6, 5, -1,-12, -3, 15, 22,-16 },
+ { 4, -1, 3, 4, -5, 0, -1, -5,-24,-29, 4, -9, 1, -3, 0, 0,
+ 0, -4, 7, -4, -4, -4, 3, 1, -6, 5, -3, -5,-10, 3, 25,-10 },
+ { -2, -1, -1, 4, 4, -1, 2, 0, -4, -4, 2, -1, -3, -1, -2, -2,
+ 1, -3, -5, -1, 2, -3, -4, -4, -3, 5, -9, 1,-11, 7, 46,-46 },
+ { 0, -9, 3, 4, 4, 3, -5, -6, 5, -4, 4, -2, 1, 7, -4,-10,
+ 13, 1, 3, -6, 4, -4, 7, 2,-19,-25, -3,-16,-12, 16, 20, -1 },
+ { 18, 6, 4,-12, 0,-14, 9, -6, -1, -4, -5, 2, 1, 12, 4, 2,
+ 7, 0, 2, 5,-11, -5, -2, 2, -4, 10, 0, -9, -7, 9, 25, -8 },
+ { 5, 0, -6, 5, 6, 3, 3,-10, -5, 1, -1, 4, 3,-11, -8, 5,
+ 4, -5, 5, -5, -7, -5, 11, 5, 20, -8,-16, 21, -4, 27, 23, -5 }
};
diff --git a/lib/ffmpeg/libavcodec/dcadsp.c b/lib/ffmpeg/libavcodec/dcadsp.c
index af48e3ce42..dd4994d276 100644
--- a/lib/ffmpeg/libavcodec/dcadsp.c
+++ b/lib/ffmpeg/libavcodec/dcadsp.c
@@ -23,7 +23,7 @@
#include "dcadsp.h"
static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
- int decifactor, float scale, float bias)
+ int decifactor, float scale)
{
float *out2 = out + decifactor;
const float *cf0 = coefs;
@@ -39,8 +39,8 @@ static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
v0 += s * *cf0++;
v1 += s * *--cf1;
}
- *out++ = (v0 * scale) + bias;
- *out2++ = (v1 * scale) + bias;
+ *out++ = v0 * scale;
+ *out2++ = v1 * scale;
}
}
diff --git a/lib/ffmpeg/libavcodec/dcadsp.h b/lib/ffmpeg/libavcodec/dcadsp.h
index 20020ae06c..bb157f7650 100644
--- a/lib/ffmpeg/libavcodec/dcadsp.h
+++ b/lib/ffmpeg/libavcodec/dcadsp.h
@@ -21,7 +21,7 @@
typedef struct DCADSPContext {
void (*lfe_fir)(float *out, const float *in, const float *coefs,
- int decifactor, float scale, float bias);
+ int decifactor, float scale);
} DCADSPContext;
void ff_dcadsp_init(DCADSPContext *s);
diff --git a/lib/ffmpeg/libavcodec/dct-test.c b/lib/ffmpeg/libavcodec/dct-test.c
index 4f0a0c6996..b45f23ed27 100644
--- a/lib/ffmpeg/libavcodec/dct-test.c
+++ b/lib/ffmpeg/libavcodec/dct-test.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <math.h>
+#include "libavutil/cpu.h"
#include "libavutil/common.h"
#include "libavutil/lfg.h"
@@ -94,24 +95,24 @@ struct algo algos[] = {
{"SIMPLE-C", 1, ff_simple_idct, ff_ref_idct, NO_PERM},
#if HAVE_MMX
- {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, FF_MM_MMX},
+ {"MMX", 0, ff_fdct_mmx, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX},
#if HAVE_MMX2
- {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, FF_MM_MMX2},
- {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, FF_MM_SSE2},
+ {"MMX2", 0, ff_fdct_mmx2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_MMX2},
+ {"SSE2", 0, ff_fdct_sse2, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_SSE2},
#endif
#if CONFIG_GPL
- {"LIBMPEG2-MMX", 1, ff_mmx_idct, ff_ref_idct, MMX_PERM, FF_MM_MMX},
- {"LIBMPEG2-MMX2", 1, ff_mmxext_idct, ff_ref_idct, MMX_PERM, FF_MM_MMX2},
+ {"LIBMPEG2-MMX", 1, ff_mmx_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX},
+ {"LIBMPEG2-MMX2", 1, ff_mmxext_idct, ff_ref_idct, MMX_PERM, AV_CPU_FLAG_MMX2},
#endif
- {"SIMPLE-MMX", 1, ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, FF_MM_MMX},
- {"XVID-MMX", 1, ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, FF_MM_MMX},
- {"XVID-MMX2", 1, ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, FF_MM_MMX2},
- {"XVID-SSE2", 1, ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, FF_MM_SSE2},
+ {"SIMPLE-MMX", 1, ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX},
+ {"XVID-MMX", 1, ff_idct_xvid_mmx, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX},
+ {"XVID-MMX2", 1, ff_idct_xvid_mmx2, ff_ref_idct, NO_PERM, AV_CPU_FLAG_MMX2},
+ {"XVID-SSE2", 1, ff_idct_xvid_sse2, ff_ref_idct, SSE2_PERM, AV_CPU_FLAG_SSE2},
#endif
#if HAVE_ALTIVEC
- {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, FF_MM_ALTIVEC},
+ {"altivecfdct", 0, fdct_altivec, ff_ref_fdct, NO_PERM, AV_CPU_FLAG_ALTIVEC},
#endif
#if ARCH_BFIN
@@ -187,7 +188,7 @@ DECLARE_ALIGNED(8, static DCTELEM, block_org)[64];
static inline void mmx_emms(void)
{
#if HAVE_MMX
- if (cpu_flags & FF_MM_MMX)
+ if (cpu_flags & AV_CPU_FLAG_MMX)
__asm__ volatile ("emms\n\t");
#endif
}
@@ -554,7 +555,7 @@ int main(int argc, char **argv)
int test_idct = 0, test_248_dct = 0;
int c,i;
int test=1;
- cpu_flags = mm_support();
+ cpu_flags = av_get_cpu_flags();
ff_ref_dct_init();
idct_mmx_init();
diff --git a/lib/ffmpeg/libavcodec/dirac.c b/lib/ffmpeg/libavcodec/dirac.c
index c65a51f964..bacd1f8e9f 100644
--- a/lib/ffmpeg/libavcodec/dirac.c
+++ b/lib/ffmpeg/libavcodec/dirac.c
@@ -25,6 +25,7 @@
* @author Marco Gerards <marco@gnu.org>
*/
+#include "libavcore/imgutils.h"
#include "dirac.h"
#include "avcodec.h"
#include "golomb.h"
@@ -268,7 +269,7 @@ int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
if (parse_source_parameters(avctx, gb, source))
return -1;
- if (avcodec_check_dimensions(avctx, source->width, source->height))
+ if (av_image_check_size(source->width, source->height, 0, avctx))
return -1;
avcodec_set_dimensions(avctx, source->width, source->height);
diff --git a/lib/ffmpeg/libavcodec/dirac_parser.c b/lib/ffmpeg/libavcodec/dirac_parser.c
index e5b9599c7f..0a1135542f 100644
--- a/lib/ffmpeg/libavcodec/dirac_parser.c
+++ b/lib/ffmpeg/libavcodec/dirac_parser.c
@@ -247,7 +247,7 @@ static void dirac_parse_close(AVCodecParserContext *s)
av_free(pc->buffer);
}
-AVCodecParser dirac_parser = {
+AVCodecParser ff_dirac_parser = {
{ CODEC_ID_DIRAC },
sizeof(DiracParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/dnxhd_parser.c b/lib/ffmpeg/libavcodec/dnxhd_parser.c
index 6149a2daab..e5a5aa09f5 100644
--- a/lib/ffmpeg/libavcodec/dnxhd_parser.c
+++ b/lib/ffmpeg/libavcodec/dnxhd_parser.c
@@ -86,7 +86,7 @@ static int dnxhd_parse(AVCodecParserContext *s,
return next;
}
-AVCodecParser dnxhd_parser = {
+AVCodecParser ff_dnxhd_parser = {
{ CODEC_ID_DNXHD },
sizeof(ParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/dnxhddec.c b/lib/ffmpeg/libavcodec/dnxhddec.c
index 8b7c343d09..58893acaf9 100644
--- a/lib/ffmpeg/libavcodec/dnxhddec.c
+++ b/lib/ffmpeg/libavcodec/dnxhddec.c
@@ -22,6 +22,7 @@
//#define TRACE
//#define DEBUG
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
#include "dnxhddata.h"
@@ -55,6 +56,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
dsputil_init(&ctx->dsp, avctx);
avctx->coded_frame = &ctx->picture;
ctx->picture.type = FF_I_TYPE;
+ ctx->picture.key_frame = 1;
return 0;
}
@@ -105,7 +107,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si
ctx->height = AV_RB16(buf + 0x18);
ctx->width = AV_RB16(buf + 0x1a);
- dprintf(ctx->avctx, "width %d, heigth %d\n", ctx->width, ctx->height);
+ av_dlog(ctx->avctx, "width %d, heigth %d\n", ctx->width, ctx->height);
if (buf[0x21] & 0x40) {
av_log(ctx->avctx, AV_LOG_ERROR, "10 bit per component\n");
@@ -113,7 +115,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si
}
ctx->cid = AV_RB32(buf + 0x28);
- dprintf(ctx->avctx, "compression id %d\n", ctx->cid);
+ av_dlog(ctx->avctx, "compression id %d\n", ctx->cid);
if (dnxhd_init_vlc(ctx, ctx->cid) < 0)
return -1;
@@ -126,7 +128,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si
ctx->mb_width = ctx->width>>4;
ctx->mb_height = buf[0x16d];
- dprintf(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
+ av_dlog(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
if ((ctx->height+15)>>4 == ctx->mb_height && ctx->picture.interlaced_frame)
ctx->height <<= 1;
@@ -139,7 +141,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si
for (i = 0; i < ctx->mb_height; i++) {
ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i<<2));
- dprintf(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
+ av_dlog(ctx->avctx, "mb scan index %d\n", ctx->mb_scan_index[i]);
if (buf_size < ctx->mb_scan_index[i] + 0x280) {
av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
return -1;
@@ -291,7 +293,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVFrame *picture = data;
int first_field = 1;
- dprintf(avctx, "frame size %d\n", buf_size);
+ av_dlog(avctx, "frame size %d\n", buf_size);
decode_coding_unit:
if (dnxhd_decode_header(ctx, buf, buf_size, first_field) < 0)
@@ -305,7 +307,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
avctx->pix_fmt = PIX_FMT_YUV422P;
- if (avcodec_check_dimensions(avctx, ctx->width, ctx->height))
+ if (av_image_check_size(ctx->width, ctx->height, 0, avctx))
return -1;
avcodec_set_dimensions(avctx, ctx->width, ctx->height);
@@ -344,7 +346,7 @@ static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec dnxhd_decoder = {
+AVCodec ff_dnxhd_decoder = {
"dnxhd",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DNXHD,
diff --git a/lib/ffmpeg/libavcodec/dnxhdenc.c b/lib/ffmpeg/libavcodec/dnxhdenc.c
index 6b089299e9..d6f8bd3cad 100644
--- a/lib/ffmpeg/libavcodec/dnxhdenc.c
+++ b/lib/ffmpeg/libavcodec/dnxhdenc.c
@@ -239,12 +239,12 @@ static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf)
buf[5] = ctx->interlaced ? ctx->cur_field+2 : 0x01;
buf[6] = 0x80; // crc flag off
buf[7] = 0xa0; // reserved
- AV_WB16(buf + 0x18, avctx->height); // ALPF
+ AV_WB16(buf + 0x18, avctx->height>>ctx->interlaced); // ALPF
AV_WB16(buf + 0x1a, avctx->width); // SPL
- AV_WB16(buf + 0x1d, avctx->height); // NAL
+ AV_WB16(buf + 0x1d, avctx->height>>ctx->interlaced); // NAL
buf[0x21] = 0x38; // FIXME 8 bit per comp
- buf[0x22] = 0x88 + (ctx->frame.interlaced_frame<<2);
+ buf[0x22] = 0x88 + (ctx->interlaced<<2);
AV_WB32(buf + 0x28, ctx->cid); // CID
buf[0x2c] = ctx->interlaced ? 0 : 0x80;
@@ -552,7 +552,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
if (bits > ctx->frame_bits)
break;
}
- //dprintf(ctx->m.avctx, "lambda %d, up %u, down %u, bits %d, frame %d\n",
+ //av_dlog(ctx->m.avctx, "lambda %d, up %u, down %u, bits %d, frame %d\n",
// lambda, last_higher, last_lower, bits, ctx->frame_bits);
if (end) {
if (bits > ctx->frame_bits)
@@ -582,7 +582,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
down_step = 1<<LAMBDA_FRAC_BITS;
}
}
- //dprintf(ctx->m.avctx, "out lambda %d\n", lambda);
+ //av_dlog(ctx->m.avctx, "out lambda %d\n", lambda);
ctx->lambda = lambda;
return 0;
}
@@ -610,7 +610,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
if (bits > ctx->frame_bits)
break;
}
- //dprintf(ctx->m.avctx, "%d, qscale %d, bits %d, frame %d, higher %d, lower %d\n",
+ //av_dlog(ctx->m.avctx, "%d, qscale %d, bits %d, frame %d, higher %d, lower %d\n",
// ctx->m.avctx->frame_number, qscale, bits, ctx->frame_bits, last_higher, last_lower);
if (bits < ctx->frame_bits) {
if (qscale == 1)
@@ -640,7 +640,7 @@ static int dnxhd_find_qscale(DNXHDEncContext *ctx)
return -1;
}
}
- //dprintf(ctx->m.avctx, "out qscale %d\n", qscale);
+ //av_dlog(ctx->m.avctx, "out qscale %d\n", qscale);
ctx->qscale = qscale;
return 0;
}
@@ -848,7 +848,7 @@ static int dnxhd_encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec dnxhd_encoder = {
+AVCodec ff_dnxhd_encoder = {
"dnxhd",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DNXHD,
diff --git a/lib/ffmpeg/libavcodec/dpcm.c b/lib/ffmpeg/libavcodec/dpcm.c
index 3f3842c8e9..6053a14550 100644
--- a/lib/ffmpeg/libavcodec/dpcm.c
+++ b/lib/ffmpeg/libavcodec/dpcm.c
@@ -155,7 +155,7 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
break;
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -299,7 +299,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
}
#define DPCM_DECODER(id, name, long_name_) \
-AVCodec name ## _decoder = { \
+AVCodec ff_ ## name ## _decoder = { \
#name, \
AVMEDIA_TYPE_AUDIO, \
id, \
diff --git a/lib/ffmpeg/libavcodec/dpx.c b/lib/ffmpeg/libavcodec/dpx.c
index 94a91816c5..55ae4e7248 100644
--- a/lib/ffmpeg/libavcodec/dpx.c
+++ b/lib/ffmpeg/libavcodec/dpx.c
@@ -20,6 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
@@ -54,6 +55,7 @@ static int decode_frame(AVCodecContext *avctx,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
+ const uint8_t *buf_end = avpkt->data + avpkt->size;
int buf_size = avpkt->size;
DPXContext *const s = avctx->priv_data;
AVFrame *picture = data;
@@ -139,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx,
if (s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
- if (avcodec_check_dimensions(avctx, w, h))
+ if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -171,6 +173,10 @@ static int decode_frame(AVCodecContext *avctx,
case 8:
case 12: // Treat 12-bit as 16-bit
case 16:
+ if (source_packet_size*avctx->width*avctx->height > buf_end - buf) {
+ av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n");
+ return -1;
+ }
if (source_packet_size == target_packet_size) {
for (x = 0; x < avctx->height; x++) {
memcpy(ptr, buf, target_packet_size*avctx->width);
@@ -214,7 +220,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec dpx_decoder = {
+AVCodec ff_dpx_decoder = {
"dpx",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DPX,
diff --git a/lib/ffmpeg/libavcodec/dsicinav.c b/lib/ffmpeg/libavcodec/dsicinav.c
index 895b6237d7..b4e0579a7b 100644
--- a/lib/ffmpeg/libavcodec/dsicinav.c
+++ b/lib/ffmpeg/libavcodec/dsicinav.c
@@ -307,7 +307,7 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx)
cin->avctx = avctx;
cin->initial_decode_frame = 1;
cin->delta = 0;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -343,7 +343,7 @@ static int cinaudio_decode_frame(AVCodecContext *avctx,
}
-AVCodec dsicinvideo_decoder = {
+AVCodec ff_dsicinvideo_decoder = {
"dsicinvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DSICINVIDEO,
@@ -356,7 +356,7 @@ AVCodec dsicinvideo_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN video"),
};
-AVCodec dsicinaudio_decoder = {
+AVCodec ff_dsicinaudio_decoder = {
"dsicinaudio",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_DSICINAUDIO,
diff --git a/lib/ffmpeg/libavcodec/dsputil.c b/lib/ffmpeg/libavcodec/dsputil.c
index 44fcf596c4..84714def41 100644
--- a/lib/ffmpeg/libavcodec/dsputil.c
+++ b/lib/ffmpeg/libavcodec/dsputil.c
@@ -27,6 +27,7 @@
* DSP utils
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "simple_idct.h"
@@ -35,11 +36,9 @@
#include "mathops.h"
#include "mpegvideo.h"
#include "config.h"
-#include "lpc.h"
#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, };
@@ -97,44 +96,6 @@ const uint8_t ff_alternate_vertical_scan[64] = {
38, 46, 54, 62, 39, 47, 55, 63,
};
-/* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256
- * for a>16909558, is an overestimate by less than 1 part in 1<<24 */
-const uint32_t ff_inverse[257]={
- 0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757,
- 536870912, 477218589, 429496730, 390451573, 357913942, 330382100, 306783379, 286331154,
- 268435456, 252645136, 238609295, 226050911, 214748365, 204522253, 195225787, 186737709,
- 178956971, 171798692, 165191050, 159072863, 153391690, 148102321, 143165577, 138547333,
- 134217728, 130150525, 126322568, 122713352, 119304648, 116080198, 113025456, 110127367,
- 107374183, 104755300, 102261127, 99882961, 97612894, 95443718, 93368855, 91382283,
- 89478486, 87652394, 85899346, 84215046, 82595525, 81037119, 79536432, 78090315,
- 76695845, 75350304, 74051161, 72796056, 71582789, 70409300, 69273667, 68174085,
- 67108864, 66076420, 65075263, 64103990, 63161284, 62245903, 61356676, 60492498,
- 59652324, 58835169, 58040099, 57266231, 56512728, 55778797, 55063684, 54366675,
- 53687092, 53024288, 52377650, 51746594, 51130564, 50529028, 49941481, 49367441,
- 48806447, 48258060, 47721859, 47197443, 46684428, 46182445, 45691142, 45210183,
- 44739243, 44278014, 43826197, 43383509, 42949673, 42524429, 42107523, 41698712,
- 41297763, 40904451, 40518560, 40139882, 39768216, 39403370, 39045158, 38693400,
- 38347923, 38008561, 37675152, 37347542, 37025581, 36709123, 36398028, 36092163,
- 35791395, 35495598, 35204650, 34918434, 34636834, 34359739, 34087043, 33818641,
- 33554432, 33294321, 33038210, 32786010, 32537632, 32292988, 32051995, 31814573,
- 31580642, 31350127, 31122952, 30899046, 30678338, 30460761, 30246249, 30034737,
- 29826162, 29620465, 29417585, 29217465, 29020050, 28825284, 28633116, 28443493,
- 28256364, 28071682, 27889399, 27709467, 27531842, 27356480, 27183338, 27012373,
- 26843546, 26676816, 26512144, 26349493, 26188825, 26030105, 25873297, 25718368,
- 25565282, 25414008, 25264514, 25116768, 24970741, 24826401, 24683721, 24542671,
- 24403224, 24265352, 24129030, 23994231, 23860930, 23729102, 23598722, 23469767,
- 23342214, 23216040, 23091223, 22967740, 22845571, 22724695, 22605092, 22486740,
- 22369622, 22253717, 22139007, 22025474, 21913099, 21801865, 21691755, 21582751,
- 21474837, 21367997, 21262215, 21157475, 21053762, 20951060, 20849356, 20748635,
- 20648882, 20550083, 20452226, 20355296, 20259280, 20164166, 20069941, 19976593,
- 19884108, 19792477, 19701685, 19611723, 19522579, 19434242, 19346700, 19259944,
- 19173962, 19088744, 19004281, 18920561, 18837576, 18755316, 18673771, 18592933,
- 18512791, 18433337, 18354562, 18276457, 18199014, 18122225, 18046082, 17970575,
- 17895698, 17821442, 17747799, 17674763, 17602325, 17530479, 17459217, 17388532,
- 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
- 16777216
-};
-
/* Input permutation for the simple_idct_mmx */
static const uint8_t simple_mmx_permutation[64]={
0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
@@ -394,38 +355,45 @@ void ff_emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize, int blo
start_x= FFMAX(0, -src_x);
end_y= FFMIN(block_h, h-src_y);
end_x= FFMIN(block_w, w-src_x);
+ assert(start_y < end_y && block_h);
+ assert(start_x < end_x && block_w);
- // copy existing part
- for(y=start_y; y<end_y; y++){
- for(x=start_x; x<end_x; x++){
- buf[x + y*linesize]= src[x + y*linesize];
- }
- }
+ w = end_x - start_x;
+ src += start_y*linesize + start_x;
+ buf += start_x;
//top
for(y=0; y<start_y; y++){
- for(x=start_x; x<end_x; x++){
- buf[x + y*linesize]= buf[x + start_y*linesize];
- }
+ memcpy(buf, src, w);
+ buf += linesize;
+ }
+
+ // copy existing part
+ for(; y<end_y; y++){
+ memcpy(buf, src, w);
+ src += linesize;
+ buf += linesize;
}
//bottom
- for(y=end_y; y<block_h; y++){
- for(x=start_x; x<end_x; x++){
- buf[x + y*linesize]= buf[x + (end_y-1)*linesize];
- }
+ src -= linesize;
+ for(; y<block_h; y++){
+ memcpy(buf, src, w);
+ buf += linesize;
}
- for(y=0; y<block_h; y++){
+ buf -= block_h * linesize + start_x;
+ while (block_h--){
//left
for(x=0; x<start_x; x++){
- buf[x + y*linesize]= buf[start_x + y*linesize];
+ buf[x] = buf[start_x];
}
//right
for(x=end_x; x<block_w; x++){
- buf[x + y*linesize]= buf[end_x - 1 + y*linesize];
+ buf[x] = buf[end_x - 1];
}
+ buf += linesize;
}
}
@@ -1199,7 +1167,7 @@ CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels8_c , 8)\
CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels8_x2_c , 8)\
CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels8_y2_c , 8)\
CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels8_xy2_c, 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_c , OPNAME ## _pixels8_c , 8)\
+av_unused CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_c , OPNAME ## _pixels8_c , 8)\
CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels8_x2_c , 8)\
CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels8_y2_c , 8)\
CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels8_xy2_c, 8)\
@@ -1213,6 +1181,9 @@ PIXOP2(put, op_put)
#undef op_avg
#undef op_put
+#define put_no_rnd_pixels8_c put_pixels8_c
+#define put_no_rnd_pixels16_c put_pixels16_c
+
#define avg2(a,b) ((a+b+1)>>1)
#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
@@ -1795,10 +1766,6 @@ static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dst
}\
}\
\
-static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## pixels8_c(dst, src, stride, 8);\
-}\
-\
static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
uint8_t half[64];\
put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
@@ -1977,9 +1944,6 @@ static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
}\
-static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## pixels16_c(dst, src, stride, 16);\
-}\
\
static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
uint8_t half[256];\
@@ -2174,6 +2138,13 @@ QPEL_MC(0, avg_ , _ , op_avg)
#undef op_put
#undef op_put_no_rnd
+#define put_qpel8_mc00_c ff_put_pixels8x8_c
+#define avg_qpel8_mc00_c ff_avg_pixels8x8_c
+#define put_qpel16_mc00_c ff_put_pixels16x16_c
+#define avg_qpel16_mc00_c ff_avg_pixels16x16_c
+#define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
+#define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
+
#if 1
#define H264_LOWPASS(OPNAME, OP, OP2) \
static av_unused void OPNAME ## h264_qpel2_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
@@ -2440,7 +2411,7 @@ static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t
}\
#define H264_MC(OPNAME, SIZE) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
+static av_unused void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
}\
\
@@ -2598,6 +2569,11 @@ H264_MC(avg_, 16)
#undef op2_put
#endif
+#define put_h264_qpel8_mc00_c ff_put_pixels8x8_c
+#define avg_h264_qpel8_mc00_c ff_avg_pixels8x8_c
+#define put_h264_qpel16_mc00_c ff_put_pixels16x16_c
+#define avg_h264_qpel16_mc00_c ff_avg_pixels16x16_c
+
static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
@@ -2616,31 +2592,18 @@ static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int
}
}
-#if CONFIG_CAVS_DECODER
-/* AVS specific */
-void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
+void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride) {
put_pixels8_c(dst, src, stride, 8);
}
-void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
+void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride) {
avg_pixels8_c(dst, src, stride, 8);
}
-void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
+void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride) {
put_pixels16_c(dst, src, stride, 16);
}
-void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride) {
+void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride) {
avg_pixels16_c(dst, src, stride, 16);
}
-#endif /* CONFIG_CAVS_DECODER */
-
-#if CONFIG_VC1_DECODER
-/* VC-1 specific */
-void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- put_pixels8_c(dst, src, stride, 8);
-}
-void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) {
- avg_pixels8_c(dst, src, stride, 8);
-}
-#endif /* CONFIG_VC1_DECODER */
#if CONFIG_RV40_DECODER
static void put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
@@ -2686,10 +2649,6 @@ static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int
}
}
-static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){
- put_pixels8_c(dst, src, stride, 8);
-}
-
static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){
uint8_t half[64];
wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
@@ -3798,10 +3757,10 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
WRAPPER8_16_SQ(rd8x8_c, rd16_c)
WRAPPER8_16_SQ(bit8x8_c, bit16_c)
-static void vector_fmul_c(float *dst, const float *src, int len){
+static void vector_fmul_c(float *dst, const float *src0, const float *src1, int len){
int i;
for(i=0; i<len; i++)
- dst[i] *= src[i];
+ dst[i] = src0[i] * src1[i];
}
static void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, int len){
@@ -3817,7 +3776,9 @@ static void vector_fmul_add_c(float *dst, const float *src0, const float *src1,
dst[i] = src0[i] * src1[i] + src2[i];
}
-void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len){
+static void vector_fmul_window_c(float *dst, const float *src0,
+ const float *src1, const float *win, int len)
+{
int i,j;
dst += len;
win += len;
@@ -3827,8 +3788,8 @@ void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, c
float s1 = src1[j];
float wi = win[i];
float wj = win[j];
- dst[i] = s0*wj - s1*wi + add_bias;
- dst[j] = s0*wi + s1*wj + add_bias;
+ dst[i] = s0*wj - s1*wi;
+ dst[j] = s0*wi + s1*wj;
}
}
@@ -3906,12 +3867,6 @@ static float scalarproduct_float_c(const float *v1, const float *v2, int len)
return p;
}
-static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
- int i;
- for(i=0; i<len; i++)
- dst[i] = src[i] * mul;
-}
-
static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
uint32_t maxi, uint32_t maxisign)
{
@@ -3957,37 +3912,6 @@ static void vector_clipf_c(float *dst, const float *src, float min, float max, i
}
}
-static av_always_inline int float_to_int16_one(const float *src){
- int_fast32_t tmp = *(const int32_t*)src;
- if(tmp & 0xf0000){
- tmp = (0x43c0ffff - tmp)>>31;
- // is this faster on some gcc/cpu combinations?
-// if(tmp > 0x43c0ffff) tmp = 0xFFFF;
-// else tmp = 0;
- }
- return tmp - 0x8000;
-}
-
-void ff_float_to_int16_c(int16_t *dst, const float *src, long len){
- int i;
- for(i=0; i<len; i++)
- dst[i] = float_to_int16_one(src+i);
-}
-
-void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels){
- int i,j,c;
- if(channels==2){
- for(i=0; i<len; i++){
- dst[2*i] = float_to_int16_one(src[0]+i);
- dst[2*i+1] = float_to_int16_one(src[1]+i);
- }
- }else{
- for(c=0; c<channels; c++)
- for(i=0, j=c; i<len; i++, j+=channels)
- dst[j] = float_to_int16_one(src[c]+i);
- }
-}
-
static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order, int shift)
{
int res = 0;
@@ -4266,6 +4190,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->add_pixels8 = add_pixels8_c;
c->add_pixels4 = add_pixels4_c;
c->sum_abs_dctelem = sum_abs_dctelem_c;
+ c->emulated_edge_mc = ff_emulated_edge_mc;
c->gmc1 = gmc1_c;
c->gmc = ff_gmc_c;
c->clear_block = clear_block_c;
@@ -4381,10 +4306,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->draw_edges = draw_edges_c;
-#if CONFIG_CAVS_DECODER
- ff_cavsdsp_init(c,avctx);
-#endif
-
#if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
ff_mlp_init(c, avctx);
#endif
@@ -4405,7 +4326,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->avg_rv40_qpel_pixels_tab[1][15] = avg_rv40_qpel8_mc33_c;
#endif
- c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
+ c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
@@ -4470,9 +4391,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;
c->vp3_idct_dc_add= ff_vp3_idct_dc_add_c;
}
- if (CONFIG_VP6_DECODER) {
- c->vp6_filter_diag4= ff_vp6_filter_diag4_c;
- }
c->h261_loop_filter= h261_loop_filter_c;
@@ -4485,17 +4403,11 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
#if CONFIG_AC3_DECODER
c->ac3_downmix = ff_ac3_downmix_c;
#endif
-#if CONFIG_LPC
- c->lpc_compute_autocorr = ff_lpc_compute_autocorr;
-#endif
c->vector_fmul = vector_fmul_c;
c->vector_fmul_reverse = vector_fmul_reverse_c;
c->vector_fmul_add = vector_fmul_add_c;
- c->vector_fmul_window = ff_vector_fmul_window_c;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
+ c->vector_fmul_window = vector_fmul_window_c;
c->vector_clipf = vector_clipf_c;
- c->float_to_int16 = ff_float_to_int16_c;
- c->float_to_int16_interleave = ff_float_to_int16_interleave_c;
c->scalarproduct_int16 = scalarproduct_int16_c;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
c->scalarproduct_float = scalarproduct_float_c;
@@ -4508,7 +4420,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->sv_fmul_scalar[0] = sv_fmul_scalar_2_c;
c->sv_fmul_scalar[1] = sv_fmul_scalar_4_c;
- c->shrink[0]= ff_img_copy_plane;
+ c->shrink[0]= av_image_copy_plane;
c->shrink[1]= ff_shrink22;
c->shrink[2]= ff_shrink44;
c->shrink[3]= ff_shrink88;
diff --git a/lib/ffmpeg/libavcodec/dsputil.h b/lib/ffmpeg/libavcodec/dsputil.h
index d67483679c..c8111866c2 100644
--- a/lib/ffmpeg/libavcodec/dsputil.h
+++ b/lib/ffmpeg/libavcodec/dsputil.h
@@ -64,10 +64,9 @@ void ff_h264_idct_add16intra_c(uint8_t *dst, const int *blockoffset, DCTELEM *bl
void ff_h264_idct8_add4_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
void ff_h264_idct_add8_c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
-void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1,
- const float *win, float add_bias, int len);
-void ff_float_to_int16_c(int16_t *dst, const float *src, long len);
-void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels);
+void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul);
+void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp);
+void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
/* encoding scans */
extern const uint8_t ff_alternate_horizontal_scan[64];
@@ -82,6 +81,11 @@ extern const uint8_t ff_zigzag248_direct[64];
extern uint32_t ff_squareTbl[512];
extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
+void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride);
+void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, int stride);
+void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride);
+void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, int stride);
+
/* VP3 DSP functions */
void ff_vp3_idct_c(DCTELEM *block/* align 16*/);
void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
@@ -91,30 +95,23 @@ void ff_vp3_idct_dc_add_c(uint8_t *dest/*align 8*/, int line_size, const DCTELEM
void ff_vp3_v_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
void ff_vp3_h_loop_filter_c(uint8_t *src, int stride, int *bounding_values);
-/* VP6 DSP functions */
-void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights, const int16_t *v_weights);
-
/* Bink functions */
void ff_bink_idct_c (DCTELEM *block);
void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block);
void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
-/* CAVS functions */
-void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
-void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
-void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
-void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
-
-/* VC1 functions */
-void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-
/* EA functions */
void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
/* 1/2^n downscaling functions from imgconvert.c */
+#if LIBAVCODEC_VERSION_MAJOR < 53
+/**
+ * @deprecated Use av_image_copy_plane() instead.
+ */
+attribute_deprecated
void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
+#endif
+
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
@@ -216,6 +213,21 @@ typedef struct DSPContext {
void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
int (*sum_abs_dctelem)(DCTELEM *block/*align 16*/);
/**
+ * Motion estimation with emulated edge values.
+ * @param buf pointer to destination buffer (unaligned)
+ * @param src pointer to pixel source (unaligned)
+ * @param linesize width (in pixels) for src/buf
+ * @param block_w number of pixels (per row) to copy to buf
+ * @param block_h nummber of pixel rows to copy to buf
+ * @param src_x offset of src to start of row - this may be negative
+ * @param src_y offset of src to top of image - this may be negative
+ * @param w width of src in pixels
+ * @param h height of src in pixels
+ */
+ void (*emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h);
+ /**
* translational global motion compensation.
*/
void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
@@ -339,15 +351,6 @@ typedef struct DSPContext {
qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
- /* AVS specific */
- qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
- qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
- void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
- void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
-
me_cmp_func pix_abs[2][4];
/* huffyuv specific */
@@ -378,23 +381,17 @@ typedef struct DSPContext {
void (*vp3_v_loop_filter)(uint8_t *src, int stride, int *bounding_values);
void (*vp3_h_loop_filter)(uint8_t *src, int stride, int *bounding_values);
- void (*vp6_filter_diag4)(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights);
-
/* assume len is a multiple of 4, and arrays are 16-byte aligned */
void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize);
void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
- /* no alignment needed */
- void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc);
/* assume len is a multiple of 8, and arrays are 16-byte aligned */
- void (*vector_fmul)(float *dst, const float *src, int len);
+ void (*vector_fmul)(float *dst, const float *src0, const float *src1, int len);
void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len);
/* assume len is a multiple of 8, and src arrays are 16-byte aligned */
void (*vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len);
/* assume len is a multiple of 4, and arrays are 16-byte aligned */
- void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len);
+ void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len);
/* assume len is a multiple of 8, and arrays are 16-byte aligned */
- void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
/**
* Multiply a vector of floats by a scalar float. Source and
@@ -447,11 +444,6 @@ typedef struct DSPContext {
*/
void (*butterflies_float)(float *restrict v1, float *restrict v2, int len);
- /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767]
- * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
- void (*float_to_int16)(int16_t *dst, const float *src, long len);
- void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels);
-
/* (I)DCT */
void (*fdct)(DCTELEM *block/* align 16*/);
void (*fdct248)(DCTELEM *block/* align 16*/);
@@ -624,11 +616,6 @@ static inline int get_penalty_factor(int lambda, int lambda2, int type){
*/
#define emms_c()
-/* should be defined by architectures supporting
- one or more MultiMedia extension */
-int mm_support(void);
-extern int mm_flags;
-
void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
@@ -640,7 +627,6 @@ void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
void ff_dsputil_init_dwt(DSPContext *c);
-void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
@@ -657,12 +643,7 @@ static inline void emms(void)
__asm__ volatile ("emms;":::"memory");
}
-
-#define emms_c() \
-{\
- if (mm_flags & FF_MM_MMX)\
- emms();\
-}
+#define emms_c() emms()
#elif ARCH_ARM
@@ -678,31 +659,30 @@ static inline void emms(void)
#define STRIDE_ALIGN 16
-#else
-
-#define mm_flags 0
-#define mm_support() 0
-
#endif
#ifndef STRIDE_ALIGN
# define STRIDE_ALIGN 8
#endif
-#define LOCAL_ALIGNED(a, t, v, s, ...) \
- uint8_t la_##v[sizeof(t s __VA_ARGS__) + (a)]; \
- t (*v) __VA_ARGS__ = (void *)FFALIGN((uintptr_t)la_##v, a)
+#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
+ uint8_t la_##v[sizeof(t s o) + (a)]; \
+ t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
+
+#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) DECLARE_ALIGNED(a, t, v) s o
+
+#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,)
#if HAVE_LOCAL_ALIGNED_8
-# define LOCAL_ALIGNED_8(t, v, s, ...) DECLARE_ALIGNED(8, t, v) s __VA_ARGS__
+# define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,)
#else
-# define LOCAL_ALIGNED_8(t, v, s, ...) LOCAL_ALIGNED(8, t, v, s, __VA_ARGS__)
+# define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
#endif
#if HAVE_LOCAL_ALIGNED_16
-# define LOCAL_ALIGNED_16(t, v, s, ...) DECLARE_ALIGNED(16, t, v) s __VA_ARGS__
+# define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,)
#else
-# define LOCAL_ALIGNED_16(t, v, s, ...) LOCAL_ALIGNED(16, t, v, s, __VA_ARGS__)
+# define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
#endif
/* PSNR */
diff --git a/lib/ffmpeg/libavcodec/dump_extradata_bsf.c b/lib/ffmpeg/libavcodec/dump_extradata_bsf.c
index db263490a3..9499d6d8d8 100644
--- a/lib/ffmpeg/libavcodec/dump_extradata_bsf.c
+++ b/lib/ffmpeg/libavcodec/dump_extradata_bsf.c
@@ -43,7 +43,7 @@ static int dump_extradata(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx,
return 0;
}
-AVBitStreamFilter dump_extradata_bsf={
+AVBitStreamFilter ff_dump_extradata_bsf={
"dump_extra",
0,
dump_extradata,
diff --git a/lib/ffmpeg/libavcodec/dv.c b/lib/ffmpeg/libavcodec/dv.c
index 9f53562328..6a4914768d 100644
--- a/lib/ffmpeg/libavcodec/dv.c
+++ b/lib/ffmpeg/libavcodec/dv.c
@@ -948,7 +948,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
int mb_x, mb_y, c_offset, linesize, y_stride;
uint8_t* y_ptr;
uint8_t* dif;
- uint8_t scratch[64];
+ LOCAL_ALIGNED_8(uint8_t, scratch, [64]);
EncBlockInfo enc_blks[5*DV_MAX_BPM];
PutBitContext pbs[5*DV_MAX_BPM];
PutBitContext* pb;
@@ -1081,6 +1081,8 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
DVVideoContext *s = avctx->priv_data;
+ const uint8_t* vsc_pack;
+ int apt, is16_9;
s->sys = ff_dv_frame_profile(s->sys, buf, buf_size);
if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) {
@@ -1114,6 +1116,14 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->picture;
+ /* Determine the codec's sample_aspect ratio from the packet */
+ vsc_pack = buf + 80*5 + 48 + 5;
+ if ( *vsc_pack == dv_video_control ) {
+ apt = buf[4] & 0x07;
+ is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07)));
+ avctx->sample_aspect_ratio = s->sys->sar[is16_9];
+ }
+
return s->sys->frame_size;
}
#endif /* CONFIG_DVVIDEO_DECODER */
@@ -1280,7 +1290,7 @@ static int dvvideo_close(AVCodecContext *c)
#if CONFIG_DVVIDEO_ENCODER
-AVCodec dvvideo_encoder = {
+AVCodec ff_dvvideo_encoder = {
"dvvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DVVIDEO,
@@ -1293,7 +1303,7 @@ AVCodec dvvideo_encoder = {
#endif // CONFIG_DVVIDEO_ENCODER
#if CONFIG_DVVIDEO_DECODER
-AVCodec dvvideo_decoder = {
+AVCodec ff_dvvideo_decoder = {
"dvvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DVVIDEO,
diff --git a/lib/ffmpeg/libavcodec/dvbsub.c b/lib/ffmpeg/libavcodec/dvbsub.c
index ea55cae317..c2a129864f 100644
--- a/lib/ffmpeg/libavcodec/dvbsub.c
+++ b/lib/ffmpeg/libavcodec/dvbsub.c
@@ -402,7 +402,7 @@ static int dvbsub_encode(AVCodecContext *avctx,
return ret;
}
-AVCodec dvbsub_encoder = {
+AVCodec ff_dvbsub_encoder = {
"dvbsub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_DVB_SUBTITLE,
diff --git a/lib/ffmpeg/libavcodec/dvbsub_parser.c b/lib/ffmpeg/libavcodec/dvbsub_parser.c
index c9ccfd0d9c..6ecd44af13 100644
--- a/lib/ffmpeg/libavcodec/dvbsub_parser.c
+++ b/lib/ffmpeg/libavcodec/dvbsub_parser.c
@@ -55,7 +55,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
uint8_t *p, *p_end;
int len, buf_pos = 0;
- dprintf(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n",
+ av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n",
s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]);
#ifdef DEBUG_PACKET_CONTENTS
@@ -82,7 +82,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
{
if (pc->packet_index != pc->packet_start)
{
- dprintf(avctx, "Discarding %d bytes\n",
+ av_dlog(avctx, "Discarding %d bytes\n",
pc->packet_index - pc->packet_start);
}
@@ -90,7 +90,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
pc->packet_index = 0;
if (buf_size < 2 || buf[0] != 0x20 || buf[1] != 0x00) {
- dprintf(avctx, "Bad packet header\n");
+ av_dlog(avctx, "Bad packet header\n");
return -1;
}
@@ -147,7 +147,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
} else if (*p == 0xff) {
if (p + 1 < p_end)
{
- dprintf(avctx, "Junk at end of packet\n");
+ av_dlog(avctx, "Junk at end of packet\n");
}
pc->packet_index = p - pc->packet_buf;
pc->in_packet = 0;
@@ -179,7 +179,7 @@ static av_cold void dvbsub_parse_close(AVCodecParserContext *s)
av_freep(&pc->packet_buf);
}
-AVCodecParser dvbsub_parser = {
+AVCodecParser ff_dvbsub_parser = {
{ CODEC_ID_DVB_SUBTITLE },
sizeof(DVBSubParseContext),
dvbsub_parse_init,
diff --git a/lib/ffmpeg/libavcodec/dvbsubdec.c b/lib/ffmpeg/libavcodec/dvbsubdec.c
index f5384471f5..e68a0b3c74 100644
--- a/lib/ffmpeg/libavcodec/dvbsubdec.c
+++ b/lib/ffmpeg/libavcodec/dvbsubdec.c
@@ -358,8 +358,14 @@ static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
int i, r, g, b, a = 0;
DVBSubContext *ctx = avctx->priv_data;
- ctx->composition_id = avctx->sub_id & 0xffff;
- ctx->ancillary_id = avctx->sub_id >> 16;
+ if (!avctx->extradata || avctx->extradata_size != 4) {
+ av_log(avctx, AV_LOG_WARNING, "Invalid extradata, subtitle streams may be combined!\n");
+ ctx->composition_id = -1;
+ ctx->ancillary_id = -1;
+ } else {
+ ctx->composition_id = AV_RB16(avctx->extradata);
+ ctx->ancillary_id = AV_RB16(avctx->extradata + 2);
+ }
default_clut.id = -1;
default_clut.next = NULL;
@@ -743,7 +749,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
uint8_t *map_table;
- dprintf(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
+ av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
top_bottom ? "bottom" : "top");
#ifdef DEBUG_PACKET_CONTENTS
@@ -978,7 +984,7 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx,
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
- dprintf(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
+ av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
@@ -1054,11 +1060,11 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
region->bgcolor = (((*buf++) >> 2) & 3);
}
- dprintf(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
+ av_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
- dprintf(avctx, "Fill region (%d)\n", region->bgcolor);
+ av_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
}
delete_region_display_list(ctx, region);
@@ -1119,7 +1125,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
ctx->time_out = *buf++;
page_state = ((*buf++) >> 2) & 3;
- dprintf(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
+ av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if (page_state == 2) {
delete_state(ctx);
@@ -1157,7 +1163,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
ctx->display_list = display;
ctx->display_list_size++;
- dprintf(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
+ av_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
}
while (tmp_display_list) {
@@ -1434,7 +1440,8 @@ static int dvbsub_decode(AVCodecContext *avctx,
segment_length = AV_RB16(p);
p += 2;
- if (page_id == ctx->composition_id || page_id == ctx->ancillary_id) {
+ if (page_id == ctx->composition_id || page_id == ctx->ancillary_id ||
+ ctx->composition_id == -1 || ctx->ancillary_id == -1) {
switch (segment_type) {
case DVBSUB_PAGE_SEGMENT:
dvbsub_parse_page_segment(avctx, p, segment_length);
@@ -1454,7 +1461,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
*data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);
break;
default:
- dprintf(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
+ av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
segment_type, page_id, segment_length);
break;
}
@@ -1464,7 +1471,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
}
if (p != p_end) {
- dprintf(avctx, "Junk at end of packet\n");
+ av_dlog(avctx, "Junk at end of packet\n");
return -1;
}
@@ -1472,7 +1479,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
}
-AVCodec dvbsub_decoder = {
+AVCodec ff_dvbsub_decoder = {
"dvbsub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_DVB_SUBTITLE,
diff --git a/lib/ffmpeg/libavcodec/dvdata.c b/lib/ffmpeg/libavcodec/dvdata.c
index 7232bafe0d..05993d874f 100644
--- a/lib/ffmpeg/libavcodec/dvdata.c
+++ b/lib/ffmpeg/libavcodec/dvdata.c
@@ -52,7 +52,7 @@ static const DVprofile dv_profiles[] = {
.ltc_divisor = 30,
.height = 480,
.width = 720,
- .sar = {{10, 11}, {40, 33}},
+ .sar = {{8, 9}, {32, 27}},
.work_chunks = &work_chunks_dv25ntsc[0],
.idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = PIX_FMT_YUV411P,
@@ -72,7 +72,7 @@ static const DVprofile dv_profiles[] = {
.ltc_divisor = 25,
.height = 576,
.width = 720,
- .sar = {{59, 54}, {118, 81}},
+ .sar = {{16, 15}, {64, 45}},
.work_chunks = &work_chunks_dv25pal[0],
.idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = PIX_FMT_YUV420P,
@@ -92,7 +92,7 @@ static const DVprofile dv_profiles[] = {
.ltc_divisor = 25,
.height = 576,
.width = 720,
- .sar = {{59, 54}, {118, 81}},
+ .sar = {{16, 15}, {64, 45}},
.work_chunks = &work_chunks_dv25pal411[0],
.idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = PIX_FMT_YUV411P,
@@ -112,7 +112,7 @@ static const DVprofile dv_profiles[] = {
.ltc_divisor = 30,
.height = 480,
.width = 720,
- .sar = {{10, 11}, {40, 33}},
+ .sar = {{8, 9}, {32, 27}},
.work_chunks = &work_chunks_dv50ntsc[0],
.idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = PIX_FMT_YUV422P,
@@ -132,7 +132,7 @@ static const DVprofile dv_profiles[] = {
.ltc_divisor = 25,
.height = 576,
.width = 720,
- .sar = {{59, 54}, {118, 81}},
+ .sar = {{16, 15}, {64, 45}},
.work_chunks = &work_chunks_dv50pal[0],
.idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = PIX_FMT_YUV422P,
@@ -232,7 +232,7 @@ static const DVprofile dv_profiles[] = {
.ltc_divisor = 25,
.height = 576,
.width = 720,
- .sar = {{59, 54}, {118, 81}},
+ .sar = {{16, 15}, {64, 45}},
.work_chunks = &work_chunks_dv25pal[0],
.idct_factor = &dv_idct_factor_sd[0],
.pix_fmt = PIX_FMT_YUV420P,
@@ -255,7 +255,7 @@ const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
int stype = frame[80*5 + 48 + 3] & 0x1f;
/* 576i50 25Mbps 4:1:1 is a special case */
- if (dsf == 1 && stype == 0 && frame[5] & 0x07) {
+ if (dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) {
return &dv_profiles[2];
}
diff --git a/lib/ffmpeg/libavcodec/dvdsub_parser.c b/lib/ffmpeg/libavcodec/dvdsub_parser.c
index 8f1b8d08e3..3bbf0dcb8b 100644
--- a/lib/ffmpeg/libavcodec/dvdsub_parser.c
+++ b/lib/ffmpeg/libavcodec/dvdsub_parser.c
@@ -76,7 +76,7 @@ static av_cold void dvdsub_parse_close(AVCodecParserContext *s)
av_freep(&pc->packet);
}
-AVCodecParser dvdsub_parser = {
+AVCodecParser ff_dvdsub_parser = {
{ CODEC_ID_DVD_SUBTITLE },
sizeof(DVDSubParseContext),
dvdsub_parse_init,
diff --git a/lib/ffmpeg/libavcodec/dvdsubdec.c b/lib/ffmpeg/libavcodec/dvdsubdec.c
index e7fc75a9c7..e713e24bfe 100644
--- a/lib/ffmpeg/libavcodec/dvdsubdec.c
+++ b/lib/ffmpeg/libavcodec/dvdsubdec.c
@@ -225,7 +225,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
- dprintf(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
+ av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
@@ -233,7 +233,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
- dprintf(NULL, "cmd=%02x\n", cmd);
+ av_dlog(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
/* menu subpicture */
@@ -266,7 +266,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
- dprintf(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
+ av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
@@ -278,7 +278,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
- dprintf(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
+ av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
@@ -286,7 +286,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
- dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
+ av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
@@ -294,7 +294,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
- dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
+ av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
@@ -317,7 +317,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
case 0xff:
goto the_end;
default:
- dprintf(NULL, "unrecognised subpicture command 0x%x\n", cmd);
+ av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
@@ -495,7 +495,7 @@ static int dvdsub_decode(AVCodecContext *avctx,
DVDSubContext *ctx = (DVDSubContext*) avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- AVSubtitle *sub = (void *)data;
+ AVSubtitle *sub = data;
int is_menu;
is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
@@ -510,7 +510,7 @@ static int dvdsub_decode(AVCodecContext *avctx,
goto no_subtitle;
#if defined(DEBUG)
- dprintf(NULL, "start=%d ms end =%d ms\n",
+ av_dlog(NULL, "start=%d ms end =%d ms\n",
sub->start_display_time,
sub->end_display_time);
ppm_save("/tmp/a.ppm", sub->rects[0]->pict.data[0],
@@ -563,7 +563,7 @@ static int dvdsub_init(AVCodecContext *avctx)
return 1;
}
-AVCodec dvdsub_decoder = {
+AVCodec ff_dvdsub_decoder = {
"dvdsub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_DVD_SUBTITLE,
diff --git a/lib/ffmpeg/libavcodec/dvdsubenc.c b/lib/ffmpeg/libavcodec/dvdsubenc.c
index 4ee0f37c9d..d09ac269ed 100644
--- a/lib/ffmpeg/libavcodec/dvdsubenc.c
+++ b/lib/ffmpeg/libavcodec/dvdsubenc.c
@@ -215,7 +215,7 @@ static int dvdsub_encode(AVCodecContext *avctx,
return ret;
}
-AVCodec dvdsub_encoder = {
+AVCodec ff_dvdsub_encoder = {
"dvdsub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_DVD_SUBTITLE,
diff --git a/lib/ffmpeg/libavcodec/dwt.c b/lib/ffmpeg/libavcodec/dwt.c
index 2ecb04a4ee..d9d58de8b2 100644
--- a/lib/ffmpeg/libavcodec/dwt.c
+++ b/lib/ffmpeg/libavcodec/dwt.c
@@ -697,7 +697,7 @@ void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs, slice_buffe
}
}
-void ff_spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
+static void ff_spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
int level;
for(level=decomposition_count-1; level>=0; level--){
switch(type){
@@ -707,7 +707,7 @@ void ff_spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int heigh
}
}
-void ff_spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count, int y){
+static void ff_spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count, int y){
const int support = type==1 ? 3 : 5;
int level;
if(type==2) return;
diff --git a/lib/ffmpeg/libavcodec/dwt.h b/lib/ffmpeg/libavcodec/dwt.h
index 8c3aa204d6..b10e4f5596 100644
--- a/lib/ffmpeg/libavcodec/dwt.h
+++ b/lib/ffmpeg/libavcodec/dwt.h
@@ -146,8 +146,6 @@ void ff_spatial_dwt(int *buffer, int width, int height, int stride, int type, in
void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer * sb, int width, int height, int stride_line, int type, int decomposition_count);
void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs, slice_buffer * slice_buf, int width, int height, int stride_line, int type, int decomposition_count, int y);
-void ff_spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count);
-void ff_spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count, int y);
void ff_spatial_idwt(IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count);
void ff_dwt_init(DWTContext *c);
diff --git a/lib/ffmpeg/libavcodec/dxa.c b/lib/ffmpeg/libavcodec/dxa.c
index 62e4e0ae82..00156292c9 100644
--- a/lib/ffmpeg/libavcodec/dxa.c
+++ b/lib/ffmpeg/libavcodec/dxa.c
@@ -317,7 +317,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec dxa_decoder = {
+AVCodec ff_dxa_decoder = {
"dxa",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DXA,
diff --git a/lib/ffmpeg/libavcodec/dxva2_h264.c b/lib/ffmpeg/libavcodec/dxva2_h264.c
index bdb42df3f7..17fb2b55c3 100644
--- a/lib/ffmpeg/libavcodec/dxva2_h264.c
+++ b/lib/ffmpeg/libavcodec/dxva2_h264.c
@@ -423,7 +423,7 @@ static int end_frame(AVCodecContext *avctx)
commit_bitstream_and_slice_buffer);
}
-AVHWAccel h264_dxva2_hwaccel = {
+AVHWAccel ff_h264_dxva2_hwaccel = {
.name = "h264_dxva2",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_H264,
diff --git a/lib/ffmpeg/libavcodec/dxva2_mpeg2.c b/lib/ffmpeg/libavcodec/dxva2_mpeg2.c
index 3b75dae11c..780542a6c1 100644
--- a/lib/ffmpeg/libavcodec/dxva2_mpeg2.c
+++ b/lib/ffmpeg/libavcodec/dxva2_mpeg2.c
@@ -260,7 +260,7 @@ static int end_frame(AVCodecContext *avctx)
commit_bitstream_and_slice_buffer);
}
-AVHWAccel mpeg2_dxva2_hwaccel = {
+AVHWAccel ff_mpeg2_dxva2_hwaccel = {
.name = "mpeg2_dxva2",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_MPEG2VIDEO,
diff --git a/lib/ffmpeg/libavcodec/dxva2_vc1.c b/lib/ffmpeg/libavcodec/dxva2_vc1.c
index a11121347a..2b9a690ebc 100644
--- a/lib/ffmpeg/libavcodec/dxva2_vc1.c
+++ b/lib/ffmpeg/libavcodec/dxva2_vc1.c
@@ -264,7 +264,7 @@ static int end_frame(AVCodecContext *avctx)
}
#if CONFIG_WMV3_DXVA2_HWACCEL
-AVHWAccel wmv3_dxva2_hwaccel = {
+AVHWAccel ff_wmv3_dxva2_hwaccel = {
.name = "wmv3_dxva2",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_WMV3,
@@ -277,7 +277,7 @@ AVHWAccel wmv3_dxva2_hwaccel = {
};
#endif
-AVHWAccel vc1_dxva2_hwaccel = {
+AVHWAccel ff_vc1_dxva2_hwaccel = {
.name = "vc1_dxva2",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_VC1,
diff --git a/lib/ffmpeg/libavcodec/eacmv.c b/lib/ffmpeg/libavcodec/eacmv.c
index 517b307271..6770cd195e 100644
--- a/lib/ffmpeg/libavcodec/eacmv.c
+++ b/lib/ffmpeg/libavcodec/eacmv.c
@@ -29,6 +29,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
typedef struct CmvContext {
@@ -96,9 +97,10 @@ static void cmv_decode_inter(CmvContext * s, const uint8_t *buf, const uint8_t *
}else if(raw<buf_end) { /* inter using second-last frame as reference */
int xoffset = (*raw & 0xF) - 7;
int yoffset = ((*raw >> 4)) - 7;
- cmv_motcomp(s->frame.data[0], s->frame.linesize[0],
- s->last2_frame.data[0], s->last2_frame.linesize[0],
- x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
+ if (s->last2_frame.data[0])
+ cmv_motcomp(s->frame.data[0], s->frame.linesize[0],
+ s->last2_frame.data[0], s->last2_frame.linesize[0],
+ x*4, y*4, xoffset, yoffset, s->avctx->width, s->avctx->height);
raw++;
}
}else{ /* inter using last frame as reference */
@@ -156,7 +158,7 @@ static int cmv_decode_frame(AVCodecContext *avctx,
return buf_size;
}
- if (avcodec_check_dimensions(s->avctx, s->width, s->height))
+ if (av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
/* shuffle */
@@ -203,7 +205,7 @@ static av_cold int cmv_decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec eacmv_decoder = {
+AVCodec ff_eacmv_decoder = {
"eacmv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_CMV,
diff --git a/lib/ffmpeg/libavcodec/eamad.c b/lib/ffmpeg/libavcodec/eamad.c
index 3077c0883d..1dd3b79755 100644
--- a/lib/ffmpeg/libavcodec/eamad.c
+++ b/lib/ffmpeg/libavcodec/eamad.c
@@ -34,6 +34,7 @@
#include "aandcttab.h"
#include "mpeg12.h"
#include "mpeg12data.h"
+#include "libavcore/imgutils.h"
#define EA_PREAMBLE_SIZE 8
#define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */
@@ -260,7 +261,7 @@ static int decode_frame(AVCodecContext *avctx,
buf += 16;
if (avctx->width != s->width || avctx->height != s->height) {
- if (avcodec_check_dimensions(avctx, s->width, s->height) < 0)
+ if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
return -1;
avcodec_set_dimensions(avctx, s->width, s->height);
if (t->frame.data[0])
@@ -305,7 +306,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec eamad_decoder = {
+AVCodec ff_eamad_decoder = {
"eamad",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MAD,
diff --git a/lib/ffmpeg/libavcodec/eatgq.c b/lib/ffmpeg/libavcodec/eatgq.c
index 7a985050c5..6f35a1513b 100644
--- a/lib/ffmpeg/libavcodec/eatgq.c
+++ b/lib/ffmpeg/libavcodec/eatgq.c
@@ -243,7 +243,7 @@ static av_cold int tgq_decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec eatgq_decoder = {
+AVCodec ff_eatgq_decoder = {
"eatgq",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TGQ,
diff --git a/lib/ffmpeg/libavcodec/eatgv.c b/lib/ffmpeg/libavcodec/eatgv.c
index 8c6a654fad..075405a907 100644
--- a/lib/ffmpeg/libavcodec/eatgv.c
+++ b/lib/ffmpeg/libavcodec/eatgv.c
@@ -32,6 +32,7 @@
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
#include "libavutil/lzo.h"
+#include "libavcore/imgutils.h"
#define EA_PREAMBLE_SIZE 8
#define kVGT_TAG MKTAG('k', 'V', 'G', 'T')
@@ -275,7 +276,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
}
}
- if (avcodec_check_dimensions(avctx, s->width, s->height))
+ if (av_image_check_size(s->width, s->height, 0, avctx))
return -1;
/* shuffle */
@@ -333,7 +334,7 @@ static av_cold int tgv_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec eatgv_decoder = {
+AVCodec ff_eatgv_decoder = {
"eatgv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TGV,
diff --git a/lib/ffmpeg/libavcodec/eatqi.c b/lib/ffmpeg/libavcodec/eatqi.c
index 7f1901d309..44792f0483 100644
--- a/lib/ffmpeg/libavcodec/eatqi.c
+++ b/lib/ffmpeg/libavcodec/eatqi.c
@@ -154,7 +154,7 @@ static av_cold int tqi_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec eatqi_decoder = {
+AVCodec ff_eatqi_decoder = {
"eatqi",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TQI,
diff --git a/lib/ffmpeg/libavcodec/escape124.c b/lib/ffmpeg/libavcodec/escape124.c
index b51206a0b5..5a6769d342 100644
--- a/lib/ffmpeg/libavcodec/escape124.c
+++ b/lib/ffmpeg/libavcodec/escape124.c
@@ -195,15 +195,6 @@ static const uint16_t mask_matrix[] = {0x1, 0x2, 0x10, 0x20,
0x100, 0x200, 0x1000, 0x2000,
0x400, 0x800, 0x4000, 0x8000};
-/**
- * Decode a single frame
- * @param avctx decoder context
- * @param data decoded frame
- * @param data_size size of the decoded frame
- * @param buf input buffer
- * @param buf_size input buffer size
- * @return 0 success, -1 on error
- */
static int escape124_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
@@ -372,7 +363,7 @@ static int escape124_decode_frame(AVCodecContext *avctx,
}
-AVCodec escape124_decoder = {
+AVCodec ff_escape124_decoder = {
"escape124",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ESCAPE124,
diff --git a/lib/ffmpeg/libavcodec/fft-test.c b/lib/ffmpeg/libavcodec/fft-test.c
index ae436029ed..85282f531a 100644
--- a/lib/ffmpeg/libavcodec/fft-test.c
+++ b/lib/ffmpeg/libavcodec/fft-test.c
@@ -176,22 +176,25 @@ static int64_t gettime(void)
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}
-static void check_diff(float *tab1, float *tab2, int n, double scale)
+static int check_diff(float *tab1, float *tab2, int n, double scale)
{
int i;
double max= 0;
double error= 0;
+ int err = 0;
for (i = 0; i < n; i++) {
double e= fabsf(tab1[i] - (tab2[i] / scale));
if (e >= 1e-3) {
- av_log(NULL, AV_LOG_ERROR, "ERROR %d: %f %f\n",
+ av_log(NULL, AV_LOG_ERROR, "ERROR %5d: %10.6f %10.6f\n",
i, tab1[i], tab2[i]);
+ err = 1;
}
error+= e*e;
if(e>max) max= e;
}
av_log(NULL, AV_LOG_INFO, "max:%f e:%g\n", max, sqrt(error)/n);
+ return err;
}
@@ -223,6 +226,7 @@ int main(int argc, char **argv)
FFTSample *tab2;
int it, i, c;
int do_speed = 0;
+ int err = 1;
enum tf_transform transform = TRANSFORM_FFT;
int do_inverse = 0;
FFTContext s1, *s = &s1;
@@ -324,13 +328,13 @@ int main(int argc, char **argv)
if (do_inverse) {
imdct_ref((float *)tab_ref, (float *)tab1, fft_nbits);
ff_imdct_calc(m, tab2, (float *)tab1);
- check_diff((float *)tab_ref, tab2, fft_size, scale);
+ err = check_diff((float *)tab_ref, tab2, fft_size, scale);
} else {
mdct_ref((float *)tab_ref, (float *)tab1, fft_nbits);
ff_mdct_calc(m, tab2, (float *)tab1);
- check_diff((float *)tab_ref, tab2, fft_size / 2, scale);
+ err = check_diff((float *)tab_ref, tab2, fft_size / 2, scale);
}
break;
case TRANSFORM_FFT:
@@ -339,7 +343,7 @@ int main(int argc, char **argv)
ff_fft_calc(s, tab);
fft_ref(tab_ref, tab1, fft_nbits);
- check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0);
+ err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 1.0);
break;
case TRANSFORM_RDFT:
if (do_inverse) {
@@ -359,7 +363,7 @@ int main(int argc, char **argv)
tab[i].re = tab2[i];
tab[i].im = 0;
}
- check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 0.5);
+ err = check_diff((float *)tab_ref, (float *)tab, fft_size * 2, 0.5);
} else {
for (i = 0; i < fft_size; i++) {
tab2[i] = tab1[i].re;
@@ -368,7 +372,7 @@ int main(int argc, char **argv)
ff_rdft_calc(r, tab2);
fft_ref(tab_ref, tab1, fft_nbits);
tab_ref[0].im = tab_ref[fft_size_2].re;
- check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0);
+ err = check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0);
}
break;
case TRANSFORM_DCT:
@@ -379,7 +383,7 @@ int main(int argc, char **argv)
} else {
dct_ref(tab_ref, tab1, fft_nbits);
}
- check_diff((float *)tab_ref, (float *)tab, fft_size, 1.0);
+ err = check_diff((float *)tab_ref, (float *)tab, fft_size, 1.0);
break;
}
@@ -442,5 +446,12 @@ int main(int argc, char **argv)
ff_dct_end(d);
break;
}
- return 0;
+
+ av_free(tab);
+ av_free(tab1);
+ av_free(tab2);
+ av_free(tab_ref);
+ av_free(exptab);
+
+ return err;
}
diff --git a/lib/ffmpeg/libavcodec/fft.c b/lib/ffmpeg/libavcodec/fft.c
index 81765510e3..3fd4d279cb 100644
--- a/lib/ffmpeg/libavcodec/fft.c
+++ b/lib/ffmpeg/libavcodec/fft.c
@@ -53,6 +53,9 @@ COSTABLE_CONST FFTSample * const ff_cos_tabs[] = {
ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536,
};
+static void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
+static void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
+
static int split_radix_permutation(int i, int n, int inverse)
{
int m;
@@ -120,7 +123,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
return -1;
}
-void ff_fft_permute_c(FFTContext *s, FFTComplex *z)
+static void ff_fft_permute_c(FFTContext *s, FFTComplex *z)
{
int j, np;
const uint16_t *revtab = s->revtab;
@@ -289,7 +292,7 @@ static void (* const fft_dispatch[])(FFTComplex*) = {
fft2048, fft4096, fft8192, fft16384, fft32768, fft65536,
};
-void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
+static void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
{
fft_dispatch[s->nbits-2](z);
}
diff --git a/lib/ffmpeg/libavcodec/fft.h b/lib/ffmpeg/libavcodec/fft.h
index eb6714fe95..37cbfbf6a1 100644
--- a/lib/ffmpeg/libavcodec/fft.h
+++ b/lib/ffmpeg/libavcodec/fft.h
@@ -106,8 +106,6 @@ extern SINTABLE(65536);
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
*/
int ff_fft_init(FFTContext *s, int nbits, int inverse);
-void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
void ff_fft_init_altivec(FFTContext *s);
void ff_fft_init_mmx(FFTContext *s);
diff --git a/lib/ffmpeg/libavcodec/ffv1.c b/lib/ffmpeg/libavcodec/ffv1.c
index 0e3007fa81..4219d62e1f 100644
--- a/lib/ffmpeg/libavcodec/ffv1.c
+++ b/lib/ffmpeg/libavcodec/ffv1.c
@@ -32,10 +32,14 @@
#include "rangecoder.h"
#include "golomb.h"
#include "mathops.h"
+#include "libavutil/avassert.h"
#define MAX_PLANES 4
#define CONTEXT_SIZE 32
+#define MAX_QUANT_TABLES 8
+#define MAX_CONTEXT_INPUTS 5
+
extern const uint8_t ff_log2_run[32];
static const int8_t quant3[256]={
@@ -213,17 +217,23 @@ typedef struct VlcState{
} VlcState;
typedef struct PlaneContext{
+ int16_t quant_table[MAX_CONTEXT_INPUTS][256];
+ int quant_table_index;
int context_count;
uint8_t (*state)[CONTEXT_SIZE];
VlcState *vlc_state;
uint8_t interlace_bit_state[2];
} PlaneContext;
+#define MAX_SLICES 256
+
typedef struct FFV1Context{
AVCodecContext *avctx;
RangeCoder c;
GetBitContext gb;
PutBitContext pb;
+ uint64_t rc_stat[256][2];
+ uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2];
int version;
int width, height;
int chroma_h_shift, chroma_v_shift;
@@ -233,13 +243,28 @@ typedef struct FFV1Context{
int plane_count;
int ac; ///< 1=range coder <-> 0=golomb rice
PlaneContext plane[MAX_PLANES];
- int16_t quant_table[5][256];
+ int16_t quant_table[MAX_CONTEXT_INPUTS][256];
+ int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256];
+ int context_count[MAX_QUANT_TABLES];
uint8_t state_transition[256];
+ uint8_t (*initial_states[MAX_QUANT_TABLES])[32];
int run_index;
int colorspace;
int_fast16_t *sample_buffer;
+ int gob_count;
+
+ int quant_table_count;
DSPContext dsp;
+
+ struct FFV1Context *slice_context[MAX_SLICES];
+ int slice_count;
+ int num_v_slices;
+ int num_h_slices;
+ int slice_width;
+ int slice_height;
+ int slice_x;
+ int slice_y;
}FFV1Context;
static av_always_inline int fold(int diff, int bits){
@@ -262,24 +287,75 @@ static inline int predict(int_fast16_t *src, int_fast16_t *last){
return mid_pred(L, L + T - LT, T);
}
-static inline int get_context(FFV1Context *f, int_fast16_t *src, int_fast16_t *last, int_fast16_t *last2){
+static inline int get_context(PlaneContext *p, int_fast16_t *src, int_fast16_t *last, int_fast16_t *last2){
const int LT= last[-1];
const int T= last[ 0];
const int RT= last[ 1];
const int L = src[-1];
- if(f->quant_table[3][127]){
+ if(p->quant_table[3][127]){
const int TT= last2[0];
const int LL= src[-2];
- return f->quant_table[0][(L-LT) & 0xFF] + f->quant_table[1][(LT-T) & 0xFF] + f->quant_table[2][(T-RT) & 0xFF]
- +f->quant_table[3][(LL-L) & 0xFF] + f->quant_table[4][(TT-T) & 0xFF];
+ return p->quant_table[0][(L-LT) & 0xFF] + p->quant_table[1][(LT-T) & 0xFF] + p->quant_table[2][(T-RT) & 0xFF]
+ +p->quant_table[3][(LL-L) & 0xFF] + p->quant_table[4][(TT-T) & 0xFF];
}else
- return f->quant_table[0][(L-LT) & 0xFF] + f->quant_table[1][(LT-T) & 0xFF] + f->quant_table[2][(T-RT) & 0xFF];
+ return p->quant_table[0][(L-LT) & 0xFF] + p->quant_table[1][(LT-T) & 0xFF] + p->quant_table[2][(T-RT) & 0xFF];
}
-static inline void put_symbol_inline(RangeCoder *c, uint8_t *state, int v, int is_signed){
+static void find_best_state(uint8_t best_state[256][256], const uint8_t one_state[256]){
+ int i,j,k,m;
+ double l2tab[256];
+
+ for(i=1; i<256; i++)
+ l2tab[i]= log2(i/256.0);
+
+ for(i=0; i<256; i++){
+ double best_len[256];
+ double p= i/256.0;
+
+ for(j=0; j<256; j++)
+ best_len[j]= 1<<30;
+
+ for(j=FFMAX(i-10,1); j<FFMIN(i+11,256); j++){
+ double occ[256]={0};
+ double len=0;
+ occ[j]=1.0;
+ for(k=0; k<256; k++){
+ double newocc[256]={0};
+ for(m=0; m<256; m++){
+ if(occ[m]){
+ len -=occ[m]*( p *l2tab[ m]
+ + (1-p)*l2tab[256-m]);
+ }
+ }
+ if(len < best_len[k]){
+ best_len[k]= len;
+ best_state[i][k]= j;
+ }
+ for(m=0; m<256; m++){
+ if(occ[m]){
+ newocc[ one_state[ m]] += occ[m]* p ;
+ newocc[256-one_state[256-m]] += occ[m]*(1-p);
+ }
+ }
+ memcpy(occ, newocc, sizeof(occ));
+ }
+ }
+ }
+}
+
+static av_always_inline av_flatten void put_symbol_inline(RangeCoder *c, uint8_t *state, int v, int is_signed, uint64_t rc_stat[256][2], uint64_t rc_stat2[32][2]){
int i;
+#define put_rac(C,S,B) \
+do{\
+ if(rc_stat){\
+ rc_stat[*(S)][B]++;\
+ rc_stat2[(S)-state][B]++;\
+ }\
+ put_rac(C,S,B);\
+}while(0)
+
if(v){
const int a= FFABS(v);
const int e= av_log2(a);
@@ -312,10 +388,11 @@ static inline void put_symbol_inline(RangeCoder *c, uint8_t *state, int v, int i
}else{
put_rac(c, state+0, 1);
}
+#undef put_rac
}
static void av_noinline put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
- put_symbol_inline(c, state, v, is_signed);
+ put_symbol_inline(c, state, v, is_signed, NULL, NULL);
}
static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed){
@@ -429,7 +506,7 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state, int
}
#if CONFIG_FFV1_ENCODER
-static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
+static av_always_inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
PlaneContext * const p= &s->plane[plane_index];
RangeCoder * const c= &s->c;
int x;
@@ -452,7 +529,7 @@ static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], in
for(x=0; x<w; x++){
int diff, context;
- context= get_context(s, sample[0]+x, sample[1]+x, sample[2]+x);
+ context= get_context(p, sample[0]+x, sample[1]+x, sample[2]+x);
diff= sample[0][x] - predict(sample[0]+x, sample[1]+x);
if(context < 0){
@@ -463,7 +540,11 @@ static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], in
diff= fold(diff, bits);
if(s->ac){
- put_symbol_inline(c, p->state[context], diff, 1);
+ if(s->flags & CODEC_FLAG_PASS1){
+ put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat, s->rc_stat2[p->quant_table_index][context]);
+ }else{
+ put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL);
+ }
}else{
if(context == 0) run_mode=1;
@@ -591,31 +672,50 @@ static void write_quant_table(RangeCoder *c, int16_t *quant_table){
put_symbol(c, state, i-last-1, 0);
}
+static void write_quant_tables(RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256]){
+ int i;
+ for(i=0; i<5; i++)
+ write_quant_table(c, quant_table[i]);
+}
+
static void write_header(FFV1Context *f){
uint8_t state[CONTEXT_SIZE];
- int i;
- RangeCoder * const c= &f->c;
+ int i, j;
+ RangeCoder * const c= &f->slice_context[0]->c;
memset(state, 128, sizeof(state));
- put_symbol(c, state, f->version, 0);
- put_symbol(c, state, f->ac, 0);
- if(f->ac>1){
- for(i=1; i<256; i++){
- f->state_transition[i]=ver2_state[i];
- put_symbol(c, state, ver2_state[i] - c->one_state[i], 1);
+ if(f->version < 2){
+ put_symbol(c, state, f->version, 0);
+ put_symbol(c, state, f->ac, 0);
+ if(f->ac>1){
+ for(i=1; i<256; i++){
+ put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1);
+ }
+ }
+ put_symbol(c, state, f->colorspace, 0); //YUV cs type
+ if(f->version>0)
+ put_symbol(c, state, f->avctx->bits_per_raw_sample, 0);
+ put_rac(c, state, 1); //chroma planes
+ put_symbol(c, state, f->chroma_h_shift, 0);
+ put_symbol(c, state, f->chroma_v_shift, 0);
+ put_rac(c, state, 0); //no transparency plane
+
+ write_quant_tables(c, f->quant_table);
+ }else{
+ put_symbol(c, state, f->slice_count, 0);
+ for(i=0; i<f->slice_count; i++){
+ FFV1Context *fs= f->slice_context[i];
+ put_symbol(c, state, (fs->slice_x +1)*f->num_h_slices / f->width , 0);
+ put_symbol(c, state, (fs->slice_y +1)*f->num_v_slices / f->height , 0);
+ put_symbol(c, state, (fs->slice_width +1)*f->num_h_slices / f->width -1, 0);
+ put_symbol(c, state, (fs->slice_height+1)*f->num_v_slices / f->height-1, 0);
+ for(j=0; j<f->plane_count; j++){
+ put_symbol(c, state, f->plane[j].quant_table_index, 0);
+ av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);
+ }
}
}
- put_symbol(c, state, f->colorspace, 0); //YUV cs type
- if(f->version>0)
- put_symbol(c, state, f->avctx->bits_per_raw_sample, 0);
- put_rac(c, state, 1); //chroma planes
- put_symbol(c, state, f->chroma_h_shift, 0);
- put_symbol(c, state, f->chroma_v_shift, 0);
- put_rac(c, state, 0); //no transparency plane
-
- for(i=0; i<5; i++)
- write_quant_table(c, f->quant_table[i]);
}
#endif /* CONFIG_FFV1_ENCODER */
@@ -631,70 +731,237 @@ static av_cold int common_init(AVCodecContext *avctx){
s->height= avctx->height;
assert(s->width && s->height);
+ //defaults
+ s->num_h_slices=1;
+ s->num_v_slices=1;
- s->sample_buffer = av_malloc(6 * (s->width+6) * sizeof(*s->sample_buffer));
- if (!s->sample_buffer)
- return AVERROR(ENOMEM);
return 0;
}
+static int init_slice_state(FFV1Context *f){
+ int i, j;
+
+ for(i=0; i<f->slice_count; i++){
+ FFV1Context *fs= f->slice_context[i];
+ for(j=0; j<f->plane_count; j++){
+ PlaneContext * const p= &fs->plane[j];
+
+ if(fs->ac){
+ if(!p-> state) p-> state= av_malloc(CONTEXT_SIZE*p->context_count*sizeof(uint8_t));
+ if(!p-> state)
+ return AVERROR(ENOMEM);
+ }else{
+ if(!p->vlc_state) p->vlc_state= av_malloc(p->context_count*sizeof(VlcState));
+ if(!p->vlc_state)
+ return AVERROR(ENOMEM);
+ }
+ }
+
+ if (fs->ac>1){
+ //FIXME only redo if state_transition changed
+ for(j=1; j<256; j++){
+ fs->c.one_state [ j]= fs->state_transition[j];
+ fs->c.zero_state[256-j]= 256-fs->c.one_state [j];
+ }
+ }
+ }
+
+ return 0;
+}
+
+static av_cold int init_slice_contexts(FFV1Context *f){
+ int i;
+
+ f->slice_count= f->num_h_slices * f->num_v_slices;
+
+ for(i=0; i<f->slice_count; i++){
+ FFV1Context *fs= av_mallocz(sizeof(*fs));
+ int sx= i % f->num_h_slices;
+ int sy= i / f->num_h_slices;
+ int sxs= f->avctx->width * sx / f->num_h_slices;
+ int sxe= f->avctx->width *(sx+1) / f->num_h_slices;
+ int sys= f->avctx->height* sy / f->num_v_slices;
+ int sye= f->avctx->height*(sy+1) / f->num_v_slices;
+ f->slice_context[i]= fs;
+ memcpy(fs, f, sizeof(*fs));
+ memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2));
+
+ fs->slice_width = sxe - sxs;
+ fs->slice_height= sye - sys;
+ fs->slice_x = sxs;
+ fs->slice_y = sys;
+
+ fs->sample_buffer = av_malloc(6 * (fs->width+6) * sizeof(*fs->sample_buffer));
+ if (!fs->sample_buffer)
+ return AVERROR(ENOMEM);
+ }
+ return 0;
+}
+
+static int allocate_initial_states(FFV1Context *f){
+ int i;
+
+ for(i=0; i<f->quant_table_count; i++){
+ f->initial_states[i]= av_malloc(f->context_count[i]*sizeof(*f->initial_states[i]));
+ if(!f->initial_states[i])
+ return AVERROR(ENOMEM);
+ memset(f->initial_states[i], 128, f->context_count[i]*sizeof(*f->initial_states[i]));
+ }
+ return 0;
+}
+
#if CONFIG_FFV1_ENCODER
+static int write_extra_header(FFV1Context *f){
+ RangeCoder * const c= &f->c;
+ uint8_t state[CONTEXT_SIZE];
+ int i, j, k;
+ uint8_t state2[32][CONTEXT_SIZE];
+
+ memset(state2, 128, sizeof(state2));
+ memset(state, 128, sizeof(state));
+
+ f->avctx->extradata= av_malloc(f->avctx->extradata_size= 10000 + (11*11*5*5*5+11*11*11)*32);
+ ff_init_range_encoder(c, f->avctx->extradata, f->avctx->extradata_size);
+ ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
+
+ put_symbol(c, state, f->version, 0);
+ put_symbol(c, state, f->ac, 0);
+ if(f->ac>1){
+ for(i=1; i<256; i++){
+ put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1);
+ }
+ }
+ put_symbol(c, state, f->colorspace, 0); //YUV cs type
+ put_symbol(c, state, f->avctx->bits_per_raw_sample, 0);
+ put_rac(c, state, 1); //chroma planes
+ put_symbol(c, state, f->chroma_h_shift, 0);
+ put_symbol(c, state, f->chroma_v_shift, 0);
+ put_rac(c, state, 0); //no transparency plane
+ put_symbol(c, state, f->num_h_slices-1, 0);
+ put_symbol(c, state, f->num_v_slices-1, 0);
+
+ put_symbol(c, state, f->quant_table_count, 0);
+ for(i=0; i<f->quant_table_count; i++)
+ write_quant_tables(c, f->quant_tables[i]);
+
+ for(i=0; i<f->quant_table_count; i++){
+ for(j=0; j<f->context_count[i]*CONTEXT_SIZE; j++)
+ if(f->initial_states[i] && f->initial_states[i][0][j] != 128)
+ break;
+ if(j<f->context_count[i]*CONTEXT_SIZE){
+ put_rac(c, state, 1);
+ for(j=0; j<f->context_count[i]; j++){
+ for(k=0; k<CONTEXT_SIZE; k++){
+ int pred= j ? f->initial_states[i][j-1][k] : 128;
+ put_symbol(c, state2[k], (int8_t)(f->initial_states[i][j][k]-pred), 1);
+ }
+ }
+ }else{
+ put_rac(c, state, 0);
+ }
+ }
+
+ f->avctx->extradata_size= ff_rac_terminate(c);
+
+ return 0;
+}
+
+static int sort_stt(FFV1Context *s, uint8_t stt[256]){
+ int i,i2,changed,print=0;
+
+ do{
+ changed=0;
+ for(i=12; i<244; i++){
+ for(i2=i+1; i2<245 && i2<i+4; i2++){
+#define COST(old, new) \
+ s->rc_stat[old][0]*-log2((256-(new))/256.0)\
+ +s->rc_stat[old][1]*-log2( (new) /256.0)
+
+#define COST2(old, new) \
+ COST(old, new)\
+ +COST(256-(old), 256-(new))
+
+ double size0= COST2(i, i ) + COST2(i2, i2);
+ double sizeX= COST2(i, i2) + COST2(i2, i );
+ if(sizeX < size0 && i!=128 && i2!=128){
+ int j;
+ FFSWAP(int, stt[ i], stt[ i2]);
+ FFSWAP(int, s->rc_stat[i ][0],s->rc_stat[ i2][0]);
+ FFSWAP(int, s->rc_stat[i ][1],s->rc_stat[ i2][1]);
+ if(i != 256-i2){
+ FFSWAP(int, stt[256-i], stt[256-i2]);
+ FFSWAP(int, s->rc_stat[256-i][0],s->rc_stat[256-i2][0]);
+ FFSWAP(int, s->rc_stat[256-i][1],s->rc_stat[256-i2][1]);
+ }
+ for(j=1; j<256; j++){
+ if (stt[j] == i ) stt[j] = i2;
+ else if(stt[j] == i2) stt[j] = i ;
+ if(i != 256-i2){
+ if (stt[256-j] == 256-i ) stt[256-j] = 256-i2;
+ else if(stt[256-j] == 256-i2) stt[256-j] = 256-i ;
+ }
+ }
+ print=changed=1;
+ }
+ }
+ }
+ }while(changed);
+ return print;
+}
+
static av_cold int encode_init(AVCodecContext *avctx)
{
FFV1Context *s = avctx->priv_data;
- int i;
+ int i, j, k, m;
common_init(avctx);
s->version=0;
s->ac= avctx->coder_type ? 2:0;
+ if(s->ac>1)
+ for(i=1; i<256; i++)
+ s->state_transition[i]=ver2_state[i];
+
s->plane_count=2;
for(i=0; i<256; i++){
+ s->quant_table_count=2;
if(avctx->bits_per_raw_sample <=8){
- s->quant_table[0][i]= quant11[i];
- s->quant_table[1][i]= 11*quant11[i];
- if(avctx->context_model==0){
- s->quant_table[2][i]= 11*11*quant11[i];
- s->quant_table[3][i]=
- s->quant_table[4][i]=0;
- }else{
- s->quant_table[2][i]= 11*11*quant5 [i];
- s->quant_table[3][i]= 5*11*11*quant5 [i];
- s->quant_table[4][i]= 5*5*11*11*quant5 [i];
- }
+ s->quant_tables[0][0][i]= quant11[i];
+ s->quant_tables[0][1][i]= 11*quant11[i];
+ s->quant_tables[0][2][i]= 11*11*quant11[i];
+ s->quant_tables[1][0][i]= quant11[i];
+ s->quant_tables[1][1][i]= 11*quant11[i];
+ s->quant_tables[1][2][i]= 11*11*quant5 [i];
+ s->quant_tables[1][3][i]= 5*11*11*quant5 [i];
+ s->quant_tables[1][4][i]= 5*5*11*11*quant5 [i];
}else{
- s->quant_table[0][i]= quant9_10bit[i];
- s->quant_table[1][i]= 11*quant9_10bit[i];
- if(avctx->context_model==0){
- s->quant_table[2][i]= 11*11*quant9_10bit[i];
- s->quant_table[3][i]=
- s->quant_table[4][i]=0;
- }else{
- s->quant_table[2][i]= 11*11*quant5_10bit[i];
- s->quant_table[3][i]= 5*11*11*quant5_10bit[i];
- s->quant_table[4][i]= 5*5*11*11*quant5_10bit[i];
- }
+ s->quant_tables[0][0][i]= quant9_10bit[i];
+ s->quant_tables[0][1][i]= 11*quant9_10bit[i];
+ s->quant_tables[0][2][i]= 11*11*quant9_10bit[i];
+ s->quant_tables[1][0][i]= quant9_10bit[i];
+ s->quant_tables[1][1][i]= 11*quant9_10bit[i];
+ s->quant_tables[1][2][i]= 11*11*quant5_10bit[i];
+ s->quant_tables[1][3][i]= 5*11*11*quant5_10bit[i];
+ s->quant_tables[1][4][i]= 5*5*11*11*quant5_10bit[i];
}
}
+ s->context_count[0]= (11*11*11+1)/2;
+ s->context_count[1]= (11*11*5*5*5+1)/2;
+ memcpy(s->quant_table, s->quant_tables[avctx->context_model], sizeof(s->quant_table));
for(i=0; i<s->plane_count; i++){
PlaneContext * const p= &s->plane[i];
- if(avctx->context_model==0){
- p->context_count= (11*11*11+1)/2;
- }else{
- p->context_count= (11*11*5*5*5+1)/2;
- }
-
- if(s->ac){
- if(!p->state) p->state= av_malloc(CONTEXT_SIZE*p->context_count*sizeof(uint8_t));
- }else{
- if(!p->vlc_state) p->vlc_state= av_malloc(p->context_count*sizeof(VlcState));
- }
+ memcpy(p->quant_table, s->quant_table, sizeof(p->quant_table));
+ p->quant_table_index= avctx->context_model;
+ p->context_count= s->context_count[p->quant_table_index];
}
+ if(allocate_initial_states(s) < 0)
+ return AVERROR(ENOMEM);
+
avctx->coded_frame= &s->picture;
switch(avctx->pix_fmt){
case PIX_FMT_YUV444P16:
@@ -708,7 +975,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "bits_per_raw_sample of more than 8 needs -coder 1 currently\n");
return -1;
}
- s->version= 1;
+ s->version= FFMAX(s->version, 1);
case PIX_FMT_YUV444P:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV420P:
@@ -727,43 +994,167 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->picture_number=0;
+ if(avctx->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)){
+ for(i=0; i<s->quant_table_count; i++){
+ s->rc_stat2[i]= av_mallocz(s->context_count[i]*sizeof(*s->rc_stat2[i]));
+ if(!s->rc_stat2[i])
+ return AVERROR(ENOMEM);
+ }
+ }
+ if(avctx->stats_in){
+ char *p= avctx->stats_in;
+ uint8_t best_state[256][256];
+ int gob_count=0;
+ char *next;
+
+ av_assert0(s->version>=2);
+
+ for(;;){
+ for(j=0; j<256; j++){
+ for(i=0; i<2; i++){
+ s->rc_stat[j][i]= strtol(p, &next, 0);
+ if(next==p){
+ av_log(avctx, AV_LOG_ERROR, "2Pass file invalid at %d %d [%s]\n", j,i,p);
+ return -1;
+ }
+ p=next;
+ }
+ }
+ for(i=0; i<s->quant_table_count; i++){
+ for(j=0; j<s->context_count[i]; j++){
+ for(k=0; k<32; k++){
+ for(m=0; m<2; m++){
+ s->rc_stat2[i][j][k][m]= strtol(p, &next, 0);
+ if(next==p){
+ av_log(avctx, AV_LOG_ERROR, "2Pass file invalid at %d %d %d %d [%s]\n", i,j,k,m,p);
+ return -1;
+ }
+ p=next;
+ }
+ }
+ }
+ }
+ gob_count= strtol(p, &next, 0);
+ if(next==p || gob_count <0){
+ av_log(avctx, AV_LOG_ERROR, "2Pass file invalid\n");
+ return -1;
+ }
+ p=next;
+ while(*p=='\n' || *p==' ') p++;
+ if(p[0]==0) break;
+ }
+ sort_stt(s, s->state_transition);
+
+ find_best_state(best_state, s->state_transition);
+
+ for(i=0; i<s->quant_table_count; i++){
+ for(j=0; j<s->context_count[i]; j++){
+ for(k=0; k<32; k++){
+ double p= 128;
+ if(s->rc_stat2[i][j][k][0]+s->rc_stat2[i][j][k][1]){
+ p=256.0*s->rc_stat2[i][j][k][1] / (s->rc_stat2[i][j][k][0]+s->rc_stat2[i][j][k][1]);
+ }
+ s->initial_states[i][j][k]= best_state[av_clip(round(p), 1, 255)][av_clip((s->rc_stat2[i][j][k][0]+s->rc_stat2[i][j][k][1])/gob_count, 0, 255)];
+ }
+ }
+ }
+ }
+
+ if(s->version>1){
+ s->num_h_slices=2;
+ s->num_v_slices=2;
+ write_extra_header(s);
+ }
+
+ if(init_slice_contexts(s) < 0)
+ return -1;
+ if(init_slice_state(s) < 0)
+ return -1;
+
+#define STATS_OUT_SIZE 1024*1024*6
+ if(avctx->flags & CODEC_FLAG_PASS1){
+ avctx->stats_out= av_mallocz(STATS_OUT_SIZE);
+ for(i=0; i<s->quant_table_count; i++){
+ for(j=0; j<s->slice_count; j++){
+ FFV1Context *sf= s->slice_context[j];
+ av_assert0(!sf->rc_stat2[i]);
+ sf->rc_stat2[i]= av_mallocz(s->context_count[i]*sizeof(*sf->rc_stat2[i]));
+ if(!sf->rc_stat2[i])
+ return AVERROR(ENOMEM);
+ }
+ }
+ }
+
return 0;
}
#endif /* CONFIG_FFV1_ENCODER */
static void clear_state(FFV1Context *f){
- int i, j;
+ int i, si, j;
- for(i=0; i<f->plane_count; i++){
- PlaneContext *p= &f->plane[i];
+ for(si=0; si<f->slice_count; si++){
+ FFV1Context *fs= f->slice_context[si];
+ for(i=0; i<f->plane_count; i++){
+ PlaneContext *p= &fs->plane[i];
- p->interlace_bit_state[0]= 128;
- p->interlace_bit_state[1]= 128;
+ p->interlace_bit_state[0]= 128;
+ p->interlace_bit_state[1]= 128;
- for(j=0; j<p->context_count; j++){
- if(f->ac){
- memset(p->state[j], 128, sizeof(uint8_t)*CONTEXT_SIZE);
+ if(fs->ac){
+ if(f->initial_states[p->quant_table_index]){
+ memcpy(p->state, f->initial_states[p->quant_table_index], CONTEXT_SIZE*p->context_count);
+ }else
+ memset(p->state, 128, CONTEXT_SIZE*p->context_count);
}else{
- p->vlc_state[j].drift= 0;
- p->vlc_state[j].error_sum= 4; //FFMAX((RANGE + 32)/64, 2);
- p->vlc_state[j].bias= 0;
- p->vlc_state[j].count= 1;
+ for(j=0; j<p->context_count; j++){
+ p->vlc_state[j].drift= 0;
+ p->vlc_state[j].error_sum= 4; //FFMAX((RANGE + 32)/64, 2);
+ p->vlc_state[j].bias= 0;
+ p->vlc_state[j].count= 1;
+ }
}
}
}
}
#if CONFIG_FFV1_ENCODER
+static int encode_slice(AVCodecContext *c, void *arg){
+ FFV1Context *fs= *(void**)arg;
+ FFV1Context *f= fs->avctx->priv_data;
+ int width = fs->slice_width;
+ int height= fs->slice_height;
+ int x= fs->slice_x;
+ int y= fs->slice_y;
+ AVFrame * const p= &f->picture;
+
+ if(f->colorspace==0){
+ const int chroma_width = -((-width )>>f->chroma_h_shift);
+ const int chroma_height= -((-height)>>f->chroma_v_shift);
+ const int cx= x>>f->chroma_h_shift;
+ const int cy= y>>f->chroma_v_shift;
+
+ encode_plane(fs, p->data[0] + x + y*p->linesize[0], width, height, p->linesize[0], 0);
+
+ encode_plane(fs, p->data[1] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
+ encode_plane(fs, p->data[2] + cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1);
+ }else{
+ encode_rgb_frame(fs, (uint32_t*)(p->data[0]) + x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4);
+ }
+ emms_c();
+
+ return 0;
+}
+
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
FFV1Context *f = avctx->priv_data;
- RangeCoder * const c= &f->c;
+ RangeCoder * const c= &f->slice_context[0]->c;
AVFrame *pict = data;
- const int width= f->width;
- const int height= f->height;
AVFrame * const p= &f->picture;
int used_count= 0;
uint8_t keystate=128;
+ uint8_t *buf_p;
+ int i;
ff_init_range_encoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
@@ -774,6 +1165,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
if(avctx->gop_size==0 || f->picture_number % avctx->gop_size == 0){
put_rac(c, &keystate, 1);
p->key_frame= 1;
+ f->gob_count++;
write_header(f);
clear_state(f);
}else{
@@ -784,7 +1176,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
if(!f->ac){
used_count += ff_rac_terminate(c);
//printf("pos=%d\n", used_count);
- init_put_bits(&f->pb, buf + used_count, buf_size - used_count);
+ init_put_bits(&f->slice_context[0]->pb, buf + used_count, buf_size - used_count);
}else if (f->ac>1){
int i;
for(i=1; i<256; i++){
@@ -793,42 +1185,122 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
}
}
- if(f->colorspace==0){
- const int chroma_width = -((-width )>>f->chroma_h_shift);
- const int chroma_height= -((-height)>>f->chroma_v_shift);
-
- encode_plane(f, p->data[0], width, height, p->linesize[0], 0);
+ for(i=1; i<f->slice_count; i++){
+ FFV1Context *fs= f->slice_context[i];
+ uint8_t *start= buf + (buf_size-used_count)*i/f->slice_count;
+ int len= buf_size/f->slice_count;
- encode_plane(f, p->data[1], chroma_width, chroma_height, p->linesize[1], 1);
- encode_plane(f, p->data[2], chroma_width, chroma_height, p->linesize[2], 1);
- }else{
- encode_rgb_frame(f, (uint32_t*)(p->data[0]), width, height, p->linesize[0]/4);
+ if(fs->ac){
+ ff_init_range_encoder(&fs->c, start, len);
+ }else{
+ init_put_bits(&fs->pb, start, len);
+ }
}
- emms_c();
+ avctx->execute(avctx, encode_slice, &f->slice_context[0], NULL, f->slice_count, sizeof(void*));
- f->picture_number++;
+ buf_p=buf;
+ for(i=0; i<f->slice_count; i++){
+ FFV1Context *fs= f->slice_context[i];
+ int bytes;
- if(f->ac){
- return ff_rac_terminate(c);
- }else{
- flush_put_bits(&f->pb); //nicer padding FIXME
- return used_count + (put_bits_count(&f->pb)+7)/8;
+ if(fs->ac){
+ uint8_t state=128;
+ put_rac(&fs->c, &state, 0);
+ bytes= ff_rac_terminate(&fs->c);
+ }else{
+ flush_put_bits(&fs->pb); //nicer padding FIXME
+ bytes= used_count + (put_bits_count(&fs->pb)+7)/8;
+ used_count= 0;
+ }
+ if(i>0){
+ av_assert0(bytes < buf_size/f->slice_count);
+ memmove(buf_p, fs->ac ? fs->c.bytestream_start : fs->pb.buf, bytes);
+ av_assert0(bytes < (1<<24));
+ AV_WB24(buf_p+bytes, bytes);
+ bytes+=3;
+ }
+ buf_p += bytes;
}
+
+ if((avctx->flags&CODEC_FLAG_PASS1) && (f->picture_number&31)==0){
+ int j, k, m;
+ char *p= avctx->stats_out;
+ char *end= p + STATS_OUT_SIZE;
+
+ memset(f->rc_stat, 0, sizeof(f->rc_stat));
+ for(i=0; i<f->quant_table_count; i++)
+ memset(f->rc_stat2[i], 0, f->context_count[i]*sizeof(*f->rc_stat2[i]));
+
+ for(j=0; j<f->slice_count; j++){
+ FFV1Context *fs= f->slice_context[j];
+ for(i=0; i<256; i++){
+ f->rc_stat[i][0] += fs->rc_stat[i][0];
+ f->rc_stat[i][1] += fs->rc_stat[i][1];
+ }
+ for(i=0; i<f->quant_table_count; i++){
+ for(k=0; k<f->context_count[i]; k++){
+ for(m=0; m<32; m++){
+ f->rc_stat2[i][k][m][0] += fs->rc_stat2[i][k][m][0];
+ f->rc_stat2[i][k][m][1] += fs->rc_stat2[i][k][m][1];
+ }
+ }
+ }
+ }
+
+ for(j=0; j<256; j++){
+ snprintf(p, end-p, "%"PRIu64" %"PRIu64" ", f->rc_stat[j][0], f->rc_stat[j][1]);
+ p+= strlen(p);
+ }
+ snprintf(p, end-p, "\n");
+
+ for(i=0; i<f->quant_table_count; i++){
+ for(j=0; j<f->context_count[i]; j++){
+ for(m=0; m<32; m++){
+ snprintf(p, end-p, "%"PRIu64" %"PRIu64" ", f->rc_stat2[i][j][m][0], f->rc_stat2[i][j][m][1]);
+ p+= strlen(p);
+ }
+ }
+ }
+ snprintf(p, end-p, "%d\n", f->gob_count);
+ } else if(avctx->flags&CODEC_FLAG_PASS1)
+ avctx->stats_out[0] = '\0';
+
+ f->picture_number++;
+ return buf_p-buf;
}
#endif /* CONFIG_FFV1_ENCODER */
static av_cold int common_end(AVCodecContext *avctx){
FFV1Context *s = avctx->priv_data;
- int i;
+ int i, j;
- for(i=0; i<s->plane_count; i++){
- PlaneContext *p= &s->plane[i];
+ if (avctx->codec->decode && s->picture.data[0])
+ avctx->release_buffer(avctx, &s->picture);
+
+ for(j=0; j<s->slice_count; j++){
+ FFV1Context *fs= s->slice_context[j];
+ for(i=0; i<s->plane_count; i++){
+ PlaneContext *p= &fs->plane[i];
- av_freep(&p->state);
- av_freep(&p->vlc_state);
+ av_freep(&p->state);
+ av_freep(&p->vlc_state);
+ }
+ av_freep(&fs->sample_buffer);
}
- av_freep(&s->sample_buffer);
+ av_freep(&avctx->stats_out);
+ for(j=0; j<s->quant_table_count; j++){
+ av_freep(&s->initial_states[j]);
+ for(i=0; i<s->slice_count; i++){
+ FFV1Context *sf= s->slice_context[i];
+ av_freep(&sf->rc_stat2[j]);
+ }
+ av_freep(&s->rc_stat2[j]);
+ }
+
+ for(i=0; i<s->slice_count; i++){
+ av_freep(&s->slice_context[i]);
+ }
return 0;
}
@@ -844,13 +1316,14 @@ static av_always_inline void decode_line(FFV1Context *s, int w, int_fast16_t *sa
for(x=0; x<w; x++){
int diff, context, sign;
- context= get_context(s, sample[1] + x, sample[0] + x, sample[1] + x);
+ context= get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
if(context < 0){
context= -context;
sign=1;
}else
sign=0;
+ av_assert2(context < p->context_count);
if(s->ac){
diff= get_symbol_inline(c, p->state[context], 1);
@@ -967,6 +1440,34 @@ static void decode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int st
}
}
+static int decode_slice(AVCodecContext *c, void *arg){
+ FFV1Context *fs= *(void**)arg;
+ FFV1Context *f= fs->avctx->priv_data;
+ int width = fs->slice_width;
+ int height= fs->slice_height;
+ int x= fs->slice_x;
+ int y= fs->slice_y;
+ AVFrame * const p= &f->picture;
+
+ av_assert1(width && height);
+ if(f->colorspace==0){
+ const int chroma_width = -((-width )>>f->chroma_h_shift);
+ const int chroma_height= -((-height)>>f->chroma_v_shift);
+ const int cx= x>>f->chroma_h_shift;
+ const int cy= y>>f->chroma_v_shift;
+ decode_plane(fs, p->data[0] + x + y*p->linesize[0], width, height, p->linesize[0], 0);
+
+ decode_plane(fs, p->data[1] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1);
+ decode_plane(fs, p->data[2] + cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[2], 1);
+ }else{
+ decode_rgb_frame(fs, (uint32_t*)p->data[0] + x + y*(p->linesize[0]/4), width, height, p->linesize[0]/4);
+ }
+
+ emms_c();
+
+ return 0;
+}
+
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale){
int v;
int i=0;
@@ -995,13 +1496,31 @@ static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale){
return 2*v - 1;
}
-static int read_header(FFV1Context *f){
- uint8_t state[CONTEXT_SIZE];
- int i, context_count;
+static int read_quant_tables(RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256]){
+ int i;
+ int context_count=1;
+
+ for(i=0; i<5; i++){
+ context_count*= read_quant_table(c, quant_table[i], context_count);
+ if(context_count > 32768U){
+ return -1;
+ }
+ }
+ return (context_count+1)/2;
+}
+
+static int read_extra_header(FFV1Context *f){
RangeCoder * const c= &f->c;
+ uint8_t state[CONTEXT_SIZE];
+ int i, j, k;
+ uint8_t state2[32][CONTEXT_SIZE];
+ memset(state2, 128, sizeof(state2));
memset(state, 128, sizeof(state));
+ ff_init_range_decoder(c, f->avctx->extradata, f->avctx->extradata_size);
+ ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
+
f->version= get_symbol(c, state, 0);
f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
if(f->ac>1){
@@ -1010,13 +1529,70 @@ static int read_header(FFV1Context *f){
}
}
f->colorspace= get_symbol(c, state, 0); //YUV cs type
- if(f->version>0)
- f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
+ f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
get_rac(c, state); //no chroma = false
f->chroma_h_shift= get_symbol(c, state, 0);
f->chroma_v_shift= get_symbol(c, state, 0);
get_rac(c, state); //transparency plane
f->plane_count= 2;
+ f->num_h_slices= 1 + get_symbol(c, state, 0);
+ f->num_v_slices= 1 + get_symbol(c, state, 0);
+ if(f->num_h_slices > (unsigned)f->width || f->num_v_slices > (unsigned)f->height){
+ av_log(f->avctx, AV_LOG_ERROR, "too many slices\n");
+ return -1;
+ }
+
+ f->quant_table_count= get_symbol(c, state, 0);
+ if(f->quant_table_count > (unsigned)MAX_QUANT_TABLES)
+ return -1;
+ for(i=0; i<f->quant_table_count; i++){
+ if((f->context_count[i]= read_quant_tables(c, f->quant_tables[i])) < 0){
+ av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
+ return -1;
+ }
+ }
+
+ if(allocate_initial_states(f) < 0)
+ return AVERROR(ENOMEM);
+
+ for(i=0; i<f->quant_table_count; i++){
+ if(get_rac(c, state)){
+ for(j=0; j<f->context_count[i]; j++){
+ for(k=0; k<CONTEXT_SIZE; k++){
+ int pred= j ? f->initial_states[i][j-1][k] : 128;
+ f->initial_states[i][j][k]= (pred+get_symbol(c, state2[k], 1))&0xFF;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int read_header(FFV1Context *f){
+ uint8_t state[CONTEXT_SIZE];
+ int i, j, context_count;
+ RangeCoder * const c= &f->slice_context[0]->c;
+
+ memset(state, 128, sizeof(state));
+
+ if(f->version < 2){
+ f->version= get_symbol(c, state, 0);
+ f->ac= f->avctx->coder_type= get_symbol(c, state, 0);
+ if(f->ac>1){
+ for(i=1; i<256; i++){
+ f->state_transition[i]= get_symbol(c, state, 1) + c->one_state[i];
+ }
+ }
+ f->colorspace= get_symbol(c, state, 0); //YUV cs type
+ if(f->version>0)
+ f->avctx->bits_per_raw_sample= get_symbol(c, state, 0);
+ get_rac(c, state); //no chroma = false
+ f->chroma_h_shift= get_symbol(c, state, 0);
+ f->chroma_v_shift= get_symbol(c, state, 0);
+ get_rac(c, state); //transparency plane
+ f->plane_count= 2;
+ }
if(f->colorspace==0){
if(f->avctx->bits_per_raw_sample<=8){
@@ -1052,26 +1628,60 @@ static int read_header(FFV1Context *f){
}
//printf("%d %d %d\n", f->chroma_h_shift, f->chroma_v_shift,f->avctx->pix_fmt);
-
- context_count=1;
- for(i=0; i<5; i++){
- context_count*= read_quant_table(c, f->quant_table[i], context_count);
- if(context_count < 0 || context_count > 32768){
- av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
- return -1;
+ if(f->version < 2){
+ context_count= read_quant_tables(c, f->quant_table);
+ if(context_count < 0){
+ av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
+ return -1;
}
+ }else{
+ f->slice_count= get_symbol(c, state, 0);
+ if(f->slice_count > (unsigned)MAX_SLICES)
+ return -1;
}
- context_count= (context_count+1)/2;
- for(i=0; i<f->plane_count; i++){
- PlaneContext * const p= &f->plane[i];
+ for(j=0; j<f->slice_count; j++){
+ FFV1Context *fs= f->slice_context[j];
+ fs->ac= f->ac;
+
+ if(f->version >= 2){
+ fs->slice_x = get_symbol(c, state, 0) *f->width ;
+ fs->slice_y = get_symbol(c, state, 0) *f->height;
+ fs->slice_width =(get_symbol(c, state, 0)+1)*f->width + fs->slice_x;
+ fs->slice_height=(get_symbol(c, state, 0)+1)*f->height + fs->slice_y;
+
+ fs->slice_x /= f->num_h_slices;
+ fs->slice_y /= f->num_v_slices;
+ fs->slice_width = fs->slice_width /f->num_h_slices - fs->slice_x;
+ fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y;
+ if((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height)
+ return -1;
+ if( (unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width
+ || (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
+ return -1;
+ }
- p->context_count= context_count;
+ for(i=0; i<f->plane_count; i++){
+ PlaneContext * const p= &fs->plane[i];
- if(f->ac){
- if(!p->state) p->state= av_malloc(CONTEXT_SIZE*p->context_count*sizeof(uint8_t));
- }else{
- if(!p->vlc_state) p->vlc_state= av_malloc(p->context_count*sizeof(VlcState));
+ if(f->version >= 2){
+ int idx=get_symbol(c, state, 0);
+ if(idx > (unsigned)f->quant_table_count){
+ av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
+ return -1;
+ }
+ p->quant_table_index= idx;
+ memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table));
+ context_count= f->context_count[idx];
+ }else{
+ memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table));
+ }
+
+ if(p->context_count < context_count){
+ av_freep(&p->state);
+ av_freep(&p->vlc_state);
+ }
+ p->context_count= context_count;
}
}
@@ -1080,10 +1690,16 @@ static int read_header(FFV1Context *f){
static av_cold int decode_init(AVCodecContext *avctx)
{
-// FFV1Context *s = avctx->priv_data;
+ FFV1Context *f = avctx->priv_data;
common_init(avctx);
+ if(avctx->extradata && read_extra_header(f) < 0)
+ return -1;
+
+ if(init_slice_contexts(f) < 0)
+ return -1;
+
return 0;
}
@@ -1091,15 +1707,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
FFV1Context *f = avctx->priv_data;
- RangeCoder * const c= &f->c;
- const int width= f->width;
- const int height= f->height;
+ RangeCoder * const c= &f->slice_context[0]->c;
AVFrame * const p= &f->picture;
- int bytes_read;
+ int bytes_read, i;
uint8_t keystate= 128;
+ const uint8_t *buf_p;
AVFrame *picture = data;
+ /* release previously stored data */
+ if (p->data[0])
+ avctx->release_buffer(avctx, p);
+
ff_init_range_decoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
@@ -1109,6 +1728,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
p->key_frame= 1;
if(read_header(f) < 0)
return -1;
+ if(init_slice_state(f) < 0)
+ return -1;
+
clear_state(f);
}else{
p->key_frame= 0;
@@ -1121,9 +1743,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
}
}
- if(!f->plane[0].state && !f->plane[0].vlc_state)
- return -1;
-
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
@@ -1137,43 +1756,37 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
bytes_read = c->bytestream - c->bytestream_start - 1;
if(bytes_read ==0) av_log(avctx, AV_LOG_ERROR, "error at end of AC stream\n"); //FIXME
//printf("pos=%d\n", bytes_read);
- init_get_bits(&f->gb, buf + bytes_read, buf_size - bytes_read);
+ init_get_bits(&f->slice_context[0]->gb, buf + bytes_read, buf_size - bytes_read);
} else {
bytes_read = 0; /* avoid warning */
}
- if(f->colorspace==0){
- const int chroma_width = -((-width )>>f->chroma_h_shift);
- const int chroma_height= -((-height)>>f->chroma_v_shift);
- decode_plane(f, p->data[0], width, height, p->linesize[0], 0);
-
- decode_plane(f, p->data[1], chroma_width, chroma_height, p->linesize[1], 1);
- decode_plane(f, p->data[2], chroma_width, chroma_height, p->linesize[2], 1);
- }else{
- decode_rgb_frame(f, (uint32_t*)p->data[0], width, height, p->linesize[0]/4);
+ buf_p= buf + buf_size;
+ for(i=f->slice_count-1; i>0; i--){
+ FFV1Context *fs= f->slice_context[i];
+ int v= AV_RB24(buf_p-3)+3;
+ if(buf_p - buf <= v){
+ av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n");
+ return -1;
+ }
+ buf_p -= v;
+ if(fs->ac){
+ ff_init_range_decoder(&fs->c, buf_p, v);
+ }else{
+ init_get_bits(&fs->gb, buf_p, v);
+ }
}
- emms_c();
-
+ avctx->execute(avctx, decode_slice, &f->slice_context[0], NULL, f->slice_count, sizeof(void*));
f->picture_number++;
*picture= *p;
-
- avctx->release_buffer(avctx, p); //FIXME
-
*data_size = sizeof(AVFrame);
- if(f->ac){
- bytes_read= c->bytestream - c->bytestream_start - 1;
- if(bytes_read ==0) av_log(f->avctx, AV_LOG_ERROR, "error at end of frame\n");
- }else{
- bytes_read+= (get_bits_count(&f->gb)+7)/8;
- }
-
- return bytes_read;
+ return buf_size;
}
-AVCodec ffv1_decoder = {
+AVCodec ff_ffv1_decoder = {
"ffv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FFV1,
@@ -1188,7 +1801,7 @@ AVCodec ffv1_decoder = {
};
#if CONFIG_FFV1_ENCODER
-AVCodec ffv1_encoder = {
+AVCodec ff_ffv1_encoder = {
"ffv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FFV1,
diff --git a/lib/ffmpeg/libavcodec/flac.c b/lib/ffmpeg/libavcodec/flac.c
index a649e08732..484a44efb3 100644
--- a/lib/ffmpeg/libavcodec/flac.c
+++ b/lib/ffmpeg/libavcodec/flac.c
@@ -19,7 +19,115 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/crc.h"
#include "flac.h"
+#include "flacdata.h"
+
+static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 };
+
+static int64_t get_utf8(GetBitContext *gb)
+{
+ int64_t val;
+ GET_UTF8(val, get_bits(gb, 8), return -1;)
+ return val;
+}
+
+int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
+ FLACFrameInfo *fi, int log_level_offset)
+{
+ int bs_code, sr_code, bps_code;
+
+ /* frame sync code */
+ if ((get_bits(gb, 15) & 0x7FFF) != 0x7FFC) {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid sync code\n");
+ return -1;
+ }
+
+ /* variable block size stream code */
+ fi->is_var_size = get_bits1(gb);
+
+ /* block size and sample rate codes */
+ bs_code = get_bits(gb, 4);
+ sr_code = get_bits(gb, 4);
+
+ /* channels and decorrelation */
+ fi->ch_mode = get_bits(gb, 4);
+ if (fi->ch_mode < FLAC_MAX_CHANNELS) {
+ fi->channels = fi->ch_mode + 1;
+ fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
+ } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
+ fi->channels = 2;
+ } else {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "invalid channel mode: %d\n", fi->ch_mode);
+ return -1;
+ }
+
+ /* bits per sample */
+ bps_code = get_bits(gb, 3);
+ if (bps_code == 3 || bps_code == 7) {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "invalid sample size code (%d)\n",
+ bps_code);
+ return -1;
+ }
+ fi->bps = sample_size_table[bps_code];
+
+ /* reserved bit */
+ if (get_bits1(gb)) {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "broken stream, invalid padding\n");
+ return -1;
+ }
+
+ /* sample or frame count */
+ fi->frame_or_sample_num = get_utf8(gb);
+ if (fi->frame_or_sample_num < 0) {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "sample/frame number invalid; utf8 fscked\n");
+ return -1;
+ }
+
+ /* blocksize */
+ if (bs_code == 0) {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "reserved blocksize code: 0\n");
+ return -1;
+ } else if (bs_code == 6) {
+ fi->blocksize = get_bits(gb, 8) + 1;
+ } else if (bs_code == 7) {
+ fi->blocksize = get_bits(gb, 16) + 1;
+ } else {
+ fi->blocksize = ff_flac_blocksize_table[bs_code];
+ }
+
+ /* sample rate */
+ if (sr_code < 12) {
+ fi->samplerate = ff_flac_sample_rate_table[sr_code];
+ } else if (sr_code == 12) {
+ fi->samplerate = get_bits(gb, 8) * 1000;
+ } else if (sr_code == 13) {
+ fi->samplerate = get_bits(gb, 16);
+ } else if (sr_code == 14) {
+ fi->samplerate = get_bits(gb, 16) * 10;
+ } else {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "illegal sample rate code %d\n",
+ sr_code);
+ return -1;
+ }
+
+ /* header CRC-8 check */
+ skip_bits(gb, 8);
+ if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
+ get_bits_count(gb)/8)) {
+ av_log(avctx, AV_LOG_ERROR + log_level_offset,
+ "header crc mismatch\n");
+ return -1;
+ }
+
+ return 0;
+}
int ff_flac_get_max_frame_size(int blocksize, int ch, int bps)
{
diff --git a/lib/ffmpeg/libavcodec/flac.h b/lib/ffmpeg/libavcodec/flac.h
index 1b114635ec..fcd80996dc 100644
--- a/lib/ffmpeg/libavcodec/flac.h
+++ b/lib/ffmpeg/libavcodec/flac.h
@@ -28,11 +28,13 @@
#define AVCODEC_FLAC_H
#include "avcodec.h"
+#include "get_bits.h"
#define FLAC_STREAMINFO_SIZE 34
#define FLAC_MAX_CHANNELS 8
#define FLAC_MIN_BLOCKSIZE 16
#define FLAC_MAX_BLOCKSIZE 65535
+#define FLAC_MIN_FRAME_SIZE 11
enum {
FLAC_CHMODE_INDEPENDENT = 0,
@@ -80,6 +82,11 @@ typedef struct FLACFrameInfo {
FLACCOMMONINFO
int blocksize; /**< block size of the frame */
int ch_mode; /**< channel decorrelation mode */
+ int64_t frame_or_sample_num; /**< frame number or sample number */
+ int is_var_size; /**< specifies if the stream uses variable
+ block sizes or a fixed block size;
+ also determines the meaning of
+ frame_or_sample_num */
} FLACFrameInfo;
/**
@@ -120,4 +127,14 @@ void ff_flac_parse_block_header(const uint8_t *block_header,
*/
int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
+/**
+ * Validate and decode a frame header.
+ * @param avctx AVCodecContext to use as av_log() context
+ * @param gb GetBitContext from which to read frame header
+ * @param[out] fi frame information
+ * @param log_level_offset log level offset. can be used to silence error messages.
+ * @return non-zero on error, 0 if ok
+ */
+int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
+ FLACFrameInfo *fi, int log_level_offset);
#endif /* AVCODEC_FLAC_H */
diff --git a/lib/ffmpeg/libavcodec/flac_parser.c b/lib/ffmpeg/libavcodec/flac_parser.c
new file mode 100644
index 0000000000..50ad72b7c0
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/flac_parser.c
@@ -0,0 +1,682 @@
+/*
+ * FLAC parser
+ * Copyright (c) 2010 Michael Chinen
+ *
+ * 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
+ * FLAC parser
+ *
+ * The FLAC parser buffers input until FLAC_MIN_HEADERS has been found.
+ * Each time it finds and verifies a CRC-8 header it sees which of the
+ * FLAC_MAX_SEQUENTIAL_HEADERS that came before it have a valid CRC-16 footer
+ * that ends at the newly found header.
+ * Headers are scored by FLAC_HEADER_BASE_SCORE plus the max of it's crc-verified
+ * children, penalized by changes in sample rate, frame number, etc.
+ * The parser returns the frame with the highest score.
+ **/
+
+#include "libavutil/crc.h"
+#include "libavutil/fifo.h"
+#include "bytestream.h"
+#include "parser.h"
+#include "flac.h"
+
+/** maximum number of adjacent headers that compare CRCs against each other */
+#define FLAC_MAX_SEQUENTIAL_HEADERS 3
+/** minimum number of headers buffered and checked before returning frames */
+#define FLAC_MIN_HEADERS 10
+/** estimate for average size of a FLAC frame */
+#define FLAC_AVG_FRAME_SIZE 8192
+
+/** scoring settings for score_header */
+#define FLAC_HEADER_BASE_SCORE 10
+#define FLAC_HEADER_CHANGED_PENALTY 7
+#define FLAC_HEADER_CRC_FAIL_PENALTY 50
+#define FLAC_HEADER_NOT_PENALIZED_YET 100000
+#define FLAC_HEADER_NOT_SCORED_YET -100000
+
+/** largest possible size of flac header */
+#define MAX_FRAME_HEADER_SIZE 16
+
+typedef struct FLACHeaderMarker {
+ int offset; /**< byte offset from start of FLACParseContext->buffer */
+ int *link_penalty; /**< pointer to array of local scores between this header
+ and the one at a distance equal array position */
+ int max_score; /**< maximum score found after checking each child that
+ has a valid CRC */
+ FLACFrameInfo fi; /**< decoded frame header info */
+ struct FLACHeaderMarker *next; /**< next CRC-8 verified header that
+ immediately follows this one in
+ the bytestream */
+ struct FLACHeaderMarker *best_child; /**< following frame header with
+ which this frame has the best
+ score with */
+} FLACHeaderMarker;
+
+typedef struct FLACParseContext {
+ AVCodecContext *avctx; /**< codec context pointer for logging */
+ FLACHeaderMarker *headers; /**< linked-list that starts at the first
+ CRC-8 verified header within buffer */
+ FLACHeaderMarker *best_header; /**< highest scoring header within buffer */
+ int nb_headers_found; /**< number of headers found in the last
+ flac_parse() call */
+ int nb_headers_buffered; /**< number of headers that are buffered */
+ int best_header_valid; /**< flag set when the parser returns junk;
+ if set return best_header next time */
+ AVFifoBuffer *fifo_buf; /**< buffer to store all data until headers
+ can be verified */
+ int end_padded; /**< specifies if fifo_buf's end is padded */
+ uint8_t *wrap_buf; /**< general fifo read buffer when wrapped */
+ int wrap_buf_allocated_size; /**< actual allocated size of the buffer */
+} FLACParseContext;
+
+static int frame_header_is_valid(AVCodecContext *avctx, const uint8_t *buf,
+ FLACFrameInfo *fi)
+{
+ GetBitContext gb;
+ init_get_bits(&gb, buf, MAX_FRAME_HEADER_SIZE * 8);
+ return !ff_flac_decode_frame_header(avctx, &gb, fi, 127);
+}
+
+/**
+ * Non-destructive fast fifo pointer fetching
+ * Returns a pointer from the specified offset.
+ * If possible the pointer points within the fifo buffer.
+ * Otherwise (if it would cause a wrap around,) a pointer to a user-specified
+ * buffer is used.
+ * The pointer can be NULL. In any case it will be reallocated to hold the size.
+ * If the returned pointer will be used after subsequent calls to flac_fifo_read_wrap
+ * then the subsequent calls should pass in a different wrap_buf so as to not
+ * overwrite the contents of the previous wrap_buf.
+ * This function is based on av_fifo_generic_read, which is why there is a comment
+ * about a memory barrier for SMP.
+ */
+static uint8_t* flac_fifo_read_wrap(FLACParseContext *fpc, int offset, int len,
+ uint8_t** wrap_buf, int* allocated_size)
+{
+ AVFifoBuffer *f = fpc->fifo_buf;
+ uint8_t *start = f->rptr + offset;
+ uint8_t *tmp_buf;
+
+ if (start >= f->end)
+ start -= f->end - f->buffer;
+ if (f->end - start >= len)
+ return start;
+
+ tmp_buf = av_fast_realloc(*wrap_buf, allocated_size, len);
+
+ if (!tmp_buf) {
+ av_log(fpc->avctx, AV_LOG_ERROR,
+ "couldn't reallocate wrap buffer of size %d", len);
+ return NULL;
+ }
+ *wrap_buf = tmp_buf;
+ do {
+ int seg_len = FFMIN(f->end - start, len);
+ memcpy(tmp_buf, start, seg_len);
+ tmp_buf = (uint8_t*)tmp_buf + seg_len;
+// memory barrier needed for SMP here in theory
+
+ start += seg_len - (f->end - f->buffer);
+ len -= seg_len;
+ } while (len > 0);
+
+ return *wrap_buf;
+}
+
+/**
+ * Return a pointer in the fifo buffer where the offset starts at until
+ * the wrap point or end of request.
+ * len will contain the valid length of the returned buffer.
+ * A second call to flac_fifo_read (with new offset and len) should be called
+ * to get the post-wrap buf if the returned len is less than the requested.
+ **/
+static uint8_t* flac_fifo_read(FLACParseContext *fpc, int offset, int *len)
+{
+ AVFifoBuffer *f = fpc->fifo_buf;
+ uint8_t *start = f->rptr + offset;
+
+ if (start >= f->end)
+ start -= f->end - f->buffer;
+ *len = FFMIN(*len, f->end - start);
+ return start;
+}
+
+static int find_headers_search_validate(FLACParseContext *fpc, int offset)
+{
+ FLACFrameInfo fi;
+ uint8_t *header_buf;
+ int size = 0;
+ header_buf = flac_fifo_read_wrap(fpc, offset,
+ MAX_FRAME_HEADER_SIZE,
+ &fpc->wrap_buf,
+ &fpc->wrap_buf_allocated_size);
+ if (frame_header_is_valid(fpc->avctx, header_buf, &fi)) {
+ FLACHeaderMarker **end_handle = &fpc->headers;
+ int i;
+
+ size = 0;
+ while (*end_handle) {
+ end_handle = &(*end_handle)->next;
+ size++;
+ }
+
+ *end_handle = av_mallocz(sizeof(FLACHeaderMarker));
+ if (!*end_handle) {
+ av_log(fpc->avctx, AV_LOG_ERROR,
+ "couldn't allocate FLACHeaderMarker\n");
+ return AVERROR(ENOMEM);
+ }
+ (*end_handle)->fi = fi;
+ (*end_handle)->offset = offset;
+ (*end_handle)->link_penalty = av_malloc(sizeof(int) *
+ FLAC_MAX_SEQUENTIAL_HEADERS);
+ for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS; i++)
+ (*end_handle)->link_penalty[i] = FLAC_HEADER_NOT_PENALIZED_YET;
+
+ fpc->nb_headers_found++;
+ size++;
+ }
+ return size;
+}
+
+static int find_headers_search(FLACParseContext *fpc, uint8_t *buf, int buf_size,
+ int search_start)
+
+{
+ int size = 0, mod_offset = (buf_size - 1) % 4, i, j;
+ uint32_t x;
+
+ for (i = 0; i < mod_offset; i++) {
+ if ((AV_RB16(buf + i) & 0xFFFE) == 0xFFF8)
+ size = find_headers_search_validate(fpc, search_start + i);
+ }
+
+ for (; i < buf_size - 1; i += 4) {
+ x = AV_RB32(buf + i);
+ if (((x & ~(x + 0x01010101)) & 0x80808080)) {
+ for (j = 0; j < 4; j++) {
+ if ((AV_RB16(buf + i + j) & 0xFFFE) == 0xFFF8)
+ size = find_headers_search_validate(fpc, search_start + i + j);
+ }
+ }
+ }
+ return size;
+}
+
+static int find_new_headers(FLACParseContext *fpc, int search_start)
+{
+ FLACHeaderMarker *end;
+ int search_end, size = 0, read_len, temp;
+ uint8_t *buf;
+ fpc->nb_headers_found = 0;
+
+ /* Search for a new header of at most 16 bytes. */
+ search_end = av_fifo_size(fpc->fifo_buf) - (MAX_FRAME_HEADER_SIZE - 1);
+ read_len = search_end - search_start + 1;
+ buf = flac_fifo_read(fpc, search_start, &read_len);
+ size = find_headers_search(fpc, buf, read_len, search_start);
+ search_start += read_len - 1;
+
+ /* If fifo end was hit do the wrap around. */
+ if (search_start != search_end) {
+ uint8_t wrap[2];
+
+ wrap[0] = buf[read_len - 1];
+ read_len = search_end - search_start + 1;
+
+ /* search_start + 1 is the post-wrap offset in the fifo. */
+ buf = flac_fifo_read(fpc, search_start + 1, &read_len);
+ wrap[1] = buf[0];
+
+ if ((AV_RB16(wrap) & 0xFFFE) == 0xFFF8) {
+ temp = find_headers_search_validate(fpc, search_start);
+ size = FFMAX(size, temp);
+ }
+ search_start++;
+
+ /* Continue to do the last half of the wrap. */
+ temp = find_headers_search(fpc, buf, read_len, search_start);
+ size = FFMAX(size, temp);
+ search_start += read_len - 1;
+ }
+
+ /* Return the size even if no new headers were found. */
+ if (!size && fpc->headers)
+ for (end = fpc->headers; end; end = end->next)
+ size++;
+ return size;
+}
+
+static int check_header_mismatch(FLACParseContext *fpc,
+ FLACHeaderMarker *header,
+ FLACHeaderMarker *child,
+ int log_level_offset)
+{
+ FLACFrameInfo *header_fi = &header->fi, *child_fi = &child->fi;
+ int deduction = 0, deduction_expected = 0, i;
+ if (child_fi->samplerate != header_fi->samplerate) {
+ deduction += FLAC_HEADER_CHANGED_PENALTY;
+ av_log(fpc->avctx, AV_LOG_WARNING + log_level_offset,
+ "sample rate change detected in adjacent frames\n");
+ }
+ if (child_fi->bps != header_fi->bps) {
+ deduction += FLAC_HEADER_CHANGED_PENALTY;
+ av_log(fpc->avctx, AV_LOG_WARNING + log_level_offset,
+ "bits per sample change detected in adjacent frames\n");
+ }
+ if (child_fi->is_var_size != header_fi->is_var_size) {
+ /* Changing blocking strategy not allowed per the spec */
+ deduction += FLAC_HEADER_BASE_SCORE;
+ av_log(fpc->avctx, AV_LOG_WARNING + log_level_offset,
+ "blocking strategy change detected in adjacent frames\n");
+ }
+ if (child_fi->channels != header_fi->channels) {
+ deduction += FLAC_HEADER_CHANGED_PENALTY;
+ av_log(fpc->avctx, AV_LOG_WARNING + log_level_offset,
+ "number of channels change detected in adjacent frames\n");
+ }
+ /* Check sample and frame numbers. */
+ if ((child_fi->frame_or_sample_num - header_fi->frame_or_sample_num
+ != header_fi->blocksize) &&
+ (child_fi->frame_or_sample_num
+ != header_fi->frame_or_sample_num + 1)) {
+ FLACHeaderMarker *curr;
+ int expected_frame_num, expected_sample_num;
+ /* If there are frames in the middle we expect this deduction,
+ as they are probably valid and this one follows it */
+
+ expected_frame_num = expected_sample_num = header_fi->frame_or_sample_num;
+ curr = header;
+ while (curr != child) {
+ /* Ignore frames that failed all crc checks */
+ for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS; i++) {
+ if (curr->link_penalty[i] < FLAC_HEADER_CRC_FAIL_PENALTY) {
+ expected_frame_num++;
+ expected_sample_num += curr->fi.blocksize;
+ break;
+ }
+ }
+ curr = curr->next;
+ }
+
+ if (expected_frame_num == child_fi->frame_or_sample_num ||
+ expected_sample_num == child_fi->frame_or_sample_num)
+ deduction_expected = deduction ? 0 : 1;
+
+ deduction += FLAC_HEADER_CHANGED_PENALTY;
+ av_log(fpc->avctx, AV_LOG_WARNING + log_level_offset,
+ "sample/frame number mismatch in adjacent frames\n");
+ }
+
+ /* If we have suspicious headers, check the CRC between them */
+ if (deduction && !deduction_expected) {
+ FLACHeaderMarker *curr;
+ int read_len;
+ uint8_t *buf;
+ uint32_t crc = 1;
+ int inverted_test = 0;
+
+ /* Since CRC is expensive only do it if we haven't yet.
+ This assumes a CRC penalty is greater than all other check penalties */
+ curr = header->next;
+ for (i = 0; i < FLAC_MAX_SEQUENTIAL_HEADERS && curr != child; i++)
+ curr = curr->next;
+
+ if (header->link_penalty[i] < FLAC_HEADER_CRC_FAIL_PENALTY ||
+ header->link_penalty[i] == FLAC_HEADER_NOT_PENALIZED_YET) {
+ FLACHeaderMarker *start, *end;
+
+ /* Although overlapping chains are scored, the crc should never
+ have to be computed twice for a single byte. */
+ start = header;
+ end = child;
+ if (i > 0 &&
+ header->link_penalty[i - 1] >= FLAC_HEADER_CRC_FAIL_PENALTY) {
+ while (start->next != child)
+ start = start->next;
+ inverted_test = 1;
+ } else if (i > 0 &&
+ header->next->link_penalty[i-1] >=
+ FLAC_HEADER_CRC_FAIL_PENALTY ) {
+ end = header->next;
+ inverted_test = 1;
+ }
+
+ read_len = end->offset - start->offset;
+ buf = flac_fifo_read(fpc, start->offset, &read_len);
+ crc = av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf, read_len);
+ read_len = (end->offset - start->offset) - read_len;
+
+ if (read_len) {
+ buf = flac_fifo_read(fpc, end->offset - read_len, &read_len);
+ crc = av_crc(av_crc_get_table(AV_CRC_16_ANSI), crc, buf, read_len);
+ }
+ }
+
+ if (!crc ^ !inverted_test) {
+ deduction += FLAC_HEADER_CRC_FAIL_PENALTY;
+ av_log(fpc->avctx, AV_LOG_WARNING + log_level_offset,
+ "crc check failed from offset %i (frame %"PRId64") to %i (frame %"PRId64")\n",
+ header->offset, header_fi->frame_or_sample_num,
+ child->offset, child_fi->frame_or_sample_num);
+ }
+ }
+ return deduction;
+}
+
+/**
+ * Score a header.
+ *
+ * Give FLAC_HEADER_BASE_SCORE points to a frame for existing.
+ * If it has children, (subsequent frames of which the preceding CRC footer
+ * validates against this one,) then take the maximum score of the children,
+ * with a penalty of FLAC_HEADER_CHANGED_PENALTY applied for each change to
+ * bps, sample rate, channels, but not decorrelation mode, or blocksize,
+ * because it can change often.
+ **/
+static int score_header(FLACParseContext *fpc, FLACHeaderMarker *header)
+{
+ FLACHeaderMarker *child;
+ int dist = 0;
+ int child_score;
+
+ if (header->max_score != FLAC_HEADER_NOT_SCORED_YET)
+ return header->max_score;
+
+ header->max_score = FLAC_HEADER_BASE_SCORE;
+
+ /* Check and compute the children's scores. */
+ child = header->next;
+ for (dist = 0; dist < FLAC_MAX_SEQUENTIAL_HEADERS && child; dist++) {
+ /* Look at the child's frame header info and penalize suspicious
+ changes between the headers. */
+ if (header->link_penalty[dist] == FLAC_HEADER_NOT_PENALIZED_YET) {
+ header->link_penalty[dist] = check_header_mismatch(fpc, header,
+ child, AV_LOG_DEBUG);
+ }
+ child_score = score_header(fpc, child) - header->link_penalty[dist];
+
+ if (FLAC_HEADER_BASE_SCORE + child_score > header->max_score) {
+ /* Keep the child because the frame scoring is dynamic. */
+ header->best_child = child;
+ header->max_score = FLAC_HEADER_BASE_SCORE + child_score;
+ }
+ child = child->next;
+ }
+
+ return header->max_score;
+}
+
+static void score_sequences(FLACParseContext *fpc)
+{
+ FLACHeaderMarker *curr;
+ int best_score = FLAC_HEADER_NOT_SCORED_YET;
+ /* First pass to clear all old scores. */
+ for (curr = fpc->headers; curr; curr = curr->next)
+ curr->max_score = FLAC_HEADER_NOT_SCORED_YET;
+
+ /* Do a second pass to score them all. */
+ for (curr = fpc->headers; curr; curr = curr->next) {
+ if (score_header(fpc, curr) > best_score) {
+ fpc->best_header = curr;
+ best_score = curr->max_score;
+ }
+ }
+}
+
+static int get_best_header(FLACParseContext* fpc, const uint8_t **poutbuf,
+ int *poutbuf_size)
+{
+ FLACHeaderMarker *header = fpc->best_header;
+ FLACHeaderMarker *child = header->best_child;
+ if (!child) {
+ *poutbuf_size = av_fifo_size(fpc->fifo_buf) - header->offset;
+ } else {
+ *poutbuf_size = child->offset - header->offset;
+
+ /* If the child has suspicious changes, log them */
+ check_header_mismatch(fpc, header, child, 0);
+ }
+
+ fpc->avctx->sample_rate = header->fi.samplerate;
+ fpc->avctx->channels = header->fi.channels;
+ fpc->avctx->frame_size = header->fi.blocksize;
+ *poutbuf = flac_fifo_read_wrap(fpc, header->offset, *poutbuf_size,
+ &fpc->wrap_buf,
+ &fpc->wrap_buf_allocated_size);
+
+ fpc->best_header_valid = 0;
+ /* Return the negative overread index so the client can compute pos.
+ This should be the amount overread to the beginning of the child */
+ if (child)
+ return child->offset - av_fifo_size(fpc->fifo_buf);
+ return 0;
+}
+
+static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+ FLACParseContext *fpc = s->priv_data;
+ FLACHeaderMarker *curr;
+ int nb_headers;
+ const uint8_t *read_end = buf;
+ const uint8_t *read_start = buf;
+
+ if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+ FLACFrameInfo fi;
+ if (frame_header_is_valid(avctx, buf, &fi))
+ avctx->frame_size = fi.blocksize;
+ *poutbuf = buf;
+ *poutbuf_size = buf_size;
+ return buf_size;
+ }
+
+ fpc->avctx = avctx;
+ if (fpc->best_header_valid)
+ return get_best_header(fpc, poutbuf, poutbuf_size);
+
+ /* If a best_header was found last call remove it with the buffer data. */
+ if (fpc->best_header && fpc->best_header->best_child) {
+ FLACHeaderMarker *temp;
+ FLACHeaderMarker *best_child = fpc->best_header->best_child;
+
+ /* Remove headers in list until the end of the best_header. */
+ for (curr = fpc->headers; curr != best_child; curr = temp) {
+ if (curr != fpc->best_header) {
+ av_log(avctx, AV_LOG_DEBUG,
+ "dropping low score %i frame header from offset %i to %i\n",
+ curr->max_score, curr->offset, curr->next->offset);
+ }
+ temp = curr->next;
+ av_freep(&curr->link_penalty);
+ av_free(curr);
+ fpc->nb_headers_buffered--;
+ }
+ /* Release returned data from ring buffer. */
+ av_fifo_drain(fpc->fifo_buf, best_child->offset);
+
+ /* Fix the offset for the headers remaining to match the new buffer. */
+ for (curr = best_child->next; curr; curr = curr->next)
+ curr->offset -= best_child->offset;
+
+ fpc->nb_headers_buffered--;
+ best_child->offset = 0;
+ fpc->headers = best_child;
+ if (fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) {
+ fpc->best_header = best_child;
+ return get_best_header(fpc, poutbuf, poutbuf_size);
+ }
+ fpc->best_header = NULL;
+ } else if (fpc->best_header) {
+ /* No end frame no need to delete the buffer; probably eof */
+ FLACHeaderMarker *temp;
+
+ for (curr = fpc->headers; curr != fpc->best_header; curr = temp) {
+ temp = curr->next;
+ av_freep(&curr->link_penalty);
+ av_free(curr);
+ }
+ fpc->headers = fpc->best_header->next;
+ av_freep(&fpc->best_header->link_penalty);
+ av_freep(&fpc->best_header);
+ }
+
+ /* Find and score new headers. */
+ while ((buf && read_end < buf + buf_size &&
+ fpc->nb_headers_buffered < FLAC_MIN_HEADERS)
+ || (!buf && !fpc->end_padded)) {
+ int start_offset;
+
+ /* Pad the end once if EOF, to check the final region for headers. */
+ if (!buf) {
+ fpc->end_padded = 1;
+ buf_size = MAX_FRAME_HEADER_SIZE;
+ read_end = read_start + MAX_FRAME_HEADER_SIZE;
+ } else {
+ /* The maximum read size is the upper-bound of what the parser
+ needs to have the required number of frames buffered */
+ int nb_desired = FLAC_MIN_HEADERS - fpc->nb_headers_buffered + 1;
+ read_end = read_end + FFMIN(buf + buf_size - read_end,
+ nb_desired * FLAC_AVG_FRAME_SIZE);
+ }
+
+ /* Fill the buffer. */
+ if (av_fifo_realloc2(fpc->fifo_buf,
+ (read_end - read_start) + av_fifo_size(fpc->fifo_buf)) < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "couldn't reallocate buffer of size %td\n",
+ (read_end - read_start) + av_fifo_size(fpc->fifo_buf));
+ goto handle_error;
+ }
+
+ if (buf) {
+ av_fifo_generic_write(fpc->fifo_buf, (void*) read_start,
+ read_end - read_start, NULL);
+ } else {
+ int8_t pad[MAX_FRAME_HEADER_SIZE];
+ memset(pad, 0, sizeof(pad));
+ av_fifo_generic_write(fpc->fifo_buf, (void*) pad, sizeof(pad), NULL);
+ }
+
+ /* Tag headers and update sequences. */
+ start_offset = av_fifo_size(fpc->fifo_buf) -
+ ((read_end - read_start) + (MAX_FRAME_HEADER_SIZE - 1));
+ start_offset = FFMAX(0, start_offset);
+ nb_headers = find_new_headers(fpc, start_offset);
+
+ if (nb_headers < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "find_new_headers couldn't allocate FLAC header\n");
+ goto handle_error;
+ }
+
+ fpc->nb_headers_buffered = nb_headers;
+ /* Wait till FLAC_MIN_HEADERS to output a valid frame. */
+ if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) {
+ if (buf && read_end < buf + buf_size) {
+ read_start = read_end;
+ continue;
+ } else {
+ goto handle_error;
+ }
+ }
+
+ /* If headers found, update the scores since we have longer chains. */
+ if (fpc->end_padded || fpc->nb_headers_found)
+ score_sequences(fpc);
+
+ /* restore the state pre-padding */
+ if (fpc->end_padded) {
+ /* HACK: drain the tail of the fifo */
+ fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;
+ fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;
+ if (fpc->fifo_buf->wptr < 0) {
+ fpc->fifo_buf->wptr += fpc->fifo_buf->end -
+ fpc->fifo_buf->buffer;
+ }
+ buf_size = 0;
+ read_start = read_end = NULL;
+ }
+ }
+
+ curr = fpc->headers;
+ for (curr = fpc->headers; curr; curr = curr->next)
+ if (!fpc->best_header || curr->max_score > fpc->best_header->max_score)
+ fpc->best_header = curr;
+
+ if (fpc->best_header) {
+ fpc->best_header_valid = 1;
+ if (fpc->best_header->offset > 0) {
+ /* Output a junk frame. */
+ av_log(avctx, AV_LOG_DEBUG, "Junk frame till offset %i\n",
+ fpc->best_header->offset);
+
+ /* Set frame_size to 0. It is unknown or invalid in a junk frame. */
+ avctx->frame_size = 0;
+ *poutbuf_size = fpc->best_header->offset;
+ *poutbuf = flac_fifo_read_wrap(fpc, 0, *poutbuf_size,
+ &fpc->wrap_buf,
+ &fpc->wrap_buf_allocated_size);
+ return buf_size ? (read_end - buf) : (fpc->best_header->offset -
+ av_fifo_size(fpc->fifo_buf));
+ }
+ if (!buf_size)
+ return get_best_header(fpc, poutbuf, poutbuf_size);
+ }
+
+handle_error:
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return read_end - buf;
+}
+
+static int flac_parse_init(AVCodecParserContext *c)
+{
+ FLACParseContext *fpc = c->priv_data;
+ /* There will generally be FLAC_MIN_HEADERS buffered in the fifo before
+ it drains. This is allocated early to avoid slow reallocation. */
+ fpc->fifo_buf = av_fifo_alloc(FLAC_AVG_FRAME_SIZE * (FLAC_MIN_HEADERS + 3));
+ return 0;
+}
+
+static void flac_parse_close(AVCodecParserContext *c)
+{
+ FLACParseContext *fpc = c->priv_data;
+ FLACHeaderMarker *curr = fpc->headers, *temp;
+
+ while (curr) {
+ temp = curr->next;
+ av_freep(&curr->link_penalty);
+ av_free(curr);
+ curr = temp;
+ }
+ av_fifo_free(fpc->fifo_buf);
+ av_free(fpc->wrap_buf);
+}
+
+AVCodecParser ff_flac_parser = {
+ { CODEC_ID_FLAC },
+ sizeof(FLACParseContext),
+ flac_parse_init,
+ flac_parse,
+ flac_parse_close,
+};
diff --git a/lib/ffmpeg/libavcodec/flacdec.c b/lib/ffmpeg/libavcodec/flacdec.c
index 07acf6e81b..ece095cf09 100644
--- a/lib/ffmpeg/libavcodec/flacdec.c
+++ b/lib/ffmpeg/libavcodec/flacdec.c
@@ -61,22 +61,8 @@ typedef struct FLACContext {
int got_streaminfo; ///< indicates if the STREAMINFO has been read
int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
- uint8_t *bitstream;
- unsigned int bitstream_size;
- unsigned int bitstream_index;
- unsigned int allocated_bitstream_size;
} FLACContext;
-static const int sample_size_table[] =
-{ 0, 8, 12, 0, 16, 20, 24, 0 };
-
-static int64_t get_utf8(GetBitContext *gb)
-{
- int64_t val;
- GET_UTF8(val, get_bits(gb, 8), return -1;)
- return val;
-}
-
static void allocate_buffers(FLACContext *s);
int ff_flac_is_extradata_valid(AVCodecContext *avctx,
@@ -113,7 +99,7 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
FLACContext *s = avctx->priv_data;
s->avctx = avctx;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
/* for now, the raw FLAC header is allowed to be passed to the decoder as
frame data instead of extradata. */
@@ -126,9 +112,9 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
/* initialize based on the demuxer-supplied streamdata header */
ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
if (s->bps > 16)
- avctx->sample_fmt = SAMPLE_FMT_S32;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32;
else
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
allocate_buffers(s);
s->got_streaminfo = 1;
@@ -150,20 +136,10 @@ static void allocate_buffers(FLACContext *s)
assert(s->max_blocksize);
- if (s->max_framesize == 0 && s->max_blocksize) {
- s->max_framesize = ff_flac_get_max_frame_size(s->max_blocksize,
- s->channels, s->bps);
- }
-
for (i = 0; i < s->channels; i++) {
s->decoded[i] = av_realloc(s->decoded[i],
sizeof(int32_t)*s->max_blocksize);
}
-
- if (s->allocated_bitstream_size < s->max_framesize)
- s->bitstream= av_fast_realloc(s->bitstream,
- &s->allocated_bitstream_size,
- s->max_framesize);
}
void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
@@ -480,129 +456,50 @@ static inline int decode_subframe(FLACContext *s, int channel)
return 0;
}
-/**
- * Validate and decode a frame header.
- * @param avctx AVCodecContext to use as av_log() context
- * @param gb GetBitContext from which to read frame header
- * @param[out] fi frame information
- * @return non-zero on error, 0 if ok
- */
-static int decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
- FLACFrameInfo *fi)
-{
- int bs_code, sr_code, bps_code;
-
- /* frame sync code */
- skip_bits(gb, 16);
-
- /* block size and sample rate codes */
- bs_code = get_bits(gb, 4);
- sr_code = get_bits(gb, 4);
-
- /* channels and decorrelation */
- fi->ch_mode = get_bits(gb, 4);
- if (fi->ch_mode < FLAC_MAX_CHANNELS) {
- fi->channels = fi->ch_mode + 1;
- fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
- } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
- fi->channels = 2;
- } else {
- av_log(avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", fi->ch_mode);
- return -1;
- }
-
- /* bits per sample */
- bps_code = get_bits(gb, 3);
- if (bps_code == 3 || bps_code == 7) {
- av_log(avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
- bps_code);
- return -1;
- }
- fi->bps = sample_size_table[bps_code];
-
- /* reserved bit */
- if (get_bits1(gb)) {
- av_log(avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
- return -1;
- }
-
- /* sample or frame count */
- if (get_utf8(gb) < 0) {
- av_log(avctx, AV_LOG_ERROR, "utf8 fscked\n");
- return -1;
- }
-
- /* blocksize */
- if (bs_code == 0) {
- av_log(avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
- return -1;
- } else if (bs_code == 6) {
- fi->blocksize = get_bits(gb, 8) + 1;
- } else if (bs_code == 7) {
- fi->blocksize = get_bits(gb, 16) + 1;
- } else {
- fi->blocksize = ff_flac_blocksize_table[bs_code];
- }
-
- /* sample rate */
- if (sr_code < 12) {
- fi->samplerate = ff_flac_sample_rate_table[sr_code];
- } else if (sr_code == 12) {
- fi->samplerate = get_bits(gb, 8) * 1000;
- } else if (sr_code == 13) {
- fi->samplerate = get_bits(gb, 16);
- } else if (sr_code == 14) {
- fi->samplerate = get_bits(gb, 16) * 10;
- } else {
- av_log(avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
- sr_code);
- return -1;
- }
-
- /* header CRC-8 check */
- skip_bits(gb, 8);
- if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
- get_bits_count(gb)/8)) {
- av_log(avctx, AV_LOG_ERROR, "header crc mismatch\n");
- return -1;
- }
-
- return 0;
-}
-
static int decode_frame(FLACContext *s)
{
int i;
GetBitContext *gb = &s->gb;
FLACFrameInfo fi;
- if (decode_frame_header(s->avctx, gb, &fi)) {
+ if (ff_flac_decode_frame_header(s->avctx, gb, &fi, 0)) {
av_log(s->avctx, AV_LOG_ERROR, "invalid frame header\n");
return -1;
}
- if (fi.channels != s->channels) {
+ if (s->channels && fi.channels != s->channels) {
av_log(s->avctx, AV_LOG_ERROR, "switching channel layout mid-stream "
"is not supported\n");
return -1;
}
+ s->channels = s->avctx->channels = fi.channels;
s->ch_mode = fi.ch_mode;
- if (fi.bps && fi.bps != s->bps) {
+ if (!s->bps && !fi.bps) {
+ av_log(s->avctx, AV_LOG_ERROR, "bps not found in STREAMINFO or frame header\n");
+ return -1;
+ }
+ if (!fi.bps) {
+ fi.bps = s->bps;
+ } else if (s->bps && fi.bps != s->bps) {
av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not "
"supported\n");
return -1;
}
+ s->bps = s->avctx->bits_per_raw_sample = fi.bps;
+
if (s->bps > 16) {
- s->avctx->sample_fmt = SAMPLE_FMT_S32;
+ s->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
s->sample_shift = 32 - s->bps;
s->is32 = 1;
} else {
- s->avctx->sample_fmt = SAMPLE_FMT_S16;
+ s->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
s->sample_shift = 16 - s->bps;
s->is32 = 0;
}
+ if (!s->max_blocksize)
+ s->max_blocksize = FLAC_MAX_BLOCKSIZE;
if (fi.blocksize > s->max_blocksize) {
av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", fi.blocksize,
s->max_blocksize);
@@ -610,14 +507,25 @@ static int decode_frame(FLACContext *s)
}
s->blocksize = fi.blocksize;
+ if (!s->samplerate && !fi.samplerate) {
+ av_log(s->avctx, AV_LOG_ERROR, "sample rate not found in STREAMINFO"
+ " or frame header\n");
+ return -1;
+ }
if (fi.samplerate == 0) {
fi.samplerate = s->samplerate;
- } else if (fi.samplerate != s->samplerate) {
+ } else if (s->samplerate && fi.samplerate != s->samplerate) {
av_log(s->avctx, AV_LOG_WARNING, "sample rate changed from %d to %d\n",
s->samplerate, fi.samplerate);
}
s->samplerate = s->avctx->sample_rate = fi.samplerate;
+ if (!s->got_streaminfo) {
+ allocate_buffers(s);
+ s->got_streaminfo = 1;
+ dump_headers(s->avctx, (FLACStreaminfo *)s);
+ }
+
// dump_headers(s->avctx, (FLACStreaminfo *)s);
/* subframes */
@@ -641,7 +549,7 @@ static int flac_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
FLACContext *s = avctx->priv_data;
- int i, j = 0, input_buf_size = 0, bytes_read = 0;
+ int i, j = 0, bytes_read = 0;
int16_t *samples_16 = data;
int32_t *samples_32 = data;
int alloc_data_size= *data_size;
@@ -650,42 +558,16 @@ static int flac_decode_frame(AVCodecContext *avctx,
*data_size=0;
if (s->max_framesize == 0) {
- s->max_framesize= FFMAX(4, buf_size); // should hopefully be enough for the first header
- s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
- }
-
- if (1 && s->max_framesize) { //FIXME truncated
- if (s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
- buf_size= FFMIN(buf_size, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
- input_buf_size= buf_size;
-
- if (s->bitstream_size + buf_size < buf_size || s->bitstream_index + s->bitstream_size + buf_size < s->bitstream_index)
- return -1;
-
- if (s->allocated_bitstream_size < s->bitstream_size + buf_size)
- s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + buf_size);
-
- if (s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size) {
- memmove(s->bitstream, &s->bitstream[s->bitstream_index],
- s->bitstream_size);
- s->bitstream_index=0;
- }
- memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size],
- buf, buf_size);
- buf= &s->bitstream[s->bitstream_index];
- buf_size += s->bitstream_size;
- s->bitstream_size= buf_size;
-
- if (buf_size < s->max_framesize && input_buf_size) {
- return input_buf_size;
- }
+ s->max_framesize =
+ ff_flac_get_max_frame_size(s->max_blocksize ? s->max_blocksize : FLAC_MAX_BLOCKSIZE,
+ FLAC_MAX_CHANNELS, 32);
}
/* check that there is at least the smallest decodable amount of data.
this amount corresponds to the smallest valid FLAC frame possible.
FF F8 69 02 00 00 9A 00 00 34 46 */
- if (buf_size < 11)
- goto end;
+ if (buf_size < FLAC_MIN_FRAME_SIZE)
+ return buf_size;
/* check for inline header */
if (AV_RB32(buf) == MKBETAG('f','L','a','C')) {
@@ -693,26 +575,13 @@ static int flac_decode_frame(AVCodecContext *avctx,
av_log(s->avctx, AV_LOG_ERROR, "invalid header\n");
return -1;
}
- bytes_read = get_metadata_size(buf, buf_size);
- goto end;
- }
-
- /* check for frame sync code and resync stream if necessary */
- if ((AV_RB16(buf) & 0xFFFE) != 0xFFF8) {
- const uint8_t *buf_end = buf + buf_size;
- av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
- while (buf+2 < buf_end && (AV_RB16(buf) & 0xFFFE) != 0xFFF8)
- buf++;
- bytes_read = buf_size - (buf_end - buf);
- goto end; // we may not have enough bits left to decode a frame, so try next time
+ return get_metadata_size(buf, buf_size);
}
/* decode frame */
init_get_bits(&s->gb, buf, buf_size*8);
if (decode_frame(s) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
- s->bitstream_size=0;
- s->bitstream_index=0;
return -1;
}
bytes_read = (get_bits_count(&s->gb)+7)/8;
@@ -722,7 +591,7 @@ static int flac_decode_frame(AVCodecContext *avctx,
if (output_size > alloc_data_size) {
av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than "
"allocated data size\n");
- goto end;
+ return -1;
}
*data_size = output_size;
@@ -760,20 +629,16 @@ static int flac_decode_frame(AVCodecContext *avctx,
DECORRELATE( (a-=b>>1) + b, a)
}
-end:
if (bytes_read > buf_size) {
av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", bytes_read - buf_size);
- s->bitstream_size=0;
- s->bitstream_index=0;
return -1;
}
+ if (bytes_read < buf_size) {
+ av_log(s->avctx, AV_LOG_DEBUG, "underread: %d orig size: %d\n",
+ buf_size - bytes_read, buf_size);
+ }
- if (s->bitstream_size) {
- s->bitstream_index += bytes_read;
- s->bitstream_size -= bytes_read;
- return input_buf_size;
- } else
- return bytes_read;
+ return bytes_read;
}
static av_cold int flac_decode_close(AVCodecContext *avctx)
@@ -784,20 +649,11 @@ static av_cold int flac_decode_close(AVCodecContext *avctx)
for (i = 0; i < s->channels; i++) {
av_freep(&s->decoded[i]);
}
- av_freep(&s->bitstream);
return 0;
}
-static void flac_flush(AVCodecContext *avctx)
-{
- FLACContext *s = avctx->priv_data;
-
- s->bitstream_size=
- s->bitstream_index= 0;
-}
-
-AVCodec flac_decoder = {
+AVCodec ff_flac_decoder = {
"flac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_FLAC,
@@ -806,9 +662,5 @@ AVCodec flac_decoder = {
NULL,
flac_decode_close,
flac_decode_frame,
- CODEC_CAP_DELAY | CODEC_CAP_SUBFRAMES, /* FIXME: add a FLAC parser so that
- we will not need to use either
- of these capabilities */
- .flush= flac_flush,
.long_name= NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
};
diff --git a/lib/ffmpeg/libavcodec/flacenc.c b/lib/ffmpeg/libavcodec/flacenc.c
index d87d5d7c21..7c814700b1 100644
--- a/lib/ffmpeg/libavcodec/flacenc.c
+++ b/lib/ffmpeg/libavcodec/flacenc.c
@@ -23,7 +23,6 @@
#include "libavutil/md5.h"
#include "avcodec.h"
#include "get_bits.h"
-#include "dsputil.h"
#include "golomb.h"
#include "lpc.h"
#include "flac.h"
@@ -77,6 +76,7 @@ typedef struct FlacFrame {
int bs_code[2];
uint8_t crc8;
int ch_mode;
+ int verbatim_only;
} FlacFrame;
typedef struct FlacEncodeContext {
@@ -94,12 +94,13 @@ typedef struct FlacEncodeContext {
FlacFrame frame;
CompressionOptions options;
AVCodecContext *avctx;
- DSPContext dsp;
+ LPCContext lpc_ctx;
struct AVMD5 *md5ctx;
} FlacEncodeContext;
+
/**
- * Write streaminfo metadata block to byte array
+ * Write streaminfo metadata block to byte array.
*/
static void write_streaminfo(FlacEncodeContext *s, uint8_t *header)
{
@@ -123,9 +124,10 @@ static void write_streaminfo(FlacEncodeContext *s, uint8_t *header)
memcpy(&header[18], s->md5sum, 16);
}
+
/**
- * Set blocksize based on samplerate
- * Choose the closest predefined blocksize >= 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)
{
@@ -135,41 +137,97 @@ static int select_blocksize(int samplerate, int block_time_ms)
assert(samplerate > 0);
blocksize = ff_flac_blocksize_table[1];
- target = (samplerate * block_time_ms) / 1000;
- for(i=0; i<16; i++) {
- if(target >= ff_flac_blocksize_table[i] && ff_flac_blocksize_table[i] > blocksize) {
+ target = (samplerate * block_time_ms) / 1000;
+ for (i = 0; i < 16; i++) {
+ if (target >= ff_flac_blocksize_table[i] &&
+ ff_flac_blocksize_table[i] > blocksize) {
blocksize = ff_flac_blocksize_table[i];
}
}
return blocksize;
}
+
+static av_cold void dprint_compression_options(FlacEncodeContext *s)
+{
+ AVCodecContext *avctx = s->avctx;
+ CompressionOptions *opt = &s->options;
+
+ av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);
+
+ switch (opt->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",
+ opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");
+ break;
+ }
+
+ av_log(avctx, AV_LOG_DEBUG, " prediction order: %d, %d\n",
+ opt->min_prediction_order, opt->max_prediction_order);
+
+ switch (opt->prediction_order_method) {
+ case ORDER_METHOD_EST:
+ av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", "estimate");
+ break;
+ case ORDER_METHOD_2LEVEL:
+ av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", "2-level");
+ break;
+ case ORDER_METHOD_4LEVEL:
+ av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", "4-level");
+ break;
+ case ORDER_METHOD_8LEVEL:
+ av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", "8-level");
+ break;
+ case ORDER_METHOD_SEARCH:
+ av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", "full search");
+ break;
+ case ORDER_METHOD_LOG:
+ av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", "log search");
+ break;
+ }
+
+
+ av_log(avctx, AV_LOG_DEBUG, " partition order: %d, %d\n",
+ opt->min_partition_order, opt->max_partition_order);
+
+ av_log(avctx, AV_LOG_DEBUG, " block size: %d\n", avctx->frame_size);
+
+ av_log(avctx, AV_LOG_DEBUG, " lpc precision: %d\n",
+ opt->lpc_coeff_precision);
+}
+
+
static av_cold int flac_encode_init(AVCodecContext *avctx)
{
int freq = avctx->sample_rate;
int channels = avctx->channels;
FlacEncodeContext *s = avctx->priv_data;
- int i, level;
+ int i, level, ret;
uint8_t *streaminfo;
s->avctx = avctx;
- dsputil_init(&s->dsp, avctx);
-
- if(avctx->sample_fmt != SAMPLE_FMT_S16) {
+ if (avctx->sample_fmt != AV_SAMPLE_FMT_S16)
return -1;
- }
- if(channels < 1 || channels > FLAC_MAX_CHANNELS) {
+ if (channels < 1 || channels > FLAC_MAX_CHANNELS)
return -1;
- }
s->channels = channels;
/* find samplerate in table */
- if(freq < 1)
+ if (freq < 1)
return -1;
- for(i=4; i<12; i++) {
- if(freq == ff_flac_sample_rate_table[i]) {
+ for (i = 4; i < 12; i++) {
+ if (freq == ff_flac_sample_rate_table[i]) {
s->samplerate = ff_flac_sample_rate_table[i];
s->sr_code[0] = i;
s->sr_code[1] = 0;
@@ -177,14 +235,14 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
}
}
/* if not in table, samplerate is non-standard */
- if(i == 12) {
- if(freq % 1000 == 0 && freq < 255000) {
+ if (i == 12) {
+ if (freq % 1000 == 0 && freq < 255000) {
s->sr_code[0] = 12;
s->sr_code[1] = freq / 1000;
- } else if(freq % 10 == 0 && freq < 655350) {
+ } else if (freq % 10 == 0 && freq < 655350) {
s->sr_code[0] = 14;
s->sr_code[1] = freq / 10;
- } else if(freq < 65535) {
+ } else if (freq < 65535) {
s->sr_code[0] = 13;
s->sr_code[1] = freq;
} else {
@@ -194,38 +252,40 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
}
/* set compression option defaults based on avctx->compression_level */
- if(avctx->compression_level < 0) {
+ if (avctx->compression_level < 0)
s->options.compression_level = 5;
- } else {
+ else
s->options.compression_level = avctx->compression_level;
- }
- av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", s->options.compression_level);
- level= s->options.compression_level;
- if(level > 12) {
+ level = s->options.compression_level;
+ if (level > 12) {
av_log(avctx, AV_LOG_ERROR, "invalid compression level: %d\n",
s->options.compression_level);
return -1;
}
- s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[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.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[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,
ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
ORDER_METHOD_SEARCH})[level];
+
s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
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 LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_USE_LPC
/* for compatibility with deprecated AVCodecContext.use_lpc */
if (avctx->use_lpc == 0) {
s->options.lpc_type = AV_LPC_TYPE_FIXED;
@@ -255,33 +315,18 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
}
}
}
- 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) {
+ 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) {
+ } 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;
@@ -292,7 +337,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
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) {
+ 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;
@@ -305,63 +350,45 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
}
s->options.max_prediction_order = avctx->max_prediction_order;
}
- if(s->options.max_prediction_order < s->options.min_prediction_order) {
+ if (s->options.max_prediction_order < s->options.min_prediction_order) {
av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n",
s->options.min_prediction_order, s->options.max_prediction_order);
return -1;
}
- av_log(avctx, AV_LOG_DEBUG, " prediction order: %d, %d\n",
- s->options.min_prediction_order, s->options.max_prediction_order);
- if(avctx->prediction_order_method >= 0) {
- if(avctx->prediction_order_method > ORDER_METHOD_LOG) {
+ if (avctx->prediction_order_method >= 0) {
+ if (avctx->prediction_order_method > ORDER_METHOD_LOG) {
av_log(avctx, AV_LOG_ERROR, "invalid prediction order method: %d\n",
avctx->prediction_order_method);
return -1;
}
s->options.prediction_order_method = avctx->prediction_order_method;
}
- switch(s->options.prediction_order_method) {
- case ORDER_METHOD_EST: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n",
- "estimate"); break;
- case ORDER_METHOD_2LEVEL: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n",
- "2-level"); break;
- case ORDER_METHOD_4LEVEL: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n",
- "4-level"); break;
- case ORDER_METHOD_8LEVEL: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n",
- "8-level"); break;
- case ORDER_METHOD_SEARCH: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n",
- "full search"); break;
- case ORDER_METHOD_LOG: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n",
- "log search"); break;
- }
- if(avctx->min_partition_order >= 0) {
- if(avctx->min_partition_order > MAX_PARTITION_ORDER) {
+ if (avctx->min_partition_order >= 0) {
+ if (avctx->min_partition_order > MAX_PARTITION_ORDER) {
av_log(avctx, AV_LOG_ERROR, "invalid min partition order: %d\n",
avctx->min_partition_order);
return -1;
}
s->options.min_partition_order = avctx->min_partition_order;
}
- if(avctx->max_partition_order >= 0) {
- if(avctx->max_partition_order > MAX_PARTITION_ORDER) {
+ if (avctx->max_partition_order >= 0) {
+ if (avctx->max_partition_order > MAX_PARTITION_ORDER) {
av_log(avctx, AV_LOG_ERROR, "invalid max partition order: %d\n",
avctx->max_partition_order);
return -1;
}
s->options.max_partition_order = avctx->max_partition_order;
}
- if(s->options.max_partition_order < s->options.min_partition_order) {
+ if (s->options.max_partition_order < s->options.min_partition_order) {
av_log(avctx, AV_LOG_ERROR, "invalid partition orders: min=%d max=%d\n",
s->options.min_partition_order, s->options.max_partition_order);
return -1;
}
- av_log(avctx, AV_LOG_DEBUG, " partition order: %d, %d\n",
- s->options.min_partition_order, s->options.max_partition_order);
- if(avctx->frame_size > 0) {
- if(avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
+ if (avctx->frame_size > 0) {
+ if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
avctx->frame_size > FLAC_MAX_BLOCKSIZE) {
av_log(avctx, AV_LOG_ERROR, "invalid block size: %d\n",
avctx->frame_size);
@@ -371,11 +398,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
s->avctx->frame_size = select_blocksize(s->samplerate, s->options.block_time_ms);
}
s->max_blocksize = s->avctx->frame_size;
- av_log(avctx, AV_LOG_DEBUG, " block size: %d\n", s->avctx->frame_size);
/* set LPC precision */
- if(avctx->lpc_coeff_precision > 0) {
- if(avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
+ if (avctx->lpc_coeff_precision > 0) {
+ if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
av_log(avctx, AV_LOG_ERROR, "invalid lpc coeff precision: %d\n",
avctx->lpc_coeff_precision);
return -1;
@@ -385,8 +411,6 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
/* default LPC precision */
s->options.lpc_coeff_precision = 15;
}
- av_log(avctx, AV_LOG_DEBUG, " lpc precision: %d\n",
- s->options.lpc_coeff_precision);
/* set maximum encoded frame size in verbatim mode */
s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,
@@ -394,24 +418,33 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
/* initialize MD5 context */
s->md5ctx = av_malloc(av_md5_size);
- if(!s->md5ctx)
+ if (!s->md5ctx)
return AVERROR(ENOMEM);
av_md5_init(s->md5ctx);
streaminfo = av_malloc(FLAC_STREAMINFO_SIZE);
+ if (!streaminfo)
+ return AVERROR(ENOMEM);
write_streaminfo(s, streaminfo);
avctx->extradata = streaminfo;
avctx->extradata_size = FLAC_STREAMINFO_SIZE;
- s->frame_count = 0;
+ s->frame_count = 0;
s->min_framesize = s->max_framesize;
avctx->coded_frame = avcodec_alloc_frame();
- avctx->coded_frame->key_frame = 1;
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
- return 0;
+ ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
+ s->options.max_prediction_order, AV_LPC_TYPE_LEVINSON);
+
+ dprint_compression_options(s);
+
+ return ret;
}
+
static void init_frame(FlacEncodeContext *s)
{
int i, ch;
@@ -419,17 +452,17 @@ static void init_frame(FlacEncodeContext *s)
frame = &s->frame;
- for(i=0; i<16; i++) {
- if(s->avctx->frame_size == ff_flac_blocksize_table[i]) {
- frame->blocksize = ff_flac_blocksize_table[i];
+ for (i = 0; i < 16; i++) {
+ if (s->avctx->frame_size == ff_flac_blocksize_table[i]) {
+ frame->blocksize = ff_flac_blocksize_table[i];
frame->bs_code[0] = i;
frame->bs_code[1] = 0;
break;
}
}
- if(i == 16) {
+ if (i == 16) {
frame->blocksize = s->avctx->frame_size;
- if(frame->blocksize <= 256) {
+ if (frame->blocksize <= 256) {
frame->bs_code[0] = 6;
frame->bs_code[1] = frame->blocksize-1;
} else {
@@ -438,45 +471,107 @@ static void init_frame(FlacEncodeContext *s)
}
}
- for(ch=0; ch<s->channels; ch++) {
+ for (ch = 0; ch < s->channels; ch++)
frame->subframes[ch].obits = 16;
- }
+
+ frame->verbatim_only = 0;
}
+
/**
- * Copy channel-interleaved input samples into separate subframes
+ * Copy channel-interleaved input samples into separate subframes.
*/
-static void copy_samples(FlacEncodeContext *s, int16_t *samples)
+static void copy_samples(FlacEncodeContext *s, const int16_t *samples)
{
int i, j, ch;
FlacFrame *frame;
frame = &s->frame;
- for(i=0,j=0; i<frame->blocksize; i++) {
- for(ch=0; ch<s->channels; ch++,j++) {
+ for (i = 0, j = 0; i < frame->blocksize; i++)
+ for (ch = 0; ch < s->channels; ch++, j++)
frame->subframes[ch].samples[i] = samples[j];
+}
+
+
+static int rice_count_exact(int32_t *res, int n, int k)
+{
+ int i;
+ int count = 0;
+
+ for (i = 0; i < n; i++) {
+ int32_t v = -2 * res[i] - 1;
+ v ^= v >> 31;
+ count += (v >> k) + 1 + k;
+ }
+ return count;
+}
+
+
+static int subframe_count_exact(FlacEncodeContext *s, FlacSubframe *sub,
+ int pred_order)
+{
+ int p, porder, psize;
+ int i, part_end;
+ int count = 0;
+
+ /* subframe header */
+ count += 8;
+
+ /* subframe */
+ if (sub->type == FLAC_SUBFRAME_CONSTANT) {
+ count += sub->obits;
+ } else if (sub->type == FLAC_SUBFRAME_VERBATIM) {
+ count += s->frame.blocksize * sub->obits;
+ } else {
+ /* warm-up samples */
+ count += pred_order * sub->obits;
+
+ /* LPC coefficients */
+ if (sub->type == FLAC_SUBFRAME_LPC)
+ count += 4 + 5 + pred_order * s->options.lpc_coeff_precision;
+
+ /* rice-encoded block */
+ count += 2;
+
+ /* partition order */
+ porder = sub->rc.porder;
+ psize = s->frame.blocksize >> porder;
+ count += 4;
+
+ /* residual */
+ i = pred_order;
+ part_end = psize;
+ for (p = 0; p < 1 << porder; p++) {
+ int k = sub->rc.params[p];
+ count += 4;
+ count += rice_count_exact(&sub->residual[i], part_end - i, k);
+ i = part_end;
+ part_end = FFMIN(s->frame.blocksize, part_end + psize);
}
}
+
+ return count;
}
#define rice_encode_count(sum, n, k) (((n)*((k)+1))+((sum-(n>>1))>>(k)))
/**
- * Solve for d/dk(rice_encode_count) = n-((sum-(n>>1))>>(k+1)) = 0
+ * Solve for d/dk(rice_encode_count) = n-((sum-(n>>1))>>(k+1)) = 0.
*/
static int find_optimal_param(uint32_t sum, int n)
{
int k;
uint32_t sum2;
- if(sum <= n>>1)
+ if (sum <= n >> 1)
return 0;
- sum2 = sum-(n>>1);
- k = av_log2(n<256 ? FASTDIV(sum2,n) : sum2/n);
+ sum2 = sum - (n >> 1);
+ k = av_log2(n < 256 ? FASTDIV(sum2, n) : sum2 / n);
return FFMIN(k, MAX_RICE_PARAM);
}
+
static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder,
uint32_t *sums, int n, int pred_order)
{
@@ -484,11 +579,11 @@ static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder,
int k, cnt, part;
uint32_t all_bits;
- part = (1 << porder);
+ part = (1 << porder);
all_bits = 4 * part;
cnt = (n >> porder) - pred_order;
- for(i=0; i<part; i++) {
+ for (i = 0; i < part; i++) {
k = find_optimal_param(sums[i], cnt);
rc->params[i] = k;
all_bits += rice_encode_count(sums[i], cnt, k);
@@ -500,6 +595,7 @@ static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder,
return all_bits;
}
+
static void calc_sums(int pmin, int pmax, uint32_t *data, int n, int pred_order,
uint32_t sums[][MAX_PARTITIONS])
{
@@ -508,26 +604,25 @@ static void calc_sums(int pmin, int pmax, uint32_t *data, int n, int pred_order,
uint32_t *res, *res_end;
/* sums for highest level */
- parts = (1 << pmax);
- res = &data[pred_order];
+ parts = (1 << pmax);
+ res = &data[pred_order];
res_end = &data[n >> pmax];
- for(i=0; i<parts; i++) {
+ for (i = 0; i < parts; i++) {
uint32_t sum = 0;
- while(res < res_end){
+ while (res < res_end)
sum += *(res++);
- }
sums[pmax][i] = sum;
- res_end+= n >> pmax;
+ res_end += n >> pmax;
}
/* sums for lower levels */
- for(i=pmax-1; i>=pmin; i--) {
+ for (i = pmax - 1; i >= pmin; i--) {
parts = (1 << i);
- for(j=0; j<parts; j++) {
+ for (j = 0; j < parts; j++)
sums[i][j] = sums[i+1][2*j] + sums[i+1][2*j+1];
- }
}
}
+
static uint32_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
int32_t *data, int n, int pred_order)
{
@@ -543,19 +638,18 @@ static uint32_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
assert(pmin <= pmax);
udata = av_malloc(n * sizeof(uint32_t));
- for(i=0; i<n; i++) {
+ for (i = 0; i < n; i++)
udata[i] = (2*data[i]) ^ (data[i]>>31);
- }
calc_sums(pmin, pmax, udata, n, pred_order, sums);
opt_porder = pmin;
bits[pmin] = UINT32_MAX;
- for(i=pmin; i<=pmax; i++) {
+ for (i = pmin; i <= pmax; i++) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
- if(bits[i] <= bits[opt_porder]) {
+ if (bits[i] <= bits[opt_porder]) {
opt_porder = i;
- *rc= tmp_rc;
+ *rc = tmp_rc;
}
}
@@ -563,155 +657,144 @@ static uint32_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
return bits[opt_porder];
}
+
static int get_max_p_order(int max_porder, int n, int order)
{
int porder = FFMIN(max_porder, av_log2(n^(n-1)));
- if(order > 0)
+ if (order > 0)
porder = FFMIN(porder, av_log2(n/order));
return porder;
}
-static uint32_t calc_rice_params_fixed(RiceContext *rc, int pmin, int pmax,
- int32_t *data, int n, int pred_order,
- int bps)
-{
- uint32_t bits;
- pmin = get_max_p_order(pmin, n, pred_order);
- pmax = get_max_p_order(pmax, n, pred_order);
- bits = pred_order*bps + 6;
- bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
- return bits;
-}
-static uint32_t calc_rice_params_lpc(RiceContext *rc, int pmin, int pmax,
- int32_t *data, int n, int pred_order,
- int bps, int precision)
+static uint32_t find_subframe_rice_params(FlacEncodeContext *s,
+ FlacSubframe *sub, int pred_order)
{
- uint32_t bits;
- pmin = get_max_p_order(pmin, n, pred_order);
- pmax = get_max_p_order(pmax, n, pred_order);
- bits = pred_order*bps + 4 + 5 + pred_order*precision + 6;
- bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
+ int pmin = get_max_p_order(s->options.min_partition_order,
+ s->frame.blocksize, pred_order);
+ int pmax = get_max_p_order(s->options.max_partition_order,
+ s->frame.blocksize, pred_order);
+
+ uint32_t bits = 8 + pred_order * sub->obits + 2 + 4;
+ if (sub->type == FLAC_SUBFRAME_LPC)
+ bits += 4 + 5 + pred_order * s->options.lpc_coeff_precision;
+ bits += calc_rice_params(&sub->rc, pmin, pmax, sub->residual,
+ s->frame.blocksize, pred_order);
return bits;
}
-static void encode_residual_verbatim(int32_t *res, int32_t *smp, int n)
-{
- assert(n > 0);
- memcpy(res, smp, n * sizeof(int32_t));
-}
static void encode_residual_fixed(int32_t *res, const int32_t *smp, int n,
int order)
{
int i;
- for(i=0; i<order; i++) {
+ for (i = 0; i < order; i++)
res[i] = smp[i];
- }
- if(order==0){
- for(i=order; i<n; i++)
- res[i]= smp[i];
- }else if(order==1){
- for(i=order; i<n; i++)
- res[i]= smp[i] - smp[i-1];
- }else if(order==2){
+ if (order == 0) {
+ for (i = order; i < n; i++)
+ res[i] = smp[i];
+ } else if (order == 1) {
+ for (i = order; i < n; i++)
+ res[i] = smp[i] - smp[i-1];
+ } else if (order == 2) {
int a = smp[order-1] - smp[order-2];
- for(i=order; i<n; i+=2) {
- int b = smp[i] - smp[i-1];
- res[i]= b - a;
- a = smp[i+1] - smp[i];
- res[i+1]= a - b;
+ for (i = order; i < n; i += 2) {
+ int b = smp[i ] - smp[i-1];
+ res[i] = b - a;
+ a = smp[i+1] - smp[i ];
+ res[i+1] = a - b;
}
- }else if(order==3){
- int a = smp[order-1] - smp[order-2];
+ } else if (order == 3) {
+ int a = smp[order-1] - smp[order-2];
int c = smp[order-1] - 2*smp[order-2] + smp[order-3];
- for(i=order; i<n; i+=2) {
- int b = smp[i] - smp[i-1];
- int d = b - a;
- res[i]= d - c;
- a = smp[i+1] - smp[i];
- c = a - b;
- res[i+1]= c - d;
+ for (i = order; i < n; i += 2) {
+ int b = smp[i ] - smp[i-1];
+ int d = b - a;
+ res[i] = d - c;
+ a = smp[i+1] - smp[i ];
+ c = a - b;
+ res[i+1] = c - d;
}
- }else{
- int a = smp[order-1] - smp[order-2];
- int c = smp[order-1] - 2*smp[order-2] + smp[order-3];
+ } else {
+ int a = smp[order-1] - smp[order-2];
+ int c = smp[order-1] - 2*smp[order-2] + smp[order-3];
int e = smp[order-1] - 3*smp[order-2] + 3*smp[order-3] - smp[order-4];
- for(i=order; i<n; i+=2) {
- int b = smp[i] - smp[i-1];
- int d = b - a;
- int f = d - c;
- res[i]= f - e;
- a = smp[i+1] - smp[i];
- c = a - b;
- e = c - d;
- res[i+1]= e - f;
+ for (i = order; i < n; i += 2) {
+ int b = smp[i ] - smp[i-1];
+ int d = b - a;
+ int f = d - c;
+ res[i ] = f - e;
+ a = smp[i+1] - smp[i ];
+ c = a - b;
+ e = c - d;
+ res[i+1] = e - f;
}
}
}
+
#define LPC1(x) {\
int c = coefs[(x)-1];\
- p0 += c*s;\
- s = smp[i-(x)+1];\
- p1 += c*s;\
+ p0 += c * s;\
+ s = smp[i-(x)+1];\
+ p1 += c * s;\
}
-static av_always_inline void encode_residual_lpc_unrolled(
- int32_t *res, const int32_t *smp, int n,
- int order, const int32_t *coefs, int shift, int big)
+static av_always_inline void encode_residual_lpc_unrolled(int32_t *res,
+ const int32_t *smp, int n, int order,
+ const int32_t *coefs, int shift, int big)
{
int i;
- for(i=order; i<n; i+=2) {
- int s = smp[i-order];
+ for (i = order; i < n; i += 2) {
+ int s = smp[i-order];
int p0 = 0, p1 = 0;
- if(big) {
- switch(order) {
- case 32: LPC1(32)
- case 31: LPC1(31)
- case 30: LPC1(30)
- case 29: LPC1(29)
- case 28: LPC1(28)
- case 27: LPC1(27)
- case 26: LPC1(26)
- case 25: LPC1(25)
- case 24: LPC1(24)
- case 23: LPC1(23)
- case 22: LPC1(22)
- case 21: LPC1(21)
- case 20: LPC1(20)
- case 19: LPC1(19)
- case 18: LPC1(18)
- case 17: LPC1(17)
- case 16: LPC1(16)
- case 15: LPC1(15)
- case 14: LPC1(14)
- case 13: LPC1(13)
- case 12: LPC1(12)
- case 11: LPC1(11)
- case 10: LPC1(10)
- case 9: LPC1( 9)
- LPC1( 8)
- LPC1( 7)
- LPC1( 6)
- LPC1( 5)
- LPC1( 4)
- LPC1( 3)
- LPC1( 2)
- LPC1( 1)
+ if (big) {
+ switch (order) {
+ case 32: LPC1(32)
+ case 31: LPC1(31)
+ case 30: LPC1(30)
+ case 29: LPC1(29)
+ case 28: LPC1(28)
+ case 27: LPC1(27)
+ case 26: LPC1(26)
+ case 25: LPC1(25)
+ case 24: LPC1(24)
+ case 23: LPC1(23)
+ case 22: LPC1(22)
+ case 21: LPC1(21)
+ case 20: LPC1(20)
+ case 19: LPC1(19)
+ case 18: LPC1(18)
+ case 17: LPC1(17)
+ case 16: LPC1(16)
+ case 15: LPC1(15)
+ case 14: LPC1(14)
+ case 13: LPC1(13)
+ case 12: LPC1(12)
+ case 11: LPC1(11)
+ case 10: LPC1(10)
+ case 9: LPC1( 9)
+ LPC1( 8)
+ LPC1( 7)
+ LPC1( 6)
+ LPC1( 5)
+ LPC1( 4)
+ LPC1( 3)
+ LPC1( 2)
+ LPC1( 1)
}
} else {
- switch(order) {
- case 8: LPC1( 8)
- case 7: LPC1( 7)
- case 6: LPC1( 6)
- case 5: LPC1( 5)
- case 4: LPC1( 4)
- case 3: LPC1( 3)
- case 2: LPC1( 2)
- case 1: LPC1( 1)
+ switch (order) {
+ case 8: LPC1( 8)
+ case 7: LPC1( 7)
+ case 6: LPC1( 6)
+ case 5: LPC1( 5)
+ case 4: LPC1( 4)
+ case 3: LPC1( 3)
+ case 2: LPC1( 2)
+ case 1: LPC1( 1)
}
}
res[i ] = smp[i ] - (p0 >> shift);
@@ -719,213 +802,231 @@ static av_always_inline void encode_residual_lpc_unrolled(
}
}
+
static void encode_residual_lpc(int32_t *res, const int32_t *smp, int n,
int order, const int32_t *coefs, int shift)
{
int i;
- for(i=0; i<order; i++) {
+ for (i = 0; i < order; i++)
res[i] = smp[i];
- }
#if CONFIG_SMALL
- for(i=order; i<n; i+=2) {
+ for (i = order; i < n; i += 2) {
int j;
- int s = smp[i];
+ int s = smp[i];
int p0 = 0, p1 = 0;
- for(j=0; j<order; j++) {
+ for (j = 0; j < order; j++) {
int c = coefs[j];
- p1 += c*s;
- s = smp[i-j-1];
- p0 += c*s;
+ p1 += c * s;
+ s = smp[i-j-1];
+ p0 += c * s;
}
res[i ] = smp[i ] - (p0 >> shift);
res[i+1] = smp[i+1] - (p1 >> shift);
}
#else
- switch(order) {
- case 1: encode_residual_lpc_unrolled(res, smp, n, 1, coefs, shift, 0); break;
- case 2: encode_residual_lpc_unrolled(res, smp, n, 2, coefs, shift, 0); break;
- case 3: encode_residual_lpc_unrolled(res, smp, n, 3, coefs, shift, 0); break;
- case 4: encode_residual_lpc_unrolled(res, smp, n, 4, coefs, shift, 0); break;
- case 5: encode_residual_lpc_unrolled(res, smp, n, 5, coefs, shift, 0); break;
- case 6: encode_residual_lpc_unrolled(res, smp, n, 6, coefs, shift, 0); break;
- case 7: encode_residual_lpc_unrolled(res, smp, n, 7, coefs, shift, 0); break;
- case 8: encode_residual_lpc_unrolled(res, smp, n, 8, coefs, shift, 0); break;
- default: encode_residual_lpc_unrolled(res, smp, n, order, coefs, shift, 1); break;
+ switch (order) {
+ case 1: encode_residual_lpc_unrolled(res, smp, n, 1, coefs, shift, 0); break;
+ case 2: encode_residual_lpc_unrolled(res, smp, n, 2, coefs, shift, 0); break;
+ case 3: encode_residual_lpc_unrolled(res, smp, n, 3, coefs, shift, 0); break;
+ case 4: encode_residual_lpc_unrolled(res, smp, n, 4, coefs, shift, 0); break;
+ case 5: encode_residual_lpc_unrolled(res, smp, n, 5, coefs, shift, 0); break;
+ case 6: encode_residual_lpc_unrolled(res, smp, n, 6, coefs, shift, 0); break;
+ case 7: encode_residual_lpc_unrolled(res, smp, n, 7, coefs, shift, 0); break;
+ case 8: encode_residual_lpc_unrolled(res, smp, n, 8, coefs, shift, 0); break;
+ default: encode_residual_lpc_unrolled(res, smp, n, order, coefs, shift, 1); break;
}
#endif
}
-static int encode_residual(FlacEncodeContext *ctx, int ch)
+
+static int encode_residual_ch(FlacEncodeContext *s, int ch)
{
int i, n;
- int min_order, max_order, opt_order, precision, omethod;
- int min_porder, max_porder;
+ int min_order, max_order, opt_order, omethod;
FlacFrame *frame;
FlacSubframe *sub;
int32_t coefs[MAX_LPC_ORDER][MAX_LPC_ORDER];
int shift[MAX_LPC_ORDER];
int32_t *res, *smp;
- frame = &ctx->frame;
- sub = &frame->subframes[ch];
- res = sub->residual;
- smp = sub->samples;
- n = frame->blocksize;
+ frame = &s->frame;
+ sub = &frame->subframes[ch];
+ res = sub->residual;
+ smp = sub->samples;
+ n = frame->blocksize;
/* CONSTANT */
- for(i=1; i<n; i++) {
- if(smp[i] != smp[0]) break;
- }
- if(i == n) {
+ for (i = 1; i < n; i++)
+ if(smp[i] != smp[0])
+ break;
+ if (i == n) {
sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT;
res[0] = smp[0];
- return sub->obits;
+ return subframe_count_exact(s, sub, 0);
}
/* VERBATIM */
- if(n < 5) {
+ if (frame->verbatim_only || n < 5) {
sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM;
- encode_residual_verbatim(res, smp, n);
- return sub->obits * n;
+ memcpy(res, smp, n * sizeof(int32_t));
+ return subframe_count_exact(s, sub, 0);
}
- min_order = ctx->options.min_prediction_order;
- max_order = ctx->options.max_prediction_order;
- min_porder = ctx->options.min_partition_order;
- max_porder = ctx->options.max_partition_order;
- precision = ctx->options.lpc_coeff_precision;
- omethod = ctx->options.prediction_order_method;
+ min_order = s->options.min_prediction_order;
+ max_order = s->options.max_prediction_order;
+ omethod = s->options.prediction_order_method;
/* FIXED */
- if (ctx->options.lpc_type == AV_LPC_TYPE_NONE ||
- ctx->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {
+ sub->type = FLAC_SUBFRAME_FIXED;
+ if (s->options.lpc_type == AV_LPC_TYPE_NONE ||
+ s->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;
+ if (max_order > MAX_FIXED_ORDER)
+ max_order = MAX_FIXED_ORDER;
opt_order = 0;
- bits[0] = UINT32_MAX;
- for(i=min_order; i<=max_order; i++) {
+ bits[0] = UINT32_MAX;
+ for (i = min_order; i <= max_order; i++) {
encode_residual_fixed(res, smp, n, i);
- bits[i] = calc_rice_params_fixed(&sub->rc, min_porder, max_porder, res,
- n, i, sub->obits);
- if(bits[i] < bits[opt_order]) {
+ bits[i] = find_subframe_rice_params(s, sub, i);
+ if (bits[i] < bits[opt_order])
opt_order = i;
- }
}
- sub->order = opt_order;
- sub->type = FLAC_SUBFRAME_FIXED;
+ sub->order = opt_order;
sub->type_code = sub->type | sub->order;
- if(sub->order != max_order) {
+ if (sub->order != max_order) {
encode_residual_fixed(res, smp, n, sub->order);
- return calc_rice_params_fixed(&sub->rc, min_porder, max_porder, res, n,
- sub->order, sub->obits);
+ find_subframe_rice_params(s, sub, sub->order);
}
- return bits[sub->order];
+ return subframe_count_exact(s, sub, sub->order);
}
/* LPC */
- opt_order = ff_lpc_calc_coefs(&ctx->dsp, smp, n, min_order, max_order,
- precision, coefs, shift, ctx->options.lpc_type,
- ctx->options.lpc_passes, omethod,
+ sub->type = FLAC_SUBFRAME_LPC;
+ opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, smp, n, min_order, max_order,
+ s->options.lpc_coeff_precision, coefs, shift, s->options.lpc_type,
+ s->options.lpc_passes, omethod,
MAX_LPC_SHIFT, 0);
- if(omethod == ORDER_METHOD_2LEVEL ||
- omethod == ORDER_METHOD_4LEVEL ||
- omethod == ORDER_METHOD_8LEVEL) {
+ if (omethod == ORDER_METHOD_2LEVEL ||
+ omethod == ORDER_METHOD_4LEVEL ||
+ omethod == ORDER_METHOD_8LEVEL) {
int levels = 1 << omethod;
uint32_t bits[1 << ORDER_METHOD_8LEVEL];
int order;
- int opt_index = levels-1;
- opt_order = max_order-1;
+ int opt_index = levels-1;
+ opt_order = max_order-1;
bits[opt_index] = UINT32_MAX;
- for(i=levels-1; i>=0; i--) {
+ for (i = levels-1; i >= 0; i--) {
order = min_order + (((max_order-min_order+1) * (i+1)) / levels)-1;
- if(order < 0) order = 0;
+ if (order < 0)
+ order = 0;
encode_residual_lpc(res, smp, n, order+1, coefs[order], shift[order]);
- bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,
- res, n, order+1, sub->obits, precision);
- if(bits[i] < bits[opt_index]) {
+ bits[i] = find_subframe_rice_params(s, sub, order+1);
+ if (bits[i] < bits[opt_index]) {
opt_index = i;
opt_order = order;
}
}
opt_order++;
- } else if(omethod == ORDER_METHOD_SEARCH) {
+ } else if (omethod == ORDER_METHOD_SEARCH) {
// brute-force optimal order search
uint32_t bits[MAX_LPC_ORDER];
opt_order = 0;
- bits[0] = UINT32_MAX;
- for(i=min_order-1; i<max_order; i++) {
+ bits[0] = UINT32_MAX;
+ for (i = min_order-1; i < max_order; i++) {
encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]);
- bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,
- res, n, i+1, sub->obits, precision);
- if(bits[i] < bits[opt_order]) {
+ bits[i] = find_subframe_rice_params(s, sub, i+1);
+ if (bits[i] < bits[opt_order])
opt_order = i;
- }
}
opt_order++;
- } else if(omethod == ORDER_METHOD_LOG) {
+ } else if (omethod == ORDER_METHOD_LOG) {
uint32_t bits[MAX_LPC_ORDER];
int step;
- opt_order= min_order - 1 + (max_order-min_order)/3;
+ opt_order = min_order - 1 + (max_order-min_order)/3;
memset(bits, -1, sizeof(bits));
- for(step=16 ;step; step>>=1){
- int last= opt_order;
- for(i=last-step; i<=last+step; i+= step){
- if(i<min_order-1 || i>=max_order || bits[i] < UINT32_MAX)
+ for (step = 16; step; step >>= 1) {
+ int last = opt_order;
+ for (i = last-step; i <= last+step; i += step) {
+ if (i < min_order-1 || i >= max_order || bits[i] < UINT32_MAX)
continue;
encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]);
- bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,
- res, n, i+1, sub->obits, precision);
- if(bits[i] < bits[opt_order])
- opt_order= i;
+ bits[i] = find_subframe_rice_params(s, sub, i+1);
+ if (bits[i] < bits[opt_order])
+ opt_order = i;
}
}
opt_order++;
}
- sub->order = opt_order;
- sub->type = FLAC_SUBFRAME_LPC;
+ sub->order = opt_order;
sub->type_code = sub->type | (sub->order-1);
- sub->shift = shift[sub->order-1];
- for(i=0; i<sub->order; i++) {
+ sub->shift = shift[sub->order-1];
+ for (i = 0; i < sub->order; i++)
sub->coefs[i] = coefs[sub->order-1][i];
- }
+
encode_residual_lpc(res, smp, n, sub->order, sub->coefs, sub->shift);
- return calc_rice_params_lpc(&sub->rc, min_porder, max_porder, res, n, sub->order,
- sub->obits, precision);
+
+ find_subframe_rice_params(s, sub, sub->order);
+
+ return subframe_count_exact(s, sub, sub->order);
}
-static int encode_residual_v(FlacEncodeContext *ctx, int ch)
+
+static int count_frame_header(FlacEncodeContext *s)
{
- int i, n;
- FlacFrame *frame;
- FlacSubframe *sub;
- int32_t *res, *smp;
+ uint8_t tmp;
+ int count;
+
+ /*
+ <14> Sync code
+ <1> Reserved
+ <1> Blocking strategy
+ <4> Block size in inter-channel samples
+ <4> Sample rate
+ <4> Channel assignment
+ <3> Sample size in bits
+ <1> Reserved
+ */
+ count = 32;
+
+ /* coded frame number */
+ PUT_UTF8(s->frame_count, tmp, count += 8;)
+
+ /* explicit block size */
+ if (s->frame.bs_code[0] == 6)
+ count += 8;
+ else if (s->frame.bs_code[0] == 7)
+ count += 16;
+
+ /* explicit sample rate */
+ count += ((s->sr_code[0] == 12) + (s->sr_code[0] > 12)) * 8;
+
+ /* frame header CRC-8 */
+ count += 8;
+
+ return count;
+}
- frame = &ctx->frame;
- sub = &frame->subframes[ch];
- res = sub->residual;
- smp = sub->samples;
- n = frame->blocksize;
- /* CONSTANT */
- for(i=1; i<n; i++) {
- if(smp[i] != smp[0]) break;
- }
- if(i == n) {
- sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT;
- res[0] = smp[0];
- return sub->obits;
- }
+static int encode_frame(FlacEncodeContext *s)
+{
+ int ch, count;
- /* VERBATIM */
- sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM;
- encode_residual_verbatim(res, smp, n);
- return sub->obits * n;
+ count = count_frame_header(s);
+
+ for (ch = 0; ch < s->channels; ch++)
+ count += encode_residual_ch(s, ch);
+
+ count += (8 - (count & 7)) & 7; // byte alignment
+ count += 16; // CRC-16
+
+ return count >> 3;
}
+
static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
{
int i, best;
@@ -936,8 +1037,8 @@ static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
/* calculate sum of 2nd order residual for each channel */
sum[0] = sum[1] = sum[2] = sum[3] = 0;
- for(i=2; i<n; i++) {
- lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
+ for (i = 2; i < n; i++) {
+ lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];
sum[2] += FFABS((lt + rt) >> 1);
sum[3] += FFABS(lt - rt);
@@ -945,9 +1046,9 @@ static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
sum[1] += FFABS(rt);
}
/* estimate bit counts */
- for(i=0; i<4; i++) {
- k = find_optimal_param(2*sum[i], n);
- sum[i] = rice_encode_count(2*sum[i], n, k);
+ for (i = 0; i < 4; i++) {
+ k = find_optimal_param(2 * sum[i], n);
+ sum[i] = rice_encode_count( 2 * sum[i], n, k);
}
/* calculate score for each mode */
@@ -958,37 +1059,36 @@ static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
/* return mode with lowest score */
best = 0;
- for(i=1; i<4; i++) {
- if(score[i] < score[best]) {
+ for (i = 1; i < 4; i++)
+ if (score[i] < score[best])
best = i;
- }
- }
- if(best == 0) {
+ if (best == 0) {
return FLAC_CHMODE_INDEPENDENT;
- } else if(best == 1) {
+ } else if (best == 1) {
return FLAC_CHMODE_LEFT_SIDE;
- } else if(best == 2) {
+ } else if (best == 2) {
return FLAC_CHMODE_RIGHT_SIDE;
} else {
return FLAC_CHMODE_MID_SIDE;
}
}
+
/**
- * Perform stereo channel decorrelation
+ * Perform stereo channel decorrelation.
*/
-static void channel_decorrelation(FlacEncodeContext *ctx)
+static void channel_decorrelation(FlacEncodeContext *s)
{
FlacFrame *frame;
int32_t *left, *right;
int i, n;
- frame = &ctx->frame;
- n = frame->blocksize;
+ frame = &s->frame;
+ n = frame->blocksize;
left = frame->subframes[0].samples;
right = frame->subframes[1].samples;
- if(ctx->channels != 2) {
+ if (s->channels != 2) {
frame->ch_mode = FLAC_CHMODE_INDEPENDENT;
return;
}
@@ -996,37 +1096,36 @@ static void channel_decorrelation(FlacEncodeContext *ctx)
frame->ch_mode = estimate_stereo_mode(left, right, n);
/* perform decorrelation and adjust bits-per-sample */
- if(frame->ch_mode == FLAC_CHMODE_INDEPENDENT) {
+ if (frame->ch_mode == FLAC_CHMODE_INDEPENDENT)
return;
- }
- if(frame->ch_mode == FLAC_CHMODE_MID_SIDE) {
+ if (frame->ch_mode == FLAC_CHMODE_MID_SIDE) {
int32_t tmp;
- for(i=0; i<n; i++) {
- tmp = left[i];
- left[i] = (tmp + right[i]) >> 1;
- right[i] = tmp - right[i];
+ for (i = 0; i < n; i++) {
+ tmp = left[i];
+ left[i] = (tmp + right[i]) >> 1;
+ right[i] = tmp - right[i];
}
frame->subframes[1].obits++;
- } else if(frame->ch_mode == FLAC_CHMODE_LEFT_SIDE) {
- for(i=0; i<n; i++) {
+ } else if (frame->ch_mode == FLAC_CHMODE_LEFT_SIDE) {
+ for (i = 0; i < n; i++)
right[i] = left[i] - right[i];
- }
frame->subframes[1].obits++;
} else {
- for(i=0; i<n; i++) {
+ for (i = 0; i < n; i++)
left[i] -= right[i];
- }
frame->subframes[0].obits++;
}
}
+
static void write_utf8(PutBitContext *pb, uint32_t val)
{
uint8_t tmp;
PUT_UTF8(val, tmp, put_bits(pb, 8, tmp);)
}
-static void output_frame_header(FlacEncodeContext *s)
+
+static void write_frame_header(FlacEncodeContext *s)
{
FlacFrame *frame;
int crc;
@@ -1036,145 +1135,43 @@ static void output_frame_header(FlacEncodeContext *s)
put_bits(&s->pb, 16, 0xFFF8);
put_bits(&s->pb, 4, frame->bs_code[0]);
put_bits(&s->pb, 4, s->sr_code[0]);
- if(frame->ch_mode == FLAC_CHMODE_INDEPENDENT) {
+
+ if (frame->ch_mode == FLAC_CHMODE_INDEPENDENT)
put_bits(&s->pb, 4, s->channels-1);
- } else {
+ else
put_bits(&s->pb, 4, frame->ch_mode);
- }
+
put_bits(&s->pb, 3, 4); /* bits-per-sample code */
put_bits(&s->pb, 1, 0);
write_utf8(&s->pb, s->frame_count);
- if(frame->bs_code[0] == 6) {
+
+ if (frame->bs_code[0] == 6)
put_bits(&s->pb, 8, frame->bs_code[1]);
- } else if(frame->bs_code[0] == 7) {
+ else if (frame->bs_code[0] == 7)
put_bits(&s->pb, 16, frame->bs_code[1]);
- }
- if(s->sr_code[0] == 12) {
+
+ if (s->sr_code[0] == 12)
put_bits(&s->pb, 8, s->sr_code[1]);
- } else if(s->sr_code[0] > 12) {
+ else if (s->sr_code[0] > 12)
put_bits(&s->pb, 16, s->sr_code[1]);
- }
+
flush_put_bits(&s->pb);
- crc = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0,
- s->pb.buf, put_bits_count(&s->pb)>>3);
+ crc = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, s->pb.buf,
+ put_bits_count(&s->pb) >> 3);
put_bits(&s->pb, 8, crc);
}
-static void output_subframe_constant(FlacEncodeContext *s, int ch)
-{
- FlacSubframe *sub;
- int32_t res;
-
- sub = &s->frame.subframes[ch];
- res = sub->residual[0];
- put_sbits(&s->pb, sub->obits, res);
-}
-
-static void output_subframe_verbatim(FlacEncodeContext *s, int ch)
-{
- int i;
- FlacFrame *frame;
- FlacSubframe *sub;
- int32_t res;
-
- frame = &s->frame;
- sub = &frame->subframes[ch];
-
- for(i=0; i<frame->blocksize; i++) {
- res = sub->residual[i];
- put_sbits(&s->pb, sub->obits, res);
- }
-}
-
-static void output_residual(FlacEncodeContext *ctx, int ch)
-{
- int i, j, p, n, parts;
- int k, porder, psize, res_cnt;
- FlacFrame *frame;
- FlacSubframe *sub;
- int32_t *res;
-
- frame = &ctx->frame;
- sub = &frame->subframes[ch];
- res = sub->residual;
- n = frame->blocksize;
-
- /* rice-encoded block */
- put_bits(&ctx->pb, 2, 0);
-
- /* partition order */
- porder = sub->rc.porder;
- psize = n >> porder;
- parts = (1 << porder);
- put_bits(&ctx->pb, 4, porder);
- res_cnt = psize - sub->order;
-
- /* residual */
- j = sub->order;
- for(p=0; p<parts; p++) {
- k = sub->rc.params[p];
- put_bits(&ctx->pb, 4, k);
- if(p == 1) res_cnt = psize;
- for(i=0; i<res_cnt && j<n; i++, j++) {
- set_sr_golomb_flac(&ctx->pb, res[j], k, INT32_MAX, 0);
- }
- }
-}
-
-static void output_subframe_fixed(FlacEncodeContext *ctx, int ch)
-{
- int i;
- FlacFrame *frame;
- FlacSubframe *sub;
- frame = &ctx->frame;
- sub = &frame->subframes[ch];
-
- /* warm-up samples */
- for(i=0; i<sub->order; i++) {
- put_sbits(&ctx->pb, sub->obits, sub->residual[i]);
- }
-
- /* residual */
- output_residual(ctx, ch);
-}
-
-static void output_subframe_lpc(FlacEncodeContext *ctx, int ch)
+static void write_subframes(FlacEncodeContext *s)
{
- int i, cbits;
- FlacFrame *frame;
- FlacSubframe *sub;
-
- frame = &ctx->frame;
- sub = &frame->subframes[ch];
-
- /* warm-up samples */
- for(i=0; i<sub->order; i++) {
- put_sbits(&ctx->pb, sub->obits, sub->residual[i]);
- }
-
- /* LPC coefficients */
- cbits = ctx->options.lpc_coeff_precision;
- put_bits(&ctx->pb, 4, cbits-1);
- put_sbits(&ctx->pb, 5, sub->shift);
- for(i=0; i<sub->order; i++) {
- put_sbits(&ctx->pb, cbits, sub->coefs[i]);
- }
-
- /* residual */
- output_residual(ctx, ch);
-}
-
-static void output_subframes(FlacEncodeContext *s)
-{
- FlacFrame *frame;
- FlacSubframe *sub;
int ch;
- frame = &s->frame;
-
- for(ch=0; ch<s->channels; ch++) {
- sub = &frame->subframes[ch];
+ for (ch = 0; ch < s->channels; ch++) {
+ FlacSubframe *sub = &s->frame.subframes[ch];
+ int i, p, porder, psize;
+ int32_t *part_end;
+ int32_t *res = sub->residual;
+ int32_t *frame_end = &sub->residual[s->frame.blocksize];
/* subframe header */
put_bits(&s->pb, 1, 0);
@@ -1182,57 +1179,91 @@ static void output_subframes(FlacEncodeContext *s)
put_bits(&s->pb, 1, 0); /* no wasted bits */
/* subframe */
- if(sub->type == FLAC_SUBFRAME_CONSTANT) {
- output_subframe_constant(s, ch);
- } else if(sub->type == FLAC_SUBFRAME_VERBATIM) {
- output_subframe_verbatim(s, ch);
- } else if(sub->type == FLAC_SUBFRAME_FIXED) {
- output_subframe_fixed(s, ch);
- } else if(sub->type == FLAC_SUBFRAME_LPC) {
- output_subframe_lpc(s, ch);
+ if (sub->type == FLAC_SUBFRAME_CONSTANT) {
+ put_sbits(&s->pb, sub->obits, res[0]);
+ } else if (sub->type == FLAC_SUBFRAME_VERBATIM) {
+ while (res < frame_end)
+ put_sbits(&s->pb, sub->obits, *res++);
+ } else {
+ /* warm-up samples */
+ for (i = 0; i < sub->order; i++)
+ put_sbits(&s->pb, sub->obits, *res++);
+
+ /* LPC coefficients */
+ if (sub->type == FLAC_SUBFRAME_LPC) {
+ int cbits = s->options.lpc_coeff_precision;
+ put_bits( &s->pb, 4, cbits-1);
+ put_sbits(&s->pb, 5, sub->shift);
+ for (i = 0; i < sub->order; i++)
+ put_sbits(&s->pb, cbits, sub->coefs[i]);
+ }
+
+ /* rice-encoded block */
+ put_bits(&s->pb, 2, 0);
+
+ /* partition order */
+ porder = sub->rc.porder;
+ psize = s->frame.blocksize >> porder;
+ put_bits(&s->pb, 4, porder);
+
+ /* residual */
+ part_end = &sub->residual[psize];
+ for (p = 0; p < 1 << porder; p++) {
+ int k = sub->rc.params[p];
+ put_bits(&s->pb, 4, k);
+ while (res < part_end)
+ set_sr_golomb_flac(&s->pb, *res++, k, INT32_MAX, 0);
+ part_end = FFMIN(frame_end, part_end + psize);
+ }
}
}
}
-static void output_frame_footer(FlacEncodeContext *s)
+
+static void write_frame_footer(FlacEncodeContext *s)
{
int crc;
flush_put_bits(&s->pb);
- crc = av_bswap16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0,
- s->pb.buf, put_bits_count(&s->pb)>>3));
+ 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);
}
-static void update_md5_sum(FlacEncodeContext *s, int16_t *samples)
+
+static int write_frame(FlacEncodeContext *s, uint8_t *frame, int buf_size)
+{
+ init_put_bits(&s->pb, frame, buf_size);
+ write_frame_header(s);
+ write_subframes(s);
+ write_frame_footer(s);
+ return put_bits_count(&s->pb) >> 3;
+}
+
+
+static void update_md5_sum(FlacEncodeContext *s, const int16_t *samples)
{
#if HAVE_BIGENDIAN
int i;
- for(i = 0; i < s->frame.blocksize*s->channels; i++) {
+ for (i = 0; i < s->frame.blocksize * s->channels; i++) {
int16_t smp = av_le2ne16(samples[i]);
av_md5_update(s->md5ctx, (uint8_t *)&smp, 2);
}
#else
- av_md5_update(s->md5ctx, (uint8_t *)samples, s->frame.blocksize*s->channels*2);
+ av_md5_update(s->md5ctx, (const uint8_t *)samples, s->frame.blocksize*s->channels*2);
#endif
}
+
static int flac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
{
- int ch;
FlacEncodeContext *s;
- int16_t *samples = data;
- int out_bytes;
- int reencoded=0;
+ const int16_t *samples = data;
+ int frame_bytes, out_bytes;
s = avctx->priv_data;
- if(buf_size < s->max_framesize*2) {
- av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
- return 0;
- }
-
/* when the last block is reached, update the header in extradata */
if (!data) {
s->max_framesize = s->max_encoded_framesize;
@@ -1241,39 +1272,35 @@ static int flac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
return 0;
}
+ /* change max_framesize for small final frame */
+ if (avctx->frame_size < s->frame.blocksize) {
+ s->max_framesize = ff_flac_get_max_frame_size(avctx->frame_size,
+ s->channels, 16);
+ }
+
init_frame(s);
copy_samples(s, samples);
channel_decorrelation(s);
- for(ch=0; ch<s->channels; ch++) {
- encode_residual(s, ch);
- }
+ frame_bytes = encode_frame(s);
-write_frame:
- init_put_bits(&s->pb, frame, buf_size);
- output_frame_header(s);
- output_subframes(s);
- output_frame_footer(s);
- out_bytes = put_bits_count(&s->pb) >> 3;
-
- if(out_bytes > s->max_framesize) {
- if(reencoded) {
- /* still too large. must be an error. */
- av_log(avctx, AV_LOG_ERROR, "error encoding frame\n");
- return -1;
- }
+ /* fallback to verbatim mode if the compressed frame is larger than it
+ would be if encoded uncompressed. */
+ if (frame_bytes > s->max_framesize) {
+ s->frame.verbatim_only = 1;
+ frame_bytes = encode_frame(s);
+ }
- /* frame too large. use verbatim mode */
- for(ch=0; ch<s->channels; ch++) {
- encode_residual_v(s, ch);
- }
- reencoded = 1;
- goto write_frame;
+ if (buf_size < frame_bytes) {
+ av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
+ return 0;
}
+ out_bytes = write_frame(s, frame, buf_size);
s->frame_count++;
+ avctx->coded_frame->pts = s->sample_count;
s->sample_count += avctx->frame_size;
update_md5_sum(s, samples);
if (out_bytes > s->max_encoded_framesize)
@@ -1284,11 +1311,13 @@ write_frame:
return out_bytes;
}
+
static av_cold int flac_encode_close(AVCodecContext *avctx)
{
if (avctx->priv_data) {
FlacEncodeContext *s = avctx->priv_data;
av_freep(&s->md5ctx);
+ ff_lpc_end(&s->lpc_ctx);
}
av_freep(&avctx->extradata);
avctx->extradata_size = 0;
@@ -1296,7 +1325,8 @@ static av_cold int flac_encode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec flac_encoder = {
+
+AVCodec ff_flac_encoder = {
"flac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_FLAC,
@@ -1306,6 +1336,6 @@ AVCodec flac_encoder = {
flac_encode_close,
NULL,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
};
diff --git a/lib/ffmpeg/libavcodec/flashsv.c b/lib/ffmpeg/libavcodec/flashsv.c
index 394ac0f82a..08748c65d1 100644
--- a/lib/ffmpeg/libavcodec/flashsv.c
+++ b/lib/ffmpeg/libavcodec/flashsv.c
@@ -250,7 +250,7 @@ static av_cold int flashsv_decode_end(AVCodecContext *avctx)
}
-AVCodec flashsv_decoder = {
+AVCodec ff_flashsv_decoder = {
"flashsv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FLASHSV,
diff --git a/lib/ffmpeg/libavcodec/flashsvenc.c b/lib/ffmpeg/libavcodec/flashsvenc.c
index ff917e9370..9093969cfe 100644
--- a/lib/ffmpeg/libavcodec/flashsvenc.c
+++ b/lib/ffmpeg/libavcodec/flashsvenc.c
@@ -280,7 +280,7 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec flashsv_encoder = {
+AVCodec ff_flashsv_encoder = {
"flashsv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FLASHSV,
diff --git a/lib/ffmpeg/libavcodec/flicvideo.c b/lib/ffmpeg/libavcodec/flicvideo.c
index 429ded53b2..913617d120 100644
--- a/lib/ffmpeg/libavcodec/flicvideo.c
+++ b/lib/ffmpeg/libavcodec/flicvideo.c
@@ -159,7 +159,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
int pixel_skip;
int pixel_countdown;
unsigned char *pixels;
- int pixel_limit;
+ unsigned int pixel_limit;
s->frame.reference = 1;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
@@ -253,10 +253,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
} else if ((line_packets & 0xC000) == 0x8000) {
// "last byte" opcode
- pixels[y_ptr + s->frame.linesize[0] - 1] = line_packets & 0xff;
+ pixel_ptr= y_ptr + s->frame.linesize[0] - 1;
+ CHECK_PIXEL_PTR(0);
+ pixels[pixel_ptr] = line_packets & 0xff;
} else {
compressed_lines--;
pixel_ptr = y_ptr;
+ CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
for (i = 0; i < line_packets; i++) {
/* account for the skip bytes */
@@ -268,7 +271,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
byte_run = -byte_run;
palette_idx1 = buf[stream_ptr++];
palette_idx2 = buf[stream_ptr++];
- CHECK_PIXEL_PTR(byte_run);
+ CHECK_PIXEL_PTR(byte_run * 2);
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
pixels[pixel_ptr++] = palette_idx1;
pixels[pixel_ptr++] = palette_idx2;
@@ -298,6 +301,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
stream_ptr += 2;
while (compressed_lines > 0) {
pixel_ptr = y_ptr;
+ CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
line_packets = buf[stream_ptr++];
if (line_packets > 0) {
@@ -453,7 +457,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
int pixel_countdown;
unsigned char *pixels;
int pixel;
- int pixel_limit;
+ unsigned int pixel_limit;
s->frame.reference = 1;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
@@ -503,6 +507,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
} else {
compressed_lines--;
pixel_ptr = y_ptr;
+ CHECK_PIXEL_PTR(0);
pixel_countdown = s->avctx->width;
for (i = 0; i < line_packets; i++) {
/* account for the skip bytes */
@@ -514,13 +519,13 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
byte_run = -byte_run;
pixel = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
- CHECK_PIXEL_PTR(byte_run);
+ CHECK_PIXEL_PTR(2 * byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
*((signed short*)(&pixels[pixel_ptr])) = pixel;
pixel_ptr += 2;
}
} else {
- CHECK_PIXEL_PTR(byte_run);
+ CHECK_PIXEL_PTR(2 * byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown--) {
*((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
@@ -611,7 +616,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
if (byte_run > 0) {
pixel = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
- CHECK_PIXEL_PTR(byte_run);
+ CHECK_PIXEL_PTR(2 * byte_run);
for (j = 0; j < byte_run; j++) {
*((signed short*)(&pixels[pixel_ptr])) = pixel;
pixel_ptr += 2;
@@ -622,7 +627,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
} else { /* copy pixels if byte_run < 0 */
byte_run = -byte_run;
- CHECK_PIXEL_PTR(byte_run);
+ CHECK_PIXEL_PTR(2 * byte_run);
for (j = 0; j < byte_run; j++) {
*((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
@@ -737,7 +742,7 @@ static av_cold int flic_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec flic_decoder = {
+AVCodec ff_flic_decoder = {
"flic",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FLIC,
diff --git a/lib/ffmpeg/libavcodec/flvdec.c b/lib/ffmpeg/libavcodec/flvdec.c
index b21a9e4a34..b1a7578173 100644
--- a/lib/ffmpeg/libavcodec/flvdec.c
+++ b/lib/ffmpeg/libavcodec/flvdec.c
@@ -20,6 +20,7 @@
#include "mpegvideo.h"
#include "h263.h"
#include "flv.h"
+#include "libavcore/imgutils.h"
void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last){
int is11 = get_bits1(gb);
@@ -82,7 +83,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
width = height = 0;
break;
}
- if(avcodec_check_dimensions(s->avctx, width, height))
+ if(av_image_check_size(width, height, 0, s->avctx))
return -1;
s->width = width;
s->height = height;
@@ -117,7 +118,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s)
return 0;
}
-AVCodec flv_decoder = {
+AVCodec ff_flv_decoder = {
"flv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FLV1,
diff --git a/lib/ffmpeg/libavcodec/flvenc.c b/lib/ffmpeg/libavcodec/flvenc.c
index bf320f2ffe..5e81dcb15d 100644
--- a/lib/ffmpeg/libavcodec/flvenc.c
+++ b/lib/ffmpeg/libavcodec/flvenc.c
@@ -84,7 +84,7 @@ void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, in
}
}
-AVCodec flv_encoder = {
+AVCodec ff_flv_encoder = {
"flv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FLV1,
diff --git a/lib/ffmpeg/libavcodec/fmtconvert.c b/lib/ffmpeg/libavcodec/fmtconvert.c
new file mode 100644
index 0000000000..e26b8997ab
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/fmtconvert.c
@@ -0,0 +1,68 @@
+/*
+ * Format Conversion Utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avcodec.h"
+#include "fmtconvert.h"
+
+static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
+ int i;
+ for(i=0; i<len; i++)
+ dst[i] = src[i] * mul;
+}
+
+static av_always_inline int float_to_int16_one(const float *src){
+ return av_clip_int16(lrintf(*src));
+}
+
+static void float_to_int16_c(int16_t *dst, const float *src, long len)
+{
+ int i;
+ for(i=0; i<len; i++)
+ dst[i] = float_to_int16_one(src+i);
+}
+
+static void float_to_int16_interleave_c(int16_t *dst, const float **src,
+ long len, int channels)
+{
+ int i,j,c;
+ if(channels==2){
+ for(i=0; i<len; i++){
+ dst[2*i] = float_to_int16_one(src[0]+i);
+ dst[2*i+1] = float_to_int16_one(src[1]+i);
+ }
+ }else{
+ for(c=0; c<channels; c++)
+ for(i=0, j=c; i<len; i++, j+=channels)
+ dst[j] = float_to_int16_one(src[c]+i);
+ }
+}
+
+av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
+{
+ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
+ c->float_to_int16 = float_to_int16_c;
+ c->float_to_int16_interleave = float_to_int16_interleave_c;
+
+ if (ARCH_ARM) ff_fmt_convert_init_arm(c, avctx);
+ if (ARCH_PPC) ff_fmt_convert_init_ppc(c, avctx);
+ if (HAVE_MMX) ff_fmt_convert_init_x86(c, avctx);
+}
diff --git a/lib/ffmpeg/libavcodec/fmtconvert.h b/lib/ffmpeg/libavcodec/fmtconvert.h
new file mode 100644
index 0000000000..f2ee261f99
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/fmtconvert.h
@@ -0,0 +1,79 @@
+/*
+ * Format Conversion Utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_FMTCONVERT_H
+#define AVCODEC_FMTCONVERT_H
+
+#include "avcodec.h"
+
+typedef struct FmtConvertContext {
+ /**
+ * Convert an array of int32_t to float and multiply by a float value.
+ * @param dst destination array of float.
+ * constraints: 16-byte aligned
+ * @param src source array of int32_t.
+ * constraints: 16-byte aligned
+ * @param len number of elements to convert.
+ * constraints: multiple of 8
+ */
+ void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
+
+ /**
+ * Convert an array of float to an array of int16_t.
+ *
+ * Convert floats from in the range [-32768.0,32767.0] to ints
+ * without rescaling
+ *
+ * @param dst destination array of int16_t.
+ * constraints: 16-byte aligned
+ * @param src source array of float.
+ * constraints: 16-byte aligned
+ * @param len number of elements to convert.
+ * constraints: multiple of 8
+ */
+ void (*float_to_int16)(int16_t *dst, const float *src, long len);
+
+ /**
+ * Convert multiple arrays of float to an interleaved array of int16_t.
+ *
+ * Convert floats from in the range [-32768.0,32767.0] to ints
+ * without rescaling
+ *
+ * @param dst destination array of interleaved int16_t.
+ * constraints: 16-byte aligned
+ * @param src source array of float arrays, one for each channel.
+ * constraints: 16-byte aligned
+ * @param len number of elements to convert.
+ * constraints: multiple of 8
+ * @param channels number of channels
+ */
+ void (*float_to_int16_interleave)(int16_t *dst, const float **src,
+ long len, int channels);
+} FmtConvertContext;
+
+void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx);
+
+void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx);
+void ff_fmt_convert_init_ppc(FmtConvertContext *c, AVCodecContext *avctx);
+void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx);
+
+#endif /* AVCODEC_FMTCONVERT_H */
diff --git a/lib/ffmpeg/libavcodec/fraps.c b/lib/ffmpeg/libavcodec/fraps.c
index 0829ac7e74..0938ccd630 100644
--- a/lib/ffmpeg/libavcodec/fraps.c
+++ b/lib/ffmpeg/libavcodec/fraps.c
@@ -118,15 +118,6 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
return 0;
}
-/**
- * decode a frame
- * @param avctx codec context
- * @param data output AVFrame
- * @param data_size size of output data or 0 if no picture is returned
- * @param buf input data frame
- * @param buf_size size of input data frame
- * @return number of consumed bytes on success or negative if decode fails
- */
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
@@ -164,7 +155,7 @@ static int decode_frame(AVCodecContext *avctx,
case 0:
default:
/* Fraps v0 is a reordered YUV420 */
- avctx->pix_fmt = PIX_FMT_YUV420P;
+ avctx->pix_fmt = PIX_FMT_YUVJ420P;
if ( (buf_size != avctx->width*avctx->height*3/2+header_size) &&
(buf_size != header_size) ) {
@@ -249,7 +240,7 @@ static int decode_frame(AVCodecContext *avctx,
* Fraps v2 is Huffman-coded YUV420 planes
* Fraps v4 is virtually the same
*/
- avctx->pix_fmt = PIX_FMT_YUV420P;
+ avctx->pix_fmt = PIX_FMT_YUVJ420P;
planes = 3;
f->reference = 1;
f->buffer_hints = FF_BUFFER_HINTS_VALID |
@@ -364,7 +355,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
}
-AVCodec fraps_decoder = {
+AVCodec ff_fraps_decoder = {
"fraps",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FRAPS,
diff --git a/lib/ffmpeg/libavcodec/frwu.c b/lib/ffmpeg/libavcodec/frwu.c
index b685248b5f..306166bdc5 100644
--- a/lib/ffmpeg/libavcodec/frwu.c
+++ b/lib/ffmpeg/libavcodec/frwu.c
@@ -109,7 +109,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec frwu_decoder = {
+AVCodec ff_frwu_decoder = {
"FRWU",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FRWU,
diff --git a/lib/ffmpeg/libavcodec/g722.c b/lib/ffmpeg/libavcodec/g722.c
new file mode 100644
index 0000000000..0efc390afc
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/g722.c
@@ -0,0 +1,583 @@
+/*
+ * G.722 ADPCM audio encoder/decoder
+ *
+ * Copyright (c) CMU 1993 Computer Science, Speech Group
+ * Chengxiang Lu and Alex Hauptmann
+ * Copyright (c) 2005 Steve Underwood <steveu at coppice.org>
+ * Copyright (c) 2009 Kenan Gillet
+ * Copyright (c) 2010 Martin Storsjo
+ *
+ * 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
+ *
+ * G.722 ADPCM audio codec
+ *
+ * This G.722 decoder is a bit-exact implementation of the ITU G.722
+ * specification for all three specified bitrates - 64000bps, 56000bps
+ * and 48000bps. It passes the ITU tests.
+ *
+ * @note For the 56000bps and 48000bps bitrates, the lowest 1 or 2 bits
+ * respectively of each byte are ignored.
+ */
+
+#include "avcodec.h"
+#include "mathops.h"
+#include "get_bits.h"
+
+#define PREV_SAMPLES_BUF_SIZE 1024
+
+#define FREEZE_INTERVAL 128
+
+typedef struct {
+ int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples
+ int prev_samples_pos; ///< the number of values in prev_samples
+
+ /**
+ * The band[0] and band[1] correspond respectively to the lower band and higher band.
+ */
+ struct G722Band {
+ int16_t s_predictor; ///< predictor output value
+ int32_t s_zero; ///< previous output signal from zero predictor
+ int8_t part_reconst_mem[2]; ///< signs of previous partially reconstructed signals
+ int16_t prev_qtzd_reconst; ///< previous quantized reconstructed signal (internal value, using low_inv_quant4)
+ int16_t pole_mem[2]; ///< second-order pole section coefficient buffer
+ int32_t diff_mem[6]; ///< quantizer difference signal memory
+ int16_t zero_mem[6]; ///< Seventh-order zero section coefficient buffer
+ int16_t log_factor; ///< delayed 2-logarithmic quantizer factor
+ int16_t scale_factor; ///< delayed quantizer scale factor
+ } band[2];
+
+ struct TrellisNode {
+ struct G722Band state;
+ uint32_t ssd;
+ int path;
+ } *node_buf[2], **nodep_buf[2];
+
+ struct TrellisPath {
+ int value;
+ int prev;
+ } *paths[2];
+} G722Context;
+
+
+static const int8_t sign_lookup[2] = { -1, 1 };
+
+static const int16_t inv_log2_table[32] = {
+ 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383,
+ 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834,
+ 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371,
+ 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008
+};
+static const int16_t high_log_factor_step[2] = { 798, -214 };
+static const int16_t high_inv_quant[4] = { -926, -202, 926, 202 };
+/**
+ * low_log_factor_step[index] == wl[rl42[index]]
+ */
+static const int16_t low_log_factor_step[16] = {
+ -60, 3042, 1198, 538, 334, 172, 58, -30,
+ 3042, 1198, 538, 334, 172, 58, -30, -60
+};
+static const int16_t low_inv_quant4[16] = {
+ 0, -2557, -1612, -1121, -786, -530, -323, -150,
+ 2557, 1612, 1121, 786, 530, 323, 150, 0
+};
+static const int16_t low_inv_quant6[64] = {
+ -17, -17, -17, -17, -3101, -2738, -2376, -2088,
+ -1873, -1689, -1535, -1399, -1279, -1170, -1072, -982,
+ -899, -822, -750, -682, -618, -558, -501, -447,
+ -396, -347, -300, -254, -211, -170, -130, -91,
+ 3101, 2738, 2376, 2088, 1873, 1689, 1535, 1399,
+ 1279, 1170, 1072, 982, 899, 822, 750, 682,
+ 618, 558, 501, 447, 396, 347, 300, 254,
+ 211, 170, 130, 91, 54, 17, -54, -17
+};
+
+/**
+ * quadrature mirror filter (QMF) coefficients
+ *
+ * ITU-T G.722 Table 11
+ */
+static const int16_t qmf_coeffs[12] = {
+ 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
+};
+
+
+/**
+ * adaptive predictor
+ *
+ * @param cur_diff the dequantized and scaled delta calculated from the
+ * current codeword
+ */
+static void do_adaptive_prediction(struct G722Band *band, const int cur_diff)
+{
+ int sg[2], limit, i, cur_qtzd_reconst;
+
+ const int cur_part_reconst = band->s_zero + cur_diff < 0;
+
+ sg[0] = sign_lookup[cur_part_reconst != band->part_reconst_mem[0]];
+ sg[1] = sign_lookup[cur_part_reconst == band->part_reconst_mem[1]];
+ band->part_reconst_mem[1] = band->part_reconst_mem[0];
+ band->part_reconst_mem[0] = cur_part_reconst;
+
+ band->pole_mem[1] = av_clip((sg[0] * av_clip(band->pole_mem[0], -8191, 8191) >> 5) +
+ (sg[1] << 7) + (band->pole_mem[1] * 127 >> 7), -12288, 12288);
+
+ limit = 15360 - band->pole_mem[1];
+ band->pole_mem[0] = av_clip(-192 * sg[0] + (band->pole_mem[0] * 255 >> 8), -limit, limit);
+
+
+ if (cur_diff) {
+ for (i = 0; i < 6; i++)
+ band->zero_mem[i] = ((band->zero_mem[i]*255) >> 8) +
+ ((band->diff_mem[i]^cur_diff) < 0 ? -128 : 128);
+ } else
+ for (i = 0; i < 6; i++)
+ band->zero_mem[i] = (band->zero_mem[i]*255) >> 8;
+
+ for (i = 5; i > 0; i--)
+ band->diff_mem[i] = band->diff_mem[i-1];
+ band->diff_mem[0] = av_clip_int16(cur_diff << 1);
+
+ band->s_zero = 0;
+ for (i = 5; i >= 0; i--)
+ band->s_zero += (band->zero_mem[i]*band->diff_mem[i]) >> 15;
+
+
+ cur_qtzd_reconst = av_clip_int16((band->s_predictor + cur_diff) << 1);
+ band->s_predictor = av_clip_int16(band->s_zero +
+ (band->pole_mem[0] * cur_qtzd_reconst >> 15) +
+ (band->pole_mem[1] * band->prev_qtzd_reconst >> 15));
+ band->prev_qtzd_reconst = cur_qtzd_reconst;
+}
+
+static int inline linear_scale_factor(const int log_factor)
+{
+ const int wd1 = inv_log2_table[(log_factor >> 6) & 31];
+ const int shift = log_factor >> 11;
+ return shift < 0 ? wd1 >> -shift : wd1 << shift;
+}
+
+static void update_low_predictor(struct G722Band *band, const int ilow)
+{
+ do_adaptive_prediction(band,
+ band->scale_factor * low_inv_quant4[ilow] >> 10);
+
+ // quantizer adaptation
+ band->log_factor = av_clip((band->log_factor * 127 >> 7) +
+ low_log_factor_step[ilow], 0, 18432);
+ band->scale_factor = linear_scale_factor(band->log_factor - (8 << 11));
+}
+
+static void update_high_predictor(struct G722Band *band, const int dhigh,
+ const int ihigh)
+{
+ do_adaptive_prediction(band, dhigh);
+
+ // quantizer adaptation
+ band->log_factor = av_clip((band->log_factor * 127 >> 7) +
+ high_log_factor_step[ihigh&1], 0, 22528);
+ band->scale_factor = linear_scale_factor(band->log_factor - (10 << 11));
+}
+
+static void apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2)
+{
+ int i;
+
+ *xout1 = 0;
+ *xout2 = 0;
+ for (i = 0; i < 12; i++) {
+ MAC16(*xout2, prev_samples[2*i ], qmf_coeffs[i ]);
+ MAC16(*xout1, prev_samples[2*i+1], qmf_coeffs[11-i]);
+ }
+}
+
+static av_cold int g722_init(AVCodecContext * avctx)
+{
+ G722Context *c = avctx->priv_data;
+
+ if (avctx->channels != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+
+ switch (avctx->bits_per_coded_sample) {
+ case 8:
+ case 7:
+ case 6:
+ break;
+ default:
+ av_log(avctx, AV_LOG_WARNING, "Unsupported bits_per_coded_sample [%d], "
+ "assuming 8\n",
+ avctx->bits_per_coded_sample);
+ case 0:
+ avctx->bits_per_coded_sample = 8;
+ break;
+ }
+
+ c->band[0].scale_factor = 8;
+ c->band[1].scale_factor = 2;
+ c->prev_samples_pos = 22;
+
+ if (avctx->lowres)
+ avctx->sample_rate /= 2;
+
+ if (avctx->trellis) {
+ int frontier = 1 << avctx->trellis;
+ int max_paths = frontier * FREEZE_INTERVAL;
+ int i;
+ for (i = 0; i < 2; i++) {
+ c->paths[i] = av_mallocz(max_paths * sizeof(**c->paths));
+ c->node_buf[i] = av_mallocz(2 * frontier * sizeof(**c->node_buf));
+ c->nodep_buf[i] = av_mallocz(2 * frontier * sizeof(**c->nodep_buf));
+ }
+ }
+
+ return 0;
+}
+
+static av_cold int g722_close(AVCodecContext *avctx)
+{
+ G722Context *c = avctx->priv_data;
+ int i;
+ for (i = 0; i < 2; i++) {
+ av_freep(&c->paths[i]);
+ av_freep(&c->node_buf[i]);
+ av_freep(&c->nodep_buf[i]);
+ }
+ return 0;
+}
+
+#if CONFIG_ADPCM_G722_DECODER
+static const int16_t low_inv_quant5[32] = {
+ -35, -35, -2919, -2195, -1765, -1458, -1219, -1023,
+ -858, -714, -587, -473, -370, -276, -190, -110,
+ 2919, 2195, 1765, 1458, 1219, 1023, 858, 714,
+ 587, 473, 370, 276, 190, 110, 35, -35
+};
+
+static const int16_t *low_inv_quants[3] = { low_inv_quant6, low_inv_quant5,
+ low_inv_quant4 };
+
+static int g722_decode_frame(AVCodecContext *avctx, void *data,
+ int *data_size, AVPacket *avpkt)
+{
+ G722Context *c = avctx->priv_data;
+ int16_t *out_buf = data;
+ int j, out_len = 0;
+ const int skip = 8 - avctx->bits_per_coded_sample;
+ const int16_t *quantizer_table = low_inv_quants[skip];
+ GetBitContext gb;
+
+ init_get_bits(&gb, avpkt->data, avpkt->size * 8);
+
+ for (j = 0; j < avpkt->size; j++) {
+ int ilow, ihigh, rlow;
+
+ ihigh = get_bits(&gb, 2);
+ ilow = get_bits(&gb, 6 - skip);
+ skip_bits(&gb, skip);
+
+ rlow = av_clip((c->band[0].scale_factor * quantizer_table[ilow] >> 10)
+ + c->band[0].s_predictor, -16384, 16383);
+
+ update_low_predictor(&c->band[0], ilow >> (2 - skip));
+
+ if (!avctx->lowres) {
+ const int dhigh = c->band[1].scale_factor *
+ high_inv_quant[ihigh] >> 10;
+ const int rhigh = av_clip(dhigh + c->band[1].s_predictor,
+ -16384, 16383);
+ int xout1, xout2;
+
+ update_high_predictor(&c->band[1], dhigh, ihigh);
+
+ c->prev_samples[c->prev_samples_pos++] = rlow + rhigh;
+ c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
+ apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
+ &xout1, &xout2);
+ out_buf[out_len++] = av_clip_int16(xout1 >> 12);
+ out_buf[out_len++] = av_clip_int16(xout2 >> 12);
+ if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
+ memmove(c->prev_samples,
+ c->prev_samples + c->prev_samples_pos - 22,
+ 22 * sizeof(c->prev_samples[0]));
+ c->prev_samples_pos = 22;
+ }
+ } else
+ out_buf[out_len++] = rlow;
+ }
+ *data_size = out_len << 1;
+ return avpkt->size;
+}
+
+AVCodec ff_adpcm_g722_decoder = {
+ .name = "g722",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = CODEC_ID_ADPCM_G722,
+ .priv_data_size = sizeof(G722Context),
+ .init = g722_init,
+ .decode = g722_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
+ .max_lowres = 1,
+};
+#endif
+
+#if CONFIG_ADPCM_G722_ENCODER
+static const int16_t low_quant[33] = {
+ 35, 72, 110, 150, 190, 233, 276, 323,
+ 370, 422, 473, 530, 587, 650, 714, 786,
+ 858, 940, 1023, 1121, 1219, 1339, 1458, 1612,
+ 1765, 1980, 2195, 2557, 2919
+};
+
+static inline void filter_samples(G722Context *c, const int16_t *samples,
+ int *xlow, int *xhigh)
+{
+ int xout1, xout2;
+ c->prev_samples[c->prev_samples_pos++] = samples[0];
+ c->prev_samples[c->prev_samples_pos++] = samples[1];
+ apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);
+ *xlow = xout1 + xout2 >> 13;
+ *xhigh = xout1 - xout2 >> 13;
+ if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
+ memmove(c->prev_samples,
+ c->prev_samples + c->prev_samples_pos - 22,
+ 22 * sizeof(c->prev_samples[0]));
+ c->prev_samples_pos = 22;
+ }
+}
+
+static inline int encode_high(const struct G722Band *state, int xhigh)
+{
+ int diff = av_clip_int16(xhigh - state->s_predictor);
+ int pred = 141 * state->scale_factor >> 8;
+ /* = diff >= 0 ? (diff < pred) + 2 : diff >= -pred */
+ return ((diff ^ (diff >> (sizeof(diff)*8-1))) < pred) + 2*(diff >= 0);
+}
+
+static inline int encode_low(const struct G722Band* state, int xlow)
+{
+ int diff = av_clip_int16(xlow - state->s_predictor);
+ /* = diff >= 0 ? diff : -(diff + 1) */
+ int limit = diff ^ (diff >> (sizeof(diff)*8-1));
+ int i = 0;
+ limit = limit + 1 << 10;
+ if (limit > low_quant[8] * state->scale_factor)
+ i = 9;
+ while (i < 29 && limit > low_quant[i] * state->scale_factor)
+ i++;
+ return (diff < 0 ? (i < 2 ? 63 : 33) : 61) - i;
+}
+
+static int g722_encode_trellis(AVCodecContext *avctx,
+ uint8_t *dst, int buf_size, void *data)
+{
+ G722Context *c = avctx->priv_data;
+ const int16_t *samples = data;
+ int i, j, k;
+ int frontier = 1 << avctx->trellis;
+ struct TrellisNode **nodes[2];
+ struct TrellisNode **nodes_next[2];
+ int pathn[2] = {0, 0}, froze = -1;
+ struct TrellisPath *p[2];
+
+ for (i = 0; i < 2; i++) {
+ nodes[i] = c->nodep_buf[i];
+ nodes_next[i] = c->nodep_buf[i] + frontier;
+ memset(c->nodep_buf[i], 0, 2 * frontier * sizeof(*c->nodep_buf));
+ nodes[i][0] = c->node_buf[i] + frontier;
+ nodes[i][0]->ssd = 0;
+ nodes[i][0]->path = 0;
+ nodes[i][0]->state = c->band[i];
+ }
+
+ for (i = 0; i < buf_size >> 1; i++) {
+ int xlow, xhigh;
+ struct TrellisNode *next[2];
+ int heap_pos[2] = {0, 0};
+
+ for (j = 0; j < 2; j++) {
+ next[j] = c->node_buf[j] + frontier*(i & 1);
+ memset(nodes_next[j], 0, frontier * sizeof(**nodes_next));
+ }
+
+ filter_samples(c, &samples[2*i], &xlow, &xhigh);
+
+ for (j = 0; j < frontier && nodes[0][j]; j++) {
+ /* Only k >> 2 affects the future adaptive state, therefore testing
+ * small steps that don't change k >> 2 is useless, the orignal
+ * value from encode_low is better than them. Since we step k
+ * in steps of 4, make sure range is a multiple of 4, so that
+ * we don't miss the original value from encode_low. */
+ int range = j < frontier/2 ? 4 : 0;
+ struct TrellisNode *cur_node = nodes[0][j];
+
+ int ilow = encode_low(&cur_node->state, xlow);
+
+ for (k = ilow - range; k <= ilow + range && k <= 63; k += 4) {
+ int decoded, dec_diff, pos;
+ uint32_t ssd;
+ struct TrellisNode* node;
+
+ if (k < 0)
+ continue;
+
+ decoded = av_clip((cur_node->state.scale_factor *
+ low_inv_quant6[k] >> 10)
+ + cur_node->state.s_predictor, -16384, 16383);
+ dec_diff = xlow - decoded;
+
+#define STORE_NODE(index, UPDATE, VALUE)\
+ ssd = cur_node->ssd + dec_diff*dec_diff;\
+ /* Check for wraparound. Using 64 bit ssd counters would \
+ * be simpler, but is slower on x86 32 bit. */\
+ if (ssd < cur_node->ssd)\
+ continue;\
+ if (heap_pos[index] < frontier) {\
+ pos = heap_pos[index]++;\
+ assert(pathn[index] < FREEZE_INTERVAL * frontier);\
+ node = nodes_next[index][pos] = next[index]++;\
+ node->path = pathn[index]++;\
+ } else {\
+ /* Try to replace one of the leaf nodes with the new \
+ * one, but not always testing the same leaf position */\
+ pos = (frontier>>1) + (heap_pos[index] & ((frontier>>1) - 1));\
+ if (ssd >= nodes_next[index][pos]->ssd)\
+ continue;\
+ heap_pos[index]++;\
+ node = nodes_next[index][pos];\
+ }\
+ node->ssd = ssd;\
+ node->state = cur_node->state;\
+ UPDATE;\
+ c->paths[index][node->path].value = VALUE;\
+ c->paths[index][node->path].prev = cur_node->path;\
+ /* Sift the newly inserted node up in the heap to restore \
+ * the heap property */\
+ while (pos > 0) {\
+ int parent = (pos - 1) >> 1;\
+ if (nodes_next[index][parent]->ssd <= ssd)\
+ break;\
+ FFSWAP(struct TrellisNode*, nodes_next[index][parent],\
+ nodes_next[index][pos]);\
+ pos = parent;\
+ }
+ STORE_NODE(0, update_low_predictor(&node->state, k >> 2), k);
+ }
+ }
+
+ for (j = 0; j < frontier && nodes[1][j]; j++) {
+ int ihigh;
+ struct TrellisNode *cur_node = nodes[1][j];
+
+ /* We don't try to get any initial guess for ihigh via
+ * encode_high - since there's only 4 possible values, test
+ * them all. Testing all of these gives a much, much larger
+ * gain than testing a larger range around ilow. */
+ for (ihigh = 0; ihigh < 4; ihigh++) {
+ int dhigh, decoded, dec_diff, pos;
+ uint32_t ssd;
+ struct TrellisNode* node;
+
+ dhigh = cur_node->state.scale_factor *
+ high_inv_quant[ihigh] >> 10;
+ decoded = av_clip(dhigh + cur_node->state.s_predictor,
+ -16384, 16383);
+ dec_diff = xhigh - decoded;
+
+ STORE_NODE(1, update_high_predictor(&node->state, dhigh, ihigh), ihigh);
+ }
+ }
+
+ for (j = 0; j < 2; j++) {
+ FFSWAP(struct TrellisNode**, nodes[j], nodes_next[j]);
+
+ if (nodes[j][0]->ssd > (1 << 16)) {
+ for (k = 1; k < frontier && nodes[j][k]; k++)
+ nodes[j][k]->ssd -= nodes[j][0]->ssd;
+ nodes[j][0]->ssd = 0;
+ }
+ }
+
+ if (i == froze + FREEZE_INTERVAL) {
+ p[0] = &c->paths[0][nodes[0][0]->path];
+ p[1] = &c->paths[1][nodes[1][0]->path];
+ for (j = i; j > froze; j--) {
+ dst[j] = p[1]->value << 6 | p[0]->value;
+ p[0] = &c->paths[0][p[0]->prev];
+ p[1] = &c->paths[1][p[1]->prev];
+ }
+ froze = i;
+ pathn[0] = pathn[1] = 0;
+ memset(nodes[0] + 1, 0, (frontier - 1)*sizeof(**nodes));
+ memset(nodes[1] + 1, 0, (frontier - 1)*sizeof(**nodes));
+ }
+ }
+
+ p[0] = &c->paths[0][nodes[0][0]->path];
+ p[1] = &c->paths[1][nodes[1][0]->path];
+ for (j = i; j > froze; j--) {
+ dst[j] = p[1]->value << 6 | p[0]->value;
+ p[0] = &c->paths[0][p[0]->prev];
+ p[1] = &c->paths[1][p[1]->prev];
+ }
+ c->band[0] = nodes[0][0]->state;
+ c->band[1] = nodes[1][0]->state;
+
+ return i;
+}
+
+static int g722_encode_frame(AVCodecContext *avctx,
+ uint8_t *dst, int buf_size, void *data)
+{
+ G722Context *c = avctx->priv_data;
+ const int16_t *samples = data;
+ int i;
+
+ if (avctx->trellis)
+ return g722_encode_trellis(avctx, dst, buf_size, data);
+
+ for (i = 0; i < buf_size >> 1; i++) {
+ int xlow, xhigh, ihigh, ilow;
+ filter_samples(c, &samples[2*i], &xlow, &xhigh);
+ ihigh = encode_high(&c->band[1], xhigh);
+ ilow = encode_low(&c->band[0], xlow);
+ update_high_predictor(&c->band[1], c->band[1].scale_factor *
+ high_inv_quant[ihigh] >> 10, ihigh);
+ update_low_predictor(&c->band[0], ilow >> 2);
+ *dst++ = ihigh << 6 | ilow;
+ }
+ return i;
+}
+
+AVCodec ff_adpcm_g722_encoder = {
+ .name = "g722",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = CODEC_ID_ADPCM_G722,
+ .priv_data_size = sizeof(G722Context),
+ .init = g722_init,
+ .close = g722_close,
+ .encode = g722_encode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
+ .sample_fmts = (enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
+};
+#endif
+
diff --git a/lib/ffmpeg/libavcodec/g726.c b/lib/ffmpeg/libavcodec/g726.c
index 5e0051171b..30bd96fcc9 100644
--- a/lib/ffmpeg/libavcodec/g726.c
+++ b/lib/ffmpeg/libavcodec/g726.c
@@ -332,7 +332,12 @@ static av_cold int g726_init(AVCodecContext * avctx)
avctx->coded_frame->key_frame = 1;
if (avctx->codec->decode)
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+
+ /* select a frame size that will end on a byte boundary and have a size of
+ approximately 1024 bytes */
+ if (avctx->codec->encode)
+ avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[index];
return 0;
}
@@ -348,12 +353,13 @@ static int g726_encode_frame(AVCodecContext *avctx,
uint8_t *dst, int buf_size, void *data)
{
G726Context *c = avctx->priv_data;
- short *samples = data;
+ const short *samples = data;
PutBitContext pb;
+ int i;
init_put_bits(&pb, dst, 1024*1024);
- for (; buf_size; buf_size--)
+ for (i = 0; i < avctx->frame_size; i++)
put_bits(&pb, c->code_size, g726_encode(c, *samples++));
flush_put_bits(&pb);
@@ -385,7 +391,7 @@ static int g726_decode_frame(AVCodecContext *avctx,
}
#if CONFIG_ADPCM_G726_ENCODER
-AVCodec adpcm_g726_encoder = {
+AVCodec ff_adpcm_g726_encoder = {
"g726",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ADPCM_G726,
@@ -394,12 +400,13 @@ AVCodec adpcm_g726_encoder = {
g726_encode_frame,
g726_close,
NULL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .capabilities = CODEC_CAP_SMALL_LAST_FRAME,
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
};
#endif
-AVCodec adpcm_g726_decoder = {
+AVCodec ff_adpcm_g726_decoder = {
"g726",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ADPCM_G726,
diff --git a/lib/ffmpeg/libavcodec/g729dec.c b/lib/ffmpeg/libavcodec/g729dec.c
index 3a6fb0fb7a..8a35bdc83c 100644
--- a/lib/ffmpeg/libavcodec/g729dec.c
+++ b/lib/ffmpeg/libavcodec/g729dec.c
@@ -312,7 +312,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
return buf_size;
}
-AVCodec g729_decoder =
+AVCodec ff_g729_decoder =
{
"g729",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/get_bits.h b/lib/ffmpeg/libavcodec/get_bits.h
index f4b3646e69..210ccc7ca6 100644
--- a/lib/ffmpeg/libavcodec/get_bits.h
+++ b/lib/ffmpeg/libavcodec/get_bits.h
@@ -39,12 +39,11 @@
# define ALT_BITSTREAM_READER
#endif
-#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
+#if !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
# if ARCH_ARM && !HAVE_FAST_UNALIGNED
# define A32_BITSTREAM_READER
# else
# define ALT_BITSTREAM_READER
-//#define LIBMPEG2_BITSTREAM_READER
//#define A32_BITSTREAM_READER
# endif
#endif
@@ -55,10 +54,6 @@ typedef struct GetBitContext {
const uint8_t *buffer, *buffer_end;
#ifdef ALT_BITSTREAM_READER
int index;
-#elif defined LIBMPEG2_BITSTREAM_READER
- uint8_t *buffer_ptr;
- uint32_t cache;
- int bit_count;
#elif defined A32_BITSTREAM_READER
uint32_t *buffer_ptr;
uint32_t cache0;
@@ -130,56 +125,46 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
#ifdef ALT_BITSTREAM_READER
# define MIN_CACHE_BITS 25
-# define OPEN_READER(name, gb)\
- unsigned int name##_index= (gb)->index;\
- int name##_cache= 0;\
+# define OPEN_READER(name, gb) \
+ unsigned int name##_index = (gb)->index; \
+ int name##_cache = 0
-# define CLOSE_READER(name, gb)\
- (gb)->index= name##_index;\
+# define CLOSE_READER(name, gb) (gb)->index = name##_index
# ifdef ALT_BITSTREAM_READER_LE
-# define UPDATE_CACHE(name, gb)\
- name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
+# define UPDATE_CACHE(name, gb) \
+ name##_cache = AV_RL32(((const uint8_t *)(gb)->buffer)+(name##_index>>3)) >> (name##_index&0x07)
-# define SKIP_CACHE(name, gb, num)\
- name##_cache >>= (num);
+# define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
# else
-# define UPDATE_CACHE(name, gb)\
- name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
+# define UPDATE_CACHE(name, gb) \
+ name##_cache = AV_RB32(((const uint8_t *)(gb)->buffer)+(name##_index>>3)) << (name##_index&0x07)
-# define SKIP_CACHE(name, gb, num)\
- name##_cache <<= (num);
+# define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
# endif
// FIXME name?
-# define SKIP_COUNTER(name, gb, num)\
- name##_index += (num);\
+# define SKIP_COUNTER(name, gb, num) name##_index += (num)
-# define SKIP_BITS(name, gb, num)\
- {\
- SKIP_CACHE(name, gb, num)\
- SKIP_COUNTER(name, gb, num)\
- }\
+# define SKIP_BITS(name, gb, num) do { \
+ SKIP_CACHE(name, gb, num); \
+ SKIP_COUNTER(name, gb, num); \
+ } while (0)
# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
-# define LAST_SKIP_CACHE(name, gb, num) ;
+# define LAST_SKIP_CACHE(name, gb, num)
# ifdef ALT_BITSTREAM_READER_LE
-# define SHOW_UBITS(name, gb, num)\
- zero_extend(name##_cache, num)
+# define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num)
-# define SHOW_SBITS(name, gb, num)\
- sign_extend(name##_cache, num)
+# define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num)
# else
-# define SHOW_UBITS(name, gb, num)\
- NEG_USR32(name##_cache, num)
+# define SHOW_UBITS(name, gb, num) NEG_USR32(name##_cache, num)
-# define SHOW_SBITS(name, gb, num)\
- NEG_SSR32(name##_cache, num)
+# define SHOW_SBITS(name, gb, num) NEG_SSR32(name##_cache, num)
# endif
-# define GET_CACHE(name, gb)\
- ((uint32_t)name##_cache)
+# define GET_CACHE(name, gb) ((uint32_t)name##_cache)
static inline int get_bits_count(const GetBitContext *s){
return s->index;
@@ -189,140 +174,76 @@ static inline void skip_bits_long(GetBitContext *s, int n){
s->index += n;
}
-#elif defined LIBMPEG2_BITSTREAM_READER
-//libmpeg2 like reader
-
-# define MIN_CACHE_BITS 17
-
-# define OPEN_READER(name, gb)\
- int name##_bit_count=(gb)->bit_count;\
- int name##_cache= (gb)->cache;\
- uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
-
-# define CLOSE_READER(name, gb)\
- (gb)->bit_count= name##_bit_count;\
- (gb)->cache= name##_cache;\
- (gb)->buffer_ptr= name##_buffer_ptr;\
-
-# define UPDATE_CACHE(name, gb)\
- if(name##_bit_count >= 0){\
- name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \
- name##_buffer_ptr+=2;\
- name##_bit_count-= 16;\
- }\
-
-# define SKIP_CACHE(name, gb, num)\
- name##_cache <<= (num);\
-
-# define SKIP_COUNTER(name, gb, num)\
- name##_bit_count += (num);\
-
-# define SKIP_BITS(name, gb, num)\
- {\
- SKIP_CACHE(name, gb, num)\
- SKIP_COUNTER(name, gb, num)\
- }\
-
-# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
-# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
-
-# define SHOW_UBITS(name, gb, num)\
- NEG_USR32(name##_cache, num)
-
-# define SHOW_SBITS(name, gb, num)\
- NEG_SSR32(name##_cache, num)
-
-# define GET_CACHE(name, gb)\
- ((uint32_t)name##_cache)
-
-static inline int get_bits_count(const GetBitContext *s){
- return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
-}
-
-static inline void skip_bits_long(GetBitContext *s, int n){
- OPEN_READER(re, s)
- re_bit_count += n;
- re_buffer_ptr += 2*(re_bit_count>>4);
- re_bit_count &= 15;
- re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count);
- UPDATE_CACHE(re, s)
- CLOSE_READER(re, s)
-}
-
#elif defined A32_BITSTREAM_READER
# define MIN_CACHE_BITS 32
-# define OPEN_READER(name, gb)\
- int name##_bit_count=(gb)->bit_count;\
- uint32_t name##_cache0= (gb)->cache0;\
- uint32_t name##_cache1= (gb)->cache1;\
- uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
-
-# define CLOSE_READER(name, gb)\
- (gb)->bit_count= name##_bit_count;\
- (gb)->cache0= name##_cache0;\
- (gb)->cache1= name##_cache1;\
- (gb)->buffer_ptr= name##_buffer_ptr;\
-
-# define UPDATE_CACHE(name, gb)\
- if(name##_bit_count > 0){\
- const uint32_t next= av_be2ne32( *name##_buffer_ptr );\
- name##_cache0 |= NEG_USR32(next,name##_bit_count);\
- name##_cache1 |= next<<name##_bit_count;\
- name##_buffer_ptr++;\
- name##_bit_count-= 32;\
- }\
+# define OPEN_READER(name, gb) \
+ int name##_bit_count = (gb)->bit_count; \
+ uint32_t name##_cache0 = (gb)->cache0; \
+ uint32_t name##_cache1 = (gb)->cache1; \
+ uint32_t *name##_buffer_ptr = (gb)->buffer_ptr
+
+# define CLOSE_READER(name, gb) do { \
+ (gb)->bit_count = name##_bit_count; \
+ (gb)->cache0 = name##_cache0; \
+ (gb)->cache1 = name##_cache1; \
+ (gb)->buffer_ptr = name##_buffer_ptr; \
+ } while (0)
+
+# define UPDATE_CACHE(name, gb) do { \
+ if(name##_bit_count > 0){ \
+ const uint32_t next = av_be2ne32(*name##_buffer_ptr); \
+ name##_cache0 |= NEG_USR32(next, name##_bit_count); \
+ name##_cache1 |= next << name##_bit_count; \
+ name##_buffer_ptr++; \
+ name##_bit_count -= 32; \
+ } \
+ } while (0)
#if ARCH_X86
-# define SKIP_CACHE(name, gb, num)\
- __asm__(\
- "shldl %2, %1, %0 \n\t"\
- "shll %2, %1 \n\t"\
- : "+r" (name##_cache0), "+r" (name##_cache1)\
- : "Ic" ((uint8_t)(num))\
- );
+# define SKIP_CACHE(name, gb, num) \
+ __asm__("shldl %2, %1, %0 \n\t" \
+ "shll %2, %1 \n\t" \
+ : "+r" (name##_cache0), "+r" (name##_cache1) \
+ : "Ic" ((uint8_t)(num)))
#else
-# define SKIP_CACHE(name, gb, num)\
- name##_cache0 <<= (num);\
- name##_cache0 |= NEG_USR32(name##_cache1,num);\
- name##_cache1 <<= (num);
+# define SKIP_CACHE(name, gb, num) do { \
+ name##_cache0 <<= (num); \
+ name##_cache0 |= NEG_USR32(name##_cache1,num); \
+ name##_cache1 <<= (num); \
+ } while (0)
#endif
-# define SKIP_COUNTER(name, gb, num)\
- name##_bit_count += (num);\
+# define SKIP_COUNTER(name, gb, num) name##_bit_count += (num)
-# define SKIP_BITS(name, gb, num)\
- {\
- SKIP_CACHE(name, gb, num)\
- SKIP_COUNTER(name, gb, num)\
- }\
+# define SKIP_BITS(name, gb, num) do { \
+ SKIP_CACHE(name, gb, num); \
+ SKIP_COUNTER(name, gb, num); \
+ } while (0)
-# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
+# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
-# define SHOW_UBITS(name, gb, num)\
- NEG_USR32(name##_cache0, num)
+# define SHOW_UBITS(name, gb, num) NEG_USR32(name##_cache0, num)
-# define SHOW_SBITS(name, gb, num)\
- NEG_SSR32(name##_cache0, num)
+# define SHOW_SBITS(name, gb, num) NEG_SSR32(name##_cache0, num)
-# define GET_CACHE(name, gb)\
- (name##_cache0)
+# define GET_CACHE(name, gb) name##_cache0
-static inline int get_bits_count(const GetBitContext *s){
+static inline int get_bits_count(const GetBitContext *s) {
return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
}
static inline void skip_bits_long(GetBitContext *s, int n){
- OPEN_READER(re, s)
+ OPEN_READER(re, s);
re_bit_count += n;
re_buffer_ptr += re_bit_count>>5;
re_bit_count &= 31;
- re_cache0 = av_be2ne32( 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)
+ UPDATE_CACHE(re, s);
+ CLOSE_READER(re, s);
}
#endif
@@ -336,73 +257,70 @@ static inline void skip_bits_long(GetBitContext *s, int n){
static inline int get_xbits(GetBitContext *s, int n){
register int sign;
register int32_t cache;
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
- cache = GET_CACHE(re,s);
- sign=(~cache)>>31;
- LAST_SKIP_BITS(re, s, n)
- CLOSE_READER(re, s)
+ OPEN_READER(re, s);
+ UPDATE_CACHE(re, s);
+ cache = GET_CACHE(re, s);
+ sign = ~cache >> 31;
+ LAST_SKIP_BITS(re, s, n);
+ CLOSE_READER(re, s);
return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
}
static inline int get_sbits(GetBitContext *s, int n){
register int tmp;
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
- tmp= SHOW_SBITS(re, s, n);
- LAST_SKIP_BITS(re, s, n)
- CLOSE_READER(re, s)
+ OPEN_READER(re, s);
+ UPDATE_CACHE(re, s);
+ tmp = SHOW_SBITS(re, s, n);
+ LAST_SKIP_BITS(re, s, n);
+ CLOSE_READER(re, s);
return tmp;
}
/**
- * reads 1-17 bits.
- * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
+ * Read 1-25 bits.
*/
static inline unsigned int get_bits(GetBitContext *s, int n){
register int tmp;
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
- tmp= SHOW_UBITS(re, s, n);
- LAST_SKIP_BITS(re, s, n)
- CLOSE_READER(re, s)
+ OPEN_READER(re, s);
+ UPDATE_CACHE(re, s);
+ tmp = SHOW_UBITS(re, s, n);
+ LAST_SKIP_BITS(re, s, n);
+ CLOSE_READER(re, s);
return tmp;
}
/**
- * shows 1-17 bits.
- * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
+ * Shows 1-25 bits.
*/
static inline unsigned int show_bits(GetBitContext *s, int n){
register int tmp;
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
- tmp= SHOW_UBITS(re, s, n);
-// CLOSE_READER(re, s)
+ OPEN_READER(re, s);
+ UPDATE_CACHE(re, s);
+ tmp = SHOW_UBITS(re, s, n);
return tmp;
}
static inline void skip_bits(GetBitContext *s, int n){
//Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
- LAST_SKIP_BITS(re, s, n)
- CLOSE_READER(re, s)
+ OPEN_READER(re, s);
+ UPDATE_CACHE(re, s);
+ LAST_SKIP_BITS(re, s, n);
+ CLOSE_READER(re, s);
}
static inline unsigned int get_bits1(GetBitContext *s){
#ifdef ALT_BITSTREAM_READER
- unsigned int index= s->index;
- uint8_t result= s->buffer[ index>>3 ];
+ unsigned int index = s->index;
+ uint8_t result = s->buffer[index>>3];
#ifdef ALT_BITSTREAM_READER_LE
- result>>= (index&0x07);
- result&= 1;
+ result >>= index & 7;
+ result &= 1;
#else
- result<<= (index&0x07);
- result>>= 8 - 1;
+ result <<= index & 7;
+ result >>= 8 - 1;
#endif
index++;
- s->index= index;
+ s->index = index;
return result;
#else
@@ -422,13 +340,13 @@ static inline void skip_bits1(GetBitContext *s){
* reads 0-32 bits.
*/
static inline unsigned int get_bits_long(GetBitContext *s, int n){
- if(n<=MIN_CACHE_BITS) return get_bits(s, n);
- else{
+ if (n <= MIN_CACHE_BITS) return get_bits(s, n);
+ else {
#ifdef ALT_BITSTREAM_READER_LE
- int ret= get_bits(s, 16);
+ int ret = get_bits(s, 16);
return ret | (get_bits(s, n-16) << 16);
#else
- int ret= get_bits(s, 16) << (n-16);
+ int ret = get_bits(s, 16) << (n-16);
return ret | get_bits(s, n-16);
#endif
}
@@ -445,17 +363,17 @@ static inline int get_sbits_long(GetBitContext *s, int n) {
* shows 0-32 bits.
*/
static inline unsigned int show_bits_long(GetBitContext *s, int n){
- if(n<=MIN_CACHE_BITS) return show_bits(s, n);
- else{
- GetBitContext gb= *s;
+ if (n <= MIN_CACHE_BITS) return show_bits(s, n);
+ else {
+ GetBitContext gb = *s;
return get_bits_long(&gb, n);
}
}
static inline int check_marker(GetBitContext *s, const char *msg)
{
- int bit= get_bits1(s);
- if(!bit)
+ int bit = get_bits1(s);
+ if (!bit)
av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
return bit;
@@ -473,42 +391,38 @@ static inline int check_marker(GetBitContext *s, const char *msg)
static inline void init_get_bits(GetBitContext *s,
const uint8_t *buffer, int bit_size)
{
- int buffer_size= (bit_size+7)>>3;
- if(buffer_size < 0 || bit_size < 0) {
+ int buffer_size = (bit_size+7)>>3;
+ if (buffer_size < 0 || bit_size < 0) {
buffer_size = bit_size = 0;
buffer = NULL;
}
- s->buffer= buffer;
- s->size_in_bits= bit_size;
- s->buffer_end= buffer + buffer_size;
+ s->buffer = buffer;
+ s->size_in_bits = bit_size;
+ s->buffer_end = buffer + buffer_size;
#ifdef ALT_BITSTREAM_READER
- s->index=0;
-#elif defined LIBMPEG2_BITSTREAM_READER
- s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1));
- s->bit_count = 16 + 8*((intptr_t)buffer&1);
- skip_bits_long(s, 0);
+ s->index = 0;
#elif defined A32_BITSTREAM_READER
- s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3));
- s->bit_count = 32 + 8*((intptr_t)buffer&3);
+ s->buffer_ptr = (uint32_t*)((intptr_t)buffer & ~3);
+ s->bit_count = 32 + 8*((intptr_t)buffer & 3);
skip_bits_long(s, 0);
#endif
}
static inline void align_get_bits(GetBitContext *s)
{
- int n= (-get_bits_count(s)) & 7;
- if(n) skip_bits(s, n);
+ int n = -get_bits_count(s) & 7;
+ if (n) skip_bits(s, n);
}
-#define init_vlc(vlc, nb_bits, nb_codes,\
- bits, bits_wrap, bits_size,\
- codes, codes_wrap, codes_size,\
- flags)\
- init_vlc_sparse(vlc, nb_bits, nb_codes,\
- bits, bits_wrap, bits_size,\
- codes, codes_wrap, codes_size,\
- NULL, 0, 0, flags)
+#define init_vlc(vlc, nb_bits, nb_codes, \
+ bits, bits_wrap, bits_size, \
+ codes, codes_wrap, codes_size, \
+ flags) \
+ init_vlc_sparse(vlc, nb_bits, nb_codes, \
+ bits, bits_wrap, bits_size, \
+ codes, codes_wrap, codes_size, \
+ NULL, 0, 0, flags)
int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
@@ -519,13 +433,12 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
#define INIT_VLC_USE_NEW_STATIC 4
void free_vlc(VLC *vlc);
-#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\
-{\
- static VLC_TYPE table[static_size][2];\
- (vlc)->table= table;\
- (vlc)->table_allocated= static_size;\
- init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\
-}
+#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size) do { \
+ static VLC_TYPE table[static_size][2]; \
+ (vlc)->table = table; \
+ (vlc)->table_allocated = static_size; \
+ init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC); \
+ } while (0)
/**
@@ -534,62 +447,60 @@ void free_vlc(VLC *vlc);
* If the vlc code is invalid and max_depth>1, then the number of bits removed
* is undefined.
*/
-#define GET_VLC(code, name, gb, table, bits, max_depth)\
-{\
- int n, nb_bits;\
- unsigned int index;\
-\
- index= SHOW_UBITS(name, gb, bits);\
- code = table[index][0];\
- n = table[index][1];\
-\
- if(max_depth > 1 && n < 0){\
- LAST_SKIP_BITS(name, gb, bits)\
- UPDATE_CACHE(name, gb)\
-\
- nb_bits = -n;\
-\
- index= SHOW_UBITS(name, gb, nb_bits) + code;\
- code = table[index][0];\
- n = table[index][1];\
- if(max_depth > 2 && n < 0){\
- LAST_SKIP_BITS(name, gb, nb_bits)\
- UPDATE_CACHE(name, gb)\
-\
- nb_bits = -n;\
-\
- index= SHOW_UBITS(name, gb, nb_bits) + code;\
- code = table[index][0];\
- n = table[index][1];\
- }\
- }\
- SKIP_BITS(name, gb, n)\
-}
-
-#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
-{\
- int n, nb_bits;\
- unsigned int index;\
-\
- index= SHOW_UBITS(name, gb, bits);\
- level = table[index].level;\
- n = table[index].len;\
-\
- if(max_depth > 1 && n < 0){\
- SKIP_BITS(name, gb, bits)\
- if(need_update){\
- UPDATE_CACHE(name, gb)\
- }\
-\
- nb_bits = -n;\
-\
- index= SHOW_UBITS(name, gb, nb_bits) + level;\
- level = table[index].level;\
- n = table[index].len;\
- }\
- run= table[index].run;\
- SKIP_BITS(name, gb, n)\
-}
+#define GET_VLC(code, name, gb, table, bits, max_depth) do { \
+ int n, nb_bits; \
+ unsigned int index; \
+ \
+ index = SHOW_UBITS(name, gb, bits); \
+ code = table[index][0]; \
+ n = table[index][1]; \
+ \
+ if (max_depth > 1 && n < 0) { \
+ LAST_SKIP_BITS(name, gb, bits); \
+ UPDATE_CACHE(name, gb); \
+ \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, gb, nb_bits) + code; \
+ code = table[index][0]; \
+ n = table[index][1]; \
+ if (max_depth > 2 && n < 0) { \
+ LAST_SKIP_BITS(name, gb, nb_bits); \
+ UPDATE_CACHE(name, gb); \
+ \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, gb, nb_bits) + code; \
+ code = table[index][0]; \
+ n = table[index][1]; \
+ } \
+ } \
+ SKIP_BITS(name, gb, n); \
+ } while (0)
+
+#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) do { \
+ int n, nb_bits; \
+ unsigned int index; \
+ \
+ index = SHOW_UBITS(name, gb, bits); \
+ level = table[index].level; \
+ n = table[index].len; \
+ \
+ if (max_depth > 1 && n < 0) { \
+ SKIP_BITS(name, gb, bits); \
+ if (need_update) { \
+ UPDATE_CACHE(name, gb); \
+ } \
+ \
+ nb_bits = -n; \
+ \
+ index = SHOW_UBITS(name, gb, nb_bits) + level; \
+ level = table[index].level; \
+ n = table[index].len; \
+ } \
+ run = table[index].run; \
+ SKIP_BITS(name, gb, n); \
+ } while (0)
/**
@@ -605,53 +516,81 @@ static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
{
int code;
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
+ OPEN_READER(re, s);
+ UPDATE_CACHE(re, s);
- GET_VLC(code, re, s, table, bits, max_depth)
+ GET_VLC(code, re, s, table, bits, max_depth);
- CLOSE_READER(re, s)
+ CLOSE_READER(re, s);
return code;
}
+static inline int decode012(GetBitContext *gb){
+ int n;
+ n = get_bits1(gb);
+ if (n == 0)
+ return 0;
+ else
+ return get_bits1(gb) + 1;
+}
+
+static inline int decode210(GetBitContext *gb){
+ if (get_bits1(gb))
+ return 0;
+ else
+ return 2 - get_bits1(gb);
+}
+
+static inline int get_bits_left(GetBitContext *gb)
+{
+ return gb->size_in_bits - get_bits_count(gb);
+}
+
//#define TRACE
#ifdef TRACE
static inline void print_bin(int bits, int n){
int i;
- for(i=n-1; i>=0; i--){
+ for (i = n-1; i >= 0; i--) {
av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
}
- for(i=n; i<24; i++)
+ for (i = n; i < 24; i++)
av_log(NULL, AV_LOG_DEBUG, " ");
}
-static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
- int r= get_bits(s, n);
+static inline int get_bits_trace(GetBitContext *s, int n, char *file,
+ const char *func, int line){
+ int r = get_bits(s, n);
print_bin(r, n);
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n",
+ r, n, r, get_bits_count(s)-n, file, func, line);
return r;
}
-static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){
- int show= show_bits(s, 24);
- int pos= get_bits_count(s);
- int r= get_vlc2(s, table, bits, max_depth);
- int len= get_bits_count(s) - pos;
- int bits2= show>>(24-len);
+static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
+ int bits, int max_depth, char *file,
+ const char *func, int line){
+ int show = show_bits(s, 24);
+ int pos = get_bits_count(s);
+ int r = get_vlc2(s, table, bits, max_depth);
+ int len = get_bits_count(s) - pos;
+ int bits2 = show >> (24-len);
print_bin(bits2, len);
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n",
+ bits2, len, r, pos, file, func, line);
return r;
}
-static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
- int show= show_bits(s, n);
- int r= get_xbits(s, n);
+static inline int get_xbits_trace(GetBitContext *s, int n, char *file,
+ const char *func, int line){
+ int show = show_bits(s, n);
+ int r = get_xbits(s, n);
print_bin(show, n);
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
+ av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n",
+ show, n, r, get_bits_count(s)-n, file, func, line);
return r;
}
@@ -667,25 +606,4 @@ static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const cha
#define tprintf(p, ...) {}
#endif
-static inline int decode012(GetBitContext *gb){
- int n;
- n = get_bits1(gb);
- if (n == 0)
- return 0;
- else
- return get_bits1(gb) + 1;
-}
-
-static inline int decode210(GetBitContext *gb){
- if (get_bits1(gb))
- return 0;
- else
- return 2 - get_bits1(gb);
-}
-
-static inline int get_bits_left(GetBitContext *gb)
-{
- return gb->size_in_bits - get_bits_count(gb);
-}
-
#endif /* AVCODEC_GET_BITS_H */
diff --git a/lib/ffmpeg/libavcodec/gif.c b/lib/ffmpeg/libavcodec/gif.c
index 5114b89226..218b80babb 100644
--- a/lib/ffmpeg/libavcodec/gif.c
+++ b/lib/ffmpeg/libavcodec/gif.c
@@ -87,7 +87,7 @@ static int gif_image_write_image(AVCodecContext *avctx,
const uint8_t *buf, int linesize)
{
GIFContext *s = avctx->priv_data;
- int len, height;
+ int len = 0, height;
const uint8_t *ptr;
/* image block */
@@ -166,7 +166,7 @@ static int gif_encode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec gif_encoder = {
+AVCodec ff_gif_encoder = {
"gif",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_GIF,
diff --git a/lib/ffmpeg/libavcodec/gifdec.c b/lib/ffmpeg/libavcodec/gifdec.c
index 1daf1b7b1a..7be284cb14 100644
--- a/lib/ffmpeg/libavcodec/gifdec.c
+++ b/lib/ffmpeg/libavcodec/gifdec.c
@@ -22,6 +22,7 @@
//#define DEBUG
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "lzw.h"
@@ -75,9 +76,8 @@ static int gif_read_image(GifState *s)
is_interleaved = flags & 0x40;
has_local_palette = flags & 0x80;
bits_per_pixel = (flags & 0x07) + 1;
-#ifdef DEBUG
- dprintf(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
-#endif
+
+ av_dlog(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
if (has_local_palette) {
bytestream_get_buffer(&s->bytestream, s->local_palette, 3 * (1 << bits_per_pixel));
@@ -162,9 +162,9 @@ static int gif_read_extension(GifState *s)
/* extension */
ext_code = bytestream_get_byte(&s->bytestream);
ext_len = bytestream_get_byte(&s->bytestream);
-#ifdef DEBUG
- dprintf(s->avctx, "gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
-#endif
+
+ av_dlog(s->avctx, "gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
+
switch(ext_code) {
case 0xf9:
if (ext_len != 4)
@@ -178,11 +178,11 @@ static int gif_read_extension(GifState *s)
else
s->transparent_color_index = -1;
s->gce_disposal = (gce_flags >> 2) & 0x7;
-#ifdef DEBUG
- dprintf(s->avctx, "gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n",
+
+ av_dlog(s->avctx, "gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n",
gce_flags, s->gce_delay,
s->transparent_color_index, s->gce_disposal);
-#endif
+
ext_len = bytestream_get_byte(&s->bytestream);
break;
}
@@ -193,9 +193,8 @@ static int gif_read_extension(GifState *s)
for (i = 0; i < ext_len; i++)
bytestream_get_byte(&s->bytestream);
ext_len = bytestream_get_byte(&s->bytestream);
-#ifdef DEBUG
- dprintf(s->avctx, "gif: ext_len1=%d\n", ext_len);
-#endif
+
+ av_dlog(s->avctx, "gif: ext_len1=%d\n", ext_len);
}
return 0;
}
@@ -231,11 +230,11 @@ static int gif_read_header1(GifState *s)
s->bits_per_pixel = (v & 0x07) + 1;
s->background_color_index = bytestream_get_byte(&s->bytestream);
bytestream_get_byte(&s->bytestream); /* ignored */
-#ifdef DEBUG
- dprintf(s->avctx, "gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
+
+ av_dlog(s->avctx, "gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
s->screen_width, s->screen_height, s->bits_per_pixel,
has_global_palette);
-#endif
+
if (has_global_palette) {
n = 1 << s->bits_per_pixel;
if (s->bytestream_end < s->bytestream + n * 3)
@@ -249,9 +248,9 @@ static int gif_parse_next_image(GifState *s)
{
while (s->bytestream < s->bytestream_end) {
int code = bytestream_get_byte(&s->bytestream);
-#ifdef DEBUG
- dprintf(s->avctx, "gif: code=%02x '%c'\n", code, code);
-#endif
+
+ av_dlog(s->avctx, "gif: code=%02x '%c'\n", code, code);
+
switch (code) {
case ',':
return gif_read_image(s);
@@ -296,7 +295,7 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, A
return -1;
avctx->pix_fmt = PIX_FMT_PAL8;
- if (avcodec_check_dimensions(avctx, s->screen_width, s->screen_height))
+ if (av_image_check_size(s->screen_width, s->screen_height, 0, avctx))
return -1;
avcodec_set_dimensions(avctx, s->screen_width, s->screen_height);
@@ -326,7 +325,7 @@ static av_cold int gif_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec gif_decoder = {
+AVCodec ff_gif_decoder = {
"gif",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_GIF,
diff --git a/lib/ffmpeg/libavcodec/gsmdec.c b/lib/ffmpeg/libavcodec/gsmdec.c
index 3759f35d21..4ce36b48bc 100644
--- a/lib/ffmpeg/libavcodec/gsmdec.c
+++ b/lib/ffmpeg/libavcodec/gsmdec.c
@@ -24,29 +24,18 @@
* GSM decoder
*/
-#define ALT_BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
+#include "msgsmdec.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;
+#include "gsmdec_template.c"
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;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
switch (avctx->codec_id) {
case CODEC_ID_GSM:
@@ -61,199 +50,6 @@ static av_cold int gsm_init(AVCodecContext *avctx)
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)
{
@@ -269,10 +65,10 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
*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:
+ init_get_bits(&gb, buf, buf_size * 8);
if (get_bits(&gb, 4) != 0xd)
av_log(avctx, AV_LOG_WARNING, "Missing GSM magic!\n");
res = gsm_decode_block(avctx, samples, &gb);
@@ -280,10 +76,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
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);
+ res = ff_msgsm_decode_block(avctx, samples, buf);
if (res < 0)
return res;
}
@@ -291,7 +84,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,
return avctx->block_align;
}
-AVCodec gsm_decoder = {
+AVCodec ff_gsm_decoder = {
"gsm",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_GSM,
@@ -303,7 +96,7 @@ AVCodec gsm_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("GSM"),
};
-AVCodec gsm_ms_decoder = {
+AVCodec ff_gsm_ms_decoder = {
"gsm_ms",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_GSM_MS,
diff --git a/lib/ffmpeg/libavcodec/gsmdec_data.c b/lib/ffmpeg/libavcodec/gsmdec_data.c
new file mode 100644
index 0000000000..4324ea28a9
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/gsmdec_data.c
@@ -0,0 +1,94 @@
+/*
+ * gsm 06.10 decoder data
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+#include "gsmdec_data.h"
+
+const uint16_t ff_gsm_long_term_gain_tab[4] = {
+ 3277, 11469, 21299, 32767
+};
+
+const int16_t ff_gsm_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}
+};
diff --git a/lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.h b/lib/ffmpeg/libavcodec/gsmdec_data.h
index e0ebf0b0f4..6b05bf6c97 100644
--- a/lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.h
+++ b/lib/ffmpeg/libavcodec/gsmdec_data.h
@@ -1,6 +1,6 @@
/*
- * vp3dsp MMX function declarations
- * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org>
+ * gsm 06.10 decoder data
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
*
* This file is part of FFmpeg.
*
@@ -19,18 +19,29 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_X86_VP3DSP_MMX_H
-#define AVCODEC_X86_VP3DSP_MMX_H
+#ifndef GSMDEC_DATA
+#define GSMDEC_DATA
#include <stdint.h>
-#include "libavcodec/dsputil.h"
-void ff_vp3_idct_mmx(int16_t *data);
-void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_vp3_idct_dc_add_mmx2(uint8_t *dest, int line_size, const DCTELEM *block);
+// input and output sizes in byte
+#define GSM_BLOCK_SIZE 33
+#define GSM_MS_BLOCK_SIZE 65
+#define GSM_FRAME_SIZE 160
-void ff_vp3_v_loop_filter_mmx2(uint8_t *src, int stride, int *bounding_values);
-void ff_vp3_h_loop_filter_mmx2(uint8_t *src, int stride, int *bounding_values);
+typedef struct {
+ // Contains first 120 elements from the previous frame
+ // (used by long_term_synth according to the "lag"),
+ // then in the following 160 elements the current
+ // frame is constructed.
+ int16_t ref_buf[280];
+ int v[9];
+ int lar[2][8];
+ int lar_idx;
+ int msr;
+} GSMContext;
-#endif /* AVCODEC_X86_VP3DSP_MMX_H */
+extern const uint16_t ff_gsm_long_term_gain_tab[4];
+extern const int16_t ff_gsm_dequant_tab[64][8];
+
+#endif
diff --git a/lib/ffmpeg/libavcodec/gsmdec_template.c b/lib/ffmpeg/libavcodec/gsmdec_template.c
new file mode 100644
index 0000000000..b63ec9ed27
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/gsmdec_template.c
@@ -0,0 +1,150 @@
+/*
+ * gsm 06.10 decoder
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * GSM decoder
+ */
+
+#include "get_bits.h"
+#include "gsmdec_data.h"
+
+static void apcm_dequant_add(GetBitContext *gb, int16_t *dst)
+{
+ int i;
+ int maxidx = get_bits(gb, 6);
+ const int16_t *tab = ff_gsm_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 void long_term_synth(int16_t *dst, int lag, int gain_idx)
+{
+ int i;
+ const int16_t *src = dst - lag;
+ uint16_t gain = ff_gsm_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;
+}
diff --git a/lib/ffmpeg/libavcodec/h261_parser.c b/lib/ffmpeg/libavcodec/h261_parser.c
index c32300d6ed..defc1cb46f 100644
--- a/lib/ffmpeg/libavcodec/h261_parser.c
+++ b/lib/ffmpeg/libavcodec/h261_parser.c
@@ -81,7 +81,7 @@ static int h261_parse(AVCodecParserContext *s,
return next;
}
-AVCodecParser h261_parser = {
+AVCodecParser ff_h261_parser = {
{ CODEC_ID_H261 },
sizeof(ParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/h261dec.c b/lib/ffmpeg/libavcodec/h261dec.c
index 3809a0179c..9f18199b04 100644
--- a/lib/ffmpeg/libavcodec/h261dec.c
+++ b/lib/ffmpeg/libavcodec/h261dec.c
@@ -553,8 +553,8 @@ static int h261_decode_frame(AVCodecContext *avctx,
int ret;
AVFrame *pict = data;
- dprintf(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
- dprintf(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
+ av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
+ av_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
s->flags= avctx->flags;
s->flags2= avctx->flags2;
@@ -641,7 +641,7 @@ static av_cold int h261_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec h261_decoder = {
+AVCodec ff_h261_decoder = {
"h261",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H261,
diff --git a/lib/ffmpeg/libavcodec/h261enc.c b/lib/ffmpeg/libavcodec/h261enc.c
index c85ee8bb05..cd282fba75 100644
--- a/lib/ffmpeg/libavcodec/h261enc.c
+++ b/lib/ffmpeg/libavcodec/h261enc.c
@@ -321,7 +321,7 @@ static void h261_encode_block(H261Context * h, DCTELEM * block, int n){
}
}
-AVCodec h261_encoder = {
+AVCodec ff_h261_encoder = {
"h261",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H261,
diff --git a/lib/ffmpeg/libavcodec/h263_parser.c b/lib/ffmpeg/libavcodec/h263_parser.c
index 16c5ea5055..e08198324b 100644
--- a/lib/ffmpeg/libavcodec/h263_parser.c
+++ b/lib/ffmpeg/libavcodec/h263_parser.c
@@ -83,7 +83,7 @@ static int h263_parse(AVCodecParserContext *s,
return next;
}
-AVCodecParser h263_parser = {
+AVCodecParser ff_h263_parser = {
{ CODEC_ID_H263 },
sizeof(ParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/h263dec.c b/lib/ffmpeg/libavcodec/h263dec.c
index d9d6f7e5d6..1c73d93405 100644
--- a/lib/ffmpeg/libavcodec/h263dec.c
+++ b/lib/ffmpeg/libavcodec/h263dec.c
@@ -25,6 +25,7 @@
* H.263 decoder.
*/
+#include "libavutil/cpu.h"
#include "internal.h"
#include "avcodec.h"
#include "dsputil.h"
@@ -260,6 +261,13 @@ static int decode_slice(MpegEncContext *s){
assert(s->mb_x==0 && s->mb_y==s->mb_height);
+ if(s->codec_id==CODEC_ID_MPEG4
+ && (s->workaround_bugs&FF_BUG_AUTODETECT)
+ && get_bits_left(&s->gb) >= 48
+ && show_bits(&s->gb, 24)==0x4010
+ && !s->data_partitioning)
+ s->padding_bug_score+=32;
+
/* try to detect the padding bug */
if( s->codec_id==CODEC_ID_MPEG4
&& (s->workaround_bugs&FF_BUG_AUTODETECT)
@@ -553,7 +561,7 @@ retry:
#endif
#if HAVE_MMX
- if(s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (mm_flags & FF_MM_MMX)){
+ if (s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
avctx->idct_algo= FF_IDCT_XVIDMMX;
avctx->coded_width= 0; // force reinit
// dsputil_init(&s->dsp, avctx);
@@ -727,7 +735,7 @@ av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time);
return get_consumed_bytes(s, buf_size);
}
-AVCodec h263_decoder = {
+AVCodec ff_h263_decoder = {
"h263",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H263,
diff --git a/lib/ffmpeg/libavcodec/h264.c b/lib/ffmpeg/libavcodec/h264.c
index fb3fc1efb6..b84430a1d7 100644
--- a/lib/ffmpeg/libavcodec/h264.c
+++ b/lib/ffmpeg/libavcodec/h264.c
@@ -1,5 +1,5 @@
/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
+ * H.26L/H.264/AVC/JVT/14496-10/... decoder
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
@@ -25,6 +25,7 @@
* @author Michael Niedermayer <michaelni@gmx.at>
*/
+#include "libavcore/imgutils.h"
#include "internal.h"
#include "dsputil.h"
#include "avcodec.h"
@@ -32,11 +33,11 @@
#include "h264.h"
#include "h264data.h"
#include "h264_mvpred.h"
-#include "h264_parser.h"
#include "golomb.h"
#include "mathops.h"
#include "rectangle.h"
#include "vdpau_internal.h"
+#include "libavutil/avassert.h"
#include "cabac.h"
@@ -231,7 +232,11 @@ nsc:
return dst;
}
-int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){
+/**
+ * Identify the exact end of the bitstream
+ * @return the length of the trailing, or 0 if damaged
+ */
+static int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){
int v= *src;
int r;
@@ -244,46 +249,6 @@ int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){
return 0;
}
-/**
- * IDCT transforms the 16 dc values and dequantizes them.
- * @param qp quantization parameter
- */
-static void h264_luma_dc_dequant_idct_c(DCTELEM *block, int qp, int qmul){
-#define stride 16
- int i;
- int temp[16]; //FIXME check if this is a good idea
- static const int x_offset[4]={0, 1*stride, 4* stride, 5*stride};
- static const int y_offset[4]={0, 2*stride, 8* stride, 10*stride};
-
-//memset(block, 64, 2*256);
-//return;
- for(i=0; i<4; i++){
- const int offset= y_offset[i];
- const int z0= block[offset+stride*0] + block[offset+stride*4];
- const int z1= block[offset+stride*0] - block[offset+stride*4];
- const int z2= block[offset+stride*1] - block[offset+stride*5];
- const int z3= block[offset+stride*1] + block[offset+stride*5];
-
- temp[4*i+0]= z0+z3;
- temp[4*i+1]= z1+z2;
- temp[4*i+2]= z1-z2;
- temp[4*i+3]= z0-z3;
- }
-
- for(i=0; i<4; i++){
- const int offset= x_offset[i];
- const int z0= temp[4*0+i] + temp[4*2+i];
- const int z1= temp[4*0+i] - temp[4*2+i];
- const int z2= temp[4*1+i] - temp[4*3+i];
- const int z3= temp[4*1+i] + temp[4*3+i];
-
- block[stride*0 +offset]= ((((z0 + z3)*qmul + 128 ) >> 8)); //FIXME think about merging this into decode_residual
- block[stride*2 +offset]= ((((z1 + z2)*qmul + 128 ) >> 8));
- block[stride*8 +offset]= ((((z1 - z2)*qmul + 128 ) >> 8));
- block[stride*10+offset]= ((((z0 - z3)*qmul + 128 ) >> 8));
- }
-}
-
#if 0
/**
* DCT transforms the 16 dc values.
@@ -327,7 +292,7 @@ static void h264_luma_dc_dct_c(DCTELEM *block/*, int qp*/){
#undef xStride
#undef stride
-static void chroma_dc_dequant_idct_c(DCTELEM *block, int qp, int qmul){
+static void chroma_dc_dequant_idct_c(DCTELEM *block, int qmul){
const int stride= 16*2;
const int xStride= 16;
int a,b,c,d,e;
@@ -396,7 +361,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
|| full_my < 0-extra_height
|| full_mx + 16/*FIXME*/ > pic_width + extra_width
|| full_my + 16/*FIXME*/ > pic_height + extra_height){
- ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*h->mb_linesize, h->mb_linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*h->mb_linesize, h->mb_linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height);
src_y= s->edge_emu_buffer + 2 + 2*h->mb_linesize;
emu=1;
}
@@ -417,13 +382,13 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
src_cr= pic->data[2] + (mx>>3) + (my>>3)*h->mb_uvlinesize;
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
src_cb= s->edge_emu_buffer;
}
chroma_op(dest_cb, src_cb, h->mb_uvlinesize, chroma_height, mx&7, my&7);
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
src_cr= s->edge_emu_buffer;
}
chroma_op(dest_cr, src_cr, h->mb_uvlinesize, chroma_height, mx&7, my&7);
@@ -652,7 +617,7 @@ static void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t
}
-static void free_tables(H264Context *h){
+static void free_tables(H264Context *h, int free_rbsp){
int i;
H264Context *hx;
av_freep(&h->intra4x4_pred_mode);
@@ -675,17 +640,18 @@ static void free_tables(H264Context *h){
av_freep(&hx->top_borders[1]);
av_freep(&hx->top_borders[0]);
av_freep(&hx->s.obmc_scratchpad);
- av_freep(&hx->rbsp_buffer[1]);
- av_freep(&hx->rbsp_buffer[0]);
- hx->rbsp_buffer_size[0] = 0;
- hx->rbsp_buffer_size[1] = 0;
+ if (free_rbsp){
+ av_freep(&hx->rbsp_buffer[1]);
+ av_freep(&hx->rbsp_buffer[0]);
+ hx->rbsp_buffer_size[0] = 0;
+ hx->rbsp_buffer_size[1] = 0;
+ }
if (i) av_freep(&h->thread_context[i]);
}
}
static void init_dequant8_coeff_table(H264Context *h){
int i,q,x;
- const int transpose = (h->h264dsp.h264_idct8_add != ff_h264_idct8_add_c); //FIXME ugly
h->dequant8_coeff[0] = h->dequant8_buffer[0];
h->dequant8_coeff[1] = h->dequant8_buffer[1];
@@ -699,7 +665,7 @@ static void init_dequant8_coeff_table(H264Context *h){
int shift = div6[q];
int idx = rem6[q];
for(x=0; x<64; x++)
- h->dequant8_coeff[i][q][transpose ? (x>>3)|((x&7)<<3) : x] =
+ h->dequant8_coeff[i][q][(x>>3)|((x&7)<<3)] =
((uint32_t)dequant8_coeff_init[idx][ dequant8_coeff_init_scan[((x>>1)&12) | (x&3)] ] *
h->pps.scaling_matrix8[i][x]) << shift;
}
@@ -708,7 +674,6 @@ static void init_dequant8_coeff_table(H264Context *h){
static void init_dequant4_coeff_table(H264Context *h){
int i,j,q,x;
- const int transpose = (h->h264dsp.h264_idct_add != ff_h264_idct_add_c); //FIXME ugly
for(i=0; i<6; i++ ){
h->dequant4_coeff[i] = h->dequant4_buffer[i];
for(j=0; j<i; j++){
@@ -724,7 +689,7 @@ static void init_dequant4_coeff_table(H264Context *h){
int shift = div6[q] + 2;
int idx = rem6[q];
for(x=0; x<16; x++)
- h->dequant4_coeff[i][q][transpose ? (x>>2)|((x<<2)&0xF) : x] =
+ h->dequant4_coeff[i][q][(x>>2)|((x<<2)&0xF)] =
((uint32_t)dequant4_coeff_init[idx][(x&1) + ((x>>2)&1)] *
h->pps.scaling_matrix4[i][x]) << shift;
}
@@ -788,7 +753,7 @@ int ff_h264_alloc_tables(H264Context *h){
return 0;
fail:
- free_tables(h);
+ free_tables(h, 1);
return -1;
}
@@ -977,7 +942,7 @@ int ff_h264_frame_start(H264Context *h){
/* can't be in alloc_tables because linesize isn't known there.
* FIXME: redo bipred weight to not require extra buffer? */
for(i = 0; i < s->avctx->thread_count; i++)
- if(!h->thread_context[i]->s.obmc_scratchpad)
+ if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize);
/* some macroblocks can be accessed before they're available in case of lost slices, mbaff or threading*/
@@ -1244,10 +1209,18 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
}else{
h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
if(is_h264){
- if(!transform_bypass)
- h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[0][s->qscale][0]);
+ if(h->non_zero_count_cache[ scan8[LUMA_DC_BLOCK_INDEX] ]){
+ if(!transform_bypass)
+ h->h264dsp.h264_luma_dc_dequant_idct(h->mb, h->mb_luma_dc, h->dequant4_coeff[0][s->qscale][0]);
+ else{
+ static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16,
+ 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16};
+ for(i = 0; i < 16; i++)
+ h->mb[dc_mapping[i]] = h->mb_luma_dc[i];
+ }
+ }
}else
- ff_svq3_luma_dc_dequant_idct_c(h->mb, s->qscale);
+ ff_svq3_luma_dc_dequant_idct_c(h->mb, h->mb_luma_dc, s->qscale);
}
if(h->deblocking_filter)
xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, simple);
@@ -1315,18 +1288,17 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
}
}
}else{
- chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp[0], h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
- chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp[1], h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
if(is_h264){
- idct_add = h->h264dsp.h264_idct_add;
- idct_dc_add = h->h264dsp.h264_idct_dc_add;
- for(i=16; i<16+8; i++){
- if(h->non_zero_count_cache[ scan8[i] ])
- idct_add (dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize);
- else if(h->mb[i*16])
- idct_dc_add(dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize);
- }
+ if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ])
+ chroma_dc_dequant_idct_c(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
+ if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ])
+ chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
+ h->h264dsp.h264_idct_add8(dest, block_offset,
+ h->mb, uvlinesize,
+ h->non_zero_count_cache);
}else{
+ chroma_dc_dequant_idct_c(h->mb + 16*16 , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
+ chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
for(i=16; i<16+8; i++){
if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i];
@@ -1374,7 +1346,8 @@ static int pred_weight_table(H264Context *h){
h->use_weight= 0;
h->use_weight_chroma= 0;
h->luma_log2_weight_denom= get_ue_golomb(&s->gb);
- h->chroma_log2_weight_denom= get_ue_golomb(&s->gb);
+ if(CHROMA)
+ h->chroma_log2_weight_denom= get_ue_golomb(&s->gb);
luma_def = 1<<h->luma_log2_weight_denom;
chroma_def = 1<<h->chroma_log2_weight_denom;
@@ -1599,31 +1572,19 @@ static int init_poc(H264Context *h){
*/
static void init_scan_tables(H264Context *h){
int i;
- if(h->h264dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly
- memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
- memcpy(h-> field_scan, field_scan, 16*sizeof(uint8_t));
- }else{
- for(i=0; i<16; i++){
+ for(i=0; i<16; i++){
#define T(x) (x>>2) | ((x<<2) & 0xF)
- h->zigzag_scan[i] = T(zigzag_scan[i]);
- h-> field_scan[i] = T( field_scan[i]);
+ h->zigzag_scan[i] = T(zigzag_scan[i]);
+ h-> field_scan[i] = T( field_scan[i]);
#undef T
- }
}
- if(h->h264dsp.h264_idct8_add == ff_h264_idct8_add_c){
- memcpy(h->zigzag_scan8x8, ff_zigzag_direct, 64*sizeof(uint8_t));
- memcpy(h->zigzag_scan8x8_cavlc, zigzag_scan8x8_cavlc, 64*sizeof(uint8_t));
- memcpy(h->field_scan8x8, field_scan8x8, 64*sizeof(uint8_t));
- memcpy(h->field_scan8x8_cavlc, field_scan8x8_cavlc, 64*sizeof(uint8_t));
- }else{
- for(i=0; i<64; i++){
+ for(i=0; i<64; i++){
#define T(x) (x>>3) | ((x&7)<<3)
- h->zigzag_scan8x8[i] = T(ff_zigzag_direct[i]);
- h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
- h->field_scan8x8[i] = T(field_scan8x8[i]);
- h->field_scan8x8_cavlc[i] = T(field_scan8x8_cavlc[i]);
+ h->zigzag_scan8x8[i] = T(ff_zigzag_direct[i]);
+ h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
+ h->field_scan8x8[i] = T(field_scan8x8[i]);
+ h->field_scan8x8_cavlc[i] = T(field_scan8x8_cavlc[i]);
#undef T
- }
}
if(h->sps.transform_bypass){ //FIXME same ugly
h->zigzag_scan_q0 = zigzag_scan;
@@ -1717,6 +1678,33 @@ static void clone_slice(H264Context *dst, H264Context *src)
}
/**
+ * computes profile from profile_idc and constraint_set?_flags
+ *
+ * @param sps SPS
+ *
+ * @return profile as defined by FF_PROFILE_H264_*
+ */
+int ff_h264_get_profile(SPS *sps)
+{
+ int profile = sps->profile_idc;
+
+ switch(sps->profile_idc) {
+ case FF_PROFILE_H264_BASELINE:
+ // constraint_set1_flag set to 1
+ profile |= (sps->constraint_set_flags & 1<<1) ? FF_PROFILE_H264_CONSTRAINED : 0;
+ break;
+ case FF_PROFILE_H264_HIGH_10:
+ case FF_PROFILE_H264_HIGH_422:
+ case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+ // constraint_set3_flag set to 1
+ profile |= (sps->constraint_set_flags & 1<<3) ? FF_PROFILE_H264_INTRA : 0;
+ break;
+ }
+
+ return profile;
+}
+
+/**
* decodes a slice header.
* This will also call MPV_common_init() and frame_start() as needed.
*
@@ -1795,7 +1783,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
}
h->sps = *h0->sps_buffers[h->pps.sps_id];
- s->avctx->profile = h->sps.profile_idc;
+ s->avctx->profile = ff_h264_get_profile(&h->sps);
s->avctx->level = h->sps.level_idc;
s->avctx->refs = h->sps.ref_frame_count;
@@ -1813,14 +1801,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
if(h->sps.frame_mbs_only_flag)
s->height= 16*s->mb_height - 2*FFMIN(h->sps.crop_bottom, 7);
else
- s->height= 16*s->mb_height - 4*FFMIN(h->sps.crop_bottom, 3);
+ s->height= 16*s->mb_height - 4*FFMIN(h->sps.crop_bottom, 7);
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height
|| av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {
if(h != h0)
return -1; // width / height changed during parallelized decoding
- free_tables(h);
+ free_tables(h, 0);
flush_dpb(s->avctx);
MPV_common_end(s);
}
@@ -1830,8 +1818,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
avcodec_set_dimensions(s->avctx, s->width, s->height);
s->avctx->sample_aspect_ratio= h->sps.sar;
- if(!s->avctx->sample_aspect_ratio.den)
- s->avctx->sample_aspect_ratio.den = 1;
+ av_assert0(s->avctx->sample_aspect_ratio.den);
if(h->sps.video_signal_type_present_flag){
s->avctx->color_range = h->sps.full_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
@@ -1902,6 +1889,7 @@ 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<<h->sps.log2_max_frame_num)){
+ Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
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;
@@ -1910,6 +1898,21 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
s->current_picture_ptr->frame_num= h->prev_frame_num;
ff_generate_sliding_window_mmcos(h);
ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
+ /* Error concealment: if a ref is missing, copy the previous ref in its place.
+ * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions
+ * about there being no actual duplicates.
+ * FIXME: this doesn't copy padding for out-of-frame motion vectors. Given we're
+ * concealing a lost frame, this probably isn't noticable by comparison, but it should
+ * be fixed. */
+ if (h->short_ref_count) {
+ if (prev) {
+ av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize,
+ (const uint8_t**)prev->data, prev->linesize,
+ s->avctx->pix_fmt, s->mb_width*16, s->mb_height*16);
+ h->short_ref[0]->poc = prev->poc+2;
+ }
+ h->short_ref[0]->frame_num = h->prev_frame_num;
+ }
}
/* See if we have a decoded first field looking for a pair... */
@@ -2771,14 +2774,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
nalsize = 0;
for(i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | buf[buf_index++];
- if(nalsize <= 1 || nalsize > buf_size - buf_index){
- if(nalsize == 1){
- buf_index++;
- continue;
- }else{
- av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
- break;
- }
+ if(nalsize <= 0 || nalsize > buf_size - buf_index){
+ av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
+ break;
}
next_avc= buf_index + nalsize;
} else {
@@ -2978,6 +2976,7 @@ static int decode_frame(AVCodecContext *avctx,
s->flags2= avctx->flags2;
/* end of stream, output what is still in the buffers */
+ out:
if (buf_size == 0) {
Picture *out;
int i, out_idx;
@@ -3006,6 +3005,11 @@ static int decode_frame(AVCodecContext *avctx,
if(buf_index < 0)
return -1;
+ if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
+ buf_size = 0;
+ goto out;
+ }
+
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
@@ -3359,7 +3363,7 @@ av_cold void ff_h264_free_context(H264Context *h)
{
int i;
- free_tables(h); //FIXME cleanup init stuff perhaps
+ free_tables(h, 1); //FIXME cleanup init stuff perhaps
for(i = 0; i < MAX_SPS_COUNT; i++)
av_freep(h->sps_buffers + i);
@@ -3383,18 +3387,22 @@ av_cold int ff_h264_decode_end(AVCodecContext *avctx)
}
static const AVProfile profiles[] = {
- { FF_PROFILE_H264_BASELINE, "Baseline" },
- { FF_PROFILE_H264_MAIN, "Main" },
- { FF_PROFILE_H264_EXTENDED, "Extended" },
- { FF_PROFILE_H264_HIGH, "High" },
- { FF_PROFILE_H264_HIGH_10, "High 10" },
- { FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
- { FF_PROFILE_H264_HIGH_444, "High 4:4:4" },
- { FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" },
+ { FF_PROFILE_H264_BASELINE, "Baseline" },
+ { FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
+ { FF_PROFILE_H264_MAIN, "Main" },
+ { FF_PROFILE_H264_EXTENDED, "Extended" },
+ { FF_PROFILE_H264_HIGH, "High" },
+ { FF_PROFILE_H264_HIGH_10, "High 10" },
+ { FF_PROFILE_H264_HIGH_10_INTRA, "High 10 Intra" },
+ { FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
+ { FF_PROFILE_H264_HIGH_422_INTRA, "High 4:2:2 Intra" },
+ { FF_PROFILE_H264_HIGH_444_PREDICTIVE, "High 4:4:4 Predictive" },
+ { FF_PROFILE_H264_HIGH_444_INTRA, "High 4:4:4 Intra" },
+ { FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" },
{ FF_PROFILE_UNKNOWN },
};
-AVCodec h264_decoder = {
+AVCodec ff_h264_decoder = {
"h264",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H264,
@@ -3406,11 +3414,11 @@ AVCodec h264_decoder = {
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush= flush_dpb,
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
- .profiles = profiles,
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};
#if CONFIG_H264_VDPAU_DECODER
-AVCodec h264_vdpau_decoder = {
+AVCodec ff_h264_vdpau_decoder = {
"h264_vdpau",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H264,
@@ -3423,6 +3431,6 @@ AVCodec h264_vdpau_decoder = {
.flush= flush_dpb,
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"),
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE},
- .profiles = profiles,
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};
#endif
diff --git a/lib/ffmpeg/libavcodec/h264.h b/lib/ffmpeg/libavcodec/h264.h
index 7158d9748e..b403968485 100644
--- a/lib/ffmpeg/libavcodec/h264.h
+++ b/lib/ffmpeg/libavcodec/h264.h
@@ -39,8 +39,8 @@
#define interlaced_dct interlaced_dct_is_a_bad_name
#define mb_intra mb_intra_is_not_initialized_see_mb_type
-#define LUMA_DC_BLOCK_INDEX 25
-#define CHROMA_DC_BLOCK_INDEX 26
+#define LUMA_DC_BLOCK_INDEX 24
+#define CHROMA_DC_BLOCK_INDEX 25
#define CHROMA_DC_COEFF_TOKEN_VLC_BITS 8
#define COEFF_TOKEN_VLC_BITS 8
@@ -209,6 +209,7 @@ typedef struct SPS{
int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
int residual_color_transform_flag; ///< residual_colour_transform_flag
+ int constraint_set_flags; ///< constraint_set[0-3]_flag
}SPS;
/**
@@ -406,6 +407,7 @@ typedef struct H264Context{
GetBitContext *inter_gb_ptr;
DECLARE_ALIGNED(16, DCTELEM, mb)[16*24];
+ DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[16];
DCTELEM mb_padding[256]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb
/**
@@ -600,10 +602,6 @@ typedef struct H264Context{
extern const uint8_t ff_h264_chroma_qp[52];
-void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp);
-
-void ff_svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
-
/**
* Decode SEI
*/
@@ -615,6 +613,11 @@ int ff_h264_decode_sei(H264Context *h);
int ff_h264_decode_seq_parameter_set(H264Context *h);
/**
+ * compute profile from sps
+ */
+int ff_h264_get_profile(SPS *sps);
+
+/**
* Decode PPS
*/
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
@@ -629,12 +632,6 @@ 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);
/**
- * 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);
-
-/**
* 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);
@@ -725,8 +722,20 @@ o-o o-o
/ / /
o-o o-o
*/
+
+/* Scan8 organization:
+ * 0 1 2 3 4 5 6 7
+ * 0 u u y y y y y
+ * 1 u U U y Y Y Y Y
+ * 2 u U U y Y Y Y Y
+ * 3 v v y Y Y Y Y
+ * 4 v V V y Y Y Y Y
+ * 5 v V V DYDUDV
+ * DY/DU/DV are for luma/chroma DC.
+ */
+
//This table must be here because scan8[constant] must be known at compiletime
-static const uint8_t scan8[16 + 2*4]={
+static const uint8_t scan8[16 + 2*4 + 3]={
4+1*8, 5+1*8, 4+2*8, 5+2*8,
6+1*8, 7+1*8, 6+2*8, 7+2*8,
4+3*8, 5+3*8, 4+4*8, 5+4*8,
@@ -735,6 +744,7 @@ static const uint8_t scan8[16 + 2*4]={
1+2*8, 2+2*8,
1+4*8, 2+4*8,
1+5*8, 2+5*8,
+ 4+5*8, 5+5*8, 6+5*8
};
static av_always_inline uint32_t pack16to32(int a, int b){
diff --git a/lib/ffmpeg/libavcodec/h264_cabac.c b/lib/ffmpeg/libavcodec/h264_cabac.c
index 485837879d..c83a7c7678 100644
--- a/lib/ffmpeg/libavcodec/h264_cabac.c
+++ b/lib/ffmpeg/libavcodec/h264_cabac.c
@@ -965,6 +965,7 @@ static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx,
nza = h->left_cbp&0x100;
nzb = h-> top_cbp&0x100;
} else {
+ idx -= CHROMA_DC_BLOCK_INDEX;
nza = (h->left_cbp>>(6+idx))&0x01;
nzb = (h-> top_cbp>>(6+idx))&0x01;
}
@@ -1048,30 +1049,6 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT
#define CC &h->cabac
#endif
-
- /* cat: 0-> DC 16x16 n = 0
- * 1-> AC 16x16 n = luma4x4idx
- * 2-> Luma4x4 n = luma4x4idx
- * 3-> DC Chroma n = iCbCr
- * 4-> AC Chroma n = 16 + 4 * iCbCr + chroma4x4idx
- * 5-> Luma8x8 n = 4 * luma8x8idx
- */
-
- /* read coded block flag */
- if( is_dc || cat != 5 ) {
- if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, is_dc ) ] ) == 0 ) {
- if( !is_dc )
- h->non_zero_count_cache[scan8[n]] = 0;
-
-#ifdef CABAC_ON_STACK
- h->cabac.range = cc.range ;
- h->cabac.low = cc.low ;
- h->cabac.bytestream= cc.bytestream;
-#endif
- return;
- }
- }
-
significant_coeff_ctx_base = h->cabac_state
+ significant_coeff_flag_offset[MB_FIELD][cat];
last_coeff_ctx_base = h->cabac_state
@@ -1112,7 +1089,8 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT
if( cat == 0 )
h->cbp_table[h->mb_xy] |= 0x100;
else
- h->cbp_table[h->mb_xy] |= 0x40 << n;
+ h->cbp_table[h->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX);
+ h->non_zero_count_cache[scan8[n]] = coeff_count;
} else {
if( cat == 5 )
fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
@@ -1171,14 +1149,44 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT
}
-static void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
+static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1);
}
-static void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
+static void decode_cabac_residual_nondc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0);
}
+/* cat: 0-> DC 16x16 n = 0
+ * 1-> AC 16x16 n = luma4x4idx
+ * 2-> Luma4x4 n = luma4x4idx
+ * 3-> DC Chroma n = iCbCr
+ * 4-> AC Chroma n = 16 + 4 * iCbCr + chroma4x4idx
+ * 5-> Luma8x8 n = 4 * luma8x8idx */
+
+/* Partially inline the CABAC residual decode: inline the coded block flag.
+ * This has very little impact on binary size and improves performance
+ * because it allows improved constant propagation into get_cabac_cbf_ctx,
+ * as well as because most blocks have zero CBFs. */
+
+static av_always_inline void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
+ /* read coded block flag */
+ if( get_cabac( &h->cabac, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, 1 ) ] ) == 0 ) {
+ h->non_zero_count_cache[scan8[n]] = 0;
+ return;
+ }
+ decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff );
+}
+
+static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
+ /* read coded block flag */
+ if( cat != 5 && get_cabac( &h->cabac, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, 0 ) ] ) == 0 ) {
+ h->non_zero_count_cache[scan8[n]] = 0;
+ return;
+ }
+ decode_cabac_residual_nondc_internal( h, block, cat, n, scantable, qmul, max_coeff );
+}
+
/**
* decodes a macroblock
* @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
@@ -1365,6 +1373,8 @@ decode_intra_mb:
pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode );
if( pred_mode < 0 ) return -1;
h->chroma_pred_mode= pred_mode;
+ } else {
+ h->chroma_pred_mode= DC_128_PRED8x8;
}
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
@@ -1597,17 +1607,15 @@ decode_intra_mb:
s->current_picture.mb_type[mb_xy]= mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
- const uint8_t *scan, *scan8x8, *dc_scan;
+ const uint8_t *scan, *scan8x8;
const uint32_t *qmul;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
- dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- dc_scan= luma_dc_zigzag_scan;
}
// decode_cabac_mb_dqp
@@ -1642,7 +1650,9 @@ decode_intra_mb:
if( IS_INTRA16x16( mb_type ) ) {
int i;
//av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" );
- decode_cabac_residual_dc( h, h->mb, 0, 0, dc_scan, 16);
+ AV_ZERO128(h->mb_luma_dc+0);
+ AV_ZERO128(h->mb_luma_dc+8);
+ decode_cabac_residual_dc( h, h->mb_luma_dc, 0, LUMA_DC_BLOCK_INDEX, scan, 16);
if( cbp&15 ) {
qmul = h->dequant4_coeff[0][s->qscale];
@@ -1681,7 +1691,7 @@ decode_intra_mb:
int c;
for( c = 0; c < 2; c++ ) {
//av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
- decode_cabac_residual_dc(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, 4);
+ decode_cabac_residual_dc(h, h->mb + 256 + 16*4*c, 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
}
}
diff --git a/lib/ffmpeg/libavcodec/h264_cavlc.c b/lib/ffmpeg/libavcodec/h264_cavlc.c
index 0475e9454a..63d2b3ca34 100644
--- a/lib/ffmpeg/libavcodec/h264_cavlc.c
+++ b/lib/ffmpeg/libavcodec/h264_cavlc.c
@@ -367,11 +367,11 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
MpegEncContext * const s = &h->s;
static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};
int level[16];
- int zeros_left, coeff_num, coeff_token, total_coeff, i, j, trailing_ones, run_before;
+ int zeros_left, coeff_token, total_coeff, i, trailing_ones, run_before;
//FIXME put trailing_onex into the context
- if(n == CHROMA_DC_BLOCK_INDEX){
+ if(n >= CHROMA_DC_BLOCK_INDEX){
coeff_token= get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1);
total_coeff= coeff_token>>2;
}else{
@@ -383,9 +383,9 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
total_coeff= pred_non_zero_count(h, n);
coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2);
total_coeff= coeff_token>>2;
- h->non_zero_count_cache[ scan8[n] ]= total_coeff;
}
}
+ h->non_zero_count_cache[ scan8[n] ]= total_coeff;
//FIXME set last_non_zero?
@@ -482,45 +482,42 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
if(total_coeff == max_coeff)
zeros_left=0;
else{
- if(n == CHROMA_DC_BLOCK_INDEX)
+ if(n >= CHROMA_DC_BLOCK_INDEX)
zeros_left= get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[ total_coeff ].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1);
else
zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1);
}
- coeff_num = zeros_left + total_coeff - 1;
- j = scantable[coeff_num];
- if(n > 24){
- block[j] = level[0];
- for(i=1;i<total_coeff;i++) {
- if(zeros_left <= 0)
- run_before = 0;
- else if(zeros_left < 7){
+ scantable += zeros_left + total_coeff - 1;
+ if(n >= LUMA_DC_BLOCK_INDEX){
+ block[*scantable] = level[0];
+ for(i=1;i<total_coeff && zeros_left > 0;i++) {
+ if(zeros_left < 7)
run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1);
- }else{
+ else
run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2);
- }
zeros_left -= run_before;
- coeff_num -= 1 + run_before;
- j= scantable[ coeff_num ];
-
- block[j]= level[i];
+ scantable -= 1 + run_before;
+ block[*scantable]= level[i];
+ }
+ for(;i<total_coeff;i++) {
+ scantable--;
+ block[*scantable]= level[i];
}
}else{
- block[j] = (level[0] * qmul[j] + 32)>>6;
- for(i=1;i<total_coeff;i++) {
- if(zeros_left <= 0)
- run_before = 0;
- else if(zeros_left < 7){
+ block[*scantable] = (level[0] * qmul[*scantable] + 32)>>6;
+ for(i=1;i<total_coeff && zeros_left > 0;i++) {
+ if(zeros_left < 7)
run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1);
- }else{
+ else
run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2);
- }
zeros_left -= run_before;
- coeff_num -= 1 + run_before;
- j= scantable[ coeff_num ];
-
- block[j]= (level[i] * qmul[j] + 32)>>6;
+ scantable -= 1 + run_before;
+ block[*scantable]= (level[i] * qmul[*scantable] + 32)>>6;
+ }
+ for(;i<total_coeff;i++) {
+ scantable--;
+ block[*scantable]= (level[i] * qmul[*scantable] + 32)>>6;
}
}
@@ -668,6 +665,8 @@ decode_intra_mb:
if(pred_mode < 0)
return -1;
h->chroma_pred_mode= pred_mode;
+ } else {
+ h->chroma_pred_mode = DC_128_PRED8x8;
}
}else if(partition_count==4){
int i, j, sub_partition_count[4], list, ref[2][4];
@@ -914,16 +913,14 @@ decode_intra_mb:
int i8x8, i4x4, chroma_idx;
int dquant;
GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr;
- const uint8_t *scan, *scan8x8, *dc_scan;
+ const uint8_t *scan, *scan8x8;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
- dc_scan= luma_dc_field_scan;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- dc_scan= luma_dc_zigzag_scan;
}
dquant= get_se_golomb(&s->gb);
@@ -942,7 +939,9 @@ decode_intra_mb:
h->chroma_qp[0]= get_chroma_qp(h, 0, s->qscale);
h->chroma_qp[1]= get_chroma_qp(h, 1, s->qscale);
if(IS_INTRA16x16(mb_type)){
- if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, h->dequant4_coeff[0][s->qscale], 16) < 0){
+ AV_ZERO128(h->mb_luma_dc+0);
+ AV_ZERO128(h->mb_luma_dc+8);
+ if( decode_residual(h, h->intra_gb_ptr, h->mb_luma_dc, LUMA_DC_BLOCK_INDEX, scan, h->dequant4_coeff[0][s->qscale], 16) < 0){
return -1; //FIXME continue if partitioned and other return -1 too
}
@@ -991,7 +990,7 @@ decode_intra_mb:
if(cbp&0x30){
for(chroma_idx=0; chroma_idx<2; chroma_idx++)
- if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, NULL, 4) < 0){
+ if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){
return -1;
}
}
diff --git a/lib/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c b/lib/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c
index e2ee10a030..d4a7f31937 100644
--- a/lib/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c
+++ b/lib/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c
@@ -169,7 +169,7 @@ fail:
return AVERROR(EINVAL);
}
-AVBitStreamFilter h264_mp4toannexb_bsf = {
+AVBitStreamFilter ff_h264_mp4toannexb_bsf = {
"h264_mp4toannexb",
sizeof(H264BSFContext),
h264_mp4toannexb_filter,
diff --git a/lib/ffmpeg/libavcodec/h264_parser.c b/lib/ffmpeg/libavcodec/h264_parser.c
index 890e0a8930..c5728e2678 100644
--- a/lib/ffmpeg/libavcodec/h264_parser.c
+++ b/lib/ffmpeg/libavcodec/h264_parser.c
@@ -26,14 +26,13 @@
*/
#include "parser.h"
-#include "h264_parser.h"
#include "h264data.h"
#include "golomb.h"
#include <assert.h>
-int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size)
+static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size)
{
int i;
uint32_t state;
@@ -127,6 +126,9 @@ static inline int parse_nal_units(AVCodecParserContext *s,
h->sei_cpb_removal_delay = -1;
h->sei_buffering_period_present = 0;
+ if (!buf_size)
+ return 0;
+
for(;;) {
int src_length, dst_length, consumed;
buf = ff_find_start_code(buf, buf_end, &state);
@@ -185,7 +187,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
h->sps = *h->sps_buffers[h->pps.sps_id];
h->frame_num = get_bits(&h->s.gb, h->sps.log2_max_frame_num);
- avctx->profile = h->sps.profile_idc;
+ avctx->profile = ff_h264_get_profile(&h->sps);
avctx->level = h->sps.level_idc;
if(h->sps.frame_mbs_only_flag){
@@ -330,7 +332,7 @@ static int init(AVCodecParserContext *s)
return 0;
}
-AVCodecParser h264_parser = {
+AVCodecParser ff_h264_parser = {
{ CODEC_ID_H264 },
sizeof(H264Context),
init,
diff --git a/lib/ffmpeg/libavcodec/h264_ps.c b/lib/ffmpeg/libavcodec/h264_ps.c
index 7648e2c7a6..3fe5815ea6 100644
--- a/lib/ffmpeg/libavcodec/h264_ps.c
+++ b/lib/ffmpeg/libavcodec/h264_ps.c
@@ -25,6 +25,7 @@
* @author Michael Niedermayer <michaelni@gmx.at>
*/
+#include "libavcore/imgutils.h"
#include "internal.h"
#include "dsputil.h"
#include "avcodec.h"
@@ -266,16 +267,16 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s
int ff_h264_decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
- int profile_idc, level_idc;
+ int profile_idc, level_idc, constraint_set_flags = 0;
unsigned int sps_id;
int i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
- get_bits1(&s->gb); //constraint_set0_flag
- get_bits1(&s->gb); //constraint_set1_flag
- get_bits1(&s->gb); //constraint_set2_flag
- get_bits1(&s->gb); //constraint_set3_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 0; //constraint_set0_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 1; //constraint_set1_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 2; //constraint_set2_flag
+ constraint_set_flags |= get_bits1(&s->gb) << 3; //constraint_set3_flag
get_bits(&s->gb, 4); // reserved
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb_31(&s->gb);
@@ -288,7 +289,9 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
if(sps == NULL)
return -1;
+ sps->time_offset_length = 24;
sps->profile_idc= profile_idc;
+ sps->constraint_set_flags = constraint_set_flags;
sps->level_idc= level_idc;
memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
@@ -341,7 +344,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
sps->mb_width = get_ue_golomb(&s->gb) + 1;
sps->mb_height= get_ue_golomb(&s->gb) + 1;
if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
- avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height)){
+ av_image_check_size(16*sps->mb_width, 16*sps->mb_height, 0, h->s.avctx)){
av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
goto fail;
}
@@ -371,7 +374,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
if(sps->crop_left || sps->crop_top){
av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n");
}
- if(sps->crop_right >= 8 || sps->crop_bottom >= (8>> !sps->frame_mbs_only_flag)){
+ if(sps->crop_right >= 8 || sps->crop_bottom >= 8){
av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n");
}
}else{
@@ -386,6 +389,9 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
if (decode_vui_parameters(h, sps) < 0)
goto fail;
+ if(!sps->sar.den)
+ sps->sar.den= 1;
+
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n",
sps_id, sps->profile_idc, sps->level_idc,
diff --git a/lib/ffmpeg/libavcodec/h264dsp.c b/lib/ffmpeg/libavcodec/h264dsp.c
index c01fc77c00..c3ee06d9df 100644
--- a/lib/ffmpeg/libavcodec/h264dsp.c
+++ b/lib/ffmpeg/libavcodec/h264dsp.c
@@ -282,6 +282,7 @@ void ff_h264dsp_init(H264DSPContext *c)
c->h264_idct8_add4 = ff_h264_idct8_add4_c;
c->h264_idct_add8 = ff_h264_idct_add8_c;
c->h264_idct_add16intra= ff_h264_idct_add16intra_c;
+ c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_c;
c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c;
c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c;
diff --git a/lib/ffmpeg/libavcodec/h264dsp.h b/lib/ffmpeg/libavcodec/h264dsp.h
index 3d32a9c18f..2491c90bbb 100644
--- a/lib/ffmpeg/libavcodec/h264dsp.h
+++ b/lib/ffmpeg/libavcodec/h264dsp.h
@@ -57,19 +57,17 @@ typedef struct H264DSPContext{
int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field);
/* IDCT */
- /* NOTE!!! if you implement any of h264_idct8_add, h264_idct8_add4 then you must implement all of them
- NOTE!!! if you implement any of h264_idct_add, h264_idct_add16, h264_idct_add16intra, h264_idct_add8 then you must implement all of them
- The reason for above, is that no 2 out of one list may use a different permutation.
- */
void (*h264_idct_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride);
void (*h264_idct8_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride);
void (*h264_idct_dc_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride);
void (*h264_idct8_dc_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride);
+
void (*h264_dct)(DCTELEM block[4][4]);
void (*h264_idct_add16)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
void (*h264_idct8_add4)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
void (*h264_idct_add8)(uint8_t **dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
+ void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul);
}H264DSPContext;
void ff_h264dsp_init(H264DSPContext *c);
diff --git a/lib/ffmpeg/libavcodec/h264dspenc.c b/lib/ffmpeg/libavcodec/h264dspenc.c
deleted file mode 100644
index b65a2cc4a2..0000000000
--- a/lib/ffmpeg/libavcodec/h264dspenc.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * H.264/MPEG-4 Part 10 (Base profile) encoder.
- *
- * DSP functions
- *
- * Copyright (c) 2006 Expertisecentrum Digitale Media, UHasselt
- *
- * 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
- * H.264 encoder related DSP utils
- *
- */
-
-#include "dsputil.h"
-
-#define H264_DCT_PART1(X) \
- a = block[0][X]+block[3][X]; \
- c = block[0][X]-block[3][X]; \
- b = block[1][X]+block[2][X]; \
- d = block[1][X]-block[2][X]; \
- pieces[0][X] = a+b; \
- pieces[2][X] = a-b; \
- pieces[1][X] = (c<<1)+d; \
- pieces[3][X] = c-(d<<1);
-
-#define H264_DCT_PART2(X) \
- a = pieces[X][0]+pieces[X][3]; \
- c = pieces[X][0]-pieces[X][3]; \
- b = pieces[X][1]+pieces[X][2]; \
- d = pieces[X][1]-pieces[X][2]; \
- block[0][X] = a+b; \
- block[2][X] = a-b; \
- block[1][X] = (c<<1)+d; \
- block[3][X] = c-(d<<1);
-
-/**
- * Transform the provided matrix using the H.264 modified DCT.
- * @note
- * we'll always work with transposed input blocks, to avoid having to make a
- * distinction between C and mmx implementations.
- *
- * @param block transposed input block
- */
-static void h264_dct_c(DCTELEM block[4][4])
-{
- DCTELEM pieces[4][4];
- DCTELEM a, b, c, d;
-
- H264_DCT_PART1(0);
- H264_DCT_PART1(1);
- H264_DCT_PART1(2);
- H264_DCT_PART1(3);
- H264_DCT_PART2(0);
- H264_DCT_PART2(1);
- H264_DCT_PART2(2);
- H264_DCT_PART2(3);
-}
-
-av_cold void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx)
-{
- c->h264_dct = h264_dct_c;
-}
-
diff --git a/lib/ffmpeg/libavcodec/h264enc.c b/lib/ffmpeg/libavcodec/h264enc.c
deleted file mode 100644
index ad874f3624..0000000000
--- a/lib/ffmpeg/libavcodec/h264enc.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * H.264 encoder
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#include "libavutil/common.h"
-#include "get_bits.h"
-#include "mpegvideo.h"
-#include "h264data.h"
-
-/**
- * Write out the provided data into a NAL unit.
- * @param nal_ref_idc NAL reference IDC
- * @param nal_unit_type NAL unit payload type
- * @param dest the target buffer, dst+1 == src is allowed as a special case
- * @param destsize the length of the dst array
- * @param b2 the data which should be escaped
- * @return pointer to current position in the output buffer or NULL if an error occurred
- */
-static uint8_t *h264_write_nal_unit(int nal_ref_idc, int nal_unit_type, uint8_t *dest, int *destsize,
- PutBitContext *b2)
-{
- PutBitContext b;
- int i, destpos, rbsplen, escape_count;
- uint8_t *rbsp;
-
- if (nal_unit_type != NAL_END_STREAM)
- put_bits(b2,1,1); // rbsp_stop_bit
-
- // Align b2 on a byte boundary
- align_put_bits(b2);
- rbsplen = put_bits_count(b2)/8;
- flush_put_bits(b2);
- rbsp = b2->buf;
-
- init_put_bits(&b,dest,*destsize);
-
- put_bits(&b,16,0);
- put_bits(&b,16,0x01);
-
- put_bits(&b,1,0); // forbidden zero bit
- put_bits(&b,2,nal_ref_idc); // nal_ref_idc
- put_bits(&b,5,nal_unit_type); // nal_unit_type
-
- flush_put_bits(&b);
-
- destpos = 5;
- escape_count= 0;
-
- for (i=0; i<rbsplen; i+=2)
- {
- if (rbsp[i]) continue;
- if (i>0 && rbsp[i-1]==0)
- i--;
- if (i+2<rbsplen && rbsp[i+1]==0 && rbsp[i+2]<=3)
- {
- escape_count++;
- i+=2;
- }
- }
-
- if(escape_count==0)
- {
- if(dest+destpos != rbsp)
- {
- memcpy(dest+destpos, rbsp, rbsplen);
- *destsize -= (rbsplen+destpos);
- }
- return dest+rbsplen+destpos;
- }
-
- if(rbsplen + escape_count + 1> *destsize)
- {
- av_log(NULL, AV_LOG_ERROR, "Destination buffer too small!\n");
- return NULL;
- }
-
- // this should be damn rare (hopefully)
- for (i = 0 ; i < rbsplen ; i++)
- {
- if (i + 2 < rbsplen && (rbsp[i] == 0 && rbsp[i+1] == 0 && rbsp[i+2] < 4))
- {
- dest[destpos++] = rbsp[i++];
- dest[destpos++] = rbsp[i];
- dest[destpos++] = 0x03; // emulation prevention byte
- }
- else
- dest[destpos++] = rbsp[i];
- }
- *destsize -= destpos;
- return dest+destpos;
-}
-
-static const uint8_t pict_type_to_golomb[7] = {-1, 2, 0, 1, -1, 4, 3};
-
-static const uint8_t intra4x4_cbp_to_golomb[48] = {
- 3, 29, 30, 17, 31, 18, 37, 8, 32, 38, 19, 9, 20, 10, 11, 2,
- 16, 33, 34, 21, 35, 22, 39, 4, 36, 40, 23, 5, 24, 6, 7, 1,
- 41, 42, 43, 25, 44, 26, 46, 12, 45, 47, 27, 13, 28, 14, 15, 0
-};
-
-static const uint8_t inter_cbp_to_golomb[48] = {
- 0, 2, 3, 7, 4, 8, 17, 13, 5, 18, 9, 14, 10, 15, 16, 11,
- 1, 32, 33, 36, 34, 37, 44, 40, 35, 45, 38, 41, 39, 42, 43, 19,
- 6, 24, 25, 20, 26, 21, 46, 28, 27, 47, 22, 29, 23, 30, 31, 12
-};
-
-#define QUANT_SHIFT 22
-
-static const int quant_coeff[52][16] = {
- { 419430, 258111, 419430, 258111, 258111, 167772, 258111, 167772, 419430, 258111, 419430, 258111, 258111, 167772, 258111, 167772,},
- { 381300, 239675, 381300, 239675, 239675, 149131, 239675, 149131, 381300, 239675, 381300, 239675, 239675, 149131, 239675, 149131,},
- { 322639, 209715, 322639, 209715, 209715, 134218, 209715, 134218, 322639, 209715, 322639, 209715, 209715, 134218, 209715, 134218,},
- { 299593, 186414, 299593, 186414, 186414, 116711, 186414, 116711, 299593, 186414, 299593, 186414, 186414, 116711, 186414, 116711,},
- { 262144, 167772, 262144, 167772, 167772, 107374, 167772, 107374, 262144, 167772, 262144, 167772, 167772, 107374, 167772, 107374,},
- { 233017, 145889, 233017, 145889, 145889, 92564, 145889, 92564, 233017, 145889, 233017, 145889, 145889, 92564, 145889, 92564,},
- { 209715, 129056, 209715, 129056, 129056, 83886, 129056, 83886, 209715, 129056, 209715, 129056, 129056, 83886, 129056, 83886,},
- { 190650, 119837, 190650, 119837, 119837, 74565, 119837, 74565, 190650, 119837, 190650, 119837, 119837, 74565, 119837, 74565,},
- { 161319, 104858, 161319, 104858, 104858, 67109, 104858, 67109, 161319, 104858, 161319, 104858, 104858, 67109, 104858, 67109,},
- { 149797, 93207, 149797, 93207, 93207, 58356, 93207, 58356, 149797, 93207, 149797, 93207, 93207, 58356, 93207, 58356,},
- { 131072, 83886, 131072, 83886, 83886, 53687, 83886, 53687, 131072, 83886, 131072, 83886, 83886, 53687, 83886, 53687,},
- { 116508, 72944, 116508, 72944, 72944, 46282, 72944, 46282, 116508, 72944, 116508, 72944, 72944, 46282, 72944, 46282,},
- { 104858, 64528, 104858, 64528, 64528, 41943, 64528, 41943, 104858, 64528, 104858, 64528, 64528, 41943, 64528, 41943,},
- { 95325, 59919, 95325, 59919, 59919, 37283, 59919, 37283, 95325, 59919, 95325, 59919, 59919, 37283, 59919, 37283,},
- { 80660, 52429, 80660, 52429, 52429, 33554, 52429, 33554, 80660, 52429, 80660, 52429, 52429, 33554, 52429, 33554,},
- { 74898, 46603, 74898, 46603, 46603, 29178, 46603, 29178, 74898, 46603, 74898, 46603, 46603, 29178, 46603, 29178,},
- { 65536, 41943, 65536, 41943, 41943, 26844, 41943, 26844, 65536, 41943, 65536, 41943, 41943, 26844, 41943, 26844,},
- { 58254, 36472, 58254, 36472, 36472, 23141, 36472, 23141, 58254, 36472, 58254, 36472, 36472, 23141, 36472, 23141,},
- { 52429, 32264, 52429, 32264, 32264, 20972, 32264, 20972, 52429, 32264, 52429, 32264, 32264, 20972, 32264, 20972,},
- { 47663, 29959, 47663, 29959, 29959, 18641, 29959, 18641, 47663, 29959, 47663, 29959, 29959, 18641, 29959, 18641,},
- { 40330, 26214, 40330, 26214, 26214, 16777, 26214, 16777, 40330, 26214, 40330, 26214, 26214, 16777, 26214, 16777,},
- { 37449, 23302, 37449, 23302, 23302, 14589, 23302, 14589, 37449, 23302, 37449, 23302, 23302, 14589, 23302, 14589,},
- { 32768, 20972, 32768, 20972, 20972, 13422, 20972, 13422, 32768, 20972, 32768, 20972, 20972, 13422, 20972, 13422,},
- { 29127, 18236, 29127, 18236, 18236, 11570, 18236, 11570, 29127, 18236, 29127, 18236, 18236, 11570, 18236, 11570,},
- { 26214, 16132, 26214, 16132, 16132, 10486, 16132, 10486, 26214, 16132, 26214, 16132, 16132, 10486, 16132, 10486,},
- { 23831, 14980, 23831, 14980, 14980, 9321, 14980, 9321, 23831, 14980, 23831, 14980, 14980, 9321, 14980, 9321,},
- { 20165, 13107, 20165, 13107, 13107, 8389, 13107, 8389, 20165, 13107, 20165, 13107, 13107, 8389, 13107, 8389,},
- { 18725, 11651, 18725, 11651, 11651, 7294, 11651, 7294, 18725, 11651, 18725, 11651, 11651, 7294, 11651, 7294,},
- { 16384, 10486, 16384, 10486, 10486, 6711, 10486, 6711, 16384, 10486, 16384, 10486, 10486, 6711, 10486, 6711,},
- { 14564, 9118, 14564, 9118, 9118, 5785, 9118, 5785, 14564, 9118, 14564, 9118, 9118, 5785, 9118, 5785,},
- { 13107, 8066, 13107, 8066, 8066, 5243, 8066, 5243, 13107, 8066, 13107, 8066, 8066, 5243, 8066, 5243,},
- { 11916, 7490, 11916, 7490, 7490, 4660, 7490, 4660, 11916, 7490, 11916, 7490, 7490, 4660, 7490, 4660,},
- { 10082, 6554, 10082, 6554, 6554, 4194, 6554, 4194, 10082, 6554, 10082, 6554, 6554, 4194, 6554, 4194,},
- { 9362, 5825, 9362, 5825, 5825, 3647, 5825, 3647, 9362, 5825, 9362, 5825, 5825, 3647, 5825, 3647,},
- { 8192, 5243, 8192, 5243, 5243, 3355, 5243, 3355, 8192, 5243, 8192, 5243, 5243, 3355, 5243, 3355,},
- { 7282, 4559, 7282, 4559, 4559, 2893, 4559, 2893, 7282, 4559, 7282, 4559, 4559, 2893, 4559, 2893,},
- { 6554, 4033, 6554, 4033, 4033, 2621, 4033, 2621, 6554, 4033, 6554, 4033, 4033, 2621, 4033, 2621,},
- { 5958, 3745, 5958, 3745, 3745, 2330, 3745, 2330, 5958, 3745, 5958, 3745, 3745, 2330, 3745, 2330,},
- { 5041, 3277, 5041, 3277, 3277, 2097, 3277, 2097, 5041, 3277, 5041, 3277, 3277, 2097, 3277, 2097,},
- { 4681, 2913, 4681, 2913, 2913, 1824, 2913, 1824, 4681, 2913, 4681, 2913, 2913, 1824, 2913, 1824,},
- { 4096, 2621, 4096, 2621, 2621, 1678, 2621, 1678, 4096, 2621, 4096, 2621, 2621, 1678, 2621, 1678,},
- { 3641, 2280, 3641, 2280, 2280, 1446, 2280, 1446, 3641, 2280, 3641, 2280, 2280, 1446, 2280, 1446,},
- { 3277, 2016, 3277, 2016, 2016, 1311, 2016, 1311, 3277, 2016, 3277, 2016, 2016, 1311, 2016, 1311,},
- { 2979, 1872, 2979, 1872, 1872, 1165, 1872, 1165, 2979, 1872, 2979, 1872, 1872, 1165, 1872, 1165,},
- { 2521, 1638, 2521, 1638, 1638, 1049, 1638, 1049, 2521, 1638, 2521, 1638, 1638, 1049, 1638, 1049,},
- { 2341, 1456, 2341, 1456, 1456, 912, 1456, 912, 2341, 1456, 2341, 1456, 1456, 912, 1456, 912,},
- { 2048, 1311, 2048, 1311, 1311, 839, 1311, 839, 2048, 1311, 2048, 1311, 1311, 839, 1311, 839,},
- { 1820, 1140, 1820, 1140, 1140, 723, 1140, 723, 1820, 1140, 1820, 1140, 1140, 723, 1140, 723,},
- { 1638, 1008, 1638, 1008, 1008, 655, 1008, 655, 1638, 1008, 1638, 1008, 1008, 655, 1008, 655,},
- { 1489, 936, 1489, 936, 936, 583, 936, 583, 1489, 936, 1489, 936, 936, 583, 936, 583,},
- { 1260, 819, 1260, 819, 819, 524, 819, 524, 1260, 819, 1260, 819, 819, 524, 819, 524,},
- { 1170, 728, 1170, 728, 728, 456, 728, 456, 1170, 728, 1170, 728, 728, 456, 728, 456,},
-};
-
-//FIXME need to check that this does not overflow signed 32 bit for low qp, I am not sure, it's very close
-//FIXME check that gcc inlines this (and optimizes intra & separate_dc stuff away)
-static inline int quantize_c(DCTELEM *block, uint8_t *scantable, int qscale,
- int intra, int separate_dc)
-{
- int i;
- const int * const quant_table = quant_coeff[qscale];
- const int bias = intra ? (1 << QUANT_SHIFT) / 3 : (1 << QUANT_SHIFT) / 6;
- const unsigned int threshold1 = (1 << QUANT_SHIFT) - bias - 1;
- const unsigned int threshold2 = (threshold1 << 1);
- int last_non_zero;
-
- if (separate_dc) {
- if (qscale <= 18) {
- //avoid overflows
- const int dc_bias = intra ? (1 << (QUANT_SHIFT - 2)) / 3 : (1 << (QUANT_SHIFT - 2)) / 6;
- const unsigned int dc_threshold1 = (1 << (QUANT_SHIFT - 2)) - dc_bias - 1;
- const unsigned int dc_threshold2 = (dc_threshold1 << 1);
-
- int level = block[0]*quant_coeff[qscale+18][0];
- if (((unsigned)(level + dc_threshold1)) > dc_threshold2) {
- if (level > 0) {
- level = (dc_bias + level) >> (QUANT_SHIFT - 2);
- block[0] = level;
- } else {
- level = (dc_bias - level) >> (QUANT_SHIFT - 2);
- block[0] = -level;
- }
-// last_non_zero = i;
- } else {
- block[0] = 0;
- }
- } else {
- const int dc_bias = intra ? (1 << (QUANT_SHIFT + 1)) / 3 : (1 << (QUANT_SHIFT + 1)) / 6;
- const unsigned int dc_threshold1 = (1 << (QUANT_SHIFT + 1)) - dc_bias - 1;
- const unsigned int dc_threshold2 = (dc_threshold1 << 1);
-
- int level = block[0]*quant_table[0];
- if (((unsigned)(level + dc_threshold1)) > dc_threshold2) {
- if (level > 0) {
- level = (dc_bias + level) >> (QUANT_SHIFT + 1);
- block[0] = level;
- } else {
- level = (dc_bias - level) >> (QUANT_SHIFT + 1);
- block[0] = -level;
- }
-// last_non_zero = i;
- } else {
- block[0] = 0;
- }
- }
- last_non_zero = 0;
- i = 1;
- } else {
- last_non_zero = -1;
- i = 0;
- }
-
- for (; i < 16; i++) {
- const int j = scantable[i];
- int level = block[j]*quant_table[j];
-
-// if ( bias+level >= (1 << (QMAT_SHIFT - 3))
-// || bias-level >= (1 << (QMAT_SHIFT - 3))) {
- if (((unsigned)(level + threshold1)) > threshold2) {
- if (level > 0) {
- level = (bias + level) >> QUANT_SHIFT;
- block[j] = level;
- } else {
- level = (bias - level) >> QUANT_SHIFT;
- block[j] = -level;
- }
- last_non_zero = i;
- } else {
- block[j] = 0;
- }
- }
-
- return last_non_zero;
-}
diff --git a/lib/ffmpeg/libavcodec/h264idct.c b/lib/ffmpeg/libavcodec/h264idct.c
index 31e072f984..f5b05ac24f 100644
--- a/lib/ffmpeg/libavcodec/h264idct.c
+++ b/lib/ffmpeg/libavcodec/h264idct.c
@@ -34,23 +34,23 @@ static av_always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int str
block[0] += 1<<(shift-1);
for(i=0; i<4; i++){
- const int z0= block[0 + block_stride*i] + block[2 + block_stride*i];
- const int z1= block[0 + block_stride*i] - block[2 + block_stride*i];
- const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i];
- const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1);
-
- block[0 + block_stride*i]= z0 + z3;
- block[1 + block_stride*i]= z1 + z2;
- block[2 + block_stride*i]= z1 - z2;
- block[3 + block_stride*i]= z0 - z3;
- }
-
- for(i=0; i<4; i++){
const int z0= block[i + block_stride*0] + block[i + block_stride*2];
const int z1= block[i + block_stride*0] - block[i + block_stride*2];
const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3];
const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1);
+ block[i + block_stride*0]= z0 + z3;
+ block[i + block_stride*1]= z1 + z2;
+ block[i + block_stride*2]= z1 - z2;
+ block[i + block_stride*3]= z0 - z3;
+ }
+
+ for(i=0; i<4; i++){
+ const int z0= block[0 + block_stride*i] + block[2 + block_stride*i];
+ const int z1= block[0 + block_stride*i] - block[2 + block_stride*i];
+ const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i];
+ const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1);
+
dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];
dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];
dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];
@@ -78,51 +78,51 @@ void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride){
for( i = 0; i < 8; i++ )
{
- const int a0 = block[0+i*8] + block[4+i*8];
- const int a2 = block[0+i*8] - block[4+i*8];
- const int a4 = (block[2+i*8]>>1) - block[6+i*8];
- const int a6 = (block[6+i*8]>>1) + block[2+i*8];
+ const int a0 = block[i+0*8] + block[i+4*8];
+ const int a2 = block[i+0*8] - block[i+4*8];
+ const int a4 = (block[i+2*8]>>1) - block[i+6*8];
+ const int a6 = (block[i+6*8]>>1) + block[i+2*8];
const int b0 = a0 + a6;
const int b2 = a2 + a4;
const int b4 = a2 - a4;
const int b6 = a0 - a6;
- const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1);
- const int a3 = block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1);
- const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1);
- const int a7 = block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1);
+ const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1);
+ const int a3 = block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1);
+ const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
+ const int a7 = block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
const int b1 = (a7>>2) + a1;
const int b3 = a3 + (a5>>2);
const int b5 = (a3>>2) - a5;
const int b7 = a7 - (a1>>2);
- block[0+i*8] = b0 + b7;
- block[7+i*8] = b0 - b7;
- block[1+i*8] = b2 + b5;
- block[6+i*8] = b2 - b5;
- block[2+i*8] = b4 + b3;
- block[5+i*8] = b4 - b3;
- block[3+i*8] = b6 + b1;
- block[4+i*8] = b6 - b1;
+ block[i+0*8] = b0 + b7;
+ block[i+7*8] = b0 - b7;
+ block[i+1*8] = b2 + b5;
+ block[i+6*8] = b2 - b5;
+ block[i+2*8] = b4 + b3;
+ block[i+5*8] = b4 - b3;
+ block[i+3*8] = b6 + b1;
+ block[i+4*8] = b6 - b1;
}
for( i = 0; i < 8; i++ )
{
- const int a0 = block[i+0*8] + block[i+4*8];
- const int a2 = block[i+0*8] - block[i+4*8];
- const int a4 = (block[i+2*8]>>1) - block[i+6*8];
- const int a6 = (block[i+6*8]>>1) + block[i+2*8];
+ const int a0 = block[0+i*8] + block[4+i*8];
+ const int a2 = block[0+i*8] - block[4+i*8];
+ const int a4 = (block[2+i*8]>>1) - block[6+i*8];
+ const int a6 = (block[6+i*8]>>1) + block[2+i*8];
const int b0 = a0 + a6;
const int b2 = a2 + a4;
const int b4 = a2 - a4;
const int b6 = a0 - a6;
- const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1);
- const int a3 = block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1);
- const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
- const int a7 = block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
+ const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1);
+ const int a3 = block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1);
+ const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1);
+ const int a7 = block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1);
const int b1 = (a7>>2) + a1;
const int b3 = a3 + (a5>>2);
@@ -216,3 +216,38 @@ void ff_h264_idct_add8_c(uint8_t **dest, const int *block_offset, DCTELEM *block
ff_h264_idct_dc_add_c(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
}
}
+/**
+ * IDCT transforms the 16 dc values and dequantizes them.
+ * @param qp quantization parameter
+ */
+void ff_h264_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qmul){
+#define stride 16
+ int i;
+ int temp[16];
+ static const uint8_t x_offset[4]={0, 2*stride, 8*stride, 10*stride};
+
+ for(i=0; i<4; i++){
+ const int z0= input[4*i+0] + input[4*i+1];
+ const int z1= input[4*i+0] - input[4*i+1];
+ const int z2= input[4*i+2] - input[4*i+3];
+ const int z3= input[4*i+2] + input[4*i+3];
+
+ temp[4*i+0]= z0+z3;
+ temp[4*i+1]= z0-z3;
+ temp[4*i+2]= z1-z2;
+ temp[4*i+3]= z1+z2;
+ }
+
+ for(i=0; i<4; i++){
+ const int offset= x_offset[i];
+ const int z0= temp[4*0+i] + temp[4*2+i];
+ const int z1= temp[4*0+i] - temp[4*2+i];
+ const int z2= temp[4*1+i] - temp[4*3+i];
+ const int z3= temp[4*1+i] + temp[4*3+i];
+
+ output[stride* 0+offset]= ((((z0 + z3)*qmul + 128 ) >> 8));
+ output[stride* 1+offset]= ((((z1 + z2)*qmul + 128 ) >> 8));
+ output[stride* 4+offset]= ((((z1 - z2)*qmul + 128 ) >> 8));
+ output[stride* 5+offset]= ((((z0 - z3)*qmul + 128 ) >> 8));
+ }
+}
diff --git a/lib/ffmpeg/libavcodec/h264pred.c b/lib/ffmpeg/libavcodec/h264pred.c
index 5706c97e16..7edb97192a 100644
--- a/lib/ffmpeg/libavcodec/h264pred.c
+++ b/lib/ffmpeg/libavcodec/h264pred.c
@@ -80,6 +80,20 @@ static void pred4x4_128_dc_c(uint8_t *src, const uint8_t *topright, int stride){
((uint32_t*)(src+3*stride))[0]= 128U*0x01010101U;
}
+static void pred4x4_127_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]=
+ ((uint32_t*)(src+3*stride))[0]= 127U*0x01010101U;
+}
+
+static void pred4x4_129_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]=
+ ((uint32_t*)(src+3*stride))[0]= 129U*0x01010101U;
+}
+
#define LOAD_TOP_RIGHT_EDGE\
const int av_unused t4= topright[0];\
@@ -547,6 +561,28 @@ static void pred16x16_128_dc_c(uint8_t *src, int stride){
}
}
+static void pred16x16_127_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<16; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]=
+ ((uint32_t*)(src+i*stride))[2]=
+ ((uint32_t*)(src+i*stride))[3]= 0x01010101U*127U;
+ }
+}
+
+static void pred16x16_129_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<16; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]=
+ ((uint32_t*)(src+i*stride))[2]=
+ ((uint32_t*)(src+i*stride))[3]= 0x01010101U*129U;
+ }
+}
+
static inline void pred16x16_plane_compat_c(uint8_t *src, int stride, const int svq3, const int rv40){
int i, j, k;
int a;
@@ -658,6 +694,23 @@ static void pred8x8_128_dc_c(uint8_t *src, int stride){
}
}
+static void pred8x8_127_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<8; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]= 0x01010101U*127U;
+ }
+}
+static void pred8x8_129_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<8; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]= 0x01010101U*129U;
+ }
+}
+
static void pred8x8_left_dc_c(uint8_t *src, int stride){
int i;
int dc0, dc2;
@@ -1210,11 +1263,17 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
} 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)
+ if(codec_id != CODEC_ID_VP8) {
+ 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;
+ } else {
h->pred4x4[TM_VP8_PRED ]= pred4x4_tm_vp8_c;
+ h->pred4x4[DC_127_PRED ]= pred4x4_127_dc_c;
+ h->pred4x4[DC_129_PRED ]= pred4x4_129_dc_c;
+ h->pred4x4[VERT_VP8_PRED ]= pred4x4_vertical_c;
+ h->pred4x4[HOR_VP8_PRED ]= pred4x4_horizontal_c;
+ }
}else{
h->pred4x4[VERT_PRED ]= pred4x4_vertical_c;
h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c;
@@ -1264,13 +1323,16 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_rv40_c;
h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_rv40_c;
h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_rv40_c;
+ if (codec_id == CODEC_ID_VP8) {
+ h->pred8x8[DC_127_PRED8x8]= pred8x8_127_dc_c;
+ h->pred8x8[DC_129_PRED8x8]= pred8x8_129_dc_c;
+ }
}
h->pred8x8[DC_128_PRED8x8 ]= pred8x8_128_dc_c;
h->pred16x16[DC_PRED8x8 ]= pred16x16_dc_c;
h->pred16x16[VERT_PRED8x8 ]= pred16x16_vertical_c;
h->pred16x16[HOR_PRED8x8 ]= pred16x16_horizontal_c;
- h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c;
switch(codec_id){
case CODEC_ID_SVQ3:
h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_svq3_c;
@@ -1280,9 +1342,12 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
break;
case CODEC_ID_VP8:
h->pred16x16[PLANE_PRED8x8 ]= pred16x16_tm_vp8_c;
+ h->pred16x16[DC_127_PRED8x8]= pred16x16_127_dc_c;
+ h->pred16x16[DC_129_PRED8x8]= pred16x16_129_dc_c;
break;
default:
h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c;
+ break;
}
h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c;
h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c;
diff --git a/lib/ffmpeg/libavcodec/h264pred.h b/lib/ffmpeg/libavcodec/h264pred.h
index b7fd2a2b7a..a492ae0ecc 100644
--- a/lib/ffmpeg/libavcodec/h264pred.h
+++ b/lib/ffmpeg/libavcodec/h264pred.h
@@ -45,29 +45,45 @@
#define VERT_LEFT_PRED 7
#define HOR_UP_PRED 8
+// DC edge (not for VP8)
#define LEFT_DC_PRED 9
#define TOP_DC_PRED 10
#define DC_128_PRED 11
-#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane
-
+// RV40 specific
#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12
#define HOR_UP_PRED_RV40_NODOWN 13
#define VERT_LEFT_PRED_RV40_NODOWN 14
+// VP8 specific
+#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane
+#define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of
+ ///< (left col+cur col x2+right col) / 4;
+ ///< this is the "unaveraged" one
+#define HOR_VP8_PRED 11 ///< unaveraged version of #HOR_PRED, see
+ ///< #VERT_VP8_PRED for details
+#define DC_127_PRED 12
+#define DC_129_PRED 13
+
#define DC_PRED8x8 0
#define HOR_PRED8x8 1
#define VERT_PRED8x8 2
#define PLANE_PRED8x8 3
+// DC edge
#define LEFT_DC_PRED8x8 4
#define TOP_DC_PRED8x8 5
#define DC_128_PRED8x8 6
+// H264/SVQ3 (8x8) specific
#define ALZHEIMER_DC_L0T_PRED8x8 7
#define ALZHEIMER_DC_0LT_PRED8x8 8
#define ALZHEIMER_DC_L00_PRED8x8 9
#define ALZHEIMER_DC_0L0_PRED8x8 10
+
+// VP8 specific
+#define DC_127_PRED8x8 7
+#define DC_129_PRED8x8 8
//@}
/**
@@ -77,7 +93,7 @@ typedef struct H264PredContext{
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);
+ void (*pred16x16[4+3+2])(uint8_t *src, int stride);
void (*pred4x4_add [2])(uint8_t *pix/*align 4*/, const DCTELEM *block/*align 16*/, int stride);
void (*pred8x8l_add [2])(uint8_t *pix/*align 8*/, const DCTELEM *block/*align 16*/, int stride);
diff --git a/lib/ffmpeg/libavcodec/huffyuv.c b/lib/ffmpeg/libavcodec/huffyuv.c
index 7541785cb2..2eb5864c47 100644
--- a/lib/ffmpeg/libavcodec/huffyuv.c
+++ b/lib/ffmpeg/libavcodec/huffyuv.c
@@ -1416,7 +1416,7 @@ static av_cold int encode_end(AVCodecContext *avctx)
#endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */
#if CONFIG_HUFFYUV_DECODER
-AVCodec huffyuv_decoder = {
+AVCodec ff_huffyuv_decoder = {
"huffyuv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_HUFFYUV,
@@ -1432,7 +1432,7 @@ AVCodec huffyuv_decoder = {
#endif
#if CONFIG_FFVHUFF_DECODER
-AVCodec ffvhuff_decoder = {
+AVCodec ff_ffvhuff_decoder = {
"ffvhuff",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FFVHUFF,
@@ -1448,7 +1448,7 @@ AVCodec ffvhuff_decoder = {
#endif
#if CONFIG_HUFFYUV_ENCODER
-AVCodec huffyuv_encoder = {
+AVCodec ff_huffyuv_encoder = {
"huffyuv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_HUFFYUV,
@@ -1462,7 +1462,7 @@ AVCodec huffyuv_encoder = {
#endif
#if CONFIG_FFVHUFF_ENCODER
-AVCodec ffvhuff_encoder = {
+AVCodec ff_ffvhuff_encoder = {
"ffvhuff",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_FFVHUFF,
diff --git a/lib/ffmpeg/libavcodec/idcinvideo.c b/lib/ffmpeg/libavcodec/idcinvideo.c
index cc79ef0a4f..64421db19a 100644
--- a/lib/ffmpeg/libavcodec/idcinvideo.c
+++ b/lib/ffmpeg/libavcodec/idcinvideo.c
@@ -253,7 +253,7 @@ static av_cold int idcin_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec idcin_decoder = {
+AVCodec ff_idcin_decoder = {
"idcinvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_IDCIN,
diff --git a/lib/ffmpeg/libavcodec/iff.c b/lib/ffmpeg/libavcodec/iff.c
index 2992cb43ad..18ad7004d9 100644
--- a/lib/ffmpeg/libavcodec/iff.c
+++ b/lib/ffmpeg/libavcodec/iff.c
@@ -25,10 +25,10 @@
* IFF PBM/ILBM bitmap decoder
*/
+#include "libavcore/imgutils.h"
#include "bytestream.h"
#include "avcodec.h"
#include "get_bits.h"
-#include "iff.h"
typedef struct {
AVFrame frame;
@@ -119,7 +119,7 @@ static av_always_inline uint32_t gray2rgb(const uint32_t x) {
/**
* Convert CMAP buffer (stored in extradata) to lavc palette format
*/
-int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
+static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
{
int count, i;
@@ -160,7 +160,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- if ((err = avcodec_check_dimensions(avctx, avctx->width, avctx->height)))
+ if ((err = av_image_check_size(avctx->width, avctx->height, 0, avctx)))
return err;
s->planesize = FFALIGN(avctx->width, 16) >> 3; // Align plane size in bits to word-boundary
s->planebuf = av_malloc(s->planesize + FF_INPUT_BUFFER_PADDING_SIZE);
@@ -367,7 +367,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec iff_ilbm_decoder = {
+AVCodec ff_iff_ilbm_decoder = {
"iff_ilbm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_IFF_ILBM,
@@ -380,7 +380,7 @@ AVCodec iff_ilbm_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("IFF ILBM"),
};
-AVCodec iff_byterun1_decoder = {
+AVCodec ff_iff_byterun1_decoder = {
"iff_byterun1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_IFF_BYTERUN1,
diff --git a/lib/ffmpeg/libavcodec/iirfilter.c b/lib/ffmpeg/libavcodec/iirfilter.c
index 90af43190e..bc63c3991a 100644
--- a/lib/ffmpeg/libavcodec/iirfilter.c
+++ b/lib/ffmpeg/libavcodec/iirfilter.c
@@ -47,25 +47,25 @@ typedef struct FFIIRFilterState{
/// maximum supported filter order
#define MAXORDER 30
-av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
- enum IIRFilterMode filt_mode,
- int order, float cutoff_ratio,
- float stopband, float ripple)
+static int butterworth_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c,
+ enum IIRFilterMode filt_mode,
+ int order, float cutoff_ratio,
+ float stopband)
{
int i, j;
- FFIIRFilterCoeffs *c;
double wa;
double p[MAXORDER + 1][2];
- if(filt_type != FF_FILTER_TYPE_BUTTERWORTH || filt_mode != FF_FILTER_MODE_LOWPASS)
- return NULL;
- if(order <= 1 || (order & 1) || order > MAXORDER || cutoff_ratio >= 1.0)
- return NULL;
-
- c = av_malloc(sizeof(FFIIRFilterCoeffs));
- c->cx = av_malloc(sizeof(c->cx[0]) * ((order >> 1) + 1));
- c->cy = av_malloc(sizeof(c->cy[0]) * order);
- c->order = order;
+ if (filt_mode != FF_FILTER_MODE_LOWPASS) {
+ av_log(avc, AV_LOG_ERROR, "Butterworth filter currently only supports "
+ "low-pass filter mode\n");
+ return -1;
+ }
+ if (order & 1) {
+ av_log(avc, AV_LOG_ERROR, "Butterworth filter currently only supports "
+ "even filter orders\n");
+ return -1;
+ }
wa = 2 * tan(M_PI * 0.5 * cutoff_ratio);
@@ -109,7 +109,94 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType f
}
c->gain /= 1 << order;
- return c;
+ return 0;
+}
+
+static int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c,
+ enum IIRFilterMode filt_mode, int order,
+ float cutoff_ratio, float stopband)
+{
+ double cos_w0, sin_w0;
+ double a0, x0, x1;
+
+ if (filt_mode != FF_FILTER_MODE_HIGHPASS &&
+ filt_mode != FF_FILTER_MODE_LOWPASS) {
+ av_log(avc, AV_LOG_ERROR, "Biquad filter currently only supports "
+ "high-pass and low-pass filter modes\n");
+ return -1;
+ }
+ if (order != 2) {
+ av_log(avc, AV_LOG_ERROR, "Biquad filter must have order of 2\n");
+ return -1;
+ }
+
+ cos_w0 = cos(M_PI * cutoff_ratio);
+ sin_w0 = sin(M_PI * cutoff_ratio);
+
+ a0 = 1.0 + (sin_w0 / 2.0);
+
+ if (filt_mode == FF_FILTER_MODE_HIGHPASS) {
+ c->gain = ((1.0 + cos_w0) / 2.0) / a0;
+ x0 = ((1.0 + cos_w0) / 2.0) / a0;
+ x1 = (-(1.0 + cos_w0)) / a0;
+ } else { // FF_FILTER_MODE_LOWPASS
+ c->gain = ((1.0 - cos_w0) / 2.0) / a0;
+ x0 = ((1.0 - cos_w0) / 2.0) / a0;
+ x1 = (1.0 - cos_w0) / a0;
+ }
+ c->cy[0] = (-1.0 + (sin_w0 / 2.0)) / a0;
+ c->cy[1] = (2.0 * cos_w0) / a0;
+
+ // divide by gain to make the x coeffs integers.
+ // during filtering, the delay state will include the gain multiplication
+ c->cx[0] = lrintf(x0 / c->gain);
+ c->cx[1] = lrintf(x1 / c->gain);
+ c->cy[0] /= c->gain;
+ c->cy[1] /= c->gain;
+
+ return 0;
+}
+
+av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
+ enum IIRFilterType filt_type,
+ enum IIRFilterMode filt_mode,
+ int order, float cutoff_ratio,
+ float stopband, float ripple)
+{
+ FFIIRFilterCoeffs *c;
+ int ret = 0;
+
+ if (order <= 0 || order > MAXORDER || cutoff_ratio >= 1.0)
+ return NULL;
+
+ FF_ALLOCZ_OR_GOTO(avc, c, sizeof(FFIIRFilterCoeffs),
+ init_fail);
+ FF_ALLOC_OR_GOTO (avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1),
+ init_fail);
+ FF_ALLOC_OR_GOTO (avc, c->cy, sizeof(c->cy[0]) * order,
+ init_fail);
+ c->order = order;
+
+ switch (filt_type) {
+ case FF_FILTER_TYPE_BUTTERWORTH:
+ ret = butterworth_init_coeffs(avc, c, filt_mode, order, cutoff_ratio,
+ stopband);
+ break;
+ case FF_FILTER_TYPE_BIQUAD:
+ ret = biquad_init_coeffs(avc, c, filt_mode, order, cutoff_ratio,
+ stopband);
+ break;
+ default:
+ av_log(avc, AV_LOG_ERROR, "filter type is not currently implemented\n");
+ goto init_fail;
+ }
+
+ if (!ret)
+ return c;
+
+init_fail:
+ ff_iir_filter_free_coeffs(c);
+ return NULL;
}
av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
@@ -118,48 +205,96 @@ av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
return s;
}
-#define FILTER(i0, i1, i2, i3) \
- in = *src * c->gain \
- + c->cy[0]*s->x[i0] + c->cy[1]*s->x[i1] \
- + c->cy[2]*s->x[i2] + c->cy[3]*s->x[i3]; \
- res = (s->x[i0] + in )*1 \
- + (s->x[i1] + s->x[i3])*4 \
- + s->x[i2] *6; \
- *dst = av_clip_int16(lrintf(res)); \
- s->x[i0] = in; \
- src += sstep; \
- dst += dstep; \
-
-void ff_iir_filter(const struct FFIIRFilterCoeffs *c, struct FFIIRFilterState *s, int size, const int16_t *src, int sstep, int16_t *dst, int dstep)
-{
- int i;
+#define CONV_S16(dest, source) dest = av_clip_int16(lrintf(source));
- if(c->order == 4){
- for(i = 0; i < size; i += 4){
- float in, res;
+#define CONV_FLT(dest, source) dest = source;
- FILTER(0, 1, 2, 3);
- FILTER(1, 2, 3, 0);
- FILTER(2, 3, 0, 1);
- FILTER(3, 0, 1, 2);
- }
- }else{
- for(i = 0; i < size; i++){
- int j;
- float in, res;
- in = *src * c->gain;
- for(j = 0; j < c->order; j++)
- in += c->cy[j] * s->x[j];
- res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1];
- for(j = 1; j < c->order >> 1; j++)
- res += (s->x[j] + s->x[c->order - j]) * c->cx[j];
- for(j = 0; j < c->order - 1; j++)
- s->x[j] = s->x[j + 1];
- *dst = av_clip_int16(lrintf(res));
- s->x[c->order - 1] = in;
- src += sstep;
- dst += sstep;
- }
+#define FILTER_BW_O4_1(i0, i1, i2, i3, fmt) \
+ in = *src0 * c->gain \
+ + c->cy[0]*s->x[i0] + c->cy[1]*s->x[i1] \
+ + c->cy[2]*s->x[i2] + c->cy[3]*s->x[i3]; \
+ res = (s->x[i0] + in )*1 \
+ + (s->x[i1] + s->x[i3])*4 \
+ + s->x[i2] *6; \
+ CONV_##fmt(*dst0, res) \
+ s->x[i0] = in; \
+ src0 += sstep; \
+ dst0 += dstep;
+
+#define FILTER_BW_O4(type, fmt) { \
+ int i; \
+ const type *src0 = src; \
+ type *dst0 = dst; \
+ for (i = 0; i < size; i += 4) { \
+ float in, res; \
+ FILTER_BW_O4_1(0, 1, 2, 3, fmt); \
+ FILTER_BW_O4_1(1, 2, 3, 0, fmt); \
+ FILTER_BW_O4_1(2, 3, 0, 1, fmt); \
+ FILTER_BW_O4_1(3, 0, 1, 2, fmt); \
+ } \
+}
+
+#define FILTER_DIRECT_FORM_II(type, fmt) { \
+ int i; \
+ const type *src0 = src; \
+ type *dst0 = dst; \
+ for (i = 0; i < size; i++) { \
+ int j; \
+ float in, res; \
+ in = *src0 * c->gain; \
+ for(j = 0; j < c->order; j++) \
+ in += c->cy[j] * s->x[j]; \
+ res = s->x[0] + in + s->x[c->order >> 1] * c->cx[c->order >> 1]; \
+ for(j = 1; j < c->order >> 1; j++) \
+ res += (s->x[j] + s->x[c->order - j]) * c->cx[j]; \
+ for(j = 0; j < c->order - 1; j++) \
+ s->x[j] = s->x[j + 1]; \
+ CONV_##fmt(*dst0, res) \
+ s->x[c->order - 1] = in; \
+ src0 += sstep; \
+ dst0 += dstep; \
+ } \
+}
+
+#define FILTER_O2(type, fmt) { \
+ int i; \
+ const type *src0 = src; \
+ type *dst0 = dst; \
+ for (i = 0; i < size; i++) { \
+ float in = *src0 * c->gain + \
+ s->x[0] * c->cy[0] + \
+ s->x[1] * c->cy[1]; \
+ CONV_##fmt(*dst0, s->x[0] + in + s->x[1] * c->cx[1]) \
+ s->x[0] = s->x[1]; \
+ s->x[1] = in; \
+ src0 += sstep; \
+ dst0 += dstep; \
+ } \
+}
+
+void ff_iir_filter(const struct FFIIRFilterCoeffs *c,
+ struct FFIIRFilterState *s, int size,
+ const int16_t *src, int sstep, int16_t *dst, int dstep)
+{
+ if (c->order == 2) {
+ FILTER_O2(int16_t, S16)
+ } else if (c->order == 4) {
+ FILTER_BW_O4(int16_t, S16)
+ } else {
+ FILTER_DIRECT_FORM_II(int16_t, S16)
+ }
+}
+
+void ff_iir_filter_flt(const struct FFIIRFilterCoeffs *c,
+ struct FFIIRFilterState *s, int size,
+ const float *src, int sstep, float *dst, int dstep)
+{
+ if (c->order == 2) {
+ FILTER_O2(float, FLT)
+ } else if (c->order == 4) {
+ FILTER_BW_O4(float, FLT)
+ } else {
+ FILTER_DIRECT_FORM_II(float, FLT)
}
}
diff --git a/lib/ffmpeg/libavcodec/iirfilter.h b/lib/ffmpeg/libavcodec/iirfilter.h
index f660955403..b29e035811 100644
--- a/lib/ffmpeg/libavcodec/iirfilter.h
+++ b/lib/ffmpeg/libavcodec/iirfilter.h
@@ -34,6 +34,7 @@ struct FFIIRFilterState;
enum IIRFilterType{
FF_FILTER_TYPE_BESSEL,
+ FF_FILTER_TYPE_BIQUAD,
FF_FILTER_TYPE_BUTTERWORTH,
FF_FILTER_TYPE_CHEBYSHEV,
FF_FILTER_TYPE_ELLIPTIC,
@@ -49,6 +50,8 @@ enum IIRFilterMode{
/**
* Initialize filter coefficients.
*
+ * @param avc a pointer to an arbitrary struct of which the first
+ * field is a pointer to an AVClass struct
* @param filt_type filter type (e.g. Butterworth)
* @param filt_mode filter mode (e.g. lowpass)
* @param order filter order
@@ -58,10 +61,11 @@ enum IIRFilterMode{
*
* @return pointer to filter coefficients structure or NULL if filter cannot be created
*/
-struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
- enum IIRFilterMode filt_mode,
- int order, float cutoff_ratio,
- float stopband, float ripple);
+struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
+ enum IIRFilterType filt_type,
+ enum IIRFilterMode filt_mode,
+ int order, float cutoff_ratio,
+ float stopband, float ripple);
/**
* Create new filter state.
@@ -87,7 +91,7 @@ void ff_iir_filter_free_coeffs(struct FFIIRFilterCoeffs *coeffs);
void ff_iir_filter_free_state(struct FFIIRFilterState *state);
/**
- * Perform lowpass filtering on input samples.
+ * Perform IIR filtering on signed 16-bit input samples.
*
* @param coeffs pointer to filter coefficients
* @param state pointer to filter state
@@ -100,4 +104,19 @@ void ff_iir_filter_free_state(struct FFIIRFilterState *state);
void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state,
int size, const int16_t *src, int sstep, int16_t *dst, int dstep);
+/**
+ * Perform IIR filtering on floating-point input samples.
+ *
+ * @param coeffs pointer to filter coefficients
+ * @param state pointer to filter state
+ * @param size input length
+ * @param src source samples
+ * @param sstep source stride
+ * @param dst filtered samples (destination may be the same as input)
+ * @param dstep destination stride
+ */
+void ff_iir_filter_flt(const struct FFIIRFilterCoeffs *coeffs,
+ struct FFIIRFilterState *state, int size,
+ const float *src, int sstep, float *dst, int dstep);
+
#endif /* AVCODEC_IIRFILTER_H */
diff --git a/lib/ffmpeg/libavcodec/imc.c b/lib/ffmpeg/libavcodec/imc.c
index a27e4b6d32..4d7fbd1db6 100644
--- a/lib/ffmpeg/libavcodec/imc.c
+++ b/lib/ffmpeg/libavcodec/imc.c
@@ -87,7 +87,7 @@ typedef struct {
DSPContext dsp;
FFTContext fft;
DECLARE_ALIGNED(16, FFTComplex, samples)[COEFFS/2];
- DECLARE_ALIGNED(16, float, out_samples)[COEFFS];
+ float *out_samples;
} IMCContext;
static VLC huffman_vlc[4][4];
@@ -116,8 +116,8 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
for(i = 0; i < COEFFS; i++)
q->mdct_sine_window[i] *= sqrt(2.0);
for(i = 0; i < COEFFS/2; i++){
- q->post_cos[i] = cos(i / 256.0 * M_PI);
- q->post_sin[i] = sin(i / 256.0 * M_PI);
+ q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI);
+ q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI);
r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
@@ -156,7 +156,7 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
ff_fft_init(&q->fft, 7, 1);
dsputil_init(&q->dsp, avctx);
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
return 0;
}
@@ -362,7 +362,7 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
iacc = 0;
for(j = (stream_format_code & 0x2)?4:0; j < BANDS; j++) {
- cwlen = av_clip((int)((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
+ cwlen = av_clipf(((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
q->bitsBandT[j] = cwlen;
summer += q->bandWidthT[j] * cwlen;
@@ -662,6 +662,7 @@ static int imc_decode_frame(AVCodecContext * avctx,
for(i = 0; i < IMC_BLOCK_SIZE / 2; i++)
buf16[i] = av_bswap16(((const uint16_t*)buf)[i]);
+ q->out_samples = data;
init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
/* Check the frame header */
@@ -805,9 +806,7 @@ static int imc_decode_frame(AVCodecContext * avctx,
imc_imdct256(q);
- q->dsp.float_to_int16(data, q->out_samples, COEFFS);
-
- *data_size = COEFFS * sizeof(int16_t);
+ *data_size = COEFFS * sizeof(float);
return IMC_BLOCK_SIZE;
}
@@ -822,7 +821,7 @@ static av_cold int imc_decode_close(AVCodecContext * avctx)
}
-AVCodec imc_decoder = {
+AVCodec ff_imc_decoder = {
.name = "imc",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_IMC,
diff --git a/lib/ffmpeg/libavcodec/imgconvert.c b/lib/ffmpeg/libavcodec/imgconvert.c
index 68f1a75746..6b0c049e2a 100644
--- a/lib/ffmpeg/libavcodec/imgconvert.c
+++ b/lib/ffmpeg/libavcodec/imgconvert.c
@@ -36,9 +36,10 @@
#include "imgconvert.h"
#include "libavutil/colorspace.h"
#include "libavutil/pixdesc.h"
+#include "libavcore/imgutils.h"
+#include "libavcore/internal.h"
-#if HAVE_MMX
-#include "x86/mmx.h"
+#if HAVE_MMX && HAVE_YASM
#include "x86/dsputil_mmx.h"
#endif
@@ -54,6 +55,14 @@
#define FF_PIXEL_PACKED 1 /**< only one components containing all the channels */
#define FF_PIXEL_PALETTE 2 /**< one components containing indexes for a palette */
+#if HAVE_MMX && HAVE_YASM
+#define deinterlace_line_inplace ff_deinterlace_line_inplace_mmx
+#define deinterlace_line ff_deinterlace_line_mmx
+#else
+#define deinterlace_line_inplace deinterlace_line_inplace_c
+#define deinterlace_line deinterlace_line_c
+#endif
+
typedef struct PixFmtInfo {
uint8_t nb_channels; /**< number of channels (including alpha) */
uint8_t color_type; /**< color type (see FF_COLOR_xxx constants) */
@@ -411,7 +420,7 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *
const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt)
{
- if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
+ if ((unsigned)pix_fmt >= PIX_FMT_NB)
return NULL;
else
return av_pix_fmt_descriptors[pix_fmt].name;
@@ -422,291 +431,77 @@ enum PixelFormat avcodec_get_pix_fmt(const char *name)
{
return av_get_pix_fmt(name);
}
-#endif
void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
{
- /* print header */
- if (pix_fmt < 0)
- snprintf (buf, buf_size,
- "name " " nb_channels" " depth" " is_alpha"
- );
- else{
- PixFmtInfo info= pix_fmt_info[pix_fmt];
-
- char is_alpha_char= info.is_alpha ? 'y' : 'n';
-
- snprintf (buf, buf_size,
- "%-11s %5d %9d %6c",
- av_pix_fmt_descriptors[pix_fmt].name,
- info.nb_channels,
- info.depth,
- is_alpha_char
- );
- }
+ av_get_pix_fmt_string(buf, buf_size, pix_fmt);
}
+#endif
int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt)
{
return av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL;
}
+#if LIBAVCODEC_VERSION_MAJOR < 53
int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){
- int i;
-
- for(i=0; i<256; i++){
- int r,g,b;
-
- switch(pix_fmt) {
- case PIX_FMT_RGB8:
- r= (i>>5 )*36;
- g= ((i>>2)&7)*36;
- b= (i&3 )*85;
- break;
- case PIX_FMT_BGR8:
- b= (i>>6 )*85;
- g= ((i>>3)&7)*36;
- r= (i&7 )*36;
- break;
- case PIX_FMT_RGB4_BYTE:
- r= (i>>3 )*255;
- g= ((i>>1)&3)*85;
- b= (i&1 )*255;
- break;
- case PIX_FMT_BGR4_BYTE:
- b= (i>>3 )*255;
- g= ((i>>1)&3)*85;
- r= (i&1 )*255;
- break;
- case PIX_FMT_GRAY8:
- r=b=g= i;
- break;
- default:
- return -1;
- }
- pal[i] = b + (g<<8) + (r<<16);
- }
-
- return 0;
+ return ff_set_systematic_pal2(pal, pix_fmt);
}
int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
{
- int i;
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
- int max_plane_step [4];
- int max_plane_step_comp[4];
-
- memset(picture->linesize, 0, sizeof(picture->linesize));
-
- if (desc->flags & PIX_FMT_HWACCEL)
- return -1;
-
- if (desc->flags & PIX_FMT_BITSTREAM) {
- picture->linesize[0] = (width * (desc->comp[0].step_minus1+1) + 7) >> 3;
- return 0;
- }
-
- memset(max_plane_step , 0, sizeof(max_plane_step ));
- memset(max_plane_step_comp, 0, sizeof(max_plane_step_comp));
- for (i = 0; i < 4; i++) {
- const AVComponentDescriptor *comp = &(desc->comp[i]);
- if ((comp->step_minus1+1) > max_plane_step[comp->plane]) {
- max_plane_step [comp->plane] = comp->step_minus1+1;
- max_plane_step_comp[comp->plane] = i;
- }
- }
-
- for (i = 0; i < 4; i++) {
- int s = (max_plane_step_comp[i] == 1 || max_plane_step_comp[i] == 2) ? desc->log2_chroma_w : 0;
- picture->linesize[i] = max_plane_step[i] * (((width + (1 << s) - 1)) >> s);
- }
-
- return 0;
+ return av_image_fill_linesizes(picture->linesize, pix_fmt, width);
}
int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
int height)
{
- int size, h2, size2;
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
-
- size = picture->linesize[0] * height;
- switch(pix_fmt) {
- case PIX_FMT_YUV420P:
- case PIX_FMT_YUV422P:
- case PIX_FMT_YUV444P:
- case PIX_FMT_YUV410P:
- case PIX_FMT_YUV411P:
- case PIX_FMT_YUV440P:
- case PIX_FMT_YUVJ420P:
- case PIX_FMT_YUVJ422P:
- case PIX_FMT_YUVJ444P:
- case PIX_FMT_YUVJ440P:
- case PIX_FMT_YUV420P16LE:
- case PIX_FMT_YUV422P16LE:
- case PIX_FMT_YUV444P16LE:
- case PIX_FMT_YUV420P16BE:
- case PIX_FMT_YUV422P16BE:
- case PIX_FMT_YUV444P16BE:
- h2 = (height + (1 << desc->log2_chroma_h) - 1) >> desc->log2_chroma_h;
- size2 = picture->linesize[1] * h2;
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size2;
- picture->data[3] = NULL;
- return size + 2 * size2;
- case PIX_FMT_YUVA420P:
- h2 = (height + (1 << desc->log2_chroma_h) - 1) >> desc->log2_chroma_h;
- size2 = picture->linesize[1] * h2;
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = picture->data[1] + size2;
- picture->data[3] = picture->data[1] + size2 + size2;
- return 2 * size + 2 * size2;
- case PIX_FMT_NV12:
- case PIX_FMT_NV21:
- h2 = (height + (1 << desc->log2_chroma_h) - 1) >> desc->log2_chroma_h;
- size2 = picture->linesize[1] * h2;
- picture->data[0] = ptr;
- picture->data[1] = picture->data[0] + size;
- picture->data[2] = NULL;
- picture->data[3] = NULL;
- return size + size2;
- case PIX_FMT_RGB24:
- case PIX_FMT_BGR24:
- case PIX_FMT_ARGB:
- case PIX_FMT_ABGR:
- case PIX_FMT_RGBA:
- case PIX_FMT_BGRA:
- case PIX_FMT_RGB48BE:
- case PIX_FMT_RGB48LE:
- case PIX_FMT_GRAY16BE:
- case PIX_FMT_GRAY16LE:
- case PIX_FMT_BGR444BE:
- case PIX_FMT_BGR444LE:
- case PIX_FMT_BGR555BE:
- case PIX_FMT_BGR555LE:
- case PIX_FMT_BGR565BE:
- case PIX_FMT_BGR565LE:
- case PIX_FMT_RGB444BE:
- case PIX_FMT_RGB444LE:
- case PIX_FMT_RGB555BE:
- case PIX_FMT_RGB555LE:
- case PIX_FMT_RGB565BE:
- case PIX_FMT_RGB565LE:
- case PIX_FMT_YUYV422:
- case PIX_FMT_UYVY422:
- case PIX_FMT_UYYVYY411:
- case PIX_FMT_RGB4:
- case PIX_FMT_BGR4:
- case PIX_FMT_MONOWHITE:
- case PIX_FMT_MONOBLACK:
- case PIX_FMT_Y400A:
- picture->data[0] = ptr;
- picture->data[1] = NULL;
- picture->data[2] = NULL;
- picture->data[3] = NULL;
- return size;
- case PIX_FMT_PAL8:
- case PIX_FMT_RGB8:
- case PIX_FMT_BGR8:
- case PIX_FMT_RGB4_BYTE:
- case PIX_FMT_BGR4_BYTE:
- case PIX_FMT_GRAY8:
- size2 = (size + 3) & ~3;
- picture->data[0] = ptr;
- picture->data[1] = ptr + size2; /* palette is stored here as 256 32 bit words */
- picture->data[2] = NULL;
- picture->data[3] = NULL;
- return size2 + 256 * 4;
- default:
- picture->data[0] = NULL;
- picture->data[1] = NULL;
- picture->data[2] = NULL;
- picture->data[3] = NULL;
- return -1;
- }
+ return av_image_fill_pointers(picture->data, pix_fmt, height, ptr, picture->linesize);
}
+#endif
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
enum PixelFormat pix_fmt, int width, int height)
{
+ int ret;
- if(avcodec_check_dimensions(NULL, width, height))
- return -1;
+ if ((ret = av_image_check_size(width, height, 0, NULL)) < 0)
+ return ret;
- if (ff_fill_linesize(picture, pix_fmt, width))
- return -1;
+ if ((ret = av_image_fill_linesizes(picture->linesize, pix_fmt, width)) < 0)
+ return ret;
- return ff_fill_pointer(picture, ptr, pix_fmt, height);
+ return av_image_fill_pointers(picture->data, pix_fmt, height, ptr, picture->linesize);
}
int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
unsigned char *dest, int dest_size)
{
- const PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
+ int i, j, nb_planes = 0, linesizes[4];
const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
- int i, j, w, ow, h, oh, data_planes;
- const unsigned char* s;
int size = avpicture_get_size(pix_fmt, width, height);
if (size > dest_size || size < 0)
- return -1;
+ return AVERROR(EINVAL);
- if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
- if (pix_fmt == PIX_FMT_YUYV422 ||
- pix_fmt == PIX_FMT_UYVY422 ||
- pix_fmt == PIX_FMT_BGR565BE ||
- pix_fmt == PIX_FMT_BGR565LE ||
- pix_fmt == PIX_FMT_BGR555BE ||
- pix_fmt == PIX_FMT_BGR555LE ||
- pix_fmt == PIX_FMT_BGR444BE ||
- pix_fmt == PIX_FMT_BGR444LE ||
- pix_fmt == PIX_FMT_RGB565BE ||
- pix_fmt == PIX_FMT_RGB565LE ||
- pix_fmt == PIX_FMT_RGB555BE ||
- pix_fmt == PIX_FMT_RGB555LE ||
- pix_fmt == PIX_FMT_RGB444BE ||
- pix_fmt == PIX_FMT_RGB444LE)
- w = width * 2;
- else if (pix_fmt == PIX_FMT_UYYVYY411)
- w = width + width/2;
- else if (pix_fmt == PIX_FMT_PAL8)
- w = width;
- else
- w = width * (pf->depth * pf->nb_channels / 8);
-
- data_planes = 1;
- h = height;
- } else {
- data_planes = pf->nb_channels;
- w = (width*pf->depth + 7)/8;
- h = height;
- }
+ for (i = 0; i < desc->nb_components; i++)
+ nb_planes = FFMAX(desc->comp[i].plane, nb_planes);
+ nb_planes++;
- ow = w;
- oh = h;
+ av_image_fill_linesizes(linesizes, pix_fmt, width);
+ for (i = 0; i < nb_planes; i++) {
+ int h, shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
+ const unsigned char *s = src->data[i];
+ h = (height + (1 << shift) - 1) >> shift;
- for (i=0; i<data_planes; i++) {
- if (i == 1) {
- w = (- ((-width) >> desc->log2_chroma_w) * pf->depth + 7) / 8;
- h = -((-height) >> desc->log2_chroma_h);
- if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21)
- w <<= 1;
- } else if (i == 3) {
- w = ow;
- h = oh;
- }
- s = src->data[i];
- for(j=0; j<h; j++) {
- memcpy(dest, s, w);
- dest += w;
+ for (j = 0; j < h; j++) {
+ memcpy(dest, s, linesizes[i]);
+ dest += linesizes[i];
s += src->linesize[i];
}
}
- if (pf->pixel_type == FF_PIXEL_PALETTE)
+ if (desc->flags & PIX_FMT_PAL)
memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);
return size;
@@ -715,7 +510,7 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
{
AVPicture dummy_pict;
- if(avcodec_check_dimensions(NULL, width, height))
+ if(av_image_check_size(width, height, 0, NULL))
return -1;
switch (pix_fmt) {
case PIX_FMT_RGB8:
@@ -899,100 +694,33 @@ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelForma
return dst_pix_fmt;
}
+#if LIBAVCODEC_VERSION_MAJOR < 53
void ff_img_copy_plane(uint8_t *dst, int dst_wrap,
const uint8_t *src, int src_wrap,
int width, int height)
{
- if((!dst) || (!src))
- return;
- for(;height > 0; height--) {
- memcpy(dst, src, width);
- dst += dst_wrap;
- src += src_wrap;
- }
+ av_image_copy_plane(dst, dst_wrap, src, src_wrap, width, height);
}
int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane)
{
- int bits;
- const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
-
- pf = &pix_fmt_info[pix_fmt];
- switch(pf->pixel_type) {
- case FF_PIXEL_PACKED:
- switch(pix_fmt) {
- case PIX_FMT_YUYV422:
- case PIX_FMT_UYVY422:
- case PIX_FMT_RGB565BE:
- case PIX_FMT_RGB565LE:
- case PIX_FMT_RGB555BE:
- case PIX_FMT_RGB555LE:
- case PIX_FMT_RGB444BE:
- case PIX_FMT_RGB444LE:
- case PIX_FMT_BGR565BE:
- case PIX_FMT_BGR565LE:
- case PIX_FMT_BGR555BE:
- case PIX_FMT_BGR555LE:
- case PIX_FMT_BGR444BE:
- case PIX_FMT_BGR444LE:
- bits = 16;
- break;
- case PIX_FMT_UYYVYY411:
- bits = 12;
- break;
- default:
- bits = pf->depth * pf->nb_channels;
- break;
- }
- return (width * bits + 7) >> 3;
- break;
- case FF_PIXEL_PLANAR:
- if ((pix_fmt != PIX_FMT_NV12 && pix_fmt != PIX_FMT_NV21) &&
- (plane == 1 || plane == 2))
- width= -((-width)>>desc->log2_chroma_w);
-
- return (width * pf->depth + 7) >> 3;
- break;
- case FF_PIXEL_PALETTE:
- if (plane == 0)
- return width;
- break;
- }
+ return av_image_get_linesize(pix_fmt, width, plane);
+}
- return -1;
+void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
+ uint8_t *src_data[4], int src_linesize[4],
+ enum PixelFormat pix_fmt, int width, int height)
+{
+ av_image_copy(dst_data, dst_linesize, src_data, src_linesize,
+ pix_fmt, width, height);
}
+#endif
void av_picture_copy(AVPicture *dst, const AVPicture *src,
enum PixelFormat pix_fmt, int width, int height)
{
- int i;
- const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
- const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
-
- switch(pf->pixel_type) {
- case FF_PIXEL_PACKED:
- case FF_PIXEL_PLANAR:
- for(i = 0; i < pf->nb_channels; i++) {
- int h;
- int bwidth = ff_get_plane_bytewidth(pix_fmt, width, i);
- h = height;
- if (i == 1 || i == 2) {
- h= -((-height)>>desc->log2_chroma_h);
- }
- ff_img_copy_plane(dst->data[i], dst->linesize[i],
- src->data[i], src->linesize[i],
- bwidth, h);
- }
- break;
- case FF_PIXEL_PALETTE:
- ff_img_copy_plane(dst->data[0], dst->linesize[0],
- src->data[0], src->linesize[0],
- width, height);
- /* copy the palette */
- memcpy(dst->data[1], src->data[1], 4*256);
- break;
- }
+ av_image_copy(dst->data, dst->linesize, src->data,
+ src->linesize, pix_fmt, width, height);
}
/* 2x2 -> 1x1 */
@@ -1085,23 +813,14 @@ void ff_shrink88(uint8_t *dst, int dst_wrap,
int avpicture_alloc(AVPicture *picture,
enum PixelFormat pix_fmt, int width, int height)
{
- int size;
- void *ptr;
-
- size = avpicture_fill(picture, NULL, pix_fmt, width, height);
- if(size<0)
- goto fail;
- ptr = av_malloc(size);
- if (!ptr)
- goto fail;
- avpicture_fill(picture, ptr, pix_fmt, width, height);
- if(picture->data[1] && !picture->data[2])
- ff_set_systematic_pal((uint32_t*)picture->data[1], pix_fmt);
+ int ret;
+
+ if ((ret = av_image_alloc(picture->data, picture->linesize, width, height, pix_fmt, 1)) < 0) {
+ memset(picture, 0, sizeof(AVPicture));
+ return ret;
+ }
return 0;
- fail:
- memset(picture, 0, sizeof(AVPicture));
- return -1;
}
void avpicture_free(AVPicture *picture)
@@ -1246,61 +965,14 @@ int img_get_alpha_info(const AVPicture *src,
return ret;
}
-#if HAVE_MMX
-#define DEINT_INPLACE_LINE_LUM \
- movd_m2r(lum_m4[0],mm0);\
- movd_m2r(lum_m3[0],mm1);\
- movd_m2r(lum_m2[0],mm2);\
- movd_m2r(lum_m1[0],mm3);\
- movd_m2r(lum[0],mm4);\
- punpcklbw_r2r(mm7,mm0);\
- movd_r2m(mm2,lum_m4[0]);\
- punpcklbw_r2r(mm7,mm1);\
- punpcklbw_r2r(mm7,mm2);\
- punpcklbw_r2r(mm7,mm3);\
- punpcklbw_r2r(mm7,mm4);\
- paddw_r2r(mm3,mm1);\
- psllw_i2r(1,mm2);\
- paddw_r2r(mm4,mm0);\
- psllw_i2r(2,mm1);\
- paddw_r2r(mm6,mm2);\
- paddw_r2r(mm2,mm1);\
- psubusw_r2r(mm0,mm1);\
- psrlw_i2r(3,mm1);\
- packuswb_r2r(mm7,mm1);\
- movd_r2m(mm1,lum_m2[0]);
-
-#define DEINT_LINE_LUM \
- movd_m2r(lum_m4[0],mm0);\
- movd_m2r(lum_m3[0],mm1);\
- movd_m2r(lum_m2[0],mm2);\
- movd_m2r(lum_m1[0],mm3);\
- movd_m2r(lum[0],mm4);\
- punpcklbw_r2r(mm7,mm0);\
- punpcklbw_r2r(mm7,mm1);\
- punpcklbw_r2r(mm7,mm2);\
- punpcklbw_r2r(mm7,mm3);\
- punpcklbw_r2r(mm7,mm4);\
- paddw_r2r(mm3,mm1);\
- psllw_i2r(1,mm2);\
- paddw_r2r(mm4,mm0);\
- psllw_i2r(2,mm1);\
- paddw_r2r(mm6,mm2);\
- paddw_r2r(mm2,mm1);\
- psubusw_r2r(mm0,mm1);\
- psrlw_i2r(3,mm1);\
- packuswb_r2r(mm7,mm1);\
- movd_r2m(mm1,dst[0]);
-#endif
-
+#if !(HAVE_MMX && HAVE_YASM)
/* filter parameters: [-1 4 2 4 -1] // 8 */
-static void deinterlace_line(uint8_t *dst,
+static void deinterlace_line_c(uint8_t *dst,
const uint8_t *lum_m4, const uint8_t *lum_m3,
const uint8_t *lum_m2, const uint8_t *lum_m1,
const uint8_t *lum,
int size)
{
-#if !HAVE_MMX
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int sum;
@@ -1318,27 +990,12 @@ static void deinterlace_line(uint8_t *dst,
lum++;
dst++;
}
-#else
-
- {
- pxor_r2r(mm7,mm7);
- movq_m2r(ff_pw_4,mm6);
- }
- for (;size > 3; size-=4) {
- DEINT_LINE_LUM
- lum_m4+=4;
- lum_m3+=4;
- lum_m2+=4;
- lum_m1+=4;
- lum+=4;
- dst+=4;
- }
-#endif
}
-static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
- int size)
+
+static void deinterlace_line_inplace_c(uint8_t *lum_m4, uint8_t *lum_m3,
+ uint8_t *lum_m2, uint8_t *lum_m1,
+ uint8_t *lum, int size)
{
-#if !HAVE_MMX
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int sum;
@@ -1356,22 +1013,8 @@ static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *
lum_m1++;
lum++;
}
-#else
-
- {
- pxor_r2r(mm7,mm7);
- movq_m2r(ff_pw_4,mm6);
- }
- for (;size > 3; size-=4) {
- DEINT_INPLACE_LINE_LUM
- lum_m4+=4;
- lum_m3+=4;
- lum_m2+=4;
- lum_m1+=4;
- lum+=4;
- }
-#endif
}
+#endif
/* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The
top field is copied as is, but the bottom field is deinterlaced
@@ -1436,7 +1079,9 @@ int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int i;
if (pix_fmt != PIX_FMT_YUV420P &&
+ pix_fmt != PIX_FMT_YUVJ420P &&
pix_fmt != PIX_FMT_YUV422P &&
+ pix_fmt != PIX_FMT_YUVJ422P &&
pix_fmt != PIX_FMT_YUV444P &&
pix_fmt != PIX_FMT_YUV411P &&
pix_fmt != PIX_FMT_GRAY8)
@@ -1447,11 +1092,13 @@ int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
for(i=0;i<3;i++) {
if (i == 1) {
switch(pix_fmt) {
+ case PIX_FMT_YUVJ420P:
case PIX_FMT_YUV420P:
width >>= 1;
height >>= 1;
break;
case PIX_FMT_YUV422P:
+ case PIX_FMT_YUVJ422P:
width >>= 1;
break;
case PIX_FMT_YUV411P:
diff --git a/lib/ffmpeg/libavcodec/imgconvert.h b/lib/ffmpeg/libavcodec/imgconvert.h
index 48e2f12719..64da317d27 100644
--- a/lib/ffmpeg/libavcodec/imgconvert.h
+++ b/lib/ffmpeg/libavcodec/imgconvert.h
@@ -27,12 +27,18 @@
#include <stdint.h>
#include "avcodec.h"
+#if LIBAVCODEC_VERSION_MAJOR < 53
+attribute_deprecated
int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width);
+attribute_deprecated
int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, int height);
+attribute_deprecated
int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane);
+attribute_deprecated
int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt);
+#endif
#endif /* AVCODEC_IMGCONVERT_H */
diff --git a/lib/ffmpeg/libavcodec/imx_dump_header_bsf.c b/lib/ffmpeg/libavcodec/imx_dump_header_bsf.c
index 2310185b8e..8119809faa 100644
--- a/lib/ffmpeg/libavcodec/imx_dump_header_bsf.c
+++ b/lib/ffmpeg/libavcodec/imx_dump_header_bsf.c
@@ -52,7 +52,7 @@ static int imx_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx
return 1;
}
-AVBitStreamFilter imx_dump_header_bsf = {
+AVBitStreamFilter ff_imx_dump_header_bsf = {
"imxdump",
0,
imx_dump_header,
diff --git a/lib/ffmpeg/libavcodec/indeo2.c b/lib/ffmpeg/libavcodec/indeo2.c
index a3d6c80081..68c6246f89 100644
--- a/lib/ffmpeg/libavcodec/indeo2.c
+++ b/lib/ffmpeg/libavcodec/indeo2.c
@@ -224,7 +224,7 @@ static av_cold int ir2_decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec indeo2_decoder = {
+AVCodec ff_indeo2_decoder = {
"indeo2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_INDEO2,
diff --git a/lib/ffmpeg/libavcodec/indeo3.c b/lib/ffmpeg/libavcodec/indeo3.c
index 63d91da6a5..5c4cd0564a 100644
--- a/lib/ffmpeg/libavcodec/indeo3.c
+++ b/lib/ffmpeg/libavcodec/indeo3.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "bytestream.h"
@@ -995,7 +996,7 @@ static int iv_decode_frame(AVCodecContext *avctx,
image_height = bytestream_get_le16(&buf_pos);
image_width = bytestream_get_le16(&buf_pos);
- if(avcodec_check_dimensions(avctx, image_width, image_height))
+ if(av_image_check_size(image_width, image_height, 0, avctx))
return -1;
if (image_width != avctx->width || image_height != avctx->height) {
int ret;
@@ -1136,7 +1137,7 @@ static av_cold int indeo3_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec indeo3_decoder = {
+AVCodec ff_indeo3_decoder = {
"indeo3",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_INDEO3,
diff --git a/lib/ffmpeg/libavcodec/indeo5.c b/lib/ffmpeg/libavcodec/indeo5.c
index dd22d4fb9e..d96b31032f 100644
--- a/lib/ffmpeg/libavcodec/indeo5.c
+++ b/lib/ffmpeg/libavcodec/indeo5.c
@@ -84,8 +84,8 @@ typedef struct {
* This header is present in key frames only.
* It defines parameters for all frames in a GOP.
*
- * @param ctx [in,out] ptr to the decoder context
- * @param avctx [in] ptr to the AVCodecContext
+ * @param[in,out] ctx ptr to the decoder context
+ * @param[in] avctx ptr to the AVCodecContext
* @return result code: 0 = OK, -1 = error
*/
static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx)
@@ -298,7 +298,7 @@ static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx)
/**
* Skip a header extension.
*
- * @param gb [in,out] the GetBit context
+ * @param[in,out] gb the GetBit context
*/
static inline void skip_hdr_extension(GetBitContext *gb)
{
@@ -314,8 +314,8 @@ static inline void skip_hdr_extension(GetBitContext *gb)
/**
* Decode Indeo5 picture header.
*
- * @param ctx [in,out] ptr to the decoder context
- * @param avctx [in] ptr to the AVCodecContext
+ * @param[in,out] ctx ptr to the decoder context
+ * @param[in] avctx ptr to the AVCodecContext
* @return result code: 0 = OK, -1 = error
*/
static int decode_pic_hdr(IVI5DecContext *ctx, AVCodecContext *avctx)
@@ -366,9 +366,9 @@ static int decode_pic_hdr(IVI5DecContext *ctx, AVCodecContext *avctx)
/**
* Decode Indeo5 band header.
*
- * @param ctx [in,out] ptr to the decoder context
- * @param band [in,out] ptr to the band descriptor
- * @param avctx [in] ptr to the AVCodecContext
+ * @param[in,out] ctx ptr to the decoder context
+ * @param[in,out] band ptr to the band descriptor
+ * @param[in] avctx ptr to the AVCodecContext
* @return result code: 0 = OK, -1 = error
*/
static int decode_band_hdr(IVI5DecContext *ctx, IVIBandDesc *band,
@@ -435,10 +435,10 @@ static int decode_band_hdr(IVI5DecContext *ctx, IVIBandDesc *band,
* 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
- * @param band [in,out] ptr to the band descriptor
- * @param tile [in,out] ptr to the tile descriptor
- * @param avctx [in] ptr to the AVCodecContext
+ * @param[in,out] ctx ptr to the decoder context
+ * @param[in,out] band ptr to the band descriptor
+ * @param[in,out] tile ptr to the tile descriptor
+ * @param[in] avctx ptr to the AVCodecContext
* @return result code: 0 = OK, -1 = error
*/
static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
@@ -559,9 +559,9 @@ static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band,
/**
* Decode an Indeo5 band.
*
- * @param ctx [in,out] ptr to the decoder context
- * @param band [in,out] ptr to the band descriptor
- * @param avctx [in] ptr to the AVCodecContext
+ * @param[in,out] ctx ptr to the decoder context
+ * @param[in,out] band ptr to the band descriptor
+ * @param[in] avctx ptr to the AVCodecContext
* @return result code: 0 = OK, -1 = error
*/
static int decode_band(IVI5DecContext *ctx, int plane_num,
@@ -649,7 +649,7 @@ static int decode_band(IVI5DecContext *ctx, int plane_num,
/**
* Switch buffers.
*
- * @param ctx [in,out] ptr to the decoder context
+ * @param[in,out] ctx ptr to the decoder context
*/
static void switch_buffers(IVI5DecContext *ctx)
{
@@ -818,7 +818,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
}
-AVCodec indeo5_decoder = {
+AVCodec ff_indeo5_decoder = {
.name = "indeo5",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_INDEO5,
diff --git a/lib/ffmpeg/libavcodec/intelh263dec.c b/lib/ffmpeg/libavcodec/intelh263dec.c
index 5e451294da..00b15ce327 100644
--- a/lib/ffmpeg/libavcodec/intelh263dec.c
+++ b/lib/ffmpeg/libavcodec/intelh263dec.c
@@ -115,7 +115,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
return 0;
}
-AVCodec h263i_decoder = {
+AVCodec ff_h263i_decoder = {
"h263i",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H263I,
diff --git a/lib/ffmpeg/libavcodec/interplayvideo.c b/lib/ffmpeg/libavcodec/interplayvideo.c
index b98386f77c..18702b21d0 100644
--- a/lib/ffmpeg/libavcodec/interplayvideo.c
+++ b/lib/ffmpeg/libavcodec/interplayvideo.c
@@ -99,6 +99,10 @@ static int copy_from(IpvideoContext *s, AVFrame *src, int delta_x, int delta_y)
motion_offset, s->upper_motion_limit_offset);
return -1;
}
+ if (src->data[0] == NULL) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid decode type, corrupted header?\n");
+ return AVERROR(EINVAL);
+ }
s->dsp.put_pixels_tab[!s->is_16bpp][0](s->pixel_ptr, src->data[0] + motion_offset,
s->current_frame.linesize[0], 8);
return 0;
@@ -1093,7 +1097,7 @@ static av_cold int ipvideo_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec interplay_video_decoder = {
+AVCodec ff_interplay_video_decoder = {
"interplayvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_INTERPLAY_VIDEO,
diff --git a/lib/ffmpeg/libavcodec/inverse.c b/lib/ffmpeg/libavcodec/inverse.c
new file mode 100644
index 0000000000..04681d256b
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/inverse.c
@@ -0,0 +1 @@
+#include "libavutil/inverse.c"
diff --git a/lib/ffmpeg/libavcodec/ituh263dec.c b/lib/ffmpeg/libavcodec/ituh263dec.c
index 8b5d9391b2..728019accc 100644
--- a/lib/ffmpeg/libavcodec/ituh263dec.c
+++ b/lib/ffmpeg/libavcodec/ituh263dec.c
@@ -325,7 +325,7 @@ static int h263p_decode_umotion(MpegEncContext * s, int pred)
code >>= 1;
code = (sign) ? (pred - code) : (pred + code);
- dprintf(s->avctx,"H.263+ UMV Motion = %d\n", code);
+ av_dlog(s->avctx,"H.263+ UMV Motion = %d\n", code);
return code;
}
@@ -951,7 +951,7 @@ int h263_decode_picture_header(MpegEncContext *s)
if (ufep == 1) {
/* OPPTYPE */
format = get_bits(&s->gb, 3);
- dprintf(s->avctx, "ufep=1, format: %d\n", format);
+ av_dlog(s->avctx, "ufep=1, format: %d\n", format);
s->custom_pcf= get_bits1(&s->gb);
s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */
if (get_bits1(&s->gb) != 0) {
@@ -1002,7 +1002,7 @@ int h263_decode_picture_header(MpegEncContext *s)
if (format == 6) {
/* Custom Picture Format (CPFMT) */
s->aspect_ratio_info = get_bits(&s->gb, 4);
- dprintf(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
+ av_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
/* aspect ratios:
0 - forbidden
1 - 1:1
@@ -1015,7 +1015,7 @@ int h263_decode_picture_header(MpegEncContext *s)
width = (get_bits(&s->gb, 9) + 1) * 4;
skip_bits1(&s->gb);
height = get_bits(&s->gb, 9) * 4;
- dprintf(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
+ av_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
/* aspected dimensions */
s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
diff --git a/lib/ffmpeg/libavcodec/ituh263enc.c b/lib/ffmpeg/libavcodec/ituh263enc.c
index 2537838224..6a84636ec3 100644
--- a/lib/ffmpeg/libavcodec/ituh263enc.c
+++ b/lib/ffmpeg/libavcodec/ituh263enc.c
@@ -162,7 +162,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
put_bits(&s->pb, 3, 7);
put_bits(&s->pb,3,ufep); /* Update Full Extended PTYPE */
- if (format == 7)
+ if (format == 8)
put_bits(&s->pb,3,6); /* Custom Source Format */
else
put_bits(&s->pb, 3, format);
@@ -192,7 +192,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
/* This should be here if PLUSPTYPE */
put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */
- if (format == 7) {
+ if (format == 8) {
/* Custom Picture Format (CPFMT) */
s->aspect_ratio_info= ff_h263_aspect_to_info(s->avctx->sample_aspect_ratio);
diff --git a/lib/ffmpeg/libavcodec/ivi_common.c b/lib/ffmpeg/libavcodec/ivi_common.c
index b15845808f..0e552bccfe 100644
--- a/lib/ffmpeg/libavcodec/ivi_common.c
+++ b/lib/ffmpeg/libavcodec/ivi_common.c
@@ -404,6 +404,10 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
val = IVI_TOSIGNED((hi << 6) | lo); /* merge them and convert into signed val */
} else {
+ if (sym >= 256U) {
+ av_log(NULL, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
+ return -1;
+ }
run = rvmap->runtab[sym];
val = rvmap->valtab[sym];
}
diff --git a/lib/ffmpeg/libavcodec/ivi_common.h b/lib/ffmpeg/libavcodec/ivi_common.h
index 6f7ea90054..803c0580be 100644
--- a/lib/ffmpeg/libavcodec/ivi_common.h
+++ b/lib/ffmpeg/libavcodec/ivi_common.h
@@ -223,9 +223,9 @@ static inline int ivi_scale_mv(int mv, int mv_scale)
* 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
- * @param flag [in] flag: 1 - for static or 0 for dynamic tables
+ * @param[in] cb pointer to codebook descriptor
+ * @param[out] vlc where to place the generated VLC table
+ * @param[in] flag flag: 1 - for static or 0 for dynamic tables
* @return result code: 0 - OK, -1 = error (invalid codebook descriptor)
*/
int ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag);
@@ -239,11 +239,11 @@ void ff_ivi_init_static_vlc(void);
* 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
- * @param which_tab [in] codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
- * @param huff_tab [out] pointer to the descriptor of the selected table
- * @param avctx [in] AVCodecContext pointer
+ * @param[in,out] gb the GetBit context
+ * @param[in] desc_coded flag signalling if table descriptor was coded
+ * @param[in] which_tab codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
+ * @param[out] huff_tab pointer to the descriptor of the selected table
+ * @param[in] avctx AVCodecContext pointer
* @return zero on success, negative value otherwise
*/
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
@@ -252,8 +252,8 @@ int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
/**
* 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
+ * @param[in] desc1 ptr to the 1st descriptor to compare
+ * @param[in] desc2 ptr to the 2nd descriptor to compare
* @return comparison result: 0 - equal, 1 - not equal
*/
int ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2);
@@ -261,16 +261,16 @@ int ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2);
/**
* Copy huffman codebook descriptors.
*
- * @param dst [out] ptr to the destination descriptor
- * @param src [in] ptr to the source descriptor
+ * @param[out] dst ptr to the destination descriptor
+ * @param[in] src ptr to the source descriptor
*/
void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src);
/**
* 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
+ * @param[in,out] planes pointer to the array of the plane descriptors
+ * @param[in] cfg pointer to the ivi_pic_config structure describing picture layout
* @return result code: 0 - OK
*/
int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg);
@@ -278,16 +278,16 @@ int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg);
/**
* Free planes, bands and macroblocks buffers.
*
- * @param planes [in] pointer to the array of the plane descriptors
+ * @param[in] planes pointer to the array of the plane descriptors
*/
void ff_ivi_free_buffers(IVIPlaneDesc *planes);
/**
* Initialize tile and macroblock descriptors.
*
- * @param planes [in,out] pointer to the array of the plane descriptors
- * @param tile_width [in] tile width
- * @param tile_height [in] tile height
+ * @param[in,out] planes pointer to the array of the plane descriptors
+ * @param[in] tile_width tile width
+ * @param[in] tile_height tile height
* @return result code: 0 - OK
*/
int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
@@ -299,7 +299,7 @@ int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
* if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3
* where X1-X3 is size of the tile data
*
- * @param gb [in,out] the GetBit context
+ * @param[in,out] gb the GetBit context
* @return size of the tile data in bytes
*/
int ff_ivi_dec_tile_data_size(GetBitContext *gb);
@@ -310,9 +310,9 @@ int ff_ivi_dec_tile_data_size(GetBitContext *gb);
* dequantize them, apply inverse transform and motion compensation
* in order to reconstruct the picture.
*
- * @param gb [in,out] the GetBit context
- * @param band [in] pointer to the band descriptor
- * @param tile [in] pointer to the tile descriptor
+ * @param[in,out] gb the GetBit context
+ * @param[in] band pointer to the band descriptor
+ * @param[in] tile pointer to the tile descriptor
* @return result code: 0 - OK, -1 = error (corrupted blocks data)
*/
int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile);
@@ -321,10 +321,10 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile);
* Handle empty tiles by performing data copying and motion
* compensation respectively.
*
- * @param avctx [in] ptr to the AVCodecContext
- * @param band [in] pointer to the band descriptor
- * @param tile [in] pointer to the tile descriptor
- * @param mv_scale [in] scaling factor for motion vectors
+ * @param[in] avctx ptr to the AVCodecContext
+ * @param[in] band pointer to the band descriptor
+ * @param[in] tile pointer to the tile descriptor
+ * @param[in] mv_scale scaling factor for motion vectors
*/
void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
IVITile *tile, int32_t mv_scale);
@@ -334,9 +334,9 @@ void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
* This conversion is done by adding back the bias value of 128
* (subtracted in the encoder) and clipping the result.
*
- * @param plane [in] pointer to the descriptor of the plane being processed
- * @param dst [out] pointer to the buffer receiving converted pixels
- * @param dst_pitch [in] pitch for moving to the next y line
+ * @param[in] plane pointer to the descriptor of the plane being processed
+ * @param[out] dst pointer to the buffer receiving converted pixels
+ * @param[in] dst_pitch pitch for moving to the next y line
*/
void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch);
diff --git a/lib/ffmpeg/libavcodec/ivi_dsp.h b/lib/ffmpeg/libavcodec/ivi_dsp.h
index 927461f5aa..4fb2f80035 100644
--- a/lib/ffmpeg/libavcodec/ivi_dsp.h
+++ b/lib/ffmpeg/libavcodec/ivi_dsp.h
@@ -35,10 +35,10 @@
/**
* 5/3 wavelet recomposition filter for Indeo5
*
- * @param plane [in] pointer to the descriptor of the plane being processed
- * @param dst [out] pointer to the destination buffer
- * @param dst_pitch [in] pitch of the destination buffer
- * @param num_bands [in] number of wavelet bands to be processed
+ * @param[in] plane pointer to the descriptor of the plane being processed
+ * @param[out] dst pointer to the destination buffer
+ * @param[in] dst_pitch pitch of the destination buffer
+ * @param[in] num_bands number of wavelet bands to be processed
*/
void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
const int dst_pitch, const int num_bands);
@@ -46,10 +46,10 @@ void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
/**
* two-dimensional inverse slant 8x8 transform
*
- * @param in [in] pointer to the vector of transform coefficients
- * @param out [out] pointer to the output buffer (frame)
- * @param pitch [in] pitch to move to the next y line
- * @param flags [in] pointer to the array of column flags:
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
* != 0 - non_empty column, 0 - empty one
* (this array must be filled by caller)
*/
@@ -59,10 +59,10 @@ void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
/**
* two-dimensional inverse slant 4x4 transform
*
- * @param in [in] pointer to the vector of transform coefficients
- * @param out [out] pointer to the output buffer (frame)
- * @param pitch [in] pitch to move to the next y line
- * @param flags [in] pointer to the array of column flags:
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
* != 0 - non_empty column, 0 - empty one
* (this array must be filled by caller)
*/
@@ -75,20 +75,20 @@ void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch,
* spreading (DC_coeff + 1)/2 over the whole block.
* It works much faster than performing the slant transform on a vector of zeroes.
*
- * @param in [in] pointer to the dc coefficient
- * @param out [out] pointer to the output buffer (frame)
- * @param pitch [in] pitch to move to the next y line
- * @param blk_size [in] transform block size
+ * @param[in] in pointer to the dc coefficient
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] blk_size transform block size
*/
void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
/**
* inverse 1D row slant transform
*
- * @param in [in] pointer to the vector of transform coefficients
- * @param out [out] pointer to the output buffer (frame)
- * @param pitch [in] pitch to move to the next y line
- * @param flags [in] pointer to the array of column flags (unused here)
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags (unused here)
*/
void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
const uint8_t *flags);
@@ -96,10 +96,10 @@ void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
/**
* inverse 1D column slant transform
*
- * @param in [in] pointer to the vector of transform coefficients
- * @param out [out] pointer to the output buffer (frame)
- * @param pitch [in] pitch to move to the next y line
- * @param flags [in] pointer to the array of column flags:
+ * @param[in] in pointer to the vector of transform coefficients
+ * @param[out] out pointer to the output buffer (frame)
+ * @param[in] pitch pitch to move to the next y line
+ * @param[in] flags pointer to the array of column flags:
* != 0 - non_empty column, 0 - empty one
* (this array must be filled by caller)
*/
@@ -130,40 +130,40 @@ void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, in
/**
* 8x8 block motion compensation with adding delta
*
- * @param buf [in,out] pointer to the block in the current frame buffer containing delta
- * @param ref_buf [in] pointer to the corresponding block in the reference frame
- * @param pitch [in] pitch for moving to the next y line
- * @param mc_type [in] interpolation type
+ * @param[in,out] buf pointer to the block in the current frame buffer containing delta
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
*/
void ff_ivi_mc_8x8_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
/**
* 4x4 block motion compensation with adding delta
*
- * @param buf [in,out] pointer to the block in the current frame buffer containing delta
- * @param ref_buf [in] pointer to the corresponding block in the reference frame
- * @param pitch [in] pitch for moving to the next y line
- * @param mc_type [in] interpolation type
+ * @param[in,out] buf pointer to the block in the current frame buffer containing delta
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
*/
void ff_ivi_mc_4x4_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
/**
* motion compensation without adding delta
*
- * @param buf [in,out] pointer to the block in the current frame receiving the result
- * @param ref_buf [in] pointer to the corresponding block in the reference frame
- * @param pitch [in] pitch for moving to the next y line
- * @param mc_type [in] interpolation type
+ * @param[in,out] buf pointer to the block in the current frame receiving the result
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
*/
void ff_ivi_mc_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
/**
* 4x4 block motion compensation without adding delta
*
- * @param buf [in,out] pointer to the block in the current frame receiving the result
- * @param ref_buf [in] pointer to the corresponding block in the reference frame
- * @param pitch [in] pitch for moving to the next y line
- * @param mc_type [in] interpolation type
+ * @param[in,out] buf pointer to the block in the current frame receiving the result
+ * @param[in] ref_buf pointer to the corresponding block in the reference frame
+ * @param[in] pitch pitch for moving to the next y line
+ * @param[in] mc_type interpolation type
*/
void ff_ivi_mc_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
diff --git a/lib/ffmpeg/libavcodec/jpeglsdec.c b/lib/ffmpeg/libavcodec/jpeglsdec.c
index 6b7dd94647..7278e020da 100644
--- a/lib/ffmpeg/libavcodec/jpeglsdec.c
+++ b/lib/ffmpeg/libavcodec/jpeglsdec.c
@@ -363,7 +363,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor
}
-AVCodec jpegls_decoder = {
+AVCodec ff_jpegls_decoder = {
"jpegls",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_JPEGLS,
diff --git a/lib/ffmpeg/libavcodec/jpeglsenc.c b/lib/ffmpeg/libavcodec/jpeglsenc.c
index 08ef71f716..ce6dc10f39 100644
--- a/lib/ffmpeg/libavcodec/jpeglsenc.c
+++ b/lib/ffmpeg/libavcodec/jpeglsenc.c
@@ -382,7 +382,7 @@ static av_cold int encode_init_ls(AVCodecContext *ctx) {
return 0;
}
-AVCodec jpegls_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them
+AVCodec ff_jpegls_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them
"jpegls",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_JPEGLS,
diff --git a/lib/ffmpeg/libavcodec/kgv1dec.c b/lib/ffmpeg/libavcodec/kgv1dec.c
index 7ecb28d417..efc477f37d 100644
--- a/lib/ffmpeg/libavcodec/kgv1dec.c
+++ b/lib/ffmpeg/libavcodec/kgv1dec.c
@@ -25,6 +25,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
typedef struct {
@@ -50,7 +51,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
h = (buf[1] + 1) * 8;
buf += 2;
- if (avcodec_check_dimensions(avctx, w, h))
+ if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
@@ -163,7 +164,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec kgv1_decoder = {
+AVCodec ff_kgv1_decoder = {
"kgv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_KGV1,
diff --git a/lib/ffmpeg/libavcodec/kmvc.c b/lib/ffmpeg/libavcodec/kmvc.c
index 3e8dccd363..bd628d85c0 100644
--- a/lib/ffmpeg/libavcodec/kmvc.c
+++ b/lib/ffmpeg/libavcodec/kmvc.c
@@ -401,7 +401,7 @@ static av_cold int decode_end(AVCodecContext * avctx)
return 0;
}
-AVCodec kmvc_decoder = {
+AVCodec ff_kmvc_decoder = {
"kmvc",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_KMVC,
diff --git a/lib/ffmpeg/libavcodec/lagarith.c b/lib/ffmpeg/libavcodec/lagarith.c
new file mode 100644
index 0000000000..89580dc159
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/lagarith.c
@@ -0,0 +1,522 @@
+/*
+ * Lagarith lossless decoder
+ * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavcodec/lagarith.c
+ * Lagarith lossless decoder
+ * @author Nathan Caldwell
+ */
+
+#include "avcodec.h"
+#include "get_bits.h"
+#include "mathops.h"
+#include "dsputil.h"
+#include "lagarithrac.h"
+
+enum LagarithFrameType {
+ FRAME_RAW = 1, /*!< uncompressed */
+ FRAME_U_RGB24 = 2, /*!< unaligned RGB24 */
+ FRAME_ARITH_YUY2 = 3, /*!< arithmetic coded YUY2 */
+ FRAME_ARITH_RGB24 = 4, /*!< arithmetic coded RGB24 */
+ FRAME_SOLID_GRAY = 5, /*!< solid grayscale color frame */
+ FRAME_SOLID_COLOR = 6, /*!< solid non-grayscale color frame */
+ FRAME_OLD_ARITH_RGB = 7, /*!< obsolete arithmetic coded RGB (no longer encoded by upstream since version 1.1.0) */
+ FRAME_ARITH_RGBA = 8, /*!< arithmetic coded RGBA */
+ FRAME_SOLID_RGBA = 9, /*!< solid RGBA color frame */
+ FRAME_ARITH_YV12 = 10, /*!< arithmetic coded YV12 */
+ FRAME_REDUCED_RES = 11, /*!< reduced resolution YV12 frame */
+};
+
+typedef struct LagarithContext {
+ AVCodecContext *avctx;
+ AVFrame picture;
+ DSPContext dsp;
+ int zeros; /*!< number of consecutive zero bytes encountered */
+ int zeros_rem; /*!< number of zero bytes remaining to output */
+} LagarithContext;
+
+/**
+ * Compute the 52bit mantissa of 1/(double)denom.
+ * This crazy format uses floats in an entropy coder and we have to match x86
+ * rounding exactly, thus ordinary floats aren't portable enough.
+ * @param denom denominator
+ * @return 52bit mantissa
+ * @see softfloat_mul
+ */
+static uint64_t softfloat_reciprocal(uint32_t denom)
+{
+ int shift = av_log2(denom - 1) + 1;
+ uint64_t ret = (1ULL << 52) / denom;
+ uint64_t err = (1ULL << 52) - ret * denom;
+ ret <<= shift;
+ err <<= shift;
+ err += denom / 2;
+ return ret + err / denom;
+}
+
+/**
+ * (uint32_t)(x*f), where f has the given mantissa, and exponent 0
+ * Used in combination with softfloat_reciprocal computes x/(double)denom.
+ * @param x 32bit integer factor
+ * @param mantissa mantissa of f with exponent 0
+ * @return 32bit integer value (x*f)
+ * @see softfloat_reciprocal
+ */
+static uint32_t softfloat_mul(uint32_t x, uint64_t mantissa)
+{
+ uint64_t l = x * (mantissa & 0xffffffff);
+ uint64_t h = x * (mantissa >> 32);
+ h += l >> 32;
+ l &= 0xffffffff;
+ l += 1 << av_log2(h >> 21);
+ h += l >> 32;
+ return h >> 20;
+}
+
+static uint8_t lag_calc_zero_run(int8_t x)
+{
+ return (x << 1) ^ (x >> 7);
+}
+
+static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
+{
+ static const uint8_t series[] = { 1, 2, 3, 5, 8, 13, 21 };
+ int i;
+ int bit = 0;
+ int bits = 0;
+ int prevbit = 0;
+ unsigned val;
+
+ for (i = 0; i < 7; i++) {
+ if (prevbit && bit)
+ break;
+ prevbit = bit;
+ bit = get_bits1(gb);
+ if (bit && !prevbit)
+ bits += series[i];
+ }
+ bits--;
+ if (bits < 0 || bits > 31) {
+ *value = 0;
+ return -1;
+ } else if (bits == 0) {
+ *value = 0;
+ return 0;
+ }
+
+ val = get_bits_long(gb, bits);
+ val |= 1 << bits;
+
+ *value = val - 1;
+
+ return 0;
+}
+
+static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb)
+{
+ int i, j, scale_factor;
+ unsigned prob, cumulative_target;
+ unsigned cumul_prob = 0;
+ unsigned scaled_cumul_prob = 0;
+
+ rac->prob[0] = 0;
+ rac->prob[257] = UINT_MAX;
+ /* Read probabilities from bitstream */
+ for (i = 1; i < 257; i++) {
+ if (lag_decode_prob(gb, &rac->prob[i]) < 0) {
+ av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability encountered.\n");
+ return -1;
+ }
+ if ((uint64_t)cumul_prob + rac->prob[i] > UINT_MAX) {
+ av_log(rac->avctx, AV_LOG_ERROR, "Integer overflow encountered in cumulative probability calculation.\n");
+ return -1;
+ }
+ cumul_prob += rac->prob[i];
+ if (!rac->prob[i]) {
+ if (lag_decode_prob(gb, &prob)) {
+ av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability run encountered.\n");
+ return -1;
+ }
+ if (prob > 257 - i)
+ prob = 257 - i;
+ for (j = 0; j < prob; j++)
+ rac->prob[++i] = 0;
+ }
+ }
+
+ if (!cumul_prob) {
+ av_log(rac->avctx, AV_LOG_ERROR, "All probabilities are 0!\n");
+ return -1;
+ }
+
+ /* Scale probabilities so cumulative probability is an even power of 2. */
+ scale_factor = av_log2(cumul_prob);
+
+ if (cumul_prob & (cumul_prob - 1)) {
+ uint64_t mul = softfloat_reciprocal(cumul_prob);
+ for (i = 1; i < 257; i++) {
+ rac->prob[i] = softfloat_mul(rac->prob[i], mul);
+ scaled_cumul_prob += rac->prob[i];
+ }
+
+ scale_factor++;
+ cumulative_target = 1 << scale_factor;
+
+ if (scaled_cumul_prob > cumulative_target) {
+ av_log(rac->avctx, AV_LOG_ERROR,
+ "Scaled probabilities are larger than target!\n");
+ return -1;
+ }
+
+ scaled_cumul_prob = cumulative_target - scaled_cumul_prob;
+
+ for (i = 1; scaled_cumul_prob; i = (i & 0x7f) + 1) {
+ if (rac->prob[i]) {
+ rac->prob[i]++;
+ scaled_cumul_prob--;
+ }
+ /* Comment from reference source:
+ * if (b & 0x80 == 0) { // order of operations is 'wrong'; it has been left this way
+ * // since the compression change is negligable and fixing it
+ * // breaks backwards compatibilty
+ * b =- (signed int)b;
+ * b &= 0xFF;
+ * } else {
+ * b++;
+ * b &= 0x7f;
+ * }
+ */
+ }
+ }
+
+ rac->scale = scale_factor;
+
+ /* Fill probability array with cumulative probability for each symbol. */
+ for (i = 1; i < 257; i++)
+ rac->prob[i] += rac->prob[i - 1];
+
+ return 0;
+}
+
+static void add_lag_median_prediction(uint8_t *dst, uint8_t *src1,
+ uint8_t *diff, int w, int *left,
+ int *left_top)
+{
+ /* This is almost identical to add_hfyu_median_prediction in dsputil.h.
+ * However the &0xFF on the gradient predictor yealds incorrect output
+ * for lagarith.
+ */
+ int i;
+ uint8_t l, lt;
+
+ l = *left;
+ lt = *left_top;
+
+ for (i = 0; i < w; i++) {
+ l = mid_pred(l, src1[i], l + src1[i] - lt) + diff[i];
+ lt = src1[i];
+ dst[i] = l;
+ }
+
+ *left = l;
+ *left_top = lt;
+}
+
+static void lag_pred_line(LagarithContext *l, uint8_t *buf,
+ int width, int stride, int line)
+{
+ int L, TL;
+
+ if (!line) {
+ /* Left prediction only for first line */
+ L = l->dsp.add_hfyu_left_prediction(buf + 1, buf + 1,
+ width - 1, buf[0]);
+ return;
+ } else if (line == 1) {
+ /* Second line, left predict first pixel, the rest of the line is median predicted */
+ /* FIXME: In the case of RGB this pixel is top predicted */
+ TL = buf[-stride];
+ } else {
+ /* Top left is 2 rows back, last pixel */
+ TL = buf[width - (2 * stride) - 1];
+ }
+ /* Left pixel is actually prev_row[width] */
+ L = buf[width - stride - 1];
+
+ add_lag_median_prediction(buf, buf - stride, buf,
+ width, &L, &TL);
+}
+
+static int lag_decode_line(LagarithContext *l, lag_rac *rac,
+ uint8_t *dst, int width, int stride,
+ int esc_count)
+{
+ int i = 0;
+ int ret = 0;
+
+ if (!esc_count)
+ esc_count = -1;
+
+ /* Output any zeros remaining from the previous run */
+handle_zeros:
+ if (l->zeros_rem) {
+ int count = FFMIN(l->zeros_rem, width - i);
+ memset(dst + i, 0, count);
+ i += count;
+ l->zeros_rem -= count;
+ }
+
+ while (i < width) {
+ dst[i] = lag_get_rac(rac);
+ ret++;
+
+ if (dst[i])
+ l->zeros = 0;
+ else
+ l->zeros++;
+
+ i++;
+ if (l->zeros == esc_count) {
+ int index = lag_get_rac(rac);
+ ret++;
+
+ l->zeros = 0;
+
+ l->zeros_rem = lag_calc_zero_run(index);
+ goto handle_zeros;
+ }
+ }
+ return ret;
+}
+
+static int lag_decode_zero_run_line(LagarithContext *l, uint8_t *dst,
+ const uint8_t *src, int width,
+ int esc_count)
+{
+ int i = 0;
+ int count;
+ uint8_t zero_run = 0;
+ const uint8_t *start = src;
+ uint8_t mask1 = -(esc_count < 2);
+ uint8_t mask2 = -(esc_count < 3);
+ uint8_t *end = dst + (width - 2);
+
+output_zeros:
+ if (l->zeros_rem) {
+ count = FFMIN(l->zeros_rem, width - i);
+ memset(dst, 0, count);
+ l->zeros_rem -= count;
+ dst += count;
+ }
+
+ while (dst < end) {
+ i = 0;
+ while (!zero_run && dst + i < end) {
+ i++;
+ zero_run =
+ !(src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2));
+ }
+ if (zero_run) {
+ zero_run = 0;
+ i += esc_count;
+ memcpy(dst, src, i);
+ dst += i;
+ l->zeros_rem = lag_calc_zero_run(src[i]);
+
+ src += i + 1;
+ goto output_zeros;
+ } else {
+ memcpy(dst, src, i);
+ src += i;
+ }
+ }
+ return start - src;
+}
+
+
+
+static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,
+ int width, int height, int stride,
+ const uint8_t *src, int src_size)
+{
+ int i = 0;
+ int read = 0;
+ uint32_t length;
+ uint32_t offset = 1;
+ int esc_count = src[0];
+ GetBitContext gb;
+ lag_rac rac;
+
+ rac.avctx = l->avctx;
+ l->zeros = 0;
+
+ if (esc_count < 4) {
+ length = width * height;
+ if (esc_count && AV_RL32(src + 1) < length) {
+ length = AV_RL32(src + 1);
+ offset += 4;
+ }
+
+ init_get_bits(&gb, src + offset, src_size * 8);
+
+ if (lag_read_prob_header(&rac, &gb) < 0)
+ return -1;
+
+ lag_rac_init(&rac, &gb, length - stride);
+
+ for (i = 0; i < height; i++)
+ read += lag_decode_line(l, &rac, dst + (i * stride), width,
+ stride, esc_count);
+
+ if (read > length)
+ av_log(l->avctx, AV_LOG_WARNING,
+ "Output more bytes than length (%d of %d)\n", read,
+ length);
+ } else if (esc_count < 8) {
+ esc_count -= 4;
+ if (esc_count > 0) {
+ /* Zero run coding only, no range coding. */
+ for (i = 0; i < height; i++)
+ src += lag_decode_zero_run_line(l, dst + (i * stride), src,
+ width, esc_count);
+ } else {
+ /* Plane is stored uncompressed */
+ for (i = 0; i < height; i++) {
+ memcpy(dst + (i * stride), src, width);
+ src += width;
+ }
+ }
+ } else if (esc_count == 0xff) {
+ /* Plane is a solid run of given value */
+ for (i = 0; i < height; i++)
+ memset(dst + i * stride, src[1], width);
+ /* Do not apply prediction.
+ Note: memset to 0 above, setting first value to src[1]
+ and applying prediction gives the same result. */
+ return 0;
+ } else {
+ av_log(l->avctx, AV_LOG_ERROR,
+ "Invalid zero run escape code! (%#x)\n", esc_count);
+ return -1;
+ }
+
+ for (i = 0; i < height; i++) {
+ lag_pred_line(l, dst, width, stride, i);
+ dst += stride;
+ }
+
+ return 0;
+}
+
+/**
+ * Decode a frame.
+ * @param avctx codec context
+ * @param data output AVFrame
+ * @param data_size size of output data or 0 if no picture is returned
+ * @param avpkt input packet
+ * @return number of consumed bytes on success or negative if decode fails
+ */
+static int lag_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size, AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ LagarithContext *l = avctx->priv_data;
+ AVFrame *const p = &l->picture;
+ uint8_t frametype = 0;
+ uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9;
+
+ AVFrame *picture = data;
+
+ if (p->data[0])
+ avctx->release_buffer(avctx, p);
+
+ p->reference = 0;
+ p->key_frame = 1;
+
+ frametype = buf[0];
+
+ offset_gu = AV_RL32(buf + 1);
+ offset_bv = AV_RL32(buf + 5);
+
+ switch (frametype) {
+ case FRAME_ARITH_YV12:
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+
+ if (avctx->get_buffer(avctx, p) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return -1;
+ }
+
+ lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height,
+ p->linesize[0], buf + offset_ry,
+ buf_size);
+ lag_decode_arith_plane(l, p->data[2], avctx->width / 2,
+ avctx->height / 2, p->linesize[2],
+ buf + offset_gu, buf_size);
+ lag_decode_arith_plane(l, p->data[1], avctx->width / 2,
+ avctx->height / 2, p->linesize[1],
+ buf + offset_bv, buf_size);
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR,
+ "Unsupported Lagarith frame type: %#x\n", frametype);
+ return -1;
+ }
+
+ *picture = *p;
+ *data_size = sizeof(AVFrame);
+
+ return buf_size;
+}
+
+static av_cold int lag_decode_init(AVCodecContext *avctx)
+{
+ LagarithContext *l = avctx->priv_data;
+ l->avctx = avctx;
+
+ dsputil_init(&l->dsp, avctx);
+
+ return 0;
+}
+
+static av_cold int lag_decode_end(AVCodecContext *avctx)
+{
+ LagarithContext *l = avctx->priv_data;
+
+ if (l->picture.data[0])
+ avctx->release_buffer(avctx, &l->picture);
+
+ return 0;
+}
+
+AVCodec ff_lagarith_decoder = {
+ "lagarith",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_LAGARITH,
+ sizeof(LagarithContext),
+ lag_decode_init,
+ NULL,
+ lag_decode_end,
+ lag_decode_frame,
+ CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("Lagarith lossless"),
+};
diff --git a/lib/ffmpeg/libavcodec/lagarithrac.c b/lib/ffmpeg/libavcodec/lagarithrac.c
new file mode 100644
index 0000000000..0cbc3b84df
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/lagarithrac.c
@@ -0,0 +1,58 @@
+/*
+ * Lagarith range decoder
+ * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com>
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavcodec/lagarithrac.c
+ * Lagarith range decoder
+ * @author Nathan Caldwell
+ * @author David Conrad
+ */
+
+#include "get_bits.h"
+#include "lagarithrac.h"
+
+void lag_rac_init(lag_rac *l, GetBitContext *gb, int length)
+{
+ int i, j;
+
+ /* According to reference decoder "1st byte is garbage",
+ * however, it gets skipped by the call to align_get_bits()
+ */
+ align_get_bits(gb);
+ l->bytestream_start =
+ l->bytestream = gb->buffer + get_bits_count(gb) / 8;
+ l->bytestream_end = l->bytestream_start + length;
+
+ l->range = 0x80;
+ l->low = *l->bytestream >> 1;
+ l->hash_shift = FFMAX(l->scale - 8, 0);
+
+ for (i = j = 0; i < 256; i++) {
+ unsigned r = i << l->hash_shift;
+ while (l->prob[j + 1] <= r)
+ j++;
+ l->range_hash[i] = j;
+ }
+
+ /* Add conversion factor to hash_shift so we don't have to in lag_get_rac. */
+ l->hash_shift += 23;
+}
diff --git a/lib/ffmpeg/libavcodec/lagarithrac.h b/lib/ffmpeg/libavcodec/lagarithrac.h
new file mode 100644
index 0000000000..d985b60353
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/lagarithrac.h
@@ -0,0 +1,116 @@
+/*
+ * Lagarith range decoder
+ * Copyright (c) 2009 Nathan Caldwell <saintdev (at) gmail.com>
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file libavcodec/lagarithrac.h
+ * Lagarith range decoder
+ * @author Nathan Caldwell
+ * @author David Conrad
+ */
+
+#ifndef AVCODEC_LAGARITHRAC_H
+#define AVCODEC_LAGARITHRAC_H
+
+#include <stdint.h>
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "get_bits.h"
+
+typedef struct lag_rac {
+ AVCodecContext *avctx;
+ unsigned low;
+ unsigned range;
+ unsigned scale; /*!< Number of bits of precision in range. */
+ unsigned hash_shift; /*!< Number of bits to shift to calculate hash for radix search. */
+
+ const uint8_t *bytestream_start; /*!< Start of input bytestream. */
+ const uint8_t *bytestream; /*!< Current position in input bytestream. */
+ const uint8_t *bytestream_end; /*!< End position of input bytestream. */
+
+ uint32_t prob[258]; /*!< Table of cumulative probability for each symbol. */
+ uint8_t range_hash[256]; /*!< Hash table mapping upper byte to approximate symbol. */
+} lag_rac;
+
+void lag_rac_init(lag_rac *l, GetBitContext *gb, int length);
+
+/* TODO: Optimize */
+static inline void lag_rac_refill(lag_rac *l)
+{
+ while (l->range <= 0x800000) {
+ l->low <<= 8;
+ l->range <<= 8;
+ l->low |= 0xff & (AV_RB16(l->bytestream) >> 1);
+ if (l->bytestream < l->bytestream_end)
+ l->bytestream++;
+ }
+}
+
+/**
+ * Decode a single byte from the compressed plane described by *l.
+ * @param l pointer to lag_rac for the current plane
+ * @return next byte of decoded data
+ */
+static inline uint8_t lag_get_rac(lag_rac *l)
+{
+ unsigned range_scaled, low_scaled, div;
+ int val;
+ uint8_t shift;
+
+ lag_rac_refill(l);
+
+ range_scaled = l->range >> l->scale;
+
+ if (l->low < range_scaled * l->prob[255]) {
+ /* val = 0 is frequent enough to deserve a shortcut */
+ if (l->low < range_scaled * l->prob[1]) {
+ val = 0;
+ } else {
+ /* FIXME __builtin_clz is ~20% faster here, but not allowed in generic code. */
+ shift = 30 - av_log2(range_scaled);
+ div = ((range_scaled << shift) + (1 << 23) - 1) >> 23;
+ /* low>>24 ensures that any cases too big for exact FASTDIV are
+ * under- rather than over-estimated
+ */
+ low_scaled = FASTDIV(l->low - (l->low >> 24), div);
+ shift -= l->hash_shift;
+ shift &= 31;
+ low_scaled = (low_scaled << shift) | (low_scaled >> (32 - shift));
+ /* low_scaled is now a lower bound of low/range_scaled */
+ val = l->range_hash[(uint8_t) low_scaled];
+ while (l->low >= range_scaled * l->prob[val + 1])
+ val++;
+ }
+
+ l->range = range_scaled * (l->prob[val + 1] - l->prob[val]);
+ } else {
+ val = 255;
+ l->range -= range_scaled * l->prob[255];
+ }
+
+ l->low -= range_scaled * l->prob[val];
+
+ return val;
+}
+
+
+#endif /* AVCODEC_LAGARITHRAC_H */
diff --git a/lib/ffmpeg/libavcodec/latm_parser.c b/lib/ffmpeg/libavcodec/latm_parser.c
index 4ac90c8d3d..8e42c6ace9 100644
--- a/lib/ffmpeg/libavcodec/latm_parser.c
+++ b/lib/ffmpeg/libavcodec/latm_parser.c
@@ -19,21 +19,16 @@
*/
/**
- * @file latm_parser.c
- * LATM parser
+ * @file
+ * AAC LATM parser
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/types.h>
-
+#include <stdint.h>
#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
+#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;
@@ -45,71 +40,72 @@ typedef struct LATMParseContext{
* @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) {
+ int buf_size)
+{
LATMParseContext *s = s1->priv_data;
- ParseContext *pc = &s->pc;
+ ParseContext *pc = &s->pc;
int pic_found, i;
uint32_t state;
pic_found = pc->frame_start_found;
- state = pc->state;
+ state = pc->state;
i = 0;
- if(!pic_found){
- for(i=0; i<buf_size; i++){
+ if (!pic_found) {
+ for (i = 0; i < buf_size; i++) {
state = (state<<8) | buf[i];
- if((state & LATM_MASK) == LATM_HEADER) {
+ if ((state & LATM_MASK) == LATM_HEADER) {
i++;
- s->count = - i;
- pic_found=1;
+ s->count = -i;
+ pic_found = 1;
break;
}
}
}
- if(pic_found){
+ if (pic_found) {
/* EOF considered as end of frame */
if (buf_size == 0)
return 0;
- if((state & LATM_SIZE_MASK) - s->count <= buf_size) {
+ if ((state & LATM_SIZE_MASK) - s->count <= buf_size) {
pc->frame_start_found = 0;
- pc->state = -1;
+ pc->state = -1;
return (state & LATM_SIZE_MASK) - s->count;
- }
+ }
}
- s->count += buf_size;
+ s->count += buf_size;
pc->frame_start_found = pic_found;
- pc->state = state;
+ 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)
+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;
+ ParseContext *pc = &s->pc;
int next;
- if(s1->flags & PARSER_FLAG_COMPLETE_FRAMES){
+ if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
next = buf_size;
- }else{
+ } else {
next = latm_find_frame_end(s1, buf, buf_size);
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
+ *poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
}
- *poutbuf = buf;
+ *poutbuf = buf;
*poutbuf_size = buf_size;
return next;
}
-AVCodecParser latm_parser = {
+AVCodecParser ff_aac_latm_parser = {
{ CODEC_ID_AAC_LATM },
sizeof(LATMParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/latmaac.c b/lib/ffmpeg/libavcodec/latmaac.c
deleted file mode 100644
index c2241649fc..0000000000
--- a/lib/ffmpeg/libavcodec/latmaac.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/types.h>
-
-#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<muxSlotLengthBytes; j++) {
- *payload++ = get_bits(b, 8);
- }
- *payloadsize = muxSlotLengthBytes;
- }
-}
-
-static int readAudioSyncStream(struct AACDecoder *parser, GetBitContext *b, int size, uint8_t *payload, int *payloadsize)
-{
- int muxlength;
-
- if (get_bits(b, 11) != SYNC_LATM) return -1; // not LATM
-
- muxlength = get_bits(b, 13);
- if (muxlength+3 > 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/lib/ffmpeg/libavcodec/lcldec.c b/lib/ffmpeg/libavcodec/lcldec.c
index 23af511455..f2e5bb0c80 100644
--- a/lib/ffmpeg/libavcodec/lcldec.c
+++ b/lib/ffmpeg/libavcodec/lcldec.c
@@ -609,7 +609,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
}
#if CONFIG_MSZH_DECODER
-AVCodec mszh_decoder = {
+AVCodec ff_mszh_decoder = {
"mszh",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSZH,
@@ -624,7 +624,7 @@ AVCodec mszh_decoder = {
#endif
#if CONFIG_ZLIB_DECODER
-AVCodec zlib_decoder = {
+AVCodec ff_zlib_decoder = {
"zlib",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ZLIB,
diff --git a/lib/ffmpeg/libavcodec/lclenc.c b/lib/ffmpeg/libavcodec/lclenc.c
index 8d7c5bf4e6..a90c1cf588 100644
--- a/lib/ffmpeg/libavcodec/lclenc.c
+++ b/lib/ffmpeg/libavcodec/lclenc.c
@@ -130,16 +130,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
// Will be user settable someday
c->compression = 6;
c->flags = 0;
-
- switch(avctx->pix_fmt){
- case PIX_FMT_BGR24:
- c->imgtype = IMGTYPE_RGB24;
- avctx->bits_per_coded_sample= 24;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Input pixel format %s not supported\n", avcodec_get_pix_fmt_name(avctx->pix_fmt));
- return -1;
- }
+ c->imgtype = IMGTYPE_RGB24;
+ avctx->bits_per_coded_sample= 24;
avctx->extradata[0]= 4;
avctx->extradata[1]= 0;
@@ -178,7 +170,7 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec zlib_encoder = {
+AVCodec ff_zlib_encoder = {
"zlib",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ZLIB,
@@ -186,5 +178,6 @@ AVCodec zlib_encoder = {
encode_init,
encode_frame,
encode_end,
+ .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_BGR24, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"),
};
diff --git a/lib/ffmpeg/libavcodec/libavcodec.v b/lib/ffmpeg/libavcodec/libavcodec.v
index 561a42cd4f..65699038ab 100644
--- a/lib/ffmpeg/libavcodec/libavcodec.v
+++ b/lib/ffmpeg/libavcodec/libavcodec.v
@@ -1,3 +1,9 @@
LIBAVCODEC_$MAJOR {
global: *;
+ local:
+ ff_*_bsf;
+ ff_*_decoder;
+ ff_*_encoder;
+ ff_*_hwaccel;
+ ff_*_parser;
};
diff --git a/lib/ffmpeg/libavcodec/libdiracdec.c b/lib/ffmpeg/libavcodec/libdiracdec.c
index d24d3baf99..520ec3f03a 100644
--- a/lib/ffmpeg/libavcodec/libdiracdec.c
+++ b/lib/ffmpeg/libavcodec/libdiracdec.c
@@ -28,6 +28,7 @@
* (http://dirac.sourceforge.net/specification.html).
*/
+#include "libavcore/imgutils.h"
#include "libdirac.h"
#undef NDEBUG
@@ -105,8 +106,8 @@ static int libdirac_decode_frame(AVCodecContext *avccontext,
/* tell FFmpeg about sequence details */
dirac_sourceparams_t *src_params = &p_dirac_params->p_decoder->src_params;
- if (avcodec_check_dimensions(avccontext, src_params->width,
- src_params->height) < 0) {
+ if (av_image_check_size(src_params->width, src_params->height,
+ 0, avccontext) < 0) {
av_log(avccontext, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n",
src_params->width, src_params->height);
avccontext->height = avccontext->width = 0;
@@ -193,7 +194,7 @@ static void libdirac_flush(AVCodecContext *avccontext)
-AVCodec libdirac_decoder = {
+AVCodec ff_libdirac_decoder = {
"libdirac",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DIRAC,
diff --git a/lib/ffmpeg/libavcodec/libdiracenc.c b/lib/ffmpeg/libavcodec/libdiracenc.c
index d390aa8a7b..a9cc6803b9 100644
--- a/lib/ffmpeg/libavcodec/libdiracenc.c
+++ b/lib/ffmpeg/libavcodec/libdiracenc.c
@@ -391,7 +391,7 @@ static av_cold int libdirac_encode_close(AVCodecContext *avccontext)
}
-AVCodec libdirac_encoder = {
+AVCodec ff_libdirac_encoder = {
"libdirac",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DIRAC,
diff --git a/lib/ffmpeg/libavcodec/libfaac.c b/lib/ffmpeg/libavcodec/libfaac.c
index bf403567c5..af85587272 100644
--- a/lib/ffmpeg/libavcodec/libfaac.c
+++ b/lib/ffmpeg/libavcodec/libfaac.c
@@ -124,10 +124,11 @@ static int Faac_encode_frame(AVCodecContext *avctx,
{
FaacAudioContext *s = avctx->priv_data;
int bytes_written;
+ int num_samples = data ? avctx->frame_size : 0;
bytes_written = faacEncEncode(s->faac_handle,
data,
- avctx->frame_size * avctx->channels,
+ num_samples * avctx->channels,
frame,
buf_size);
@@ -147,13 +148,13 @@ static av_cold int Faac_encode_close(AVCodecContext *avctx)
static const AVProfile profiles[] = {
{ FF_PROFILE_AAC_MAIN, "Main" },
- { FF_PROFILE_AAC_LOW, "Low" },
+ { FF_PROFILE_AAC_LOW, "LC" },
{ FF_PROFILE_AAC_SSR, "SSR" },
{ FF_PROFILE_AAC_LTP, "LTP" },
{ FF_PROFILE_UNKNOWN },
};
-AVCodec libfaac_encoder = {
+AVCodec ff_libfaac_encoder = {
"libfaac",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AAC,
@@ -161,7 +162,8 @@ AVCodec libfaac_encoder = {
Faac_encode_init,
Faac_encode_frame,
Faac_encode_close,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Codec)"),
- .profiles = profiles,
+ .profiles = NULL_IF_CONFIG_SMALL(profiles),
};
diff --git a/lib/ffmpeg/libavcodec/libfaad.c b/lib/ffmpeg/libavcodec/libfaad.c
deleted file mode 100644
index 679729ad2c..0000000000
--- a/lib/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 <dlfcn.h>
-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/lib/ffmpeg/libavcodec/libgsm.c b/lib/ffmpeg/libavcodec/libgsm.c
index a7bc68ad71..1f76f82d55 100644
--- a/lib/ffmpeg/libavcodec/libgsm.c
+++ b/lib/ffmpeg/libavcodec/libgsm.c
@@ -49,7 +49,7 @@ static av_cold int libgsm_init(AVCodecContext *avctx) {
if(!avctx->sample_rate)
avctx->sample_rate= 8000;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
}else{
if (avctx->sample_rate != 8000) {
av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n",
@@ -112,7 +112,7 @@ static int libgsm_encode_frame(AVCodecContext *avctx,
}
-AVCodec libgsm_encoder = {
+AVCodec ff_libgsm_encoder = {
"libgsm",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_GSM,
@@ -120,11 +120,11 @@ AVCodec libgsm_encoder = {
libgsm_init,
libgsm_encode_frame,
libgsm_close,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
-AVCodec libgsm_ms_encoder = {
+AVCodec ff_libgsm_ms_encoder = {
"libgsm_ms",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_GSM_MS,
@@ -132,7 +132,7 @@ AVCodec libgsm_ms_encoder = {
libgsm_init,
libgsm_encode_frame,
libgsm_close,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"),
};
@@ -156,7 +156,7 @@ static int libgsm_decode_frame(AVCodecContext *avctx,
return avctx->block_align;
}
-AVCodec libgsm_decoder = {
+AVCodec ff_libgsm_decoder = {
"libgsm",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_GSM,
@@ -168,7 +168,7 @@ AVCodec libgsm_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"),
};
-AVCodec libgsm_ms_decoder = {
+AVCodec ff_libgsm_ms_decoder = {
"libgsm_ms",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_GSM_MS,
diff --git a/lib/ffmpeg/libavcodec/libmp3lame.c b/lib/ffmpeg/libavcodec/libmp3lame.c
index 1d74d6d59d..db0bc8259c 100644
--- a/lib/ffmpeg/libavcodec/libmp3lame.c
+++ b/lib/ffmpeg/libavcodec/libmp3lame.c
@@ -55,13 +55,12 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
} else {
lame_set_quality(s->gfp, avctx->compression_level);
}
- /* lame 3.91 doesn't work in mono */
- lame_set_mode(s->gfp, JOINT_STEREO);
+ lame_set_mode(s->gfp, s->stereo ? JOINT_STEREO : MONO);
lame_set_brate(s->gfp, avctx->bit_rate/1000);
if(avctx->flags & CODEC_FLAG_QSCALE) {
lame_set_brate(s->gfp, 0);
lame_set_VBR(s->gfp, vbr_default);
- lame_set_VBR_q(s->gfp, avctx->global_quality / (float)FF_QP2LAMBDA);
+ lame_set_VBR_quality(s->gfp, avctx->global_quality/(float)FF_QP2LAMBDA);
}
lame_set_bWriteVbrTag(s->gfp,0);
lame_set_disable_reservoir(s->gfp, avctx->flags2 & CODEC_FLAG2_BIT_RESERVOIR ? 0 : 1);
@@ -214,7 +213,7 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx)
}
-AVCodec libmp3lame_encoder = {
+AVCodec ff_libmp3lame_encoder = {
"libmp3lame",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MP3,
@@ -223,7 +222,7 @@ AVCodec libmp3lame_encoder = {
MP3lame_encode_frame,
MP3lame_encode_close,
.capabilities= CODEC_CAP_DELAY,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.supported_samplerates= sSampleRates,
.long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
};
diff --git a/lib/ffmpeg/libavcodec/libopencore-amr.c b/lib/ffmpeg/libavcodec/libopencore-amr.c
index 266164514f..b2e2f1632e 100644
--- a/lib/ffmpeg/libavcodec/libopencore-amr.c
+++ b/lib/ffmpeg/libavcodec/libopencore-amr.c
@@ -32,7 +32,7 @@ static void amr_decode_fix_avctx(AVCodecContext *avctx)
avctx->channels = 1;
avctx->frame_size = 160 * is_amr_wb;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
}
#if CONFIG_LIBOPENCORE_AMRNB
@@ -139,7 +139,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
return packet_size;
}
-AVCodec libopencore_amrnb_decoder = {
+AVCodec ff_libopencore_amrnb_decoder = {
"libopencore_amrnb",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AMR_NB,
@@ -213,7 +213,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx,
return written;
}
-AVCodec libopencore_amrnb_encoder = {
+AVCodec ff_libopencore_amrnb_encoder = {
"libopencore_amrnb",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AMR_NB,
@@ -222,7 +222,7 @@ AVCodec libopencore_amrnb_encoder = {
amr_nb_encode_frame,
amr_nb_encode_close,
NULL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
};
@@ -310,7 +310,7 @@ static int amr_wb_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec libopencore_amrwb_decoder = {
+AVCodec ff_libopencore_amrwb_decoder = {
"libopencore_amrwb",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_AMR_WB,
diff --git a/lib/ffmpeg/libavcodec/libopenjpeg.c b/lib/ffmpeg/libavcodec/libopenjpeg.c
index f85ec00150..0a9ded896d 100644
--- a/lib/ffmpeg/libavcodec/libopenjpeg.c
+++ b/lib/ffmpeg/libavcodec/libopenjpeg.c
@@ -24,6 +24,7 @@
* JPEG 2000 decoder using libopenjpeg
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "libavutil/intreadwrite.h"
#define OPJ_STATIC
@@ -113,7 +114,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
}
width = image->comps[0].w << avctx->lowres;
height = image->comps[0].h << avctx->lowres;
- if(avcodec_check_dimensions(avctx, width, height) < 0) {
+ if(av_image_check_size(width, height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "%dx%d dimension invalid.\n", width, height);
goto done;
}
@@ -183,7 +184,7 @@ static av_cold int libopenjpeg_decode_close(AVCodecContext *avctx)
}
-AVCodec libopenjpeg_decoder = {
+AVCodec ff_libopenjpeg_decoder = {
"libopenjpeg",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_JPEG2000,
diff --git a/lib/ffmpeg/libavcodec/libschroedingerdec.c b/lib/ffmpeg/libavcodec/libschroedingerdec.c
index ef20f20f33..e733d9e34d 100644
--- a/lib/ffmpeg/libavcodec/libschroedingerdec.c
+++ b/lib/ffmpeg/libavcodec/libschroedingerdec.c
@@ -27,6 +27,7 @@
* (http://dirac.sourceforge.net/specification.html).
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "libdirac_libschro.h"
#include "libschroedinger.h"
@@ -169,8 +170,8 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
p_schro_params->format = schro_decoder_get_video_format(decoder);
/* Tell FFmpeg about sequence details. */
- if (avcodec_check_dimensions(avccontext, p_schro_params->format->width,
- p_schro_params->format->height) < 0) {
+ if (av_image_check_size(p_schro_params->format->width, p_schro_params->format->height,
+ 0, avccontext) < 0) {
av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
p_schro_params->format->width, p_schro_params->format->height);
avccontext->height = avccontext->width = 0;
@@ -345,7 +346,7 @@ static void libschroedinger_flush(AVCodecContext *avccontext)
p_schro_params->eos_signalled = 0;
}
-AVCodec libschroedinger_decoder = {
+AVCodec ff_libschroedinger_decoder = {
"libschroedinger",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DIRAC,
diff --git a/lib/ffmpeg/libavcodec/libschroedingerenc.c b/lib/ffmpeg/libavcodec/libschroedingerenc.c
index c4a0433043..4f42d28b3b 100644
--- a/lib/ffmpeg/libavcodec/libschroedingerenc.c
+++ b/lib/ffmpeg/libavcodec/libschroedingerenc.c
@@ -422,7 +422,7 @@ static int libschroedinger_encode_close(AVCodecContext *avccontext)
}
-AVCodec libschroedinger_encoder = {
+AVCodec ff_libschroedinger_encoder = {
"libschroedinger",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_DIRAC,
diff --git a/lib/ffmpeg/libavcodec/libspeexdec.c b/lib/ffmpeg/libavcodec/libspeexdec.c
index c5cfbd5108..1caf738536 100644
--- a/lib/ffmpeg/libavcodec/libspeexdec.c
+++ b/lib/ffmpeg/libavcodec/libspeexdec.c
@@ -49,7 +49,7 @@ static av_cold int libspeex_decode_init(AVCodecContext *avctx)
if (avctx->extradata_size >= 80)
s->header = speex_packet_to_header(avctx->extradata, avctx->extradata_size);
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
if (s->header) {
avctx->sample_rate = s->header->rate;
avctx->channels = s->header->nb_channels;
@@ -138,7 +138,7 @@ static av_cold int libspeex_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec libspeex_decoder = {
+AVCodec ff_libspeex_decoder = {
"libspeex",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SPEEX,
diff --git a/lib/ffmpeg/libavcodec/libtheoraenc.c b/lib/ffmpeg/libavcodec/libtheoraenc.c
index e4ca721166..87793adc72 100644
--- a/lib/ffmpeg/libavcodec/libtheoraenc.c
+++ b/lib/ffmpeg/libavcodec/libtheoraenc.c
@@ -357,7 +357,7 @@ static av_cold int encode_close(AVCodecContext* avc_context)
}
/** AVCodec struct exposed to libavcodec */
-AVCodec libtheora_encoder = {
+AVCodec ff_libtheora_encoder = {
.name = "libtheora",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_THEORA,
diff --git a/lib/ffmpeg/libavcodec/libvorbis.c b/lib/ffmpeg/libavcodec/libvorbis.c
index d0463adeef..9324b28f45 100644
--- a/lib/ffmpeg/libavcodec/libvorbis.c
+++ b/lib/ffmpeg/libavcodec/libvorbis.c
@@ -26,6 +26,7 @@
#include <vorbis/vorbisenc.h>
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "bytestream.h"
#include "vorbis.h"
@@ -38,6 +39,7 @@
#define BUFFER_SIZE (1024*64)
typedef struct OggVorbisContext {
+ AVClass *av_class;
vorbis_info vi ;
vorbis_dsp_state vd ;
vorbis_block vb ;
@@ -48,10 +50,18 @@ typedef struct OggVorbisContext {
/* decoder */
vorbis_comment vc ;
ogg_packet op;
+
+ double iblock;
} OggVorbisContext ;
+static const AVOption options[]={
+{"iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), FF_OPT_TYPE_DOUBLE, 0, -15, 0, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM},
+{NULL}
+};
+static const AVClass class = { "libvorbis", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
+ OggVorbisContext *context = avccontext->priv_data ;
double cfreq;
if(avccontext->flags & CODEC_FLAG_QSCALE) {
@@ -82,14 +92,21 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco
return -1;
}
+ if(context->iblock){
+ vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock);
+ }
+
return vorbis_encode_setup_init(vi);
}
+/* How many bytes are needed for a buffer of length 'l' */
+static int xiph_len(int l) { return (1 + l / 255 + l); }
+
static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) {
OggVorbisContext *context = avccontext->priv_data ;
ogg_packet header, header_comm, header_code;
uint8_t *p;
- unsigned int offset, len;
+ unsigned int offset;
vorbis_info_init(&context->vi) ;
if(oggvorbis_init_encoder(&context->vi, avccontext) < 0) {
@@ -105,9 +122,11 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) {
vorbis_analysis_headerout(&context->vd, &context->vc, &header,
&header_comm, &header_code);
- len = header.bytes + header_comm.bytes + header_code.bytes;
- avccontext->extradata_size= 64 + len + len/255;
- p = avccontext->extradata= av_mallocz(avccontext->extradata_size);
+ avccontext->extradata_size=
+ 1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes) +
+ header_code.bytes;
+ p = avccontext->extradata =
+ av_malloc(avccontext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
p[0] = 2;
offset = 1;
offset += av_xiphlacing(&p[offset], header.bytes);
@@ -118,8 +137,7 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) {
offset += header_comm.bytes;
memcpy(&p[offset], header_code.packet, header_code.bytes);
offset += header_code.bytes;
- avccontext->extradata_size = offset;
- avccontext->extradata= av_realloc(avccontext->extradata, avccontext->extradata_size);
+ assert(offset == avccontext->extradata_size);
/* vorbis_block_clear(&context->vb);
vorbis_dsp_clear(&context->vd);
@@ -225,7 +243,7 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext) {
}
-AVCodec libvorbis_encoder = {
+AVCodec ff_libvorbis_encoder = {
"libvorbis",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_VORBIS,
@@ -234,6 +252,7 @@ AVCodec libvorbis_encoder = {
oggvorbis_encode_frame,
oggvorbis_encode_close,
.capabilities= CODEC_CAP_DELAY,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
+ .priv_class= &class,
} ;
diff --git a/lib/ffmpeg/libavcodec/libvpxdec.c b/lib/ffmpeg/libavcodec/libvpxdec.c
index 0464d12e71..f912322c50 100644
--- a/lib/ffmpeg/libavcodec/libvpxdec.c
+++ b/lib/ffmpeg/libavcodec/libvpxdec.c
@@ -27,6 +27,7 @@
#include <vpx/vpx_decoder.h>
#include <vpx/vp8dx.h>
+#include "libavcore/imgutils.h"
#include "avcodec.h"
typedef struct VP8DecoderContext {
@@ -86,7 +87,7 @@ static int vp8_decode(AVCodecContext *avctx,
if ((int) img->d_w != avctx->width || (int) img->d_h != avctx->height) {
av_log(avctx, AV_LOG_INFO, "dimension change! %dx%d -> %dx%d\n",
avctx->width, avctx->height, img->d_w, img->d_h);
- if (avcodec_check_dimensions(avctx, img->d_w, img->d_h))
+ if (av_image_check_size(img->d_w, img->d_h, 0, avctx))
return AVERROR_INVALIDDATA;
avcodec_set_dimensions(avctx, img->d_w, img->d_h);
}
@@ -110,7 +111,7 @@ static av_cold int vp8_free(AVCodecContext *avctx)
return 0;
}
-AVCodec libvpx_decoder = {
+AVCodec ff_libvpx_decoder = {
"libvpx",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP8,
diff --git a/lib/ffmpeg/libavcodec/libvpxenc.c b/lib/ffmpeg/libavcodec/libvpxenc.c
index c83ab936d4..878c979deb 100644
--- a/lib/ffmpeg/libavcodec/libvpxenc.c
+++ b/lib/ffmpeg/libavcodec/libvpxenc.c
@@ -36,13 +36,13 @@
* One encoded frame returned from the library.
*/
struct FrameListData {
- void *buf; /**≤ compressed data buffer */
- size_t sz; /**≤ length of compressed data */
- int64_t pts; /**≤ time stamp to show frame
+ void *buf; /**< compressed data buffer */
+ size_t sz; /**< length of compressed data */
+ int64_t pts; /**< time stamp to show frame
(in timebase units) */
- unsigned long duration; /**≤ duration to show frame
+ unsigned long duration; /**< duration to show frame
(in timebase units) */
- uint32_t flags; /**≤ flags for this frame */
+ uint32_t flags; /**< flags for this frame */
struct FrameListData *next;
};
@@ -241,6 +241,22 @@ static av_cold int vp8_init(AVCodecContext *avctx)
enccfg.rc_max_quantizer = avctx->qmax;
enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
+ //0-100 (0 => CBR, 100 => VBR)
+ enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
+ enccfg.rc_2pass_vbr_minsection_pct =
+ avctx->rc_min_rate * 100LL / avctx->bit_rate;
+ if (avctx->rc_max_rate)
+ enccfg.rc_2pass_vbr_maxsection_pct =
+ avctx->rc_max_rate * 100LL / avctx->bit_rate;
+
+ if (avctx->rc_buffer_size)
+ enccfg.rc_buf_sz =
+ avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
+ if (avctx->rc_initial_buffer_occupancy)
+ enccfg.rc_buf_initial_sz =
+ avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
+ enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
+
//_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO
if (avctx->keyint_min == avctx->gop_size)
enccfg.kf_min_dist = avctx->keyint_min;
@@ -294,6 +310,7 @@ static av_cold int vp8_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
codecctl_int(avctx, VP8E_SET_CPUUSED, cpuused);
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
+ codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
//provide dummy value to initialize wrapper, values will be updated each _encode()
vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
@@ -477,7 +494,7 @@ static int vp8_encode(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return coded_size;
}
-AVCodec libvpx_encoder = {
+AVCodec ff_libvpx_encoder = {
"libvpx",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP8,
diff --git a/lib/ffmpeg/libavcodec/libx264.c b/lib/ffmpeg/libavcodec/libx264.c
index 8387f41286..84ecb2aecb 100644
--- a/lib/ffmpeg/libavcodec/libx264.c
+++ b/lib/ffmpeg/libavcodec/libx264.c
@@ -100,7 +100,15 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
}
x4->pic.i_pts = frame->pts;
- x4->pic.i_type = X264_TYPE_AUTO;
+ x4->pic.i_type =
+ frame->pict_type == FF_I_TYPE ? X264_TYPE_KEYFRAME :
+ frame->pict_type == FF_P_TYPE ? X264_TYPE_P :
+ frame->pict_type == FF_B_TYPE ? X264_TYPE_B :
+ X264_TYPE_AUTO;
+ if (x4->params.b_tff != frame->top_field_first) {
+ x4->params.b_tff = frame->top_field_first;
+ x264_encoder_reconfig(x4->enc, &x4->params);
+ }
}
do {
@@ -269,9 +277,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (avctx->level > 0)
x4->params.i_level_idc = avctx->level;
- x4->params.rc.f_rate_tolerance =
- (float)avctx->bit_rate_tolerance/avctx->bit_rate;
-
if ((avctx->rc_buffer_size != 0) &&
(avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
x4->params.rc.f_vbv_buffer_init =
@@ -294,6 +299,10 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
+ x4->params.i_slice_count = avctx->slices;
+
+ x4->params.vui.b_fullrange = avctx->pix_fmt == PIX_FMT_YUVJ420P;
+
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
x4->params.b_repeat_headers = 0;
@@ -320,7 +329,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
return 0;
}
-AVCodec libx264_encoder = {
+AVCodec ff_libx264_encoder = {
.name = "libx264",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_H264,
@@ -329,6 +338,6 @@ AVCodec libx264_encoder = {
.encode = X264_frame,
.close = X264_close,
.capabilities = CODEC_CAP_DELAY,
- .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
+ .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
};
diff --git a/lib/ffmpeg/libavcodec/libxavs.c b/lib/ffmpeg/libavcodec/libxavs.c
new file mode 100644
index 0000000000..08b93f5895
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/libxavs.c
@@ -0,0 +1,351 @@
+/*
+ * AVS encoding using the xavs library
+ * Copyright (C) 2010 Amanda, Y.N. Wu <amanda11192003@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <stdint.h>
+#include <xavs.h>
+#include "avcodec.h"
+
+#define END_OF_STREAM 0x001
+
+#define XAVS_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */
+#define XAVS_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */
+#define XAVS_PART_B8X8 0x100 /* Analyze b16x8, b*/
+
+typedef struct XavsContext {
+ xavs_param_t params;
+ xavs_t *enc;
+ xavs_picture_t pic;
+ uint8_t *sei;
+ int sei_size;
+ AVFrame out_pic;
+ int end_of_stream;
+} XavsContext;
+
+static void XAVS_log(void *p, int level, const char *fmt, va_list args)
+{
+ static const int level_map[] = {
+ [XAVS_LOG_ERROR] = AV_LOG_ERROR,
+ [XAVS_LOG_WARNING] = AV_LOG_WARNING,
+ [XAVS_LOG_INFO] = AV_LOG_INFO,
+ [XAVS_LOG_DEBUG] = AV_LOG_DEBUG
+ };
+
+ if (level < 0 || level > XAVS_LOG_DEBUG)
+ return;
+
+ av_vlog(p, level_map[level], fmt, args);
+}
+
+static int encode_nals(AVCodecContext *ctx, uint8_t *buf,
+ int size, xavs_nal_t *nals,
+ int nnal, int skip_sei)
+{
+ XavsContext *x4 = ctx->priv_data;
+ uint8_t *p = buf;
+ int i, s;
+
+ /* Write the SEI as part of the first frame. */
+ if (x4->sei_size > 0 && nnal > 0) {
+ memcpy(p, x4->sei, x4->sei_size);
+ p += x4->sei_size;
+ x4->sei_size = 0;
+ }
+
+ for (i = 0; i < nnal; i++) {
+ /* Don't put the SEI in extradata. */
+ if (skip_sei && nals[i].i_type == NAL_SEI) {
+ x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 );
+ if (xavs_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0)
+ return -1;
+
+ continue;
+ }
+ s = xavs_nal_encode(p, &size, 1, nals + i);
+ if (s < 0)
+ return -1;
+ p += s;
+ }
+
+ return p - buf;
+}
+
+static int XAVS_frame(AVCodecContext *ctx, uint8_t *buf,
+ int bufsize, void *data)
+{
+ XavsContext *x4 = ctx->priv_data;
+ AVFrame *frame = data;
+ xavs_nal_t *nal;
+ int nnal, i;
+ xavs_picture_t pic_out;
+
+ x4->pic.img.i_csp = XAVS_CSP_I420;
+ x4->pic.img.i_plane = 3;
+
+ if (frame) {
+ for (i = 0; i < 3; i++) {
+ x4->pic.img.plane[i] = frame->data[i];
+ x4->pic.img.i_stride[i] = frame->linesize[i];
+ }
+
+ x4->pic.i_pts = frame->pts;
+ x4->pic.i_type = XAVS_TYPE_AUTO;
+ }
+
+ if (xavs_encoder_encode(x4->enc, &nal, &nnal,
+ frame? &x4->pic: NULL, &pic_out) < 0)
+ return -1;
+
+ bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
+
+ if (bufsize < 0)
+ return -1;
+
+ if (!bufsize && !frame && !(x4->end_of_stream)){
+ buf[bufsize] = 0x0;
+ buf[bufsize+1] = 0x0;
+ buf[bufsize+2] = 0x01;
+ buf[bufsize+3] = 0xb1;
+ bufsize += 4;
+ x4->end_of_stream = END_OF_STREAM;
+ return bufsize;
+ }
+ /* FIXME: libxavs now provides DTS */
+ /* but AVFrame doesn't have a field for it. */
+ x4->out_pic.pts = pic_out.i_pts;
+
+ switch (pic_out.i_type) {
+ case XAVS_TYPE_IDR:
+ case XAVS_TYPE_I:
+ x4->out_pic.pict_type = FF_I_TYPE;
+ break;
+ case XAVS_TYPE_P:
+ x4->out_pic.pict_type = FF_P_TYPE;
+ break;
+ case XAVS_TYPE_B:
+ case XAVS_TYPE_BREF:
+ x4->out_pic.pict_type = FF_B_TYPE;
+ break;
+ }
+
+ /* There is no IDR frame in AVS JiZhun */
+ /* Sequence header is used as a flag */
+ x4->out_pic.key_frame = pic_out.i_type == XAVS_TYPE_I;
+
+ x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
+
+ return bufsize;
+}
+
+static av_cold int XAVS_close(AVCodecContext *avctx)
+{
+ XavsContext *x4 = avctx->priv_data;
+
+ av_freep(&avctx->extradata);
+ av_free(x4->sei);
+
+ if (x4->enc)
+ xavs_encoder_close(x4->enc);
+
+ return 0;
+}
+
+static av_cold int XAVS_init(AVCodecContext *avctx)
+{
+ XavsContext *x4 = avctx->priv_data;
+
+ x4->sei_size = 0;
+ xavs_param_default(&x4->params);
+
+ x4->params.pf_log = XAVS_log;
+ x4->params.p_log_private = avctx;
+ x4->params.i_keyint_max = avctx->gop_size;
+ x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
+ x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
+ x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
+ x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
+ if (avctx->flags & CODEC_FLAG_PASS2) {
+ x4->params.rc.b_stat_read = 1;
+ } else {
+ if (avctx->crf) {
+ x4->params.rc.i_rc_method = XAVS_RC_CRF;
+ x4->params.rc.f_rf_constant = avctx->crf;
+ } else if (avctx->cqp > -1) {
+ x4->params.rc.i_rc_method = XAVS_RC_CQP;
+ x4->params.rc.i_qp_constant = avctx->cqp;
+ }
+ }
+
+ /* if neither crf nor cqp modes are selected we have to enable the RC */
+ /* we do it this way because we cannot check if the bitrate has been set */
+ if (!(avctx->crf || (avctx->cqp > -1)))
+ x4->params.rc.i_rc_method = XAVS_RC_ABR;
+
+ x4->params.i_bframe = avctx->max_b_frames;
+ /* cabac is not included in AVS JiZhun Profile */
+ x4->params.b_cabac = 0;
+
+ x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
+ x4->params.i_bframe_bias = avctx->bframebias;
+
+ avctx->has_b_frames = !!avctx->max_b_frames;
+
+ /* AVS doesn't allow B picture as reference */
+ /* The max allowed reference frame number of B is 2 */
+ x4->params.i_keyint_min = avctx->keyint_min;
+ if (x4->params.i_keyint_min > x4->params.i_keyint_max)
+ x4->params.i_keyint_min = x4->params.i_keyint_max;
+
+ x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
+
+ // x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
+ x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
+ x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
+
+ x4->params.rc.i_qp_min = avctx->qmin;
+ x4->params.rc.i_qp_max = avctx->qmax;
+ x4->params.rc.i_qp_step = avctx->max_qdiff;
+
+ x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
+ x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
+ x4->params.rc.f_complexity_blur = avctx->complexityblur;
+
+ x4->params.i_frame_reference = avctx->refs;
+
+ x4->params.i_width = avctx->width;
+ x4->params.i_height = avctx->height;
+ x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
+ x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
+ /* This is only used for counting the fps */
+ x4->params.i_fps_num = avctx->time_base.den;
+ x4->params.i_fps_den = avctx->time_base.num;
+ x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16;
+ if (avctx->partitions) {
+ if (avctx->partitions & XAVS_PART_I8X8)
+ x4->params.analyse.inter |= XAVS_ANALYSE_I8x8;
+
+ if (avctx->partitions & XAVS_PART_P8X8)
+ x4->params.analyse.inter |= XAVS_ANALYSE_PSUB16x16;
+
+ if (avctx->partitions & XAVS_PART_B8X8)
+ x4->params.analyse.inter |= XAVS_ANALYSE_BSUB16x16;
+ }
+
+ x4->params.analyse.i_direct_mv_pred = avctx->directpred;
+
+ x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
+
+ switch (avctx->me_method) {
+ case ME_EPZS:
+ x4->params.analyse.i_me_method = XAVS_ME_DIA;
+ break;
+ case ME_HEX:
+ x4->params.analyse.i_me_method = XAVS_ME_HEX;
+ break;
+ case ME_UMH:
+ x4->params.analyse.i_me_method = XAVS_ME_UMH;
+ break;
+ case ME_FULL:
+ x4->params.analyse.i_me_method = XAVS_ME_ESA;
+ break;
+ case ME_TESA:
+ x4->params.analyse.i_me_method = XAVS_ME_TESA;
+ break;
+ default:
+ x4->params.analyse.i_me_method = XAVS_ME_HEX;
+ }
+
+ x4->params.analyse.i_me_range = avctx->me_range;
+ x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
+
+ x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
+ x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
+ /* AVS P2 only enables 8x8 transform */
+ x4->params.analyse.b_transform_8x8 = 1; //avctx->flags2 & CODEC_FLAG2_8X8DCT;
+ x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
+
+ x4->params.analyse.i_trellis = avctx->trellis;
+ x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
+
+ if (avctx->level > 0)
+ x4->params.i_level_idc = avctx->level;
+
+ x4->params.rc.f_rate_tolerance =
+ (float)avctx->bit_rate_tolerance/avctx->bit_rate;
+
+ if ((avctx->rc_buffer_size) &&
+ (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
+ x4->params.rc.f_vbv_buffer_init =
+ (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
+ } else
+ x4->params.rc.f_vbv_buffer_init = 0.9;
+
+ /* TAG:do we have MB tree RC method */
+ /* what is the RC method we are now using? Default NO */
+ x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
+ x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
+ x4->params.rc.f_pb_factor = avctx->b_quant_factor;
+ x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
+
+ x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
+ x4->params.i_log_level = XAVS_LOG_DEBUG;
+ x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD;
+ x4->params.i_threads = avctx->thread_count;
+ x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
+
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
+ x4->params.b_repeat_headers = 0;
+
+ x4->enc = xavs_encoder_open(&x4->params);
+ if (!x4->enc)
+ return -1;
+
+ avctx->coded_frame = &x4->out_pic;
+ /* TAG: Do we have GLOBAL HEADER in AVS */
+ /* We Have PPS and SPS in AVS */
+ if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
+ xavs_nal_t *nal;
+ int nnal, s;
+
+ s = xavs_encoder_headers(x4->enc, &nal, &nnal);
+
+ avctx->extradata = av_malloc(s);
+ avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
+ }
+ return 0;
+}
+
+AVCodec ff_libxavs_encoder = {
+ .name = "libxavs",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_CAVS,
+ .priv_data_size = sizeof(XavsContext),
+ .init = XAVS_init,
+ .encode = XAVS_frame,
+ .close = XAVS_close,
+ .capabilities = CODEC_CAP_DELAY,
+ .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
+ .long_name = NULL_IF_CONFIG_SMALL("libxavs - the Chinese Audio Video Standard Encoder"),
+};
+
diff --git a/lib/ffmpeg/libavcodec/libxvidff.c b/lib/ffmpeg/libavcodec/libxvidff.c
index 140848f0da..d95ddee8d7 100644
--- a/lib/ffmpeg/libavcodec/libxvidff.c
+++ b/lib/ffmpeg/libavcodec/libxvidff.c
@@ -31,6 +31,7 @@
#include <xvid.h>
#include <unistd.h>
#include "avcodec.h"
+#include "libavutil/cpu.h"
#include "libavutil/intreadwrite.h"
#include "libxvid_internal.h"
#if !HAVE_MKSTEMP
@@ -44,35 +45,33 @@
#define BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x))
#define BUFFER_CAT(x) (&((x)[strlen(x)]))
-/* For PPC Use */
-int has_altivec(void);
-
/**
* Structure for the private Xvid context.
* This stores all the private context for the codec.
*/
struct xvid_context {
- void *encoder_handle; /** Handle for Xvid encoder */
- int xsize, ysize; /** Frame size */
- int vop_flags; /** VOP flags for Xvid encoder */
- int vol_flags; /** VOL flags for Xvid encoder */
- int me_flags; /** Motion Estimation flags */
- int qscale; /** Do we use constant scale? */
- int quicktime_format; /** Are we in a QT-based format? */
- AVFrame encoded_picture; /** Encoded frame information */
- char *twopassbuffer; /** Character buffer for two-pass */
- char *old_twopassbuffer; /** Old character buffer (two-pass) */
- char *twopassfile; /** second pass temp file name */
- unsigned char *intra_matrix; /** P-Frame Quant Matrix */
- unsigned char *inter_matrix; /** I-Frame Quant Matrix */
+ void *encoder_handle; /**< Handle for Xvid encoder */
+ int xsize; /**< Frame x size */
+ int ysize; /**< Frame y size */
+ int vop_flags; /**< VOP flags for Xvid encoder */
+ int vol_flags; /**< VOL flags for Xvid encoder */
+ int me_flags; /**< Motion Estimation flags */
+ int qscale; /**< Do we use constant scale? */
+ int quicktime_format; /**< Are we in a QT-based format? */
+ AVFrame encoded_picture; /**< Encoded frame information */
+ char *twopassbuffer; /**< Character buffer for two-pass */
+ char *old_twopassbuffer; /**< Old character buffer (two-pass) */
+ char *twopassfile; /**< second pass temp file name */
+ unsigned char *intra_matrix; /**< P-Frame Quant Matrix */
+ unsigned char *inter_matrix; /**< I-Frame Quant Matrix */
};
/**
* Structure for the private first-pass plugin.
*/
struct xvid_ff_pass1 {
- int version; /** Xvid version */
- struct xvid_context *context; /** Pointer to private context */
+ int version; /**< Xvid version */
+ struct xvid_context *context; /**< Pointer to private context */
};
/* Prototypes - See function implementation for details */
@@ -214,7 +213,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) {
#if ARCH_PPC
/* Xvid's PPC support is borked, use libavcodec to detect */
#if HAVE_ALTIVEC
- if( has_altivec() ) {
+ if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
xvid_gbl_init.cpu_flags = XVID_CPU_FORCE | XVID_CPU_ALTIVEC;
} else
#endif
@@ -450,7 +449,11 @@ static int xvid_encode_frame(AVCodecContext *avctx,
xvid_enc_frame.vop_flags = x->vop_flags;
xvid_enc_frame.vol_flags = x->vol_flags;
xvid_enc_frame.motion = x->me_flags;
- xvid_enc_frame.type = XVID_TYPE_AUTO;
+ xvid_enc_frame.type =
+ picture->pict_type == FF_I_TYPE ? XVID_TYPE_IVOP :
+ picture->pict_type == FF_P_TYPE ? XVID_TYPE_PVOP :
+ picture->pict_type == FF_B_TYPE ? XVID_TYPE_BVOP :
+ XVID_TYPE_AUTO;
/* Pixel aspect ratio setting */
if (avctx->sample_aspect_ratio.num < 1 || avctx->sample_aspect_ratio.num > 255 ||
@@ -811,7 +814,7 @@ int xvid_ff_2pass(void *ref, int cmd, void *p1, void *p2) {
/**
* Xvid codec definition for libavcodec.
*/
-AVCodec libxvid_encoder = {
+AVCodec ff_libxvid_encoder = {
"libxvid",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG4,
diff --git a/lib/ffmpeg/libavcodec/ljpegenc.c b/lib/ffmpeg/libavcodec/ljpegenc.c
index 2ef07c3a32..56336cb3bf 100644
--- a/lib/ffmpeg/libavcodec/ljpegenc.c
+++ b/lib/ffmpeg/libavcodec/ljpegenc.c
@@ -186,7 +186,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
}
-AVCodec ljpeg_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them
+AVCodec ff_ljpeg_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them
"ljpeg",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_LJPEG,
diff --git a/lib/ffmpeg/libavcodec/loco.c b/lib/ffmpeg/libavcodec/loco.c
index d19a80cf34..48fa829914 100644
--- a/lib/ffmpeg/libavcodec/loco.c
+++ b/lib/ffmpeg/libavcodec/loco.c
@@ -285,7 +285,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec loco_decoder = {
+AVCodec ff_loco_decoder = {
"loco",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_LOCO,
diff --git a/lib/ffmpeg/libavcodec/lpc.c b/lib/ffmpeg/libavcodec/lpc.c
index 112a78d4b9..6d7671c81f 100644
--- a/lib/ffmpeg/libavcodec/lpc.c
+++ b/lib/ffmpeg/libavcodec/lpc.c
@@ -20,7 +20,6 @@
*/
#include "libavutil/lls.h"
-#include "dsputil.h"
#define LPC_USE_DOUBLE
#include "lpc.h"
@@ -29,7 +28,8 @@
/**
* Apply Welch window function to audio block
*/
-static void apply_welch_window(const int32_t *data, int len, double *w_data)
+static void lpc_apply_welch_window_c(const int32_t *data, int len,
+ double *w_data)
{
int i, n2;
double w;
@@ -55,24 +55,16 @@ static void apply_welch_window(const int32_t *data, int len, double *w_data)
* 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,
- double *autoc)
+static void lpc_compute_autocorr_c(const double *data, int len, int lag,
+ double *autoc)
{
int i, j;
- double tmp[len + lag + 1];
- double *data1= tmp + lag;
-
- apply_welch_window(data, len, data1);
-
- for(j=0; j<lag; j++)
- data1[j-lag]= 0.0;
- data1[len] = 0.0;
for(j=0; j<lag; j+=2){
double sum0 = 1.0, sum1 = 1.0;
for(i=j; i<len; i++){
- sum0 += data1[i] * data1[i-j];
- sum1 += data1[i] * data1[i-j-1];
+ sum0 += data[i] * data[i-j];
+ sum1 += data[i] * data[i-j-1];
}
autoc[j ] = sum0;
autoc[j+1] = sum1;
@@ -81,8 +73,8 @@ void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
if(j==lag){
double sum = 1.0;
for(i=j-1; i<len; i+=2){
- sum += data1[i ] * data1[i-j ]
- + data1[i+1] * data1[i-j+1];
+ sum += data[i ] * data[i-j ]
+ + data[i+1] * data[i-j+1];
}
autoc[j] = sum;
}
@@ -162,7 +154,7 @@ static int estimate_best_order(double *ref, int min_order, int max_order)
* 1 = LPC with coeffs determined by Levinson-Durbin recursion
* 2+ = LPC with coeffs determined by Cholesky factorization using (use_lpc-1) passes.
*/
-int ff_lpc_calc_coefs(DSPContext *s,
+int ff_lpc_calc_coefs(LPCContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift,
@@ -178,8 +170,19 @@ int ff_lpc_calc_coefs(DSPContext *s,
assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
lpc_type > AV_LPC_TYPE_FIXED);
+ /* reinit LPC context if parameters have changed */
+ if (blocksize != s->blocksize || max_order != s->max_order ||
+ lpc_type != s->lpc_type) {
+ ff_lpc_end(s);
+ ff_lpc_init(s, blocksize, max_order, lpc_type);
+ }
+
if (lpc_type == AV_LPC_TYPE_LEVINSON) {
- s->lpc_compute_autocorr(samples, blocksize, max_order, autoc);
+ double *windowed_samples = s->windowed_samples + max_order;
+
+ s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
+
+ s->lpc_compute_autocorr(windowed_samples, blocksize, max_order, autoc);
compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
@@ -236,3 +239,33 @@ int ff_lpc_calc_coefs(DSPContext *s,
return opt_order;
}
+
+av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
+ enum AVLPCType lpc_type)
+{
+ s->blocksize = blocksize;
+ s->max_order = max_order;
+ s->lpc_type = lpc_type;
+
+ if (lpc_type == AV_LPC_TYPE_LEVINSON) {
+ s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
+ sizeof(*s->windowed_samples));
+ if (!s->windowed_samples)
+ return AVERROR(ENOMEM);
+ } else {
+ s->windowed_samples = NULL;
+ }
+
+ s->lpc_apply_welch_window = lpc_apply_welch_window_c;
+ s->lpc_compute_autocorr = lpc_compute_autocorr_c;
+
+ if (HAVE_MMX)
+ ff_lpc_init_x86(s);
+
+ return 0;
+}
+
+av_cold void ff_lpc_end(LPCContext *s)
+{
+ av_freep(&s->windowed_samples);
+}
diff --git a/lib/ffmpeg/libavcodec/lpc.h b/lib/ffmpeg/libavcodec/lpc.h
index 1c595f6b9a..96b66df909 100644
--- a/lib/ffmpeg/libavcodec/lpc.h
+++ b/lib/ffmpeg/libavcodec/lpc.h
@@ -36,18 +36,61 @@
#define MAX_LPC_ORDER 32
+typedef struct LPCContext {
+ int blocksize;
+ int max_order;
+ enum AVLPCType lpc_type;
+ double *windowed_samples;
+
+ /**
+ * Apply a Welch window to an array of input samples.
+ * The output samples have the same scale as the input, but are in double
+ * sample format.
+ * @param data input samples
+ * @param len number of input samples
+ * @param w_data output samples
+ */
+ void (*lpc_apply_welch_window)(const int32_t *data, int len,
+ double *w_data);
+ /**
+ * Perform autocorrelation on input samples with delay of 0 to lag.
+ * @param data input samples.
+ * constraints: no alignment needed, but must have have at
+ * least lag*sizeof(double) valid bytes preceeding it, and
+ * size must be at least (len+1)*sizeof(double) if data is
+ * 16-byte aligned or (len+2)*sizeof(double) if data is
+ * unaligned.
+ * @param len number of input samples to process
+ * @param lag maximum delay to calculate
+ * @param autoc output autocorrelation coefficients.
+ * constraints: array size must be at least lag+1.
+ */
+ void (*lpc_compute_autocorr)(const double *data, int len, int lag,
+ double *autoc);
+} LPCContext;
+
+
/**
* Calculate LPC coefficients for multiple orders
*/
-int ff_lpc_calc_coefs(DSPContext *s,
+int ff_lpc_calc_coefs(LPCContext *s,
const int32_t *samples, int blocksize, int min_order,
int max_order, int precision,
int32_t coefs[][MAX_LPC_ORDER], int *shift,
enum AVLPCType lpc_type, int lpc_passes,
int omethod, int max_shift, int zero_shift);
-void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag,
- double *autoc);
+/**
+ * Initialize LPCContext.
+ */
+int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
+ enum AVLPCType lpc_type);
+void ff_lpc_init_x86(LPCContext *s);
+
+/**
+ * Uninitialize LPCContext.
+ */
+void ff_lpc_end(LPCContext *s);
#ifdef LPC_USE_DOUBLE
#define LPC_TYPE double
diff --git a/lib/ffmpeg/libavcodec/lsp.c b/lib/ffmpeg/libavcodec/lsp.c
index 7112492001..98ca490a76 100644
--- a/lib/ffmpeg/libavcodec/lsp.c
+++ b/lib/ffmpeg/libavcodec/lsp.c
@@ -65,6 +65,14 @@ void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order)
lsp[i] = ff_cos(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0,14)
}
+void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order)
+{
+ int i;
+
+ for(i = 0; i < lp_order; i++)
+ lsp[i] = cos(2.0 * M_PI * lsf[i]);
+}
+
/**
* \brief decodes polynomial coefficients from LSP
* \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff)
@@ -109,6 +117,32 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
}
}
+void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
+{
+ int lp_half_order = lp_order >> 1;
+ double buf[lp_half_order + 1];
+ double pa[lp_half_order + 1];
+ double *qa = buf + 1;
+ int i,j;
+
+ qa[-1] = 0.0;
+
+ ff_lsp2polyf(lsp , pa, lp_half_order );
+ ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
+
+ for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) {
+ double paf = pa[i] * (1 + lsp[lp_order - 1]);
+ double qaf = (qa[i] - qa[i-2]) * (1 - lsp[lp_order - 1]);
+ lp[i-1] = (paf + qaf) * 0.5;
+ lp[j-1] = (paf - qaf) * 0.5;
+ }
+
+ lp[lp_half_order - 1] = (1.0 + lsp[lp_order - 1]) *
+ pa[lp_half_order] * 0.5;
+
+ lp[lp_order - 1] = lsp[lp_order - 1];
+}
+
void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order)
{
int16_t lsp_1st[MAX_LP_ORDER]; // (0.15)
diff --git a/lib/ffmpeg/libavcodec/lsp.h b/lib/ffmpeg/libavcodec/lsp.h
index 51d3f529dd..e3af30d300 100644
--- a/lib/ffmpeg/libavcodec/lsp.h
+++ b/lib/ffmpeg/libavcodec/lsp.h
@@ -31,7 +31,7 @@
/**
* \brief ensure a minimum distance between LSFs
- * \param lsfq [in/out] LSF to check and adjust
+ * \param[in,out] lsfq LSF to check and adjust
* \param lsfq_min_distance minimum distance between LSFs
* \param lsfq_min minimum allowed LSF value
* \param lsfq_max maximum allowed LSF value
@@ -46,7 +46,7 @@ void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, in
* Omitting this step creates audible distortion on the sinusoidal sweep
* test vectors in 3GPP TS 26.074.
*
- * @param lsf [in,out] LSFs in Hertz
+ * @param[in,out] lsf LSFs in Hertz
* @param min_spacing minimum distance between two consecutive lsf values
* @param size size of the lsf vector
*/
@@ -54,7 +54,7 @@ void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size);
/**
* \brief Convert LSF to LSP
- * \param lsp [out] LSP coefficients (-0x8000 <= (0.15) < 0x8000)
+ * \param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
* \param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI)
* \param lp_order LP filter order
*
@@ -63,17 +63,27 @@ void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size);
void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order);
/**
+ * Floating point version of ff_acelp_lsf2lsp()
+ */
+void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order);
+
+/**
* \brief LSP to LP conversion (3.2.6 of G.729)
- * \param lp [out] decoded LP coefficients (-0x8000 <= (3.12) < 0x8000)
+ * \param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000)
* \param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
* \param lp_half_order LP filter order, divided by 2
*/
void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order);
/**
+ * LSP to LP conversion (5.2.4 of AMR-WB)
+ */
+void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order);
+
+/**
* \brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729)
- * \param lp_1st [out] decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000)
- * \param lp_2nd [out] decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000)
+ * \param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000)
+ * \param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000)
* \param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000)
* \param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000)
* \param lp_order LP filter order
@@ -111,7 +121,7 @@ void ff_sort_nearly_sorted_floats(float *vals, int len);
* We only need to calculate the 6 first elements of the polynomial.
*
* @param lsp line spectral pairs in cosine domain
- * @param f [out] polynomial input/output as a vector
+ * @param[out] f polynomial input/output as a vector
*
* TIA/EIA/IS-733 2.4.3.3.5-1/2
*/
diff --git a/lib/ffmpeg/libavcodec/mace.c b/lib/ffmpeg/libavcodec/mace.c
index 3c71320d54..1b8c9d0836 100644
--- a/lib/ffmpeg/libavcodec/mace.c
+++ b/lib/ffmpeg/libavcodec/mace.c
@@ -230,7 +230,7 @@ static av_cold int mace_decode_init(AVCodecContext * avctx)
{
if (avctx->channels > 2)
return -1;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -279,7 +279,7 @@ static int mace_decode_frame(AVCodecContext *avctx,
return buf_size;
}
-AVCodec mace3_decoder = {
+AVCodec ff_mace3_decoder = {
"mace3",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MACE3,
@@ -291,7 +291,7 @@ AVCodec mace3_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
};
-AVCodec mace6_decoder = {
+AVCodec ff_mace6_decoder = {
"mace6",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MACE6,
diff --git a/lib/ffmpeg/libavcodec/mdec.c b/lib/ffmpeg/libavcodec/mdec.c
index 606a749695..12d1751172 100644
--- a/lib/ffmpeg/libavcodec/mdec.c
+++ b/lib/ffmpeg/libavcodec/mdec.c
@@ -229,9 +229,11 @@ static av_cold int decode_init(AVCodecContext *avctx){
ff_mpeg12_init_vlcs();
ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct);
+ if( avctx->idct_algo == FF_IDCT_AUTO )
+ avctx->idct_algo = FF_IDCT_SIMPLE;
p->qstride= 0;
p->qscale_table= av_mallocz(a->mb_width);
- avctx->pix_fmt= PIX_FMT_YUV420P;
+ avctx->pix_fmt= PIX_FMT_YUVJ420P;
return 0;
}
@@ -248,7 +250,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec mdec_decoder = {
+AVCodec ff_mdec_decoder = {
"mdec",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MDEC,
diff --git a/lib/ffmpeg/libavcodec/mimic.c b/lib/ffmpeg/libavcodec/mimic.c
index e5f7123e94..bcf125a262 100644
--- a/lib/ffmpeg/libavcodec/mimic.c
+++ b/lib/ffmpeg/libavcodec/mimic.c
@@ -378,7 +378,7 @@ static av_cold int mimic_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec mimic_decoder = {
+AVCodec ff_mimic_decoder = {
"mimic",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MIMIC,
diff --git a/lib/ffmpeg/libavcodec/mips/mathops.h b/lib/ffmpeg/libavcodec/mips/mathops.h
index a1b04ed951..b58361f74d 100644
--- a/lib/ffmpeg/libavcodec/mips/mathops.h
+++ b/lib/ffmpeg/libavcodec/mips/mathops.h
@@ -25,6 +25,8 @@
#include "config.h"
#include "libavutil/common.h"
+#if HAVE_INLINE_ASM
+
#if HAVE_LOONGSON
static inline av_const int64_t MAC64(int64_t d, int a, int b)
@@ -73,4 +75,6 @@ static inline av_const int64_t MLS64(int64_t d, int a, int b)
#endif
+#endif /* HAVE_INLINE_ASM */
+
#endif /* AVCODEC_MIPS_MATHOPS_H */
diff --git a/lib/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c b/lib/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c
new file mode 100644
index 0000000000..855f24add3
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/mjpeg2jpeg_bsf.c
@@ -0,0 +1,113 @@
+/*
+ * MJPEG/AVI1 to JPEG/JFIF bitstream format filter
+ * Copyright (c) 2010 Adrian Daerr and Nicolas George
+ *
+ * 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
+ */
+
+/*
+ * Adapted from mjpeg2jpeg.c, with original copyright:
+ * Paris 2010 Adrian Daerr, public domain
+ */
+
+#include <string.h>
+#include "avcodec.h"
+#include "mjpeg.h"
+
+static const uint8_t jpeg_header[] = {
+ 0xff, 0xd8, // SOI
+ 0xff, 0xe0, // APP0
+ 0x00, 0x10, // APP0 header size (including
+ // this field, but excluding preceding)
+ 0x4a, 0x46, 0x49, 0x46, 0x00, // ID string 'JFIF\0'
+ 0x01, 0x01, // version
+ 0x00, // bits per type
+ 0x00, 0x00, // X density
+ 0x00, 0x00, // Y density
+ 0x00, // X thumbnail size
+ 0x00, // Y thumbnail size
+};
+
+static const int dht_segment_size = 420;
+static const uint8_t dht_segment_head[] = { 0xFF, 0xC4, 0x01, 0xA2, 0x00 };
+static const uint8_t dht_segment_frag[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x0a, 0x0b, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static uint8_t *append(uint8_t *buf, const uint8_t *src, int size)
+{
+ memcpy(buf, src, size);
+ return buf + size;
+}
+
+static uint8_t *append_dht_segment(uint8_t *buf)
+{
+ buf = append(buf, dht_segment_head, sizeof(dht_segment_head));
+ buf = append(buf, ff_mjpeg_bits_dc_luminance + 1, 16);
+ buf = append(buf, dht_segment_frag, sizeof(dht_segment_frag));
+ buf = append(buf, ff_mjpeg_val_dc, 12);
+ *(buf++) = 0x10;
+ buf = append(buf, ff_mjpeg_bits_ac_luminance + 1, 16);
+ buf = append(buf, ff_mjpeg_val_ac_luminance, 162);
+ *(buf++) = 0x11;
+ buf = append(buf, ff_mjpeg_bits_ac_chrominance + 1, 16);
+ buf = append(buf, ff_mjpeg_val_ac_chrominance, 162);
+ return buf;
+}
+
+static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
+ AVCodecContext *avctx, const char *args,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size,
+ int keyframe)
+{
+ int input_skip, output_size;
+ uint8_t *output, *out;
+
+ if (buf_size < 12) {
+ av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (memcmp("AVI1", buf + 6, 4)) {
+ av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
+ return AVERROR_INVALIDDATA;
+ }
+ input_skip = (buf[4] << 8) + buf[5] + 4;
+ if (buf_size < input_skip) {
+ av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
+ return AVERROR_INVALIDDATA;
+ }
+ output_size = buf_size - input_skip +
+ sizeof(jpeg_header) + dht_segment_size;
+ output = out = av_malloc(output_size);
+ if (!output)
+ return AVERROR(ENOMEM);
+ out = append(out, jpeg_header, sizeof(jpeg_header));
+ out = append_dht_segment(out);
+ out = append(out, buf + input_skip, buf_size - input_skip);
+ *poutbuf = output;
+ *poutbuf_size = output_size;
+ return 1;
+}
+
+AVBitStreamFilter ff_mjpeg2jpeg_bsf = {
+ .name = "mjpeg2jpeg",
+ .priv_data_size = 0,
+ .filter = mjpeg2jpeg_filter,
+};
diff --git a/lib/ffmpeg/libavcodec/mjpeg_parser.c b/lib/ffmpeg/libavcodec/mjpeg_parser.c
index b1848fac51..0cc355db5c 100644
--- a/lib/ffmpeg/libavcodec/mjpeg_parser.c
+++ b/lib/ffmpeg/libavcodec/mjpeg_parser.c
@@ -96,7 +96,7 @@ static int jpeg_parse(AVCodecParserContext *s,
}
-AVCodecParser mjpeg_parser = {
+AVCodecParser ff_mjpeg_parser = {
{ CODEC_ID_MJPEG },
sizeof(ParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/mjpega_dump_header_bsf.c b/lib/ffmpeg/libavcodec/mjpega_dump_header_bsf.c
index bb7858e498..2e86fd4ef3 100644
--- a/lib/ffmpeg/libavcodec/mjpega_dump_header_bsf.c
+++ b/lib/ffmpeg/libavcodec/mjpega_dump_header_bsf.c
@@ -87,7 +87,7 @@ static int mjpega_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *av
return 0;
}
-AVBitStreamFilter mjpega_dump_header_bsf = {
+AVBitStreamFilter ff_mjpega_dump_header_bsf = {
"mjpegadump",
0,
mjpega_dump_header,
diff --git a/lib/ffmpeg/libavcodec/mjpegbdec.c b/lib/ffmpeg/libavcodec/mjpegbdec.c
index 907fa6f504..dc5a838d7a 100644
--- a/lib/ffmpeg/libavcodec/mjpegbdec.c
+++ b/lib/ffmpeg/libavcodec/mjpegbdec.c
@@ -145,7 +145,7 @@ read_header:
return buf_ptr - buf;
}
-AVCodec mjpegb_decoder = {
+AVCodec ff_mjpegb_decoder = {
"mjpegb",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MJPEGB,
diff --git a/lib/ffmpeg/libavcodec/mjpegdec.c b/lib/ffmpeg/libavcodec/mjpegdec.c
index 8aff966f6e..fbc637aa30 100644
--- a/lib/ffmpeg/libavcodec/mjpegdec.c
+++ b/lib/ffmpeg/libavcodec/mjpegdec.c
@@ -33,6 +33,7 @@
//#define DEBUG
#include <assert.h>
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mjpeg.h"
@@ -43,23 +44,22 @@
static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table,
int nb_codes, int use_static, int is_ac)
{
- uint8_t huff_size[256+16];
- uint16_t huff_code[256+16];
+ uint8_t huff_size[256];
+ uint16_t huff_code[256];
+ uint16_t huff_sym[256];
+ int i;
assert(nb_codes <= 256);
memset(huff_size, 0, sizeof(huff_size));
ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
- if(is_ac){
- memmove(huff_size+16, huff_size, sizeof(uint8_t)*nb_codes);
- memmove(huff_code+16, huff_code, sizeof(uint16_t)*nb_codes);
- memset(huff_size, 0, sizeof(uint8_t)*16);
- memset(huff_code, 0, sizeof(uint16_t)*16);
- nb_codes += 16;
- }
+ for(i=0; i<256; i++)
+ huff_sym[i]= i + 16*is_ac;
+
+ if(is_ac) huff_sym[0]= 16*256;
- return init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2, use_static);
+ return init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2, huff_sym, 2, 2, use_static);
}
static void build_basic_mjpeg_vlc(MJpegDecodeContext * s) {
@@ -71,6 +71,10 @@ static void build_basic_mjpeg_vlc(MJpegDecodeContext * s) {
ff_mjpeg_val_ac_luminance, 251, 0, 1);
build_vlc(&s->vlcs[1][1], ff_mjpeg_bits_ac_chrominance,
ff_mjpeg_val_ac_chrominance, 251, 0, 1);
+ build_vlc(&s->vlcs[2][0], ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance, 251, 0, 0);
+ build_vlc(&s->vlcs[2][1], ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance, 251, 0, 0);
}
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
@@ -190,6 +194,13 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
if(build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1, 0, class > 0) < 0){
return -1;
}
+
+ if(class>0){
+ free_vlc(&s->vlcs[2][index]);
+ if(build_vlc(&s->vlcs[2][index], bits_table, val_table, code_max + 1, 0, 0) < 0){
+ return -1;
+ }
+ }
}
return 0;
}
@@ -218,7 +229,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
height= s->height;
av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
- if(avcodec_check_dimensions(s->avctx, width, height))
+ if(av_image_check_size(width, height, 0, s->avctx))
return -1;
nb_components = get_bits(&s->gb, 8);
@@ -405,19 +416,16 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
block[0] = val;
/* AC coefs */
i = 0;
- {OPEN_READER(re, &s->gb)
- for(;;) {
+ {OPEN_READER(re, &s->gb);
+ do {
UPDATE_CACHE(re, &s->gb);
- GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
+ GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2);
- /* EOB */
- if (code == 0x10)
- break;
i += ((unsigned)code) >> 4;
- if(code != 0x100){
code &= 0xf;
+ if(code){
if(code > MIN_CACHE_BITS - 16){
- UPDATE_CACHE(re, &s->gb)
+ UPDATE_CACHE(re, &s->gb);
}
{
int cache=GET_CACHE(re,&s->gb);
@@ -425,22 +433,17 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
- LAST_SKIP_BITS(re, &s->gb, code)
+ LAST_SKIP_BITS(re, &s->gb, code);
- if (i >= 63) {
- if(i == 63){
- j = s->scantable.permutated[63];
- block[j] = level * quant_matrix[j];
- break;
- }
+ if (i > 63) {
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j];
}
- }
- CLOSE_READER(re, &s->gb)}
+ }while(i<63);
+ CLOSE_READER(re, &s->gb);}
return 0;
}
@@ -472,17 +475,17 @@ static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8
(*EOBRUN)--;
return 0;
}
- {OPEN_READER(re, &s->gb)
+ {OPEN_READER(re, &s->gb);
for(i=ss;;i++) {
UPDATE_CACHE(re, &s->gb);
- GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
- /* Progressive JPEG use AC coeffs from zero and this decoder sets offset 16 by default */
- code -= 16;
- if(code & 0xF) {
- i += ((unsigned) code) >> 4;
- code &= 0xf;
+ GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
+
+ run = ((unsigned) code) >> 4;
+ code &= 0xF;
+ if(code) {
+ i += run;
if(code > MIN_CACHE_BITS - 16){
- UPDATE_CACHE(re, &s->gb)
+ UPDATE_CACHE(re, &s->gb);
}
{
int cache=GET_CACHE(re,&s->gb);
@@ -490,7 +493,7 @@ static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
- LAST_SKIP_BITS(re, &s->gb, code)
+ LAST_SKIP_BITS(re, &s->gb, code);
if (i >= se) {
if(i == se){
@@ -504,22 +507,25 @@ static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block, uint8
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j] << Al;
}else{
- run = ((unsigned) code) >> 4;
if(run == 0xF){// ZRL - skip 15 coefficients
i += 15;
+ if (i >= se) {
+ av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);
+ return -1;
+ }
}else{
- val = run;
- run = (1 << run);
- UPDATE_CACHE(re, &s->gb);
- run += (GET_CACHE(re, &s->gb) >> (32 - val)) & (run - 1);
- if(val)
- LAST_SKIP_BITS(re, &s->gb, val);
- *EOBRUN = run - 1;
+ val = (1 << run);
+ if(run){
+ UPDATE_CACHE(re, &s->gb);
+ val += NEG_USR32(GET_CACHE(re, &s->gb), run);
+ LAST_SKIP_BITS(re, &s->gb, run);
+ }
+ *EOBRUN = val - 1;
break;
}
}
}
- CLOSE_READER(re, &s->gb)}
+ CLOSE_READER(re, &s->gb);}
if(i > *last_nnz)
*last_nnz = i;
return 0;
@@ -563,9 +569,8 @@ static int decode_block_refinement(MJpegDecodeContext *s, DCTELEM *block, uint8_
else {
for(;;i++) {
UPDATE_CACHE(re, &s->gb);
- GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2)
- /* Progressive JPEG use AC coeffs from zero and this decoder sets offset 16 by default */
- code -= 16;
+ GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
+
if(code & 0xF) {
run = ((unsigned) code) >> 4;
UPDATE_CACHE(re, &s->gb);
@@ -578,7 +583,7 @@ static int decode_block_refinement(MJpegDecodeContext *s, DCTELEM *block, uint8_
if(i == se) {
if(i > *last_nnz)
*last_nnz = i;
- CLOSE_READER(re, &s->gb)
+ CLOSE_READER(re, &s->gb);
return 0;
}
}else{
@@ -1026,7 +1031,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
if(8*len + get_bits_count(&s->gb) > s->gb.size_in_bits)
return -1;
- id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16);
+ id = get_bits_long(&s->gb, 32);
id = av_be2ne32(id);
len -= 6;
@@ -1133,7 +1138,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
/* Apple MJPEG-A */
if ((s->start_code == APP1) && (len > (0x28 - 8)))
{
- id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16);
+ id = get_bits_long(&s->gb, 32);
id = av_be2ne32(id);
len -= 4;
if (id == AV_RL32("mjpg")) /* Apple MJPEG-A */
@@ -1250,7 +1255,7 @@ static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
}
val = -1;
found:
- dprintf(NULL, "find_marker skipped %d bytes\n", skipped);
+ av_dlog(NULL, "find_marker skipped %d bytes\n", skipped);
*pbuf_ptr = buf_ptr;
return val;
}
@@ -1520,7 +1525,7 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
av_freep(&s->ljpeg_buffer);
s->ljpeg_buffer_size=0;
- for(i=0;i<2;i++) {
+ for(i=0;i<3;i++) {
for(j=0;j<4;j++)
free_vlc(&s->vlcs[i][j]);
}
@@ -1531,7 +1536,7 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec mjpeg_decoder = {
+AVCodec ff_mjpeg_decoder = {
"mjpeg",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MJPEG,
@@ -1542,11 +1547,11 @@ AVCodec mjpeg_decoder = {
ff_mjpeg_decode_frame,
CODEC_CAP_DR1,
NULL,
- .max_lowres = 8,
+ .max_lowres = 4,
.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
};
-AVCodec thp_decoder = {
+AVCodec ff_thp_decoder = {
"thp",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_THP,
diff --git a/lib/ffmpeg/libavcodec/mjpegdec.h b/lib/ffmpeg/libavcodec/mjpegdec.h
index bbf734b56f..7baa5dc286 100644
--- a/lib/ffmpeg/libavcodec/mjpegdec.h
+++ b/lib/ffmpeg/libavcodec/mjpegdec.h
@@ -44,7 +44,7 @@ typedef struct MJpegDecodeContext {
uint8_t *buffer;
int16_t quant_matrixes[4][64];
- VLC vlcs[2][4];
+ VLC vlcs[3][4];
int qscale[4]; ///< quantizer scale calculated from quant_matrixes
int org_height; /* size given at codec init */
diff --git a/lib/ffmpeg/libavcodec/mjpegenc.c b/lib/ffmpeg/libavcodec/mjpegenc.c
index ec819c800a..15b588c793 100644
--- a/lib/ffmpeg/libavcodec/mjpegenc.c
+++ b/lib/ffmpeg/libavcodec/mjpegenc.c
@@ -441,9 +441,11 @@ void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64])
encode_block(s, block[5], 5);
encode_block(s, block[7], 7);
}
+
+ s->i_tex_bits += get_bits_diff(s);
}
-AVCodec mjpeg_encoder = {
+AVCodec ff_mjpeg_encoder = {
"mjpeg",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MJPEG,
diff --git a/lib/ffmpeg/libavcodec/mlp_parser.c b/lib/ffmpeg/libavcodec/mlp_parser.c
index 90bf9391e9..a6196f9abd 100644
--- a/lib/ffmpeg/libavcodec/mlp_parser.c
+++ b/lib/ffmpeg/libavcodec/mlp_parser.c
@@ -255,9 +255,9 @@ static int mlp_parse(AVCodecParserContext *s,
avctx->bits_per_raw_sample = mh.group1_bits;
if (avctx->bits_per_raw_sample > 16)
- avctx->sample_fmt = SAMPLE_FMT_S32;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32;
else
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->sample_rate = mh.group1_samplerate;
avctx->frame_size = mh.access_unit_size;
@@ -288,7 +288,7 @@ lost_sync:
return 1;
}
-AVCodecParser mlp_parser = {
+AVCodecParser ff_mlp_parser = {
{ CODEC_ID_MLP, CODEC_ID_TRUEHD },
sizeof(MLPParseContext),
mlp_init,
diff --git a/lib/ffmpeg/libavcodec/mlpdec.c b/lib/ffmpeg/libavcodec/mlpdec.c
index 16397eefd7..a655b3d4a9 100644
--- a/lib/ffmpeg/libavcodec/mlpdec.c
+++ b/lib/ffmpeg/libavcodec/mlpdec.c
@@ -318,9 +318,9 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
m->avctx->bits_per_raw_sample = mh.group1_bits;
if (mh.group1_bits > 16)
- m->avctx->sample_fmt = SAMPLE_FMT_S32;
+ m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
else
- m->avctx->sample_fmt = SAMPLE_FMT_S16;
+ m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
m->params_valid = 1;
for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
@@ -931,7 +931,7 @@ static int output_data_internal(MLPDecodeContext *m, unsigned int substr,
static int output_data(MLPDecodeContext *m, unsigned int substr,
uint8_t *data, unsigned int *data_size)
{
- if (m->avctx->sample_fmt == SAMPLE_FMT_S32)
+ if (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32)
return output_data_internal(m, substr, data, data_size, 1);
else
return output_data_internal(m, substr, data, data_size, 0);
@@ -1137,7 +1137,7 @@ error:
return -1;
}
-AVCodec mlp_decoder = {
+AVCodec ff_mlp_decoder = {
"mlp",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MLP,
@@ -1150,7 +1150,7 @@ AVCodec mlp_decoder = {
};
#if CONFIG_TRUEHD_DECODER
-AVCodec truehd_decoder = {
+AVCodec ff_truehd_decoder = {
"truehd",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_TRUEHD,
diff --git a/lib/ffmpeg/libavcodec/mmvideo.c b/lib/ffmpeg/libavcodec/mmvideo.c
index 6dbc0c4494..60e00fbe29 100644
--- a/lib/ffmpeg/libavcodec/mmvideo.c
+++ b/lib/ffmpeg/libavcodec/mmvideo.c
@@ -78,6 +78,10 @@ static void mm_decode_pal(MmContext *s, const uint8_t *buf, const uint8_t *buf_e
}
}
+/**
+ * @param half_horiz Half horizontal resolution (0 or 1)
+ * @param half_vert Half vertical resolution (0 or 1)
+ */
static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size)
{
int i, x, y;
@@ -86,6 +90,9 @@ static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const
while(i<buf_size) {
int run_length, color;
+ if (y >= s->avctx->height)
+ return;
+
if (buf[i] & 0x80) {
run_length = 1;
color = buf[i];
@@ -108,11 +115,15 @@ static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const
if (x >= s->avctx->width) {
x=0;
- y += half_vert ? 2 : 1;
+ y += 1 + half_vert;
}
}
}
+/*
+ * @param half_horiz Half horizontal resolution (0 or 1)
+ * @param half_vert Half vertical resolution (0 or 1)
+ */
static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size)
{
const int data_ptr = 2 + AV_RL16(&buf[0]);
@@ -130,6 +141,9 @@ static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const
continue;
}
+ if (y + half_vert >= s->avctx->height)
+ return;
+
for(i=0; i<length; i++) {
for(j=0; j<8; j++) {
int replace = (buf[r+i] >> (7-j)) & 1;
@@ -145,12 +159,12 @@ static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const
}
d++;
}
- x += half_horiz ? 2 : 1;
+ x += 1 + half_horiz;
}
}
r += length;
- y += half_vert ? 2 : 1;
+ y += 1 + half_vert;
}
}
@@ -198,7 +212,7 @@ static av_cold int mm_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec mmvideo_decoder = {
+AVCodec ff_mmvideo_decoder = {
"mmvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MMVIDEO,
diff --git a/lib/ffmpeg/libavcodec/motion-test.c b/lib/ffmpeg/libavcodec/motion-test.c
index 37f55a6f42..994b262bc0 100644
--- a/lib/ffmpeg/libavcodec/motion-test.c
+++ b/lib/ffmpeg/libavcodec/motion-test.c
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
AVCodecContext *ctx;
int c;
DSPContext cctx, mmxctx;
- int flags[2] = { FF_MM_MMX, FF_MM_MMX2 };
+ int flags[2] = { AV_CPU_FLAG_MMX, AV_CPU_FLAG_MMX2 };
int flags_size = HAVE_MMX2 ? 2 : 1;
for(;;) {
@@ -145,11 +145,11 @@ int main(int argc, char **argv)
printf("ffmpeg motion test\n");
ctx = avcodec_alloc_context();
- ctx->dsp_mask = FF_MM_FORCE;
+ ctx->dsp_mask = AV_CPU_FLAG_FORCE;
dsputil_init(&cctx, ctx);
for (c = 0; c < flags_size; c++) {
int x;
- ctx->dsp_mask = FF_MM_FORCE | flags[c];
+ ctx->dsp_mask = AV_CPU_FLAG_FORCE | flags[c];
dsputil_init(&mmxctx, ctx);
for (x = 0; x < 2; x++) {
diff --git a/lib/ffmpeg/libavcodec/motionpixels.c b/lib/ffmpeg/libavcodec/motionpixels.c
index 9bc5e2035d..ed0af4d90e 100644
--- a/lib/ffmpeg/libavcodec/motionpixels.c
+++ b/lib/ffmpeg/libavcodec/motionpixels.c
@@ -302,7 +302,7 @@ static av_cold int mp_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec motionpixels_decoder = {
+AVCodec ff_motionpixels_decoder = {
"motionpixels",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MOTIONPIXELS,
diff --git a/lib/ffmpeg/libavcodec/movsub_bsf.c b/lib/ffmpeg/libavcodec/movsub_bsf.c
index 2423f2db94..088c774001 100644
--- a/lib/ffmpeg/libavcodec/movsub_bsf.c
+++ b/lib/ffmpeg/libavcodec/movsub_bsf.c
@@ -33,7 +33,7 @@ static int text2movsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, co
return 1;
}
-AVBitStreamFilter text2movsub_bsf={
+AVBitStreamFilter ff_text2movsub_bsf={
"text2movsub",
0,
text2movsub,
@@ -49,7 +49,7 @@ static int mov2textsub(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, co
return 1;
}
-AVBitStreamFilter mov2textsub_bsf={
+AVBitStreamFilter ff_mov2textsub_bsf={
"mov2textsub",
0,
mov2textsub,
diff --git a/lib/ffmpeg/libavcodec/mp3_header_compress_bsf.c b/lib/ffmpeg/libavcodec/mp3_header_compress_bsf.c
index f5c513834a..006a3679e9 100644
--- a/lib/ffmpeg/libavcodec/mp3_header_compress_bsf.c
+++ b/lib/ffmpeg/libavcodec/mp3_header_compress_bsf.c
@@ -79,7 +79,7 @@ output_unchanged:
return 1;
}
-AVBitStreamFilter mp3_header_compress_bsf={
+AVBitStreamFilter ff_mp3_header_compress_bsf={
"mp3comp",
0,
mp3_header_compress,
diff --git a/lib/ffmpeg/libavcodec/mp3_header_decompress_bsf.c b/lib/ffmpeg/libavcodec/mp3_header_decompress_bsf.c
index d897ed9852..f096d5e4fd 100644
--- a/lib/ffmpeg/libavcodec/mp3_header_decompress_bsf.c
+++ b/lib/ffmpeg/libavcodec/mp3_header_decompress_bsf.c
@@ -89,7 +89,7 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext
return 1;
}
-AVBitStreamFilter mp3_header_decompress_bsf={
+AVBitStreamFilter ff_mp3_header_decompress_bsf={
"mp3decomp",
0,
mp3_header_decompress,
diff --git a/lib/ffmpeg/libavcodec/mpc.c b/lib/ffmpeg/libavcodec/mpc.c
index 30ae591a0f..d9a1fb776a 100644
--- a/lib/ffmpeg/libavcodec/mpc.c
+++ b/lib/ffmpeg/libavcodec/mpc.c
@@ -42,27 +42,27 @@ void ff_mpc_init(void)
/**
* Process decoded Musepack data and produce PCM
*/
-static void mpc_synth(MPCContext *c, int16_t *out)
+static void mpc_synth(MPCContext *c, int16_t *out, int channels)
{
int dither_state = 0;
int i, ch;
OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;
- for(ch = 0; ch < 2; ch++){
+ for(ch = 0; ch < channels; ch++){
samples_ptr = samples + ch;
for(i = 0; i < SAMPLES_PER_BAND; i++) {
ff_mpa_synth_filter(c->synth_buf[ch], &(c->synth_buf_offset[ch]),
ff_mpa_synth_window, &dither_state,
- samples_ptr, 2,
+ samples_ptr, channels,
c->sb_samples[ch][i]);
- samples_ptr += 64;
+ samples_ptr += 32 * channels;
}
}
- for(i = 0; i < MPC_FRAME_SIZE*2; i++)
+ for(i = 0; i < MPC_FRAME_SIZE*channels; i++)
*out++=samples[i];
}
-void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data)
+void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels)
{
int i, j, ch;
Band *bands = c->bands;
@@ -98,5 +98,5 @@ void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data)
}
}
- mpc_synth(c, data);
+ mpc_synth(c, data, channels);
}
diff --git a/lib/ffmpeg/libavcodec/mpc.h b/lib/ffmpeg/libavcodec/mpc.h
index 25d1d2ce04..2d9755a593 100644
--- a/lib/ffmpeg/libavcodec/mpc.h
+++ b/lib/ffmpeg/libavcodec/mpc.h
@@ -72,6 +72,6 @@ typedef struct {
} MPCContext;
void ff_mpc_init(void);
-void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, void *dst);
+void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, void *dst, int channels);
#endif /* AVCODEC_MPC_H */
diff --git a/lib/ffmpeg/libavcodec/mpc7.c b/lib/ffmpeg/libavcodec/mpc7.c
index 42de27e7b9..a77648f770 100644
--- a/lib/ffmpeg/libavcodec/mpc7.c
+++ b/lib/ffmpeg/libavcodec/mpc7.c
@@ -85,7 +85,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
c->IS, c->MSS, c->gapless, c->lastframelen, c->maxbands);
c->frames_to_skip = 0;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
if(vlc_initialized) return 0;
@@ -206,7 +206,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
c->dsp.bswap_buf((uint32_t*)bits, (const uint32_t*)(buf + 4), (buf_size - 4) >> 2);
init_get_bits(&gb, bits, (buf_size - 4)* 8);
- skip_bits(&gb, buf[0]);
+ skip_bits_long(&gb, buf[0]);
/* read subband indexes */
for(i = 0; i <= c->maxbands; i++){
@@ -260,7 +260,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
for(ch = 0; ch < 2; ch++)
idx_to_quant(c, &gb, bands[i].res[ch], c->Q[ch] + off);
- ff_mpc_dequantize_and_synth(c, mb, data);
+ ff_mpc_dequantize_and_synth(c, mb, data, 2);
av_free(bits);
@@ -288,7 +288,7 @@ static void mpc7_decode_flush(AVCodecContext *avctx)
c->frames_to_skip = 32;
}
-AVCodec mpc7_decoder = {
+AVCodec ff_mpc7_decoder = {
"mpc7",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MUSEPACK7,
diff --git a/lib/ffmpeg/libavcodec/mpc8.c b/lib/ffmpeg/libavcodec/mpc8.c
index 376274608f..327a0c02f4 100644
--- a/lib/ffmpeg/libavcodec/mpc8.c
+++ b/lib/ffmpeg/libavcodec/mpc8.c
@@ -99,6 +99,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
MPCContext *c = avctx->priv_data;
GetBitContext gb;
static int vlc_initialized = 0;
+ int channels;
static VLC_TYPE band_table[542][2];
static VLC_TYPE q1_table[520][2];
@@ -125,11 +126,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
skip_bits(&gb, 3);//sample rate
c->maxbands = get_bits(&gb, 5) + 1;
- skip_bits(&gb, 4);//channels
+ channels = get_bits(&gb, 4) + 1;
+ if (channels > 2) {
+ av_log_missing_feature(avctx, "Multichannel MPC SV8", 1);
+ return -1;
+ }
c->MSS = get_bits1(&gb);
c->frames = 1 << (get_bits(&gb, 3) * 2);
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
if(vlc_initialized) return 0;
@@ -387,19 +392,19 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
}
}
- ff_mpc_dequantize_and_synth(c, maxband, data);
+ ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
- *data_size = MPC_FRAME_SIZE * 4;
+ *data_size = MPC_FRAME_SIZE * 2 * avctx->channels;
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
}
-AVCodec mpc8_decoder = {
+AVCodec ff_mpc8_decoder = {
"mpc8",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MUSEPACK8,
diff --git a/lib/ffmpeg/libavcodec/mpeg12.c b/lib/ffmpeg/libavcodec/mpeg12.c
index 8d61553ce9..6254abb1c3 100644
--- a/lib/ffmpeg/libavcodec/mpeg12.c
+++ b/lib/ffmpeg/libavcodec/mpeg12.c
@@ -137,6 +137,9 @@ void ff_mpeg1_clean_buffers(MpegEncContext *s){
/******************************************/
/* decoding */
+VLC ff_dc_lum_vlc;
+VLC ff_dc_chroma_vlc;
+
static VLC mv_vlc;
static VLC mbincr_vlc;
static VLC mb_ptype_vlc;
@@ -150,10 +153,10 @@ av_cold void ff_mpeg12_init_vlcs(void)
if (!done) {
done = 1;
- INIT_VLC_STATIC(&dc_lum_vlc, DC_VLC_BITS, 12,
+ INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
ff_mpeg12_vlc_dc_lum_bits, 1, 1,
ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
- INIT_VLC_STATIC(&dc_chroma_vlc, DC_VLC_BITS, 12,
+ INIT_VLC_STATIC(&ff_dc_chroma_vlc, DC_VLC_BITS, 12,
ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 17,
@@ -210,7 +213,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1<< s->chroma_format);
- dprintf(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
+ av_dlog(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
assert(s->mb_skipped==0);
@@ -269,7 +272,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
mb_type = btype2mb_type[ mb_type ];
break;
}
- dprintf(s->avctx, "mb_type=%x\n", mb_type);
+ av_dlog(s->avctx, "mb_type=%x\n", mb_type);
// motion_type = 0; /* avoid warning */
if (IS_INTRA(mb_type)) {
s->dsp.clear_blocks(s->block[0]);
@@ -367,7 +370,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
/* motion vectors */
s->mv_dir= (mb_type>>13)&3;
- dprintf(s->avctx, "motion_type=%d\n", motion_type);
+ av_dlog(s->avctx, "motion_type=%d\n", motion_type);
switch(motion_type) {
case MT_FRAME: /* or MT_16X8 */
if (s->picture_structure == PICT_FRAME) {
@@ -418,12 +421,12 @@ static int mpeg_decode_mb(MpegEncContext *s,
s->last_mv[i][j][0]);
s->last_mv[i][j][0] = val;
s->mv[i][j][0] = val;
- dprintf(s->avctx, "fmx=%d\n", val);
+ av_dlog(s->avctx, "fmx=%d\n", val);
val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
s->last_mv[i][j][1] >> 1);
s->last_mv[i][j][1] = val << 1;
s->mv[i][j][1] = val;
- dprintf(s->avctx, "fmy=%d\n", val);
+ av_dlog(s->avctx, "fmy=%d\n", val);
}
}
}
@@ -629,7 +632,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
dc += diff;
s->last_dc[component] = dc;
block[0] = dc*quant_matrix[0];
- dprintf(s->avctx, "dc=%d diff=%d\n", dc, diff);
+ av_dlog(s->avctx, "dc=%d diff=%d\n", dc, diff);
i = 0;
{
OPEN_READER(re, &s->gb);
@@ -715,9 +718,6 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
/* now quantify & encode AC coefficients */
for(;;) {
GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
@@ -757,14 +757,9 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
}
block[j] = level;
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
-#if MIN_CACHE_BITS >= 19
UPDATE_CACHE(re, &s->gb);
-#endif
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
@@ -797,9 +792,6 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
/* now quantify & encode AC coefficients */
for(;;) {
@@ -836,14 +828,9 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *bloc
}
block[j] = level;
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
-#if MIN_CACHE_BITS >= 19
UPDATE_CACHE(re, &s->gb);
-#endif
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
@@ -888,9 +875,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
/* now quantify & encode AC coefficients */
for(;;) {
@@ -924,14 +908,9 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
mismatch ^= level;
block[j] = level;
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
-#if MIN_CACHE_BITS >= 19
UPDATE_CACHE(re, &s->gb);
-#endif
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
@@ -966,9 +945,6 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
goto end;
}
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
/* now quantify & encode AC coefficients */
for(;;) {
@@ -997,14 +973,9 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
}
block[j] = level;
-#if MIN_CACHE_BITS < 19
- UPDATE_CACHE(re, &s->gb);
-#endif
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
break;
-#if MIN_CACHE_BITS >=19
UPDATE_CACHE(re, &s->gb);
-#endif
}
end:
LAST_SKIP_BITS(re, &s->gb, 2);
@@ -1041,7 +1012,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
dc += diff;
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
- dprintf(s->avctx, "dc=%d\n", block[0]);
+ av_dlog(s->avctx, "dc=%d\n", block[0]);
mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
@@ -1168,7 +1139,7 @@ typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
- AVPanScan pan_scan; /** some temporary storage for the panscan */
+ AVPanScan pan_scan; /**< some temporary storage for the panscan */
int slice_count;
int swap_uv;//indicate VCR2
int save_aspect_info;
@@ -1415,7 +1386,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
s1->frame_rate_ext.num = get_bits(&s->gb, 2)+1;
s1->frame_rate_ext.den = get_bits(&s->gb, 5)+1;
- dprintf(s->avctx, "sequence extension\n");
+ av_dlog(s->avctx, "sequence extension\n");
s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
s->avctx->sub_id = 2; /* indicates MPEG-2 found */
@@ -1506,7 +1477,7 @@ static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], uint16_t matrix1
static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
{
- dprintf(s->avctx, "matrix extension\n");
+ av_dlog(s->avctx, "matrix extension\n");
if(get_bits1(&s->gb)) load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
if(get_bits1(&s->gb)) load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
@@ -1580,15 +1551,15 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
}
/* composite display not parsed */
- dprintf(s->avctx, "intra_dc_precision=%d\n", s->intra_dc_precision);
- dprintf(s->avctx, "picture_structure=%d\n", s->picture_structure);
- dprintf(s->avctx, "top field first=%d\n", s->top_field_first);
- dprintf(s->avctx, "repeat first field=%d\n", s->repeat_first_field);
- dprintf(s->avctx, "conceal=%d\n", s->concealment_motion_vectors);
- dprintf(s->avctx, "intra_vlc_format=%d\n", s->intra_vlc_format);
- dprintf(s->avctx, "alternate_scan=%d\n", s->alternate_scan);
- dprintf(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
- dprintf(s->avctx, "progressive_frame=%d\n", s->progressive_frame);
+ av_dlog(s->avctx, "intra_dc_precision=%d\n", s->intra_dc_precision);
+ av_dlog(s->avctx, "picture_structure=%d\n", s->picture_structure);
+ av_dlog(s->avctx, "top field first=%d\n", s->top_field_first);
+ av_dlog(s->avctx, "repeat first field=%d\n", s->repeat_first_field);
+ av_dlog(s->avctx, "conceal=%d\n", s->concealment_motion_vectors);
+ av_dlog(s->avctx, "intra_vlc_format=%d\n", s->intra_vlc_format);
+ av_dlog(s->avctx, "alternate_scan=%d\n", s->alternate_scan);
+ av_dlog(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
+ av_dlog(s->avctx, "progressive_frame=%d\n", s->progressive_frame);
}
static void exchange_uv(MpegEncContext *s){
@@ -2229,7 +2200,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
Mpeg1Context *s = avctx->priv_data;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
- dprintf(avctx, "fill_buffer\n");
+ av_dlog(avctx, "fill_buffer\n");
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
/* special case for last picture */
@@ -2500,7 +2471,7 @@ static int mpeg_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec mpeg1video_decoder = {
+AVCodec ff_mpeg1video_decoder = {
"mpeg1video",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG1VIDEO,
@@ -2515,7 +2486,7 @@ AVCodec mpeg1video_decoder = {
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
};
-AVCodec mpeg2video_decoder = {
+AVCodec ff_mpeg2video_decoder = {
"mpeg2video",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG2VIDEO,
@@ -2531,7 +2502,7 @@ AVCodec mpeg2video_decoder = {
};
//legacy decoder
-AVCodec mpegvideo_decoder = {
+AVCodec ff_mpegvideo_decoder = {
"mpegvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG2VIDEO,
@@ -2553,7 +2524,7 @@ static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx){
if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) )
return -1;
if( !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD) ){
- dprintf(avctx, "mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
+ av_dlog(avctx, "mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
}
mpeg_decode_init(avctx);
@@ -2563,7 +2534,7 @@ static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx){
return 0;
}
-AVCodec mpeg_xvmc_decoder = {
+AVCodec ff_mpeg_xvmc_decoder = {
"mpegvideo_xvmc",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG2VIDEO_XVMC,
@@ -2580,7 +2551,7 @@ AVCodec mpeg_xvmc_decoder = {
#endif
#if CONFIG_MPEG_VDPAU_DECODER
-AVCodec mpeg_vdpau_decoder = {
+AVCodec ff_mpeg_vdpau_decoder = {
"mpegvideo_vdpau",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG2VIDEO,
@@ -2596,7 +2567,7 @@ AVCodec mpeg_vdpau_decoder = {
#endif
#if CONFIG_MPEG1_VDPAU_DECODER
-AVCodec mpeg1_vdpau_decoder = {
+AVCodec ff_mpeg1_vdpau_decoder = {
"mpeg1video_vdpau",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG1VIDEO,
diff --git a/lib/ffmpeg/libavcodec/mpeg12.h b/lib/ffmpeg/libavcodec/mpeg12.h
index 30bb675d35..541b66bd94 100644
--- a/lib/ffmpeg/libavcodec/mpeg12.h
+++ b/lib/ffmpeg/libavcodec/mpeg12.h
@@ -27,8 +27,8 @@
#define DC_VLC_BITS 9
#define TEX_VLC_BITS 9
-static VLC dc_lum_vlc;
-static VLC dc_chroma_vlc;
+extern VLC ff_dc_lum_vlc;
+extern VLC ff_dc_chroma_vlc;
extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
@@ -40,9 +40,9 @@ static inline int decode_dc(GetBitContext *gb, int component)
int code, diff;
if (component == 0) {
- code = get_vlc2(gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2);
} else {
- code = get_vlc2(gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2);
}
if (code < 0){
av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n");
diff --git a/lib/ffmpeg/libavcodec/mpeg12enc.c b/lib/ffmpeg/libavcodec/mpeg12enc.c
index 6868e2a206..b2526f6b7a 100644
--- a/lib/ffmpeg/libavcodec/mpeg12enc.c
+++ b/lib/ffmpeg/libavcodec/mpeg12enc.c
@@ -890,7 +890,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
next_coef:
#if 0
if (level != 0)
- dprintf(s->avctx, "level[%d]=%d\n", i, level);
+ av_dlog(s->avctx, "level[%d]=%d\n", i, level);
#endif
/* encode using VLC */
if (level != 0) {
@@ -930,7 +930,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
put_bits(&s->pb, table_vlc[112][1], table_vlc[112][0]);
}
-AVCodec mpeg1video_encoder = {
+AVCodec ff_mpeg1video_encoder = {
"mpeg1video",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG1VIDEO,
@@ -944,7 +944,7 @@ AVCodec mpeg1video_encoder = {
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
};
-AVCodec mpeg2video_encoder = {
+AVCodec ff_mpeg2video_encoder = {
"mpeg2video",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG2VIDEO,
diff --git a/lib/ffmpeg/libavcodec/mpeg4video_parser.c b/lib/ffmpeg/libavcodec/mpeg4video_parser.c
index 5dbda8ba80..5d0f47ec13 100644
--- a/lib/ffmpeg/libavcodec/mpeg4video_parser.c
+++ b/lib/ffmpeg/libavcodec/mpeg4video_parser.c
@@ -129,7 +129,7 @@ static int mpeg4video_parse(AVCodecParserContext *s,
}
-AVCodecParser mpeg4video_parser = {
+AVCodecParser ff_mpeg4video_parser = {
{ CODEC_ID_MPEG4 },
sizeof(ParseContext1),
mpeg4video_parse_init,
diff --git a/lib/ffmpeg/libavcodec/mpeg4videodec.c b/lib/ffmpeg/libavcodec/mpeg4videodec.c
index b339f7812f..5303da3874 100644
--- a/lib/ffmpeg/libavcodec/mpeg4videodec.c
+++ b/lib/ffmpeg/libavcodec/mpeg4videodec.c
@@ -1023,12 +1023,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
if(last) i+=192;
} else {
/* second escape */
-#if MIN_CACHE_BITS < 20
- LAST_SKIP_BITS(re, &s->gb, 2);
- UPDATE_CACHE(re, &s->gb);
-#else
SKIP_BITS(re, &s->gb, 2);
-#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run + rl->max_run[run>>7][level/qmul] +1; //FIXME opt indexing
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
@@ -1036,12 +1031,7 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
}
} else {
/* first escape */
-#if MIN_CACHE_BITS < 19
- LAST_SKIP_BITS(re, &s->gb, 1);
- UPDATE_CACHE(re, &s->gb);
-#else
SKIP_BITS(re, &s->gb, 1);
-#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
@@ -1575,6 +1565,7 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
s->avctx->time_base.den = get_bits(gb, 16);
if(!s->avctx->time_base.den){
av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");
+ s->avctx->time_base.num = 0;
return -1;
}
@@ -2234,7 +2225,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
return 0;
}
-AVCodec mpeg4_decoder = {
+AVCodec ff_mpeg4_decoder = {
"mpeg4",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG4,
@@ -2252,7 +2243,7 @@ AVCodec mpeg4_decoder = {
#if CONFIG_MPEG4_VDPAU_DECODER
-AVCodec mpeg4_vdpau_decoder = {
+AVCodec ff_mpeg4_vdpau_decoder = {
"mpeg4_vdpau",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG4,
diff --git a/lib/ffmpeg/libavcodec/mpeg4videoenc.c b/lib/ffmpeg/libavcodec/mpeg4videoenc.c
index 856cfa777e..2af898b955 100644
--- a/lib/ffmpeg/libavcodec/mpeg4videoenc.c
+++ b/lib/ffmpeg/libavcodec/mpeg4videoenc.c
@@ -1338,7 +1338,7 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
put_bits(&s->pb, 1, 0); /* no HEC */
}
-AVCodec mpeg4_encoder = {
+AVCodec ff_mpeg4_encoder = {
"mpeg4",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MPEG4,
diff --git a/lib/ffmpeg/libavcodec/mpegaudio.h b/lib/ffmpeg/libavcodec/mpegaudio.h
index e2ad911b0c..97c7855f06 100644
--- a/lib/ffmpeg/libavcodec/mpegaudio.h
+++ b/lib/ffmpeg/libavcodec/mpegaudio.h
@@ -72,19 +72,19 @@
#if CONFIG_FLOAT
typedef float OUT_INT;
-#define OUT_FMT SAMPLE_FMT_FLT
+#define OUT_FMT AV_SAMPLE_FMT_FLT
#elif CONFIG_MPEGAUDIO_HP && CONFIG_AUDIO_NONSHORT
typedef int32_t OUT_INT;
#define OUT_MAX INT32_MAX
#define OUT_MIN INT32_MIN
#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
-#define OUT_FMT SAMPLE_FMT_S32
+#define OUT_FMT AV_SAMPLE_FMT_S32
#else
typedef int16_t OUT_INT;
#define OUT_MAX INT16_MAX
#define OUT_MIN INT16_MIN
#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
-#define OUT_FMT SAMPLE_FMT_S16
+#define OUT_FMT AV_SAMPLE_FMT_S16
#endif
#if CONFIG_FLOAT
diff --git a/lib/ffmpeg/libavcodec/mpegaudio_parser.c b/lib/ffmpeg/libavcodec/mpegaudio_parser.c
index 6d7ab8a9c1..cfd92d42eb 100644
--- a/lib/ffmpeg/libavcodec/mpegaudio_parser.c
+++ b/lib/ffmpeg/libavcodec/mpegaudio_parser.c
@@ -140,7 +140,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
}
-AVCodecParser mpegaudio_parser = {
+AVCodecParser ff_mpegaudio_parser = {
{ CODEC_ID_MP1, CODEC_ID_MP2, CODEC_ID_MP3 },
sizeof(MpegAudioParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/mpegaudiodec.c b/lib/ffmpeg/libavcodec/mpegaudiodec.c
index 4f48c15e09..0cd0b688c1 100644
--- a/lib/ffmpeg/libavcodec/mpegaudiodec.c
+++ b/lib/ffmpeg/libavcodec/mpegaudiodec.c
@@ -352,7 +352,7 @@ static av_cold int decode_init(AVCodecContext * avctx)
scale_factor_mult[i][0] = MULLx(norm, FIXR(1.0 * 2.0), FRAC_BITS);
scale_factor_mult[i][1] = MULLx(norm, FIXR(0.7937005259 * 2.0), FRAC_BITS);
scale_factor_mult[i][2] = MULLx(norm, FIXR(0.6299605249 * 2.0), FRAC_BITS);
- dprintf(avctx, "%d: norm=%x s=%x %x %x\n",
+ av_dlog(avctx, "%d: norm=%x s=%x %x %x\n",
i, norm,
scale_factor_mult[i][0],
scale_factor_mult[i][1],
@@ -457,7 +457,7 @@ static av_cold int decode_init(AVCodecContext * avctx)
k = i & 1;
is_table_lsf[j][k ^ 1][i] = FIXR(f);
is_table_lsf[j][k][i] = FIXR(1.0);
- dprintf(avctx, "is_table_lsf %d %d: %x %x\n",
+ av_dlog(avctx, "is_table_lsf %d %d: %x %x\n",
i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]);
}
}
@@ -986,7 +986,7 @@ static int mp_decode_layer2(MPADecodeContext *s)
else
bound = sblimit;
- dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
+ av_dlog(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
/* sanity check */
if( bound > sblimit ) bound = sblimit;
@@ -1309,7 +1309,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
exponent= exponents[s_index];
- dprintf(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n",
+ av_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n",
i, g->region_size[i] - j, x, y, exponent);
if(y&16){
x = y >> 5;
@@ -1377,7 +1377,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
last_pos= pos;
code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1);
- dprintf(s->avctx, "t=%d code=%d\n", g->count1table_select, code);
+ av_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code);
g->sb_hybrid[s_index+0]=
g->sb_hybrid[s_index+1]=
g->sb_hybrid[s_index+2]=
@@ -1735,7 +1735,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
for(gr=0;gr<nb_granules;gr++) {
for(ch=0;ch<s->nb_channels;ch++) {
- dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch);
+ av_dlog(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch);
g = &s->granules[ch][gr];
g->part2_3_length = get_bits(&s->gb, 12);
g->big_values = get_bits(&s->gb, 9);
@@ -1776,7 +1776,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
/* compute huffman coded region sizes */
region_address1 = get_bits(&s->gb, 4);
region_address2 = get_bits(&s->gb, 3);
- dprintf(s->avctx, "region1=%d region2=%d\n",
+ av_dlog(s->avctx, "region1=%d region2=%d\n",
region_address1, region_address2);
ff_init_long_region(s, g, region_address1, region_address2);
}
@@ -1788,7 +1788,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
g->preflag = get_bits1(&s->gb);
g->scalefac_scale = get_bits1(&s->gb);
g->count1table_select = get_bits1(&s->gb);
- dprintf(s->avctx, "block_type=%d switch_point=%d\n",
+ av_dlog(s->avctx, "block_type=%d switch_point=%d\n",
g->block_type, g->switch_point);
}
}
@@ -1797,7 +1797,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
assert((get_bits_count(&s->gb) & 7) == 0);
/* now we get bits from the main_data_begin offset */
- dprintf(s->avctx, "seekback: %d\n", main_data_begin);
+ av_dlog(s->avctx, "seekback: %d\n", main_data_begin);
//av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size);
memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES);
@@ -1831,7 +1831,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
/* MPEG1 scale factors */
slen1 = slen_table[0][g->scalefac_compress];
slen2 = slen_table[1][g->scalefac_compress];
- dprintf(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2);
+ av_dlog(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2);
if (g->block_type == 2) {
n = g->switch_point ? 17 : 18;
j = 0;
@@ -1964,7 +1964,7 @@ static int mp_decode_frame(MPADecodeContext *s,
if (s->error_protection)
skip_bits(&s->gb, 16);
- dprintf(s->avctx, "frame %d:\n", s->frame_count);
+ av_dlog(s->avctx, "frame %d:\n", s->frame_count);
switch(s->layer) {
case 1:
s->avctx->frame_size = 384;
@@ -2054,7 +2054,8 @@ static int decode_frame(AVCodecContext * avctx,
}
/* update codec info */
avctx->channels = s->nb_channels;
- avctx->bit_rate = s->bit_rate;
+ if (!avctx->bit_rate)
+ avctx->bit_rate = s->bit_rate;
avctx->sub_id = s->layer;
if(*data_size < 1152*avctx->channels*sizeof(OUT_INT))
@@ -2122,7 +2123,8 @@ static int decode_frame_adu(AVCodecContext * avctx,
/* update codec info */
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
- avctx->bit_rate = s->bit_rate;
+ if (!avctx->bit_rate)
+ avctx->bit_rate = s->bit_rate;
avctx->sub_id = s->layer;
s->frame_size = len;
@@ -2306,7 +2308,7 @@ static int decode_frame_mp3on4(AVCodecContext * avctx,
#if !CONFIG_FLOAT
#if CONFIG_MP1_DECODER
-AVCodec mp1_decoder =
+AVCodec ff_mp1_decoder =
{
"mp1",
AVMEDIA_TYPE_AUDIO,
@@ -2322,7 +2324,7 @@ AVCodec mp1_decoder =
};
#endif
#if CONFIG_MP2_DECODER
-AVCodec mp2_decoder =
+AVCodec ff_mp2_decoder =
{
"mp2",
AVMEDIA_TYPE_AUDIO,
@@ -2338,7 +2340,7 @@ AVCodec mp2_decoder =
};
#endif
#if CONFIG_MP3_DECODER
-AVCodec mp3_decoder =
+AVCodec ff_mp3_decoder =
{
"mp3",
AVMEDIA_TYPE_AUDIO,
@@ -2354,7 +2356,7 @@ AVCodec mp3_decoder =
};
#endif
#if CONFIG_MP3ADU_DECODER
-AVCodec mp3adu_decoder =
+AVCodec ff_mp3adu_decoder =
{
"mp3adu",
AVMEDIA_TYPE_AUDIO,
@@ -2370,7 +2372,7 @@ AVCodec mp3adu_decoder =
};
#endif
#if CONFIG_MP3ON4_DECODER
-AVCodec mp3on4_decoder =
+AVCodec ff_mp3on4_decoder =
{
"mp3on4",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/mpegaudiodec_float.c b/lib/ffmpeg/libavcodec/mpegaudiodec_float.c
index 93adaf8cc8..758ef83e05 100644
--- a/lib/ffmpeg/libavcodec/mpegaudiodec_float.c
+++ b/lib/ffmpeg/libavcodec/mpegaudiodec_float.c
@@ -80,8 +80,15 @@ static void compute_antialias_float(MPADecodeContext *s,
}
}
+static av_cold int decode_end(AVCodecContext * avctx)
+{
+ MPADecodeContext *s = avctx->priv_data;
+ ff_dct_end(&s->dct);
+ return 0;
+}
+
#if CONFIG_MP1FLOAT_DECODER
-AVCodec mp1float_decoder =
+AVCodec ff_mp1float_decoder =
{
"mp1float",
AVMEDIA_TYPE_AUDIO,
@@ -89,7 +96,7 @@ AVCodec mp1float_decoder =
sizeof(MPADecodeContext),
decode_init,
NULL,
- NULL,
+ decode_end,
decode_frame,
CODEC_CAP_PARSE_ONLY,
.flush= flush,
@@ -97,7 +104,7 @@ AVCodec mp1float_decoder =
};
#endif
#if CONFIG_MP2FLOAT_DECODER
-AVCodec mp2float_decoder =
+AVCodec ff_mp2float_decoder =
{
"mp2float",
AVMEDIA_TYPE_AUDIO,
@@ -105,7 +112,7 @@ AVCodec mp2float_decoder =
sizeof(MPADecodeContext),
decode_init,
NULL,
- NULL,
+ decode_end,
decode_frame,
CODEC_CAP_PARSE_ONLY,
.flush= flush,
@@ -113,7 +120,7 @@ AVCodec mp2float_decoder =
};
#endif
#if CONFIG_MP3FLOAT_DECODER
-AVCodec mp3float_decoder =
+AVCodec ff_mp3float_decoder =
{
"mp3float",
AVMEDIA_TYPE_AUDIO,
@@ -121,7 +128,7 @@ AVCodec mp3float_decoder =
sizeof(MPADecodeContext),
decode_init,
NULL,
- NULL,
+ decode_end,
decode_frame,
CODEC_CAP_PARSE_ONLY,
.flush= flush,
@@ -129,7 +136,7 @@ AVCodec mp3float_decoder =
};
#endif
#if CONFIG_MP3ADUFLOAT_DECODER
-AVCodec mp3adufloat_decoder =
+AVCodec ff_mp3adufloat_decoder =
{
"mp3adufloat",
AVMEDIA_TYPE_AUDIO,
@@ -137,7 +144,7 @@ AVCodec mp3adufloat_decoder =
sizeof(MPADecodeContext),
decode_init,
NULL,
- NULL,
+ decode_end,
decode_frame_adu,
CODEC_CAP_PARSE_ONLY,
.flush= flush,
@@ -145,7 +152,7 @@ AVCodec mp3adufloat_decoder =
};
#endif
#if CONFIG_MP3ON4FLOAT_DECODER
-AVCodec mp3on4float_decoder =
+AVCodec ff_mp3on4float_decoder =
{
"mp3on4float",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/mpegaudiodecheader.c b/lib/ffmpeg/libavcodec/mpegaudiodecheader.c
index 67f882f566..0821dd43c1 100644
--- a/lib/ffmpeg/libavcodec/mpegaudiodecheader.c
+++ b/lib/ffmpeg/libavcodec/mpegaudiodecheader.c
@@ -91,20 +91,20 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
}
#if defined(DEBUG)
- dprintf(NULL, "layer%d, %d Hz, %d kbits/s, ",
+ av_dlog(NULL, "layer%d, %d Hz, %d kbits/s, ",
s->layer, s->sample_rate, s->bit_rate);
if (s->nb_channels == 2) {
if (s->layer == 3) {
if (s->mode_ext & MODE_EXT_MS_STEREO)
- dprintf(NULL, "ms-");
+ av_dlog(NULL, "ms-");
if (s->mode_ext & MODE_EXT_I_STEREO)
- dprintf(NULL, "i-");
+ av_dlog(NULL, "i-");
}
- dprintf(NULL, "stereo");
+ av_dlog(NULL, "stereo");
} else {
- dprintf(NULL, "mono");
+ av_dlog(NULL, "mono");
}
- dprintf(NULL, "\n");
+ av_dlog(NULL, "\n");
#endif
return 0;
}
diff --git a/lib/ffmpeg/libavcodec/mpegaudioenc.c b/lib/ffmpeg/libavcodec/mpegaudioenc.c
index ce1524ba91..eef40d0fa1 100644
--- a/lib/ffmpeg/libavcodec/mpegaudioenc.c
+++ b/lib/ffmpeg/libavcodec/mpegaudioenc.c
@@ -122,7 +122,7 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
s->sblimit = ff_mpa_sblimit_table[table];
s->alloc_table = ff_mpa_alloc_tables[table];
- dprintf(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
+ av_dlog(avctx, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n",
bitrate, freq, s->frame_size, table, s->frame_frac_incr);
for(i=0;i<s->nb_channels;i++)
@@ -306,7 +306,7 @@ static void idct32(int *out, int *tab)
#define WSHIFT (WFRAC_BITS + 15 - FRAC_BITS)
-static void filter(MpegAudioContext *s, int ch, short *samples, int incr)
+static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
{
short *p, *q;
int sum, offset, i, j;
@@ -752,7 +752,7 @@ static int MPA_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data)
{
MpegAudioContext *s = avctx->priv_data;
- short *samples = data;
+ const short *samples = data;
short smr[MPA_MAX_CHANNELS][SBLIMIT];
unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
int padding, i;
@@ -783,7 +783,7 @@ static av_cold int MPA_encode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec mp2_encoder = {
+AVCodec ff_mp2_encoder = {
"mp2",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_MP2,
@@ -792,7 +792,7 @@ AVCodec mp2_encoder = {
MPA_encode_frame,
MPA_encode_close,
NULL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.supported_samplerates= (const int[]){44100, 48000, 32000, 22050, 24000, 16000, 0},
.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
};
diff --git a/lib/ffmpeg/libavcodec/mpegvideo.c b/lib/ffmpeg/libavcodec/mpegvideo.c
index 684bdfe138..c8706bcf60 100644
--- a/lib/ffmpeg/libavcodec/mpegvideo.c
+++ b/lib/ffmpeg/libavcodec/mpegvideo.c
@@ -28,6 +28,7 @@
*/
#include "libavutil/intmath.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "internal.h"
@@ -497,7 +498,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
- else
+ else if (s->codec_id != CODEC_ID_H264)
s->mb_height = (s->height + 15) / 16;
if(s->avctx->pix_fmt == PIX_FMT_NONE){
@@ -510,7 +511,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
return -1;
}
- if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
+ if((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
dsputil_init(&s->dsp, s->avctx);
@@ -962,7 +963,12 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
return -1;
s->current_picture_ptr= pic;
- s->current_picture_ptr->top_field_first= s->top_field_first; //FIXME use only the vars from current_pic
+ //FIXME use only the vars from current_pic
+ s->current_picture_ptr->top_field_first= s->top_field_first;
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) {
+ if(s->picture_structure != PICT_FRAME)
+ s->current_picture_ptr->top_field_first= (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
+ }
s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence;
}
@@ -1254,7 +1260,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
av_log(s->avctx, AV_LOG_DEBUG, "?");
- if(IS_INTERLACED(mb_type) && s->codec_id == CODEC_ID_H264)
+ if(IS_INTERLACED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "=");
else
av_log(s->avctx, AV_LOG_DEBUG, " ");
@@ -1473,7 +1479,7 @@ static inline int hpel_motion_lowres(MpegEncContext *s,
if( (unsigned)src_x > h_edge_pos - (!!sx) - w
|| (unsigned)src_y >(v_edge_pos >> field_based) - (!!sy) - h){
- ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
src_x, src_y<<field_based, h_edge_pos, v_edge_pos);
src= s->edge_emu_buffer;
emu=1;
@@ -1546,14 +1552,14 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
if( (unsigned)src_x > h_edge_pos - (!!sx) - 2*block_s
|| (unsigned)src_y >(v_edge_pos >> field_based) - (!!sy) - h){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based,
src_x, src_y<<field_based, h_edge_pos, v_edge_pos);
ptr_y = s->edge_emu_buffer;
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
- ff_emulated_edge_mc(uvbuf , ptr_cb, s->uvlinesize, 9, 9+field_based,
+ s->dsp.emulated_edge_mc(uvbuf , ptr_cb, s->uvlinesize, 9, 9+field_based,
uvsrc_x, uvsrc_y<<field_based, h_edge_pos>>1, v_edge_pos>>1);
- ff_emulated_edge_mc(uvbuf+16, ptr_cr, s->uvlinesize, 9, 9+field_based,
+ s->dsp.emulated_edge_mc(uvbuf+16, ptr_cr, s->uvlinesize, 9, 9+field_based,
uvsrc_x, uvsrc_y<<field_based, h_edge_pos>>1, v_edge_pos>>1);
ptr_cb= uvbuf;
ptr_cr= uvbuf+16;
@@ -1619,7 +1625,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
if(s->flags&CODEC_FLAG_EMU_EDGE){
if( (unsigned)src_x > h_edge_pos - (!!sx) - block_s
|| (unsigned)src_y > v_edge_pos - (!!sy) - block_s){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
ptr= s->edge_emu_buffer;
emu=1;
}
@@ -1630,7 +1636,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
ptr = ref_picture[2] + offset;
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
ptr= s->edge_emu_buffer;
}
pix_op[op_index](dest_cr, ptr, s->uvlinesize, block_s, sx, sy);
diff --git a/lib/ffmpeg/libavcodec/mpegvideo.h b/lib/ffmpeg/libavcodec/mpegvideo.h
index 8cd20b7036..53ab0f4a7f 100644
--- a/lib/ffmpeg/libavcodec/mpegvideo.h
+++ b/lib/ffmpeg/libavcodec/mpegvideo.h
@@ -224,9 +224,6 @@ typedef struct MpegEncContext {
int stream_codec_tag; ///< internal stream_codec_tag upper case converted from avctx stream_codec_tag
/* the following fields are managed internally by the encoder */
- /** bit output */
- PutBitContext pb;
-
/* sequence parameters */
int context_initialized;
int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else
@@ -247,6 +244,23 @@ typedef struct MpegEncContext {
Picture **input_picture; ///< next pictures on display order for encoding
Picture **reordered_input_picture; ///< pointer to the next pictures in codedorder for encoding
+ int y_dc_scale, c_dc_scale;
+ int ac_pred;
+ int block_last_index[12]; ///< last non zero coefficient in block
+ int h263_aic; ///< Advanded INTRA Coding (AIC)
+
+ /* scantables */
+ ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
+ ScanTable intra_scantable;
+ ScanTable intra_h_scantable;
+ ScanTable intra_v_scantable;
+
+ /* WARNING: changes above this line require updates to hardcoded
+ * offsets used in asm. */
+
+ /** bit output */
+ PutBitContext pb;
+
int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
struct MpegEncContext *thread_context[MAX_THREADS];
@@ -283,7 +297,6 @@ typedef struct MpegEncContext {
int16_t *dc_val_base;
int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous
int16_t dc_cache[4*5];
- int y_dc_scale, c_dc_scale;
const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table
const uint8_t *c_dc_scale_table; ///< qscale -> c_dc_scale table
const uint8_t *chroma_qscale_table; ///< qscale -> chroma_qscale (h263)
@@ -291,7 +304,6 @@ typedef struct MpegEncContext {
uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
int16_t (*ac_val_base)[16];
int16_t (*ac_val[3])[16]; ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous
- int ac_pred;
uint8_t *prev_pict_types; ///< previous picture types in bitstream order, used for mb skip
#define PREV_PICT_TYPES_BUFFER_SIZE 256
int mb_skipped; ///< MUST BE SET only during DECODING
@@ -434,12 +446,6 @@ typedef struct MpegEncContext {
/** identical to the above but for MMX & these are not permutated, second 64 entries are bias*/
uint16_t (*q_intra_matrix16)[2][64];
uint16_t (*q_inter_matrix16)[2][64];
- int block_last_index[12]; ///< last non zero coefficient in block
- /* scantables */
- ScanTable intra_scantable;
- ScanTable intra_h_scantable;
- ScanTable intra_v_scantable;
- ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
/* noise reduction */
int (*dct_error_sum)[64];
@@ -495,7 +501,6 @@ typedef struct MpegEncContext {
/* H.263+ specific */
int umvplus; ///< == H263+ && unrestricted_mv
- int h263_aic; ///< Advanded INTRA Coding (AIC)
int h263_aic_dir; ///< AIC direction: 0 = left, 1 = top
int h263_slice_structured;
int alt_inter_vlc; ///< alternative inter vlc
diff --git a/lib/ffmpeg/libavcodec/mpegvideo_common.h b/lib/ffmpeg/libavcodec/mpegvideo_common.h
index 8e46e692f9..d607e45ae1 100644
--- a/lib/ffmpeg/libavcodec/mpegvideo_common.h
+++ b/lib/ffmpeg/libavcodec/mpegvideo_common.h
@@ -40,8 +40,6 @@
#include <limits.h>
int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
-int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
-void denoise_dct_c(MpegEncContext *s, DCTELEM *block);
/**
* allocates a Picture
@@ -85,7 +83,7 @@ static inline void gmc1_motion(MpegEncContext *s,
if(s->flags&CODEC_FLAG_EMU_EDGE){
if( (unsigned)src_x >= s->h_edge_pos - 17
|| (unsigned)src_y >= s->v_edge_pos - 17){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer;
}
}
@@ -124,7 +122,7 @@ static inline void gmc1_motion(MpegEncContext *s,
if(s->flags&CODEC_FLAG_EMU_EDGE){
if( (unsigned)src_x >= (s->h_edge_pos>>1) - 9
|| (unsigned)src_y >= (s->v_edge_pos>>1) - 9){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
emu=1;
}
@@ -133,7 +131,7 @@ static inline void gmc1_motion(MpegEncContext *s,
ptr = ref_picture[2] + offset;
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
@@ -225,7 +223,7 @@ static inline int hpel_motion(MpegEncContext *s,
if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){
if( (unsigned)src_x > h_edge_pos - (motion_x&1) - w
|| (unsigned)src_y > v_edge_pos - (motion_y&1) - h){
- ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
src_x, src_y<<field_based, h_edge_pos, s->v_edge_pos);
src= s->edge_emu_buffer;
emu=1;
@@ -317,19 +315,19 @@ if(s->quarter_sample)
"MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
return;
}
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
17, 17+field_based,
src_x, src_y<<field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->edge_emu_buffer;
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
- ff_emulated_edge_mc(uvbuf ,
+ s->dsp.emulated_edge_mc(uvbuf ,
ptr_cb, s->uvlinesize,
9, 9+field_based,
uvsrc_x, uvsrc_y<<field_based,
s->h_edge_pos>>1, s->v_edge_pos>>1);
- ff_emulated_edge_mc(uvbuf+16,
+ s->dsp.emulated_edge_mc(uvbuf+16,
ptr_cr, s->uvlinesize,
9, 9+field_based,
uvsrc_x, uvsrc_y<<field_based,
@@ -514,17 +512,17 @@ static inline void qpel_motion(MpegEncContext *s,
if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 16
|| (unsigned)src_y > v_edge_pos - (motion_y&3) - h ){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
17, 17+field_based, src_x, src_y<<field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y= s->edge_emu_buffer;
if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
uint8_t *uvbuf= s->edge_emu_buffer + 18*s->linesize;
- ff_emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize,
+ s->dsp.emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y<<field_based,
s->h_edge_pos>>1, s->v_edge_pos>>1);
- ff_emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize,
+ s->dsp.emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y<<field_based,
s->h_edge_pos>>1, s->v_edge_pos>>1);
@@ -592,7 +590,7 @@ static inline void chroma_4mv_motion(MpegEncContext *s,
if(s->flags&CODEC_FLAG_EMU_EDGE){
if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8
|| (unsigned)src_y > (s->v_edge_pos>>1) - (dxy>>1) - 8){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
9, 9, src_x, src_y,
s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
@@ -603,7 +601,7 @@ static inline void chroma_4mv_motion(MpegEncContext *s,
ptr = ref_picture[2] + offset;
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
9, 9, src_x, src_y,
s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
@@ -764,7 +762,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
if(s->flags&CODEC_FLAG_EMU_EDGE){
if( (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 8
|| (unsigned)src_y > s->v_edge_pos - (motion_y&3) - 8 ){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr,
s->linesize, 9, 9,
src_x, src_y,
s->h_edge_pos, s->v_edge_pos);
diff --git a/lib/ffmpeg/libavcodec/mpegvideo_enc.c b/lib/ffmpeg/libavcodec/mpegvideo_enc.c
index 9f8682cae5..6167a9b20e 100644
--- a/lib/ffmpeg/libavcodec/mpegvideo_enc.c
+++ b/lib/ffmpeg/libavcodec/mpegvideo_enc.c
@@ -48,6 +48,8 @@
static int encode_picture(MpegEncContext *s, int picture_number);
static int dct_quantize_refine(MpegEncContext *s, DCTELEM *block, int16_t *weight, DCTELEM *orig, int n, int qscale);
static int sse_mb(MpegEncContext *s);
+static void denoise_dct_c(MpegEncContext *s, DCTELEM *block);
+static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
/* enable all paranoid tests for rounding, overflows, etc... */
//#define PARANOID
@@ -252,8 +254,14 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
}
break;
case CODEC_ID_LJPEG:
+ if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUVJ422P && avctx->pix_fmt != PIX_FMT_YUVJ444P && avctx->pix_fmt != PIX_FMT_BGRA &&
+ ((avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUV422P && avctx->pix_fmt != PIX_FMT_YUV444P) || avctx->strict_std_compliance>FF_COMPLIANCE_UNOFFICIAL)){
+ av_log(avctx, AV_LOG_ERROR, "colorspace not supported in LJPEG\n");
+ return -1;
+ }
+ break;
case CODEC_ID_MJPEG:
- if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUVJ422P && avctx->pix_fmt != PIX_FMT_RGB32 &&
+ if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUVJ422P &&
((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;
@@ -351,12 +359,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_INFO, "impossible bitrate constraints, this will fail\n");
}
- if(avctx->rc_buffer_size && avctx->bit_rate*av_q2d(avctx->time_base) > avctx->rc_buffer_size){
+ if(avctx->rc_buffer_size && avctx->bit_rate*(int64_t)avctx->time_base.num > avctx->rc_buffer_size * (int64_t)avctx->time_base.den){
av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n");
return -1;
}
- if(avctx->bit_rate*av_q2d(avctx->time_base) > avctx->bit_rate_tolerance){
+ if(!s->fixed_qscale && avctx->bit_rate*av_q2d(avctx->time_base) > avctx->bit_rate_tolerance){
av_log(avctx, AV_LOG_ERROR, "bitrate tolerance too small for bitrate\n");
return -1;
}
@@ -519,7 +527,9 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
if(avctx->codec_id == CODEC_ID_MPEG4 && s->avctx->time_base.den > (1<<16)-1){
- av_log(avctx, AV_LOG_ERROR, "timebase not supported by mpeg 4 standard\n");
+ av_log(avctx, AV_LOG_ERROR, "timebase %d/%d not supported by MPEG 4 standard, "
+ "the maximum admitted value for the timebase denominator is %d\n",
+ s->avctx->time_base.num, s->avctx->time_base.den, (1<<16)-1);
return -1;
}
s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
@@ -570,7 +580,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
break;
case CODEC_ID_H263:
if (!CONFIG_H263_ENCODER) return -1;
- if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height) == 7) {
+ if (ff_match_2uint16(h263_format, FF_ARRAY_ELEMS(h263_format), s->width, s->height) == 8) {
av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height);
return -1;
}
@@ -618,7 +628,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
s->h263_aic=1;
s->h263_plus=1;
s->loop_filter=1;
- s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
+ s->unrestricted_mv= 0;
break;
case CODEC_ID_MPEG4:
s->out_format = FMT_H263;
@@ -1538,11 +1548,11 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
uint8_t *ebuf= s->edge_emu_buffer + 32;
- ff_emulated_edge_mc(ebuf , ptr_y , wrap_y,16,16,mb_x*16,mb_y*16, s->width , s->height);
+ s->dsp.emulated_edge_mc(ebuf , ptr_y , wrap_y,16,16,mb_x*16,mb_y*16, s->width , s->height);
ptr_y= ebuf;
- ff_emulated_edge_mc(ebuf+18*wrap_y , ptr_cb, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
+ s->dsp.emulated_edge_mc(ebuf+18*wrap_y , ptr_cb, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cb= ebuf+18*wrap_y;
- ff_emulated_edge_mc(ebuf+18*wrap_y+8, ptr_cr, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
+ s->dsp.emulated_edge_mc(ebuf+18*wrap_y+8, ptr_cr, wrap_c, 8, mb_block_height, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cr= ebuf+18*wrap_y+8;
}
@@ -2974,7 +2984,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
return 0;
}
-void denoise_dct_c(MpegEncContext *s, DCTELEM *block){
+static void denoise_dct_c(MpegEncContext *s, DCTELEM *block){
const int intra= s->mb_intra;
int i;
@@ -2998,9 +3008,9 @@ void denoise_dct_c(MpegEncContext *s, DCTELEM *block){
}
}
-int dct_quantize_trellis_c(MpegEncContext *s,
- DCTELEM *block, int n,
- int qscale, int *overflow){
+static int dct_quantize_trellis_c(MpegEncContext *s,
+ DCTELEM *block, int n,
+ int qscale, int *overflow){
const int *qmat;
const uint8_t *scantable= s->intra_scantable.scantable;
const uint8_t *perm_scantable= s->intra_scantable.permutated;
@@ -3769,7 +3779,7 @@ int dct_quantize_c(MpegEncContext *s,
return last_non_zero;
}
-AVCodec h263_encoder = {
+AVCodec ff_h263_encoder = {
"h263",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H263,
@@ -3781,7 +3791,7 @@ AVCodec h263_encoder = {
.long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
};
-AVCodec h263p_encoder = {
+AVCodec ff_h263p_encoder = {
"h263p",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_H263P,
@@ -3793,7 +3803,7 @@ AVCodec h263p_encoder = {
.long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
};
-AVCodec msmpeg4v1_encoder = {
+AVCodec ff_msmpeg4v1_encoder = {
"msmpeg4v1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSMPEG4V1,
@@ -3805,7 +3815,7 @@ AVCodec msmpeg4v1_encoder = {
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
};
-AVCodec msmpeg4v2_encoder = {
+AVCodec ff_msmpeg4v2_encoder = {
"msmpeg4v2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSMPEG4V2,
@@ -3817,7 +3827,7 @@ AVCodec msmpeg4v2_encoder = {
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
};
-AVCodec msmpeg4v3_encoder = {
+AVCodec ff_msmpeg4v3_encoder = {
"msmpeg4",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSMPEG4V3,
@@ -3829,7 +3839,7 @@ AVCodec msmpeg4v3_encoder = {
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
};
-AVCodec wmv1_encoder = {
+AVCodec ff_wmv1_encoder = {
"wmv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WMV1,
diff --git a/lib/ffmpeg/libavcodec/mpegvideo_parser.c b/lib/ffmpeg/libavcodec/mpegvideo_parser.c
index 546c3bdad7..6369224d1a 100644
--- a/lib/ffmpeg/libavcodec/mpegvideo_parser.c
+++ b/lib/ffmpeg/libavcodec/mpegvideo_parser.c
@@ -176,7 +176,7 @@ static int mpegvideo_split(AVCodecContext *avctx,
return 0;
}
-AVCodecParser mpegvideo_parser = {
+AVCodecParser ff_mpegvideo_parser = {
{ CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO },
sizeof(ParseContext1),
NULL,
diff --git a/lib/ffmpeg/libavcodec/mpegvideo_xvmc.c b/lib/ffmpeg/libavcodec/mpegvideo_xvmc.c
index a245200517..0a5a750fd7 100644
--- a/lib/ffmpeg/libavcodec/mpegvideo_xvmc.c
+++ b/lib/ffmpeg/libavcodec/mpegvideo_xvmc.c
@@ -301,7 +301,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
for (i = 0; i < blocks_per_mb; i++) {
if (s->block_last_index[i] >= 0) {
// I do not have unsigned_intra MOCO to test, hope it is OK.
- if (s->mb_intra && (render->idct || (!render->idct && !render->unsigned_intra)))
+ if (s->mb_intra && (render->idct || !render->unsigned_intra))
*s->pblocks[i][0] -= 1 << 10;
if (!render->idct) {
s->dsp.idct(*s->pblocks[i]);
diff --git a/lib/ffmpeg/libavcodec/h264_parser.h b/lib/ffmpeg/libavcodec/msgsmdec.c
index 149f49a386..e759451c83 100644
--- a/lib/ffmpeg/libavcodec/h264_parser.h
+++ b/lib/ffmpeg/libavcodec/msgsmdec.c
@@ -1,6 +1,6 @@
/*
- * H.26L/H.264/AVC/JVT/14496-10/... parser
- * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
+ * gsm 06.10 decoder, Microsoft variant
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
*
* This file is part of FFmpeg.
*
@@ -19,21 +19,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/**
- * @file
- * H.264 / AVC / MPEG4 part10 parser.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_H264_PARSER_H
-#define AVCODEC_H264_PARSER_H
-
-#include "h264.h"
-
-/**
- * finds the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size);
+#define ALT_BITSTREAM_READER_LE
+#include "avcodec.h"
+#include "msgsmdec.h"
+#include "gsmdec_template.c"
-#endif /* AVCODEC_H264_PARSER_H */
+int ff_msgsm_decode_block(AVCodecContext *avctx, int16_t *samples,
+ const uint8_t *buf)
+{
+ int res;
+ GetBitContext gb;
+ init_get_bits(&gb, buf, GSM_MS_BLOCK_SIZE * 8);
+ res = gsm_decode_block(avctx, samples, &gb);
+ if (res < 0)
+ return res;
+ return gsm_decode_block(avctx, samples + GSM_FRAME_SIZE, &gb);
+}
diff --git a/lib/ffmpeg/libavcodec/iff.h b/lib/ffmpeg/libavcodec/msgsmdec.h
index 76db10b884..fbf819a49c 100644
--- a/lib/ffmpeg/libavcodec/iff.h
+++ b/lib/ffmpeg/libavcodec/msgsmdec.h
@@ -1,6 +1,6 @@
/*
- * IFF PBM/ILBM bitmap decoder
- * Copyright (c) 2010 Peter Ross <pross@xvid.org>
+ * gsm 06.10 decoder, Microsoft variant
+ * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
*
* This file is part of FFmpeg.
*
@@ -19,12 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_IFF_H
-#define AVCODEC_IFF_H
+#ifndef MSGSMDEC_H
+#define MSGSMDEC_H
-#include <stdint.h>
#include "avcodec.h"
-int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal);
+int ff_msgsm_decode_block(AVCodecContext *avctx, int16_t *samples,
+ const uint8_t *buf);
-#endif /* AVCODEC_IFF_H */
+#endif
diff --git a/lib/ffmpeg/libavcodec/msmpeg4.c b/lib/ffmpeg/libavcodec/msmpeg4.c
index 8b48dc7cd7..8b3b6a56b6 100644
--- a/lib/ffmpeg/libavcodec/msmpeg4.c
+++ b/lib/ffmpeg/libavcodec/msmpeg4.c
@@ -1395,8 +1395,7 @@ return -1;
#endif
if(s->msmpeg4_version==1){
- int start_code;
- start_code = (get_bits(&s->gb, 16)<<16) | get_bits(&s->gb, 16);
+ int start_code = get_bits_long(&s->gb, 32);
if(start_code!=0x00000100){
av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
return -1;
@@ -1798,12 +1797,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
#endif
} else {
/* second escape */
-#if MIN_CACHE_BITS < 23
- LAST_SKIP_BITS(re, &s->gb, 2);
- UPDATE_CACHE(re, &s->gb);
-#else
SKIP_BITS(re, &s->gb, 2);
-#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
@@ -1817,12 +1811,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
}
} else {
/* first escape */
-#if MIN_CACHE_BITS < 22
- LAST_SKIP_BITS(re, &s->gb, 1);
- UPDATE_CACHE(re, &s->gb);
-#else
SKIP_BITS(re, &s->gb, 1);
-#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
@@ -1919,7 +1908,7 @@ int ff_msmpeg4_decode_motion(MpegEncContext * s,
return 0;
}
-AVCodec msmpeg4v1_decoder = {
+AVCodec ff_msmpeg4v1_decoder = {
"msmpeg4v1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSMPEG4V1,
@@ -1934,7 +1923,7 @@ AVCodec msmpeg4v1_decoder = {
.pix_fmts= ff_pixfmt_list_420,
};
-AVCodec msmpeg4v2_decoder = {
+AVCodec ff_msmpeg4v2_decoder = {
"msmpeg4v2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSMPEG4V2,
@@ -1949,7 +1938,7 @@ AVCodec msmpeg4v2_decoder = {
.pix_fmts= ff_pixfmt_list_420,
};
-AVCodec msmpeg4v3_decoder = {
+AVCodec ff_msmpeg4v3_decoder = {
"msmpeg4",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSMPEG4V3,
@@ -1964,7 +1953,7 @@ AVCodec msmpeg4v3_decoder = {
.pix_fmts= ff_pixfmt_list_420,
};
-AVCodec wmv1_decoder = {
+AVCodec ff_wmv1_decoder = {
"wmv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WMV1,
diff --git a/lib/ffmpeg/libavcodec/msrle.c b/lib/ffmpeg/libavcodec/msrle.c
index 28eb5d33f1..f1fa8f54ff 100644
--- a/lib/ffmpeg/libavcodec/msrle.c
+++ b/lib/ffmpeg/libavcodec/msrle.c
@@ -143,7 +143,7 @@ static av_cold int msrle_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec msrle_decoder = {
+AVCodec ff_msrle_decoder = {
"msrle",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSRLE,
diff --git a/lib/ffmpeg/libavcodec/msrledec.c b/lib/ffmpeg/libavcodec/msrledec.c
index 6e16d535b3..97510830d5 100644
--- a/lib/ffmpeg/libavcodec/msrledec.c
+++ b/lib/ffmpeg/libavcodec/msrledec.c
@@ -45,7 +45,7 @@ static int msrle_decode_pal4(AVCodecContext *avctx, AVPicture *pic,
unsigned char rle_code;
unsigned char extra_byte, odd_pixel;
unsigned char stream_byte;
- int pixel_ptr = 0;
+ unsigned int pixel_ptr = 0;
int row_dec = pic->linesize[0];
int row_ptr = (avctx->height - 1) * row_dec;
int frame_size = row_dec * avctx->height;
@@ -70,39 +70,37 @@ static int msrle_decode_pal4(AVCodecContext *avctx, AVPicture *pic,
pixel_ptr += stream_byte;
FETCH_NEXT_STREAM_BYTE();
row_ptr -= stream_byte * row_dec;
- } else {
- // copy pixels from encoded stream
- odd_pixel = stream_byte & 1;
- rle_code = (stream_byte + 1) / 2;
- extra_byte = rle_code & 0x01;
- if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
- (row_ptr < 0)) {
- av_log(avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n");
- return -1;
- }
+ } else {
+ // copy pixels from encoded stream
+ odd_pixel = stream_byte & 1;
+ rle_code = (stream_byte + 1) / 2;
+ extra_byte = rle_code & 0x01;
+ if (row_ptr + pixel_ptr + stream_byte > frame_size) {
+ av_log(avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n");
+ return -1;
+ }
- for (i = 0; i < rle_code; i++) {
- if (pixel_ptr >= avctx->width)
- break;
- FETCH_NEXT_STREAM_BYTE();
- pic->data[0][row_ptr + pixel_ptr] = stream_byte >> 4;
- pixel_ptr++;
- if (i + 1 == rle_code && odd_pixel)
- break;
- if (pixel_ptr >= avctx->width)
- break;
- pic->data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F;
- pixel_ptr++;
- }
+ for (i = 0; i < rle_code; i++) {
+ if (pixel_ptr >= avctx->width)
+ break;
+ FETCH_NEXT_STREAM_BYTE();
+ pic->data[0][row_ptr + pixel_ptr] = stream_byte >> 4;
+ pixel_ptr++;
+ if (i + 1 == rle_code && odd_pixel)
+ break;
+ if (pixel_ptr >= avctx->width)
+ break;
+ pic->data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F;
+ pixel_ptr++;
+ }
- // if the RLE code is odd, skip a byte in the stream
- if (extra_byte)
- stream_ptr++;
+ // if the RLE code is odd, skip a byte in the stream
+ if (extra_byte)
+ stream_ptr++;
}
} else {
// decode a run of data
- if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
- (row_ptr < 0)) {
+ if (row_ptr + pixel_ptr + stream_byte > frame_size) {
av_log(avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n");
return -1;
}
@@ -138,6 +136,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
int p1, p2, line=avctx->height - 1, pos=0, i;
uint16_t av_uninit(pix16);
uint32_t av_uninit(pix32);
+ unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3);
output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
output_end = pic->data[0] + (avctx->height) * pic->linesize[0];
@@ -159,11 +158,11 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
p1 = *src++;
p2 = *src++;
line -= p2;
- if (line < 0){
+ pos += p1;
+ if (line < 0 || pos >= width){
av_log(avctx, AV_LOG_ERROR, "Skip beyond picture bounds\n");
return -1;
}
- pos += p1;
output = pic->data[0] + line * pic->linesize[0] + pos * (depth >> 3);
continue;
}
diff --git a/lib/ffmpeg/libavcodec/msvideo1.c b/lib/ffmpeg/libavcodec/msvideo1.c
index 30aca3954e..d40304df3a 100644
--- a/lib/ffmpeg/libavcodec/msvideo1.c
+++ b/lib/ffmpeg/libavcodec/msvideo1.c
@@ -331,7 +331,7 @@ static av_cold int msvideo1_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec msvideo1_decoder = {
+AVCodec ff_msvideo1_decoder = {
"msvideo1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_MSVIDEO1,
diff --git a/lib/ffmpeg/libavcodec/nellymoserdec.c b/lib/ffmpeg/libavcodec/nellymoserdec.c
index 8976467f61..80e04ee0a2 100644
--- a/lib/ffmpeg/libavcodec/nellymoserdec.c
+++ b/lib/ffmpeg/libavcodec/nellymoserdec.c
@@ -34,9 +34,11 @@
#include "nellymoser.h"
#include "libavutil/lfg.h"
#include "libavutil/random_seed.h"
+#include "libavcore/audioconvert.h"
#include "avcodec.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
@@ -48,10 +50,10 @@ typedef struct NellyMoserDecodeContext {
float state[128];
AVLFG random_state;
GetBitContext gb;
- int add_bias;
float scale_bias;
DSPContext dsp;
FFTContext imdct_ctx;
+ FmtConvertContext fmt_conv;
DECLARE_ALIGNED(16, float,imdct_out)[NELLY_BUF_LEN * 2];
} NellyMoserDecodeContext;
@@ -64,7 +66,7 @@ static void overlap_and_window(NellyMoserDecodeContext *s, float *state, float *
while (bot < NELLY_BUF_LEN) {
audio[bot] = a_in [bot]*ff_sine_128[bot]
- +state[bot]*ff_sine_128[top] + s->add_bias;
+ +state[bot]*ff_sine_128[top];
bot++;
top--;
@@ -134,21 +136,16 @@ static av_cold int decode_init(AVCodecContext * avctx) {
ff_mdct_init(&s->imdct_ctx, 8, 1, 1.0);
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
- if(s->dsp.float_to_int16 == ff_float_to_int16_c) {
- s->add_bias = 385;
- s->scale_bias = 1.0/(8*32768);
- } else {
- s->add_bias = 0;
- s->scale_bias = 1.0/(1*8);
- }
+ s->scale_bias = 1.0/(1*8);
/* Generate overlap window */
if (!ff_sine_128[127])
ff_init_ff_sine_windows(7);
- avctx->sample_fmt = SAMPLE_FMT_S16;
- avctx->channel_layout = CH_LAYOUT_MONO;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ avctx->channel_layout = AV_CH_LAYOUT_MONO;
return 0;
}
@@ -181,7 +178,7 @@ static int decode_tag(AVCodecContext * avctx,
for (i=0 ; i<blocks ; i++) {
nelly_decode_block(s, &buf[i*NELLY_BLOCK_LEN], s->float_buf);
- s->dsp.float_to_int16(&samples[i*NELLY_SAMPLES], s->float_buf, NELLY_SAMPLES);
+ s->fmt_conv.float_to_int16(&samples[i*NELLY_SAMPLES], s->float_buf, NELLY_SAMPLES);
*data_size += NELLY_SAMPLES*sizeof(int16_t);
}
@@ -195,7 +192,7 @@ static av_cold int decode_end(AVCodecContext * avctx) {
return 0;
}
-AVCodec nellymoser_decoder = {
+AVCodec ff_nellymoser_decoder = {
"nellymoser",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_NELLYMOSER,
diff --git a/lib/ffmpeg/libavcodec/nellymoserenc.c b/lib/ffmpeg/libavcodec/nellymoserenc.c
index 1f9442cf9d..9b792ff2ac 100644
--- a/lib/ffmpeg/libavcodec/nellymoserenc.c
+++ b/lib/ffmpeg/libavcodec/nellymoserenc.c
@@ -113,13 +113,13 @@ static const uint8_t quant_lut_offset[8] = { 0, 0, 1, 4, 11, 32, 81, 230 };
static void apply_mdct(NellyMoserEncodeContext *s)
{
- memcpy(s->in_buff, s->buf[s->bufsel], NELLY_BUF_LEN * sizeof(float));
- s->dsp.vector_fmul(s->in_buff, ff_sine_128, NELLY_BUF_LEN);
+ s->dsp.vector_fmul(s->in_buff, s->buf[s->bufsel], ff_sine_128, NELLY_BUF_LEN);
s->dsp.vector_fmul_reverse(s->in_buff + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN, ff_sine_128,
NELLY_BUF_LEN);
ff_mdct_calc(&s->mdct_ctx, s->mdct_out, s->in_buff);
- s->dsp.vector_fmul(s->buf[s->bufsel] + NELLY_BUF_LEN, ff_sine_128, NELLY_BUF_LEN);
+ s->dsp.vector_fmul(s->buf[s->bufsel] + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN,
+ ff_sine_128, NELLY_BUF_LEN);
s->dsp.vector_fmul_reverse(s->buf[s->bufsel] + 2 * NELLY_BUF_LEN, s->buf[1 - s->bufsel], ff_sine_128,
NELLY_BUF_LEN);
ff_mdct_calc(&s->mdct_ctx, s->mdct_out + NELLY_BUF_LEN, s->buf[s->bufsel] + NELLY_BUF_LEN);
@@ -351,7 +351,7 @@ static void encode_block(NellyMoserEncodeContext *s, unsigned char *output, int
static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data)
{
NellyMoserEncodeContext *s = avctx->priv_data;
- int16_t *samples = data;
+ const int16_t *samples = data;
int i;
if (s->last_frame)
@@ -382,7 +382,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, voi
return 0;
}
-AVCodec nellymoser_encoder = {
+AVCodec ff_nellymoser_encoder = {
.name = "nellymoser",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_NELLYMOSER,
@@ -392,4 +392,5 @@ AVCodec nellymoser_encoder = {
.close = encode_end,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
};
diff --git a/lib/ffmpeg/libavcodec/noise_bsf.c b/lib/ffmpeg/libavcodec/noise_bsf.c
index c49dd1f9d9..491fbccc1d 100644
--- a/lib/ffmpeg/libavcodec/noise_bsf.c
+++ b/lib/ffmpeg/libavcodec/noise_bsf.c
@@ -39,7 +39,7 @@ static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const ch
return 1;
}
-AVBitStreamFilter noise_bsf={
+AVBitStreamFilter ff_noise_bsf={
"noise",
sizeof(int),
noise,
diff --git a/lib/ffmpeg/libavcodec/nuv.c b/lib/ffmpeg/libavcodec/nuv.c
index 791f450913..d53d4578ba 100644
--- a/lib/ffmpeg/libavcodec/nuv.c
+++ b/lib/ffmpeg/libavcodec/nuv.c
@@ -23,6 +23,7 @@
#include "libavutil/bswap.h"
#include "libavutil/lzo.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "rtjpeg.h"
@@ -111,12 +112,11 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit
if (quality >= 0)
get_quant_quality(c, quality);
if (width != c->width || height != c->height) {
- if (avcodec_check_dimensions(avctx, height, width) < 0)
+ if (av_image_check_size(height, width, 0, avctx) < 0)
return 0;
avctx->width = c->width = width;
avctx->height = c->height = height;
- c->decomp_size = c->height * c->width * 3 / 2;
- c->decomp_buf = av_realloc(c->decomp_buf, c->decomp_size + AV_LZO_OUTPUT_PADDING);
+ av_fast_malloc(&c->decomp_buf, &c->decomp_size, c->height * c->width * 3 / 2);
if (!c->decomp_buf) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
return 0;
@@ -272,7 +272,7 @@ static av_cold int decode_end(AVCodecContext *avctx) {
return 0;
}
-AVCodec nuv_decoder = {
+AVCodec ff_nuv_decoder = {
"nuv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_NUV,
diff --git a/lib/ffmpeg/libavcodec/opt.c b/lib/ffmpeg/libavcodec/opt.c
index 128d95d1ce..ffa422ec93 100644
--- a/lib/ffmpeg/libavcodec/opt.c
+++ b/lib/ffmpeg/libavcodec/opt.c
@@ -1,6 +1,6 @@
/*
- * AVOptions
- * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
+ * AVOptions ABI compatibility wrapper
+ * Copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
@@ -19,187 +19,53 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/**
- * @file
- * AVOptions
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
#include "avcodec.h"
#include "opt.h"
-#include "libavutil/eval.h"
-//FIXME order them and do a bin search
-const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags){
- AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
- const AVOption *o= c->option;
+#if LIBAVCODEC_VERSION_MAJOR < 53 && CONFIG_SHARED && HAVE_SYMVER
- for(;o && o->name; o++){
- if(!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags )
- return o;
- }
- return NULL;
+FF_SYMVER(const AVOption *, av_find_opt, (void *obj, const char *name, const char *unit, int mask, int flags), "LIBAVCODEC_52"){
+ return av_find_opt(obj, name, unit, mask, flags);
}
-
-const AVOption *av_next_option(void *obj, const AVOption *last){
- if(last && last[1].name) return ++last;
- else if(last) return NULL;
- else return (*(AVClass**)obj)->option;
+FF_SYMVER(int, av_set_string3, (void *obj, const char *name, const char *val, int alloc, const AVOption **o_out), "LIBAVCODEC_52"){
+ return av_set_string3(obj, name, val, alloc, o_out);
}
-
-static int av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const AVOption **o_out){
- const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
- void *dst;
- if(o_out)
- *o_out= o;
- if(!o || o->offset<=0)
- return AVERROR(ENOENT);
-
- if(o->max*den < num*intnum || o->min*den > num*intnum) {
- av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name);
- return AVERROR(ERANGE);
- }
-
- dst= ((uint8_t*)obj) + o->offset;
-
- switch(o->type){
- case FF_OPT_TYPE_FLAGS:
- case FF_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
- case FF_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break;
- case FF_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break;
- case FF_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break;
- case FF_OPT_TYPE_RATIONAL:
- if((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
- else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
- break;
- default:
- return AVERROR(EINVAL);
- }
- return 0;
+FF_SYMVER(const AVOption *, av_set_double, (void *obj, const char *name, double n), "LIBAVCODEC_52"){
+ return av_set_double(obj, name, n);
}
-
-static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
- const AVOption *o = NULL;
- if (av_set_number2(obj, name, num, den, intnum, &o) < 0)
- return NULL;
- else
- return o;
+FF_SYMVER(const AVOption *, av_set_q, (void *obj, const char *name, AVRational n), "LIBAVCODEC_52"){
+ return av_set_q(obj, name, n);
}
-
-static const double const_values[]={
- M_PI,
- M_E,
- FF_QP2LAMBDA,
- 0
-};
-
-static const char * const const_names[]={
- "PI",
- "E",
- "QP2LAMBDA",
- 0
-};
-
-static int hexchar2int(char c) {
- if (c >= '0' && c <= '9') return c - '0';
- if (c >= 'a' && c <= 'f') return c - 'a' + 10;
- if (c >= 'A' && c <= 'F') return c - 'A' + 10;
- return -1;
+FF_SYMVER(const AVOption *, av_set_int, (void *obj, const char *name, int64_t n), "LIBAVCODEC_52"){
+ return av_set_int(obj, name, n);
}
-
-int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out){
- int ret;
- const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
- if (o_out)
- *o_out = o;
- if(!o)
- return AVERROR(ENOENT);
- if(!val || o->offset<=0)
- return AVERROR(EINVAL);
-
- if(o->type == FF_OPT_TYPE_BINARY){
- uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset);
- int *lendst = (int *)(dst + 1);
- uint8_t *bin, *ptr;
- int len = strlen(val);
- av_freep(dst);
- *lendst = 0;
- if (len & 1) return AVERROR(EINVAL);
- len /= 2;
- ptr = bin = av_malloc(len);
- while (*val) {
- int a = hexchar2int(*val++);
- int b = hexchar2int(*val++);
- if (a < 0 || b < 0) {
- av_free(bin);
- return AVERROR(EINVAL);
- }
- *ptr++ = (a << 4) | b;
- }
- *dst = bin;
- *lendst = len;
- return 0;
- }
- if(o->type != FF_OPT_TYPE_STRING){
- int notfirst=0;
- for(;;){
- int i;
- char buf[256];
- int cmd=0;
- double d;
-
- if(*val == '+' || *val == '-')
- cmd= *(val++);
-
- for(i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+' && val[i]!='-'; i++)
- buf[i]= val[i];
- buf[i]=0;
-
- {
- const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0);
- if(o_named && o_named->type == FF_OPT_TYPE_CONST)
- d= o_named->default_val;
- else if(!strcmp(buf, "default")) d= o->default_val;
- else if(!strcmp(buf, "max" )) d= o->max;
- else if(!strcmp(buf, "min" )) d= o->min;
- else if(!strcmp(buf, "none" )) d= 0;
- else if(!strcmp(buf, "all" )) d= ~0;
- else {
- int res = av_parse_and_eval_expr(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
- if (res < 0) {
- av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
- return res;
- }
- }
- }
- if(o->type == FF_OPT_TYPE_FLAGS){
- if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;
- else if(cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d;
- }else{
- if (cmd=='+') d= notfirst*av_get_double(obj, name, NULL) + d;
- else if(cmd=='-') d= notfirst*av_get_double(obj, name, NULL) - d;
- }
-
- if ((ret = av_set_number2(obj, name, d, 1, 1, o_out)) < 0)
- return ret;
- val+= i;
- if(!*val)
- return 0;
- notfirst=1;
- }
- return AVERROR(EINVAL);
- }
-
- if(alloc){
- av_free(*(void**)(((uint8_t*)obj) + o->offset));
- val= av_strdup(val);
- }
-
- memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val));
- return 0;
+FF_SYMVER(double, av_get_double, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){
+ return av_get_double(obj, name, o_out);
+}
+FF_SYMVER(AVRational, av_get_q, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){
+ return av_get_q(obj, name, o_out);
+}
+FF_SYMVER(int64_t, av_get_int, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){
+ return av_get_int(obj, name, o_out);
+}
+FF_SYMVER(const char *, av_get_string, (void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len), "LIBAVCODEC_52"){
+ return av_get_string(obj, name, o_out, buf, buf_len);
+}
+FF_SYMVER(const AVOption *, av_next_option, (void *obj, const AVOption *last), "LIBAVCODEC_52"){
+ return av_next_option(obj, last);
}
+FF_SYMVER(int, av_opt_show2, (void *obj, void *av_log_obj, int req_flags, int rej_flags), "LIBAVCODEC_52"){
+ return av_opt_show2(obj, av_log_obj, req_flags, rej_flags);
+}
+FF_SYMVER(void, av_opt_set_defaults, (void *s), "LIBAVCODEC_52"){
+ return av_opt_set_defaults(s);
+}
+FF_SYMVER(void, av_opt_set_defaults2, (void *s, int mask, int flags), "LIBAVCODEC_52"){
+ return av_opt_set_defaults2(s, mask, flags);
+}
+#endif
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_SET_STRING_OLD
const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc){
const AVOption *o;
if (av_set_string3(obj, name, val, alloc, &o) < 0)
@@ -215,241 +81,9 @@ const AVOption *av_set_string(void *obj, const char *name, const char *val){
}
#endif
-const AVOption *av_set_double(void *obj, const char *name, double n){
- return av_set_number(obj, name, n, 1, 1);
-}
-
-const AVOption *av_set_q(void *obj, const char *name, AVRational n){
- return av_set_number(obj, name, n.num, n.den, 1);
-}
-
-const AVOption *av_set_int(void *obj, const char *name, int64_t n){
- return av_set_number(obj, name, 1, 1, n);
-}
-
-/**
- *
- * @param buf a buffer which is used for returning non string values as strings, can be NULL
- * @param buf_len allocated length in bytes of buf
- */
-const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
- const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
- void *dst;
- uint8_t *bin;
- int len, i;
- if(!o || o->offset<=0)
- return NULL;
- if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
- return NULL;
-
- dst= ((uint8_t*)obj) + o->offset;
- if(o_out) *o_out= o;
-
- switch(o->type){
- case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
- case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
- case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
- case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
- case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
- case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
- case FF_OPT_TYPE_STRING: return *(void**)dst;
- case FF_OPT_TYPE_BINARY:
- len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
- if(len >= (buf_len + 1)/2) return NULL;
- bin = *(uint8_t**)dst;
- for(i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]);
- break;
- default: return NULL;
- }
- return buf;
-}
-
-static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum){
- const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
- void *dst;
- if(!o || o->offset<=0)
- goto error;
-
- dst= ((uint8_t*)obj) + o->offset;
-
- if(o_out) *o_out= o;
-
- switch(o->type){
- case FF_OPT_TYPE_FLAGS: *intnum= *(unsigned int*)dst;return 0;
- case FF_OPT_TYPE_INT: *intnum= *(int *)dst;return 0;
- case FF_OPT_TYPE_INT64: *intnum= *(int64_t*)dst;return 0;
- case FF_OPT_TYPE_FLOAT: *num= *(float *)dst;return 0;
- case FF_OPT_TYPE_DOUBLE: *num= *(double *)dst;return 0;
- case FF_OPT_TYPE_RATIONAL: *intnum= ((AVRational*)dst)->num;
- *den = ((AVRational*)dst)->den;
- return 0;
- }
-error:
- *den=*intnum=0;
- return -1;
-}
-
-double av_get_double(void *obj, const char *name, const AVOption **o_out){
- int64_t intnum=1;
- double num=1;
- int den=1;
-
- av_get_number(obj, name, o_out, &num, &den, &intnum);
- return num*intnum/den;
-}
-
-AVRational av_get_q(void *obj, const char *name, const AVOption **o_out){
- int64_t intnum=1;
- double num=1;
- int den=1;
-
- av_get_number(obj, name, o_out, &num, &den, &intnum);
- if(num == 1.0 && (int)intnum == intnum)
- return (AVRational){intnum, den};
- else
- return av_d2q(num*intnum/den, 1<<24);
-}
-
-int64_t av_get_int(void *obj, const char *name, const AVOption **o_out){
- int64_t intnum=1;
- double num=1;
- int den=1;
-
- av_get_number(obj, name, o_out, &num, &den, &intnum);
- return num*intnum/den;
-}
-
-static void opt_list(void *obj, void *av_log_obj, const char *unit)
-{
- const AVOption *opt=NULL;
-
- while((opt= av_next_option(obj, opt))){
- if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM)))
- continue;
-
- /* Don't print CONST's on level one.
- * Don't print anything but CONST's on level two.
- * Only print items from the requested unit.
- */
- if (!unit && opt->type==FF_OPT_TYPE_CONST)
- continue;
- else if (unit && opt->type!=FF_OPT_TYPE_CONST)
- continue;
- else if (unit && opt->type==FF_OPT_TYPE_CONST && strcmp(unit, opt->unit))
- continue;
- else if (unit && opt->type == FF_OPT_TYPE_CONST)
- av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name);
- else
- av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name);
-
- switch( opt->type )
- {
- case FF_OPT_TYPE_FLAGS:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<flags>" );
- break;
- case FF_OPT_TYPE_INT:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<int>" );
- break;
- case FF_OPT_TYPE_INT64:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<int64>" );
- break;
- case FF_OPT_TYPE_DOUBLE:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<double>" );
- break;
- case FF_OPT_TYPE_FLOAT:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<float>" );
- break;
- case FF_OPT_TYPE_STRING:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<string>" );
- break;
- case FF_OPT_TYPE_RATIONAL:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<rational>" );
- break;
- case FF_OPT_TYPE_BINARY:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "<binary>" );
- break;
- case FF_OPT_TYPE_CONST:
- default:
- av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "" );
- break;
- }
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
-
- if(opt->help)
- av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
- av_log(av_log_obj, AV_LOG_INFO, "\n");
- if (opt->unit && opt->type != FF_OPT_TYPE_CONST) {
- opt_list(obj, av_log_obj, opt->unit);
- }
- }
-}
-
+#if FF_API_OPT_SHOW
int av_opt_show(void *obj, void *av_log_obj){
- if(!obj)
- return -1;
-
- av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
-
- opt_list(obj, av_log_obj, NULL);
-
- return 0;
-}
-
-/** Set the values of the AVCodecContext or AVFormatContext structure.
- * They are set to the defaults specified in the according AVOption options
- * array default_val field.
- *
- * @param s AVCodecContext or AVFormatContext for which the defaults will be set
- */
-void av_opt_set_defaults2(void *s, int mask, int flags)
-{
- const AVOption *opt = NULL;
- while ((opt = av_next_option(s, opt)) != NULL) {
- if((opt->flags & mask) != flags)
- continue;
- switch(opt->type) {
- case FF_OPT_TYPE_CONST:
- /* Nothing to be done here */
- break;
- case FF_OPT_TYPE_FLAGS:
- case FF_OPT_TYPE_INT: {
- int val;
- val = opt->default_val;
- av_set_int(s, opt->name, val);
- }
- break;
- case FF_OPT_TYPE_INT64:
- if((double)(opt->default_val+0.6) == opt->default_val)
- av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name);
- av_set_int(s, opt->name, opt->default_val);
- break;
- case FF_OPT_TYPE_FLOAT: {
- double val;
- val = opt->default_val;
- av_set_double(s, opt->name, val);
- }
- break;
- case FF_OPT_TYPE_RATIONAL: {
- AVRational val;
- val = av_d2q(opt->default_val, INT_MAX);
- av_set_q(s, opt->name, val);
- }
- break;
- case FF_OPT_TYPE_STRING:
- case FF_OPT_TYPE_BINARY:
- /* Cannot set default for string as default_val is of type * double */
- break;
- default:
- av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
- }
- }
+ return av_opt_show2(obj, av_log_obj,
+ AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0);
}
-
-void av_opt_set_defaults(void *s){
- av_opt_set_defaults2(s, 0, 0);
-}
-
+#endif
diff --git a/lib/ffmpeg/libavcodec/opt.h b/lib/ffmpeg/libavcodec/opt.h
index 9f0da7296f..95147595b7 100644
--- a/lib/ffmpeg/libavcodec/opt.h
+++ b/lib/ffmpeg/libavcodec/opt.h
@@ -29,130 +29,9 @@
#include "libavutil/rational.h"
#include "avcodec.h"
+#include "libavutil/opt.h"
-enum AVOptionType{
- FF_OPT_TYPE_FLAGS,
- FF_OPT_TYPE_INT,
- FF_OPT_TYPE_INT64,
- FF_OPT_TYPE_DOUBLE,
- FF_OPT_TYPE_FLOAT,
- FF_OPT_TYPE_STRING,
- FF_OPT_TYPE_RATIONAL,
- FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
- FF_OPT_TYPE_CONST=128,
-};
-
-/**
- * AVOption
- */
-typedef struct AVOption {
- const char *name;
-
- /**
- * short English help text
- * @todo What about other languages?
- */
- const char *help;
-
- /**
- * The offset relative to the context structure where the option
- * value is stored. It should be 0 for named constants.
- */
- int offset;
- enum AVOptionType type;
-
- /**
- * the default value for scalar options
- */
- double default_val;
- double min; ///< minimum valid value for the option
- double max; ///< maximum valid value for the option
-
- int flags;
-#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
-#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
-#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
-#define AV_OPT_FLAG_AUDIO_PARAM 8
-#define AV_OPT_FLAG_VIDEO_PARAM 16
-#define AV_OPT_FLAG_SUBTITLE_PARAM 32
-//FIXME think about enc-audio, ... style flags
-
- /**
- * The logical unit to which the option belongs. Non-constant
- * options and corresponding named constants share the same
- * unit. May be NULL.
- */
- const char *unit;
-} AVOption;
-
-/**
- * AVOption2.
- * THIS IS NOT PART OF THE API/ABI YET!
- * This is identical to AVOption except that default_val was replaced by
- * an union, it should be compatible with AVOption on normal platforms.
- */
-typedef struct AVOption2 {
- const char *name;
-
- /**
- * short English help text
- * @todo What about other languages?
- */
- const char *help;
-
- /**
- * The offset relative to the context structure where the option
- * value is stored. It should be 0 for named constants.
- */
- int offset;
- enum AVOptionType type;
-
- /**
- * the default value for scalar options
- */
- union {
- double dbl;
- const char *str;
- } default_val;
-
- double min; ///< minimum valid value for the option
- double max; ///< maximum valid value for the option
-
- int flags;
-/*
-#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
-#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
-#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
-#define AV_OPT_FLAG_AUDIO_PARAM 8
-#define AV_OPT_FLAG_VIDEO_PARAM 16
-#define AV_OPT_FLAG_SUBTITLE_PARAM 32
-*/
-//FIXME think about enc-audio, ... style flags
-
- /**
- * The logical unit to which the option belongs. Non-constant
- * options and corresponding named constants share the same
- * unit. May be NULL.
- */
- const char *unit;
-} AVOption2;
-
-
-/**
- * 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).
- *
- * @param[in] obj a pointer to a struct whose first element is a
- * pointer to an AVClass
- * @param[in] name the name of the option to look for
- * @param[in] unit the unit of the option to look for, or any if NULL
- * @return a pointer to the option found, or NULL if no option
- * has been found
- */
-const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
-
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_SET_STRING_OLD
/**
* @see av_set_string2()
*/
@@ -166,46 +45,11 @@ attribute_deprecated const AVOption *av_set_string(void *obj, const char *name,
*/
attribute_deprecated const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc);
#endif
-
+#if FF_API_OPT_SHOW
/**
- * 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.
- * @param[in] name the name of the field to set
- * @param[in] val The value to set. If the field is not of a string
- * type, then the given string is parsed.
- * SI postfixes and some named scalars are supported.
- * If the field is of a numeric type, it has to be a numeric or named
- * scalar. Behavior with more than one scalar and +- infix operators
- * is undefined.
- * If the field is of a flags type, it has to be a sequence of numeric
- * scalars or named flags separated by '+' or '-'. Prefixing a flag
- * with '+' causes it to be set without affecting the other flags;
- * similarly, '-' unsets a flag.
- * @param[out] o_out if non-NULL put here a pointer to the AVOption
- * found
- * @param alloc when 1 then the old value will be av_freed() and the
- * new av_strduped()
- * when 0 then no av_free() nor av_strdup() will be used
- * @return 0 if the value has been set, or an AVERROR code in case of
- * error:
- * AVERROR(ENOENT) if no matching option exists
- * AVERROR(ERANGE) if the value is out of range
- * AVERROR(EINVAL) if the value is not valid
+ * @deprecated Use av_opt_show2() instead.
*/
-int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
-
-const AVOption *av_set_double(void *obj, const char *name, double n);
-const AVOption *av_set_q(void *obj, const char *name, AVRational n);
-const AVOption *av_set_int(void *obj, const char *name, int64_t n);
-double av_get_double(void *obj, const char *name, const AVOption **o_out);
-AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
-int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
-const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
-const AVOption *av_next_option(void *obj, const AVOption *last);
-int av_opt_show(void *obj, void *av_log_obj);
-void av_opt_set_defaults(void *s);
-void av_opt_set_defaults2(void *s, int mask, int flags);
+attribute_deprecated int av_opt_show(void *obj, void *av_log_obj);
+#endif
#endif /* AVCODEC_OPT_H */
diff --git a/lib/ffmpeg/libavcodec/options.c b/lib/ffmpeg/libavcodec/options.c
index c59e92bffa..369ee5d334 100644
--- a/lib/ffmpeg/libavcodec/options.c
+++ b/lib/ffmpeg/libavcodec/options.c
@@ -25,7 +25,7 @@
*/
#include "avcodec.h"
-#include "opt.h"
+#include "libavutil/opt.h"
#include <float.h> /* FLT_MIN, FLT_MAX */
static const char* context_to_name(void* ptr) {
@@ -160,7 +160,7 @@ 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"},
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_INOFFICIAL
{"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"},
@@ -273,7 +273,7 @@ static const AVOption options[]={
{"rd", "rate distortion optimal, slow", 0, FF_OPT_TYPE_CONST, FF_CMP_RD, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"zero", "0", 0, FF_OPT_TYPE_CONST, FF_CMP_ZERO, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"vsad", "sum of absolute vertical differences", 0, FF_OPT_TYPE_CONST, FF_CMP_VSAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsse","sum of squared vertical differences", 0, FF_OPT_TYPE_CONST, FF_CMP_VSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"vsse", "sum of squared vertical differences", 0, FF_OPT_TYPE_CONST, FF_CMP_VSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"nsse", "noise preserving sum of squared differences", 0, FF_OPT_TYPE_CONST, FF_CMP_NSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
#if CONFIG_SNOW_ENCODER
{"w53", "5/3 wavelet, only used in snow", 0, FF_OPT_TYPE_CONST, FF_CMP_W53, INT_MIN, INT_MAX, V|E, "cmp_func"},
@@ -338,7 +338,7 @@ static const AVOption options[]={
{"dts_hd_ma", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_DTS_HD_MA, INT_MIN, INT_MAX, A|E, "profile"},
{"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
-{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|D},
+{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|A|D},
{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
@@ -387,7 +387,7 @@ 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
+#if FF_API_USE_LPC
{"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},
@@ -430,6 +430,7 @@ static const AVOption options[]={
{"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},
+{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
{NULL},
};
@@ -465,13 +466,43 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_typ
s->execute2= avcodec_default_execute2;
s->sample_aspect_ratio= (AVRational){0,1};
s->pix_fmt= PIX_FMT_NONE;
- s->sample_fmt= SAMPLE_FMT_NONE;
+ s->sample_fmt= AV_SAMPLE_FMT_NONE;
s->palctrl = NULL;
s->reget_buffer= avcodec_default_reget_buffer;
s->reordered_opaque= AV_NOPTS_VALUE;
}
+int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
+ avcodec_get_context_defaults2(s, codec ? codec->type : AVMEDIA_TYPE_UNKNOWN);
+ if(codec && codec->priv_data_size){
+ if(!s->priv_data){
+ s->priv_data= av_mallocz(codec->priv_data_size);
+ if (!s->priv_data) {
+ return AVERROR(ENOMEM);
+ }
+ }
+ if(codec->priv_class){
+ *(AVClass**)s->priv_data= codec->priv_class;
+ av_opt_set_defaults(s->priv_data);
+ }
+ }
+ return 0;
+}
+
+AVCodecContext *avcodec_alloc_context3(AVCodec *codec){
+ AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
+
+ if(avctx==NULL) return NULL;
+
+ if(avcodec_get_context_defaults3(avctx, codec) < 0){
+ av_free(avctx);
+ return NULL;
+ }
+
+ return avctx;
+}
+
AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
diff --git a/lib/ffmpeg/libavcodec/pamenc.c b/lib/ffmpeg/libavcodec/pamenc.c
index ae0ea3a102..9f50d7fbfa 100644
--- a/lib/ffmpeg/libavcodec/pamenc.c
+++ b/lib/ffmpeg/libavcodec/pamenc.c
@@ -108,7 +108,7 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
}
-AVCodec pam_encoder = {
+AVCodec ff_pam_encoder = {
"pam",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PAM,
diff --git a/lib/ffmpeg/libavcodec/parser.c b/lib/ffmpeg/libavcodec/parser.c
index 1aa86515d8..d877f5d411 100644
--- a/lib/ffmpeg/libavcodec/parser.c
+++ b/lib/ffmpeg/libavcodec/parser.c
@@ -150,6 +150,12 @@ int av_parser_parse2(AVCodecParserContext *s,
int index, i;
uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
+ if(!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
+ s->next_frame_offset =
+ s->cur_offset = pos;
+ s->flags |= PARSER_FLAG_FETCHED_OFFSET;
+ }
+
if (buf_size == 0) {
/* padding is always necessary even if EOF, so we add it here */
memset(dummy_buf, 0, sizeof(dummy_buf));
diff --git a/lib/ffmpeg/libavcodec/pcm-mpeg.c b/lib/ffmpeg/libavcodec/pcm-mpeg.c
index c2343a69b0..189b2b5691 100644
--- a/lib/ffmpeg/libavcodec/pcm-mpeg.c
+++ b/lib/ffmpeg/libavcodec/pcm-mpeg.c
@@ -24,6 +24,7 @@
* PCM codecs for encodings found in MPEG streams (DVD/Blu-ray)
*/
+#include "libavcore/audioconvert.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -53,9 +54,9 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
{
static const uint8_t bits_per_samples[4] = { 0, 16, 20, 24 };
static const uint32_t channel_layouts[16] = {
- 0, CH_LAYOUT_MONO, 0, CH_LAYOUT_STEREO, CH_LAYOUT_SURROUND,
- CH_LAYOUT_2_1, CH_LAYOUT_4POINT0, CH_LAYOUT_2_2, CH_LAYOUT_5POINT0,
- CH_LAYOUT_5POINT1, CH_LAYOUT_7POINT0, CH_LAYOUT_7POINT1, 0, 0, 0, 0
+ 0, AV_CH_LAYOUT_MONO, 0, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_2_1, AV_CH_LAYOUT_4POINT0, AV_CH_LAYOUT_2_2, AV_CH_LAYOUT_5POINT0,
+ AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_7POINT0, AV_CH_LAYOUT_7POINT1, 0, 0, 0, 0
};
static const uint8_t channels[16] = {
0, 1, 0, 2, 3, 3, 4, 4, 5, 6, 7, 8, 0, 0, 0, 0
@@ -63,7 +64,7 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
uint8_t channel_layout = header[2] >> 4;
if (avctx->debug & FF_DEBUG_PICT_INFO)
- dprintf(avctx, "pcm_bluray_parse_header: header = %02x%02x%02x%02x\n",
+ av_dlog(avctx, "pcm_bluray_parse_header: header = %02x%02x%02x%02x\n",
header[0], header[1], header[2], header[3]);
/* get the sample depth and derive the sample format from it */
@@ -72,8 +73,8 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "unsupported sample depth (0)\n");
return -1;
}
- avctx->sample_fmt = avctx->bits_per_coded_sample == 16 ? SAMPLE_FMT_S16 :
- SAMPLE_FMT_S32;
+ avctx->sample_fmt = avctx->bits_per_coded_sample == 16 ? AV_SAMPLE_FMT_S16 :
+ AV_SAMPLE_FMT_S32;
/* get the sample rate. Not all values are known or exist. */
switch (header[2] & 0x0f) {
@@ -111,7 +112,7 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx,
avctx->bits_per_coded_sample;
if (avctx->debug & FF_DEBUG_PICT_INFO)
- dprintf(avctx,
+ av_dlog(avctx,
"pcm_bluray_parse_header: %d channels, %d bits per sample, %d kHz, %d kbit\n",
avctx->channels, avctx->bits_per_coded_sample,
avctx->sample_rate, avctx->bit_rate);
@@ -146,7 +147,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
samples = buf_size / sample_size;
output_size = samples * avctx->channels *
- (avctx->sample_fmt == SAMPLE_FMT_S32 ? 4 : 2);
+ (avctx->sample_fmt == AV_SAMPLE_FMT_S32 ? 4 : 2);
if (output_size > *data_size) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient output buffer space (%d bytes, needed %d bytes)\n",
@@ -158,11 +159,11 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
if (samples) {
switch (avctx->channel_layout) {
/* cases with same number of source and coded channels */
- case CH_LAYOUT_STEREO:
- case CH_LAYOUT_4POINT0:
- case CH_LAYOUT_2_2:
+ case AV_CH_LAYOUT_STEREO:
+ case AV_CH_LAYOUT_4POINT0:
+ case AV_CH_LAYOUT_2_2:
samples *= num_source_channels;
- if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
+ if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
#if HAVE_BIGENDIAN
memcpy(dst16, src, output_size);
#else
@@ -177,11 +178,11 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
}
break;
/* cases where number of source channels = coded channels + 1 */
- case CH_LAYOUT_MONO:
- case CH_LAYOUT_SURROUND:
- case CH_LAYOUT_2_1:
- case CH_LAYOUT_5POINT0:
- if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
+ case AV_CH_LAYOUT_MONO:
+ case AV_CH_LAYOUT_SURROUND:
+ case AV_CH_LAYOUT_2_1:
+ case AV_CH_LAYOUT_5POINT0:
+ if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
#if HAVE_BIGENDIAN
memcpy(dst16, src, avctx->channels * 2);
@@ -206,8 +207,8 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
}
break;
/* remapping: L, R, C, LBack, RBack, LF */
- case CH_LAYOUT_5POINT1:
- if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
+ case AV_CH_LAYOUT_5POINT1:
+ if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
dst16[0] = bytestream_get_be16(&src);
dst16[1] = bytestream_get_be16(&src);
@@ -230,8 +231,8 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
}
break;
/* remapping: L, R, C, LSide, LBack, RBack, RSide, <unused> */
- case CH_LAYOUT_7POINT0:
- if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
+ case AV_CH_LAYOUT_7POINT0:
+ if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
dst16[0] = bytestream_get_be16(&src);
dst16[1] = bytestream_get_be16(&src);
@@ -258,8 +259,8 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
}
break;
/* remapping: L, R, C, LSide, LBack, RBack, RSide, LF */
- case CH_LAYOUT_7POINT1:
- if (SAMPLE_FMT_S16 == avctx->sample_fmt) {
+ case AV_CH_LAYOUT_7POINT1:
+ if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
do {
dst16[0] = bytestream_get_be16(&src);
dst16[1] = bytestream_get_be16(&src);
@@ -290,12 +291,12 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx,
retval = src - avpkt->data;
if (avctx->debug & FF_DEBUG_BITSTREAM)
- dprintf(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n",
+ av_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n",
retval, *data_size);
return retval;
}
-AVCodec pcm_bluray_decoder = {
+AVCodec ff_pcm_bluray_decoder = {
"pcm_bluray",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_PCM_BLURAY,
@@ -304,7 +305,7 @@ AVCodec pcm_bluray_decoder = {
NULL,
NULL,
pcm_bluray_decode_frame,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16, SAMPLE_FMT_S32,
- SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
+ AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"),
};
diff --git a/lib/ffmpeg/libavcodec/pcm.c b/lib/ffmpeg/libavcodec/pcm.c
index 4e86154831..0785a9d2ab 100644
--- a/lib/ffmpeg/libavcodec/pcm.c
+++ b/lib/ffmpeg/libavcodec/pcm.c
@@ -81,14 +81,14 @@ static int pcm_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data)
{
int n, sample_size, v;
- short *samples;
+ const short *samples;
unsigned char *dst;
- uint8_t *srcu8;
- int16_t *samples_int16_t;
- int32_t *samples_int32_t;
- int64_t *samples_int64_t;
- uint16_t *samples_uint16_t;
- uint32_t *samples_uint32_t;
+ const uint8_t *srcu8;
+ const int16_t *samples_int16_t;
+ const int32_t *samples_int32_t;
+ const int64_t *samples_int64_t;
+ const uint16_t *samples_uint16_t;
+ const uint32_t *samples_uint32_t;
sample_size = av_get_bits_per_sample(avctx->codec->id)/8;
n = buf_size / sample_size;
@@ -228,7 +228,7 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx)
avctx->sample_fmt = avctx->codec->sample_fmts[0];
- if (avctx->sample_fmt == SAMPLE_FMT_S32)
+ if (avctx->sample_fmt == AV_SAMPLE_FMT_S32)
avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id);
return 0;
@@ -259,7 +259,7 @@ static int pcm_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
- int sample_size, c, n;
+ int sample_size, c, n, i;
short *samples;
const uint8_t *src, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
@@ -288,6 +288,14 @@ static int pcm_decode_frame(AVCodecContext *avctx,
if (CODEC_ID_PCM_DVD == avctx->codec_id)
/* 2 samples are interleaved per block in PCM_DVD */
sample_size = avctx->bits_per_coded_sample * 2 / 8;
+ else if (avctx->codec_id == CODEC_ID_PCM_LXF)
+ /* we process 40-bit blocks per channel for LXF */
+ sample_size = 5;
+
+ if (sample_size == 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n");
+ return AVERROR(EINVAL);
+ }
n = avctx->channels * sample_size;
@@ -436,6 +444,26 @@ static int pcm_decode_frame(AVCodecContext *avctx,
}
samples = (short *) dst_int32_t;
break;
+ case CODEC_ID_PCM_LXF:
+ dst_int32_t = data;
+ n /= avctx->channels;
+ //unpack and de-planerize
+ for (i = 0; i < n; i++) {
+ for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
+ //extract low 20 bits and expand to 32 bits
+ *dst_int32_t++ = (src8[2] << 28) | (src8[1] << 20) | (src8[0] << 12) |
+ ((src8[2] & 0xF) << 8) | src8[1];
+ }
+
+ for (c = 0, src8 = src + i*5; c < avctx->channels; c++, src8 += n*5) {
+ //extract high 20 bits and expand to 32 bits
+ *dst_int32_t++ = (src8[4] << 24) | (src8[3] << 16) |
+ ((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4);
+ }
+ }
+ src += n * avctx->channels * 5;
+ samples = (short *) dst_int32_t;
+ break;
default:
return -1;
}
@@ -444,17 +472,15 @@ static int pcm_decode_frame(AVCodecContext *avctx,
}
#if CONFIG_ENCODERS
-#define PCM_ENCODER(id,sample_fmt_,name,long_name_) \
-AVCodec name ## _encoder = { \
- #name, \
- AVMEDIA_TYPE_AUDIO, \
- id, \
- 0, \
- pcm_encode_init, \
- pcm_encode_frame, \
- pcm_encode_close, \
- NULL, \
- .sample_fmts = (const enum SampleFormat[]){sample_fmt_,SAMPLE_FMT_NONE}, \
+#define PCM_ENCODER(id_,sample_fmt_,name_,long_name_) \
+AVCodec ff_ ## name_ ## _encoder = { \
+ .name = #name_, \
+ .type = AVMEDIA_TYPE_AUDIO, \
+ .id = id_, \
+ .init = pcm_encode_init, \
+ .encode = pcm_encode_frame, \
+ .close = pcm_encode_close, \
+ .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
};
#else
@@ -462,17 +488,15 @@ AVCodec name ## _encoder = { \
#endif
#if CONFIG_DECODERS
-#define PCM_DECODER(id,sample_fmt_,name,long_name_) \
-AVCodec name ## _decoder = { \
- #name, \
- AVMEDIA_TYPE_AUDIO, \
- id, \
- sizeof(PCMDecode), \
- pcm_decode_init, \
- NULL, \
- NULL, \
- pcm_decode_frame, \
- .sample_fmts = (const enum SampleFormat[]){sample_fmt_,SAMPLE_FMT_NONE}, \
+#define PCM_DECODER(id_,sample_fmt_,name_,long_name_) \
+AVCodec ff_ ## name_ ## _decoder = { \
+ .name = #name_, \
+ .type = AVMEDIA_TYPE_AUDIO, \
+ .id = id_, \
+ .priv_data_size = sizeof(PCMDecode), \
+ .init = pcm_decode_init, \
+ .decode = pcm_decode_frame, \
+ .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
};
#else
@@ -483,27 +507,28 @@ AVCodec name ## _decoder = { \
PCM_ENCODER(id,sample_fmt_,name,long_name_) PCM_DECODER(id,sample_fmt_,name,long_name_)
/* Note: Do not forget to add new entries to the Makefile as well. */
-PCM_CODEC (CODEC_ID_PCM_ALAW, SAMPLE_FMT_S16, pcm_alaw, "PCM A-law");
-PCM_CODEC (CODEC_ID_PCM_DVD, SAMPLE_FMT_S32, pcm_dvd, "PCM signed 20|24-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_F32BE, SAMPLE_FMT_FLT, pcm_f32be, "PCM 32-bit floating point big-endian");
-PCM_CODEC (CODEC_ID_PCM_F32LE, SAMPLE_FMT_FLT, pcm_f32le, "PCM 32-bit floating point little-endian");
-PCM_CODEC (CODEC_ID_PCM_F64BE, SAMPLE_FMT_DBL, pcm_f64be, "PCM 64-bit floating point big-endian");
-PCM_CODEC (CODEC_ID_PCM_F64LE, SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit floating point little-endian");
-PCM_CODEC (CODEC_ID_PCM_MULAW, SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law");
-PCM_CODEC (CODEC_ID_PCM_S8, SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
-PCM_CODEC (CODEC_ID_PCM_S16BE, SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_S16LE, SAMPLE_FMT_S16, pcm_s16le, "PCM signed 16-bit little-endian");
-PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, SAMPLE_FMT_S16, pcm_s16le_planar, "PCM 16-bit little-endian planar");
-PCM_CODEC (CODEC_ID_PCM_S24BE, SAMPLE_FMT_S32, pcm_s24be, "PCM signed 24-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_S24DAUD, SAMPLE_FMT_S16, pcm_s24daud, "PCM D-Cinema audio signed 24-bit");
-PCM_CODEC (CODEC_ID_PCM_S24LE, SAMPLE_FMT_S32, pcm_s24le, "PCM signed 24-bit little-endian");
-PCM_CODEC (CODEC_ID_PCM_S32BE, SAMPLE_FMT_S32, pcm_s32be, "PCM signed 32-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_S32LE, SAMPLE_FMT_S32, pcm_s32le, "PCM signed 32-bit little-endian");
-PCM_CODEC (CODEC_ID_PCM_U8, SAMPLE_FMT_U8, pcm_u8, "PCM unsigned 8-bit");
-PCM_CODEC (CODEC_ID_PCM_U16BE, SAMPLE_FMT_S16, pcm_u16be, "PCM unsigned 16-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_U16LE, SAMPLE_FMT_S16, pcm_u16le, "PCM unsigned 16-bit little-endian");
-PCM_CODEC (CODEC_ID_PCM_U24BE, SAMPLE_FMT_S32, pcm_u24be, "PCM unsigned 24-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_U24LE, SAMPLE_FMT_S32, pcm_u24le, "PCM unsigned 24-bit little-endian");
-PCM_CODEC (CODEC_ID_PCM_U32BE, SAMPLE_FMT_S32, pcm_u32be, "PCM unsigned 32-bit big-endian");
-PCM_CODEC (CODEC_ID_PCM_U32LE, SAMPLE_FMT_S32, pcm_u32le, "PCM unsigned 32-bit little-endian");
-PCM_CODEC (CODEC_ID_PCM_ZORK, SAMPLE_FMT_S16, pcm_zork, "PCM Zork");
+PCM_CODEC (CODEC_ID_PCM_ALAW, AV_SAMPLE_FMT_S16, pcm_alaw, "PCM A-law");
+PCM_DECODER(CODEC_ID_PCM_DVD, AV_SAMPLE_FMT_S32, pcm_dvd, "PCM signed 20|24-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_F32BE, AV_SAMPLE_FMT_FLT, pcm_f32be, "PCM 32-bit floating point big-endian");
+PCM_CODEC (CODEC_ID_PCM_F32LE, AV_SAMPLE_FMT_FLT, pcm_f32le, "PCM 32-bit floating point little-endian");
+PCM_CODEC (CODEC_ID_PCM_F64BE, AV_SAMPLE_FMT_DBL, pcm_f64be, "PCM 64-bit floating point big-endian");
+PCM_CODEC (CODEC_ID_PCM_F64LE, AV_SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit floating point little-endian");
+PCM_DECODER(CODEC_ID_PCM_LXF, AV_SAMPLE_FMT_S32, pcm_lxf, "PCM signed 20-bit little-endian planar");
+PCM_CODEC (CODEC_ID_PCM_MULAW, AV_SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law");
+PCM_CODEC (CODEC_ID_PCM_S8, AV_SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
+PCM_CODEC (CODEC_ID_PCM_S16BE, AV_SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_S16LE, AV_SAMPLE_FMT_S16, pcm_s16le, "PCM signed 16-bit little-endian");
+PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, AV_SAMPLE_FMT_S16, pcm_s16le_planar, "PCM 16-bit little-endian planar");
+PCM_CODEC (CODEC_ID_PCM_S24BE, AV_SAMPLE_FMT_S32, pcm_s24be, "PCM signed 24-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_S24DAUD, AV_SAMPLE_FMT_S16, pcm_s24daud, "PCM D-Cinema audio signed 24-bit");
+PCM_CODEC (CODEC_ID_PCM_S24LE, AV_SAMPLE_FMT_S32, pcm_s24le, "PCM signed 24-bit little-endian");
+PCM_CODEC (CODEC_ID_PCM_S32BE, AV_SAMPLE_FMT_S32, pcm_s32be, "PCM signed 32-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_S32LE, AV_SAMPLE_FMT_S32, pcm_s32le, "PCM signed 32-bit little-endian");
+PCM_CODEC (CODEC_ID_PCM_U8, AV_SAMPLE_FMT_U8, pcm_u8, "PCM unsigned 8-bit");
+PCM_CODEC (CODEC_ID_PCM_U16BE, AV_SAMPLE_FMT_S16, pcm_u16be, "PCM unsigned 16-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_U16LE, AV_SAMPLE_FMT_S16, pcm_u16le, "PCM unsigned 16-bit little-endian");
+PCM_CODEC (CODEC_ID_PCM_U24BE, AV_SAMPLE_FMT_S32, pcm_u24be, "PCM unsigned 24-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_U24LE, AV_SAMPLE_FMT_S32, pcm_u24le, "PCM unsigned 24-bit little-endian");
+PCM_CODEC (CODEC_ID_PCM_U32BE, AV_SAMPLE_FMT_S32, pcm_u32be, "PCM unsigned 32-bit big-endian");
+PCM_CODEC (CODEC_ID_PCM_U32LE, AV_SAMPLE_FMT_S32, pcm_u32le, "PCM unsigned 32-bit little-endian");
+PCM_CODEC (CODEC_ID_PCM_ZORK, AV_SAMPLE_FMT_S16, pcm_zork, "PCM Zork");
diff --git a/lib/ffmpeg/libavcodec/pcx.c b/lib/ffmpeg/libavcodec/pcx.c
index 072d136d81..cafade2d7d 100644
--- a/lib/ffmpeg/libavcodec/pcx.c
+++ b/lib/ffmpeg/libavcodec/pcx.c
@@ -22,6 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
@@ -142,7 +143,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (p->data[0])
avctx->release_buffer(avctx, p);
- if (avcodec_check_dimensions(avctx, w, h))
+ if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -246,7 +247,7 @@ static av_cold int pcx_end(AVCodecContext *avctx) {
return 0;
}
-AVCodec pcx_decoder = {
+AVCodec ff_pcx_decoder = {
"pcx",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PCX,
diff --git a/lib/ffmpeg/libavcodec/pcxenc.c b/lib/ffmpeg/libavcodec/pcxenc.c
index a3ce284b5b..124516b957 100644
--- a/lib/ffmpeg/libavcodec/pcxenc.c
+++ b/lib/ffmpeg/libavcodec/pcxenc.c
@@ -33,7 +33,7 @@ typedef struct PCXContext {
AVFrame picture;
} PCXContext;
-static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF };
+static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
static av_cold int pcx_encode_init(AVCodecContext *avctx)
{
@@ -189,7 +189,7 @@ static int pcx_encode_frame(AVCodecContext *avctx,
return buf - buf_start;
}
-AVCodec pcx_encoder = {
+AVCodec ff_pcx_encoder = {
"pcx",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PCX,
diff --git a/lib/ffmpeg/libavcodec/pgssubdec.c b/lib/ffmpeg/libavcodec/pgssubdec.c
index f45152212b..1ed475787f 100644
--- a/lib/ffmpeg/libavcodec/pgssubdec.c
+++ b/lib/ffmpeg/libavcodec/pgssubdec.c
@@ -28,6 +28,7 @@
#include "dsputil.h"
#include "bytestream.h"
#include "libavutil/colorspace.h"
+#include "libavcore/imgutils.h"
//#define DEBUG_PACKET_CONTENTS
@@ -53,6 +54,7 @@ typedef struct PGSSubPicture {
int h;
uint8_t *rle;
unsigned int rle_buffer_size, rle_data_len;
+ unsigned int rle_remaining_len;
} PGSSubPicture;
typedef struct PGSSubContext {
@@ -134,7 +136,12 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitle *sub,
}
}
- dprintf(avctx, "Pixel Count = %d, Area = %d\n", pixel_count, sub->rects[0]->w * sub->rects[0]->h);
+ if (pixel_count < sub->rects[0]->w * sub->rects[0]->h) {
+ av_log(avctx, AV_LOG_ERROR, "Insufficient RLE data for subtitle\n");
+ return -1;
+ }
+
+ av_dlog(avctx, "Pixel Count = %d, Area = %d\n", pixel_count, sub->rects[0]->w * sub->rects[0]->h);
return 0;
}
@@ -158,6 +165,10 @@ static int parse_picture_segment(AVCodecContext *avctx,
uint8_t sequence_desc;
unsigned int rle_bitmap_len, width, height;
+ if (buf_size <= 4)
+ return -1;
+ buf_size -= 4;
+
/* skip 3 unknown bytes: Object ID (2 bytes), Version Number */
buf += 3;
@@ -165,20 +176,23 @@ static int parse_picture_segment(AVCodecContext *avctx,
sequence_desc = bytestream_get_byte(&buf);
if (!(sequence_desc & 0x80)) {
- av_log(avctx, AV_LOG_ERROR, "Decoder does not support object data over multiple packets.\n");
- return -1;
- }
+ /* Additional RLE data */
+ if (buf_size > ctx->picture.rle_remaining_len)
+ return -1;
- /* Decode rle bitmap length */
- rle_bitmap_len = bytestream_get_be24(&buf);
+ memcpy(ctx->picture.rle + ctx->picture.rle_data_len, buf, buf_size);
+ ctx->picture.rle_data_len += buf_size;
+ ctx->picture.rle_remaining_len -= buf_size;
- /* Check to ensure we have enough data for rle_bitmap_length if just a single packet */
- if (rle_bitmap_len > buf_size - 7) {
- av_log(avctx, AV_LOG_ERROR, "Not enough RLE data for specified length of %d.\n", rle_bitmap_len);
- return -1;
+ return 0;
}
- ctx->picture.rle_data_len = rle_bitmap_len;
+ if (buf_size <= 7)
+ return -1;
+ buf_size -= 7;
+
+ /* Decode rle bitmap length, stored size includes width/height data */
+ rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
/* Get bitmap dimensions from data */
width = bytestream_get_be16(&buf);
@@ -198,7 +212,9 @@ static int parse_picture_segment(AVCodecContext *avctx,
if (!ctx->picture.rle)
return -1;
- memcpy(ctx->picture.rle, buf, rle_bitmap_len);
+ memcpy(ctx->picture.rle, buf, buf_size);
+ ctx->picture.rle_data_len = buf_size;
+ ctx->picture.rle_remaining_len = rle_bitmap_len - buf_size;
return 0;
}
@@ -237,7 +253,7 @@ static void parse_palette_segment(AVCodecContext *avctx,
YUV_TO_RGB1(cb, cr);
YUV_TO_RGB2(r, g, b, y);
- dprintf(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
+ av_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
/* Store color in palette */
ctx->clut[color_id] = RGBA(r,g,b,alpha);
@@ -266,9 +282,9 @@ static void parse_presentation_segment(AVCodecContext *avctx,
int w = bytestream_get_be16(&buf);
int h = bytestream_get_be16(&buf);
- dprintf(avctx, "Video Dimensions %dx%d\n",
+ av_dlog(avctx, "Video Dimensions %dx%d\n",
w, h);
- if (avcodec_check_dimensions(avctx, w, h) >= 0)
+ if (av_image_check_size(w, h, 0, avctx) >= 0)
avcodec_set_dimensions(avctx, w, h);
/* Skip 1 bytes of unknown, frame rate? */
@@ -301,7 +317,7 @@ static void parse_presentation_segment(AVCodecContext *avctx,
/* TODO If cropping, cropping_x, cropping_y, cropping_width, cropping_height (all 2 bytes).*/
- dprintf(avctx, "Subtitle Placement x=%d, y=%d\n", x, y);
+ av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n", x, y);
if (x > avctx->width || y > avctx->height) {
av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
@@ -363,10 +379,13 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
/* Process bitmap */
sub->rects[0]->pict.linesize[0] = ctx->picture.w;
- if (ctx->picture.rle)
+ if (ctx->picture.rle) {
+ if (ctx->picture.rle_remaining_len)
+ av_log(avctx, AV_LOG_ERROR, "RLE data length %u is %u bytes shorter than expected\n",
+ ctx->picture.rle_data_len, ctx->picture.rle_remaining_len);
if(decode_rle(avctx, sub, ctx->picture.rle, ctx->picture.rle_data_len) < 0)
return 0;
-
+ }
/* Allocate memory for colors */
sub->rects[0]->nb_colors = 256;
sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
@@ -414,7 +433,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
segment_type = bytestream_get_byte(&buf);
segment_length = bytestream_get_be16(&buf);
- dprintf(avctx, "Segment Length %d, Segment Type %x\n", segment_length, segment_type);
+ av_dlog(avctx, "Segment Length %d, Segment Type %x\n", segment_length, segment_type);
if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf)
break;
@@ -454,7 +473,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
return buf_size;
}
-AVCodec pgssub_decoder = {
+AVCodec ff_pgssub_decoder = {
"pgssub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_HDMV_PGS_SUBTITLE,
diff --git a/lib/ffmpeg/libavcodec/pictordec.c b/lib/ffmpeg/libavcodec/pictordec.c
index f990b1852b..59885ae383 100644
--- a/lib/ffmpeg/libavcodec/pictordec.c
+++ b/lib/ffmpeg/libavcodec/pictordec.c
@@ -24,6 +24,7 @@
* Pictor/PC Paint decoder
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "cga_data.h"
@@ -135,7 +136,7 @@ static int decode_frame(AVCodecContext *avctx,
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)
+ if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
return -1;
avcodec_set_dimensions(avctx, s->width, s->height);
if (s->frame.data[0])
@@ -236,9 +237,9 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec pictor_decoder = {
+AVCodec ff_pictor_decoder = {
"pictor",
- CODEC_TYPE_VIDEO,
+ AVMEDIA_TYPE_VIDEO,
CODEC_ID_PICTOR,
sizeof(PicContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/png.c b/lib/ffmpeg/libavcodec/png.c
index 534dc68bf1..d7898c0a41 100644
--- a/lib/ffmpeg/libavcodec/png.c
+++ b/lib/ffmpeg/libavcodec/png.c
@@ -31,12 +31,12 @@ const uint8_t ff_png_pass_ymask[NB_PASSES] = {
};
/* minimum x value */
-const uint8_t ff_png_pass_xmin[NB_PASSES] = {
+static const uint8_t ff_png_pass_xmin[NB_PASSES] = {
0, 4, 0, 2, 0, 1, 0
};
/* x shift to get row width */
-const uint8_t ff_png_pass_xshift[NB_PASSES] = {
+static const uint8_t ff_png_pass_xshift[NB_PASSES] = {
3, 3, 2, 2, 1, 1, 0
};
diff --git a/lib/ffmpeg/libavcodec/png.h b/lib/ffmpeg/libavcodec/png.h
index 7c0ab9f6c6..bab5224851 100644
--- a/lib/ffmpeg/libavcodec/png.h
+++ b/lib/ffmpeg/libavcodec/png.h
@@ -55,12 +55,6 @@ extern const uint8_t ff_mngsig[8];
/* Mask to determine which y pixels are valid in a pass */
extern const uint8_t ff_png_pass_ymask[NB_PASSES];
-/* minimum x value */
-extern const uint8_t ff_png_pass_xmin[NB_PASSES];
-
-/* x shift to get row width */
-extern const uint8_t ff_png_pass_xshift[NB_PASSES];
-
/* Mask to determine which pixels are valid in a pass */
extern const uint8_t ff_png_pass_mask[NB_PASSES];
diff --git a/lib/ffmpeg/libavcodec/pngdec.c b/lib/ffmpeg/libavcodec/pngdec.c
index 037c5a0e58..4bc5c3705a 100644
--- a/lib/ffmpeg/libavcodec/pngdec.c
+++ b/lib/ffmpeg/libavcodec/pngdec.c
@@ -18,6 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "png.h"
@@ -430,7 +431,7 @@ static int decode_frame(AVCodecContext *avctx,
goto fail;
tag32 = bytestream_get_be32(&s->bytestream);
tag = av_bswap32(tag32);
- dprintf(avctx, "png: tag=%c%c%c%c length=%u\n",
+ av_dlog(avctx, "png: tag=%c%c%c%c length=%u\n",
(tag & 0xff),
((tag >> 8) & 0xff),
((tag >> 16) & 0xff),
@@ -441,7 +442,7 @@ static int decode_frame(AVCodecContext *avctx,
goto fail;
s->width = bytestream_get_be32(&s->bytestream);
s->height = bytestream_get_be32(&s->bytestream);
- if(avcodec_check_dimensions(avctx, s->width, s->height)){
+ if(av_image_check_size(s->width, s->height, 0, avctx)){
s->width= s->height= 0;
goto fail;
}
@@ -452,7 +453,7 @@ static int decode_frame(AVCodecContext *avctx,
s->interlace_type = *s->bytestream++;
crc = bytestream_get_be32(&s->bytestream);
s->state |= PNG_IHDR;
- dprintf(avctx, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
+ av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
s->width, s->height, s->bit_depth, s->color_type,
s->compression_type, s->filter_type, s->interlace_type);
break;
@@ -516,7 +517,7 @@ static int decode_frame(AVCodecContext *avctx,
s->width);
s->crow_size = s->pass_row_size + 1;
}
- dprintf(avctx, "row_size=%d crow_size =%d\n",
+ av_dlog(avctx, "row_size=%d crow_size =%d\n",
s->row_size, s->crow_size);
s->image_buf = p->data[0];
s->image_linesize = p->linesize[0];
@@ -656,7 +657,7 @@ static av_cold int png_dec_end(AVCodecContext *avctx)
return 0;
}
-AVCodec png_decoder = {
+AVCodec ff_png_decoder = {
"png",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PNG,
diff --git a/lib/ffmpeg/libavcodec/pngenc.c b/lib/ffmpeg/libavcodec/pngenc.c
index d199b95da9..4cb56337e7 100644
--- a/lib/ffmpeg/libavcodec/pngenc.c
+++ b/lib/ffmpeg/libavcodec/pngenc.c
@@ -436,7 +436,7 @@ static av_cold int png_enc_init(AVCodecContext *avctx){
return 0;
}
-AVCodec png_encoder = {
+AVCodec ff_png_encoder = {
"png",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PNG,
diff --git a/lib/ffmpeg/libavcodec/pnm.c b/lib/ffmpeg/libavcodec/pnm.c
index cb6a7139f2..c104e23427 100644
--- a/lib/ffmpeg/libavcodec/pnm.c
+++ b/lib/ffmpeg/libavcodec/pnm.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "pnm.h"
@@ -101,7 +102,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
}
}
/* check that all tags are present */
- if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || avcodec_check_dimensions(avctx, w, h))
+ if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_image_check_size(w, h, 0, avctx))
return -1;
avctx->width = w;
@@ -134,11 +135,15 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
return -1;
pnm_get(s, buf1, sizeof(buf1));
avctx->height = atoi(buf1);
- if(avcodec_check_dimensions(avctx, avctx->width, avctx->height))
+ if(av_image_check_size(avctx->width, avctx->height, 0, avctx))
return -1;
if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
pnm_get(s, buf1, sizeof(buf1));
s->maxval = atoi(buf1);
+ if (s->maxval <= 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
+ s->maxval = 255;
+ }
if (s->maxval >= 256) {
if (avctx->pix_fmt == PIX_FMT_GRAY8) {
avctx->pix_fmt = PIX_FMT_GRAY16BE;
diff --git a/lib/ffmpeg/libavcodec/pnm_parser.c b/lib/ffmpeg/libavcodec/pnm_parser.c
index b8ba1a836c..17e8082609 100644
--- a/lib/ffmpeg/libavcodec/pnm_parser.c
+++ b/lib/ffmpeg/libavcodec/pnm_parser.c
@@ -83,7 +83,7 @@ retry:
return next;
}
-AVCodecParser pnm_parser = {
+AVCodecParser ff_pnm_parser = {
{ CODEC_ID_PGM, CODEC_ID_PGMYUV, CODEC_ID_PPM, CODEC_ID_PBM, CODEC_ID_PAM},
sizeof(ParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/pnmdec.c b/lib/ffmpeg/libavcodec/pnmdec.c
index 6bea93de02..39faab7be2 100644
--- a/lib/ffmpeg/libavcodec/pnmdec.c
+++ b/lib/ffmpeg/libavcodec/pnmdec.c
@@ -188,7 +188,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
#if CONFIG_PGM_DECODER
-AVCodec pgm_decoder = {
+AVCodec ff_pgm_decoder = {
"pgm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PGM,
@@ -205,7 +205,7 @@ AVCodec pgm_decoder = {
#endif
#if CONFIG_PGMYUV_DECODER
-AVCodec pgmyuv_decoder = {
+AVCodec ff_pgmyuv_decoder = {
"pgmyuv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PGMYUV,
@@ -222,7 +222,7 @@ AVCodec pgmyuv_decoder = {
#endif
#if CONFIG_PPM_DECODER
-AVCodec ppm_decoder = {
+AVCodec ff_ppm_decoder = {
"ppm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PPM,
@@ -239,7 +239,7 @@ AVCodec ppm_decoder = {
#endif
#if CONFIG_PBM_DECODER
-AVCodec pbm_decoder = {
+AVCodec ff_pbm_decoder = {
"pbm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PBM,
@@ -256,7 +256,7 @@ AVCodec pbm_decoder = {
#endif
#if CONFIG_PAM_DECODER
-AVCodec pam_decoder = {
+AVCodec ff_pam_decoder = {
"pam",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PAM,
diff --git a/lib/ffmpeg/libavcodec/pnmenc.c b/lib/ffmpeg/libavcodec/pnmenc.c
index 1fbf665883..4dbd587e1a 100644
--- a/lib/ffmpeg/libavcodec/pnmenc.c
+++ b/lib/ffmpeg/libavcodec/pnmenc.c
@@ -113,7 +113,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf,
#if CONFIG_PGM_ENCODER
-AVCodec pgm_encoder = {
+AVCodec ff_pgm_encoder = {
"pgm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PGM,
@@ -126,7 +126,7 @@ AVCodec pgm_encoder = {
#endif
#if CONFIG_PGMYUV_ENCODER
-AVCodec pgmyuv_encoder = {
+AVCodec ff_pgmyuv_encoder = {
"pgmyuv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PGMYUV,
@@ -139,7 +139,7 @@ AVCodec pgmyuv_encoder = {
#endif
#if CONFIG_PPM_ENCODER
-AVCodec ppm_encoder = {
+AVCodec ff_ppm_encoder = {
"ppm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PPM,
@@ -152,7 +152,7 @@ AVCodec ppm_encoder = {
#endif
#if CONFIG_PBM_ENCODER
-AVCodec pbm_encoder = {
+AVCodec ff_pbm_encoder = {
"pbm",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PBM,
diff --git a/lib/ffmpeg/libavcodec/ppc/Makefile b/lib/ffmpeg/libavcodec/ppc/Makefile
index 175b1093b0..35ea0c38f8 100644
--- a/lib/ffmpeg/libavcodec/ppc/Makefile
+++ b/lib/ffmpeg/libavcodec/ppc/Makefile
@@ -18,10 +18,10 @@ 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 \
+OBJS-$(HAVE_ALTIVEC) += ppc/dsputil_altivec.o \
ppc/fdct_altivec.o \
ppc/float_altivec.o \
+ ppc/fmtconvert_altivec.o \
ppc/gmc_altivec.o \
ppc/idct_altivec.o \
ppc/int_altivec.o \
diff --git a/lib/ffmpeg/libavcodec/ppc/check_altivec.c b/lib/ffmpeg/libavcodec/ppc/check_altivec.c
deleted file mode 100644
index 6b9332ce3a..0000000000
--- a/lib/ffmpeg/libavcodec/ppc/check_altivec.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-/**
- * @file
- * Check for AltiVec presence.
- */
-
-#ifdef __APPLE__
-#undef _POSIX_C_SOURCE
-#include <sys/sysctl.h>
-#elif defined(__OpenBSD__)
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <machine/cpu.h>
-#elif defined(__AMIGAOS4__)
-#include <exec/exec.h>
-#include <interfaces/exec.h>
-#include <proto/exec.h>
-#endif /* __APPLE__ */
-
-#include "config.h"
-#include "dsputil_altivec.h"
-
-/**
- * This function MAY rely on signal() or fork() in order to make sure AltiVec
- * is present.
- */
-
-int has_altivec(void)
-{
-#ifdef __AMIGAOS4__
- ULONG result = 0;
- extern struct ExecIFace *IExec;
-
- IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
- if (result == VECTORTYPE_ALTIVEC) return 1;
- return 0;
-#elif defined(__APPLE__) || defined(__OpenBSD__)
-#ifdef __OpenBSD__
- int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
-#else
- int sels[2] = {CTL_HW, HW_VECTORUNIT};
-#endif
- int has_vu = 0;
- size_t len = sizeof(has_vu);
- int err;
-
- err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
-
- if (err == 0) return has_vu != 0;
- return 0;
-#elif CONFIG_RUNTIME_CPUDETECT
- int proc_ver;
- // Support of mfspr PVR emulation added in Linux 2.6.17.
- __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver));
- proc_ver >>= 16;
- if (proc_ver & 0x8000 ||
- proc_ver == 0x000c ||
- proc_ver == 0x0039 || proc_ver == 0x003c ||
- proc_ver == 0x0044 || proc_ver == 0x0045 ||
- proc_ver == 0x0070)
- return 1;
- return 0;
-#else
- // Since we were compiled for AltiVec, just assume we have it
- // until someone comes up with a proper way (not involving signal hacks).
- return 1;
-#endif /* __AMIGAOS4__ */
-}
-
diff --git a/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.c b/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.c
index 163323264c..6779312c96 100644
--- a/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -230,7 +230,7 @@ static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i
int i;
int s;
const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
- vector unsigned char perm1, perm2, *pix1v, *pix2v;
+ vector unsigned char perm1, perm2, pix1v_low, pix1v_high, pix2v_low, pix2v_high;
vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sad;
vector signed int sumdiffs;
@@ -241,11 +241,13 @@ static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i
for (i = 0; i < h; i++) {
/* Read potentially unaligned pixels into t1 and t2 */
perm1 = vec_lvsl(0, pix1);
- pix1v = (vector unsigned char *) pix1;
+ pix1v_high = vec_ld( 0, pix1);
+ pix1v_low = vec_ld(15, pix1);
perm2 = vec_lvsl(0, pix2);
- pix2v = (vector unsigned char *) pix2;
- t1 = vec_perm(pix1v[0], pix1v[1], perm1);
- t2 = vec_perm(pix2v[0], pix2v[1], perm2);
+ pix2v_high = vec_ld( 0, pix2);
+ pix2v_low = vec_ld(15, pix2);
+ t1 = vec_perm(pix1v_high, pix1v_low, perm1);
+ t2 = vec_perm(pix2v_high, pix2v_low, perm2);
/* Calculate a sum of abs differences vector */
t3 = vec_max(t1, t2);
diff --git a/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.h b/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.h
index 18f8dd8710..cd44f602b9 100644
--- a/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.h
+++ b/lib/ffmpeg/libavcodec/ppc/dsputil_altivec.h
@@ -30,8 +30,6 @@ void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size,
void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-int has_altivec(void);
-
void fdct_altivec(int16_t *block);
void gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h,
int x16, int y16, int rounder);
diff --git a/lib/ffmpeg/libavcodec/ppc/dsputil_ppc.c b/lib/ffmpeg/libavcodec/ppc/dsputil_ppc.c
index 229ca09960..9e4f1aa667 100644
--- a/lib/ffmpeg/libavcodec/ppc/dsputil_ppc.c
+++ b/lib/ffmpeg/libavcodec/ppc/dsputil_ppc.c
@@ -20,22 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h"
#include "dsputil_altivec.h"
-int mm_flags = 0;
-
-int mm_support(void)
-{
- int result = 0;
-#if HAVE_ALTIVEC
- if (has_altivec()) {
- result |= FF_MM_ALTIVEC;
- }
-#endif /* result */
- return result;
-}
-
/* ***** WARNING ***** WARNING ***** WARNING ***** */
/*
clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with a
@@ -181,9 +169,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
#if HAVE_ALTIVEC
if(CONFIG_H264_DECODER) dsputil_h264_init_ppc(c, avctx);
- if (has_altivec()) {
- mm_flags |= FF_MM_ALTIVEC;
-
+ if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
dsputil_init_altivec(c, avctx);
if(CONFIG_VC1_DECODER)
vc1dsp_init_altivec(c, avctx);
diff --git a/lib/ffmpeg/libavcodec/ppc/fft_altivec_s.S b/lib/ffmpeg/libavcodec/ppc/fft_altivec_s.S
index d17d033bab..5d3c5406c3 100644
--- a/lib/ffmpeg/libavcodec/ppc/fft_altivec_s.S
+++ b/lib/ffmpeg/libavcodec/ppc/fft_altivec_s.S
@@ -2,6 +2,9 @@
* FFT transform with Altivec optimizations
* Copyright (c) 2009 Loren Merritt
*
+ * This algorithm (though not any of the implementation details) is
+ * based on libdjbfft by D. J. Bernstein.
+ *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
diff --git a/lib/ffmpeg/libavcodec/ppc/float_altivec.c b/lib/ffmpeg/libavcodec/ppc/float_altivec.c
index d1f9f1ade3..ba97cbfd3b 100644
--- a/lib/ffmpeg/libavcodec/ppc/float_altivec.c
+++ b/lib/ffmpeg/libavcodec/ppc/float_altivec.c
@@ -23,16 +23,16 @@
#include "dsputil_altivec.h"
#include "util_altivec.h"
-static void vector_fmul_altivec(float *dst, const float *src, int len)
+static void vector_fmul_altivec(float *dst, const float *src0, const float *src1, int len)
{
int i;
vector float d0, d1, s, zero = (vector float)vec_splat_u32(0);
for(i=0; i<len-7; i+=8) {
- d0 = vec_ld(0, dst+i);
- s = vec_ld(0, src+i);
- d1 = vec_ld(16, dst+i);
+ d0 = vec_ld(0, src0+i);
+ s = vec_ld(0, src1+i);
+ d1 = vec_ld(16, src0+i);
d0 = vec_madd(d0, s, zero);
- d1 = vec_madd(d1, vec_ld(16,src+i), zero);
+ d1 = vec_madd(d1, vec_ld(16,src1+i), zero);
vec_st(d0, 0, dst+i);
vec_st(d1, 16, dst+i);
}
@@ -90,13 +90,9 @@ static void vector_fmul_add_altivec(float *dst, const float *src0,
}
}
-static void vector_fmul_window_altivec(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len)
+static void vector_fmul_window_altivec(float *dst, const float *src0, const float *src1, const float *win, int len)
{
- union {
- vector float v;
- float s[4];
- } vadd;
- vector float vadd_bias, zero, t0, t1, s0, s1, wi, wj;
+ vector float zero, t0, t1, s0, s1, wi, wj;
const vector unsigned char reverse = vcprm(3,2,1,0);
int i,j;
@@ -104,8 +100,6 @@ static void vector_fmul_window_altivec(float *dst, const float *src0, const floa
win += len;
src0+= len;
- vadd.s[0] = add_bias;
- vadd_bias = vec_splat(vadd.v, 0);
zero = (vector float)vec_splat_u32(0);
for(i=-len*4, j=len*4-16; i<0; i+=16, j-=16) {
@@ -117,9 +111,9 @@ static void vector_fmul_window_altivec(float *dst, const float *src0, const floa
s1 = vec_perm(s1, s1, reverse);
wj = vec_perm(wj, wj, reverse);
- t0 = vec_madd(s0, wj, vadd_bias);
+ t0 = vec_madd(s0, wj, zero);
t0 = vec_nmsub(s1, wi, t0);
- t1 = vec_madd(s0, wi, vadd_bias);
+ t1 = vec_madd(s0, wi, zero);
t1 = vec_madd(s1, wj, t1);
t1 = vec_perm(t1, t1, reverse);
@@ -128,124 +122,12 @@ static void vector_fmul_window_altivec(float *dst, const float *src0, const floa
}
}
-static void int32_to_float_fmul_scalar_altivec(float *dst, const int *src, float mul, int len)
-{
- union {
- vector float v;
- float s[4];
- } mul_u;
- int i;
- vector float src1, src2, dst1, dst2, mul_v, zero;
-
- zero = (vector float)vec_splat_u32(0);
- mul_u.s[0] = mul;
- mul_v = vec_splat(mul_u.v, 0);
-
- for(i=0; i<len; i+=8) {
- src1 = vec_ctf(vec_ld(0, src+i), 0);
- src2 = vec_ctf(vec_ld(16, src+i), 0);
- dst1 = vec_madd(src1, mul_v, zero);
- dst2 = vec_madd(src2, mul_v, zero);
- vec_st(dst1, 0, dst+i);
- vec_st(dst2, 16, dst+i);
- }
-}
-
-
-static vector signed short
-float_to_int16_one_altivec(const float *src)
-{
- vector float s0 = vec_ld(0, src);
- vector float s1 = vec_ld(16, src);
- vector signed int t0 = vec_cts(s0, 0);
- vector signed int t1 = vec_cts(s1, 0);
- return vec_packs(t0,t1);
-}
-
-static void float_to_int16_altivec(int16_t *dst, const float *src, long len)
-{
- int i;
- vector signed short d0, d1, d;
- vector unsigned char align;
- if(((long)dst)&15) //FIXME
- for(i=0; i<len-7; i+=8) {
- d0 = vec_ld(0, dst+i);
- d = float_to_int16_one_altivec(src+i);
- d1 = vec_ld(15, dst+i);
- d1 = vec_perm(d1, d0, vec_lvsl(0,dst+i));
- align = vec_lvsr(0, dst+i);
- d0 = vec_perm(d1, d, align);
- d1 = vec_perm(d, d1, align);
- vec_st(d0, 0, dst+i);
- vec_st(d1,15, dst+i);
- }
- else
- for(i=0; i<len-7; i+=8) {
- d = float_to_int16_one_altivec(src+i);
- vec_st(d, 0, dst+i);
- }
-}
-
-static void
-float_to_int16_interleave_altivec(int16_t *dst, const float **src,
- long len, int channels)
-{
- int i;
- vector signed short d0, d1, d2, c0, c1, t0, t1;
- vector unsigned char align;
- if(channels == 1)
- float_to_int16_altivec(dst, src[0], len);
- else
- if (channels == 2) {
- if(((long)dst)&15)
- for(i=0; i<len-7; i+=8) {
- d0 = vec_ld(0, dst + i);
- t0 = float_to_int16_one_altivec(src[0] + i);
- d1 = vec_ld(31, dst + i);
- t1 = float_to_int16_one_altivec(src[1] + i);
- c0 = vec_mergeh(t0, t1);
- c1 = vec_mergel(t0, t1);
- d2 = vec_perm(d1, d0, vec_lvsl(0, dst + i));
- align = vec_lvsr(0, dst + i);
- d0 = vec_perm(d2, c0, align);
- d1 = vec_perm(c0, c1, align);
- vec_st(d0, 0, dst + i);
- d0 = vec_perm(c1, d2, align);
- vec_st(d1, 15, dst + i);
- vec_st(d0, 31, dst + i);
- dst+=8;
- }
- else
- for(i=0; i<len-7; i+=8) {
- t0 = float_to_int16_one_altivec(src[0] + i);
- t1 = float_to_int16_one_altivec(src[1] + i);
- d0 = vec_mergeh(t0, t1);
- d1 = vec_mergel(t0, t1);
- vec_st(d0, 0, dst + i);
- vec_st(d1, 16, dst + i);
- dst+=8;
- }
- } else {
- DECLARE_ALIGNED(16, int16_t, tmp)[len];
- int c, j;
- for (c = 0; c < channels; c++) {
- float_to_int16_altivec(tmp, src[c], len);
- for (i = 0, j = c; i < len; i++, j+=channels) {
- dst[j] = tmp[i];
- }
- }
- }
-}
-
void float_init_altivec(DSPContext* c, AVCodecContext *avctx)
{
c->vector_fmul = vector_fmul_altivec;
c->vector_fmul_reverse = vector_fmul_reverse_altivec;
c->vector_fmul_add = vector_fmul_add_altivec;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_altivec;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->vector_fmul_window = vector_fmul_window_altivec;
- c->float_to_int16 = float_to_int16_altivec;
- c->float_to_int16_interleave = float_to_int16_interleave_altivec;
}
}
diff --git a/lib/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c b/lib/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
new file mode 100644
index 0000000000..e5287c96c1
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/ppc/fmtconvert_altivec.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2006 Luca Barbato <lu_zero@gentoo.org>
+ *
+ * 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/fmtconvert.h"
+
+#include "dsputil_altivec.h"
+#include "util_altivec.h"
+
+static void int32_to_float_fmul_scalar_altivec(float *dst, const int *src, float mul, int len)
+{
+ union {
+ vector float v;
+ float s[4];
+ } mul_u;
+ int i;
+ vector float src1, src2, dst1, dst2, mul_v, zero;
+
+ zero = (vector float)vec_splat_u32(0);
+ mul_u.s[0] = mul;
+ mul_v = vec_splat(mul_u.v, 0);
+
+ for(i=0; i<len; i+=8) {
+ src1 = vec_ctf(vec_ld(0, src+i), 0);
+ src2 = vec_ctf(vec_ld(16, src+i), 0);
+ dst1 = vec_madd(src1, mul_v, zero);
+ dst2 = vec_madd(src2, mul_v, zero);
+ vec_st(dst1, 0, dst+i);
+ vec_st(dst2, 16, dst+i);
+ }
+}
+
+
+static vector signed short
+float_to_int16_one_altivec(const float *src)
+{
+ vector float s0 = vec_ld(0, src);
+ vector float s1 = vec_ld(16, src);
+ vector signed int t0 = vec_cts(s0, 0);
+ vector signed int t1 = vec_cts(s1, 0);
+ return vec_packs(t0,t1);
+}
+
+static void float_to_int16_altivec(int16_t *dst, const float *src, long len)
+{
+ int i;
+ vector signed short d0, d1, d;
+ vector unsigned char align;
+ if(((long)dst)&15) //FIXME
+ for(i=0; i<len-7; i+=8) {
+ d0 = vec_ld(0, dst+i);
+ d = float_to_int16_one_altivec(src+i);
+ d1 = vec_ld(15, dst+i);
+ d1 = vec_perm(d1, d0, vec_lvsl(0,dst+i));
+ align = vec_lvsr(0, dst+i);
+ d0 = vec_perm(d1, d, align);
+ d1 = vec_perm(d, d1, align);
+ vec_st(d0, 0, dst+i);
+ vec_st(d1,15, dst+i);
+ }
+ else
+ for(i=0; i<len-7; i+=8) {
+ d = float_to_int16_one_altivec(src+i);
+ vec_st(d, 0, dst+i);
+ }
+}
+
+static void
+float_to_int16_interleave_altivec(int16_t *dst, const float **src,
+ long len, int channels)
+{
+ int i;
+ vector signed short d0, d1, d2, c0, c1, t0, t1;
+ vector unsigned char align;
+ if(channels == 1)
+ float_to_int16_altivec(dst, src[0], len);
+ else
+ if (channels == 2) {
+ if(((long)dst)&15)
+ for(i=0; i<len-7; i+=8) {
+ d0 = vec_ld(0, dst + i);
+ t0 = float_to_int16_one_altivec(src[0] + i);
+ d1 = vec_ld(31, dst + i);
+ t1 = float_to_int16_one_altivec(src[1] + i);
+ c0 = vec_mergeh(t0, t1);
+ c1 = vec_mergel(t0, t1);
+ d2 = vec_perm(d1, d0, vec_lvsl(0, dst + i));
+ align = vec_lvsr(0, dst + i);
+ d0 = vec_perm(d2, c0, align);
+ d1 = vec_perm(c0, c1, align);
+ vec_st(d0, 0, dst + i);
+ d0 = vec_perm(c1, d2, align);
+ vec_st(d1, 15, dst + i);
+ vec_st(d0, 31, dst + i);
+ dst+=8;
+ }
+ else
+ for(i=0; i<len-7; i+=8) {
+ t0 = float_to_int16_one_altivec(src[0] + i);
+ t1 = float_to_int16_one_altivec(src[1] + i);
+ d0 = vec_mergeh(t0, t1);
+ d1 = vec_mergel(t0, t1);
+ vec_st(d0, 0, dst + i);
+ vec_st(d1, 16, dst + i);
+ dst+=8;
+ }
+ } else {
+ DECLARE_ALIGNED(16, int16_t, tmp)[len];
+ int c, j;
+ for (c = 0; c < channels; c++) {
+ float_to_int16_altivec(tmp, src[c], len);
+ for (i = 0, j = c; i < len; i++, j+=channels) {
+ dst[j] = tmp[i];
+ }
+ }
+ }
+}
+
+void ff_fmt_convert_init_ppc(FmtConvertContext *c, AVCodecContext *avctx)
+{
+ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_altivec;
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)) {
+ c->float_to_int16 = float_to_int16_altivec;
+ c->float_to_int16_interleave = float_to_int16_interleave_altivec;
+ }
+}
diff --git a/lib/ffmpeg/libavcodec/ppc/h264_altivec.c b/lib/ffmpeg/libavcodec/ppc/h264_altivec.c
index c9c29442ce..aee2bc2d1a 100644
--- a/lib/ffmpeg/libavcodec/ppc/h264_altivec.c
+++ b/lib/ffmpeg/libavcodec/ppc/h264_altivec.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/h264data.h"
#include "libavcodec/h264dsp.h"
@@ -969,7 +970,7 @@ H264_WEIGHT( 8, 4)
void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
- if (has_altivec()) {
+ if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
c->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;
@@ -1001,7 +1002,7 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
void ff_h264dsp_init_ppc(H264DSPContext *c)
{
- if (has_altivec()) {
+ if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
c->h264_idct_add = ff_h264_idct_add_altivec;
c->h264_idct_add8 = ff_h264_idct_add8_altivec;
c->h264_idct_add16 = ff_h264_idct_add16_altivec;
diff --git a/lib/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/lib/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c
index 0126b7f42e..64898a10d0 100644
--- a/lib/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c
+++ b/lib/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h"
@@ -570,7 +571,7 @@ static void dct_unquantize_h263_altivec(MpegEncContext *s,
void MPV_common_init_altivec(MpegEncContext *s)
{
- if ((mm_flags & FF_MM_ALTIVEC) == 0) return;
+ if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return;
if (s->avctx->lowres==0) {
if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
diff --git a/lib/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c b/lib/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
index f7b3cda7a4..8096c4a535 100644
--- a/lib/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
+++ b/lib/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavcodec/vp8dsp.h"
#include "dsputil_altivec.h"
#include "types_altivec.h"
@@ -265,7 +266,7 @@ static void put_vp8_pixels16_altivec(uint8_t *dst, int stride, uint8_t *src, int
av_cold void ff_vp8dsp_init_altivec(VP8DSPContext *c)
{
- if (!has_altivec())
+ if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec;
diff --git a/lib/ffmpeg/libavcodec/psymodel.c b/lib/ffmpeg/libavcodec/psymodel.c
index a85c29baaa..8bd5b8bdd8 100644
--- a/lib/ffmpeg/libavcodec/psymodel.c
+++ b/lib/ffmpeg/libavcodec/psymodel.c
@@ -53,7 +53,7 @@ FFPsyWindowInfo ff_psy_suggest_window(FFPsyContext *ctx,
}
void ff_psy_set_band_info(FFPsyContext *ctx, int channel,
- const float *coeffs, FFPsyWindowInfo *wi)
+ const float *coeffs, const FFPsyWindowInfo *wi)
{
ctx->model->analyze(ctx, channel, coeffs, wi);
}
@@ -88,8 +88,9 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av
cutoff_coeff = 2.0 * avctx->cutoff / avctx->sample_rate;
if (cutoff_coeff)
- ctx->fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS,
- FILT_ORDER, cutoff_coeff, 0.0, 0.0);
+ ctx->fcoeffs = ff_iir_filter_init_coeffs(avctx, FF_FILTER_TYPE_BUTTERWORTH,
+ FF_FILTER_MODE_LOWPASS, FILT_ORDER,
+ cutoff_coeff, 0.0, 0.0);
if (ctx->fcoeffs) {
ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);
for (i = 0; i < avctx->channels; i++)
diff --git a/lib/ffmpeg/libavcodec/psymodel.h b/lib/ffmpeg/libavcodec/psymodel.h
index bc19d49f73..fc2f6d954c 100644
--- a/lib/ffmpeg/libavcodec/psymodel.h
+++ b/lib/ffmpeg/libavcodec/psymodel.h
@@ -72,7 +72,7 @@ typedef struct FFPsyModel {
const char *name;
int (*init) (FFPsyContext *apc);
FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type);
- void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, FFPsyWindowInfo *wi);
+ void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, const FFPsyWindowInfo *wi);
void (*end) (FFPsyContext *apc);
} FFPsyModel;
@@ -116,7 +116,7 @@ FFPsyWindowInfo ff_psy_suggest_window(FFPsyContext *ctx,
* @param wi window information
*/
void ff_psy_set_band_info(FFPsyContext *ctx, int channel, const float *coeffs,
- FFPsyWindowInfo *wi);
+ const FFPsyWindowInfo *wi);
/**
* Cleanup model context at the end.
diff --git a/lib/ffmpeg/libavcodec/ptx.c b/lib/ffmpeg/libavcodec/ptx.c
index d8798f2e9c..86b06b4aaa 100644
--- a/lib/ffmpeg/libavcodec/ptx.c
+++ b/lib/ffmpeg/libavcodec/ptx.c
@@ -20,6 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
typedef struct PTXContext {
@@ -64,7 +65,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (p->data[0])
avctx->release_buffer(avctx, p);
- if (avcodec_check_dimensions(avctx, w, h))
+ if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -105,7 +106,7 @@ static av_cold int ptx_end(AVCodecContext *avctx) {
return 0;
}
-AVCodec ptx_decoder = {
+AVCodec ff_ptx_decoder = {
"ptx",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_PTX,
diff --git a/lib/ffmpeg/libavcodec/qcelpdec.c b/lib/ffmpeg/libavcodec/qcelpdec.c
index 0441e1fcae..3ed821c81e 100644
--- a/lib/ffmpeg/libavcodec/qcelpdec.c
+++ b/lib/ffmpeg/libavcodec/qcelpdec.c
@@ -92,7 +92,7 @@ static av_cold int qcelp_decode_init(AVCodecContext *avctx)
QCELPContext *q = avctx->priv_data;
int i;
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
for(i=0; i<10; i++)
q->prev_lspf[i] = (i+1)/11.;
@@ -842,7 +842,7 @@ erasure:
return *data_size;
}
-AVCodec qcelp_decoder =
+AVCodec ff_qcelp_decoder =
{
.name = "qcelp",
.type = AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/qdm2.c b/lib/ffmpeg/libavcodec/qdm2.c
index 87dd0717e8..3779b8e3aa 100644
--- a/lib/ffmpeg/libavcodec/qdm2.c
+++ b/lib/ffmpeg/libavcodec/qdm2.c
@@ -1209,7 +1209,8 @@ static void qdm2_decode_super_block (QDM2Context *q)
init_get_bits(&gb, header.data, header.size*8);
if (header.type == 2 || header.type == 4 || header.type == 5) {
- int csum = 257 * get_bits(&gb, 8) + 2 * get_bits(&gb, 8);
+ int csum = 257 * get_bits(&gb, 8);
+ csum += 2 * get_bits(&gb, 8);
csum = qdm2_packet_checksum(q->compressed_data, q->checksum_size, csum);
@@ -1865,7 +1866,7 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
qdm2_init(s);
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
// dump_context(s);
return 0;
@@ -1882,7 +1883,7 @@ static av_cold int qdm2_decode_close(AVCodecContext *avctx)
}
-static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
+static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
{
int ch, i;
const int frame_size = (q->frame_size * q->channels);
@@ -1918,7 +1919,7 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {
SAMPLES_NEEDED_2("has errors, and C list is not empty")
- return;
+ return -1;
}
}
@@ -1939,6 +1940,8 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
out[i] = value;
}
+
+ return 0;
}
@@ -1949,28 +1952,29 @@ static int qdm2_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
QDM2Context *s = avctx->priv_data;
+ int16_t *out = data;
+ int i;
if(!buf)
return 0;
if(buf_size < s->checksum_size)
return -1;
- *data_size = s->channels * s->frame_size * sizeof(int16_t);
-
av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n",
buf_size, buf, s->checksum_size, data, *data_size);
- qdm2_decode(s, buf, data);
-
- // reading only when next superblock found
- if (s->sub_packet == 0) {
- return s->checksum_size;
+ for (i = 0; i < 16; i++) {
+ if (qdm2_decode(s, buf, out) < 0)
+ return -1;
+ out += s->channels * s->frame_size;
}
- return 0;
+ *data_size = (uint8_t*)out - (uint8_t*)data;
+
+ return s->checksum_size;
}
-AVCodec qdm2_decoder =
+AVCodec ff_qdm2_decoder =
{
.name = "qdm2",
.type = AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/qdrw.c b/lib/ffmpeg/libavcodec/qdrw.c
index 57500580e2..be47b4228b 100644
--- a/lib/ffmpeg/libavcodec/qdrw.c
+++ b/lib/ffmpeg/libavcodec/qdrw.c
@@ -150,7 +150,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec qdraw_decoder = {
+AVCodec ff_qdraw_decoder = {
"qdraw",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_QDRAW,
diff --git a/lib/ffmpeg/libavcodec/qpeg.c b/lib/ffmpeg/libavcodec/qpeg.c
index e6a0b30aef..e4c2291f39 100644
--- a/lib/ffmpeg/libavcodec/qpeg.c
+++ b/lib/ffmpeg/libavcodec/qpeg.c
@@ -311,7 +311,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec qpeg_decoder = {
+AVCodec ff_qpeg_decoder = {
"qpeg",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_QPEG,
diff --git a/lib/ffmpeg/libavcodec/qtrle.c b/lib/ffmpeg/libavcodec/qtrle.c
index 1fd9a803e4..8ad6778299 100644
--- a/lib/ffmpeg/libavcodec/qtrle.c
+++ b/lib/ffmpeg/libavcodec/qtrle.c
@@ -537,7 +537,7 @@ static av_cold int qtrle_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec qtrle_decoder = {
+AVCodec ff_qtrle_decoder = {
"qtrle",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_QTRLE,
diff --git a/lib/ffmpeg/libavcodec/qtrleenc.c b/lib/ffmpeg/libavcodec/qtrleenc.c
index 6cc7a556f3..78149e5ed8 100644
--- a/lib/ffmpeg/libavcodec/qtrleenc.c
+++ b/lib/ffmpeg/libavcodec/qtrleenc.c
@@ -22,6 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
@@ -62,7 +63,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx)
{
QtrleEncContext *s = avctx->priv_data;
- if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+ if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
return -1;
}
s->avctx=avctx;
@@ -320,7 +321,7 @@ static av_cold int qtrle_encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec qtrle_encoder = {
+AVCodec ff_qtrle_encoder = {
"qtrle",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_QTRLE,
diff --git a/lib/ffmpeg/libavcodec/r210dec.c b/lib/ffmpeg/libavcodec/r210dec.c
index cf04070697..a5222b17fc 100644
--- a/lib/ffmpeg/libavcodec/r210dec.c
+++ b/lib/ffmpeg/libavcodec/r210dec.c
@@ -63,9 +63,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
for (w = 0; w < avctx->width; w++) {
uint32_t pixel = av_be2ne32(*src++);
uint16_t r, g, b;
- b = pixel << 6;
- g = (pixel >> 4) & 0xffc0;
- r = (pixel >> 14) & 0xffc0;
+ if (avctx->codec_id==CODEC_ID_R210) {
+ b = pixel << 6;
+ g = (pixel >> 4) & 0xffc0;
+ r = (pixel >> 14) & 0xffc0;
+ } else {
+ b = pixel << 4;
+ g = (pixel >> 6) & 0xffc0;
+ r = (pixel >> 16) & 0xffc0;
+ }
*dst++ = r | (r >> 10);
*dst++ = g | (g >> 10);
*dst++ = b | (b >> 10);
@@ -90,7 +96,8 @@ static av_cold int decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec r210_decoder = {
+#if CONFIG_R210_DECODER
+AVCodec ff_r210_decoder = {
"r210",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_R210,
@@ -102,3 +109,18 @@ AVCodec r210_decoder = {
CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"),
};
+#endif
+#if CONFIG_R10K_DECODER
+AVCodec ff_r10k_decoder = {
+ "r10k",
+ AVMEDIA_TYPE_VIDEO,
+ CODEC_ID_R10K,
+ 0,
+ decode_init,
+ NULL,
+ decode_close,
+ decode_frame,
+ CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"),
+};
+#endif
diff --git a/lib/ffmpeg/libavcodec/ra144.c b/lib/ffmpeg/libavcodec/ra144.c
index 35b7921ec4..9baa06850f 100644
--- a/lib/ffmpeg/libavcodec/ra144.c
+++ b/lib/ffmpeg/libavcodec/ra144.c
@@ -1503,8 +1503,8 @@ const int16_t * const ff_lpc_refl_cb[10]={
lpc_refl_cb6, lpc_refl_cb7, lpc_refl_cb8, lpc_refl_cb9, lpc_refl_cb10
};
-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)
+static 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];
diff --git a/lib/ffmpeg/libavcodec/ra144.h b/lib/ffmpeg/libavcodec/ra144.h
index 536b5bbe72..722b42e68a 100644
--- a/lib/ffmpeg/libavcodec/ra144.h
+++ b/lib/ffmpeg/libavcodec/ra144.h
@@ -23,7 +23,7 @@
#define AVCODEC_RA144_H
#include <stdint.h>
-#include "dsputil.h"
+#include "lpc.h"
#define NBLOCKS 4 ///< number of subblocks within a block
#define BLOCKSIZE 40 ///< subblock size in 16-bit words
@@ -34,7 +34,7 @@
typedef struct {
AVCodecContext *avctx;
- DSPContext dsp;
+ LPCContext lpc_ctx;
unsigned int old_energy; ///< previous frame energy
@@ -56,8 +56,6 @@ typedef struct {
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);
diff --git a/lib/ffmpeg/libavcodec/ra144dec.c b/lib/ffmpeg/libavcodec/ra144dec.c
index 5b391d4675..53f529d6b4 100644
--- a/lib/ffmpeg/libavcodec/ra144dec.c
+++ b/lib/ffmpeg/libavcodec/ra144dec.c
@@ -37,7 +37,7 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx)
ractx->lpc_coef[0] = ractx->lpc_tables[0];
ractx->lpc_coef[1] = ractx->lpc_tables[1];
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -114,7 +114,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
return 20;
}
-AVCodec ra_144_decoder =
+AVCodec ff_ra_144_decoder =
{
"real_144",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/ra144enc.c b/lib/ffmpeg/libavcodec/ra144enc.c
index 9e2cf36c2d..a0912056d7 100644
--- a/lib/ffmpeg/libavcodec/ra144enc.c
+++ b/lib/ffmpeg/libavcodec/ra144enc.c
@@ -29,7 +29,6 @@
#include "avcodec.h"
#include "put_bits.h"
-#include "lpc.h"
#include "celp_filters.h"
#include "ra144.h"
@@ -37,8 +36,9 @@
static av_cold int ra144_encode_init(AVCodecContext * avctx)
{
RA144Context *ractx;
+ int ret;
- if (avctx->sample_fmt != SAMPLE_FMT_S16) {
+ if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
av_log(avctx, AV_LOG_ERROR, "invalid sample format\n");
return -1;
}
@@ -53,7 +53,16 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx)
ractx->lpc_coef[0] = ractx->lpc_tables[0];
ractx->lpc_coef[1] = ractx->lpc_tables[1];
ractx->avctx = avctx;
- dsputil_init(&ractx->dsp, avctx);
+ ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
+ AV_LPC_TYPE_LEVINSON);
+ return ret;
+}
+
+
+static av_cold int ra144_encode_close(AVCodecContext *avctx)
+{
+ RA144Context *ractx = avctx->priv_data;
+ ff_lpc_end(&ractx->lpc_ctx);
return 0;
}
@@ -451,7 +460,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame,
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,
+ ff_lpc_calc_coefs(&ractx->lpc_ctx, 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++)
@@ -499,13 +508,14 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame,
}
-AVCodec ra_144_encoder =
+AVCodec ff_ra_144_encoder =
{
"real_144",
- CODEC_TYPE_AUDIO,
+ AVMEDIA_TYPE_AUDIO,
CODEC_ID_RA_144,
sizeof(RA144Context),
ra144_encode_init,
ra144_encode_frame,
+ ra144_encode_close,
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"),
};
diff --git a/lib/ffmpeg/libavcodec/ra288.c b/lib/ffmpeg/libavcodec/ra288.c
index bfc62e1ffa..9445e7088e 100644
--- a/lib/ffmpeg/libavcodec/ra288.c
+++ b/lib/ffmpeg/libavcodec/ra288.c
@@ -54,7 +54,7 @@ typedef struct {
static av_cold int ra288_decode_init(AVCodecContext *avctx)
{
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
return 0;
}
@@ -203,7 +203,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,
return avctx->block_align;
}
-AVCodec ra_288_decoder =
+AVCodec ff_ra_288_decoder =
{
"real_288",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/ratecontrol.c b/lib/ffmpeg/libavcodec/ratecontrol.c
index 4261678087..1fe947fa9c 100644
--- a/lib/ffmpeg/libavcodec/ratecontrol.c
+++ b/lib/ffmpeg/libavcodec/ratecontrol.c
@@ -106,7 +106,7 @@ int ff_rate_control_init(MpegEncContext *s)
};
emms_c();
- res = av_parse_expr(&rcc->rc_eq_eval, s->avctx->rc_eq ? s->avctx->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx);
+ res = av_expr_parse(&rcc->rc_eq_eval, s->avctx->rc_eq ? s->avctx->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx);
if (res < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->avctx->rc_eq);
return res;
@@ -254,7 +254,7 @@ void ff_rate_control_uninit(MpegEncContext *s)
RateControlContext *rcc= &s->rc_context;
emms_c();
- av_free_expr(rcc->rc_eq_eval);
+ av_expr_free(rcc->rc_eq_eval);
av_freep(&rcc->entry);
#if CONFIG_LIBXVID
@@ -338,7 +338,7 @@ static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_f
0
};
- bits = av_eval_expr(rcc->rc_eq_eval, const_values, rce);
+ bits = av_expr_eval(rcc->rc_eq_eval, const_values, rce);
if (isnan(bits)) {
av_log(s->avctx, AV_LOG_ERROR, "Error evaluating rc_eq \"%s\"\n", s->avctx->rc_eq);
return -1;
diff --git a/lib/ffmpeg/libavcodec/rawdec.c b/lib/ffmpeg/libavcodec/rawdec.c
index ce1febbf94..29cc5e44d8 100644
--- a/lib/ffmpeg/libavcodec/rawdec.c
+++ b/lib/ffmpeg/libavcodec/rawdec.c
@@ -25,10 +25,14 @@
*/
#include "avcodec.h"
+#include "imgconvert.h"
#include "raw.h"
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
+#include "libavcore/internal.h"
typedef struct RawVideoContext {
+ uint32_t palette[AVPALETTE_COUNT];
unsigned char * buffer; /* block of memory for holding one frame */
int length; /* number of bytes in buffer */
int flip;
@@ -80,16 +84,20 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
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);
+ ff_set_systematic_pal2(context->palette, avctx->pix_fmt);
context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
- context->buffer = av_malloc(context->length);
+ if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
+ avctx->pix_fmt==PIX_FMT_PAL8 &&
+ (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){
+ context->buffer = av_malloc(context->length);
+ if (!context->buffer)
+ return -1;
+ }
context->pic.pict_type = FF_I_TYPE;
context->pic.key_frame = 1;
avctx->coded_frame= &context->pic;
- if (!context->buffer)
- return -1;
-
if((avctx->extradata_size >= 9 && !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9)) ||
avctx->codec_tag == MKTAG( 3 , 0 , 0 , 0 ))
context->flip=1;
@@ -115,13 +123,13 @@ static int raw_decode(AVCodecContext *avctx,
frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
frame->top_field_first = avctx->coded_frame->top_field_first;
+ frame->reordered_opaque = avctx->reordered_opaque;
+ frame->pkt_pts = avctx->pkt->pts;
//2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
- if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
- avctx->pix_fmt==PIX_FMT_PAL8 &&
- (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){
+ if (context->buffer) {
int i;
- uint8_t *dst = context->buffer + 256*4;
+ uint8_t *dst = context->buffer;
buf_size = context->length - 256*4;
if (avctx->bits_per_coded_sample == 4){
for(i=0; 2*i+1 < buf_size; i++){
@@ -146,8 +154,10 @@ static int raw_decode(AVCodecContext *avctx,
return -1;
avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
- if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){
- frame->data[1]= context->buffer;
+ if((avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length) ||
+ (avctx->pix_fmt!=PIX_FMT_PAL8 &&
+ (av_pix_fmt_descriptors[avctx->pix_fmt].flags & PIX_FMT_PAL))){
+ frame->data[1]= context->palette;
}
if (avctx->palctrl && avctx->palctrl->palette_changed) {
memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE);
@@ -186,7 +196,7 @@ static av_cold int raw_close_decoder(AVCodecContext *avctx)
return 0;
}
-AVCodec rawvideo_decoder = {
+AVCodec ff_rawvideo_decoder = {
"rawvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RAWVIDEO,
diff --git a/lib/ffmpeg/libavcodec/rawenc.c b/lib/ffmpeg/libavcodec/rawenc.c
index 419970486b..630df0f723 100644
--- a/lib/ffmpeg/libavcodec/rawenc.c
+++ b/lib/ffmpeg/libavcodec/rawenc.c
@@ -55,7 +55,7 @@ static int raw_encode(AVCodecContext *avctx,
return ret;
}
-AVCodec rawvideo_encoder = {
+AVCodec ff_rawvideo_encoder = {
"rawvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RAWVIDEO,
diff --git a/lib/ffmpeg/libavcodec/rdft.c b/lib/ffmpeg/libavcodec/rdft.c
index f37263b7c2..59b4624716 100644
--- a/lib/ffmpeg/libavcodec/rdft.c
+++ b/lib/ffmpeg/libavcodec/rdft.c
@@ -44,7 +44,7 @@ SINTABLE(16384);
SINTABLE(32768);
SINTABLE(65536);
#endif
-SINTABLE_CONST FFTSample * const ff_sin_tabs[] = {
+static SINTABLE_CONST FFTSample * const ff_sin_tabs[] = {
NULL, NULL, NULL, NULL,
ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024,
ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,
diff --git a/lib/ffmpeg/libavcodec/remove_extradata_bsf.c b/lib/ffmpeg/libavcodec/remove_extradata_bsf.c
index 95bd98bef2..f0d9b4513a 100644
--- a/lib/ffmpeg/libavcodec/remove_extradata_bsf.c
+++ b/lib/ffmpeg/libavcodec/remove_extradata_bsf.c
@@ -48,7 +48,7 @@ static int remove_extradata(AVBitStreamFilterContext *bsfc, AVCodecContext *avct
return 0;
}
-AVBitStreamFilter remove_extradata_bsf={
+AVBitStreamFilter ff_remove_extradata_bsf={
"remove_extra",
0,
remove_extradata,
diff --git a/lib/ffmpeg/libavcodec/resample.c b/lib/ffmpeg/libavcodec/resample.c
index b008180fe5..272831520d 100644
--- a/lib/ffmpeg/libavcodec/resample.c
+++ b/lib/ffmpeg/libavcodec/resample.c
@@ -26,7 +26,8 @@
#include "avcodec.h"
#include "audioconvert.h"
-#include "opt.h"
+#include "libavutil/opt.h"
+#include "libavcore/samplefmt.h"
struct AVResampleContext;
@@ -46,7 +47,7 @@ struct ReSampleContext {
/* channel convert */
int input_channels, output_channels, filter_channels;
AVAudioConvert *convert_ctx[2];
- enum SampleFormat sample_fmt[2]; ///< input and output sample format
+ enum AVSampleFormat sample_fmt[2]; ///< input and output sample format
unsigned sample_size[2]; ///< size of one sample in sample_fmt
short *buffer[2]; ///< buffers used for conversion to S16
unsigned buffer_size[2]; ///< sizes of allocated buffers
@@ -143,8 +144,8 @@ static void ac3_5p1_mux(short *output, short *input1, short *input2, int n)
ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
int output_rate, int input_rate,
- enum SampleFormat sample_fmt_out,
- enum SampleFormat sample_fmt_in,
+ enum AVSampleFormat sample_fmt_out,
+ enum AVSampleFormat sample_fmt_in,
int filter_length, int log2_phase_count,
int linear, double cutoff)
{
@@ -174,26 +175,26 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
s->sample_fmt [0] = sample_fmt_in;
s->sample_fmt [1] = sample_fmt_out;
- s->sample_size[0] = av_get_bits_per_sample_format(s->sample_fmt[0])>>3;
- s->sample_size[1] = av_get_bits_per_sample_format(s->sample_fmt[1])>>3;
+ s->sample_size[0] = av_get_bits_per_sample_fmt(s->sample_fmt[0])>>3;
+ s->sample_size[1] = av_get_bits_per_sample_fmt(s->sample_fmt[1])>>3;
- if (s->sample_fmt[0] != SAMPLE_FMT_S16) {
- if (!(s->convert_ctx[0] = av_audio_convert_alloc(SAMPLE_FMT_S16, 1,
+ if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) {
+ if (!(s->convert_ctx[0] = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1,
s->sample_fmt[0], 1, NULL, 0))) {
av_log(s, AV_LOG_ERROR,
"Cannot convert %s sample format to s16 sample format\n",
- avcodec_get_sample_fmt_name(s->sample_fmt[0]));
+ av_get_sample_fmt_name(s->sample_fmt[0]));
av_free(s);
return NULL;
}
}
- if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
+ if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) {
if (!(s->convert_ctx[1] = av_audio_convert_alloc(s->sample_fmt[1], 1,
- SAMPLE_FMT_S16, 1, NULL, 0))) {
+ AV_SAMPLE_FMT_S16, 1, NULL, 0))) {
av_log(s, AV_LOG_ERROR,
"Cannot convert s16 sample format to %s sample format\n",
- avcodec_get_sample_fmt_name(s->sample_fmt[1]));
+ av_get_sample_fmt_name(s->sample_fmt[1]));
av_audio_convert_free(s->convert_ctx[0]);
av_free(s);
return NULL;
@@ -217,13 +218,13 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
return s;
}
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_AUDIO_OLD
ReSampleContext *audio_resample_init(int output_channels, int input_channels,
int output_rate, int input_rate)
{
return av_audio_resample_init(output_channels, input_channels,
output_rate, input_rate,
- SAMPLE_FMT_S16, SAMPLE_FMT_S16,
+ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16,
TAPS, 10, 0, 0.8);
}
#endif
@@ -245,7 +246,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
return nb_samples;
}
- if (s->sample_fmt[0] != SAMPLE_FMT_S16) {
+ if (s->sample_fmt[0] != AV_SAMPLE_FMT_S16) {
int istride[1] = { s->sample_size[0] };
int ostride[1] = { 2 };
const void *ibuf[1] = { input };
@@ -275,7 +276,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
lenout= 4*nb_samples * s->ratio + 16;
- if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
+ if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) {
output_bak = output;
if (!s->buffer_size[1] || s->buffer_size[1] < lenout) {
@@ -340,7 +341,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
}
- if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
+ if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) {
int istride[1] = { 2 };
int ostride[1] = { s->sample_size[1] };
const void *ibuf[1] = { output };
diff --git a/lib/ffmpeg/libavcodec/rl2.c b/lib/ffmpeg/libavcodec/rl2.c
index 1174c35d51..19104144a2 100644
--- a/lib/ffmpeg/libavcodec/rl2.c
+++ b/lib/ffmpeg/libavcodec/rl2.c
@@ -169,15 +169,6 @@ static av_cold int rl2_decode_init(AVCodecContext *avctx)
}
-/**
- * Decode a single frame
- * @param avctx decoder context
- * @param data decoded frame
- * @param data_size size of the decoded frame
- * @param buf input buffer
- * @param buf_size input buffer size
- * @return 0 success, -1 on error
- */
static int rl2_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
@@ -228,7 +219,7 @@ static av_cold int rl2_decode_end(AVCodecContext *avctx)
}
-AVCodec rl2_decoder = {
+AVCodec ff_rl2_decoder = {
"rl2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RL2,
diff --git a/lib/ffmpeg/libavcodec/roqaudioenc.c b/lib/ffmpeg/libavcodec/roqaudioenc.c
index 11fd6f06cb..f6bd726c4f 100644
--- a/lib/ffmpeg/libavcodec/roqaudioenc.c
+++ b/lib/ffmpeg/libavcodec/roqaudioenc.c
@@ -49,7 +49,7 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Audio must be 22050 Hz\n");
return -1;
}
- if (avctx->sample_fmt != SAMPLE_FMT_S16) {
+ if (avctx->sample_fmt != AV_SAMPLE_FMT_S16) {
av_log(avctx, AV_LOG_ERROR, "Audio must be signed 16-bit\n");
return -1;
}
@@ -108,7 +108,7 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data)
{
int i, samples, stereo, ch;
- short *in;
+ const short *in;
unsigned char *out;
ROQDPCMContext *context = avctx->priv_data;
@@ -153,7 +153,7 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec roq_dpcm_encoder = {
+AVCodec ff_roq_dpcm_encoder = {
"roq_dpcm",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_ROQ_DPCM,
@@ -162,6 +162,6 @@ AVCodec roq_dpcm_encoder = {
roq_dpcm_encode_frame,
roq_dpcm_encode_close,
NULL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("id RoQ DPCM"),
};
diff --git a/lib/ffmpeg/libavcodec/roqvideo.c b/lib/ffmpeg/libavcodec/roqvideo.c
index 830eb7b329..eb8fc253ad 100644
--- a/lib/ffmpeg/libavcodec/roqvideo.c
+++ b/lib/ffmpeg/libavcodec/roqvideo.c
@@ -115,6 +115,11 @@ static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax
return;
}
+ if (ri->last_frame->data[0] == NULL) {
+ av_log(ri->avctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
+ return;
+ }
+
for(cp = 0; cp < 3; cp++) {
int outstride = ri->current_frame->linesize[cp];
int instride = ri->last_frame ->linesize[cp];
diff --git a/lib/ffmpeg/libavcodec/roqvideodec.c b/lib/ffmpeg/libavcodec/roqvideodec.c
index 7c6f5ff6fb..4959239ba7 100644
--- a/lib/ffmpeg/libavcodec/roqvideodec.c
+++ b/lib/ffmpeg/libavcodec/roqvideodec.c
@@ -210,7 +210,7 @@ static av_cold int roq_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec roq_decoder = {
+AVCodec ff_roq_decoder = {
"roqvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ROQ,
diff --git a/lib/ffmpeg/libavcodec/roqvideoenc.c b/lib/ffmpeg/libavcodec/roqvideoenc.c
index 28fd9d8512..0efbca8742 100644
--- a/lib/ffmpeg/libavcodec/roqvideoenc.c
+++ b/lib/ffmpeg/libavcodec/roqvideoenc.c
@@ -1054,7 +1054,7 @@ static int roq_encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec roq_encoder =
+AVCodec ff_roq_encoder =
{
"roqvideo",
AVMEDIA_TYPE_VIDEO,
diff --git a/lib/ffmpeg/libavcodec/rpza.c b/lib/ffmpeg/libavcodec/rpza.c
index e103f525d2..6a79d97e86 100644
--- a/lib/ffmpeg/libavcodec/rpza.c
+++ b/lib/ffmpeg/libavcodec/rpza.c
@@ -275,7 +275,7 @@ static av_cold int rpza_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec rpza_decoder = {
+AVCodec ff_rpza_decoder = {
"rpza",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RPZA,
diff --git a/lib/ffmpeg/libavcodec/rv10.c b/lib/ffmpeg/libavcodec/rv10.c
index e9face622b..f47540d8f1 100644
--- a/lib/ffmpeg/libavcodec/rv10.c
+++ b/lib/ffmpeg/libavcodec/rv10.c
@@ -25,6 +25,7 @@
* RV10/RV20 decoder
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -245,7 +246,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
if(!marker) av_log(s->avctx, AV_LOG_ERROR, "marker missing\n");
pb_frame = get_bits1(&s->gb);
- dprintf(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
+ av_dlog(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
if (pb_frame){
av_log(s->avctx, AV_LOG_ERROR, "pb frame not supported\n");
@@ -264,7 +265,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
s->last_dc[0] = get_bits(&s->gb, 8);
s->last_dc[1] = get_bits(&s->gb, 8);
s->last_dc[2] = get_bits(&s->gb, 8);
- dprintf(s->avctx, "DC:%d %d %d\n", s->last_dc[0],
+ av_dlog(s->avctx, "DC:%d %d %d\n", s->last_dc[0],
s->last_dc[1], s->last_dc[2]);
}
}
@@ -369,7 +370,7 @@ static int rv20_decode_picture_header(MpegEncContext *s)
}
if(new_w != s->width || new_h != s->height){
av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
- if (avcodec_check_dimensions(s->avctx, new_w, new_h) < 0)
+ if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
return -1;
MPV_common_end(s);
avcodec_set_dimensions(s->avctx, new_w, new_h);
@@ -560,7 +561,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
ff_er_frame_start(s);
}
- dprintf(avctx, "qscale=%d\n", s->qscale);
+ av_dlog(avctx, "qscale=%d\n", s->qscale);
/* default quantization values */
if(s->codec_id== CODEC_ID_RV10){
@@ -599,7 +600,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
for(s->mb_num_left= mb_count; s->mb_num_left>0; s->mb_num_left--) {
int ret;
ff_update_block_index(s);
- dprintf(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
+ av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
@@ -654,7 +655,7 @@ static int rv10_decode_frame(AVCodecContext *avctx,
int slice_count;
const uint8_t *slices_hdr = NULL;
- dprintf(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
+ av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
/* no supplementary picture */
if (buf_size == 0) {
@@ -706,7 +707,7 @@ static int rv10_decode_frame(AVCodecContext *avctx,
return buf_size;
}
-AVCodec rv10_decoder = {
+AVCodec ff_rv10_decoder = {
"rv10",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RV10,
@@ -721,7 +722,7 @@ AVCodec rv10_decoder = {
.pix_fmts= ff_pixfmt_list_420,
};
-AVCodec rv20_decoder = {
+AVCodec ff_rv20_decoder = {
"rv20",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RV20,
diff --git a/lib/ffmpeg/libavcodec/rv10enc.c b/lib/ffmpeg/libavcodec/rv10enc.c
index 51ca69118a..206fe13225 100644
--- a/lib/ffmpeg/libavcodec/rv10enc.c
+++ b/lib/ffmpeg/libavcodec/rv10enc.c
@@ -56,7 +56,7 @@ void rv10_encode_picture_header(MpegEncContext *s, int picture_number)
put_bits(&s->pb, 3, 0); /* ignored */
}
-AVCodec rv10_encoder = {
+AVCodec ff_rv10_encoder = {
"rv10",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RV10,
diff --git a/lib/ffmpeg/libavcodec/rv20enc.c b/lib/ffmpeg/libavcodec/rv20enc.c
index 5ab0b9a039..fe26dd486d 100644
--- a/lib/ffmpeg/libavcodec/rv20enc.c
+++ b/lib/ffmpeg/libavcodec/rv20enc.c
@@ -41,7 +41,7 @@ void rv20_encode_picture_header(MpegEncContext *s, int picture_number){
put_bits(&s->pb, 1, s->no_rounding);
assert(s->f_code == 1);
- assert(s->unrestricted_mv == 1);
+ assert(s->unrestricted_mv == 0);
assert(s->alt_inter_vlc == 0);
assert(s->umvplus == 0);
assert(s->modified_quant==1);
@@ -57,7 +57,7 @@ void rv20_encode_picture_header(MpegEncContext *s, int picture_number){
}
}
-AVCodec rv20_encoder = {
+AVCodec ff_rv20_encoder = {
"rv20",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RV20,
diff --git a/lib/ffmpeg/libavcodec/rv30.c b/lib/ffmpeg/libavcodec/rv30.c
index 22a5dd5b64..38b600af80 100644
--- a/lib/ffmpeg/libavcodec/rv30.c
+++ b/lib/ffmpeg/libavcodec/rv30.c
@@ -266,7 +266,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx)
return 0;
}
-AVCodec rv30_decoder = {
+AVCodec ff_rv30_decoder = {
"rv30",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RV30,
diff --git a/lib/ffmpeg/libavcodec/rv34.c b/lib/ffmpeg/libavcodec/rv34.c
index b586aa0b86..08fa8a90ff 100644
--- a/lib/ffmpeg/libavcodec/rv34.c
+++ b/lib/ffmpeg/libavcodec/rv34.c
@@ -718,12 +718,12 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
uint8_t *uvbuf= s->edge_emu_buffer + 22 * s->linesize;
srcY -= 2 + 2*s->linesize;
- ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, (width<<3)+6, (height<<3)+6,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, (width<<3)+6, (height<<3)+6,
src_x - 2, src_y - 2, s->h_edge_pos, s->v_edge_pos);
srcY = s->edge_emu_buffer + 2 + 2*s->linesize;
- ff_emulated_edge_mc(uvbuf , srcU, s->uvlinesize, (width<<2)+1, (height<<2)+1,
+ s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, (width<<2)+1, (height<<2)+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- ff_emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, (width<<2)+1, (height<<2)+1,
+ s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, (width<<2)+1, (height<<2)+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
srcU = uvbuf;
srcV = uvbuf + 16;
diff --git a/lib/ffmpeg/libavcodec/rv40.c b/lib/ffmpeg/libavcodec/rv40.c
index e4a46c1889..acebeb7da5 100644
--- a/lib/ffmpeg/libavcodec/rv40.c
+++ b/lib/ffmpeg/libavcodec/rv40.c
@@ -24,6 +24,8 @@
* RV40 decoder
*/
+#include "libavcore/imgutils.h"
+
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -142,7 +144,7 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn
si->pts = get_bits(gb, 13);
if(!si->type || !get_bits1(gb))
rv40_parse_picture_size(gb, &w, &h);
- if(avcodec_check_dimensions(r->s.avctx, w, h) < 0)
+ if(av_image_check_size(w, h, 0, r->s.avctx) < 0)
return -1;
si->width = w;
si->height = h;
@@ -666,7 +668,7 @@ static av_cold int rv40_decode_init(AVCodecContext *avctx)
return 0;
}
-AVCodec rv40_decoder = {
+AVCodec ff_rv40_decoder = {
"rv40",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_RV40,
diff --git a/lib/ffmpeg/libavcodec/sgidec.c b/lib/ffmpeg/libavcodec/sgidec.c
index bbfd94bdf0..ac2adfe7ca 100644
--- a/lib/ffmpeg/libavcodec/sgidec.c
+++ b/lib/ffmpeg/libavcodec/sgidec.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "sgi.h"
@@ -201,7 +202,7 @@ static int decode_frame(AVCodecContext *avctx,
return -1;
}
- if (avcodec_check_dimensions(avctx, s->width, s->height))
+ if (av_image_check_size(s->width, s->height, 0, avctx))
return -1;
avcodec_set_dimensions(avctx, s->width, s->height);
@@ -258,7 +259,7 @@ static av_cold int sgi_end(AVCodecContext *avctx)
return 0;
}
-AVCodec sgi_decoder = {
+AVCodec ff_sgi_decoder = {
"sgi",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SGI,
diff --git a/lib/ffmpeg/libavcodec/sgienc.c b/lib/ffmpeg/libavcodec/sgienc.c
index f9f3709788..eafb655b46 100644
--- a/lib/ffmpeg/libavcodec/sgienc.c
+++ b/lib/ffmpeg/libavcodec/sgienc.c
@@ -159,7 +159,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
return buf - orig_buf;
}
-AVCodec sgi_encoder = {
+AVCodec ff_sgi_encoder = {
"sgi",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SGI,
diff --git a/lib/ffmpeg/libavcodec/shorten.c b/lib/ffmpeg/libavcodec/shorten.c
index 213e5b39b7..f50da4e87f 100644
--- a/lib/ffmpeg/libavcodec/shorten.c
+++ b/lib/ffmpeg/libavcodec/shorten.c
@@ -105,7 +105,7 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx)
{
ShortenContext *s = avctx->priv_data;
s->avctx = avctx;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -305,7 +305,7 @@ static int shorten_decode_frame(AVCodecContext *avctx,
s->bitstream_size= buf_size;
if(buf_size < s->max_framesize){
- //dprintf(avctx, "wanna more data ... %d\n", buf_size);
+ //av_dlog(avctx, "wanna more data ... %d\n", buf_size);
*data_size = 0;
return input_buf_size;
}
@@ -541,7 +541,7 @@ static void shorten_flush(AVCodecContext *avctx){
s->bitstream_index= 0;
}
-AVCodec shorten_decoder = {
+AVCodec ff_shorten_decoder = {
"shorten",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SHORTEN,
diff --git a/lib/ffmpeg/libavcodec/sipr.c b/lib/ffmpeg/libavcodec/sipr.c
index aa798340bb..b96e3b9024 100644
--- a/lib/ffmpeg/libavcodec/sipr.c
+++ b/lib/ffmpeg/libavcodec/sipr.c
@@ -209,32 +209,6 @@ static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
}
}
-static void lsp2lpc_sipr(const double *lsp, float *Az)
-{
- int lp_half_order = LP_FILTER_ORDER >> 1;
- double buf[(LP_FILTER_ORDER >> 1) + 1];
- double pa[(LP_FILTER_ORDER >> 1) + 1];
- double *qa = buf + 1;
- int i,j;
-
- qa[-1] = 0.0;
-
- ff_lsp2polyf(lsp , pa, lp_half_order );
- ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
-
- for (i = 1, j = LP_FILTER_ORDER - 1; i < lp_half_order; i++, j--) {
- double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER - 1]);
- double qaf = (qa[i] - qa[i-2]) * (1 - lsp[LP_FILTER_ORDER - 1]);
- Az[i-1] = (paf + qaf) * 0.5;
- Az[j-1] = (paf - qaf) * 0.5;
- }
-
- Az[lp_half_order - 1] = (1.0 + lsp[LP_FILTER_ORDER - 1]) *
- pa[lp_half_order] * 0.5;
-
- Az[LP_FILTER_ORDER - 1] = lsp[LP_FILTER_ORDER - 1];
-}
-
static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
int num_subfr)
{
@@ -247,7 +221,7 @@ static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
for (j = 0; j < LP_FILTER_ORDER; j++)
lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
- lsp2lpc_sipr(lsfint, Az);
+ ff_amrwb_lsp2lpc(lsfint, Az, LP_FILTER_ORDER);
Az += LP_FILTER_ORDER;
t += t0;
}
@@ -519,7 +493,7 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx)
for (i = 0; i < 4; i++)
ctx->energy_history[i] = -14;
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
dsputil_init(&ctx->dsp, avctx);
@@ -573,9 +547,9 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
mode_par->subframe_count * sizeof(float);
return mode_par->bits_per_frame >> 3;
-};
+}
-AVCodec sipr_decoder = {
+AVCodec ff_sipr_decoder = {
"sipr",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SIPR,
diff --git a/lib/ffmpeg/libavcodec/smacker.c b/lib/ffmpeg/libavcodec/smacker.c
index ac2f76b775..2fcc33511f 100644
--- a/lib/ffmpeg/libavcodec/smacker.c
+++ b/lib/ffmpeg/libavcodec/smacker.c
@@ -555,7 +555,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int smka_decode_init(AVCodecContext *avctx)
{
avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
- avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? SAMPLE_FMT_U8 : SAMPLE_FMT_S16;
+ avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;
return 0;
}
@@ -689,7 +689,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
return buf_size;
}
-AVCodec smacker_decoder = {
+AVCodec ff_smacker_decoder = {
"smackvid",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SMACKVIDEO,
@@ -702,7 +702,7 @@ AVCodec smacker_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("Smacker video"),
};
-AVCodec smackaud_decoder = {
+AVCodec ff_smackaud_decoder = {
"smackaud",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SMACKAUDIO,
diff --git a/lib/ffmpeg/libavcodec/smc.c b/lib/ffmpeg/libavcodec/smc.c
index 2e2dffdc86..f8b994c1d1 100644
--- a/lib/ffmpeg/libavcodec/smc.c
+++ b/lib/ffmpeg/libavcodec/smc.c
@@ -471,7 +471,7 @@ static av_cold int smc_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec smc_decoder = {
+AVCodec ff_smc_decoder = {
"smc",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SMC,
diff --git a/lib/ffmpeg/libavcodec/snow.c b/lib/ffmpeg/libavcodec/snow.c
index 18039d2295..9ab9fed71f 100644
--- a/lib/ffmpeg/libavcodec/snow.c
+++ b/lib/ffmpeg/libavcodec/snow.c
@@ -1171,7 +1171,7 @@ static void pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride, i
src += sx + sy*stride;
if( (unsigned)sx >= w - b_w - (HTAPS_MAX-2)
|| (unsigned)sy >= h - b_h - (HTAPS_MAX-2)){
- ff_emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, sx, sy, w, h);
+ s->dsp.emulated_edge_mc(tmp + MB_SIZE, src, stride, b_w+HTAPS_MAX-1, b_h+HTAPS_MAX-1, sx, sy, w, h);
src= tmp + MB_SIZE;
}
// assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h);
@@ -2234,7 +2234,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec snow_decoder = {
+AVCodec ff_snow_decoder = {
"snow",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SNOW,
@@ -3985,7 +3985,7 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec snow_encoder = {
+AVCodec ff_snow_encoder = {
"snow",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SNOW,
diff --git a/lib/ffmpeg/libavcodec/sonic.c b/lib/ffmpeg/libavcodec/sonic.c
index d24931f6fe..8dfac1a6fa 100644
--- a/lib/ffmpeg/libavcodec/sonic.c
+++ b/lib/ffmpeg/libavcodec/sonic.c
@@ -825,7 +825,7 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
}
s->int_samples = av_mallocz(4* s->frame_size);
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -935,7 +935,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
return (get_bits_count(&gb)+7)/8;
}
-AVCodec sonic_decoder = {
+AVCodec ff_sonic_decoder = {
"sonic",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SONIC,
@@ -949,7 +949,7 @@ AVCodec sonic_decoder = {
#endif /* CONFIG_SONIC_DECODER */
#if CONFIG_SONIC_ENCODER
-AVCodec sonic_encoder = {
+AVCodec ff_sonic_encoder = {
"sonic",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SONIC,
@@ -963,7 +963,7 @@ AVCodec sonic_encoder = {
#endif
#if CONFIG_SONIC_LS_ENCODER
-AVCodec sonic_ls_encoder = {
+AVCodec ff_sonic_ls_encoder = {
"sonicls",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_SONIC_LS,
diff --git a/lib/ffmpeg/libavcodec/sp5xdec.c b/lib/ffmpeg/libavcodec/sp5xdec.c
index b047f9c7af..8bcdbe41b4 100644
--- a/lib/ffmpeg/libavcodec/sp5xdec.c
+++ b/lib/ffmpeg/libavcodec/sp5xdec.c
@@ -37,9 +37,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVPacket avpkt_recoded;
-#if 0
- MJpegDecodeContext *s = avctx->priv_data;
-#endif
const int qscale = 5;
const uint8_t *buf_ptr;
uint8_t *recoded;
@@ -50,7 +47,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
buf_ptr = buf;
-#if 1
recoded = av_mallocz(buf_size + 1024);
if (!recoded)
return -1;
@@ -98,102 +94,10 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
av_free(recoded);
-#else
- /* SOF */
- s->bits = 8;
- s->width = avctx->coded_width;
- s->height = avctx->coded_height;
- s->nb_components = 3;
- s->component_id[0] = 0;
- s->h_count[0] = 2;
- s->v_count[0] = 2;
- s->quant_index[0] = 0;
- s->component_id[1] = 1;
- s->h_count[1] = 1;
- s->v_count[1] = 1;
- s->quant_index[1] = 1;
- s->component_id[2] = 2;
- s->h_count[2] = 1;
- s->v_count[2] = 1;
- s->quant_index[2] = 1;
- s->h_max = 2;
- s->v_max = 2;
-
- s->qscale_table = av_mallocz((s->width+15)/16);
- avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420;
- s->interlaced = 0;
-
- s->picture.reference = 0;
- if (avctx->get_buffer(avctx, &s->picture) < 0)
- {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
-
- s->picture.pict_type = FF_I_TYPE;
- s->picture.key_frame = 1;
-
- for (i = 0; i < 3; i++)
- s->linesize[i] = s->picture.linesize[i] << s->interlaced;
-
- /* DQT */
- for (i = 0; i < 64; i++)
- {
- j = s->scantable.permutated[i];
- s->quant_matrixes[0][j] = sp5x_quant_table[(qscale * 2) + i];
- }
- s->qscale[0] = FFMAX(
- s->quant_matrixes[0][s->scantable.permutated[1]],
- s->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;
-
- for (i = 0; i < 64; i++)
- {
- j = s->scantable.permutated[i];
- s->quant_matrixes[1][j] = sp5x_quant_table[(qscale * 2) + 1 + i];
- }
- s->qscale[1] = FFMAX(
- s->quant_matrixes[1][s->scantable.permutated[1]],
- s->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;
-
- /* DHT */
-
- /* SOS */
- s->comp_index[0] = 0;
- s->nb_blocks[0] = s->h_count[0] * s->v_count[0];
- s->h_scount[0] = s->h_count[0];
- s->v_scount[0] = s->v_count[0];
- s->dc_index[0] = 0;
- s->ac_index[0] = 0;
-
- s->comp_index[1] = 1;
- s->nb_blocks[1] = s->h_count[1] * s->v_count[1];
- s->h_scount[1] = s->h_count[1];
- s->v_scount[1] = s->v_count[1];
- s->dc_index[1] = 1;
- s->ac_index[1] = 1;
-
- s->comp_index[2] = 2;
- s->nb_blocks[2] = s->h_count[2] * s->v_count[2];
- s->h_scount[2] = s->h_count[2];
- s->v_scount[2] = s->v_count[2];
- s->dc_index[2] = 1;
- s->ac_index[2] = 1;
-
- for (i = 0; i < 3; i++)
- s->last_dc[i] = 1024;
-
- s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);
- s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);
-
- init_get_bits(&s->gb, buf+14, (buf_size-14)*8);
-
- return mjpeg_decode_scan(s);
-#endif
-
return i;
}
-AVCodec sp5x_decoder = {
+AVCodec ff_sp5x_decoder = {
"sp5x",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SP5X,
@@ -208,7 +112,7 @@ AVCodec sp5x_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
};
-AVCodec amv_decoder = {
+AVCodec ff_amv_decoder = {
"amv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_AMV,
diff --git a/lib/ffmpeg/libavcodec/srtdec.c b/lib/ffmpeg/libavcodec/srtdec.c
new file mode 100644
index 0000000000..30fdc12fe7
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/srtdec.c
@@ -0,0 +1,241 @@
+/*
+ * SubRip subtitle decoder
+ * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavcore/parseutils.h"
+#include "avcodec.h"
+#include "ass.h"
+
+static int html_color_parse(AVCodecContext *avctx, const char *str)
+{
+ uint8_t rgba[4];
+ if (av_parse_color(rgba, str, strcspn(str, "\" >"), avctx) < 0)
+ return -1;
+ return rgba[0] | rgba[1] << 8 | rgba[2] << 16;
+}
+
+enum {
+ PARAM_UNKNOWN = -1,
+ PARAM_SIZE,
+ PARAM_COLOR,
+ PARAM_FACE,
+ PARAM_NUMBER
+};
+
+typedef struct {
+ char tag[128];
+ char param[PARAM_NUMBER][128];
+} SrtStack;
+
+static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
+ const char *in, int x1, int y1, int x2, int y2)
+{
+ char c, *param, buffer[128], tmp[128];
+ int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
+ SrtStack stack[16];
+
+ stack[0].tag[0] = 0;
+ strcpy(stack[0].param[PARAM_SIZE], "{\\fs}");
+ strcpy(stack[0].param[PARAM_COLOR], "{\\c}");
+ strcpy(stack[0].param[PARAM_FACE], "{\\fn}");
+
+ if (x1 >= 0 && y1 >= 0) {
+ if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
+ out += snprintf(out, out_end-out,
+ "{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
+ else
+ out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1);
+ }
+
+ for (; out < out_end && !end && *in; in++) {
+ switch (*in) {
+ case '\r':
+ break;
+ case '\n':
+ if (line_start) {
+ end = 1;
+ break;
+ }
+ while (out[-1] == ' ')
+ out--;
+ out += snprintf(out, out_end-out, "\\N");
+ line_start = 1;
+ break;
+ case ' ':
+ if (!line_start)
+ *out++ = *in;
+ break;
+ case '{': /* skip all {\xxx} substrings except for {\an%d}
+ and all microdvd like styles such as {Y:xxx} */
+ an += sscanf(in, "{\\an%*1u}%c", &c) == 1;
+ if ((an != 1 && sscanf(in, "{\\%*[^}]}%n%c", &len, &c) > 0) ||
+ sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n%c", &len, &c) > 0) {
+ in += len - 1;
+ } else
+ *out++ = *in;
+ break;
+ case '<':
+ tag_close = in[1] == '/';
+ if (sscanf(in+tag_close+1, "%128[^>]>%n%c", buffer, &len,&c) >= 2) {
+ if ((param = strchr(buffer, ' ')))
+ *param++ = 0;
+ if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
+ ( tag_close && sptr > 0 && !strcmp(stack[sptr-1].tag, buffer))) {
+ int i, j, unknown = 0;
+ in += len + tag_close;
+ if (!tag_close)
+ memset(stack+sptr, 0, sizeof(*stack));
+ if (!strcmp(buffer, "font")) {
+ if (tag_close) {
+ for (i=PARAM_NUMBER-1; i>=0; i--)
+ if (stack[sptr-1].param[i][0])
+ for (j=sptr-2; j>=0; j--)
+ if (stack[j].param[i][0]) {
+ out += snprintf(out, out_end-out,
+ stack[j].param[i]);
+ break;
+ }
+ } else {
+ while (param) {
+ if (!strncmp(param, "size=", 5)) {
+ unsigned font_size;
+ param += 5 + (param[5] == '"');
+ if (sscanf(param, "%u", &font_size) == 1) {
+ snprintf(stack[sptr].param[PARAM_SIZE],
+ sizeof(stack[0].param[PARAM_SIZE]),
+ "{\\fs%u}", font_size);
+ }
+ } else if (!strncmp(param, "color=", 6)) {
+ param += 6 + (param[6] == '"');
+ snprintf(stack[sptr].param[PARAM_COLOR],
+ sizeof(stack[0].param[PARAM_COLOR]),
+ "{\\c&H%X&}",
+ html_color_parse(avctx, param));
+ } else if (!strncmp(param, "face=", 5)) {
+ param += 5 + (param[5] == '"');
+ len = strcspn(param,
+ param[-1] == '"' ? "\"" :" ");
+ av_strlcpy(tmp, param,
+ FFMIN(sizeof(tmp), len+1));
+ param += len;
+ snprintf(stack[sptr].param[PARAM_FACE],
+ sizeof(stack[0].param[PARAM_FACE]),
+ "{\\fn%s}", tmp);
+ }
+ if ((param = strchr(param, ' ')))
+ param++;
+ }
+ for (i=0; i<PARAM_NUMBER; i++)
+ if (stack[sptr].param[i][0])
+ out += snprintf(out, out_end-out,
+ stack[sptr].param[i]);
+ }
+ } else if (!buffer[1] && strspn(buffer, "bisu") == 1) {
+ out += snprintf(out, out_end-out,
+ "{\\%c%d}", buffer[0], !tag_close);
+ } else {
+ unknown = 1;
+ snprintf(tmp, sizeof(tmp), "</%s>", buffer);
+ }
+ if (tag_close) {
+ sptr--;
+ } else if (unknown && !strstr(in, tmp)) {
+ in -= len + tag_close;
+ *out++ = *in;
+ } else
+ av_strlcpy(stack[sptr++].tag, buffer,
+ sizeof(stack[0].tag));
+ break;
+ }
+ }
+ default:
+ *out++ = *in;
+ break;
+ }
+ if (*in != ' ' && *in != '\r' && *in != '\n')
+ line_start = 0;
+ }
+
+ out = FFMIN(out, out_end-3);
+ while (!strncmp(out-2, "\\N", 2))
+ out -= 2;
+ while (out[-1] == ' ')
+ out--;
+ out += snprintf(out, out_end-out, "\r\n");
+ return in;
+}
+
+static const char *read_ts(const char *buf, int *ts_start, int *ts_end,
+ int *x1, int *y1, int *x2, int *y2)
+{
+ int i, hs, ms, ss, he, me, se;
+
+ for (i=0; i<2; i++) {
+ /* try to read timestamps in either the first or second line */
+ int c = sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d"
+ "%*[ ]X1:%u X2:%u Y1:%u Y2:%u",
+ &hs, &ms, &ss, ts_start, &he, &me, &se, ts_end,
+ x1, x2, y1, y2);
+ buf += strcspn(buf, "\n") + 1;
+ if (c >= 8) {
+ *ts_start = 100*(ss + 60*(ms + 60*hs)) + *ts_start/10;
+ *ts_end = 100*(se + 60*(me + 60*he)) + *ts_end /10;
+ return buf;
+ }
+ }
+ return NULL;
+}
+
+static int srt_decode_frame(AVCodecContext *avctx,
+ void *data, int *got_sub_ptr, AVPacket *avpkt)
+{
+ AVSubtitle *sub = data;
+ int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
+ char buffer[2048];
+ const char *ptr = avpkt->data;
+ const char *end = avpkt->data + avpkt->size;
+
+ if (avpkt->size <= 0)
+ return avpkt->size;
+
+ ff_ass_init(sub);
+
+ while (ptr < end && *ptr) {
+ ptr = read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
+ if (!ptr)
+ break;
+ ptr = srt_to_ass(avctx, buffer, buffer+sizeof(buffer), ptr,
+ x1, y1, x2, y2);
+ ff_ass_add_rect(sub, buffer, ts_start, ts_end, 0);
+ }
+
+ *got_sub_ptr = sub->num_rects > 0;
+ return avpkt->size;
+}
+
+AVCodec ff_srt_decoder = {
+ .name = "srt",
+ .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"),
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ .id = CODEC_ID_SRT,
+ .init = ff_ass_subtitle_header_default,
+ .decode = srt_decode_frame,
+};
diff --git a/lib/ffmpeg/libavcodec/sunrast.c b/lib/ffmpeg/libavcodec/sunrast.c
index 456ab85a88..76b65b356c 100644
--- a/lib/ffmpeg/libavcodec/sunrast.c
+++ b/lib/ffmpeg/libavcodec/sunrast.c
@@ -20,6 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#define RT_OLD 0
@@ -97,7 +98,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
if (p->data[0])
avctx->release_buffer(avctx, p);
- if (avcodec_check_dimensions(avctx, w, h))
+ if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -183,7 +184,7 @@ static av_cold int sunrast_end(AVCodecContext *avctx) {
return 0;
}
-AVCodec sunrast_decoder = {
+AVCodec ff_sunrast_decoder = {
"sunrast",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SUNRAST,
diff --git a/lib/ffmpeg/libavcodec/svq1dec.c b/lib/ffmpeg/libavcodec/svq1dec.c
index 1d40f596ad..eb7100713e 100644
--- a/lib/ffmpeg/libavcodec/svq1dec.c
+++ b/lib/ffmpeg/libavcodec/svq1dec.c
@@ -833,7 +833,7 @@ static av_cold int svq1_decode_end(AVCodecContext *avctx)
}
-AVCodec svq1_decoder = {
+AVCodec ff_svq1_decoder = {
"svq1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SVQ1,
diff --git a/lib/ffmpeg/libavcodec/svq1enc.c b/lib/ffmpeg/libavcodec/svq1enc.c
index c89be259d7..a415d843d2 100644
--- a/lib/ffmpeg/libavcodec/svq1enc.c
+++ b/lib/ffmpeg/libavcodec/svq1enc.c
@@ -572,7 +572,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
}
-AVCodec svq1_encoder = {
+AVCodec ff_svq1_encoder = {
"svq1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SVQ1,
diff --git a/lib/ffmpeg/libavcodec/svq3.c b/lib/ffmpeg/libavcodec/svq3.c
index df2acd8955..5162e99243 100644
--- a/lib/ffmpeg/libavcodec/svq3.c
+++ b/lib/ffmpeg/libavcodec/svq3.c
@@ -125,22 +125,18 @@ static const uint32_t svq3_dequant_coeff[32] = {
61694, 68745, 77615, 89113,100253,109366,126635,141533
};
-
-void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp)
-{
+void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *output, DCTELEM *input, int qp){
const int qmul = svq3_dequant_coeff[qp];
#define stride 16
int i;
int temp[16];
- static const int x_offset[4] = {0, 1*stride, 4* stride, 5*stride};
- static const int y_offset[4] = {0, 2*stride, 8* stride, 10*stride};
+ static const uint8_t x_offset[4]={0, 1*stride, 4*stride, 5*stride};
- for (i = 0; i < 4; i++){
- const int offset = y_offset[i];
- const int z0 = 13*(block[offset+stride*0] + block[offset+stride*4]);
- const int z1 = 13*(block[offset+stride*0] - block[offset+stride*4]);
- const int z2 = 7* block[offset+stride*1] - 17*block[offset+stride*5];
- const int z3 = 17* block[offset+stride*1] + 7*block[offset+stride*5];
+ for(i=0; i<4; i++){
+ const int z0 = 13*(input[4*i+0] + input[4*i+2]);
+ const int z1 = 13*(input[4*i+0] - input[4*i+2]);
+ const int z2 = 7* input[4*i+1] - 17*input[4*i+3];
+ const int z3 = 17* input[4*i+1] + 7*input[4*i+3];
temp[4*i+0] = z0+z3;
temp[4*i+1] = z1+z2;
@@ -148,17 +144,17 @@ void ff_svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp)
temp[4*i+3] = z0-z3;
}
- for (i = 0; i < 4; i++){
- const int offset = x_offset[i];
- const int z0 = 13*(temp[4*0+i] + temp[4*2+i]);
- const int z1 = 13*(temp[4*0+i] - temp[4*2+i]);
- const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
- const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
-
- block[stride*0 +offset] = ((z0 + z3)*qmul + 0x80000) >> 20;
- block[stride*2 +offset] = ((z1 + z2)*qmul + 0x80000) >> 20;
- block[stride*8 +offset] = ((z1 - z2)*qmul + 0x80000) >> 20;
- block[stride*10+offset] = ((z0 - z3)*qmul + 0x80000) >> 20;
+ for(i=0; i<4; i++){
+ const int offset= x_offset[i];
+ const int z0= 13*(temp[4*0+i] + temp[4*2+i]);
+ const int z1= 13*(temp[4*0+i] - temp[4*2+i]);
+ const int z2= 7* temp[4*1+i] - 17*temp[4*3+i];
+ const int z3= 17* temp[4*1+i] + 7*temp[4*3+i];
+
+ output[stride* 0+offset] = ((z0 + z3)*qmul + 0x80000) >> 20;
+ output[stride* 2+offset] = ((z1 + z2)*qmul + 0x80000) >> 20;
+ output[stride* 8+offset] = ((z1 - z2)*qmul + 0x80000) >> 20;
+ output[stride*10+offset] = ((z0 - z3)*qmul + 0x80000) >> 20;
}
}
#undef stride
@@ -287,7 +283,7 @@ static inline void svq3_mc_dir_part(MpegEncContext *s,
src = pic->data[0] + mx + my*s->linesize;
if (emu) {
- ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1),
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1),
mx, my, s->h_edge_pos, s->v_edge_pos);
src = s->edge_emu_buffer;
}
@@ -308,7 +304,7 @@ static inline void svq3_mc_dir_part(MpegEncContext *s,
src = pic->data[i] + mx + my*s->uvlinesize;
if (emu) {
- ff_emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1),
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1),
mx, my, (s->h_edge_pos >> 1), (s->v_edge_pos >> 1));
src = s->edge_emu_buffer;
}
@@ -648,7 +644,9 @@ static int svq3_decode_mb(H264Context *h, unsigned int mb_type)
}
}
if (IS_INTRA16x16(mb_type)) {
- if (svq3_decode_block(&s->gb, h->mb, 0, 0)){
+ AV_ZERO128(h->mb_luma_dc+0);
+ AV_ZERO128(h->mb_luma_dc+8);
+ if (svq3_decode_block(&s->gb, h->mb_luma_dc, 0, 1)){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n");
return -1;
}
@@ -796,11 +794,6 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx)
unsigned char *extradata;
unsigned int size;
- if(avctx->thread_count > 1){
- av_log(avctx, AV_LOG_ERROR, "SVQ3 does not support multithreaded decoding, patch welcome! (check latest SVN too)\n");
- return -1;
- }
-
if (ff_h264_decode_init(avctx) < 0)
return -1;
@@ -1069,7 +1062,7 @@ static int svq3_decode_frame(AVCodecContext *avctx,
}
-AVCodec svq3_decoder = {
+AVCodec ff_svq3_decoder = {
"svq3",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_SVQ3,
diff --git a/lib/ffmpeg/libavcodec/synth_filter.c b/lib/ffmpeg/libavcodec/synth_filter.c
index a0ae364d79..4af496d372 100644
--- a/lib/ffmpeg/libavcodec/synth_filter.c
+++ b/lib/ffmpeg/libavcodec/synth_filter.c
@@ -24,7 +24,7 @@
static void synth_filter_float(FFTContext *imdct,
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
- float out[32], const float in[32], float scale, float bias)
+ float out[32], const float in[32], float scale)
{
float *synth_buf= synth_buf_ptr + *synth_buf_offset;
int i, j;
@@ -48,8 +48,8 @@ static void synth_filter_float(FFTContext *imdct,
c += window[i + j + 32]*( synth_buf[16 + i + j - 512]);
d += window[i + j + 48]*( synth_buf[31 - i + j - 512]);
}
- out[i ] = a*scale + bias;
- out[i + 16] = b*scale + bias;
+ out[i ] = a*scale;
+ out[i + 16] = b*scale;
synth_buf2[i ] = c;
synth_buf2[i + 16] = d;
}
diff --git a/lib/ffmpeg/libavcodec/synth_filter.h b/lib/ffmpeg/libavcodec/synth_filter.h
index d6209d5dba..33edcc437f 100644
--- a/lib/ffmpeg/libavcodec/synth_filter.h
+++ b/lib/ffmpeg/libavcodec/synth_filter.h
@@ -28,7 +28,7 @@ typedef struct SynthFilterContext {
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
float out[32], const float in[32],
- float scale, float bias);
+ float scale);
} SynthFilterContext;
void ff_synth_filter_init(SynthFilterContext *c);
diff --git a/lib/ffmpeg/libavcodec/targa.c b/lib/ffmpeg/libavcodec/targa.c
index 50fe107ea9..e6e1ca6f21 100644
--- a/lib/ffmpeg/libavcodec/targa.c
+++ b/lib/ffmpeg/libavcodec/targa.c
@@ -20,15 +20,9 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
-
-enum TargaCompr{
- TGA_NODATA = 0, // no image data
- TGA_PAL = 1, // palettized
- TGA_RGB = 2, // true-color
- TGA_BW = 3, // black & white or grayscale
- TGA_RLE = 8, // flag pointing that data is RLE-coded
-};
+#include "targa.h"
typedef struct TargaContext {
AVFrame picture;
@@ -145,7 +139,7 @@ static int decode_frame(AVCodecContext *avctx,
if(s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
- if(avcodec_check_dimensions(avctx, w, h))
+ if(av_image_check_size(w, h, 0, avctx))
return -1;
if(w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -241,7 +235,7 @@ static av_cold int targa_end(AVCodecContext *avctx){
return 0;
}
-AVCodec targa_decoder = {
+AVCodec ff_targa_decoder = {
"targa",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TARGA,
diff --git a/lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.h b/lib/ffmpeg/libavcodec/targa.h
index a30089a3e5..5bc2a4407c 100644
--- a/lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.h
+++ b/lib/ffmpeg/libavcodec/targa.h
@@ -1,7 +1,4 @@
/*
- * vp6dsp SSE2 function declarations
- * Copyright (c) 2009 Zuxy Meng <zuxy.meng@gmail.com>
- *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
@@ -19,12 +16,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_X86_VP6DSP_SSE2_H
-#define AVCODEC_X86_VP6DSP_SSE2_H
-
-#include <stdint.h>
-
-void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights);
+/**
+ * @file
+ * targa file common definitions
+ *
+ * Based on:
+ * http://www.gamers.org/dEngine/quake3/TGA.txt
+ *
+ * and other specs you can find referenced for example in:
+ * http://en.wikipedia.org/wiki/Truevision_TGA
+ */
-#endif /* AVCODEC_X86_VP6DSP_SSE2_H */
+enum TargaCompr {
+ TGA_NODATA = 0, // no image data
+ TGA_PAL = 1, // palettized
+ TGA_RGB = 2, // true-color
+ TGA_BW = 3, // black & white or grayscale
+ TGA_RLE = 8, // flag pointing that data is RLE-coded
+};
diff --git a/lib/ffmpeg/libavcodec/targaenc.c b/lib/ffmpeg/libavcodec/targaenc.c
index e5d0042ecb..5c5fd008c1 100644
--- a/lib/ffmpeg/libavcodec/targaenc.c
+++ b/lib/ffmpeg/libavcodec/targaenc.c
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "rle.h"
+#include "targa.h"
typedef struct TargaContext {
AVFrame picture;
@@ -81,12 +82,12 @@ static int targa_encode_frame(AVCodecContext *avctx,
if(avctx->width > 0xffff || avctx->height > 0xffff) {
av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n");
- return -1;
+ return AVERROR(EINVAL);
}
picsize = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
if(buf_size < picsize + 45) {
av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
- return -1;
+ return AVERROR(EINVAL);
}
p->pict_type= FF_I_TYPE;
@@ -96,24 +97,30 @@ static int targa_encode_frame(AVCodecContext *avctx,
memset(outbuf, 0, 12);
AV_WL16(outbuf+12, avctx->width);
AV_WL16(outbuf+14, avctx->height);
- outbuf[17] = 0x20; /* origin is top-left. no alpha */
+ /* image descriptor byte: origin is always top-left, bits 0-3 specify alpha */
+ outbuf[17] = 0x20 | (avctx->pix_fmt == PIX_FMT_BGRA ? 8 : 0);
- /* TODO: support alpha channel */
switch(avctx->pix_fmt) {
case PIX_FMT_GRAY8:
- outbuf[2] = 3; /* uncompressed grayscale image */
+ outbuf[2] = TGA_BW; /* uncompressed grayscale image */
outbuf[16] = 8; /* bpp */
break;
case PIX_FMT_RGB555LE:
- outbuf[2] = 2; /* uncompresses true-color image */
+ outbuf[2] = TGA_RGB; /* uncompresses true-color image */
outbuf[16] = 16; /* bpp */
break;
case PIX_FMT_BGR24:
- outbuf[2] = 2; /* uncompressed true-color image */
+ outbuf[2] = TGA_RGB; /* uncompressed true-color image */
outbuf[16] = 24; /* bpp */
break;
+ case PIX_FMT_BGRA:
+ outbuf[2] = TGA_RGB; /* uncompressed true-color image */
+ outbuf[16] = 32; /* bpp */
+ break;
default:
- return -1;
+ av_log(avctx, AV_LOG_ERROR, "Pixel format '%s' not supported.\n",
+ avcodec_get_pix_fmt_name(avctx->pix_fmt));
+ return AVERROR(EINVAL);
}
bpp = outbuf[16] >> 3;
@@ -151,13 +158,13 @@ static av_cold int targa_encode_init(AVCodecContext *avctx)
return 0;
}
-AVCodec targa_encoder = {
+AVCodec ff_targa_encoder = {
.name = "targa",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_TARGA,
.priv_data_size = sizeof(TargaContext),
.init = targa_encode_init,
.encode = targa_encode_frame,
- .pix_fmts= (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB555LE, PIX_FMT_GRAY8, PIX_FMT_NONE},
+ .pix_fmts= (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_BGRA, PIX_FMT_RGB555LE, PIX_FMT_GRAY8, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("Truevision Targa image"),
};
diff --git a/lib/ffmpeg/libavcodec/tiertexseqv.c b/lib/ffmpeg/libavcodec/tiertexseqv.c
index c5f632e186..c8aa38cca9 100644
--- a/lib/ffmpeg/libavcodec/tiertexseqv.c
+++ b/lib/ffmpeg/libavcodec/tiertexseqv.c
@@ -219,7 +219,7 @@ static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec tiertexseqvideo_decoder = {
+AVCodec ff_tiertexseqvideo_decoder = {
"tiertexseqvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TIERTEXSEQVIDEO,
diff --git a/lib/ffmpeg/libavcodec/tiff.c b/lib/ffmpeg/libavcodec/tiff.c
index 2f3cef2b00..b012baa994 100644
--- a/lib/ffmpeg/libavcodec/tiff.c
+++ b/lib/ffmpeg/libavcodec/tiff.c
@@ -33,6 +33,7 @@
#include "faxcompr.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
typedef struct TiffContext {
AVCodecContext *avctx;
@@ -262,6 +263,10 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
s->height = value;
break;
case TIFF_BPP:
+ if(count > 4){
+ av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
+ return -1;
+ }
if(count == 1) s->bpp = value;
else{
switch(type){
@@ -277,10 +282,6 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
s->bpp = -1;
}
}
- if(count > 4){
- av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
- return -1;
- }
switch(s->bpp*10 + count){
case 11:
s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
@@ -305,7 +306,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
return -1;
}
if(s->width != s->avctx->width || s->height != s->avctx->height){
- if(avcodec_check_dimensions(s->avctx, s->width, s->height))
+ if(av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
avcodec_set_dimensions(s->avctx, s->width, s->height);
}
@@ -507,7 +508,7 @@ static int decode_frame(AVCodecContext *avctx,
s->bpp = 1;
avctx->pix_fmt = PIX_FMT_MONOBLACK;
if(s->width != s->avctx->width || s->height != s->avctx->height){
- if(avcodec_check_dimensions(s->avctx, s->width, s->height))
+ if(av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
avcodec_set_dimensions(s->avctx, s->width, s->height);
}
@@ -530,10 +531,19 @@ static int decode_frame(AVCodecContext *avctx,
else
ssize = s->stripsize;
+ if (ssize > buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "Buffer size is smaller than strip size\n");
+ return -1;
+ }
+
if(s->stripdata){
soff = tget(&s->stripdata, s->sot, s->le);
}else
soff = s->stripoff;
+ if (soff < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid stripoff: %d\n", soff);
+ return AVERROR(EINVAL);
+ }
if(tiff_unpack_strip(s, dst, stride, orig_buf + soff, ssize, FFMIN(s->rps, s->height - i)) < 0)
break;
dst += s->rps * stride;
@@ -590,7 +600,7 @@ static av_cold int tiff_end(AVCodecContext *avctx)
return 0;
}
-AVCodec tiff_decoder = {
+AVCodec ff_tiff_decoder = {
"tiff",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TIFF,
diff --git a/lib/ffmpeg/libavcodec/tiffenc.c b/lib/ffmpeg/libavcodec/tiffenc.c
index 0905ceae19..293ec0ac65 100644
--- a/lib/ffmpeg/libavcodec/tiffenc.c
+++ b/lib/ffmpeg/libavcodec/tiffenc.c
@@ -442,7 +442,7 @@ fail:
return ret;
}
-AVCodec tiff_encoder = {
+AVCodec ff_tiff_encoder = {
"tiff",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TIFF,
diff --git a/lib/ffmpeg/libavcodec/tmv.c b/lib/ffmpeg/libavcodec/tmv.c
index 5117cd03cd..62b6e19de1 100644
--- a/lib/ffmpeg/libavcodec/tmv.c
+++ b/lib/ffmpeg/libavcodec/tmv.c
@@ -39,10 +39,10 @@ static int tmv_decode_frame(AVCodecContext *avctx, void *data,
{
TMVContext *tmv = avctx->priv_data;
const uint8_t *src = avpkt->data;
- uint8_t *dst, *dst_char;
+ uint8_t *dst;
unsigned char_cols = avctx->width >> 3;
unsigned char_rows = avctx->height >> 3;
- unsigned x, y, mask, char_y, fg, bg, c;
+ unsigned x, y, fg, bg, c;
if (tmv->pic.data[0])
avctx->release_buffer(avctx, &tmv->pic);
@@ -68,17 +68,11 @@ static int tmv_decode_frame(AVCodecContext *avctx, void *data,
for (y = 0; y < char_rows; y++) {
for (x = 0; x < char_cols; x++) {
- c = *src++ * 8;
+ c = *src++;
bg = *src >> 4;
fg = *src++ & 0xF;
-
- dst_char = dst + x * 8;
- for (char_y = 0; char_y < 8; char_y++) {
- for (mask = 0x80; mask; mask >>= 1) {
- *dst_char++ = ff_cga_font[c + char_y] & mask ? fg : bg;
- }
- dst_char += tmv->pic.linesize[0] - 8;
- }
+ ff_draw_pc_font(dst + x * 8, tmv->pic.linesize[0],
+ ff_cga_font, 8, c, fg, bg);
}
dst += tmv->pic.linesize[0] * 8;
}
@@ -98,7 +92,7 @@ static av_cold int tmv_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec tmv_decoder = {
+AVCodec ff_tmv_decoder = {
.name = "tmv",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_TMV,
diff --git a/lib/ffmpeg/libavcodec/truemotion1.c b/lib/ffmpeg/libavcodec/truemotion1.c
index 4306917912..448da84c57 100644
--- a/lib/ffmpeg/libavcodec/truemotion1.c
+++ b/lib/ffmpeg/libavcodec/truemotion1.c
@@ -35,6 +35,7 @@
#include "avcodec.h"
#include "dsputil.h"
+#include "libavcore/imgutils.h"
#include "truemotion1data.h"
@@ -71,6 +72,7 @@ typedef struct TrueMotion1Context {
int last_deltaset, last_vectable;
unsigned int *vert_pred;
+ int vert_pred_size;
} TrueMotion1Context;
@@ -178,11 +180,7 @@ static int make_ydt15_entry(int p1, int p2, int16_t *ydt)
return (lo + (hi << 16)) << 1;
}
-#if HAVE_BIGENDIAN
-static int make_cdt15_entry(int p2, int p1, int16_t *cdt)
-#else
static int make_cdt15_entry(int p1, int p2, int16_t *cdt)
-#endif
{
int r, b, lo;
@@ -207,11 +205,7 @@ static int make_ydt16_entry(int p1, int p2, int16_t *ydt)
return (lo + (hi << 16)) << 1;
}
-#if HAVE_BIGENDIAN
-static int make_cdt16_entry(int p2, int p1, int16_t *cdt)
-#else
static int make_cdt16_entry(int p1, int p2, int16_t *cdt)
-#endif
{
int r, b, lo;
@@ -221,11 +215,7 @@ static int make_cdt16_entry(int p1, int p2, int16_t *cdt)
return (lo + (lo << 16)) << 1;
}
-#if HAVE_BIGENDIAN
-static int make_ydt24_entry(int p2, int p1, int16_t *ydt)
-#else
static int make_ydt24_entry(int p1, int p2, int16_t *ydt)
-#endif
{
int lo, hi;
@@ -234,11 +224,7 @@ static int make_ydt24_entry(int p1, int p2, int16_t *ydt)
return (lo + (hi << 8) + (hi << 16)) << 1;
}
-#if HAVE_BIGENDIAN
-static int make_cdt24_entry(int p2, int p1, int16_t *cdt)
-#else
static int make_cdt24_entry(int p1, int p2, int16_t *cdt)
-#endif
{
int r, b;
@@ -321,15 +307,12 @@ static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_
static int truemotion1_decode_header(TrueMotion1Context *s)
{
int i;
+ int width_shift = 0;
+ int new_pix_fmt;
struct frame_header header;
uint8_t header_buffer[128]; /* logical maximum size of the header */
const uint8_t *sel_vector_table;
- /* There is 1 change bit per 4 pixels, so each change byte represents
- * 32 pixels; divide width by 4 to obtain the number of change bits and
- * then round up to the nearest byte. */
- s->mb_change_bits_row_size = ((s->avctx->width >> 2) + 7) >> 3;
-
header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f;
if (s->buf[0] < 0x10)
{
@@ -404,7 +387,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if ((header.compression & 1) && header.header_type)
sel_vector_table = pc_tbl2;
else {
- if (header.vectable < 4)
+ if (header.vectable > 0 && header.vectable < 4)
sel_vector_table = tables[header.vectable - 1];
else {
av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable);
@@ -412,11 +395,30 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
}
}
- // FIXME: where to place this ?!?!
- if (compression_types[header.compression].algorithm == ALGO_RGB24H)
- s->avctx->pix_fmt = PIX_FMT_RGB32;
- else
- s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well
+ if (compression_types[header.compression].algorithm == ALGO_RGB24H) {
+ new_pix_fmt = PIX_FMT_RGB32;
+ width_shift = 1;
+ } else
+ new_pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well
+
+ s->w >>= width_shift;
+ if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0)
+ return -1;
+
+ if (s->w != s->avctx->width || s->h != s->avctx->height ||
+ new_pix_fmt != s->avctx->pix_fmt) {
+ if (s->frame.data[0])
+ s->avctx->release_buffer(s->avctx, &s->frame);
+ s->avctx->sample_aspect_ratio = (AVRational){ 1 << width_shift, 1 };
+ s->avctx->pix_fmt = new_pix_fmt;
+ avcodec_set_dimensions(s->avctx, s->w, s->h);
+ av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int));
+ }
+
+ /* There is 1 change bit per 4 pixels, so each change byte represents
+ * 32 pixels; divide width by 4 to obtain the number of change bits and
+ * then round up to the nearest byte. */
+ s->mb_change_bits_row_size = ((s->avctx->width >> (2 - width_shift)) + 7) >> 3;
if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable))
{
@@ -476,8 +478,7 @@ static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
/* there is a vertical predictor for each pixel in a line; each vertical
* predictor is 0 to start with */
- s->vert_pred =
- (unsigned int *)av_malloc(s->avctx->width * sizeof(unsigned int));
+ av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int));
return 0;
}
@@ -831,7 +832,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
}
}
- pixels_left -= 4;
+ pixels_left -= 2;
}
/* next change row */
@@ -890,7 +891,7 @@ static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec truemotion1_decoder = {
+AVCodec ff_truemotion1_decoder = {
"truemotion1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TRUEMOTION1,
diff --git a/lib/ffmpeg/libavcodec/truemotion2.c b/lib/ffmpeg/libavcodec/truemotion2.c
index 5013a9eeb7..d20ee94b29 100644
--- a/lib/ffmpeg/libavcodec/truemotion2.c
+++ b/lib/ffmpeg/libavcodec/truemotion2.c
@@ -260,7 +260,8 @@ static int tm2_read_deltas(TM2Context *ctx, int stream_id) {
return 0;
}
-static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) {
+static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size)
+{
int i;
int cur = 0;
int skip = 0;
@@ -274,6 +275,11 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) {
if(len == 0)
return 4;
+ if (len >= INT_MAX/4-1 || len < 0 || len > buf_size) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "Error, invalid stream size.\n");
+ return -1;
+ }
+
toks = AV_RB32(buf); buf += 4; cur += 4;
if(toks & 1) {
len = AV_RB32(buf); buf += 4; cur += 4;
@@ -313,8 +319,13 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) {
len = AV_RB32(buf); buf += 4; cur += 4;
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
- for(i = 0; i < toks; i++)
+ for(i = 0; i < toks; i++) {
+ if (get_bits_left(&ctx->gb) <= 0) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks);
+ return -1;
+ }
ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes);
+ }
} else {
for(i = 0; i < toks; i++)
ctx->tokens[stream_id][i] = codes.recode[0];
@@ -788,7 +799,7 @@ static int decode_frame(AVCodecContext *avctx,
}
for(i = 0; i < TM2_NUM_STREAMS; i++){
- t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i]);
+ t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i], buf_size);
if(t == -1){
av_free(swbuf);
return -1;
@@ -870,7 +881,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec truemotion2_decoder = {
+AVCodec ff_truemotion2_decoder = {
"truemotion2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TRUEMOTION2,
diff --git a/lib/ffmpeg/libavcodec/truespeech.c b/lib/ffmpeg/libavcodec/truespeech.c
index eafbca52d8..d903a0119e 100644
--- a/lib/ffmpeg/libavcodec/truespeech.c
+++ b/lib/ffmpeg/libavcodec/truespeech.c
@@ -56,7 +56,7 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx)
{
// TSContext *c = avctx->priv_data;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -165,7 +165,7 @@ static void truespeech_correlate_filter(TSContext *dec)
dec->cvector[i] = (8 - dec->vector[i]) >> 3;
}
for(i = 0; i < 8; i++)
- dec->cvector[i] = (dec->cvector[i] * ts_230[i]) >> 15;
+ dec->cvector[i] = (dec->cvector[i] * ts_decay_994_1000[i]) >> 15;
dec->filtval = dec->vector[0];
}
@@ -207,7 +207,7 @@ static void truespeech_apply_twopoint_filter(TSContext *dec, int quart)
off = (t / 25) + dec->offset1[quart >> 1] + 18;
ptr0 = tmp + 145 - off;
ptr1 = tmp + 146;
- filter = (const int16_t*)ts_240 + (t % 25) * 2;
+ filter = (const int16_t*)ts_order2_coeffs + (t % 25) * 2;
for(i = 0; i < 60; i++){
t = (ptr0[0] * filter[0] + ptr0[1] * filter[1] + 0x2000) >> 14;
ptr0++;
@@ -228,11 +228,11 @@ static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart)
for(i = 0; i < 7; i++) {
t = dec->pulseval[quart] & 3;
dec->pulseval[quart] >>= 2;
- tmp[6 - i] = ts_562[dec->pulseoff[quart] * 4 + t];
+ tmp[6 - i] = ts_pulse_scales[dec->pulseoff[quart] * 4 + t];
}
coef = dec->pulsepos[quart] >> 15;
- ptr1 = (const int16_t*)ts_140 + 30;
+ ptr1 = (const int16_t*)ts_pulse_values + 30;
ptr2 = tmp;
for(i = 0, j = 3; (i < 30) && (j > 0); i++){
t = *ptr1++;
@@ -245,7 +245,7 @@ static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart)
}
}
coef = dec->pulsepos[quart] & 0x7FFF;
- ptr1 = (const int16_t*)ts_140;
+ ptr1 = (const int16_t*)ts_pulse_values;
for(i = 30, j = 4; (i < 60) && (j > 0); i++){
t = *ptr1++;
if(coef >= t)
@@ -291,7 +291,7 @@ static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
}
for(i = 0; i < 8; i++)
- t[i] = (ts_5E2[i] * ptr1[i]) >> 15;
+ t[i] = (ts_decay_35_64[i] * ptr1[i]) >> 15;
ptr0 = dec->tmp2;
for(i = 0; i < 60; i++){
@@ -305,7 +305,7 @@ static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
}
for(i = 0; i < 8; i++)
- t[i] = (ts_5F2[i] * ptr1[i]) >> 15;
+ t[i] = (ts_decay_3_4[i] * ptr1[i]) >> 15;
ptr0 = dec->tmp3;
for(i = 0; i < 60; i++){
@@ -381,7 +381,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx,
return consumed;
}
-AVCodec truespeech_decoder = {
+AVCodec ff_truespeech_decoder = {
"truespeech",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_TRUESPEECH,
diff --git a/lib/ffmpeg/libavcodec/truespeech_data.h b/lib/ffmpeg/libavcodec/truespeech_data.h
index eef7da8eee..73ebda5e85 100644
--- a/lib/ffmpeg/libavcodec/truespeech_data.h
+++ b/lib/ffmpeg/libavcodec/truespeech_data.h
@@ -71,7 +71,7 @@ static const int16_t * const ts_codebook[8] = {
};
/* table used for decoding pulse positions */
-static const int16_t ts_140[120] = {
+static const int16_t ts_pulse_values[120] = {
0x0E46, 0x0CCC, 0x0B6D, 0x0A28, 0x08FC, 0x07E8, 0x06EB, 0x0604,
0x0532, 0x0474, 0x03C9, 0x0330, 0x02A8, 0x0230, 0x01C7, 0x016C,
0x011E, 0x00DC, 0x00A5, 0x0078, 0x0054, 0x0038, 0x0023, 0x0014,
@@ -94,11 +94,11 @@ static const int16_t ts_140[120] = {
};
/* filter for correlated input filter */
-static const int16_t ts_230[8] =
+static const int16_t ts_decay_994_1000[8] =
{ 0x7F3B, 0x7E78, 0x7DB6, 0x7CF5, 0x7C35, 0x7B76, 0x7AB8, 0x79FC };
/* two-point filters table */
-static const int16_t ts_240[25 * 2] = {
+static const int16_t ts_order2_coeffs[25 * 2] = {
0xED2F, 0x5239,
0x54F1, 0xE4A9,
0x2620, 0xEE3E,
@@ -131,7 +131,7 @@ static const int16_t ts_240[25 * 2] = {
};
/* possible pulse values */
-static const int16_t ts_562[64] = {
+static const int16_t ts_pulse_scales[64] = {
0x0002, 0x0006, 0xFFFE, 0xFFFA,
0x0004, 0x000C, 0xFFFC, 0xFFF4,
0x0006, 0x0012, 0xFFFA, 0xFFEE,
@@ -151,9 +151,9 @@ static const int16_t ts_562[64] = {
};
/* filters used in final output calculations */
-static const int16_t ts_5E2[8] =
+static const int16_t ts_decay_35_64[8] =
{ 0x4666, 0x26B8, 0x154C, 0x0BB6, 0x0671, 0x038B, 0x01F3, 0x0112 };
-static const int16_t ts_5F2[8] =
+static const int16_t ts_decay_3_4[8] =
{ 0x6000, 0x4800, 0x3600, 0x2880, 0x1E60, 0x16C8, 0x1116, 0x0CD1 };
#endif /* AVCODEC_TRUESPEECH_DATA_H */
diff --git a/lib/ffmpeg/libavcodec/tscc.c b/lib/ffmpeg/libavcodec/tscc.c
index 2b717c1481..9de53a7267 100644
--- a/lib/ffmpeg/libavcodec/tscc.c
+++ b/lib/ffmpeg/libavcodec/tscc.c
@@ -197,7 +197,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec tscc_decoder = {
+AVCodec ff_tscc_decoder = {
"camtasia",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TSCC,
diff --git a/lib/ffmpeg/libavcodec/tta.c b/lib/ffmpeg/libavcodec/tta.c
index 0a4c69a472..936dff2333 100644
--- a/lib/ffmpeg/libavcodec/tta.c
+++ b/lib/ffmpeg/libavcodec/tta.c
@@ -63,7 +63,7 @@ typedef struct TTAContext {
int32_t *decode_buffer;
- TTAChannel *ch_ctx;;
+ TTAChannel *ch_ctx;
} TTAContext;
#if 0
@@ -246,15 +246,15 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
if (s->is_float)
{
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
av_log(s->avctx, AV_LOG_ERROR, "Unsupported sample format. Please contact the developers.\n");
return -1;
}
else switch(s->bps) {
-// case 1: avctx->sample_fmt = SAMPLE_FMT_U8; break;
- case 2: avctx->sample_fmt = SAMPLE_FMT_S16; break;
-// case 3: avctx->sample_fmt = SAMPLE_FMT_S24; break;
- case 4: avctx->sample_fmt = SAMPLE_FMT_S32; break;
+// case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break;
+ case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; break;
+// case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S24; break;
+ case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Invalid/unsupported sample format. Please contact the developers.\n");
return -1;
@@ -456,7 +456,7 @@ static av_cold int tta_decode_close(AVCodecContext *avctx) {
return 0;
}
-AVCodec tta_decoder = {
+AVCodec ff_tta_decoder = {
"tta",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_TTA,
diff --git a/lib/ffmpeg/libavcodec/twinvq.c b/lib/ffmpeg/libavcodec/twinvq.c
index 701e9595cf..bd43104e6e 100644
--- a/lib/ffmpeg/libavcodec/twinvq.c
+++ b/lib/ffmpeg/libavcodec/twinvq.c
@@ -646,7 +646,6 @@ static void imdct_and_window(TwinContext *tctx, enum FrameType ftype, int wtype,
prev_buf + (bsize-wsize)/2,
buf1 + bsize*j,
ff_sine_windows[av_log2(wsize)],
- 0.0,
wsize/2);
out2 += wsize;
@@ -783,7 +782,7 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb,
dec_bark_env(tctx, bark1[i][j], bark_use_hist[i][j], i,
tctx->tmp_buf, gain[sub*i+j], ftype);
- tctx->dsp.vector_fmul(chunk + block_size*j, tctx->tmp_buf,
+ tctx->dsp.vector_fmul(chunk + block_size*j, chunk + block_size*j, tctx->tmp_buf,
block_size);
}
@@ -805,7 +804,7 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb,
dec_lpc_spectrum_inv(tctx, lsp, ftype, tctx->tmp_buf);
for (j = 0; j < mtab->fmode[ftype].sub; j++) {
- tctx->dsp.vector_fmul(chunk, tctx->tmp_buf, block_size);
+ tctx->dsp.vector_fmul(chunk, chunk, tctx->tmp_buf, block_size);
chunk += block_size;
}
}
@@ -1068,7 +1067,7 @@ static av_cold int twin_decode_init(AVCodecContext *avctx)
int ibps = avctx->bit_rate/(1000 * avctx->channels);
tctx->avctx = avctx;
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
if (avctx->channels > CHANNELS_MAX) {
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n",
@@ -1119,7 +1118,7 @@ static av_cold int twin_decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec twinvq_decoder =
+AVCodec ff_twinvq_decoder =
{
"twinvq",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/txd.c b/lib/ffmpeg/libavcodec/txd.c
index ac8229f9e4..b394e1f5be 100644
--- a/lib/ffmpeg/libavcodec/txd.c
+++ b/lib/ffmpeg/libavcodec/txd.c
@@ -22,6 +22,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "s3tc.h"
@@ -79,7 +80,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (p->data[0])
avctx->release_buffer(avctx, p);
- if (avcodec_check_dimensions(avctx, w, h))
+ if (av_image_check_size(w, h, 0, avctx))
return -1;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -154,7 +155,7 @@ static av_cold int txd_end(AVCodecContext *avctx) {
return 0;
}
-AVCodec txd_decoder = {
+AVCodec ff_txd_decoder = {
"txd",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_TXD,
diff --git a/lib/ffmpeg/libavcodec/ulti.c b/lib/ffmpeg/libavcodec/ulti.c
index 1d04c807fb..bb1270f055 100644
--- a/lib/ffmpeg/libavcodec/ulti.c
+++ b/lib/ffmpeg/libavcodec/ulti.c
@@ -404,7 +404,7 @@ static int ulti_decode_frame(AVCodecContext *avctx,
return buf_size;
}
-AVCodec ulti_decoder = {
+AVCodec ff_ulti_decoder = {
"ultimotion",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ULTI,
diff --git a/lib/ffmpeg/libavcodec/utils.c b/lib/ffmpeg/libavcodec/utils.c
index cfcd7082bb..53a0674323 100644
--- a/lib/ffmpeg/libavcodec/utils.c
+++ b/lib/ffmpeg/libavcodec/utils.c
@@ -29,9 +29,13 @@
#include "libavutil/integer.h"
#include "libavutil/crc.h"
#include "libavutil/pixdesc.h"
+#include "libavcore/audioconvert.h"
+#include "libavcore/imgutils.h"
+#include "libavcore/internal.h"
+#include "libavcore/samplefmt.h"
#include "avcodec.h"
#include "dsputil.h"
-#include "opt.h"
+#include "libavutil/opt.h"
#include "imgconvert.h"
#include "audioconvert.h"
#include "internal.h"
@@ -41,32 +45,35 @@
#include <float.h>
static int volatile entangled_thread_counter=0;
-int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
+static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
static void *codec_mutex;
-void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
+void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size)
{
if(min_size < *size)
return ptr;
- *size= FFMAX(17*min_size/16 + 32, min_size);
+ min_size= FFMAX(17*min_size/16 + 32, min_size);
- ptr= av_realloc(ptr, *size);
+ ptr= av_realloc(ptr, min_size);
if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now
- *size= 0;
+ min_size= 0;
+
+ *size= min_size;
return ptr;
}
-void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size)
+void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size)
{
void **p = ptr;
if (min_size < *size)
return;
- *size= FFMAX(17*min_size/16 + 32, min_size);
+ min_size= FFMAX(17*min_size/16 + 32, min_size);
av_free(*p);
- *p = av_malloc(*size);
- if (!*p) *size = 0;
+ *p = av_malloc(min_size);
+ if (!*p) min_size = 0;
+ *size= min_size;
}
/* encoder management */
@@ -138,7 +145,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
case PIX_FMT_YUVA420P:
w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
h_align= 16;
- if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP)
+ if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264)
h_align= 32; // interlaced is rounded up to 2 MBs
break;
case PIX_FMT_YUV411P:
@@ -178,8 +185,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
*width = FFALIGN(*width , w_align);
*height= FFALIGN(*height, h_align);
- if(s->codec_id == CODEC_ID_H264)
+ if(s->codec_id == CODEC_ID_H264 || s->lowres)
*height+=2; // some of the optimized chroma MC reads one line too much
+ // which is also done in mpeg decoders with lowres > 0
linesize_align[0] =
linesize_align[1] =
@@ -212,13 +220,11 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
*width=FFALIGN(*width, align);
}
+#if LIBAVCODEC_VERSION_MAJOR < 53
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
- if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
- return 0;
-
- av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
- return AVERROR(EINVAL);
+ return av_image_check_size(w, h, 0, av_log_ctx);
}
+#endif
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
@@ -236,7 +242,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
return -1;
}
- if(avcodec_check_dimensions(s,w,h))
+ if(av_image_check_size(w, h, 0, s))
return -1;
if(s->internal_buffer==NULL){
@@ -284,7 +290,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
do {
// NOTE: do not align linesizes individually, this breaks e.g. assumptions
// that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
- ff_fill_linesize(&picture, s->pix_fmt, w);
+ av_image_fill_linesizes(picture.linesize, s->pix_fmt, w);
// increase alignment of w for next try (rhs gives the lowest bit set in w)
w += w & ~(w-1);
@@ -294,7 +300,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
}
} while (unaligned);
- tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h);
+ tmpsize = av_image_fill_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize);
if (tmpsize < 0)
return -1;
@@ -323,7 +329,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]);
}
if(size[1] && !size[2])
- ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt);
+ ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);
buf->width = s->width;
buf->height = s->height;
buf->pix_fmt= s->pix_fmt;
@@ -338,6 +344,8 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
}
s->internal_buffer_count++;
+ if(s->pkt) pic->pkt_pts= s->pkt->pts;
+ else pic->pkt_pts= AV_NOPTS_VALUE;
pic->reordered_opaque= s->reordered_opaque;
if(s->debug&FF_DEBUG_BUFFERS)
@@ -472,11 +480,17 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
goto end;
if (codec->priv_data_size > 0) {
+ if(!avctx->priv_data){
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data) {
ret = AVERROR(ENOMEM);
goto end;
}
+ if(codec->priv_class){ //this can be droped once all user apps use avcodec_get_context_defaults3()
+ *(AVClass**)avctx->priv_data= codec->priv_class;
+ av_opt_set_defaults(avctx->priv_data);
+ }
+ }
} else {
avctx->priv_data = NULL;
}
@@ -486,10 +500,20 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
else if(avctx->width && avctx->height)
avcodec_set_dimensions(avctx, avctx->width, avctx->height);
+ if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
+ && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
+ || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
+ av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
+ avcodec_set_dimensions(avctx, 0, 0);
+ }
+
+ /* if the decoder init function was already called previously,
+ free the already allocated subtitle_header before overwriting it */
+ if (codec->decode)
+ av_freep(&avctx->subtitle_header);
+
#define SANE_NB_CHANNELS 128U
- if (((avctx->coded_width || avctx->coded_height)
- && avcodec_check_dimensions(avctx, avctx->coded_width, avctx->coded_height))
- || avctx->channels > SANE_NB_CHANNELS) {
+ if (avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
}
@@ -500,19 +524,19 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
avctx->codec_type = codec->type;
avctx->codec_id = codec->id;
}
- if(avctx->codec_id != codec->id || avctx->codec_type != codec->type){
+ if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
+ && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
goto free_and_end;
}
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;
- }
+ if (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;
+ }
+ if(avctx->codec->init){
ret = avctx->codec->init(avctx);
if (ret < 0) {
goto free_and_end;
@@ -555,7 +579,7 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf
av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
- if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
+ if(av_image_check_size(avctx->width, avctx->height, 0, avctx))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
@@ -582,7 +606,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return ret;
}
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_VIDEO_OLD
int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
const uint8_t *buf, int buf_size)
@@ -605,14 +629,19 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
int ret;
*got_picture_ptr= 0;
- if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
+ if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
return -1;
+
+ avctx->pkt = avpkt;
+
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
avpkt);
emms_c(); //needed to avoid an emms_c() call before every return;
+ picture->pkt_dts= avpkt->dts;
+
if (*got_picture_ptr)
avctx->frame_number++;
}else
@@ -621,7 +650,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
return ret;
}
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_AUDIO_OLD
int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
const uint8_t *buf, int buf_size)
@@ -641,6 +670,8 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
{
int ret;
+ avctx->pkt = avpkt;
+
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
//FIXME remove the check below _after_ ensuring that all audio check that the available space is enough
if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
@@ -662,7 +693,7 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa
return ret;
}
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_SUBTITLE_OLD
int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
const uint8_t *buf, int buf_size)
@@ -682,6 +713,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
{
int ret;
+ avctx->pkt = avpkt;
*got_sub_ptr = 0;
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
if (*got_sub_ptr)
@@ -919,10 +951,10 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
", %d Hz", enc->sample_rate);
}
av_strlcat(buf, ", ", buf_size);
- avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
- if (enc->sample_fmt != SAMPLE_FMT_NONE) {
+ av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
+ if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt));
+ ", %s", av_get_sample_fmt_name(enc->sample_fmt));
}
break;
case AVMEDIA_TYPE_DATA:
@@ -1076,21 +1108,11 @@ int av_get_bits_per_sample(enum CodecID codec_id){
}
}
-int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) {
- switch (sample_fmt) {
- case SAMPLE_FMT_U8:
- return 8;
- case SAMPLE_FMT_S16:
- return 16;
- case SAMPLE_FMT_S32:
- case SAMPLE_FMT_FLT:
- return 32;
- case SAMPLE_FMT_DBL:
- return 64;
- default:
- return 0;
- }
+#if FF_API_OLD_SAMPLE_FMT
+int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt) {
+ return av_get_bits_per_sample_fmt(sample_fmt);
}
+#endif
#if !HAVE_THREADS
int avcodec_thread_init(AVCodecContext *s, int thread_count){
@@ -1113,132 +1135,19 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
return n;
}
-typedef struct {
- const char *abbr;
- int width, height;
-} VideoFrameSizeAbbr;
-
-typedef struct {
- const char *abbr;
- int rate_num, rate_den;
-} VideoFrameRateAbbr;
-
-static const VideoFrameSizeAbbr video_frame_size_abbrs[] = {
- { "ntsc", 720, 480 },
- { "pal", 720, 576 },
- { "qntsc", 352, 240 }, /* VCD compliant NTSC */
- { "qpal", 352, 288 }, /* VCD compliant PAL */
- { "sntsc", 640, 480 }, /* square pixel NTSC */
- { "spal", 768, 576 }, /* square pixel PAL */
- { "film", 352, 240 },
- { "ntsc-film", 352, 240 },
- { "sqcif", 128, 96 },
- { "qcif", 176, 144 },
- { "cif", 352, 288 },
- { "4cif", 704, 576 },
- { "16cif", 1408,1152 },
- { "qqvga", 160, 120 },
- { "qvga", 320, 240 },
- { "vga", 640, 480 },
- { "svga", 800, 600 },
- { "xga", 1024, 768 },
- { "uxga", 1600,1200 },
- { "qxga", 2048,1536 },
- { "sxga", 1280,1024 },
- { "qsxga", 2560,2048 },
- { "hsxga", 5120,4096 },
- { "wvga", 852, 480 },
- { "wxga", 1366, 768 },
- { "wsxga", 1600,1024 },
- { "wuxga", 1920,1200 },
- { "woxga", 2560,1600 },
- { "wqsxga", 3200,2048 },
- { "wquxga", 3840,2400 },
- { "whsxga", 6400,4096 },
- { "whuxga", 7680,4800 },
- { "cga", 320, 200 },
- { "ega", 640, 350 },
- { "hd480", 852, 480 },
- { "hd720", 1280, 720 },
- { "hd1080", 1920,1080 },
-};
-
-static const VideoFrameRateAbbr video_frame_rate_abbrs[]= {
- { "ntsc", 30000, 1001 },
- { "pal", 25, 1 },
- { "qntsc", 30000, 1001 }, /* VCD compliant NTSC */
- { "qpal", 25, 1 }, /* VCD compliant PAL */
- { "sntsc", 30000, 1001 }, /* square pixel NTSC */
- { "spal", 25, 1 }, /* square pixel PAL */
- { "film", 24, 1 },
- { "ntsc-film", 24000, 1001 },
-};
+#if LIBAVCODEC_VERSION_MAJOR < 53
+#include "libavcore/parseutils.h"
int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str)
{
- int i;
- int n = FF_ARRAY_ELEMS(video_frame_size_abbrs);
- char *p;
- int frame_width = 0, frame_height = 0;
-
- for(i=0;i<n;i++) {
- if (!strcmp(video_frame_size_abbrs[i].abbr, str)) {
- frame_width = video_frame_size_abbrs[i].width;
- frame_height = video_frame_size_abbrs[i].height;
- break;
- }
- }
- if (i == n) {
- p = str;
- frame_width = strtol(p, &p, 10);
- if (*p)
- p++;
- frame_height = strtol(p, &p, 10);
- }
- if (frame_width <= 0 || frame_height <= 0)
- return -1;
- *width_ptr = frame_width;
- *height_ptr = frame_height;
- return 0;
+ return av_parse_video_size(width_ptr, height_ptr, str);
}
int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg)
{
- int i;
- int n = FF_ARRAY_ELEMS(video_frame_rate_abbrs);
- char* cp;
-
- /* First, we check our abbreviation table */
- for (i = 0; i < n; ++i)
- if (!strcmp(video_frame_rate_abbrs[i].abbr, arg)) {
- frame_rate->num = video_frame_rate_abbrs[i].rate_num;
- frame_rate->den = video_frame_rate_abbrs[i].rate_den;
- return 0;
- }
-
- /* Then, we try to parse it as fraction */
- cp = strchr(arg, '/');
- if (!cp)
- cp = strchr(arg, ':');
- if (cp) {
- char* cpp;
- frame_rate->num = strtol(arg, &cpp, 10);
- if (cpp != arg || cpp == cp)
- frame_rate->den = strtol(cp+1, &cpp, 10);
- else
- frame_rate->num = 0;
- }
- else {
- /* Finally we give up and parse it as double */
- AVRational time_base = av_d2q(strtod(arg, 0), 1001000);
- frame_rate->den = time_base.den;
- frame_rate->num = time_base.num;
- }
- if (!frame_rate->num || !frame_rate->den)
- return -1;
- else
- return 0;
+ return av_parse_video_rate(frame_rate, arg);
}
+#endif
int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
int i;
@@ -1249,7 +1158,7 @@ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
{
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "
- "version to the newest one from SVN. If the problem still "
+ "version to the newest one from Git. If the problem still "
"occurs, it means that your file has a feature which has not "
"been implemented.", feature);
if(want_sample)
diff --git a/lib/ffmpeg/libavcodec/v210dec.c b/lib/ffmpeg/libavcodec/v210dec.c
index 61e9566c87..97ef594666 100644
--- a/lib/ffmpeg/libavcodec/v210dec.c
+++ b/lib/ffmpeg/libavcodec/v210dec.c
@@ -120,7 +120,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec v210_decoder = {
+AVCodec ff_v210_decoder = {
"v210",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_V210,
diff --git a/lib/ffmpeg/libavcodec/v210enc.c b/lib/ffmpeg/libavcodec/v210enc.c
index 11e0e0eb7a..39f672d22b 100644
--- a/lib/ffmpeg/libavcodec/v210enc.c
+++ b/lib/ffmpeg/libavcodec/v210enc.c
@@ -117,7 +117,7 @@ static av_cold int encode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec v210_encoder = {
+AVCodec ff_v210_encoder = {
"v210",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_V210,
diff --git a/lib/ffmpeg/libavcodec/v210x.c b/lib/ffmpeg/libavcodec/v210x.c
index 6b93a056f9..0d6a681b78 100644
--- a/lib/ffmpeg/libavcodec/v210x.c
+++ b/lib/ffmpeg/libavcodec/v210x.c
@@ -132,7 +132,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
return 0;
}
-AVCodec v210x_decoder = {
+AVCodec ff_v210x_decoder = {
"v210x",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_V210X,
diff --git a/lib/ffmpeg/libavcodec/vaapi.c b/lib/ffmpeg/libavcodec/vaapi.c
index 10f9054278..de028a0a7e 100644
--- a/lib/ffmpeg/libavcodec/vaapi.c
+++ b/lib/ffmpeg/libavcodec/vaapi.c
@@ -180,7 +180,7 @@ int ff_vaapi_common_end_frame(MpegEncContext *s)
struct vaapi_context * const vactx = s->avctx->hwaccel_context;
int ret = -1;
- dprintf(s->avctx, "ff_vaapi_common_end_frame()\n");
+ av_dlog(s->avctx, "ff_vaapi_common_end_frame()\n");
if (commit_slices(vactx) < 0)
goto done;
diff --git a/lib/ffmpeg/libavcodec/vaapi_h264.c b/lib/ffmpeg/libavcodec/vaapi_h264.c
index 29f3a81bac..cbe526b6e7 100644
--- a/lib/ffmpeg/libavcodec/vaapi_h264.c
+++ b/lib/ffmpeg/libavcodec/vaapi_h264.c
@@ -227,7 +227,7 @@ static int start_frame(AVCodecContext *avctx,
VAPictureParameterBufferH264 *pic_param;
VAIQMatrixBufferH264 *iq_matrix;
- dprintf(avctx, "start_frame()\n");
+ av_dlog(avctx, "start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferH264);
@@ -289,7 +289,7 @@ static int end_frame(AVCodecContext *avctx)
{
H264Context * const h = avctx->priv_data;
- dprintf(avctx, "end_frame()\n");
+ av_dlog(avctx, "end_frame()\n");
return ff_vaapi_common_end_frame(&h->s);
}
@@ -302,7 +302,7 @@ static int decode_slice(AVCodecContext *avctx,
MpegEncContext * const s = &h->s;
VASliceParameterBufferH264 *slice_param;
- dprintf(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size);
+ av_dlog(avctx, "decode_slice(): buffer %p, size %d\n", buffer, size);
/* Fill in VASliceParameterBufferH264. */
slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
@@ -334,7 +334,7 @@ static int decode_slice(AVCodecContext *avctx,
return 0;
}
-AVHWAccel h264_vaapi_hwaccel = {
+AVHWAccel ff_h264_vaapi_hwaccel = {
.name = "h264_vaapi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_H264,
diff --git a/lib/ffmpeg/libavcodec/vaapi_mpeg2.c b/lib/ffmpeg/libavcodec/vaapi_mpeg2.c
index 2e870dcfa0..17d82b723f 100644
--- a/lib/ffmpeg/libavcodec/vaapi_mpeg2.c
+++ b/lib/ffmpeg/libavcodec/vaapi_mpeg2.c
@@ -44,7 +44,7 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_
VAIQMatrixBufferMPEG2 *iq_matrix;
int i;
- dprintf(avctx, "vaapi_mpeg2_start_frame()\n");
+ av_dlog(avctx, "vaapi_mpeg2_start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG2);
@@ -111,7 +111,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
GetBitContext gb;
uint32_t start_code, quantiser_scale_code, intra_slice_flag, macroblock_offset;
- dprintf(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size %d\n", buffer, size);
+ av_dlog(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size %d\n", buffer, size);
/* Determine macroblock_offset */
init_get_bits(&gb, buffer, 8 * size);
@@ -138,7 +138,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
return 0;
}
-AVHWAccel mpeg2_vaapi_hwaccel = {
+AVHWAccel ff_mpeg2_vaapi_hwaccel = {
.name = "mpeg2_vaapi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_MPEG2VIDEO,
diff --git a/lib/ffmpeg/libavcodec/vaapi_mpeg4.c b/lib/ffmpeg/libavcodec/vaapi_mpeg4.c
index 8f02e91397..78e0d646cb 100644
--- a/lib/ffmpeg/libavcodec/vaapi_mpeg4.c
+++ b/lib/ffmpeg/libavcodec/vaapi_mpeg4.c
@@ -47,7 +47,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_
VAIQMatrixBufferMPEG4 *iq_matrix;
int i;
- dprintf(avctx, "vaapi_mpeg4_start_frame()\n");
+ av_dlog(avctx, "vaapi_mpeg4_start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG4);
@@ -125,7 +125,7 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
MpegEncContext * const s = avctx->priv_data;
VASliceParameterBufferMPEG4 *slice_param;
- dprintf(avctx, "vaapi_mpeg4_decode_slice(): buffer %p, size %d\n", buffer, size);
+ av_dlog(avctx, "vaapi_mpeg4_decode_slice(): buffer %p, size %d\n", buffer, size);
/* video_plane_with_short_video_header() contains all GOBs
* in-order, and this is what VA API (Intel backend) expects: only
@@ -150,7 +150,7 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer
}
#if CONFIG_MPEG4_VAAPI_HWACCEL
-AVHWAccel mpeg4_vaapi_hwaccel = {
+AVHWAccel ff_mpeg4_vaapi_hwaccel = {
.name = "mpeg4_vaapi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_MPEG4,
@@ -164,7 +164,7 @@ AVHWAccel mpeg4_vaapi_hwaccel = {
#endif
#if CONFIG_H263_VAAPI_HWACCEL
-AVHWAccel h263_vaapi_hwaccel = {
+AVHWAccel ff_h263_vaapi_hwaccel = {
.name = "h263_vaapi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_H263,
diff --git a/lib/ffmpeg/libavcodec/vaapi_vc1.c b/lib/ffmpeg/libavcodec/vaapi_vc1.c
index 2c24042ab5..c61a5bd862 100644
--- a/lib/ffmpeg/libavcodec/vaapi_vc1.c
+++ b/lib/ffmpeg/libavcodec/vaapi_vc1.c
@@ -138,7 +138,7 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t
struct vaapi_context * const vactx = avctx->hwaccel_context;
VAPictureParameterBufferVC1 *pic_param;
- dprintf(avctx, "vaapi_vc1_start_frame()\n");
+ av_dlog(avctx, "vaapi_vc1_start_frame()\n");
vactx->slice_param_size = sizeof(VASliceParameterBufferVC1);
@@ -308,7 +308,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
MpegEncContext * const s = &v->s;
VASliceParameterBufferVC1 *slice_param;
- dprintf(avctx, "vaapi_vc1_decode_slice(): buffer %p, size %d\n", buffer, size);
+ av_dlog(avctx, "vaapi_vc1_decode_slice(): buffer %p, size %d\n", buffer, size);
/* Current bit buffer is beyond any marker for VC-1, so skip it */
if (avctx->codec_id == CODEC_ID_VC1 && IS_MARKER(AV_RB32(buffer))) {
@@ -326,7 +326,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
}
#if CONFIG_WMV3_VAAPI_HWACCEL
-AVHWAccel wmv3_vaapi_hwaccel = {
+AVHWAccel ff_wmv3_vaapi_hwaccel = {
.name = "wmv3_vaapi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_WMV3,
@@ -339,7 +339,7 @@ AVHWAccel wmv3_vaapi_hwaccel = {
};
#endif
-AVHWAccel vc1_vaapi_hwaccel = {
+AVHWAccel ff_vc1_vaapi_hwaccel = {
.name = "vc1_vaapi",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_VC1,
diff --git a/lib/ffmpeg/libavcodec/vb.c b/lib/ffmpeg/libavcodec/vb.c
index 13c4b0a8d9..fc79f5d586 100644
--- a/lib/ffmpeg/libavcodec/vb.c
+++ b/lib/ffmpeg/libavcodec/vb.c
@@ -287,7 +287,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec vb_decoder = {
+AVCodec ff_vb_decoder = {
"vb",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VB,
diff --git a/lib/ffmpeg/libavcodec/vc1.c b/lib/ffmpeg/libavcodec/vc1.c
index cca345df38..86904cbffd 100644
--- a/lib/ffmpeg/libavcodec/vc1.c
+++ b/lib/ffmpeg/libavcodec/vc1.c
@@ -306,13 +306,17 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
{
v->zz_8x4 = wmv2_scantableA;
v->zz_4x8 = wmv2_scantableB;
- v->res_sm = get_bits(gb, 2); //reserved
- if (v->res_sm)
+ v->res_y411 = get_bits1(gb);
+ v->res_sprite = get_bits1(gb);
+ if (v->res_y411)
{
av_log(avctx, AV_LOG_ERROR,
- "Reserved RES_SM=%i is forbidden\n", v->res_sm);
+ "Old interlaced mode is not supported\n");
return -1;
}
+ if (v->res_sprite) {
+ av_log(avctx, AV_LOG_ERROR, "WMVP is not fully supported\n");
+ }
}
// (fps-2)/4 (->30)
@@ -382,7 +386,21 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte
v->quantizer_mode = get_bits(gb, 2); //common
v->finterpflag = get_bits1(gb); //common
- v->res_rtm_flag = get_bits1(gb); //reserved
+
+ if (v->res_sprite) {
+ v->s.avctx->width = v->s.avctx->coded_width = get_bits(gb, 11);
+ v->s.avctx->height = v->s.avctx->coded_height = get_bits(gb, 11);
+ skip_bits(gb, 5); //frame rate
+ v->res_x8 = get_bits1(gb);
+ if (get_bits1(gb)) { // something to do with DC VLC selection
+ av_log(avctx, AV_LOG_ERROR, "Unsupported sprite feature\n");
+ return -1;
+ }
+ skip_bits(gb, 3); //slice code
+ v->res_rtm_flag = 0;
+ } else {
+ v->res_rtm_flag = get_bits1(gb); //reserved
+ }
if (!v->res_rtm_flag)
{
// av_log(avctx, AV_LOG_ERROR,
@@ -561,6 +579,9 @@ int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant, status;
+ if(v->res_sprite) {
+ skip_bits(gb, 2); //not yet deciphered
+ }
if(v->finterpflag) v->interpfrm = get_bits1(gb);
skip_bits(gb, 2); //framecnt unused
v->rangeredfrm = 0;
diff --git a/lib/ffmpeg/libavcodec/vc1.h b/lib/ffmpeg/libavcodec/vc1.h
index d5f0e05465..e5a9cbaec1 100644
--- a/lib/ffmpeg/libavcodec/vc1.h
+++ b/lib/ffmpeg/libavcodec/vc1.h
@@ -160,7 +160,8 @@ typedef struct VC1Context{
/** Simple/Main Profile sequence header */
//@{
- int res_sm; ///< reserved, 2b
+ int res_sprite; ///< reserved, sprite mode
+ int res_y411; ///< reserved, old interlaced mode
int res_x8; ///< reserved
int multires; ///< frame-level RESPIC syntax element present
int res_fasttx; ///< reserved, always 1
diff --git a/lib/ffmpeg/libavcodec/vc1_parser.c b/lib/ffmpeg/libavcodec/vc1_parser.c
index 6e559dec9b..98caa2048d 100644
--- a/lib/ffmpeg/libavcodec/vc1_parser.c
+++ b/lib/ffmpeg/libavcodec/vc1_parser.c
@@ -169,7 +169,7 @@ static int vc1_split(AVCodecContext *avctx,
return 0;
}
-AVCodecParser vc1_parser = {
+AVCodecParser ff_vc1_parser = {
{ CODEC_ID_VC1 },
sizeof(VC1ParseContext),
NULL,
diff --git a/lib/ffmpeg/libavcodec/vc1dec.c b/lib/ffmpeg/libavcodec/vc1dec.c
index 8c9cbcd9db..3bd2cce297 100644
--- a/lib/ffmpeg/libavcodec/vc1dec.c
+++ b/lib/ffmpeg/libavcodec/vc1dec.c
@@ -288,12 +288,12 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
uint8_t *uvbuf= s->edge_emu_buffer + 19 * s->linesize;
srcY -= s->mspel * (1 + s->linesize);
- ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2,
src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos);
srcY = s->edge_emu_buffer;
- ff_emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1,
+ s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- ff_emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1,
+ s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
srcU = uvbuf;
srcV = uvbuf + 16;
@@ -403,7 +403,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n)
|| (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 8 - s->mspel*2
|| (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 8 - s->mspel*2){
srcY -= s->mspel * (1 + s->linesize);
- ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 9+s->mspel*2, 9+s->mspel*2,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 9+s->mspel*2, 9+s->mspel*2,
src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos);
srcY = s->edge_emu_buffer;
/* if we deal with range reduction we need to scale source blocks */
@@ -537,9 +537,9 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
|| (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
|| (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - 9){
- ff_emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- ff_emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, 8+1, 8+1,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, 8+1, 8+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
srcU = s->edge_emu_buffer;
srcV = s->edge_emu_buffer + 16;
@@ -872,12 +872,12 @@ static void vc1_interp_mc(VC1Context *v)
uint8_t *uvbuf= s->edge_emu_buffer + 19 * s->linesize;
srcY -= s->mspel * (1 + s->linesize);
- ff_emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2,
src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos);
srcY = s->edge_emu_buffer;
- ff_emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1,
+ s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- ff_emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1,
+ s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1,
uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
srcU = uvbuf;
srcV = uvbuf + 16;
@@ -3240,6 +3240,11 @@ static int vc1_decode_frame(AVCodecContext *avctx,
}
}
+ if(v->res_sprite && (s->pict_type!=FF_I_TYPE)){
+ 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;
@@ -3340,7 +3345,7 @@ static av_cold int vc1_decode_end(AVCodecContext *avctx)
}
-AVCodec vc1_decoder = {
+AVCodec ff_vc1_decoder = {
"vc1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VC1,
@@ -3356,7 +3361,7 @@ AVCodec vc1_decoder = {
};
#if CONFIG_WMV3_DECODER
-AVCodec wmv3_decoder = {
+AVCodec ff_wmv3_decoder = {
"wmv3",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WMV3,
@@ -3373,7 +3378,7 @@ AVCodec wmv3_decoder = {
#endif
#if CONFIG_WMV3_VDPAU_DECODER
-AVCodec wmv3_vdpau_decoder = {
+AVCodec ff_wmv3_vdpau_decoder = {
"wmv3_vdpau",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WMV3,
@@ -3390,7 +3395,7 @@ AVCodec wmv3_vdpau_decoder = {
#endif
#if CONFIG_VC1_VDPAU_DECODER
-AVCodec vc1_vdpau_decoder = {
+AVCodec ff_vc1_vdpau_decoder = {
"vc1_vdpau",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VC1,
diff --git a/lib/ffmpeg/libavcodec/vc1dsp.c b/lib/ffmpeg/libavcodec/vc1dsp.c
index 8634bef69b..aab1694797 100644
--- a/lib/ffmpeg/libavcodec/vc1dsp.c
+++ b/lib/ffmpeg/libavcodec/vc1dsp.c
@@ -630,7 +630,7 @@ av_cold void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c;
dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c;
- dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_c;
+ dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_pixels8x8_c;
dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;
dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_c;
dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_c;
@@ -647,7 +647,7 @@ av_cold void ff_vc1dsp_init(DSPContext* dsp, AVCodecContext *avctx) {
dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
- dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_vc1_mspel_mc00_c;
+ dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_pixels8x8_c;
dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_c;
dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_c;
dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_c;
diff --git a/lib/ffmpeg/libavcodec/vcr1.c b/lib/ffmpeg/libavcodec/vcr1.c
index 31da94f3d0..9a9c439881 100644
--- a/lib/ffmpeg/libavcodec/vcr1.c
+++ b/lib/ffmpeg/libavcodec/vcr1.c
@@ -176,7 +176,7 @@ static av_cold int encode_init(AVCodecContext *avctx){
}
#endif
-AVCodec vcr1_decoder = {
+AVCodec ff_vcr1_decoder = {
"vcr1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VCR1,
@@ -190,7 +190,7 @@ AVCodec vcr1_decoder = {
};
#if CONFIG_VCR1_ENCODER
-AVCodec vcr1_encoder = {
+AVCodec ff_vcr1_encoder = {
"vcr1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VCR1,
diff --git a/lib/ffmpeg/libavcodec/vmdav.c b/lib/ffmpeg/libavcodec/vmdav.c
index 4914d2a09a..e396c0bc9e 100644
--- a/lib/ffmpeg/libavcodec/vmdav.c
+++ b/lib/ffmpeg/libavcodec/vmdav.c
@@ -446,7 +446,7 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx)
s->channels = avctx->channels;
s->bits = avctx->bits_per_coded_sample;
s->block_align = avctx->block_align;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
av_log(s->avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, block align = %d, sample rate = %d\n",
s->channels, s->bits, s->block_align, avctx->sample_rate);
@@ -565,7 +565,7 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
* Public Data Structures
*/
-AVCodec vmdvideo_decoder = {
+AVCodec ff_vmdvideo_decoder = {
"vmdvideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VMDVIDEO,
@@ -578,7 +578,7 @@ AVCodec vmdvideo_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("Sierra VMD video"),
};
-AVCodec vmdaudio_decoder = {
+AVCodec ff_vmdaudio_decoder = {
"vmdaudio",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_VMDAUDIO,
diff --git a/lib/ffmpeg/libavcodec/vmnc.c b/lib/ffmpeg/libavcodec/vmnc.c
index 49aaeb2992..e13452dcc6 100644
--- a/lib/ffmpeg/libavcodec/vmnc.c
+++ b/lib/ffmpeg/libavcodec/vmnc.c
@@ -508,7 +508,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec vmnc_decoder = {
+AVCodec ff_vmnc_decoder = {
"vmnc",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VMNC,
diff --git a/lib/ffmpeg/libavcodec/vorbis_dec.c b/lib/ffmpeg/libavcodec/vorbis_dec.c
index b3cc43fca4..bca56ba663 100644
--- a/lib/ffmpeg/libavcodec/vorbis_dec.c
+++ b/lib/ffmpeg/libavcodec/vorbis_dec.c
@@ -31,6 +31,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
#include "vorbis.h"
#include "xiph.h"
@@ -61,8 +62,8 @@ typedef struct vorbis_floor0_s vorbis_floor0;
typedef struct vorbis_floor1_s vorbis_floor1;
struct vorbis_context_s;
typedef
-uint_fast8_t (* vorbis_floor_decode_func)
- (struct vorbis_context_s *, vorbis_floor_data *, float *);
+int (* vorbis_floor_decode_func)
+ (struct vorbis_context_s *, vorbis_floor_data *, float *);
typedef struct {
uint_fast8_t floor_type;
vorbis_floor_decode_func decode;
@@ -81,7 +82,7 @@ typedef struct {
} t0;
struct vorbis_floor1_s {
uint_fast8_t partitions;
- uint_fast8_t partition_class[32];
+ uint8_t partition_class[32];
uint_fast8_t class_dimensions[16];
uint_fast8_t class_subclasses[16];
uint_fast8_t class_masterbook[16];
@@ -97,13 +98,13 @@ typedef struct {
uint_fast16_t type;
uint_fast32_t begin;
uint_fast32_t end;
- uint_fast32_t partition_size;
+ unsigned partition_size;
uint_fast8_t classifications;
uint_fast8_t classbook;
int_fast16_t books[64][8];
uint_fast8_t maxpass;
uint_fast16_t ptns_to_read;
- uint_fast8_t *classifs;
+ uint8_t *classifs;
} vorbis_residue;
typedef struct {
@@ -127,6 +128,7 @@ typedef struct vorbis_context_s {
AVCodecContext *avccontext;
GetBitContext gb;
DSPContext dsp;
+ FmtConvertContext fmt_conv;
FFTContext mdct[2];
uint_fast8_t first_frame;
@@ -153,8 +155,7 @@ typedef struct vorbis_context_s {
float *channel_residues;
float *channel_floors;
float *saved;
- uint_fast32_t add_bias; // for float->int conversion
- uint_fast32_t exp_bias;
+ float scale_bias; // for float->int conversion
} vorbis_context;
/* Helper functions */
@@ -459,15 +460,15 @@ static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc)
// Process floors part
-static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec);
+static int vorbis_floor0_decode(vorbis_context *vc,
+ vorbis_floor_data *vfu, float *vec);
static void create_map(vorbis_context *vc, uint_fast8_t floor_number);
-static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec);
+static int vorbis_floor1_decode(vorbis_context *vc,
+ vorbis_floor_data *vfu, float *vec);
static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
{
GetBitContext *gb = &vc->gb;
- uint_fast16_t i,j,k;
+ int i,j,k;
vc->floor_count = get_bits(gb, 6) + 1;
@@ -483,6 +484,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
if (floor_setup->floor_type == 1) {
int maximum_class = -1;
uint_fast8_t rangebits;
+ uint_fast32_t rangemax;
uint_fast16_t floor1_values = 2;
floor_setup->decode = vorbis_floor1_decode;
@@ -534,8 +536,15 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
rangebits = get_bits(gb, 4);
+ rangemax = (1 << rangebits);
+ if (rangemax > vc->blocksize[1] / 2) {
+ av_log(vc->avccontext, AV_LOG_ERROR,
+ "Floor value is too large for blocksize: %d (%d)\n",
+ rangemax, vc->blocksize[1] / 2);
+ return -1;
+ }
floor_setup->data.t1.list[0].x = 0;
- floor_setup->data.t1.list[1].x = (1 << rangebits);
+ floor_setup->data.t1.list[1].x = rangemax;
for (j = 0; j < floor_setup->data.t1.partitions; ++j) {
for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) {
@@ -653,9 +662,9 @@ 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->avccontext->channels * vc->blocksize[1] / (res_setup->type == 2 ? 1 : 2) ||
+ res_setup->end > vc->avccontext->channels * vc->blocksize[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);
+ av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %u, %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2);
return -1;
}
@@ -667,6 +676,8 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->classifs = av_malloc(res_setup->ptns_to_read *
vc->audio_channels *
sizeof(*res_setup->classifs));
+ if (!res_setup->classifs)
+ return AVERROR(ENOMEM);
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);
@@ -922,8 +933,8 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
vc->saved = av_mallocz((vc->blocksize[1] / 4) * vc->audio_channels * sizeof(float));
vc->previous_window = 0;
- ff_mdct_init(&vc->mdct[0], bl0, 1, vc->exp_bias ? -(1 << 15) : -1.0);
- ff_mdct_init(&vc->mdct[1], bl1, 1, vc->exp_bias ? -(1 << 15) : -1.0);
+ ff_mdct_init(&vc->mdct[0], bl0, 1, -vc->scale_bias);
+ ff_mdct_init(&vc->mdct[1], bl1, 1, -vc->scale_bias);
AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
@@ -952,14 +963,9 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
vc->avccontext = avccontext;
dsputil_init(&vc->dsp, avccontext);
+ ff_fmt_convert_init(&vc->fmt_conv, avccontext);
- if (vc->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- vc->add_bias = 385;
- vc->exp_bias = 0;
- } else {
- vc->add_bias = 0;
- vc->exp_bias = 15 << 23;
- }
+ vc->scale_bias = 32768.0f;
if (!headers_len) {
av_log(avccontext, AV_LOG_ERROR, "Extradata missing.\n");
@@ -1004,7 +1010,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
avccontext->channels = vc->audio_channels;
avccontext->sample_rate = vc->audio_samplerate;
avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2;
- avccontext->sample_fmt = SAMPLE_FMT_S16;
+ avccontext->sample_fmt = AV_SAMPLE_FMT_S16;
return 0 ;
}
@@ -1013,8 +1019,8 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
// Read and decode floor
-static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec)
+static int vorbis_floor0_decode(vorbis_context *vc,
+ vorbis_floor_data *vfu, float *vec)
{
vorbis_floor0 *vf = &vfu->t0;
float *lsp = vf->lsp;
@@ -1038,6 +1044,9 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
}
AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx);
codebook = vc->codebooks[vf->book_list[book_idx]];
+ /* Invalid codebook! */
+ if (!codebook.codevectors)
+ return -1;
while (lsp_len<vf->order) {
int vec_off;
@@ -1123,8 +1132,8 @@ static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc,
return 0;
}
-static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec)
+static int vorbis_floor1_decode(vorbis_context *vc,
+ vorbis_floor_data *vfu, float *vec)
{
vorbis_floor1 *vf = &vfu->t1;
GetBitContext *gb = &vc->gb;
@@ -1141,8 +1150,8 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
int_fast16_t book;
uint_fast16_t offset;
uint_fast16_t i,j;
- /*u*/int_fast16_t adx, ady, off, predicted; // WTF ? dy/adx = (unsigned)dy/adx ?
- int_fast16_t dy, err;
+ int_fast16_t adx, ady, dy, off, predicted;
+ int_fast32_t err;
if (!get_bits1(gb)) // silence
@@ -1205,7 +1214,7 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc,
adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;
ady = FFABS(dy);
err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);
- off = (int16_t)err / (int16_t)adx;
+ off = err / adx;
if (dy < 0) {
predicted = floor1_Y_final[low_neigh_offs] - off;
} else {
@@ -1267,7 +1276,7 @@ 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 ptns_to_read = vr->ptns_to_read;
- uint_fast8_t *classifs = vr->classifs;
+ uint8_t *classifs = vr->classifs;
uint_fast8_t pass;
uint_fast8_t ch_used;
uint_fast8_t i,j,l;
@@ -1440,18 +1449,6 @@ void vorbis_inverse_coupling(float *mag, float *ang, int blocksize)
}
}
-static void copy_normalize(float *dst, float *src, int len, int exp_bias,
- float add_bias)
-{
- int i;
- if (exp_bias) {
- memcpy(dst, src, len * sizeof(float));
- } else {
- for (i = 0; i < len; i++)
- dst[i] = src[i] + add_bias;
- }
-}
-
// Decode the audio packet using the functions above
static int vorbis_parse_audio_packet(vorbis_context *vc)
@@ -1471,7 +1468,6 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
uint_fast8_t res_chan[255];
uint_fast8_t res_num = 0;
int_fast16_t retlen = 0;
- float fadd_bias = vc->add_bias;
if (get_bits1(gb)) {
av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
@@ -1500,13 +1496,20 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
for (i = 0; i < vc->audio_channels; ++i) {
vorbis_floor *floor;
+ int ret;
if (mapping->submaps > 1) {
floor = &vc->floors[mapping->submap_floor[mapping->mux[i]]];
} else {
floor = &vc->floors[mapping->submap_floor[0]];
}
- no_residue[i] = floor->decode(vc, &floor->data, ch_floor_ptr);
+ ret = floor->decode(vc, &floor->data, ch_floor_ptr);
+
+ if (ret < 0) {
+ av_log(vc->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n");
+ return -1;
+ }
+ no_residue[i] = ret;
ch_floor_ptr += blocksize / 2;
}
@@ -1558,7 +1561,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
for (j = vc->audio_channels-1;j >= 0; j--) {
ch_floor_ptr = vc->channel_floors + j * blocksize / 2;
ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2;
- vc->dsp.vector_fmul(ch_floor_ptr, ch_res_ptr, blocksize / 2);
+ vc->dsp.vector_fmul(ch_floor_ptr, ch_floor_ptr, ch_res_ptr, blocksize / 2);
ff_imdct_half(&vc->mdct[blockflag], ch_res_ptr, ch_floor_ptr);
}
@@ -1575,13 +1578,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
const float *win = vc->win[blockflag & previous_window];
if (blockflag == previous_window) {
- vc->dsp.vector_fmul_window(ret, saved, buf, win, fadd_bias, blocksize / 4);
+ vc->dsp.vector_fmul_window(ret, saved, buf, win, blocksize / 4);
} else if (blockflag > previous_window) {
- vc->dsp.vector_fmul_window(ret, saved, buf, win, fadd_bias, bs0 / 4);
- copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4, vc->exp_bias, fadd_bias);
+ vc->dsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);
+ memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
} else {
- copy_normalize(ret, saved, (bs1 - bs0) / 4, vc->exp_bias, fadd_bias);
- vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, fadd_bias, bs0 / 4);
+ memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
+ vc->dsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
}
memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float));
}
@@ -1636,7 +1639,8 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
len * ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i];
}
- vc->dsp.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels);
+ vc->fmt_conv.float_to_int16_interleave(data, channel_ptrs, len,
+ vc->audio_channels);
*data_size = len * 2 * vc->audio_channels;
return buf_size ;
@@ -1653,7 +1657,7 @@ static av_cold int vorbis_decode_close(AVCodecContext *avccontext)
return 0 ;
}
-AVCodec vorbis_decoder = {
+AVCodec ff_vorbis_decoder = {
"vorbis",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_VORBIS,
diff --git a/lib/ffmpeg/libavcodec/vorbis_enc.c b/lib/ffmpeg/libavcodec/vorbis_enc.c
index f6385fdc96..93683ac422 100644
--- a/lib/ffmpeg/libavcodec/vorbis_enc.c
+++ b/lib/ffmpeg/libavcodec/vorbis_enc.c
@@ -126,6 +126,17 @@ typedef struct {
int64_t sample_count;
} vorbis_enc_context;
+#define MAX_CHANNELS 2
+#define MAX_CODEBOOK_DIM 8
+
+#define MAX_FLOOR_CLASS_DIM 4
+#define NUM_FLOOR_PARTITIONS 8
+#define MAX_FLOOR_VALUES (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)
+
+#define RESIDUE_SIZE 1600
+#define RESIDUE_PART_SIZE 32
+#define NUM_RESIDUE_PARTITIONS (RESIDUE_SIZE/RESIDUE_PART_SIZE)
+
static inline void put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,
int entry)
{
@@ -263,7 +274,7 @@ static void create_vorbis_context(vorbis_enc_context *venc,
// just 1 floor
fc = &venc->floors[0];
- fc->partitions = 8;
+ fc->partitions = NUM_FLOOR_PARTITIONS;
fc->partition_to_class = av_malloc(sizeof(int) * fc->partitions);
fc->nclasses = 0;
for (i = 0; i < fc->partitions; i++) {
@@ -668,7 +679,7 @@ static void floor_fit(vorbis_enc_context *venc, vorbis_enc_floor *fc,
int range = 255 / fc->multiplier + 1;
int i;
float tot_average = 0.;
- float averages[fc->values];
+ float averages[MAX_FLOOR_VALUES];
for (i = 0; i < fc->values; i++) {
averages[i] = get_floor_average(fc, coeffs, i);
tot_average += averages[i];
@@ -699,7 +710,7 @@ static void floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
float *floor, int samples)
{
int range = 255 / fc->multiplier + 1;
- int coded[fc->values]; // first 2 values are unused
+ int coded[MAX_FLOOR_VALUES]; // first 2 values are unused
int i, counter;
put_bits(pb, 1, 1); // non zero
@@ -807,7 +818,7 @@ static void residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
int psize = rc->partition_size;
int partitions = (rc->end - rc->begin) / psize;
int channels = (rc->type == 2) ? 1 : real_ch;
- int classes[channels][partitions];
+ int classes[MAX_CHANNELS][NUM_RESIDUE_PARTITIONS];
int classwords = venc->codebooks[rc->classbook].ndimentions;
assert(rc->type == 2);
@@ -864,7 +875,7 @@ static void residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
s = real_ch * samples;
for (k = 0; k < psize; k += book->ndimentions) {
int dim, a2 = a1, b2 = b1;
- float vec[book->ndimentions], *pv = vec;
+ float vec[MAX_CODEBOOK_DIM], *pv = vec;
for (dim = book->ndimentions; dim--; ) {
*pv++ = coeffs[a2 + b2];
if ((a2 += samples) == s) {
@@ -888,7 +899,7 @@ static void residue_encode(vorbis_enc_context *venc, vorbis_enc_residue *rc,
}
}
-static int apply_window_and_mdct(vorbis_enc_context *venc, signed short *audio,
+static int apply_window_and_mdct(vorbis_enc_context *venc, const signed short *audio,
int samples)
{
int i, j, channel;
@@ -973,7 +984,7 @@ static int vorbis_encode_frame(AVCodecContext *avccontext,
int buf_size, void *data)
{
vorbis_enc_context *venc = avccontext->priv_data;
- signed short *audio = data;
+ const signed short *audio = data;
int samples = data ? avccontext->frame_size : 0;
vorbis_enc_mode *mode;
vorbis_enc_mapping *mapping;
@@ -999,7 +1010,7 @@ static int vorbis_encode_frame(AVCodecContext *avccontext,
for (i = 0; i < venc->channels; i++) {
vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]];
- uint_fast16_t posts[fc->values];
+ uint_fast16_t posts[MAX_FLOOR_VALUES];
floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples);
floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples);
}
@@ -1091,7 +1102,7 @@ static av_cold int vorbis_encode_close(AVCodecContext *avccontext)
return 0 ;
}
-AVCodec vorbis_encoder = {
+AVCodec ff_vorbis_encoder = {
"vorbis",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_VORBIS,
@@ -1100,6 +1111,6 @@ AVCodec vorbis_encoder = {
vorbis_encode_frame,
vorbis_encode_close,
.capabilities= CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
};
diff --git a/lib/ffmpeg/libavcodec/vp3.c b/lib/ffmpeg/libavcodec/vp3.c
index 83835b26c5..d634fca0eb 100644
--- a/lib/ffmpeg/libavcodec/vp3.c
+++ b/lib/ffmpeg/libavcodec/vp3.c
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <string.h>
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"
@@ -1321,12 +1322,11 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
return;
h= y - s->last_slice_end;
+ s->last_slice_end= y;
y -= h;
if (!s->flipped_image) {
- if (y == 0)
- h -= s->height - s->avctx->height; // account for non-mod16
- y = s->height - y - h;
+ y = s->avctx->height - y - h;
}
cy = y >> s->chroma_y_shift;
@@ -1337,7 +1337,6 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
emms_c();
s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);
- s->last_slice_end= y + h;
}
/*
@@ -1433,7 +1432,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
if(stride<0) temp -= 9*stride;
else temp += 9*stride;
- ff_emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height);
+ s->dsp.emulated_edge_mc(temp, motion_source, stride, 9, 9, src_x, src_y, plane_width, plane_height);
motion_source= temp;
}
}
@@ -1508,7 +1507,7 @@ static void render_slice(Vp3DecodeContext *s, int slice)
* dispatch (slice - 1);
*/
- vp3_draw_horiz_band(s, FFMIN(64*slice + 64-16, s->height-16));
+ vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16));
}
/*
@@ -1722,7 +1721,6 @@ static int vp3_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size;
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
- static int counter = 0;
int i;
init_get_bits(&gb, buf, buf_size * 8);
@@ -1748,8 +1746,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, " VP3 %sframe #%d: Q index = %d\n",
- s->keyframe?"key":"", counter, s->qps[0]);
- counter++;
+ s->keyframe?"key":"", avctx->frame_number+1, s->qps[0]);
s->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL : AVDISCARD_NONKEY);
@@ -1782,7 +1779,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
if (s->version)
{
s->version = get_bits(&gb, 5);
- if (counter == 1)
+ if (avctx->frame_number == 0)
av_log(s->avctx, AV_LOG_DEBUG, "VP version: %d\n", s->version);
}
}
@@ -1850,7 +1847,7 @@ static int vp3_decode_frame(AVCodecContext *avctx,
int row = (s->height >> (3+(i && s->chroma_y_shift))) - 1;
apply_loop_filter(s, i, row, row+1);
}
- vp3_draw_horiz_band(s, s->height);
+ vp3_draw_horiz_band(s, s->avctx->height);
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->current_frame;
@@ -1965,7 +1962,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
Vp3DecodeContext *s = avctx->priv_data;
int visible_width, visible_height, colorspace;
int offset_x = 0, offset_y = 0;
- AVRational fps;
+ AVRational fps, aspect;
s->theora = get_bits_long(gb, 24);
av_log(avctx, AV_LOG_DEBUG, "Theora bitstream version %X\n", s->theora);
@@ -1981,7 +1978,7 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
visible_width = s->width = get_bits(gb, 16) << 4;
visible_height = s->height = get_bits(gb, 16) << 4;
- if(avcodec_check_dimensions(avctx, s->width, s->height)){
+ if(av_image_check_size(s->width, s->height, 0, avctx)){
av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", s->width, s->height);
s->width= s->height= 0;
return -1;
@@ -2002,8 +1999,13 @@ static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
fps.den, fps.num, 1<<30);
}
- avctx->sample_aspect_ratio.num = get_bits_long(gb, 24);
- avctx->sample_aspect_ratio.den = get_bits_long(gb, 24);
+ aspect.num = get_bits_long(gb, 24);
+ aspect.den = get_bits_long(gb, 24);
+ if (aspect.num && aspect.den) {
+ av_reduce(&avctx->sample_aspect_ratio.num,
+ &avctx->sample_aspect_ratio.den,
+ aspect.num, aspect.den, 1<<30);
+ }
if (s->theora < 0x030200)
skip_bits(gb, 5); /* keyframe frequency force */
@@ -2049,13 +2051,9 @@ static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
if (s->theora >= 0x030200) {
n = get_bits(gb, 3);
/* loop filter limit values table */
- for (i = 0; i < 64; i++) {
- s->filter_limit_values[i] = get_bits(gb, n);
- if (s->filter_limit_values[i] > 127) {
- av_log(avctx, AV_LOG_ERROR, "filter limit value too large (%i > 127), clamping\n", s->filter_limit_values[i]);
- s->filter_limit_values[i] = 127;
- }
- }
+ if (n)
+ for (i = 0; i < 64; i++)
+ s->filter_limit_values[i] = get_bits(gb, n);
}
if (s->theora >= 0x030200)
@@ -2215,7 +2213,7 @@ static av_cold int theora_decode_init(AVCodecContext *avctx)
return vp3_decode_init(avctx);
}
-AVCodec theora_decoder = {
+AVCodec ff_theora_decoder = {
"theora",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_THEORA,
@@ -2230,7 +2228,7 @@ AVCodec theora_decoder = {
};
#endif
-AVCodec vp3_decoder = {
+AVCodec ff_vp3_decoder = {
"vp3",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP3,
diff --git a/lib/ffmpeg/libavcodec/vp3_parser.c b/lib/ffmpeg/libavcodec/vp3_parser.c
index c22e6dd277..4453447aaf 100644
--- a/lib/ffmpeg/libavcodec/vp3_parser.c
+++ b/lib/ffmpeg/libavcodec/vp3_parser.c
@@ -35,7 +35,7 @@ static int parse(AVCodecParserContext *s,
return buf_size;
}
-AVCodecParser vp3_parser = {
+AVCodecParser ff_vp3_parser = {
{ CODEC_ID_THEORA, CODEC_ID_VP3,
CODEC_ID_VP6, CODEC_ID_VP6F, CODEC_ID_VP6A },
0,
diff --git a/lib/ffmpeg/libavcodec/vp5.c b/lib/ffmpeg/libavcodec/vp5.c
index 1479344ba4..e9de38e6dd 100644
--- a/lib/ffmpeg/libavcodec/vp5.c
+++ b/lib/ffmpeg/libavcodec/vp5.c
@@ -39,10 +39,10 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
VP56RangeCoder *c = &s->c;
int rows, cols;
- vp56_init_range_decoder(&s->c, buf, buf_size);
+ ff_vp56_init_range_decoder(&s->c, buf, buf_size);
s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c);
vp56_rac_get(c);
- vp56_init_dequant(s, vp56_rac_gets(c, 6));
+ ff_vp56_init_dequant(s, vp56_rac_gets(c, 6));
if (s->framep[VP56_FRAME_CURRENT]->key_frame)
{
vp56_rac_gets(c, 8);
@@ -254,7 +254,7 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx)
{
VP56Context *s = avctx->priv_data;
- vp56_init(avctx, 1, 0);
+ ff_vp56_init(avctx, 1, 0);
s->vp56_coord_div = vp5_coord_div;
s->parse_vector_adjustment = vp5_parse_vector_adjustment;
s->parse_coeff = vp5_parse_coeff;
@@ -266,15 +266,15 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx)
return 0;
}
-AVCodec vp5_decoder = {
+AVCodec ff_vp5_decoder = {
"vp5",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP5,
sizeof(VP56Context),
vp5_decode_init,
NULL,
- vp56_free,
- vp56_decode_frame,
+ ff_vp56_free,
+ ff_vp56_decode_frame,
CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("On2 VP5"),
};
diff --git a/lib/ffmpeg/libavcodec/vp56.c b/lib/ffmpeg/libavcodec/vp56.c
index 74fe5ff5f4..3412e3dce2 100644
--- a/lib/ffmpeg/libavcodec/vp56.c
+++ b/lib/ffmpeg/libavcodec/vp56.c
@@ -28,7 +28,7 @@
#include "vp56data.h"
-void vp56_init_dequant(VP56Context *s, int quantizer)
+void ff_vp56_init_dequant(VP56Context *s, int quantizer)
{
s->quantizer = quantizer;
s->dequant_dc = vp56_dc_dequant[quantizer] << 2;
@@ -337,7 +337,7 @@ static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src,
if (x<0 || x+12>=s->plane_width[plane] ||
y<0 || y+12>=s->plane_height[plane]) {
- ff_emulated_edge_mc(s->edge_emu_buffer,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer,
src + s->block_offset[b] + (dy-2)*stride + (dx-2),
stride, 12, 12, x, y,
s->plane_width[plane],
@@ -481,8 +481,8 @@ static int vp56_size_changed(AVCodecContext *avctx)
return 0;
}
-int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
- AVPacket *avpkt)
+int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+ AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
VP56Context *s = avctx->priv_data;
@@ -639,7 +639,7 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
return avpkt->size;
}
-av_cold void vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
+av_cold void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
{
VP56Context *s = avctx->priv_data;
int i;
@@ -678,7 +678,7 @@ av_cold void vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
}
}
-av_cold int vp56_free(AVCodecContext *avctx)
+av_cold int ff_vp56_free(AVCodecContext *avctx)
{
VP56Context *s = avctx->priv_data;
diff --git a/lib/ffmpeg/libavcodec/vp56.h b/lib/ffmpeg/libavcodec/vp56.h
index 6bdea23fdf..da6b1b64b8 100644
--- a/lib/ffmpeg/libavcodec/vp56.h
+++ b/lib/ffmpeg/libavcodec/vp56.h
@@ -32,7 +32,11 @@
#include "vp56dsp.h"
typedef struct vp56_context VP56Context;
-typedef struct vp56_mv VP56mv;
+
+typedef struct {
+ int16_t x;
+ int16_t y;
+} DECLARE_ALIGNED(4, , VP56mv);
typedef void (*VP56ParseVectorAdjustment)(VP56Context *s,
VP56mv *vect);
@@ -52,7 +56,7 @@ typedef struct {
bits left) in order to eliminate a negate in cache refilling */
const uint8_t *buffer;
const uint8_t *end;
- unsigned long code_word;
+ unsigned int code_word;
} VP56RangeCoder;
typedef struct {
@@ -61,11 +65,6 @@ typedef struct {
DCTELEM dc_coeff;
} VP56RefDc;
-struct vp56_mv {
- int x;
- int y;
-};
-
typedef struct {
uint8_t type;
VP56mv mv;
@@ -171,87 +170,100 @@ struct vp56_context {
};
-void vp56_init(AVCodecContext *avctx, int flip, int has_alpha);
-int vp56_free(AVCodecContext *avctx);
-void vp56_init_dequant(VP56Context *s, int quantizer);
-int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
- AVPacket *avpkt);
+void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha);
+int ff_vp56_free(AVCodecContext *avctx);
+void ff_vp56_init_dequant(VP56Context *s, int quantizer);
+int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+ AVPacket *avpkt);
/**
* vp56 specific range coder implementation
*/
-static inline void vp56_init_range_decoder(VP56RangeCoder *c,
- const uint8_t *buf, int buf_size)
-{
- c->high = 255;
- c->bits = -8;
- c->buffer = buf;
- c->end = buf + buf_size;
- c->code_word = bytestream_get_be16(&c->buffer);
-}
+extern const uint8_t ff_vp56_norm_shift[256];
+void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size);
-static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
+static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
{
- /* 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 shift = ff_vp56_norm_shift[c->high];
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 = code_word >= low_shift;
- int shift;
+ unsigned int code_word = c->code_word;
- /* 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 */
- 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;
+ code_word |= bytestream_get_be16(&c->buffer) << bits;
+ bits -= 16;
}
c->bits = bits;
- c->code_word = code_word;
+ return code_word;
+}
+
+#if ARCH_X86
+#include "x86/vp56_arith.h"
+#endif
+
+#ifndef vp56_rac_get_prob
+#define vp56_rac_get_prob vp56_rac_get_prob
+static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
+{
+ unsigned int code_word = vp56_rac_renorm(c);
+ unsigned int low = 1 + (((c->high - 1) * prob) >> 8);
+ unsigned int low_shift = low << 16;
+ int bit = code_word >= low_shift;
+
+ c->high = bit ? c->high - low : low;
+ c->code_word = bit ? code_word - low_shift : code_word;
+
return bit;
}
+#endif
+
+// branchy variant, to be used where there's a branch based on the bit decoded
+static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
+{
+ unsigned long code_word = vp56_rac_renorm(c);
+ unsigned low = 1 + (((c->high - 1) * prob) >> 8);
+ unsigned low_shift = low << 16;
+
+ if (code_word >= low_shift) {
+ c->high -= low;
+ c->code_word = code_word - low_shift;
+ return 1;
+ }
+
+ c->high = low;
+ c->code_word = code_word;
+ return 0;
+}
-static inline int vp56_rac_get(VP56RangeCoder *c)
+static av_always_inline int vp56_rac_get(VP56RangeCoder *c)
{
+ unsigned int code_word = vp56_rac_renorm(c);
/* equiprobable */
int low = (c->high + 1) >> 1;
- unsigned int low_shift = low << 8;
- int bit = c->code_word >= low_shift;
+ unsigned int low_shift = low << 16;
+ int bit = code_word >= low_shift;
if (bit) {
- c->high = (c->high - low) << 1;
- c->code_word -= low_shift;
+ c->high -= low;
+ code_word -= low_shift;
} else {
- c->high = low << 1;
+ c->high = low;
}
- /* normalize */
- c->code_word <<= 1;
- if (++c->bits == 0 && c->buffer < c->end) {
- c->bits = -8;
- c->code_word |= *c->buffer++;
- }
+ c->code_word = code_word;
return bit;
}
// rounding is different than vp56_rac_get, is vp56_rac_get wrong?
-static inline int vp8_rac_get(VP56RangeCoder *c)
+static av_always_inline int vp8_rac_get(VP56RangeCoder *c)
{
return vp56_rac_get_prob(c, 128);
}
-static inline int vp56_rac_gets(VP56RangeCoder *c, int bits)
+static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits)
{
int value = 0;
@@ -262,7 +274,7 @@ static inline int vp56_rac_gets(VP56RangeCoder *c, int bits)
return value;
}
-static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
+static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
{
int value = 0;
@@ -274,7 +286,7 @@ static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
}
// fixme: add 1 bit to all the calls to this?
-static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
+static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
{
int v;
@@ -290,21 +302,22 @@ static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
}
// P(7)
-static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits)
+static av_unused 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)
+static av_unused 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)
+static av_always_inline
+int vp56_rac_get_tree(VP56RangeCoder *c,
+ const VP56Tree *tree,
+ const uint8_t *probs)
{
while (tree->val > 0) {
if (vp56_rac_get_prob(c, probs[tree->prob_idx]))
@@ -320,8 +333,9 @@ static inline int vp56_rac_get_tree(VP56RangeCoder *c,
* 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)
+static av_always_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])];
@@ -332,14 +346,15 @@ static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (
// 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)
+static av_always_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)
+static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob)
{
int v = 0;
diff --git a/lib/ffmpeg/libavcodec/vp56dsp.c b/lib/ffmpeg/libavcodec/vp56dsp.c
index 9eb9299a36..c629343a8b 100644
--- a/lib/ffmpeg/libavcodec/vp56dsp.c
+++ b/lib/ffmpeg/libavcodec/vp56dsp.c
@@ -82,7 +82,12 @@ void ff_vp56dsp_init(VP56DSPContext *s, enum CodecID codec)
} else {
s->edge_filter_hor = vp6_edge_filter_hor;
s->edge_filter_ver = vp6_edge_filter_ver;
+
+ if (CONFIG_VP6_DECODER) {
+ s->vp6_filter_diag4 = ff_vp6_filter_diag4_c;
+ }
}
if (ARCH_ARM) ff_vp56dsp_init_arm(s, codec);
+ if (HAVE_MMX) ff_vp56dsp_init_x86(s, codec);
}
diff --git a/lib/ffmpeg/libavcodec/vp56dsp.h b/lib/ffmpeg/libavcodec/vp56dsp.h
index 2d6941fa29..74a9cb5309 100644
--- a/lib/ffmpeg/libavcodec/vp56dsp.h
+++ b/lib/ffmpeg/libavcodec/vp56dsp.h
@@ -22,13 +22,21 @@
#define AVCODEC_VP56DSP_H
#include <stdint.h>
+#include "avcodec.h"
typedef struct VP56DSPContext {
void (*edge_filter_hor)(uint8_t *yuv, int stride, int t);
void (*edge_filter_ver)(uint8_t *yuv, int stride, int t);
+
+ void (*vp6_filter_diag4)(uint8_t *dst, uint8_t *src, int stride,
+ const int16_t *h_weights,const int16_t *v_weights);
} VP56DSPContext;
+void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride,
+ const int16_t *h_weights, const int16_t *v_weights);
+
void ff_vp56dsp_init(VP56DSPContext *s, enum CodecID codec);
void ff_vp56dsp_init_arm(VP56DSPContext *s, enum CodecID codec);
+void ff_vp56dsp_init_x86(VP56DSPContext* c, enum CodecID codec);
#endif /* AVCODEC_VP56DSP_H */
diff --git a/lib/ffmpeg/libavcodec/vp56rac.c b/lib/ffmpeg/libavcodec/vp56rac.c
new file mode 100644
index 0000000000..f11531de24
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/vp56rac.c
@@ -0,0 +1,47 @@
+/*
+ * VP5/6/8 decoder
+ * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "vp56.h"
+
+const uint8_t ff_vp56_norm_shift[256]= {
+ 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,
+ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+};
+
+void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
+{
+ c->high = 255;
+ c->bits = -16;
+ c->buffer = buf;
+ c->end = buf + buf_size;
+ c->code_word = bytestream_get_be24(&c->buffer);
+}
diff --git a/lib/ffmpeg/libavcodec/vp6.c b/lib/ffmpeg/libavcodec/vp6.c
index f8bcd4be37..0a02ce58d6 100644
--- a/lib/ffmpeg/libavcodec/vp6.c
+++ b/lib/ffmpeg/libavcodec/vp6.c
@@ -54,7 +54,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
int separated_coeff = buf[0] & 1;
s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80);
- vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
+ ff_vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
sub_version = buf[1] >> 3;
@@ -87,7 +87,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
res = 2;
}
- vp56_init_range_decoder(c, buf+6, buf_size-6);
+ ff_vp56_init_range_decoder(c, buf+6, buf_size-6);
vp56_rac_gets(c, 2);
parse_filter_info = s->filter_header;
@@ -103,7 +103,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
buf += 2;
buf_size -= 2;
}
- vp56_init_range_decoder(c, buf+1, buf_size-1);
+ ff_vp56_init_range_decoder(c, buf+1, buf_size-1);
*golden_frame = vp56_rac_get(c);
if (s->filter_header) {
@@ -143,7 +143,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
s->parse_coeff = vp6_parse_coeff_huffman;
init_get_bits(&s->gb, buf, buf_size<<3);
} else {
- vp56_init_range_decoder(&s->cc, buf, buf_size);
+ ff_vp56_init_range_decoder(&s->cc, buf, buf_size);
s->ccp = &s->cc;
}
} else {
@@ -559,7 +559,7 @@ static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
vp6_filter_hv4(dst, src+offset1, stride, stride,
vp6_block_copy_filter[select][y8]);
} else {
- s->dsp.vp6_filter_diag4(dst, src+offset1+((mv.x^mv.y)>>31), stride,
+ s->vp56dsp.vp6_filter_diag4(dst, src+offset1+((mv.x^mv.y)>>31), stride,
vp6_block_copy_filter[select][x8],
vp6_block_copy_filter[select][y8]);
}
@@ -576,8 +576,8 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx)
{
VP56Context *s = avctx->priv_data;
- vp56_init(avctx, avctx->codec->id == CODEC_ID_VP6,
- avctx->codec->id == CODEC_ID_VP6A);
+ ff_vp56_init(avctx, avctx->codec->id == CODEC_ID_VP6,
+ avctx->codec->id == CODEC_ID_VP6A);
s->vp56_coord_div = vp6_coord_div;
s->parse_vector_adjustment = vp6_parse_vector_adjustment;
s->filter = vp6_filter;
@@ -594,7 +594,7 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx)
VP56Context *s = avctx->priv_data;
int pt, ct, cg;
- vp56_free(avctx);
+ ff_vp56_free(avctx);
for (pt=0; pt<2; pt++) {
free_vlc(&s->dccv_vlc[pt]);
@@ -606,7 +606,7 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx)
return 0;
}
-AVCodec vp6_decoder = {
+AVCodec ff_vp6_decoder = {
"vp6",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP6,
@@ -614,13 +614,13 @@ AVCodec vp6_decoder = {
vp6_decode_init,
NULL,
vp6_decode_free,
- vp56_decode_frame,
+ ff_vp56_decode_frame,
CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("On2 VP6"),
};
/* flash version, not flipped upside-down */
-AVCodec vp6f_decoder = {
+AVCodec ff_vp6f_decoder = {
"vp6f",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP6F,
@@ -628,13 +628,13 @@ AVCodec vp6f_decoder = {
vp6_decode_init,
NULL,
vp6_decode_free,
- vp56_decode_frame,
+ ff_vp56_decode_frame,
CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"),
};
/* flash version, not flipped upside-down, with alpha channel */
-AVCodec vp6a_decoder = {
+AVCodec ff_vp6a_decoder = {
"vp6a",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP6A,
@@ -642,7 +642,7 @@ AVCodec vp6a_decoder = {
vp6_decode_init,
NULL,
vp6_decode_free,
- vp56_decode_frame,
+ ff_vp56_decode_frame,
CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"),
};
diff --git a/lib/ffmpeg/libavcodec/vp6dsp.c b/lib/ffmpeg/libavcodec/vp6dsp.c
index 69a11ee188..1119b56705 100644
--- a/lib/ffmpeg/libavcodec/vp6dsp.c
+++ b/lib/ffmpeg/libavcodec/vp6dsp.c
@@ -22,7 +22,7 @@
*/
#include "libavutil/common.h"
-#include "dsputil.h"
+#include "vp56dsp.h"
void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride,
diff --git a/lib/ffmpeg/libavcodec/vp8.c b/lib/ffmpeg/libavcodec/vp8.c
index 74a05f3310..effeb4ed2f 100644
--- a/lib/ffmpeg/libavcodec/vp8.c
+++ b/lib/ffmpeg/libavcodec/vp8.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 David Conrad
* Copyright (C) 2010 Ronald S. Bultje
+ * Copyright (C) 2010 Jason Garrett-Glaser
*
* This file is part of FFmpeg.
*
@@ -21,6 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "vp56.h"
#include "vp8data.h"
@@ -29,7 +31,12 @@
#include "rectangle.h"
typedef struct {
- uint8_t segment;
+ uint8_t filter_level;
+ uint8_t inner_limit;
+ uint8_t inner_filter;
+} VP8FilterStrength;
+
+typedef struct {
uint8_t skip;
// todo: make it possible to check for at least (i4x4 or split_mv)
// in one op. are others needed?
@@ -62,6 +69,7 @@ typedef struct {
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;
+ int deblock_filter;
/**
* If this flag is not set, all the probability updates
@@ -78,11 +86,17 @@ typedef struct {
VP8Macroblock *macroblocks;
VP8Macroblock *macroblocks_base;
- int mb_stride;
+ VP8FilterStrength *filter_strength;
+
+ uint8_t *intra4x4_pred_mode_top;
+ uint8_t intra4x4_pred_mode_left[4];
+ uint8_t *segmentation_map;
- uint8_t *intra4x4_pred_mode;
- uint8_t *intra4x4_pred_mode_base;
- int b4_stride;
+ /**
+ * Cache of the top row needed for intra prediction
+ * 16 for luma, 8 for each chroma plane
+ */
+ uint8_t (*top_border)[16+8+8];
/**
* For coeff decode, we need to know whether the above block had non-zero
@@ -102,11 +116,15 @@ typedef struct {
*/
DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
+ DECLARE_ALIGNED(16, DCTELEM, block_dc)[16];
+ uint8_t intra4x4_pred_mode_mb[16];
int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock
+ int segment; ///< segment of the current macroblock
int mbskip_enabled;
int sign_bias[4]; ///< one state [0, 1] per ref frame type
+ int ref_count[3];
/**
* Base parameters for segmentation, i.e. per-macroblock parameters.
@@ -176,13 +194,12 @@ typedef struct {
uint8_t golden;
uint8_t pred16x16[4];
uint8_t pred8x8c[3];
- uint8_t token[4][8][3][NUM_DCT_TOKENS-1];
+ /* Padded to allow overreads */
+ uint8_t token[4][17][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;
@@ -194,19 +211,19 @@ static void vp8_decode_flush(AVCodecContext *avctx)
memset(s->framep, 0, sizeof(s->framep));
av_freep(&s->macroblocks_base);
- av_freep(&s->intra4x4_pred_mode_base);
+ av_freep(&s->filter_strength);
+ av_freep(&s->intra4x4_pred_mode_top);
av_freep(&s->top_nnz);
av_freep(&s->edge_emu_buffer);
+ av_freep(&s->top_border);
+ av_freep(&s->segmentation_map);
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))
+ if (av_image_check_size(width, height, 0, s->avctx))
return AVERROR_INVALIDDATA;
vp8_decode_flush(s->avctx);
@@ -216,21 +233,18 @@ static int update_dimensions(VP8Context *s, int width, int 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->macroblocks_base = av_mallocz((s->mb_width+s->mb_height*2+1)*sizeof(*s->macroblocks));
+ s->filter_strength = av_mallocz(s->mb_width*sizeof(*s->filter_strength));
+ s->intra4x4_pred_mode_top = av_mallocz(s->mb_width*4);
s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz));
+ s->top_border = av_mallocz((s->mb_width+1)*sizeof(*s->top_border));
+ s->segmentation_map = av_mallocz(s->mb_width*s->mb_height);
- s->macroblocks = s->macroblocks_base + 1 + s->mb_stride;
- s->intra4x4_pred_mode = s->intra4x4_pred_mode_base + 4 + s->b4_stride;
+ if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_top ||
+ !s->top_nnz || !s->top_border || !s->segmentation_map)
+ return AVERROR(ENOMEM);
- 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;
+ s->macroblocks = s->macroblocks_base + 1;
return 0;
}
@@ -281,15 +295,15 @@ static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
return -1;
for (i = 0; i < s->num_coeff_partitions-1; i++) {
- int size = RL24(sizes + 3*i);
+ int size = AV_RL24(sizes + 3*i);
if (buf_size - size < 0)
return -1;
- vp56_init_range_decoder(&s->coeff_partition[i], buf, size);
+ ff_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);
+ ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size);
return 0;
}
@@ -369,14 +383,14 @@ static void update_refs(VP8Context *s)
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 header_size, hscale, vscale, i, j, k, l, m, 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;
+ header_size = AV_RL24(buf) >> 5;
buf += 3;
buf_size -= 3;
@@ -394,8 +408,8 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
}
if (s->keyframe) {
- if (RL24(buf) != 0x2a019d) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid start code 0x%x\n", RL24(buf));
+ if (AV_RL24(buf) != 0x2a019d) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid start code 0x%x\n", AV_RL24(buf));
return AVERROR_INVALIDDATA;
}
width = AV_RL16(buf+3) & 0x3fff;
@@ -409,7 +423,10 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
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));
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 16; j++)
+ memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]],
+ sizeof(s->prob->token[i][j]));
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));
@@ -422,7 +439,7 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
return ret;
}
- vp56_init_range_decoder(c, buf, header_size);
+ ff_vp56_init_range_decoder(c, buf, header_size);
buf += header_size;
buf_size -= header_size;
@@ -469,8 +486,11 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
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 (vp56_rac_get_prob_branchy(c, vp8_token_update_probs[i][j][k][l])) {
+ int prob = vp8_rac_get_uint(c, 8);
+ for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++)
+ s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob;
+ }
if ((s->mbskip_enabled = vp8_rac_get(c)))
s->prob->mbskip = vp8_rac_get_uint(c, 8);
@@ -490,15 +510,15 @@ static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
// 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]))
+ if (vp56_rac_get_prob_branchy(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)
+static av_always_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),
@@ -507,40 +527,47 @@ static inline void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src,
((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])
+static av_always_inline
+void find_near_mvs(VP8Context *s, VP8Macroblock *mb,
+ VP56mv near[2], VP56mv *best, uint8_t cnt[4])
{
- VP8Macroblock *mb_edge[3] = { mb - s->mb_stride /* top */,
- mb - 1 /* left */,
- mb - s->mb_stride - 1 /* top-left */ };
+ VP8Macroblock *mb_edge[3] = { mb + 2 /* top */,
+ mb - 1 /* left */,
+ mb + 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 idx = CNT_ZERO;
int best_idx = CNT_ZERO;
+ int cur_sign_bias = s->sign_bias[mb->ref_frame];
+ int *sign_bias = s->sign_bias;
/* 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);
- }
+ #define MV_EDGE_CHECK(n)\
+ {\
+ VP8Macroblock *edge = mb_edge[n];\
+ int edge_ref = edge->ref_frame;\
+ if (edge_ref != VP56_FRAME_CURRENT) {\
+ uint32_t mv = AV_RN32A(&edge->mv);\
+ if (mv) {\
+ if (cur_sign_bias != sign_bias[edge_ref]) {\
+ /* SWAR negate of the values in mv. */\
+ mv = ~mv;\
+ mv = ((mv&0x7fff7fff) + 0x00010001) ^ (mv&0x80008000);\
+ }\
+ if (!n || mv != AV_RN32A(&near_mv[idx]))\
+ AV_WN32A(&near_mv[++idx], mv);\
+ cnt[idx] += 1 + (n != 2);\
+ } else\
+ cnt[CNT_ZERO] += 1 + (n != 2);\
+ }\
}
+ MV_EDGE_CHECK(0)
+ MV_EDGE_CHECK(1)
+ MV_EDGE_CHECK(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)))
+ /* If we have three distinct MVs, merge first and last if they're the same */
+ if (cnt[CNT_SPLITMV] && AV_RN32A(&near_mv[1+EDGE_TOP]) == AV_RN32A(&near_mv[1+EDGE_TOPLEFT]))
cnt[CNT_NEAREST] += 1;
cnt[CNT_SPLITMV] = ((mb_edge[EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
@@ -549,15 +576,15 @@ static void find_near_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
/* 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]);
+ FFSWAP(uint8_t, 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);
+ mb->mv = near_mv[best_idx];
near[0] = near_mv[CNT_NEAREST];
near[1] = near_mv[CNT_NEAR];
}
@@ -567,9 +594,9 @@ static void find_near_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
*/
static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
{
- int x = 0;
+ int bit, x = 0;
- if (vp56_rac_get_prob(c, p[0])) {
+ if (vp56_rac_get_prob_branchy(c, p[0])) {
int i;
for (i = 0; i < 3; i++)
@@ -578,104 +605,132 @@ static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
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]);
+ } else {
+ // small_mvtree
+ const uint8_t *ps = p+2;
+ bit = vp56_rac_get_prob(c, *ps);
+ ps += 1 + 3*bit;
+ x += 4*bit;
+ bit = vp56_rac_get_prob(c, *ps);
+ ps += 1 + bit;
+ x += 2*bit;
+ x += vp56_rac_get_prob(c, *ps);
+ }
return (x && vp56_rac_get_prob(c, p[1])) ? -x : x;
}
-static const uint8_t *get_submv_prob(const VP56mv *left, const VP56mv *top)
+static av_always_inline
+const uint8_t *get_submv_prob(uint32_t left, uint32_t 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)
+ if (left == top)
+ return vp8_submv_prob[4-!!left];
+ if (!top)
return vp8_submv_prob[2];
- return l_is_zero ? vp8_submv_prob[1] : vp8_submv_prob[0];
+ return vp8_submv_prob[1-!!left];
}
/**
* 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)
+static av_always_inline
+int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb)
{
- 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];
+ int part_idx;
+ int n, num;
+ VP8Macroblock *top_mb = &mb[2];
+ VP8Macroblock *left_mb = &mb[-1];
+ const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning],
+ *mbsplits_top = vp8_mbsplits[top_mb->partitioning],
+ *mbsplits_cur, *firstidx;
+ VP56mv *top_mv = top_mb->bmv;
+ VP56mv *left_mv = left_mb->bmv;
+ VP56mv *cur_mv = mb->bmv;
+
+ if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) {
+ if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1])) {
+ part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]);
+ } else {
+ part_idx = VP8_SPLITMVMODE_8x8;
+ }
+ } else {
+ part_idx = VP8_SPLITMVMODE_4x4;
+ }
+
+ num = vp8_mbsplit_count[part_idx];
+ mbsplits_cur = vp8_mbsplits[part_idx],
+ firstidx = vp8_mbfirstidx[part_idx];
+ mb->partitioning = part_idx;
for (n = 0; n < num; n++) {
int k = firstidx[n];
- const VP56mv *left, *above;
+ uint32_t 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]];
+ if (!(k & 3))
+ left = AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
+ else
+ left = AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
+ if (k <= 3)
+ above = AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
+ else
+ above = AV_RN32A(&cur_mv[mbsplits_cur[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;
+ if (vp56_rac_get_prob_branchy(c, submv_prob[0])) {
+ if (vp56_rac_get_prob_branchy(c, submv_prob[1])) {
+ if (vp56_rac_get_prob_branchy(c, submv_prob[2])) {
+ mb->bmv[n].y = mb->mv.y + read_mv_component(c, s->prob->mvc[0]);
+ mb->bmv[n].x = mb->mv.x + read_mv_component(c, s->prob->mvc[1]);
+ } else {
+ AV_ZERO32(&mb->bmv[n]);
+ }
+ } else {
+ AV_WN32A(&mb->bmv[n], above);
+ }
+ } else {
+ AV_WN32A(&mb->bmv[n], left);
}
}
return num;
}
-static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4,
- int stride, int keyframe)
+static av_always_inline
+void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c,
+ int mb_x, 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];
+ uint8_t *intra4x4 = s->intra4x4_pred_mode_mb;
+ if (keyframe) {
+ int x, y;
+ uint8_t* const top = s->intra4x4_pred_mode_top + 4 * mb_x;
+ uint8_t* const left = s->intra4x4_pred_mode_left;
+ for (y = 0; y < 4; y++) {
+ for (x = 0; x < 4; x++) {
+ const uint8_t *ctx;
+ ctx = vp8_pred4x4_prob_intra[top[x]][left[y]];
+ *intra4x4 = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
+ left[y] = top[x] = *intra4x4;
+ intra4x4++;
}
- intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
}
- intra4x4 += stride;
+ } else {
+ int i;
+ for (i = 0; i < 16; i++)
+ intra4x4[i] = vp8_rac_get_tree(c, vp8_pred4x4_tree, vp8_pred4x4_prob_inter);
}
}
-static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
- uint8_t *intra4x4)
+static av_always_inline
+void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_t *segment)
{
VP56RangeCoder *c = &s->c;
- int n;
if (s->segmentation.update_map)
- mb->segment = vp8_rac_get_tree(c, vp8_segmentid_tree, s->prob->segmentid);
+ *segment = vp8_rac_get_tree(c, vp8_segmentid_tree, s->prob->segmentid);
+ s->segment = *segment;
mb->skip = s->mbskip_enabled ? vp56_rac_get_prob(c, s->prob->mbskip) : 0;
@@ -683,47 +738,53 @@ static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
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);
+ decode_intra4x4_modes(s, c, mb_x, 1);
+ } else {
+ const uint32_t modes = vp8_pred4x4_mode[mb->mode] * 0x01010101u;
+ AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);
+ AV_WN32A(s->intra4x4_pred_mode_left, modes);
+ }
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)) {
+ } else if (vp56_rac_get_prob_branchy(c, s->prob->intra)) {
VP56mv near[2], best;
- int cnt[4] = { 0 };
- uint8_t p[4];
+ uint8_t cnt[4] = { 0 };
// inter MB, 16.2
- if (vp56_rac_get_prob(c, s->prob->last))
+ if (vp56_rac_get_prob_branchy(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;
+ s->ref_count[mb->ref_frame-1]++;
// 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;
+ find_near_mvs(s, mb, near, &best, cnt);
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[0]][0])) {
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[1]][1])) {
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[2]][2])) {
+ if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[3]][3])) {
+ mb->mode = VP8_MVMODE_SPLIT;
+ clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y);
+ mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1];
+ } else {
+ mb->mode = VP8_MVMODE_NEW;
+ clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y);
+ mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
+ mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
+ }
+ } else {
+ mb->mode = VP8_MVMODE_NEAR;
+ clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y);
+ }
+ } else {
+ mb->mode = VP8_MVMODE_NEAREST;
+ clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y);
+ }
+ } else {
+ mb->mode = VP8_MVMODE_ZERO;
+ AV_ZERO32(&mb->mv);
}
if (mb->mode != VP8_MVMODE_SPLIT) {
mb->partitioning = VP8_SPLITMVMODE_NONE;
@@ -733,13 +794,13 @@ static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
// 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);
+ if (mb->mode == MODE_I4x4)
+ decode_intra4x4_modes(s, c, mb_x, 0);
s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c);
mb->ref_frame = VP56_FRAME_CURRENT;
+ mb->partitioning = VP8_SPLITMVMODE_NONE;
+ AV_ZERO32(&mb->bmv[0]);
}
}
@@ -754,64 +815,94 @@ static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y,
* @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])
+static int decode_block_coeffs_internal(VP56RangeCoder *c, DCTELEM block[16],
+ uint8_t probs[8][3][NUM_DCT_TOKENS-1],
+ int i, uint8_t *token_prob, 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);
+ goto skip_eob;
+ do {
+ int coeff;
+ if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
+ return i;
+
+skip_eob:
+ if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0
+ if (++i == 16)
+ return i; // invalid input; blocks should end with EOB
+ token_prob = probs[i][0];
+ goto skip_eob;
+ }
- 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];
+ if (!vp56_rac_get_prob_branchy(c, token_prob[2])) { // DCT_1
+ coeff = 1;
+ token_prob = probs[i+1][1];
+ } else {
+ if (!vp56_rac_get_prob_branchy(c, token_prob[3])) { // DCT 2,3,4
+ coeff = vp56_rac_get_prob_branchy(c, token_prob[4]);
+ if (coeff)
+ coeff += vp56_rac_get_prob(c, token_prob[5]);
+ coeff += 2;
+ } else {
+ // DCT_CAT*
+ if (!vp56_rac_get_prob_branchy(c, token_prob[6])) {
+ if (!vp56_rac_get_prob_branchy(c, token_prob[7])) { // DCT_CAT1
+ coeff = 5 + vp56_rac_get_prob(c, vp8_dct_cat1_prob[0]);
+ } else { // DCT_CAT2
+ coeff = 7;
+ coeff += vp56_rac_get_prob(c, vp8_dct_cat2_prob[0]) << 1;
+ coeff += vp56_rac_get_prob(c, vp8_dct_cat2_prob[1]);
+ }
+ } else { // DCT_CAT3 and up
+ int a = vp56_rac_get_prob(c, token_prob[8]);
+ int b = vp56_rac_get_prob(c, token_prob[9+a]);
+ int cat = (a<<1) + b;
+ coeff = 3 + (8<<cat);
+ coeff += vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]);
+ }
+ }
+ token_prob = probs[i+1][2];
}
+ block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i];
+ } while (++i < 16);
- // 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;
+ return i;
+}
- // 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 av_always_inline
+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])
+{
+ uint8_t *token_prob = probs[i][zero_nhood];
+ if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
+ return 0;
+ return decode_block_coeffs_internal(c, block, probs, i, token_prob, qmul);
}
-static void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb,
- uint8_t t_nnz[9], uint8_t l_nnz[9])
+static av_always_inline
+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);
+ int segment = s->segment;
+ int block_dc = 0;
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,
+ nnz = decode_block_coeffs(c, s->block_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);
+ if (nnz) {
+ nnz_total += nnz;
+ block_dc = 1;
+ if (nnz == 1)
+ s->vp8dsp.vp8_luma_dc_wht_dc(s->block, s->block_dc);
+ else
+ s->vp8dsp.vp8_luma_dc_wht(s->block, s->block_dc);
+ }
luma_start = 1;
luma_ctx = 0;
}
@@ -822,8 +913,8 @@ static void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb
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;
+ // nnz+block_dc may be one more than the actual last index, but we don't care
+ s->non_zero_count_cache[y][x] = nnz + block_dc;
t_nnz[x] = l_nnz[y] = !!nnz;
nnz_total += nnz;
}
@@ -849,29 +940,163 @@ static void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb
mb->skip = 1;
}
-static int check_intra_pred_mode(int mode, int mb_x, int mb_y)
+static av_always_inline
+void backup_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr,
+ int linesize, int uvlinesize, int simple)
+{
+ AV_COPY128(top_border, src_y + 15*linesize);
+ if (!simple) {
+ AV_COPY64(top_border+16, src_cb + 7*uvlinesize);
+ AV_COPY64(top_border+24, src_cr + 7*uvlinesize);
+ }
+}
+
+static av_always_inline
+void xchg_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr,
+ int linesize, int uvlinesize, int mb_x, int mb_y, int mb_width,
+ int simple, int xchg)
+{
+ uint8_t *top_border_m1 = top_border-32; // for TL prediction
+ src_y -= linesize;
+ src_cb -= uvlinesize;
+ src_cr -= uvlinesize;
+
+#define XCHG(a,b,xchg) do { \
+ if (xchg) AV_SWAP64(b,a); \
+ else AV_COPY64(b,a); \
+ } while (0)
+
+ XCHG(top_border_m1+8, src_y-8, xchg);
+ XCHG(top_border, src_y, xchg);
+ XCHG(top_border+8, src_y+8, 1);
+ if (mb_x < mb_width-1)
+ XCHG(top_border+32, src_y+16, 1);
+
+ // only copy chroma for normal loop filter
+ // or to initialize the top row to 127
+ if (!simple || !mb_y) {
+ XCHG(top_border_m1+16, src_cb-8, xchg);
+ XCHG(top_border_m1+24, src_cr-8, xchg);
+ XCHG(top_border+16, src_cb, 1);
+ XCHG(top_border+24, src_cr, 1);
+ }
+}
+
+static av_always_inline
+int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
+{
+ if (!mb_x) {
+ return mb_y ? TOP_DC_PRED8x8 : DC_128_PRED8x8;
+ } else {
+ return mb_y ? mode : LEFT_DC_PRED8x8;
+ }
+}
+
+static av_always_inline
+int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y)
+{
+ if (!mb_x) {
+ return mb_y ? VERT_PRED8x8 : DC_129_PRED8x8;
+ } else {
+ return mb_y ? mode : HOR_PRED8x8;
+ }
+}
+
+static av_always_inline
+int check_intra_pred8x8_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 check_dc_pred8x8_mode(mode, mb_x, mb_y);
+ } else {
+ return mode;
+ }
+}
+
+static av_always_inline
+int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y)
+{
+ switch (mode) {
+ case DC_PRED8x8:
+ return check_dc_pred8x8_mode(mode, mb_x, mb_y);
+ case VERT_PRED8x8:
+ return !mb_y ? DC_127_PRED8x8 : mode;
+ case HOR_PRED8x8:
+ return !mb_x ? DC_129_PRED8x8 : mode;
+ case PLANE_PRED8x8 /*TM*/:
+ return check_tm_pred8x8_mode(mode, mb_x, mb_y);
}
return mode;
}
-static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
- uint8_t *bmode, int mb_x, int mb_y)
+static av_always_inline
+int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y)
{
+ if (!mb_x) {
+ return mb_y ? VERT_VP8_PRED : DC_129_PRED;
+ } else {
+ return mb_y ? mode : HOR_VP8_PRED;
+ }
+}
+
+static av_always_inline
+int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf)
+{
+ switch (mode) {
+ case VERT_PRED:
+ if (!mb_x && mb_y) {
+ *copy_buf = 1;
+ return mode;
+ }
+ /* fall-through */
+ case DIAG_DOWN_LEFT_PRED:
+ case VERT_LEFT_PRED:
+ return !mb_y ? DC_127_PRED : mode;
+ case HOR_PRED:
+ if (!mb_y) {
+ *copy_buf = 1;
+ return mode;
+ }
+ /* fall-through */
+ case HOR_UP_PRED:
+ return !mb_x ? DC_129_PRED : mode;
+ case TM_VP8_PRED:
+ return check_tm_pred4x4_mode(mode, mb_x, mb_y);
+ case DC_PRED: // 4x4 DC doesn't use the same "H.264-style" exceptions as 16x16/8x8 DC
+ case DIAG_DOWN_RIGHT_PRED:
+ case VERT_RIGHT_PRED:
+ case HOR_DOWN_PRED:
+ if (!mb_y || !mb_x)
+ *copy_buf = 1;
+ return mode;
+ }
+ return mode;
+}
+
+static av_always_inline
+void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
+ int mb_x, int mb_y)
+{
+ AVCodecContext *avctx = s->avctx;
int x, y, mode, nnz, tr;
+ // for the first row, we need to run xchg_mb_border to init the top edge to 127
+ // otherwise, skip it if we aren't going to deblock
+ if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
+ xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
+ s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
+ s->filter.simple, 1);
+
if (mb->mode < MODE_I4x4) {
- mode = check_intra_pred_mode(mb->mode, mb_x, mb_y);
+ if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // tested
+ mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y);
+ } else {
+ mode = check_intra_pred8x8_mode(mb->mode, mb_x, mb_y);
+ }
s->hpc.pred16x16[mode](dst[0], s->linesize);
} else {
uint8_t *ptr = dst[0];
+ uint8_t *intra4x4 = s->intra4x4_pred_mode_mb;
+ uint8_t tr_top[4] = { 127, 127, 127, 127 };
// all blocks on the right edge of the macroblock use bottom edge
// the top macroblock for their topright edge
@@ -879,18 +1104,65 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
// 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) {
+ if (!(!mb_y && avctx->flags & CODEC_FLAG_EMU_EDGE) &&
+ mb_x == s->mb_width-1) {
tr = tr_right[-1]*0x01010101;
tr_right = (uint8_t *)&tr;
}
+ if (mb->skip)
+ AV_ZERO128(s->non_zero_count_cache);
+
for (y = 0; y < 4; y++) {
uint8_t *topright = ptr + 4 - s->linesize;
for (x = 0; x < 4; x++) {
- if (x == 3)
+ int copy = 0, linesize = s->linesize;
+ uint8_t *dst = ptr+4*x;
+ DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];
+
+ if ((y == 0 || x == 3) && mb_y == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
+ topright = tr_top;
+ } else if (x == 3)
topright = tr_right;
- s->hpc.pred4x4[bmode[x]](ptr+4*x, topright, s->linesize);
+ if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // mb_x+x or mb_y+y is a hack but works
+ mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x, mb_y + y, &copy);
+ if (copy) {
+ dst = copy_dst + 12;
+ linesize = 8;
+ if (!(mb_y + y)) {
+ copy_dst[3] = 127U;
+ AV_WN32A(copy_dst+4, 127U * 0x01010101U);
+ } else {
+ AV_COPY32(copy_dst+4, ptr+4*x-s->linesize);
+ if (!(mb_x + x)) {
+ copy_dst[3] = 129U;
+ } else {
+ copy_dst[3] = ptr[4*x-s->linesize-1];
+ }
+ }
+ if (!(mb_x + x)) {
+ copy_dst[11] =
+ copy_dst[19] =
+ copy_dst[27] =
+ copy_dst[35] = 129U;
+ } else {
+ copy_dst[11] = ptr[4*x -1];
+ copy_dst[19] = ptr[4*x+s->linesize -1];
+ copy_dst[27] = ptr[4*x+s->linesize*2-1];
+ copy_dst[35] = ptr[4*x+s->linesize*3-1];
+ }
+ }
+ } else {
+ mode = intra4x4[x];
+ }
+ s->hpc.pred4x4[mode](dst, topright, linesize);
+ if (copy) {
+ AV_COPY32(ptr+4*x , copy_dst+12);
+ AV_COPY32(ptr+4*x+s->linesize , copy_dst+20);
+ AV_COPY32(ptr+4*x+s->linesize*2, copy_dst+28);
+ AV_COPY32(ptr+4*x+s->linesize*3, copy_dst+36);
+ }
nnz = s->non_zero_count_cache[y][x];
if (nnz) {
@@ -903,15 +1175,31 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
}
ptr += 4*s->linesize;
- bmode += s->b4_stride;
+ intra4x4 += 4;
}
}
- mode = check_intra_pred_mode(s->chroma_pred_mode, mb_x, mb_y);
+ if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
+ mode = check_intra_pred8x8_mode_emuedge(s->chroma_pred_mode, mb_x, mb_y);
+ } else {
+ mode = check_intra_pred8x8_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);
+
+ if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
+ xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
+ s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
+ s->filter.simple, 0);
}
+static const uint8_t subpel_idx[3][8] = {
+ { 0, 1, 2, 1, 2, 1, 2, 1 }, // nr. of left extra pixels,
+ // also function pointer index
+ { 0, 3, 5, 3, 5, 3, 5, 3 }, // nr. of extra pixels required
+ { 0, 2, 3, 2, 3, 2, 3, 2 }, // nr. of right extra pixels
+};
+
/**
* Generic MC function.
*
@@ -929,45 +1217,87 @@ static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
* @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 av_always_inline
+void vp8_mc_luma(VP8Context *s, 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;
- }
+ if (AV_RN32A(mv)) {
+
+ int mx = (mv->x << 1)&7, mx_idx = subpel_idx[0][mx];
+ int my = (mv->y << 1)&7, my_idx = subpel_idx[0][my];
+
+ x_off += mv->x >> 2;
+ y_off += mv->y >> 2;
+
+ // edge emulation
+ src += y_off * linesize + x_off;
+ if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
+ y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src - my_idx * linesize - mx_idx, linesize,
+ block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
+ x_off - mx_idx, y_off - my_idx, width, height);
+ src = s->edge_emu_buffer + mx_idx + linesize * my_idx;
+ }
+ mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my);
+ } else
+ mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0);
+}
- mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my);
+static av_always_inline
+void vp8_mc_chroma(VP8Context *s, uint8_t *dst1, uint8_t *dst2, uint8_t *src1,
+ uint8_t *src2, 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])
+{
+ if (AV_RN32A(mv)) {
+ int mx = mv->x&7, mx_idx = subpel_idx[0][mx];
+ int my = mv->y&7, my_idx = subpel_idx[0][my];
+
+ x_off += mv->x >> 3;
+ y_off += mv->y >> 3;
+
+ // edge emulation
+ src1 += y_off * linesize + x_off;
+ src2 += y_off * linesize + x_off;
+ if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
+ y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src1 - my_idx * linesize - mx_idx, linesize,
+ block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
+ x_off - mx_idx, y_off - my_idx, width, height);
+ src1 = s->edge_emu_buffer + mx_idx + linesize * my_idx;
+ mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
+
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src2 - my_idx * linesize - mx_idx, linesize,
+ block_w + subpel_idx[1][mx], block_h + subpel_idx[1][my],
+ x_off - mx_idx, y_off - my_idx, width, height);
+ src2 = s->edge_emu_buffer + mx_idx + linesize * my_idx;
+ mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
+ } else {
+ mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
+ mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
+ }
+ } else {
+ mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
+ mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
+ }
}
-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)
+static av_always_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]);
+ vp8_mc_luma(s, 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) {
@@ -978,29 +1308,47 @@ static inline void vp8_mc_part(VP8Context *s, uint8_t *dst[3],
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)]);
+ vp8_mc_chroma(s, dst[1] + by_off * s->uvlinesize + bx_off,
+ dst[2] + by_off * s->uvlinesize + bx_off, ref_frame->data[1],
+ 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)]);
+}
+
+/* Fetch pixels for estimated mv 4 macroblocks ahead.
+ * Optimized for 64-byte cache lines. Inspired by ffh264 prefetch_motion. */
+static av_always_inline void prefetch_motion(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, int mb_xy, int ref)
+{
+ /* Don't prefetch refs that haven't been used very often this frame. */
+ if (s->ref_count[ref-1] > (mb_xy >> 5)) {
+ int x_off = mb_x << 4, y_off = mb_y << 4;
+ int mx = (mb->mv.x>>2) + x_off + 8;
+ int my = (mb->mv.y>>2) + y_off;
+ uint8_t **src= s->framep[ref]->data;
+ int off= mx + (my + (mb_x&3)*4)*s->linesize + 64;
+ s->dsp.prefetch(src[0]+off, s->linesize, 4);
+ off= (mx>>1) + ((my>>1) + (mb_x&7))*s->uvlinesize + 64;
+ s->dsp.prefetch(src[1]+off, src[2]-src[1], 2);
+ }
}
/**
* 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)
+static av_always_inline
+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;
+ AVFrame *ref = s->framep[mb->ref_frame];
+ VP56mv *bmv = mb->bmv;
- if (mb->mode < VP8_MVMODE_SPLIT) {
- vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off,
+ switch (mb->partitioning) {
+ case VP8_SPLITMVMODE_NONE:
+ vp8_mc_part(s, dst, ref, x_off, y_off,
0, 0, 16, 16, width, height, &mb->mv);
- } else switch (mb->partitioning) {
+ break;
case VP8_SPLITMVMODE_4x4: {
int x, y;
VP56mv uvmv;
@@ -1008,11 +1356,11 @@ static void inter_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
/* 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]);
+ vp8_mc_luma(s, dst[0] + 4*y*s->linesize + x*4,
+ ref->data[0], &bmv[4*y + x],
+ 4*x + x_off, 4*y + y_off, 4, 4,
+ width, height, s->linesize,
+ s->put_pixels_tab[2]);
}
}
@@ -1034,93 +1382,98 @@ static void inter_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
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]);
+ vp8_mc_chroma(s, dst[1] + 4*y*s->uvlinesize + x*4,
+ dst[2] + 4*y*s->uvlinesize + x*4,
+ ref->data[1], ref->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]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 0, 0, 16, 8, width, height, &bmv[0]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 0, 8, 16, 8, width, height, &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]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 0, 0, 8, 16, width, height, &bmv[0]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 8, 0, 8, 16, width, height, &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]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 0, 0, 8, 8, width, height, &bmv[0]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 8, 0, 8, 8, width, height, &bmv[1]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 0, 8, 8, 8, width, height, &bmv[2]);
+ vp8_mc_part(s, dst, ref, x_off, y_off,
+ 8, 8, 8, 8, width, height, &bmv[3]);
break;
}
}
-static void idct_mb(VP8Context *s, uint8_t *y_dst, uint8_t *u_dst, uint8_t *v_dst,
- VP8Macroblock *mb)
+static av_always_inline void idct_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb)
{
- int x, y, nnz;
+ int x, y, ch;
- if (mb->mode != MODE_I4x4)
+ if (mb->mode != MODE_I4x4) {
+ uint8_t *y_dst = dst[0];
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);
+ uint32_t nnz4 = AV_RN32A(s->non_zero_count_cache[y]);
+ if (nnz4) {
+ if (nnz4&~0x01010101) {
+ for (x = 0; x < 4; x++) {
+ int 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);
+ }
+ }
+ } else {
+ s->vp8dsp.vp8_idct_dc_add4y(y_dst, s->block[y], 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);
+ for (ch = 0; ch < 2; ch++) {
+ uint32_t nnz4 = AV_RN32A(s->non_zero_count_cache[4+ch]);
+ if (nnz4) {
+ uint8_t *ch_dst = dst[1+ch];
+ if (nnz4&~0x01010101) {
+ for (y = 0; y < 2; y++) {
+ for (x = 0; x < 2; x++) {
+ int nnz = s->non_zero_count_cache[4+ch][(y<<1)+x];
+ if (nnz) {
+ if (nnz == 1)
+ s->vp8dsp.vp8_idct_dc_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
+ else
+ s->vp8dsp.vp8_idct_add(ch_dst+4*x, s->block[4+ch][(y<<1)+x], s->uvlinesize);
+ }
+ }
+ ch_dst += 4*s->uvlinesize;
+ }
+ } else {
+ s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, s->block[4+ch], 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)
+static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
{
int interior_limit, filter_level;
if (s->segmentation.enabled) {
- filter_level = s->segmentation.filter_level[mb->segment];
+ filter_level = s->segmentation.filter_level[s->segment];
if (!s->segmentation.absolute_vals)
filter_level += s->filter.level;
} else
@@ -1150,70 +1503,88 @@ static void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, int *level, in
}
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;
- }
- }
+ f->filter_level = filter_level;
+ f->inner_limit = interior_limit;
+ f->inner_filter = !mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT;
}
-// 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)
+static av_always_inline void filter_mb(VP8Context *s, uint8_t *dst[3], VP8FilterStrength *f, int mb_x, int mb_y)
{
- int filter_level, inner_limit, hev_thresh, mbedge_lim, bedge_lim;
+ int mbedge_lim, bedge_lim, hev_thresh;
+ int filter_level = f->filter_level;
+ int inner_limit = f->inner_limit;
+ int inner_filter = f->inner_filter;
+ int linesize = s->linesize;
+ int uvlinesize = s->uvlinesize;
- 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;
+ 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;
+ }
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);
+ s->vp8dsp.vp8_h_loop_filter16y(dst[0], linesize,
+ mbedge_lim, inner_limit, hev_thresh);
+ s->vp8dsp.vp8_h_loop_filter8uv(dst[1], dst[2], 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 (inner_filter) {
+ s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0]+ 4, linesize, bedge_lim,
+ inner_limit, hev_thresh);
+ s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0]+ 8, linesize, bedge_lim,
+ inner_limit, hev_thresh);
+ s->vp8dsp.vp8_h_loop_filter16y_inner(dst[0]+12, linesize, bedge_lim,
+ inner_limit, hev_thresh);
+ s->vp8dsp.vp8_h_loop_filter8uv_inner(dst[1] + 4, dst[2] + 4,
+ 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);
+ s->vp8dsp.vp8_v_loop_filter16y(dst[0], linesize,
+ mbedge_lim, inner_limit, hev_thresh);
+ s->vp8dsp.vp8_v_loop_filter8uv(dst[1], dst[2], 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);
+ if (inner_filter) {
+ s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+ 4*linesize,
+ linesize, bedge_lim,
+ inner_limit, hev_thresh);
+ s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+ 8*linesize,
+ linesize, bedge_lim,
+ inner_limit, hev_thresh);
+ s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+12*linesize,
+ linesize, bedge_lim,
+ inner_limit, hev_thresh);
+ s->vp8dsp.vp8_v_loop_filter8uv_inner(dst[1] + 4 * uvlinesize,
+ dst[2] + 4 * uvlinesize,
+ 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)
+static av_always_inline void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f, int mb_x, int mb_y)
{
- int filter_level, inner_limit, mbedge_lim, bedge_lim;
+ int mbedge_lim, bedge_lim;
+ int filter_level = f->filter_level;
+ int inner_limit = f->inner_limit;
+ int inner_filter = f->inner_filter;
+ int linesize = s->linesize;
- filter_level_for_mb(s, mb, &filter_level, &inner_limit, NULL);
if (!filter_level)
return;
@@ -1221,25 +1592,25 @@ static void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8Macroblock *mb, int
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);
+ s->vp8dsp.vp8_h_loop_filter_simple(dst, linesize, mbedge_lim);
+ if (inner_filter) {
+ s->vp8dsp.vp8_h_loop_filter_simple(dst+ 4, linesize, bedge_lim);
+ s->vp8dsp.vp8_h_loop_filter_simple(dst+ 8, linesize, bedge_lim);
+ s->vp8dsp.vp8_h_loop_filter_simple(dst+12, 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);
+ s->vp8dsp.vp8_v_loop_filter_simple(dst, linesize, mbedge_lim);
+ if (inner_filter) {
+ s->vp8dsp.vp8_v_loop_filter_simple(dst+ 4*linesize, linesize, bedge_lim);
+ s->vp8dsp.vp8_v_loop_filter_simple(dst+ 8*linesize, linesize, bedge_lim);
+ s->vp8dsp.vp8_v_loop_filter_simple(dst+12*linesize, linesize, bedge_lim);
}
}
static void filter_mb_row(VP8Context *s, int mb_y)
{
- VP8Macroblock *mb = s->macroblocks + mb_y*s->mb_stride;
+ VP8FilterStrength *f = s->filter_strength;
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,
@@ -1248,7 +1619,8 @@ static void filter_mb_row(VP8Context *s, int mb_y)
int mb_x;
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- filter_mb(s, dst, mb++, mb_x, mb_y);
+ backup_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2], s->linesize, s->uvlinesize, 0);
+ filter_mb(s, dst, f++, mb_x, mb_y);
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
@@ -1257,12 +1629,13 @@ static void filter_mb_row(VP8Context *s, int mb_y)
static void filter_mb_row_simple(VP8Context *s, int mb_y)
{
+ VP8FilterStrength *f = s->filter_strength;
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);
+ backup_mb_border(s->top_border[mb_x+1], dst, NULL, NULL, s->linesize, 0, 1);
+ filter_mb_simple(s, dst, f++, mb_x, mb_y);
dst += 16;
}
}
@@ -1273,7 +1646,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
VP8Context *s = avctx->priv_data;
int ret, mb_x, mb_y, i, y, referenced;
enum AVDiscard skip_thresh;
- AVFrame *curframe;
+ AVFrame *av_uninit(curframe);
if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0)
return ret;
@@ -1288,6 +1661,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
s->invisible = 1;
goto skip_decode;
}
+ s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh;
for (i = 0; i < 4; i++)
if (&s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
@@ -1325,50 +1699,62 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
memset(s->top_nnz, 0, s->mb_width*sizeof(*s->top_nnz));
+ /* Zero macroblock structures for top/top-left prediction from outside the frame. */
+ memset(s->macroblocks + s->mb_height*2 - 1, 0, (s->mb_width+1)*sizeof(*s->macroblocks));
+
// 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);
+ s->top_border[0][15] = s->top_border[0][23] = 127;
+ memset(s->top_border[1]-1, 127, s->mb_width*sizeof(*s->top_border)+1);
}
+ memset(s->ref_count, 0, sizeof(s->ref_count));
+ if (s->keyframe)
+ memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width*4);
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;
+ VP8Macroblock *mb = s->macroblocks + (s->mb_height - mb_y - 1)*2;
+ int mb_xy = mb_y*s->mb_width;
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(mb - 1, 0, sizeof(*mb)); // zero left macroblock
memset(s->left_nnz, 0, sizeof(s->left_nnz));
+ AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101);
// left edge of 129 for intra prediction
- if (!(avctx->flags & CODEC_FLAG_EMU_EDGE))
+ 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;
+ if (mb_y == 1) // top left edge is also 129
+ s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129;
+ }
+
+ for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
+ /* Prefetch the current frame, 4 MBs ahead */
+ s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);
+ s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2);
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- decode_mb_mode(s, mb, mb_x, mb_y, intra4x4 + 4*mb_x);
+ decode_mb_mode(s, mb, mb_x, mb_y, s->segmentation_map + mb_xy);
+
+ prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS);
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 {
+ if (mb->mode <= MODE_I4x4)
+ intra_predict(s, dst, mb, mb_x, mb_y);
+ else
inter_predict(s, dst, mb, mb_x, mb_y);
- }
+
+ prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN);
if (!mb->skip) {
- idct_mb(s, dst[0], dst[1], dst[2], mb);
+ idct_mb(s, dst, mb);
} else {
AV_ZERO64(s->left_nnz);
AV_WN64(s->top_nnz[mb_x], 0); // array of 9, so unaligned
@@ -1380,24 +1766,22 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
+ if (s->deblock_filter)
+ filter_level_for_mb(s, mb, &s->filter_strength[mb_x]);
+
+ prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN2);
+
dst[0] += 16;
dst[1] += 8;
dst[2] += 8;
- mb++;
}
- if (mb_y && s->filter.level && avctx->skip_loop_filter < skip_thresh) {
+ if (s->deblock_filter) {
if (s->filter.simple)
- filter_mb_row_simple(s, mb_y-1);
+ filter_mb_row_simple(s, mb_y);
else
- filter_mb_row(s, mb_y-1);
+ filter_mb_row(s, mb_y);
}
}
- 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,
@@ -1448,12 +1832,6 @@ static av_cold int vp8_decode_init(AVCodecContext *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;
}
@@ -1463,7 +1841,7 @@ static av_cold int vp8_decode_free(AVCodecContext *avctx)
return 0;
}
-AVCodec vp8_decoder = {
+AVCodec ff_vp8_decoder = {
"vp8",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VP8,
diff --git a/lib/ffmpeg/libavcodec/vp8_parser.c b/lib/ffmpeg/libavcodec/vp8_parser.c
index 10e7c3b44b..e769e33abe 100644
--- a/lib/ffmpeg/libavcodec/vp8_parser.c
+++ b/lib/ffmpeg/libavcodec/vp8_parser.c
@@ -32,7 +32,7 @@ static int parse(AVCodecParserContext *s,
return buf_size;
}
-AVCodecParser vp8_parser = {
+AVCodecParser ff_vp8_parser = {
{ CODEC_ID_VP8 },
0,
NULL,
diff --git a/lib/ffmpeg/libavcodec/vp8data.h b/lib/ffmpeg/libavcodec/vp8data.h
index e8bd82da79..775472e8e8 100644
--- a/lib/ffmpeg/libavcodec/vp8data.h
+++ b/lib/ffmpeg/libavcodec/vp8data.h
@@ -55,13 +55,6 @@ enum inter_mvmode {
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)
@@ -103,23 +96,6 @@ static const int vp8_mode_contexts[6][4] = {
{ 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 },
@@ -139,12 +115,6 @@ static const uint8_t vp8_mbfirstidx[4][16] = {
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 };
@@ -156,12 +126,6 @@ static const uint8_t vp8_submv_prob[5][3] = {
{ 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 };
@@ -329,19 +293,18 @@ 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] =
+/* Inverse of vp8_coeff_band: mappings of bands to coefficient indexes.
+ * Each list is -1-terminated. */
+static const int8_t vp8_coeff_band_indexes[8][10] =
{
- { -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'
+ {0, -1},
+ {1, -1},
+ {2, -1},
+ {3, -1},
+ {5, -1},
+ {6, -1},
+ {4, 7, 8, 9, 10, 11, 12, 13, 14, -1},
+ {15, -1}
};
static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 };
@@ -351,18 +314,15 @@ 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] =
+// only used for cat3 and above; cat 1 and 2 are referenced directly
+static const uint8_t * const vp8_dct_cat_prob[] =
{
- 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] =
{
{
diff --git a/lib/ffmpeg/libavcodec/vp8dsp.c b/lib/ffmpeg/libavcodec/vp8dsp.c
index 0d2dc01e70..30699cecbe 100644
--- a/lib/ffmpeg/libavcodec/vp8dsp.c
+++ b/lib/ffmpeg/libavcodec/vp8dsp.c
@@ -46,14 +46,30 @@ static void vp8_luma_dc_wht_c(DCTELEM block[4][4][16], DCTELEM dc[16])
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;
+ dc[i*4+0] = 0;
+ dc[i*4+1] = 0;
+ dc[i*4+2] = 0;
+ dc[i*4+3] = 0;
+
+ block[i][0][0] = (t0 + t1) >> 3;
+ block[i][1][0] = (t3 + t2) >> 3;
+ block[i][2][0] = (t0 - t1) >> 3;
+ block[i][3][0] = (t3 - t2) >> 3;
}
}
+static void vp8_luma_dc_wht_dc_c(DCTELEM block[4][4][16], DCTELEM dc[16])
+{
+ int i, val = (dc[0] + 3) >> 3;
+ dc[0] = 0;
+
+ for (i = 0; i < 4; i++) {
+ block[i][0][0] = val;
+ block[i][1][0] = val;
+ block[i][2][0] = val;
+ block[i][3][0] = val;
+ }
+}
#define MUL_20091(a) ((((a)*20091) >> 16) + (a))
#define MUL_35468(a) (((a)*35468) >> 16)
@@ -69,6 +85,10 @@ static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], int stride)
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]);
+ block[0*4+i] = 0;
+ block[1*4+i] = 0;
+ block[2*4+i] = 0;
+ block[3*4+i] = 0;
tmp[i*4+0] = t0 + t3;
tmp[i*4+1] = t1 + t2;
@@ -94,6 +114,7 @@ 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;
+ block[0] = 0;
for (i = 0; i < 4; i++) {
dst[0] = cm[dst[0]];
@@ -104,6 +125,21 @@ static void vp8_idct_dc_add_c(uint8_t *dst, DCTELEM block[16], int stride)
}
}
+static void vp8_idct_dc_add4uv_c(uint8_t *dst, DCTELEM block[4][16], int stride)
+{
+ vp8_idct_dc_add_c(dst+stride*0+0, block[0], stride);
+ vp8_idct_dc_add_c(dst+stride*0+4, block[1], stride);
+ vp8_idct_dc_add_c(dst+stride*4+0, block[2], stride);
+ vp8_idct_dc_add_c(dst+stride*4+4, block[3], stride);
+}
+
+static void vp8_idct_dc_add4y_c(uint8_t *dst, DCTELEM block[4][16], int stride)
+{
+ vp8_idct_dc_add_c(dst+ 0, block[0], stride);
+ vp8_idct_dc_add_c(dst+ 4, block[1], stride);
+ vp8_idct_dc_add_c(dst+ 8, block[2], stride);
+ vp8_idct_dc_add_c(dst+12, block[3], stride);
+}
// because I like only having two parameters to pass functions...
#define LOAD_PIXELS\
@@ -196,8 +232,8 @@ static av_always_inline void filter_mbedge(uint8_t *p, int stride)
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,\
+#define LOOP_FILTER(dir, size, stridea, strideb, maybe_inline) \
+static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, int stride,\
int flim_E, int flim_I, int hev_thresh)\
{\
int i;\
@@ -211,7 +247,7 @@ static void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, int stride,\
}\
}\
\
-static void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, int stride,\
+static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, int stride,\
int flim_E, int flim_I, int hev_thresh)\
{\
int i;\
@@ -226,10 +262,26 @@ static void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, int st
}\
}
-LOOP_FILTER(v, 16, 1, stride)
-LOOP_FILTER(h, 16, stride, 1)
-LOOP_FILTER(v, 8, 1, stride)
-LOOP_FILTER(h, 8, stride, 1)
+LOOP_FILTER(v, 16, 1, stride,)
+LOOP_FILTER(h, 16, stride, 1,)
+
+#define UV_LOOP_FILTER(dir, stridea, strideb) \
+LOOP_FILTER(dir, 8, stridea, strideb, av_always_inline) \
+static void vp8_ ## dir ## _loop_filter8uv_c(uint8_t *dstU, uint8_t *dstV, int stride,\
+ int fE, int fI, int hev_thresh)\
+{\
+ vp8_ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh);\
+ vp8_ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh);\
+}\
+static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, uint8_t *dstV, int stride,\
+ int fE, int fI, int hev_thresh)\
+{\
+ vp8_ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, hev_thresh);\
+ vp8_ ## dir ## _loop_filter8_inner_c(dstV, stride, fE, fI, hev_thresh);\
+}
+
+UV_LOOP_FILTER(v, 1, stride)
+UV_LOOP_FILTER(h, stride, 1)
static void vp8_v_loop_filter_simple_c(uint8_t *dst, int stride, int flim)
{
@@ -279,8 +331,8 @@ PUT_PIXELS(4)
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) \
+#define VP8_EPEL_H(SIZE, TAPS) \
+static void put_vp8_epel ## SIZE ## _h ## TAPS ## _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; \
@@ -288,13 +340,13 @@ static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dsts
\
for (y = 0; y < h; y++) { \
for (x = 0; x < SIZE; x++) \
- dst[x] = FILTER(src, filter, 1); \
+ dst[x] = FILTER_ ## TAPS ## TAP(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) \
+#define VP8_EPEL_V(SIZE, TAPS) \
+static void put_vp8_epel ## SIZE ## _v ## TAPS ## _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; \
@@ -302,63 +354,63 @@ static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dsts
\
for (y = 0; y < h; y++) { \
for (x = 0; x < SIZE; x++) \
- dst[x] = FILTER(src, filter, srcstride); \
+ dst[x] = FILTER_ ## TAPS ## TAP(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) \
+#define VP8_EPEL_HV(SIZE, HTAPS, VTAPS) \
+static void put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _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_array[(2*SIZE+VTAPS-1)*SIZE]; \
uint8_t *tmp = tmp_array; \
- src -= 2*srcstride; \
+ src -= (2-(VTAPS==4))*srcstride; \
\
- for (y = 0; y < h+5; y++) { \
+ for (y = 0; y < h+VTAPS-1; y++) { \
for (x = 0; x < SIZE; x++) \
- tmp[x] = FILTERX(src, filter, 1); \
+ tmp[x] = FILTER_ ## HTAPS ## TAP(src, filter, 1); \
tmp += SIZE; \
src += srcstride; \
} \
\
- tmp = tmp_array + 2*SIZE; \
+ tmp = tmp_array + (2-(VTAPS==4))*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[x] = FILTER_ ## VTAPS ## TAP(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)
+VP8_EPEL_H(16, 4)
+VP8_EPEL_H(8, 4)
+VP8_EPEL_H(4, 4)
+VP8_EPEL_H(16, 6)
+VP8_EPEL_H(8, 6)
+VP8_EPEL_H(4, 6)
+VP8_EPEL_V(16, 4)
+VP8_EPEL_V(8, 4)
+VP8_EPEL_V(4, 4)
+VP8_EPEL_V(16, 6)
+VP8_EPEL_V(8, 6)
+VP8_EPEL_V(4, 6)
+VP8_EPEL_HV(16, 4, 4)
+VP8_EPEL_HV(8, 4, 4)
+VP8_EPEL_HV(4, 4, 4)
+VP8_EPEL_HV(16, 4, 6)
+VP8_EPEL_HV(8, 4, 6)
+VP8_EPEL_HV(4, 4, 6)
+VP8_EPEL_HV(16, 6, 4)
+VP8_EPEL_HV(8, 6, 4)
+VP8_EPEL_HV(4, 6, 4)
+VP8_EPEL_HV(16, 6, 6)
+VP8_EPEL_HV(8, 6, 6)
+VP8_EPEL_HV(4, 6, 6)
#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) \
@@ -439,19 +491,22 @@ VP8_BILINEAR(4)
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_luma_dc_wht = vp8_luma_dc_wht_c;
+ dsp->vp8_luma_dc_wht_dc = vp8_luma_dc_wht_dc_c;
+ dsp->vp8_idct_add = vp8_idct_add_c;
+ dsp->vp8_idct_dc_add = vp8_idct_dc_add_c;
+ dsp->vp8_idct_dc_add4y = vp8_idct_dc_add4y_c;
+ dsp->vp8_idct_dc_add4uv = vp8_idct_dc_add4uv_c;
+
+ dsp->vp8_v_loop_filter16y = vp8_v_loop_filter16_c;
+ dsp->vp8_h_loop_filter16y = vp8_h_loop_filter16_c;
+ dsp->vp8_v_loop_filter8uv = vp8_v_loop_filter8uv_c;
+ dsp->vp8_h_loop_filter8uv = vp8_h_loop_filter8uv_c;
+
+ dsp->vp8_v_loop_filter16y_inner = vp8_v_loop_filter16_inner_c;
+ dsp->vp8_h_loop_filter16y_inner = vp8_h_loop_filter16_inner_c;
+ dsp->vp8_v_loop_filter8uv_inner = vp8_v_loop_filter8uv_inner_c;
+ dsp->vp8_h_loop_filter8uv_inner = vp8_h_loop_filter8uv_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;
diff --git a/lib/ffmpeg/libavcodec/vp8dsp.h b/lib/ffmpeg/libavcodec/vp8dsp.h
index b660048cc5..ee5c7ec0fb 100644
--- a/lib/ffmpeg/libavcodec/vp8dsp.h
+++ b/lib/ffmpeg/libavcodec/vp8dsp.h
@@ -31,20 +31,31 @@ typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, int dstStride, uint8_t *src
typedef struct VP8DSPContext {
void (*vp8_luma_dc_wht)(DCTELEM block[4][4][16], DCTELEM dc[16]);
+ void (*vp8_luma_dc_wht_dc)(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);
+ void (*vp8_idct_dc_add4y)(uint8_t *dst, DCTELEM block[4][16], int stride);
+ void (*vp8_idct_dc_add4uv)(uint8_t *dst, DCTELEM block[4][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);
+ void (*vp8_v_loop_filter16y)(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+ void (*vp8_h_loop_filter16y)(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+ void (*vp8_v_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+ void (*vp8_h_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, 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_filter16y_inner)(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+ void (*vp8_h_loop_filter16y_inner)(uint8_t *dst, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+ void (*vp8_v_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV, int stride,
+ int flim_E, int flim_I, int hev_thresh);
+ void (*vp8_h_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV, 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);
diff --git a/lib/ffmpeg/libavcodec/vqavideo.c b/lib/ffmpeg/libavcodec/vqavideo.c
index a1698394ef..c3b5ba6556 100644
--- a/lib/ffmpeg/libavcodec/vqavideo.c
+++ b/lib/ffmpeg/libavcodec/vqavideo.c
@@ -68,6 +68,7 @@
#include <string.h>
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#define PALETTE_COUNT 256
@@ -147,7 +148,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx)
s->vqa_version = vqa_header[0];
s->width = AV_RL16(&vqa_header[6]);
s->height = AV_RL16(&vqa_header[8]);
- if(avcodec_check_dimensions(avctx, s->width, s->height)){
+ if(av_image_check_size(s->width, s->height, 0, avctx)){
s->width= s->height= 0;
return -1;
}
@@ -608,7 +609,7 @@ static av_cold int vqa_decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec vqa_decoder = {
+AVCodec ff_vqa_decoder = {
"vqavideo",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WS_VQA,
diff --git a/lib/ffmpeg/libavcodec/wavpack.c b/lib/ffmpeg/libavcodec/wavpack.c
index 7358d29735..e96981460b 100644
--- a/lib/ffmpeg/libavcodec/wavpack.c
+++ b/lib/ffmpeg/libavcodec/wavpack.c
@@ -1,6 +1,6 @@
/*
* WavPack lossless audio decoder
- * Copyright (c) 2006 Konstantin Shishkov
+ * Copyright (c) 2006,2011 Konstantin Shishkov
*
* This file is part of FFmpeg.
*
@@ -91,7 +91,7 @@ typedef struct WvChannel {
int bitrate_acc, bitrate_delta;
} WvChannel;
-typedef struct WavpackContext {
+typedef struct WavpackFrameContext {
AVCodecContext *avctx;
int frame_flags;
int stereo, stereo_in;
@@ -118,6 +118,22 @@ typedef struct WavpackContext {
int max_samples;
int pos;
SavedContext sc, extra_sc;
+} WavpackFrameContext;
+
+#define WV_MAX_FRAME_DECODERS 14
+
+typedef struct WavpackContext {
+ AVCodecContext *avctx;
+
+ WavpackFrameContext *fdec[WV_MAX_FRAME_DECODERS];
+ int fdec_num;
+
+ int multichannel;
+ int mkv_mode;
+ int block;
+ int samples;
+ int samples_left;
+ int ch_offset;
} WavpackContext;
// exponent table copied from WavPack source
@@ -224,7 +240,7 @@ static av_always_inline int get_tail(GetBitContext *gb, int k)
return res;
}
-static void update_error_limit(WavpackContext *ctx)
+static void update_error_limit(WavpackFrameContext *ctx)
{
int i, br[2], sl[2];
@@ -258,7 +274,7 @@ static void update_error_limit(WavpackContext *ctx)
}
}
-static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int *last)
+static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, int channel, int *last)
{
int t, t2;
int sign, base, add, ret;
@@ -361,7 +377,7 @@ static int wv_get_value(WavpackContext *ctx, GetBitContext *gb, int channel, int
return sign ? ~ret : ret;
}
-static inline int wv_get_value_integer(WavpackContext *s, uint32_t *crc, int S)
+static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, int S)
{
int bit;
@@ -377,7 +393,7 @@ static inline int wv_get_value_integer(WavpackContext *s, uint32_t *crc, int S)
return (((S + bit) << s->shift) - bit) << s->post_shift;
}
-static float wv_get_value_float(WavpackContext *s, uint32_t *crc, int S)
+static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S)
{
union {
float f;
@@ -450,13 +466,13 @@ static float wv_get_value_float(WavpackContext *s, uint32_t *crc, int S)
return value.f;
}
-static void wv_reset_saved_context(WavpackContext *s)
+static void wv_reset_saved_context(WavpackFrameContext *s)
{
s->pos = 0;
s->sc.crc = s->extra_sc.crc = 0xFFFFFFFF;
}
-static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *dst, const int type)
+static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, void *dst, const int type)
{
int i, j, count = 0;
int last, t;
@@ -467,6 +483,7 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
int16_t *dst16 = dst;
int32_t *dst32 = dst;
float *dstfl = dst;
+ const int channel_pad = s->avctx->channels - 2;
if(s->samples_left == s->samples)
s->one = s->zero = s->zeroes = 0;
@@ -494,7 +511,7 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
B = s->decorr[i].samplesB[pos];
j = (pos + t) & 7;
}
- if(type != SAMPLE_FMT_S16){
+ if(type != AV_SAMPLE_FMT_S16){
L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10);
}else{
@@ -506,13 +523,13 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
s->decorr[i].samplesA[j] = L = L2;
s->decorr[i].samplesB[j] = R = R2;
}else if(t == -1){
- if(type != SAMPLE_FMT_S16)
+ if(type != AV_SAMPLE_FMT_S16)
L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10);
else
L2 = L + ((s->decorr[i].weightA * s->decorr[i].samplesA[0] + 512) >> 10);
UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L);
L = L2;
- if(type != SAMPLE_FMT_S16)
+ if(type != AV_SAMPLE_FMT_S16)
R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10);
else
R2 = R + ((s->decorr[i].weightB * L2 + 512) >> 10);
@@ -520,7 +537,7 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
R = R2;
s->decorr[i].samplesA[0] = R;
}else{
- if(type != SAMPLE_FMT_S16)
+ if(type != AV_SAMPLE_FMT_S16)
R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10);
else
R2 = R + ((s->decorr[i].weightB * s->decorr[i].samplesB[0] + 512) >> 10);
@@ -532,7 +549,7 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
s->decorr[i].samplesA[0] = R;
}
- if(type != SAMPLE_FMT_S16)
+ if(type != AV_SAMPLE_FMT_S16)
L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10);
else
L2 = L + ((s->decorr[i].weightA * R2 + 512) >> 10);
@@ -546,15 +563,18 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
L += (R -= (L >> 1));
crc = (crc * 3 + L) * 3 + R;
- if(type == SAMPLE_FMT_FLT){
+ if(type == AV_SAMPLE_FMT_FLT){
*dstfl++ = wv_get_value_float(s, &crc_extra_bits, L);
*dstfl++ = wv_get_value_float(s, &crc_extra_bits, R);
- } else if(type == SAMPLE_FMT_S32){
+ dstfl += channel_pad;
+ } else if(type == AV_SAMPLE_FMT_S32){
*dst32++ = wv_get_value_integer(s, &crc_extra_bits, L);
*dst32++ = wv_get_value_integer(s, &crc_extra_bits, R);
+ dst32 += channel_pad;
} else {
*dst16++ = wv_get_value_integer(s, &crc_extra_bits, L);
*dst16++ = wv_get_value_integer(s, &crc_extra_bits, R);
+ dst16 += channel_pad;
}
count++;
}while(!last && count < s->max_samples);
@@ -582,7 +602,7 @@ static inline int wv_unpack_stereo(WavpackContext *s, GetBitContext *gb, void *d
return count * 2;
}
-static inline int wv_unpack_mono(WavpackContext *s, GetBitContext *gb, void *dst, const int type)
+static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb, void *dst, const int type)
{
int i, j, count = 0;
int last, t;
@@ -593,6 +613,7 @@ static inline int wv_unpack_mono(WavpackContext *s, GetBitContext *gb, void *dst
int16_t *dst16 = dst;
int32_t *dst32 = dst;
float *dstfl = dst;
+ const int channel_stride = s->avctx->channels;
if(s->samples_left == s->samples)
s->one = s->zero = s->zeroes = 0;
@@ -613,7 +634,7 @@ static inline int wv_unpack_mono(WavpackContext *s, GetBitContext *gb, void *dst
A = s->decorr[i].samplesA[pos];
j = (pos + t) & 7;
}
- if(type != SAMPLE_FMT_S16)
+ if(type != AV_SAMPLE_FMT_S16)
S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
else
S = T + ((s->decorr[i].weightA * A + 512) >> 10);
@@ -623,14 +644,18 @@ static inline int wv_unpack_mono(WavpackContext *s, GetBitContext *gb, void *dst
pos = (pos + 1) & 7;
crc = crc * 3 + S;
- if(type == SAMPLE_FMT_FLT)
- *dstfl++ = wv_get_value_float(s, &crc_extra_bits, S);
- else if(type == SAMPLE_FMT_S32)
- *dst32++ = wv_get_value_integer(s, &crc_extra_bits, S);
- else
- *dst16++ = wv_get_value_integer(s, &crc_extra_bits, S);
+ if(type == AV_SAMPLE_FMT_FLT){
+ *dstfl = wv_get_value_float(s, &crc_extra_bits, S);
+ dstfl += channel_stride;
+ }else if(type == AV_SAMPLE_FMT_S32){
+ *dst32 = wv_get_value_integer(s, &crc_extra_bits, S);
+ dst32 += channel_stride;
+ }else{
+ *dst16 = wv_get_value_integer(s, &crc_extra_bits, S);
+ dst16 += channel_stride;
+ }
count++;
- }while(!last && count < s->samples);
+ }while(!last && count < s->max_samples);
s->samples_left -= count;
if(!s->samples_left){
@@ -655,43 +680,92 @@ static inline int wv_unpack_mono(WavpackContext *s, GetBitContext *gb, void *dst
return count;
}
+static av_cold int wv_alloc_frame_context(WavpackContext *c)
+{
+
+ if(c->fdec_num == WV_MAX_FRAME_DECODERS)
+ return -1;
+
+ c->fdec[c->fdec_num] = av_mallocz(sizeof(**c->fdec));
+ if(!c->fdec[c->fdec_num])
+ return -1;
+ c->fdec_num++;
+ c->fdec[c->fdec_num - 1]->avctx = c->avctx;
+ wv_reset_saved_context(c->fdec[c->fdec_num - 1]);
+
+ return 0;
+}
+
static av_cold int wavpack_decode_init(AVCodecContext *avctx)
{
WavpackContext *s = avctx->priv_data;
s->avctx = avctx;
- s->stereo = (avctx->channels == 2);
if(avctx->bits_per_coded_sample <= 16)
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
else
- avctx->sample_fmt = SAMPLE_FMT_S32;
- avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32;
+ if(avctx->channels <= 2 && !avctx->channel_layout)
+ avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+
+ s->multichannel = avctx->channels > 2;
+ /* lavf demuxer does not provide extradata, Matroska stores 0x403
+ there, use this to detect decoding mode for multichannel */
+ s->mkv_mode = 0;
+ if(s->multichannel && avctx->extradata && avctx->extradata_size == 2){
+ int ver = AV_RL16(avctx->extradata);
+ if(ver >= 0x402 && ver <= 0x410)
+ s->mkv_mode = 1;
+ }
- wv_reset_saved_context(s);
+ s->fdec_num = 0;
return 0;
}
-static int wavpack_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
+static av_cold int wavpack_decode_end(AVCodecContext *avctx)
{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
WavpackContext *s = avctx->priv_data;
+ int i;
+
+ for(i = 0; i < s->fdec_num; i++)
+ av_freep(&s->fdec[i]);
+ s->fdec_num = 0;
+
+ return 0;
+}
+
+static int wavpack_decode_block(AVCodecContext *avctx, int block_no,
+ void *data, int *data_size,
+ const uint8_t *buf, int buf_size)
+{
+ WavpackContext *wc = avctx->priv_data;
+ WavpackFrameContext *s;
void *samples = data;
int samplecount;
int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0, got_float = 0;
int got_hybrid = 0;
+ const uint8_t* orig_buf = buf;
const uint8_t* buf_end = buf + buf_size;
int i, j, id, size, ssize, weights, t;
- int bpp;
+ int bpp, chan, chmask;
if (buf_size == 0){
*data_size = 0;
return 0;
}
+ if(block_no >= wc->fdec_num && wv_alloc_frame_context(wc) < 0){
+ av_log(avctx, AV_LOG_ERROR, "Error creating frame decode context\n");
+ return -1;
+ }
+
+ s = wc->fdec[block_no];
+ if(!s){
+ av_log(avctx, AV_LOG_ERROR, "Context for block %d is not present\n", block_no);
+ return -1;
+ }
+
if(!s->samples_left){
memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
memset(s->ch, 0, sizeof(s->ch));
@@ -700,28 +774,39 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
s->got_extra_bits = 0;
}
- s->samples = AV_RL32(buf); buf += 4;
- if(!s->samples){
- *data_size = 0;
- return buf_size;
+ if(!wc->mkv_mode){
+ s->samples = AV_RL32(buf); buf += 4;
+ if(!s->samples){
+ *data_size = 0;
+ return buf_size;
+ }
+ }else{
+ s->samples = wc->samples;
}
s->frame_flags = AV_RL32(buf); buf += 4;
if(s->frame_flags&0x80){
bpp = sizeof(float);
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
} else if((s->frame_flags&0x03) <= 1){
bpp = 2;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
} else {
bpp = 4;
- avctx->sample_fmt = SAMPLE_FMT_S32;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32;
}
+ samples = (uint8_t*)samples + bpp * wc->ch_offset;
+
+ s->stereo = !(s->frame_flags & WV_MONO);
s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
s->joint = s->frame_flags & WV_JOINT_STEREO;
s->hybrid = s->frame_flags & WV_HYBRID_MODE;
s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE;
s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f);
s->CRC = AV_RL32(buf); buf += 4;
+ if(wc->mkv_mode)
+ buf += 4; //skip block size;
+
+ wc->ch_offset += 1 + s->stereo;
s->max_samples = *data_size / (bpp * avctx->channels);
s->max_samples = FFMIN(s->max_samples, s->samples);
@@ -895,7 +980,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
got_float = 1;
break;
case WP_ID_DATA:
- s->sc.offset = buf - avpkt->data;
+ s->sc.offset = buf - orig_buf;
s->sc.size = size * 8;
init_get_bits(&s->gb, buf, size * 8);
s->data_size = size * 8;
@@ -908,13 +993,50 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
buf += size;
continue;
}
- s->extra_sc.offset = buf - avpkt->data;
+ s->extra_sc.offset = buf - orig_buf;
s->extra_sc.size = size * 8;
init_get_bits(&s->gb_extra_bits, buf, size * 8);
s->crc_extra_bits = get_bits_long(&s->gb_extra_bits, 32);
buf += size;
s->got_extra_bits = 1;
break;
+ case WP_ID_CHANINFO:
+ if(size <= 1){
+ av_log(avctx, AV_LOG_ERROR, "Insufficient channel information\n");
+ return -1;
+ }
+ chan = *buf++;
+ switch(size - 2){
+ case 0:
+ chmask = *buf;
+ break;
+ case 1:
+ chmask = AV_RL16(buf);
+ break;
+ case 2:
+ chmask = AV_RL24(buf);
+ break;
+ case 3:
+ chmask = AV_RL32(buf);
+ break;
+ case 5:
+ chan |= (buf[1] & 0xF) << 8;
+ chmask = AV_RL24(buf + 2);
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Invalid channel info size %d\n", size);
+ chan = avctx->channels;
+ chmask = avctx->channel_layout;
+ }
+ if(chan != avctx->channels){
+ av_log(avctx, AV_LOG_ERROR, "Block reports total %d channels, decoder believes it's %d channels\n",
+ chan, avctx->channels);
+ return -1;
+ }
+ if(!avctx->channel_layout)
+ avctx->channel_layout = chmask;
+ buf += size - 1;
+ break;
default:
buf += size;
}
@@ -945,11 +1067,11 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Packed samples not found\n");
return -1;
}
- if(!got_float && avctx->sample_fmt == SAMPLE_FMT_FLT){
+ if(!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLT){
av_log(avctx, AV_LOG_ERROR, "Float information not found\n");
return -1;
}
- if(s->got_extra_bits && avctx->sample_fmt != SAMPLE_FMT_FLT){
+ if(s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLT){
const int size = get_bits_left(&s->gb_extra_bits);
const int wanted = s->samples * s->extra_bits << s->stereo_in;
if(size < wanted){
@@ -959,73 +1081,121 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
}
s->samples_left = s->samples;
}else{
- init_get_bits(&s->gb, avpkt->data + s->sc.offset, s->sc.size);
+ init_get_bits(&s->gb, orig_buf + s->sc.offset, s->sc.size);
skip_bits_long(&s->gb, s->sc.bits_used);
if(s->got_extra_bits){
- init_get_bits(&s->gb_extra_bits, avpkt->data + s->extra_sc.offset,
+ init_get_bits(&s->gb_extra_bits, orig_buf + s->extra_sc.offset,
s->extra_sc.size);
skip_bits_long(&s->gb_extra_bits, s->extra_sc.bits_used);
}
}
if(s->stereo_in){
- if(avctx->sample_fmt == SAMPLE_FMT_S16)
- samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_S16);
- else if(avctx->sample_fmt == SAMPLE_FMT_S32)
- samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_S32);
+ if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
+ samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
+ else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
+ samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
else
- samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_FLT);
-
+ samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
+ samplecount >>= 1;
}else{
- if(avctx->sample_fmt == SAMPLE_FMT_S16)
- samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_S16);
- else if(avctx->sample_fmt == SAMPLE_FMT_S32)
- samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_S32);
+ const int channel_stride = avctx->channels;
+
+ if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
+ samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
+ else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
+ samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
else
- samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_FLT);
+ samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
- if(s->stereo && avctx->sample_fmt == SAMPLE_FMT_S16){
- int16_t *dst = (int16_t*)samples + samplecount * 2;
- int16_t *src = (int16_t*)samples + samplecount;
+ if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
+ int16_t *dst = (int16_t*)samples + 1;
+ int16_t *src = (int16_t*)samples;
int cnt = samplecount;
while(cnt--){
- *--dst = *--src;
- *--dst = *src;
+ *dst = *src;
+ src += channel_stride;
+ dst += channel_stride;
}
- samplecount *= 2;
- }else if(s->stereo && avctx->sample_fmt == SAMPLE_FMT_S32){
- int32_t *dst = (int32_t*)samples + samplecount * 2;
- int32_t *src = (int32_t*)samples + samplecount;
+ }else if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S32){
+ int32_t *dst = (int32_t*)samples + 1;
+ int32_t *src = (int32_t*)samples;
int cnt = samplecount;
while(cnt--){
- *--dst = *--src;
- *--dst = *src;
+ *dst = *src;
+ src += channel_stride;
+ dst += channel_stride;
}
- samplecount *= 2;
}else if(s->stereo){
- float *dst = (float*)samples + samplecount * 2;
- float *src = (float*)samples + samplecount;
+ float *dst = (float*)samples + 1;
+ float *src = (float*)samples;
int cnt = samplecount;
while(cnt--){
- *--dst = *--src;
- *--dst = *src;
+ *dst = *src;
+ src += channel_stride;
+ dst += channel_stride;
}
- samplecount *= 2;
}
}
- *data_size = samplecount * bpp;
- return s->samples_left > 0 ? 0 : buf_size;
+ wc->samples_left = s->samples_left;
+
+ return samplecount * bpp;
}
-AVCodec wavpack_decoder = {
+static int wavpack_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ WavpackContext *s = avctx->priv_data;
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ int frame_size;
+ int samplecount = 0;
+
+ s->block = 0;
+ s->samples_left = 0;
+ s->ch_offset = 0;
+
+ if(s->mkv_mode){
+ s->samples = AV_RL32(buf); buf += 4;
+ }
+ while(buf_size > 0){
+ if(!s->multichannel){
+ frame_size = buf_size;
+ }else{
+ if(!s->mkv_mode){
+ frame_size = AV_RL32(buf) - 12; buf += 4; buf_size -= 4;
+ }else{
+ if(buf_size < 12) //MKV files can have zero flags after last block
+ break;
+ frame_size = AV_RL32(buf + 8) + 12;
+ }
+ }
+ if(frame_size < 0 || frame_size > buf_size){
+ av_log(avctx, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",
+ s->block, frame_size, buf_size);
+ return -1;
+ }
+ if((samplecount = wavpack_decode_block(avctx, s->block, data,
+ data_size, buf, frame_size)) < 0)
+ return -1;
+ s->block++;
+ buf += frame_size; buf_size -= frame_size;
+ }
+ *data_size = samplecount * avctx->channels;
+
+ return s->samples_left > 0 ? 0 : avpkt->size;
+}
+
+AVCodec ff_wavpack_decoder = {
"wavpack",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_WAVPACK,
sizeof(WavpackContext),
wavpack_decode_init,
NULL,
- NULL,
+ wavpack_decode_end,
wavpack_decode_frame,
.capabilities = CODEC_CAP_SUBFRAMES,
.long_name = NULL_IF_CONFIG_SMALL("WavPack"),
diff --git a/lib/ffmpeg/libavcodec/wma.c b/lib/ffmpeg/libavcodec/wma.c
index e2d153b835..a7eacb8c78 100644
--- a/lib/ffmpeg/libavcodec/wma.c
+++ b/lib/ffmpeg/libavcodec/wma.c
@@ -126,6 +126,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
s->block_align = avctx->block_align;
dsputil_init(&s->dsp, avctx);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
if (avctx->codec->id == CODEC_ID_WMAV1) {
s->version = 1;
@@ -217,13 +218,13 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
high_freq = high_freq * 0.5;
}
}
- dprintf(s->avctx, "flags2=0x%x\n", flags2);
- dprintf(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
+ av_dlog(s->avctx, "flags2=0x%x\n", flags2);
+ av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, s->nb_channels, s->sample_rate, s->bit_rate,
s->block_align);
- dprintf(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
+ av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
- dprintf(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
+ av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
/* compute the scale factor band sizes for each MDCT block size */
diff --git a/lib/ffmpeg/libavcodec/wma.h b/lib/ffmpeg/libavcodec/wma.h
index 11274ad970..a51b3e83cf 100644
--- a/lib/ffmpeg/libavcodec/wma.h
+++ b/lib/ffmpeg/libavcodec/wma.h
@@ -26,6 +26,7 @@
#include "put_bits.h"
#include "dsputil.h"
#include "fft.h"
+#include "fmtconvert.h"
/* size of blocks */
#define BLOCK_MIN_BITS 7
@@ -134,6 +135,7 @@ typedef struct WMACodecContext {
float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
DSPContext dsp;
+ FmtConvertContext fmt_conv;
#ifdef TRACE
int frame_count;
diff --git a/lib/ffmpeg/libavcodec/wmadec.c b/lib/ffmpeg/libavcodec/wmadec.c
index 5582a7236b..83f8dea8bb 100644
--- a/lib/ffmpeg/libavcodec/wmadec.c
+++ b/lib/ffmpeg/libavcodec/wmadec.c
@@ -123,7 +123,7 @@ static int wma_decode_init(AVCodecContext * avctx)
wma_lsp_to_curve_init(s, s->frame_len);
}
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -768,9 +768,8 @@ next:
/* decode a frame of frame_len samples */
static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
{
- int ret, i, n, ch, incr;
- int16_t *ptr;
- float *iptr;
+ int ret, n, ch, incr;
+ const float *output[MAX_CHANNELS];
#ifdef TRACE
tprintf(s->avctx, "***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
@@ -790,28 +789,12 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
/* convert frame to integer */
n = s->frame_len;
incr = s->nb_channels;
- if (s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
- for(ch = 0; ch < s->nb_channels; ch++) {
- ptr = samples + ch;
- iptr = s->frame_out[ch];
-
- for(i=0;i<n;i++) {
- *ptr = av_clip_int16(lrintf(*iptr++));
- ptr += incr;
- }
- /* prepare for next block */
- memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
- s->frame_len * sizeof(float));
- }
- } else {
- 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, 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));
- }
+ for (ch = 0; ch < MAX_CHANNELS; ch++)
+ output[ch] = s->frame_out[ch];
+ s->fmt_conv.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));
}
#ifdef TRACE
@@ -939,7 +922,7 @@ static av_cold void flush(AVCodecContext *avctx)
s->last_superframe_len= 0;
}
-AVCodec wmav1_decoder =
+AVCodec ff_wmav1_decoder =
{
"wmav1",
AVMEDIA_TYPE_AUDIO,
@@ -953,7 +936,7 @@ AVCodec wmav1_decoder =
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
};
-AVCodec wmav2_decoder =
+AVCodec ff_wmav2_decoder =
{
"wmav2",
AVMEDIA_TYPE_AUDIO,
diff --git a/lib/ffmpeg/libavcodec/wmaenc.c b/lib/ffmpeg/libavcodec/wmaenc.c
index 7aaeb70baa..4e54a70161 100644
--- a/lib/ffmpeg/libavcodec/wmaenc.c
+++ b/lib/ffmpeg/libavcodec/wmaenc.c
@@ -74,7 +74,7 @@ static int encode_init(AVCodecContext * avctx){
}
-static void apply_window_and_mdct(AVCodecContext * avctx, signed short * audio, int len) {
+static void apply_window_and_mdct(AVCodecContext * avctx, const signed short * audio, int len) {
WMACodecContext *s = avctx->priv_data;
int window_index= s->frame_len_bits - s->block_len_bits;
int i, j, channel;
@@ -328,7 +328,7 @@ static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
static int encode_superframe(AVCodecContext *avctx,
unsigned char *buf, int buf_size, void *data){
WMACodecContext *s = avctx->priv_data;
- short *samples = data;
+ const short *samples = data;
int i, total_gain;
s->block_len_bits= s->frame_len_bits; //required by non variable block len
@@ -383,7 +383,7 @@ static int encode_superframe(AVCodecContext *avctx,
return put_bits_ptr(&s->pb) - s->pb.buf;
}
-AVCodec wmav1_encoder =
+AVCodec ff_wmav1_encoder =
{
"wmav1",
AVMEDIA_TYPE_AUDIO,
@@ -392,11 +392,11 @@ AVCodec wmav1_encoder =
encode_init,
encode_superframe,
ff_wma_end,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
};
-AVCodec wmav2_encoder =
+AVCodec ff_wmav2_encoder =
{
"wmav2",
AVMEDIA_TYPE_AUDIO,
@@ -405,6 +405,6 @@ AVCodec wmav2_encoder =
encode_init,
encode_superframe,
ff_wma_end,
- .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
};
diff --git a/lib/ffmpeg/libavcodec/wmaprodec.c b/lib/ffmpeg/libavcodec/wmaprodec.c
index 3eca10150a..d248ae4ac0 100644
--- a/lib/ffmpeg/libavcodec/wmaprodec.c
+++ b/lib/ffmpeg/libavcodec/wmaprodec.c
@@ -1,7 +1,7 @@
/*
* Wmapro compatible decoder
* Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion
- * Copyright (c) 2008 - 2009 Sascha Sommer, Benjamin Larsson
+ * Copyright (c) 2008 - 2011 Sascha Sommer, Benjamin Larsson
*
* This file is part of FFmpeg.
*
@@ -100,9 +100,10 @@
#define MAX_BANDS 29 ///< max number of scale factor bands
#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size
+#define WMAPRO_BLOCK_MIN_BITS 6 ///< log2 of min block size
#define WMAPRO_BLOCK_MAX_BITS 12 ///< log2 of max block size
#define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS) ///< maximum block size
-#define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1) ///< possible block sizes
+#define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1) ///< possible block sizes
#define VLCBITS 9
@@ -142,6 +143,7 @@ typedef struct {
int* scale_factors; ///< pointer to the scale factor values used for decoding
uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block
float* coeffs; ///< pointer to the subframe decode buffer
+ uint16_t num_vec_coeffs; ///< number of vector coded coefficients
DECLARE_ALIGNED(16, float, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer
} WMAProChannelCtx;
@@ -190,6 +192,7 @@ typedef struct WMAProDecodeCtx {
/* packet decode state */
GetBitContext pgb; ///< bitstream reader context for the packet
+ int next_packet_start; ///< start offset of the next wma packet in the demuxer packet
uint8_t packet_offset; ///< frame offset in the packet
uint8_t packet_sequence_number; ///< current packet number
int num_saved_bits; ///< saved number of bits
@@ -213,6 +216,7 @@ typedef struct WMAProDecodeCtx {
int8_t channels_for_cur_subframe; ///< number of channels that contain the subframe
int8_t channel_indexes_for_cur_subframe[WMAPRO_MAX_CHANNELS];
int8_t num_bands; ///< number of scale factor bands
+ int8_t transmit_num_vec_coeffs; ///< number of vector coded coefficients is part of the bitstream
int16_t* cur_sfb_offsets; ///< sfb offsets for the current block
uint8_t table_idx; ///< index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables
int8_t esc_len; ///< length of escaped coefficients
@@ -276,7 +280,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
dsputil_init(&s->dsp, avctx);
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
- avctx->sample_fmt = SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
if (avctx->extradata_size >= 18) {
s->decode_flags = AV_RL16(edata_ptr+14);
@@ -284,8 +288,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->bits_per_sample = AV_RL16(edata_ptr);
/** dump the extradata */
for (i = 0; i < avctx->extradata_size; i++)
- dprintf(avctx, "[%x] ", avctx->extradata[i]);
- dprintf(avctx, "\n");
+ av_dlog(avctx, "[%x] ", avctx->extradata[i]);
+ av_dlog(avctx, "\n");
} else {
av_log_ask_for_sample(avctx, "Unknown extradata size\n");
@@ -296,15 +300,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->log2_frame_size = av_log2(avctx->block_align) + 4;
/** frame info */
- s->skip_frame = 1; /** skip first frame */
+ s->skip_frame = 1; /* skip first frame */
s->packet_loss = 1;
s->len_prefix = (s->decode_flags & 0x40);
- if (!s->len_prefix) {
- av_log_ask_for_sample(avctx, "no length prefix\n");
- return AVERROR_INVALIDDATA;
- }
-
/** get frame len */
s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(avctx->sample_rate,
3, s->decode_flags);
@@ -316,7 +315,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
/** subframe info */
log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3);
s->max_num_subframes = 1 << log2_max_num_subframes;
- if (s->max_num_subframes == 16)
+ if (s->max_num_subframes == 16 || s->max_num_subframes == 4)
s->max_subframe_len_bit = 1;
s->subframe_len_bits = av_log2(log2_max_num_subframes) + 1;
@@ -422,8 +421,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
/** init MDCT, FIXME: only init needed sizes */
for (i = 0; i < WMAPRO_BLOCK_SIZES; i++)
- ff_mdct_init(&s->mdct_ctx[i], BLOCK_MIN_BITS+1+i, 1,
- 1.0 / (1 << (BLOCK_MIN_BITS + i - 1))
+ ff_mdct_init(&s->mdct_ctx[i], WMAPRO_BLOCK_MIN_BITS+1+i, 1,
+ 1.0 / (1 << (WMAPRO_BLOCK_MIN_BITS + i - 1))
/ (1 << (s->bits_per_sample - 1)));
/** init MDCT windows: simple sinus window */
@@ -508,11 +507,11 @@ static int decode_subframe_length(WMAProDecodeCtx *s, int offset)
*/
static int decode_tilehdr(WMAProDecodeCtx *s)
{
- uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /** sum of samples for all currently known subframes of a channel */
- uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /** flag indicating if a channel contains the current subframe */
- int channels_for_cur_subframe = s->num_channels; /** number of channels that contain the current subframe */
- int fixed_channel_layout = 0; /** flag indicating that all channels use the same subframe offsets and sizes */
- int min_channel_len = 0; /** smallest sum of samples (channels with this length will be processed first) */
+ uint16_t num_samples[WMAPRO_MAX_CHANNELS]; /**< sum of samples for all currently known subframes of a channel */
+ uint8_t contains_subframe[WMAPRO_MAX_CHANNELS]; /**< flag indicating if a channel contains the current subframe */
+ int channels_for_cur_subframe = s->num_channels; /**< number of channels that contain the current subframe */
+ int fixed_channel_layout = 0; /**< flag indicating that all channels use the same subframe offsets and sizes */
+ int min_channel_len = 0; /**< smallest sum of samples (channels with this length will be processed first) */
int c;
/* Should never consume more than 3073 bits (256 iterations for the
@@ -583,7 +582,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s)
int i;
int offset = 0;
for (i = 0; i < s->channel[c].num_subframes; i++) {
- dprintf(s->avctx, "frame[%i] channel[%i] subframe[%i]"
+ av_dlog(s->avctx, "frame[%i] channel[%i] subframe[%i]"
" len %i\n", s->frame_num, c, i,
s->channel[c].subframe_len[i]);
s->channel[c].subframe_offset[i] = offset;
@@ -782,7 +781,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
const uint16_t* run;
const float* level;
- dprintf(s->avctx, "decode coefficients for channel %i\n", c);
+ av_dlog(s->avctx, "decode coefficients for channel %i\n", c);
vlctable = get_bits1(&s->gb);
vlc = &coef_vlc[vlctable];
@@ -797,7 +796,8 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
/** decode vector coefficients (consumes up to 167 bits per iteration for
4 vector coded large values) */
- while (!rl_mode && cur_coeff + 3 < s->subframe_len) {
+ while ((s->transmit_num_vec_coeffs || !rl_mode) &&
+ (cur_coeff + 3 < ci->num_vec_coeffs)) {
int vals[4];
int i;
unsigned int idx;
@@ -846,7 +846,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
}
/** decode run level coded coefficients */
- if (rl_mode) {
+ if (cur_coeff < s->subframe_len) {
memset(&ci->coeffs[cur_coeff], 0,
sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff));
if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc,
@@ -1026,12 +1026,12 @@ static void wmapro_window(WMAProDecodeCtx *s)
winlen = s->subframe_len;
}
- window = s->windows[av_log2(winlen) - BLOCK_MIN_BITS];
+ window = s->windows[av_log2(winlen) - WMAPRO_BLOCK_MIN_BITS];
winlen >>= 1;
s->dsp.vector_fmul_window(start, start, start + winlen,
- window, 0, winlen);
+ window, winlen);
s->channel[c].prev_block_len = s->subframe_len;
}
@@ -1066,7 +1066,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
}
}
- dprintf(s->avctx,
+ av_dlog(s->avctx,
"processing subframe with offset %i len %i\n", offset, subframe_len);
/** get a list of all channels that contain the estimated block */
@@ -1093,7 +1093,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
s->parsed_all_subframes = 1;
- dprintf(s->avctx, "subframe is part of %i channels\n",
+ av_dlog(s->avctx, "subframe is part of %i channels\n",
s->channels_for_cur_subframe);
/** calculate number of scale factor bands and their offsets */
@@ -1151,10 +1151,19 @@ static int decode_subframe(WMAProDecodeCtx *s)
if (transmit_coeffs) {
int step;
int quant_step = 90 * s->bits_per_sample >> 4;
- if ((get_bits1(&s->gb))) {
- /** FIXME: might change run level mode decision */
- av_log_ask_for_sample(s->avctx, "unsupported quant step coding\n");
- return AVERROR_INVALIDDATA;
+
+ /** decode number of vector coded coefficients */
+ if ((s->transmit_num_vec_coeffs = get_bits1(&s->gb))) {
+ int num_bits = av_log2((s->subframe_len + 3)/4) + 1;
+ for (i = 0; i < s->channels_for_cur_subframe; i++) {
+ int c = s->channel_indexes_for_cur_subframe[i];
+ s->channel[c].num_vec_coeffs = get_bits(&s->gb, num_bits) << 2;
+ }
+ } else {
+ for (i = 0; i < s->channels_for_cur_subframe; i++) {
+ int c = s->channel_indexes_for_cur_subframe[i];
+ s->channel[c].num_vec_coeffs = s->subframe_len;
+ }
}
/** decode quantization step */
step = get_sbits(&s->gb, 6);
@@ -1195,7 +1204,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
return AVERROR_INVALIDDATA;
}
- dprintf(s->avctx, "BITSTREAM: subframe header length was %i\n",
+ av_dlog(s->avctx, "BITSTREAM: subframe header length was %i\n",
get_bits_count(&s->gb) - s->subframe_offset);
/** parse coefficients */
@@ -1209,7 +1218,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
sizeof(*s->channel[c].coeffs) * subframe_len);
}
- dprintf(s->avctx, "BITSTREAM: subframe length was %i\n",
+ av_dlog(s->avctx, "BITSTREAM: subframe length was %i\n",
get_bits_count(&s->gb) - s->subframe_offset);
if (transmit_coeffs) {
@@ -1238,7 +1247,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
}
/** apply imdct (ff_imdct_half == DCTIV with reverse) */
- ff_imdct_half(&s->mdct_ctx[av_log2(subframe_len) - BLOCK_MIN_BITS],
+ ff_imdct_half(&s->mdct_ctx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS],
s->channel[c].coeffs, s->tmp);
}
}
@@ -1285,7 +1294,7 @@ static int decode_frame(WMAProDecodeCtx *s)
if (s->len_prefix)
len = get_bits(gb, s->log2_frame_size);
- dprintf(s->avctx, "decoding frame with length %x\n", len);
+ av_dlog(s->avctx, "decoding frame with length %x\n", len);
/** decode tile information */
if (decode_tilehdr(s)) {
@@ -1295,15 +1304,16 @@ static int decode_frame(WMAProDecodeCtx *s)
/** read postproc transform */
if (s->num_channels > 1 && get_bits1(gb)) {
- av_log_ask_for_sample(s->avctx, "Unsupported postproc transform found\n");
- s->packet_loss = 1;
- return 0;
+ if (get_bits1(gb)) {
+ for (i = 0; i < s->num_channels * s->num_channels; i++)
+ skip_bits(gb, 4);
+ }
}
/** read drc info */
if (s->dynamic_range_compression) {
s->drc_gain = get_bits(gb, 8);
- dprintf(s->avctx, "drc_gain %i\n", s->drc_gain);
+ av_dlog(s->avctx, "drc_gain %i\n", s->drc_gain);
}
/** no idea what these are for, might be the number of samples
@@ -1314,18 +1324,18 @@ static int decode_frame(WMAProDecodeCtx *s)
/** usually true for the first frame */
if (get_bits1(gb)) {
skip = get_bits(gb, av_log2(s->samples_per_frame * 2));
- dprintf(s->avctx, "start skip: %i\n", skip);
+ av_dlog(s->avctx, "start skip: %i\n", skip);
}
/** sometimes true for the last frame */
if (get_bits1(gb)) {
skip = get_bits(gb, av_log2(s->samples_per_frame * 2));
- dprintf(s->avctx, "end skip: %i\n", skip);
+ av_dlog(s->avctx, "end skip: %i\n", skip);
}
}
- dprintf(s->avctx, "BITSTREAM: frame header length was %i\n",
+ av_dlog(s->avctx, "BITSTREAM: frame header length was %i\n",
get_bits_count(gb) - s->frame_offset);
/** reset subframe states */
@@ -1368,16 +1378,22 @@ static int decode_frame(WMAProDecodeCtx *s)
} else
s->samples += s->num_channels * s->samples_per_frame;
- if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
- /** FIXME: not sure if this is always an error */
- av_log(s->avctx, AV_LOG_ERROR, "frame[%i] would have to skip %i bits\n",
- s->frame_num, len - (get_bits_count(gb) - s->frame_offset) - 1);
- s->packet_loss = 1;
- return 0;
- }
+ if (s->len_prefix) {
+ if (len != (get_bits_count(gb) - s->frame_offset) + 2) {
+ /** FIXME: not sure if this is always an error */
+ av_log(s->avctx, AV_LOG_ERROR,
+ "frame[%i] would have to skip %i bits\n", s->frame_num,
+ len - (get_bits_count(gb) - s->frame_offset) - 1);
+ s->packet_loss = 1;
+ return 0;
+ }
- /** skip the rest of the frame data */
- skip_bits_long(gb, len - (get_bits_count(gb) - s->frame_offset) - 1);
+ /** skip the rest of the frame data */
+ skip_bits_long(gb, len - (get_bits_count(gb) - s->frame_offset) - 1);
+ } else {
+ while (get_bits_count(gb) < s->num_saved_bits && get_bits1(gb) == 0) {
+ }
+ }
/** decode trailer bit */
more_frames = get_bits1(gb);
@@ -1473,13 +1489,14 @@ static int decode_packet(AVCodecContext *avctx,
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
- s->buf_bit_size = buf_size << 3;
/** sanity check for the buffer length */
if (buf_size < avctx->block_align)
return 0;
+ s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
+ s->buf_bit_size = buf_size << 3;
/** parse packet header */
init_get_bits(gb, buf, s->buf_bit_size);
@@ -1488,7 +1505,7 @@ static int decode_packet(AVCodecContext *avctx,
/** get number of bits that need to be added to the previous frame */
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
- dprintf(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number,
+ av_dlog(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number,
num_bits_prev_frame);
/** check for packet loss */
@@ -1501,32 +1518,54 @@ static int decode_packet(AVCodecContext *avctx,
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
+ int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
+ if (num_bits_prev_frame >= remaining_packet_bits) {
+ num_bits_prev_frame = remaining_packet_bits;
+ s->packet_done = 1;
+ }
+
/** append the previous frame data to the remaining data from the
previous packet to create a full frame */
save_bits(s, gb, num_bits_prev_frame, 1);
- dprintf(avctx, "accumulated %x bits of frame data\n",
+ av_dlog(avctx, "accumulated %x bits of frame data\n",
s->num_saved_bits - s->frame_offset);
/** decode the cross packet frame if it is valid */
if (!s->packet_loss)
decode_frame(s);
} else if (s->num_saved_bits - s->frame_offset) {
- dprintf(avctx, "ignoring %x previously saved bits\n",
+ av_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
}
- s->packet_loss = 0;
+ if (s->packet_loss) {
+ /** reset number of saved bits so that the decoder
+ does not start to decode incomplete frames in the
+ s->len_prefix == 0 case */
+ s->num_saved_bits = 0;
+ s->packet_loss = 0;
+ }
} else {
int frame_size;
- s->buf_bit_size = avpkt->size << 3;
+ s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
- if (remaining_bits(s, gb) > s->log2_frame_size &&
+ if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
s->packet_done = !decode_frame(s);
+ } else if (!s->len_prefix
+ && s->num_saved_bits > get_bits_count(&s->gb)) {
+ /** when the frames do not have a length prefix, we don't know
+ the compressed length of the individual frames
+ however, we know what part of a new packet belongs to the
+ previous frame
+ therefore we save the incoming packet first, then we append
+ the "previous frame" data from the next packet so that
+ we get a buffer that only contains full frames */
+ s->packet_done = !decode_frame(s);
} else
s->packet_done = 1;
}
@@ -1564,7 +1603,7 @@ static void flush(AVCodecContext *avctx)
/**
*@brief wmapro decoder
*/
-AVCodec wmapro_decoder = {
+AVCodec ff_wmapro_decoder = {
"wmapro",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_WMAPRO,
diff --git a/lib/ffmpeg/libavcodec/wmavoice.c b/lib/ffmpeg/libavcodec/wmavoice.c
index 2a58014da3..13011ec234 100644
--- a/lib/ffmpeg/libavcodec/wmavoice.c
+++ b/lib/ffmpeg/libavcodec/wmavoice.c
@@ -256,7 +256,7 @@ typedef struct {
/**
* @}
* @defgroup post_filter Postfilter values
- * Varibales used for postfilter implementation, mostly history for
+ * Variables used for postfilter implementation, mostly history for
* smoothing and so on, and context variables for FFT/iFFT.
* @{
*/
@@ -425,7 +425,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx)
2 * (s->block_conv_table[1] - 2 * s->min_pitch_val);
s->block_pitch_nbits = av_ceil_log2(s->block_pitch_range);
- ctx->sample_fmt = SAMPLE_FMT_FLT;
+ ctx->sample_fmt = AV_SAMPLE_FMT_FLT;
return 0;
}
@@ -582,14 +582,14 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs,
(5.0 / 14.7));
angle_mul = gain_mul * (8.0 * M_LN10 / M_PI);
for (n = 0; n <= 64; n++) {
- float pow;
+ float pwr;
idx = FFMAX(0, lrint((max - lpcs[n]) * irange) - 1);
- pow = wmavoice_denoise_power_table[s->denoise_strength][idx];
- lpcs[n] = angle_mul * pow;
+ pwr = wmavoice_denoise_power_table[s->denoise_strength][idx];
+ lpcs[n] = angle_mul * pwr;
/* 70.57 =~ 1/log10(1.0331663) */
- idx = (pow * gain_mul - 0.0295) * 70.570526123;
+ idx = (pwr * gain_mul - 0.0295) * 70.570526123;
if (idx > 127) { // fallback if index falls outside table range
coeffs[n] = wmavoice_energy_table[127] *
powf(1.0331663, idx - 127);
@@ -1033,7 +1033,8 @@ static void aw_parse_coords(WMAVoiceContext *s, GetBitContext *gb,
static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb,
int block_idx, AMRFixed *fcb)
{
- uint16_t use_mask[7]; // only 5 are used, rest is padding
+ uint16_t use_mask_mem[9]; // only 5 are used, rest is padding
+ uint16_t *use_mask = use_mask_mem + 2;
/* in this function, idx is the index in the 80-bit (+ padding) use_mask
* bit-array. Since use_mask consists of 16-bit values, the lower 4 bits
* of idx are the position of the bit within a particular item in the
@@ -1065,6 +1066,7 @@ static void aw_pulse_set2(WMAVoiceContext *s, GetBitContext *gb,
/* aw_pulse_set1() already applies pulses around pulse_off (to be exactly,
* in the range of [pulse_off, pulse_off + s->aw_pulse_range], and thus
* we exclude that range from being pulsed again in this function. */
+ memset(&use_mask[-2], 0, 2 * sizeof(use_mask[0]));
memset( use_mask, -1, 5 * sizeof(use_mask[0]));
memset(&use_mask[5], 0, 2 * sizeof(use_mask[0]));
if (s->aw_n_pulses[block_idx] > 0)
@@ -2016,7 +2018,7 @@ static av_cold void wmavoice_flush(AVCodecContext *ctx)
}
}
-AVCodec wmavoice_decoder = {
+AVCodec ff_wmavoice_decoder = {
"wmavoice",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_WMAVOICE,
diff --git a/lib/ffmpeg/libavcodec/wmv2.c b/lib/ffmpeg/libavcodec/wmv2.c
index e872b44f93..32aaa8f6df 100644
--- a/lib/ffmpeg/libavcodec/wmv2.c
+++ b/lib/ffmpeg/libavcodec/wmv2.c
@@ -102,7 +102,7 @@ void ff_mspel_motion(MpegEncContext *s,
if(s->flags&CODEC_FLAG_EMU_EDGE){
if(src_x<1 || src_y<1 || src_x + 17 >= s->h_edge_pos
|| src_y + h+1 >= v_edge_pos){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr - 1 - s->linesize, s->linesize, 19, 19,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr - 1 - s->linesize, s->linesize, 19, 19,
src_x-1, src_y-1, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer + 1 + s->linesize;
emu=1;
@@ -143,7 +143,7 @@ void ff_mspel_motion(MpegEncContext *s,
offset = (src_y * uvlinesize) + src_x;
ptr = ref_picture[1] + offset;
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
@@ -151,7 +151,7 @@ void ff_mspel_motion(MpegEncContext *s,
ptr = ref_picture[2] + offset;
if(emu){
- ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
+ s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
diff --git a/lib/ffmpeg/libavcodec/wmv2dec.c b/lib/ffmpeg/libavcodec/wmv2dec.c
index c83f898d7f..768b819479 100644
--- a/lib/ffmpeg/libavcodec/wmv2dec.c
+++ b/lib/ffmpeg/libavcodec/wmv2dec.c
@@ -87,7 +87,7 @@ static int decode_ext_header(Wmv2Context *w){
if(s->avctx->extradata_size<4) return -1;
- init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
+ init_get_bits(&gb, s->avctx->extradata, 32);
fps = get_bits(&gb, 5);
s->bit_rate = get_bits(&gb, 11)*1024;
@@ -484,7 +484,7 @@ static av_cold int wmv2_decode_end(AVCodecContext *avctx)
return ff_h263_decode_end(avctx);
}
-AVCodec wmv2_decoder = {
+AVCodec ff_wmv2_decoder = {
"wmv2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WMV2,
diff --git a/lib/ffmpeg/libavcodec/wmv2enc.c b/lib/ffmpeg/libavcodec/wmv2enc.c
index 7416f85233..f2ab55b7fb 100644
--- a/lib/ffmpeg/libavcodec/wmv2enc.c
+++ b/lib/ffmpeg/libavcodec/wmv2enc.c
@@ -211,7 +211,7 @@ void ff_wmv2_encode_mb(MpegEncContext * s,
}
}
-AVCodec wmv2_encoder = {
+AVCodec ff_wmv2_encoder = {
"wmv2",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WMV2,
diff --git a/lib/ffmpeg/libavcodec/wnv1.c b/lib/ffmpeg/libavcodec/wnv1.c
index 56634d10ac..2f96039053 100644
--- a/lib/ffmpeg/libavcodec/wnv1.c
+++ b/lib/ffmpeg/libavcodec/wnv1.c
@@ -154,7 +154,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec wnv1_decoder = {
+AVCodec ff_wnv1_decoder = {
"wnv1",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_WNV1,
diff --git a/lib/ffmpeg/libavcodec/ws-snd1.c b/lib/ffmpeg/libavcodec/ws-snd1.c
index a383673db7..d6a60d441f 100644
--- a/lib/ffmpeg/libavcodec/ws-snd1.c
+++ b/lib/ffmpeg/libavcodec/ws-snd1.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdint.h>
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
@@ -31,8 +32,8 @@
* http://www.multimedia.cx
*/
-static const char ws_adpcm_2bit[] = { -2, -1, 0, 1};
-static const char ws_adpcm_4bit[] = {
+static const int8_t ws_adpcm_2bit[] = { -2, -1, 0, 1};
+static const int8_t ws_adpcm_4bit[] = {
-9, -8, -6, -5, -4, -3, -2, -1,
0, 1, 2, 3, 4, 5, 6, 8 };
@@ -42,7 +43,7 @@ static av_cold int ws_snd_decode_init(AVCodecContext * avctx)
{
// WSSNDContext *c = avctx->priv_data;
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -120,7 +121,7 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
break;
case 2: /* no compression */
if (count & 0x20) { /* big delta */
- char t;
+ int8_t t;
t = count;
t <<= 3;
sample += t >> 3;
@@ -145,7 +146,7 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
return buf_size;
}
-AVCodec ws_snd1_decoder = {
+AVCodec ff_ws_snd1_decoder = {
"ws_snd1",
AVMEDIA_TYPE_AUDIO,
CODEC_ID_WESTWOOD_SND1,
diff --git a/lib/ffmpeg/libavcodec/x86/Makefile b/lib/ffmpeg/libavcodec/x86/Makefile
index 6d1a9c6064..83cec00442 100644
--- a/lib/ffmpeg/libavcodec/x86/Makefile
+++ b/lib/ffmpeg/libavcodec/x86/Makefile
@@ -6,10 +6,14 @@ YASM-OBJS-FFT-$(HAVE_AMD3DNOWEXT) += x86/fft_3dn2.o
YASM-OBJS-FFT-$(HAVE_SSE) += x86/fft_sse.o
YASM-OBJS-$(CONFIG_FFT) += x86/fft_mmx.o \
$(YASM-OBJS-FFT-yes)
-YASM-OBJS-$(CONFIG_GPL) += x86/h264_deblock_sse2.o \
- x86/h264_idct_sse2.o \
-YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_intrapred.o \
+MMX-OBJS-$(CONFIG_H264DSP) += x86/h264dsp_mmx.o
+YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_deblock.o \
+ x86/h264_weight.o \
+ x86/h264_idct.o \
+
+YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o
+MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_yasm.o
@@ -20,29 +24,31 @@ 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
+YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o
MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o
MMX-OBJS-$(CONFIG_LPC) += x86/lpc_mmx.o
MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp_mmx.o
MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o
-MMX-OBJS-$(CONFIG_VP3_DECODER) += x86/vp3dsp_mmx.o \
- x86/vp3dsp_sse2.o
-MMX-OBJS-$(CONFIG_VP5_DECODER) += x86/vp3dsp_mmx.o \
- x86/vp3dsp_sse2.o
-MMX-OBJS-$(CONFIG_VP6_DECODER) += x86/vp3dsp_mmx.o \
- x86/vp3dsp_sse2.o \
- x86/vp6dsp_mmx.o \
- x86/vp6dsp_sse2.o
+YASM-OBJS-$(CONFIG_VP3_DECODER) += x86/vp3dsp.o
+YASM-OBJS-$(CONFIG_VP5_DECODER) += x86/vp3dsp.o
+MMX-OBJS-$(CONFIG_VP5_DECODER) += x86/vp56dsp_init.o
+YASM-OBJS-$(CONFIG_VP6_DECODER) += x86/vp3dsp.o \
+ x86/vp56dsp.o
+MMX-OBJS-$(CONFIG_VP6_DECODER) += x86/vp56dsp_init.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 \
+ x86/deinterlace.o \
+ x86/fmtconvert.o \
+ x86/h264_chromamc.o \
$(YASM-OBJS-yes)
MMX-OBJS-$(CONFIG_FFT) += x86/fft.o
-OBJS-$(HAVE_MMX) += x86/cpuid.o \
- x86/dnxhd_mmx.o \
+OBJS-$(HAVE_MMX) += x86/dnxhd_mmx.o \
x86/dsputil_mmx.o \
x86/fdct_mmx.o \
+ x86/fmtconvert_mmx.o \
x86/idct_mmx_xvid.o \
x86/idct_sse2_xvid.o \
x86/motion_est_mmx.o \
diff --git a/lib/ffmpeg/libavcodec/x86/cavsdsp_mmx.c b/lib/ffmpeg/libavcodec/x86/cavsdsp_mmx.c
index e8c7065fd7..0f5fdaa53d 100644
--- a/lib/ffmpeg/libavcodec/x86/cavsdsp_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/cavsdsp_mmx.c
@@ -23,8 +23,10 @@
*/
#include "libavutil/common.h"
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h"
+#include "libavcodec/cavsdsp.h"
#include "dsputil_mmx.h"
/*****************************************************************************
@@ -172,7 +174,7 @@ static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
);
}
- add_pixels_clamped_mmx(b2, dst, stride);
+ ff_add_pixels_clamped_mmx(b2, dst, stride);
}
/*****************************************************************************
@@ -437,7 +439,7 @@ CAVS_MC(put_, 16,mmx2)
CAVS_MC(avg_, 8, mmx2)
CAVS_MC(avg_, 16,mmx2)
-void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) {
+static void ff_cavsdsp_init_mmx2(CAVSDSPContext* c, AVCodecContext *avctx) {
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \
@@ -453,7 +455,7 @@ void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) {
c->cavs_idct8_add = cavs_idct8_add_mmx;
}
-void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) {
+static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) {
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \
@@ -468,3 +470,11 @@ void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) {
#undef dspfunc
c->cavs_idct8_add = cavs_idct8_add_mmx;
}
+
+void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx)
+{
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & AV_CPU_FLAG_MMX2) ff_cavsdsp_init_mmx2 (c, avctx);
+ if (mm_flags & AV_CPU_FLAG_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
+}
diff --git a/lib/ffmpeg/libavcodec/x86/cpuid.c b/lib/ffmpeg/libavcodec/x86/cpuid.c
deleted file mode 100644
index 1ed4d2e7e3..0000000000
--- a/lib/ffmpeg/libavcodec/x86/cpuid.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * CPU detection code, extracted from mmx.h
- * (c)1997-99 by H. Dietz and R. Fisher
- * Converted to C and improved by Fabrice Bellard.
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdlib.h>
-#include "libavutil/x86_cpu.h"
-#include "libavcodec/dsputil.h"
-
-#undef printf
-
-/* ebx saving is necessary for PIC. gcc seems unable to see it alone */
-#define cpuid(index,eax,ebx,ecx,edx)\
- __asm__ volatile\
- ("mov %%"REG_b", %%"REG_S"\n\t"\
- "cpuid\n\t"\
- "xchg %%"REG_b", %%"REG_S\
- : "=a" (eax), "=S" (ebx),\
- "=c" (ecx), "=d" (edx)\
- : "0" (index));
-
-/* Function to test if multimedia instructions are supported... */
-int mm_support(void)
-{
- int rval = 0;
- int eax, ebx, ecx, edx;
- int max_std_level, max_ext_level, std_caps=0, ext_caps=0;
-
-#if ARCH_X86_32
- x86_reg a, c;
- __asm__ volatile (
- /* See if CPUID instruction is supported ... */
- /* ... Get copies of EFLAGS into eax and ecx */
- "pushfl\n\t"
- "pop %0\n\t"
- "mov %0, %1\n\t"
-
- /* ... Toggle the ID bit in one copy and store */
- /* to the EFLAGS reg */
- "xor $0x200000, %0\n\t"
- "push %0\n\t"
- "popfl\n\t"
-
- /* ... Get the (hopefully modified) EFLAGS */
- "pushfl\n\t"
- "pop %0\n\t"
- : "=a" (a), "=c" (c)
- :
- : "cc"
- );
-
- if (a == c)
- return 0; /* CPUID not supported */
-#endif
-
- cpuid(0, max_std_level, ebx, ecx, edx);
-
- if(max_std_level >= 1){
- cpuid(1, eax, ebx, ecx, std_caps);
- if (std_caps & (1<<23))
- rval |= FF_MM_MMX;
- if (std_caps & (1<<25))
- rval |= FF_MM_MMX2
-#if HAVE_SSE
- | FF_MM_SSE;
- if (std_caps & (1<<26))
- rval |= FF_MM_SSE2;
- if (ecx & 1)
- rval |= FF_MM_SSE3;
- if (ecx & 0x00000200 )
- rval |= FF_MM_SSSE3;
- if (ecx & 0x00080000 )
- rval |= FF_MM_SSE4;
- if (ecx & 0x00100000 )
- rval |= FF_MM_SSE42;
-#endif
- ;
- }
-
- cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
-
- if(max_ext_level >= 0x80000001){
- cpuid(0x80000001, eax, ebx, ecx, ext_caps);
- if (ext_caps & (1<<31))
- rval |= FF_MM_3DNOW;
- if (ext_caps & (1<<30))
- rval |= FF_MM_3DNOWEXT;
- if (ext_caps & (1<<23))
- rval |= FF_MM_MMX;
- if (ext_caps & (1<<22))
- rval |= FF_MM_MMX2;
- }
-
-#if 0
- av_log(NULL, AV_LOG_DEBUG, "%s%s%s%s%s%s%s%s%s%s\n",
- (rval&FF_MM_MMX) ? "MMX ":"",
- (rval&FF_MM_MMX2) ? "MMX2 ":"",
- (rval&FF_MM_SSE) ? "SSE ":"",
- (rval&FF_MM_SSE2) ? "SSE2 ":"",
- (rval&FF_MM_SSE3) ? "SSE3 ":"",
- (rval&FF_MM_SSSE3) ? "SSSE3 ":"",
- (rval&FF_MM_SSE4) ? "SSE4.1 ":"",
- (rval&FF_MM_SSE42) ? "SSE4.2 ":"",
- (rval&FF_MM_3DNOW) ? "3DNow ":"",
- (rval&FF_MM_3DNOWEXT) ? "3DNowExt ":"");
-#endif
- return rval;
-}
-
-#ifdef TEST
-int main ( void )
-{
- int mm_flags;
- mm_flags = mm_support();
- printf("mm_support = 0x%08X\n",mm_flags);
- return 0;
-}
-#endif
diff --git a/lib/ffmpeg/libavcodec/x86/dct32_sse.c b/lib/ffmpeg/libavcodec/x86/dct32_sse.c
index 216a5efb6e..74338d6920 100644
--- a/lib/ffmpeg/libavcodec/x86/dct32_sse.c
+++ b/lib/ffmpeg/libavcodec/x86/dct32_sse.c
@@ -288,7 +288,9 @@ void ff_dct32_float_sse(FFTSample *out, const FFTSample *in)
"movss %%xmm2, 116(%1) \n\t"
:"+&r"(tmp1)
:"r"(out), "r"(b1), "r"(smask), "r"(in)
- :"memory"
+ :XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
+ "memory"
);
}
diff --git a/lib/ffmpeg/libavcodec/x86/deinterlace.asm b/lib/ffmpeg/libavcodec/x86/deinterlace.asm
new file mode 100644
index 0000000000..76a096eff3
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/deinterlace.asm
@@ -0,0 +1,83 @@
+;******************************************************************************
+;* MMX optimized deinterlacing functions
+;* Copyright (c) 2010 Vitor Sessak
+;* Copyright (c) 2002 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
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+SECTION_RODATA
+
+cextern pw_4
+
+SECTION .text
+
+%macro DEINTERLACE 1
+%ifidn %1, inplace
+;void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
+cglobal deinterlace_line_inplace_mmx, 6,6,7, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
+%else
+;void ff_deinterlace_line_mmx(uint8_t *dst, const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
+cglobal deinterlace_line_mmx, 7,7,7, dst, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
+%endif
+ pxor mm7, mm7
+ movq mm6, [pw_4]
+.nextrow
+ movd mm0, [lum_m4q]
+ movd mm1, [lum_m3q]
+ movd mm2, [lum_m2q]
+%ifidn %1, inplace
+ movd [lum_m4q], mm2
+%endif
+ movd mm3, [lum_m1q]
+ movd mm4, [lumq]
+ punpcklbw mm0, mm7
+ punpcklbw mm1, mm7
+ punpcklbw mm2, mm7
+ punpcklbw mm3, mm7
+ punpcklbw mm4, mm7
+ paddw mm1, mm3
+ psllw mm2, 1
+ paddw mm0, mm4
+ psllw mm1, 2
+ paddw mm2, mm6
+ paddw mm1, mm2
+ psubusw mm1, mm0
+ psrlw mm1, 3
+ packuswb mm1, mm7
+%ifidn %1, inplace
+ movd [lum_m2q], mm1
+%else
+ movd [dstq], mm1
+ add dstq, 4
+%endif
+ add lum_m4q, 4
+ add lum_m3q, 4
+ add lum_m2q, 4
+ add lum_m1q, 4
+ add lumq, 4
+ sub sized, 4
+ jg .nextrow
+ REP_RET
+%endmacro
+
+DEINTERLACE ""
+
+DEINTERLACE inplace
diff --git a/lib/ffmpeg/libavcodec/x86/dnxhd_mmx.c b/lib/ffmpeg/libavcodec/x86/dnxhd_mmx.c
index 59bcb3929b..1256beef7f 100644
--- a/lib/ffmpeg/libavcodec/x86/dnxhd_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/dnxhd_mmx.c
@@ -27,16 +27,16 @@
static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int line_size)
{
__asm__ volatile(
- "pxor %%xmm7, %%xmm7 \n\t"
+ "pxor %%xmm5, %%xmm5 \n\t"
"movq (%0), %%xmm0 \n\t"
"add %2, %0 \n\t"
"movq (%0), %%xmm1 \n\t"
"movq (%0, %2), %%xmm2 \n\t"
"movq (%0, %2,2), %%xmm3 \n\t"
- "punpcklbw %%xmm7, %%xmm0 \n\t"
- "punpcklbw %%xmm7, %%xmm1 \n\t"
- "punpcklbw %%xmm7, %%xmm2 \n\t"
- "punpcklbw %%xmm7, %%xmm3 \n\t"
+ "punpcklbw %%xmm5, %%xmm0 \n\t"
+ "punpcklbw %%xmm5, %%xmm1 \n\t"
+ "punpcklbw %%xmm5, %%xmm2 \n\t"
+ "punpcklbw %%xmm5, %%xmm3 \n\t"
"movdqa %%xmm0, (%1) \n\t"
"movdqa %%xmm1, 16(%1) \n\t"
"movdqa %%xmm2, 32(%1) \n\t"
@@ -52,7 +52,7 @@ static void get_pixels_8x4_sym_sse2(DCTELEM *block, const uint8_t *pixels, int l
void ff_dnxhd_init_mmx(DNXHDEncContext *ctx)
{
- if (mm_flags & FF_MM_SSE2) {
+ if (av_get_cpu_flags() & AV_CPU_FLAG_SSE2) {
ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
}
}
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_h264_template_mmx.c b/lib/ffmpeg/libavcodec/x86/dsputil_h264_template_mmx.c
deleted file mode 100644
index bc2379e1d0..0000000000
--- a/lib/ffmpeg/libavcodec/x86/dsputil_h264_template_mmx.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>,
- * 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
- */
-
-/**
- * MMX optimized version of (put|avg)_h264_chroma_mc8.
- * H264_CHROMA_MC8_TMPL must be defined to the desired function name
- * H264_CHROMA_OP must be defined to empty for put and pavgb/pavgusb for avg
- * H264_CHROMA_MC8_MV0 must be defined to a (put|avg)_pixels8 function
- */
-static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y, const uint64_t *rnd_reg)
-{
- DECLARE_ALIGNED(8, uint64_t, AA);
- DECLARE_ALIGNED(8, uint64_t, DD);
- int i;
-
- if(y==0 && x==0) {
- /* no filter needed */
- H264_CHROMA_MC8_MV0(dst, src, stride, h);
- return;
- }
-
- assert(x<8 && y<8 && x>=0 && y>=0);
-
- if(y==0 || x==0)
- {
- /* 1 dimensional filter only */
- const int dxy = x ? 1 : stride;
-
- __asm__ volatile(
- "movd %0, %%mm5\n\t"
- "movq %1, %%mm4\n\t"
- "movq %2, %%mm6\n\t" /* mm6 = rnd >> 3 */
- "punpcklwd %%mm5, %%mm5\n\t"
- "punpckldq %%mm5, %%mm5\n\t" /* mm5 = B = x */
- "pxor %%mm7, %%mm7\n\t"
- "psubw %%mm5, %%mm4\n\t" /* mm4 = A = 8-x */
- :: "rm"(x+y), "m"(ff_pw_8), "m"(*(rnd_reg+1)));
-
- for(i=0; i<h; i++) {
- __asm__ volatile(
- /* mm0 = src[0..7], mm1 = src[1..8] */
- "movq %0, %%mm0\n\t"
- "movq %1, %%mm2\n\t"
- :: "m"(src[0]), "m"(src[dxy]));
-
- __asm__ volatile(
- /* [mm0,mm1] = A * src[0..7] */
- /* [mm2,mm3] = B * src[1..8] */
- "movq %%mm0, %%mm1\n\t"
- "movq %%mm2, %%mm3\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "punpckhbw %%mm7, %%mm1\n\t"
- "punpcklbw %%mm7, %%mm2\n\t"
- "punpckhbw %%mm7, %%mm3\n\t"
- "pmullw %%mm4, %%mm0\n\t"
- "pmullw %%mm4, %%mm1\n\t"
- "pmullw %%mm5, %%mm2\n\t"
- "pmullw %%mm5, %%mm3\n\t"
-
- /* dst[0..7] = (A * src[0..7] + B * src[1..8] + (rnd >> 3)) >> 3 */
- "paddw %%mm6, %%mm0\n\t"
- "paddw %%mm6, %%mm1\n\t"
- "paddw %%mm2, %%mm0\n\t"
- "paddw %%mm3, %%mm1\n\t"
- "psrlw $3, %%mm0\n\t"
- "psrlw $3, %%mm1\n\t"
- "packuswb %%mm1, %%mm0\n\t"
- H264_CHROMA_OP(%0, %%mm0)
- "movq %%mm0, %0\n\t"
- : "=m" (dst[0]));
-
- src += stride;
- dst += stride;
- }
- return;
- }
-
- /* general case, bilinear */
- __asm__ volatile("movd %2, %%mm4\n\t"
- "movd %3, %%mm6\n\t"
- "punpcklwd %%mm4, %%mm4\n\t"
- "punpcklwd %%mm6, %%mm6\n\t"
- "punpckldq %%mm4, %%mm4\n\t" /* mm4 = x words */
- "punpckldq %%mm6, %%mm6\n\t" /* mm6 = y words */
- "movq %%mm4, %%mm5\n\t"
- "pmullw %%mm6, %%mm4\n\t" /* mm4 = x * y */
- "psllw $3, %%mm5\n\t"
- "psllw $3, %%mm6\n\t"
- "movq %%mm5, %%mm7\n\t"
- "paddw %%mm6, %%mm7\n\t"
- "movq %%mm4, %1\n\t" /* DD = x * y */
- "psubw %%mm4, %%mm5\n\t" /* mm5 = B = 8x - xy */
- "psubw %%mm4, %%mm6\n\t" /* mm6 = C = 8y - xy */
- "paddw %4, %%mm4\n\t"
- "psubw %%mm7, %%mm4\n\t" /* mm4 = A = xy - (8x+8y) + 64 */
- "pxor %%mm7, %%mm7\n\t"
- "movq %%mm4, %0\n\t"
- : "=m" (AA), "=m" (DD) : "rm" (x), "rm" (y), "m" (ff_pw_64));
-
- __asm__ volatile(
- /* mm0 = src[0..7], mm1 = src[1..8] */
- "movq %0, %%mm0\n\t"
- "movq %1, %%mm1\n\t"
- : : "m" (src[0]), "m" (src[1]));
-
- for(i=0; i<h; i++) {
- src += stride;
-
- __asm__ volatile(
- /* mm2 = A * src[0..3] + B * src[1..4] */
- /* mm3 = A * src[4..7] + B * src[5..8] */
- "movq %%mm0, %%mm2\n\t"
- "movq %%mm1, %%mm3\n\t"
- "punpckhbw %%mm7, %%mm0\n\t"
- "punpcklbw %%mm7, %%mm1\n\t"
- "punpcklbw %%mm7, %%mm2\n\t"
- "punpckhbw %%mm7, %%mm3\n\t"
- "pmullw %0, %%mm0\n\t"
- "pmullw %0, %%mm2\n\t"
- "pmullw %%mm5, %%mm1\n\t"
- "pmullw %%mm5, %%mm3\n\t"
- "paddw %%mm1, %%mm2\n\t"
- "paddw %%mm0, %%mm3\n\t"
- : : "m" (AA));
-
- __asm__ volatile(
- /* [mm2,mm3] += C * src[0..7] */
- "movq %0, %%mm0\n\t"
- "movq %%mm0, %%mm1\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "punpckhbw %%mm7, %%mm1\n\t"
- "pmullw %%mm6, %%mm0\n\t"
- "pmullw %%mm6, %%mm1\n\t"
- "paddw %%mm0, %%mm2\n\t"
- "paddw %%mm1, %%mm3\n\t"
- : : "m" (src[0]));
-
- __asm__ volatile(
- /* [mm2,mm3] += D * src[1..8] */
- "movq %1, %%mm1\n\t"
- "movq %%mm1, %%mm0\n\t"
- "movq %%mm1, %%mm4\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "punpckhbw %%mm7, %%mm4\n\t"
- "pmullw %2, %%mm0\n\t"
- "pmullw %2, %%mm4\n\t"
- "paddw %%mm0, %%mm2\n\t"
- "paddw %%mm4, %%mm3\n\t"
- "movq %0, %%mm0\n\t"
- : : "m" (src[0]), "m" (src[1]), "m" (DD));
-
- __asm__ volatile(
- /* dst[0..7] = ([mm2,mm3] + rnd) >> 6 */
- "paddw %1, %%mm2\n\t"
- "paddw %1, %%mm3\n\t"
- "psrlw $6, %%mm2\n\t"
- "psrlw $6, %%mm3\n\t"
- "packuswb %%mm3, %%mm2\n\t"
- H264_CHROMA_OP(%0, %%mm2)
- "movq %%mm2, %0\n\t"
- : "=m" (dst[0]) : "m" (*rnd_reg));
- dst+= stride;
- }
-}
-
-static void H264_CHROMA_MC4_TMPL(uint8_t *dst/*align 4*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y, const uint64_t *rnd_reg)
-{
- __asm__ volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movd %5, %%mm2 \n\t"
- "movd %6, %%mm3 \n\t"
- "movq "MANGLE(ff_pw_8)", %%mm4\n\t"
- "movq "MANGLE(ff_pw_8)", %%mm5\n\t"
- "punpcklwd %%mm2, %%mm2 \n\t"
- "punpcklwd %%mm3, %%mm3 \n\t"
- "punpcklwd %%mm2, %%mm2 \n\t"
- "punpcklwd %%mm3, %%mm3 \n\t"
- "psubw %%mm2, %%mm4 \n\t"
- "psubw %%mm3, %%mm5 \n\t"
-
- "movd (%1), %%mm0 \n\t"
- "movd 1(%1), %%mm6 \n\t"
- "add %3, %1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm6 \n\t"
- "pmullw %%mm4, %%mm0 \n\t"
- "pmullw %%mm2, %%mm6 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
-
- "1: \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 1(%1), %%mm1 \n\t"
- "add %3, %1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "pmullw %%mm4, %%mm0 \n\t"
- "pmullw %%mm2, %%mm1 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "movq %%mm1, %%mm0 \n\t"
- "pmullw %%mm5, %%mm6 \n\t"
- "pmullw %%mm3, %%mm1 \n\t"
- "paddw %4, %%mm6 \n\t"
- "paddw %%mm6, %%mm1 \n\t"
- "psrlw $6, %%mm1 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- H264_CHROMA_OP4((%0), %%mm1, %%mm6)
- "movd %%mm1, (%0) \n\t"
- "add %3, %0 \n\t"
- "movd (%1), %%mm6 \n\t"
- "movd 1(%1), %%mm1 \n\t"
- "add %3, %1 \n\t"
- "punpcklbw %%mm7, %%mm6 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "pmullw %%mm4, %%mm6 \n\t"
- "pmullw %%mm2, %%mm1 \n\t"
- "paddw %%mm6, %%mm1 \n\t"
- "movq %%mm1, %%mm6 \n\t"
- "pmullw %%mm5, %%mm0 \n\t"
- "pmullw %%mm3, %%mm1 \n\t"
- "paddw %4, %%mm0 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "psrlw $6, %%mm1 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- H264_CHROMA_OP4((%0), %%mm1, %%mm0)
- "movd %%mm1, (%0) \n\t"
- "add %3, %0 \n\t"
- "sub $2, %2 \n\t"
- "jnz 1b \n\t"
- : "+r"(dst), "+r"(src), "+r"(h)
- : "r"((x86_reg)stride), "m"(*rnd_reg), "m"(x), "m"(y)
- );
-}
-
-#ifdef H264_CHROMA_MC2_TMPL
-static void H264_CHROMA_MC2_TMPL(uint8_t *dst/*align 2*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- int tmp = ((1<<16)-1)*x + 8;
- int CD= tmp*y;
- int AB= (tmp<<3) - CD;
- __asm__ volatile(
- /* mm5 = {A,B,A,B} */
- /* mm6 = {C,D,C,D} */
- "movd %0, %%mm5\n\t"
- "movd %1, %%mm6\n\t"
- "punpckldq %%mm5, %%mm5\n\t"
- "punpckldq %%mm6, %%mm6\n\t"
- "pxor %%mm7, %%mm7\n\t"
- /* mm0 = src[0,1,1,2] */
- "movd %2, %%mm2\n\t"
- "punpcklbw %%mm7, %%mm2\n\t"
- "pshufw $0x94, %%mm2, %%mm2\n\t"
- :: "r"(AB), "r"(CD), "m"(src[0]));
-
-
- __asm__ volatile(
- "1:\n\t"
- "add %4, %1\n\t"
- /* mm1 = A * src[0,1] + B * src[1,2] */
- "movq %%mm2, %%mm1\n\t"
- "pmaddwd %%mm5, %%mm1\n\t"
- /* mm0 = src[0,1,1,2] */
- "movd (%1), %%mm0\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "pshufw $0x94, %%mm0, %%mm0\n\t"
- /* mm1 += C * src[0,1] + D * src[1,2] */
- "movq %%mm0, %%mm2\n\t"
- "pmaddwd %%mm6, %%mm0\n\t"
- "paddw %3, %%mm1\n\t"
- "paddw %%mm0, %%mm1\n\t"
- /* dst[0,1] = pack((mm1 + 32) >> 6) */
- "psrlw $6, %%mm1\n\t"
- "packssdw %%mm7, %%mm1\n\t"
- "packuswb %%mm7, %%mm1\n\t"
- H264_CHROMA_OP4((%0), %%mm1, %%mm3)
- "movd %%mm1, %%esi\n\t"
- "movw %%si, (%0)\n\t"
- "add %4, %0\n\t"
- "sub $1, %2\n\t"
- "jnz 1b\n\t"
- : "+r" (dst), "+r"(src), "+r"(h)
- : "m" (ff_pw_32), "r"((x86_reg)stride)
- : "%esi");
-
-}
-#endif
-
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c b/lib/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c
deleted file mode 100644
index 0eceb74f23..0000000000
--- a/lib/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2008 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
- */
-
-/**
- * SSSE3 optimized version of (put|avg)_h264_chroma_mc8.
- * H264_CHROMA_MC8_TMPL must be defined to the desired function name
- * H264_CHROMA_MC8_MV0 must be defined to a (put|avg)_pixels8 function
- * AVG_OP must be defined to empty for put and the identify for avg
- */
-static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y, int rnd)
-{
- if(y==0 && x==0) {
- /* no filter needed */
- H264_CHROMA_MC8_MV0(dst, src, stride, h);
- return;
- }
-
- assert(x<8 && y<8 && x>=0 && y>=0);
-
- if(y==0 || x==0)
- {
- /* 1 dimensional filter only */
- __asm__ volatile(
- "movd %0, %%xmm7 \n\t"
- "movq %1, %%xmm6 \n\t"
- "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.a:&ff_pw_3))
- );
-
- if(x) {
- __asm__ volatile(
- "1: \n\t"
- "movq (%1), %%xmm0 \n\t"
- "movq 1(%1), %%xmm1 \n\t"
- "movq (%1,%3), %%xmm2 \n\t"
- "movq 1(%1,%3), %%xmm3 \n\t"
- "punpcklbw %%xmm1, %%xmm0 \n\t"
- "punpcklbw %%xmm3, %%xmm2 \n\t"
- "pmaddubsw %%xmm7, %%xmm0 \n\t"
- "pmaddubsw %%xmm7, %%xmm2 \n\t"
- AVG_OP("movq (%0), %%xmm4 \n\t")
- AVG_OP("movhps (%0,%3), %%xmm4 \n\t")
- "paddw %%xmm6, %%xmm0 \n\t"
- "paddw %%xmm6, %%xmm2 \n\t"
- "psrlw $3, %%xmm0 \n\t"
- "psrlw $3, %%xmm2 \n\t"
- "packuswb %%xmm2, %%xmm0 \n\t"
- AVG_OP("pavgb %%xmm4, %%xmm0 \n\t")
- "movq %%xmm0, (%0) \n\t"
- "movhps %%xmm0, (%0,%3) \n\t"
- "sub $2, %2 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%0,%3,2), %0 \n\t"
- "jg 1b \n\t"
- :"+r"(dst), "+r"(src), "+r"(h)
- :"r"((x86_reg)stride)
- );
- } else {
- __asm__ volatile(
- "1: \n\t"
- "movq (%1), %%xmm0 \n\t"
- "movq (%1,%3), %%xmm1 \n\t"
- "movdqa %%xmm1, %%xmm2 \n\t"
- "movq (%1,%3,2), %%xmm3 \n\t"
- "punpcklbw %%xmm1, %%xmm0 \n\t"
- "punpcklbw %%xmm3, %%xmm2 \n\t"
- "pmaddubsw %%xmm7, %%xmm0 \n\t"
- "pmaddubsw %%xmm7, %%xmm2 \n\t"
- AVG_OP("movq (%0), %%xmm4 \n\t")
- AVG_OP("movhps (%0,%3), %%xmm4 \n\t")
- "paddw %%xmm6, %%xmm0 \n\t"
- "paddw %%xmm6, %%xmm2 \n\t"
- "psrlw $3, %%xmm0 \n\t"
- "psrlw $3, %%xmm2 \n\t"
- "packuswb %%xmm2, %%xmm0 \n\t"
- AVG_OP("pavgb %%xmm4, %%xmm0 \n\t")
- "movq %%xmm0, (%0) \n\t"
- "movhps %%xmm0, (%0,%3) \n\t"
- "sub $2, %2 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%0,%3,2), %0 \n\t"
- "jg 1b \n\t"
- :"+r"(dst), "+r"(src), "+r"(h)
- :"r"((x86_reg)stride)
- );
- }
- return;
- }
-
- /* general case, bilinear */
- __asm__ volatile(
- "movd %0, %%xmm7 \n\t"
- "movd %1, %%xmm6 \n\t"
- "movdqa %2, %%xmm5 \n\t"
- "pshuflw $0, %%xmm7, %%xmm7 \n\t"
- "pshuflw $0, %%xmm6, %%xmm6 \n\t"
- "movlhps %%xmm7, %%xmm7 \n\t"
- "movlhps %%xmm6, %%xmm6 \n\t"
- :: "r"((x*255+8)*(8-y)), "r"((x*255+8)*y), "m"(*(rnd?&ff_pw_32:&ff_pw_28))
- );
-
- __asm__ volatile(
- "movq (%1), %%xmm0 \n\t"
- "movq 1(%1), %%xmm1 \n\t"
- "punpcklbw %%xmm1, %%xmm0 \n\t"
- "add %3, %1 \n\t"
- "1: \n\t"
- "movq (%1), %%xmm1 \n\t"
- "movq 1(%1), %%xmm2 \n\t"
- "movq (%1,%3), %%xmm3 \n\t"
- "movq 1(%1,%3), %%xmm4 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "punpcklbw %%xmm2, %%xmm1 \n\t"
- "punpcklbw %%xmm4, %%xmm3 \n\t"
- "movdqa %%xmm1, %%xmm2 \n\t"
- "movdqa %%xmm3, %%xmm4 \n\t"
- "pmaddubsw %%xmm7, %%xmm0 \n\t"
- "pmaddubsw %%xmm6, %%xmm1 \n\t"
- "pmaddubsw %%xmm7, %%xmm2 \n\t"
- "pmaddubsw %%xmm6, %%xmm3 \n\t"
- "paddw %%xmm5, %%xmm0 \n\t"
- "paddw %%xmm5, %%xmm2 \n\t"
- "paddw %%xmm0, %%xmm1 \n\t"
- "paddw %%xmm2, %%xmm3 \n\t"
- "movdqa %%xmm4, %%xmm0 \n\t"
- "psrlw $6, %%xmm1 \n\t"
- "psrlw $6, %%xmm3 \n\t"
- AVG_OP("movq (%0), %%xmm2 \n\t")
- AVG_OP("movhps (%0,%3), %%xmm2 \n\t")
- "packuswb %%xmm3, %%xmm1 \n\t"
- AVG_OP("pavgb %%xmm2, %%xmm1 \n\t")
- "movq %%xmm1, (%0)\n\t"
- "movhps %%xmm1, (%0,%3)\n\t"
- "sub $2, %2 \n\t"
- "lea (%0,%3,2), %0 \n\t"
- "jg 1b \n\t"
- :"+r"(dst), "+r"(src), "+r"(h)
- :"r"((x86_reg)stride)
- );
-}
-
-static void H264_CHROMA_MC4_TMPL(uint8_t *dst/*align 4*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- __asm__ volatile(
- "movd %0, %%mm7 \n\t"
- "movd %1, %%mm6 \n\t"
- "movq %2, %%mm5 \n\t"
- "pshufw $0, %%mm7, %%mm7 \n\t"
- "pshufw $0, %%mm6, %%mm6 \n\t"
- :: "r"((x*255+8)*(8-y)), "r"((x*255+8)*y), "m"(ff_pw_32)
- );
-
- __asm__ volatile(
- "movd (%1), %%mm0 \n\t"
- "punpcklbw 1(%1), %%mm0 \n\t"
- "add %3, %1 \n\t"
- "1: \n\t"
- "movd (%1), %%mm1 \n\t"
- "movd (%1,%3), %%mm3 \n\t"
- "punpcklbw 1(%1), %%mm1 \n\t"
- "punpcklbw 1(%1,%3), %%mm3 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "movq %%mm1, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "pmaddubsw %%mm7, %%mm0 \n\t"
- "pmaddubsw %%mm6, %%mm1 \n\t"
- "pmaddubsw %%mm7, %%mm2 \n\t"
- "pmaddubsw %%mm6, %%mm3 \n\t"
- "paddw %%mm5, %%mm0 \n\t"
- "paddw %%mm5, %%mm2 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "paddw %%mm2, %%mm3 \n\t"
- "movq %%mm4, %%mm0 \n\t"
- "psrlw $6, %%mm1 \n\t"
- "psrlw $6, %%mm3 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- "packuswb %%mm3, %%mm3 \n\t"
- AVG_OP("pavgb (%0), %%mm1 \n\t")
- AVG_OP("pavgb (%0,%3), %%mm3 \n\t")
- "movd %%mm1, (%0)\n\t"
- "movd %%mm3, (%0,%3)\n\t"
- "sub $2, %2 \n\t"
- "lea (%0,%3,2), %0 \n\t"
- "jg 1b \n\t"
- :"+r"(dst), "+r"(src), "+r"(h)
- :"r"((x86_reg)stride)
- );
-}
-
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_mmx.c b/lib/ffmpeg/libavcodec/x86/dsputil_mmx.c
index c4202d53d7..39bf3f2936 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputil_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/dsputil_mmx.c
@@ -22,23 +22,19 @@
* MMX optimization by Nick Kurshev <nickols_k@mail.ru>
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/h264dsp.h"
#include "libavcodec/mpegvideo.h"
#include "libavcodec/simple_idct.h"
+#include "libavcodec/ac3dec.h"
#include "dsputil_mmx.h"
-#include "vp3dsp_mmx.h"
-#include "vp3dsp_sse2.h"
-#include "vp6dsp_mmx.h"
-#include "vp6dsp_sse2.h"
#include "idct_xvid.h"
//#undef NDEBUG
//#include <assert.h>
-int mm_flags; /* multimedia extension flags */
-
/* pixel operations */
DECLARE_ALIGNED(8, const uint64_t, ff_bone) = 0x0101010101010101ULL;
DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL;
@@ -46,22 +42,30 @@ DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL;
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_1 ) = 0x0001000100010001ULL;
+DECLARE_ALIGNED(16, const xmm_reg, ff_pw_3 ) = {0x0003000300030003ULL, 0x0003000300030003ULL};
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(16, const xmm_reg, ff_pw_9 ) = {0x0009000900090009ULL, 0x0009000900090009ULL};
DECLARE_ALIGNED(8, const uint64_t, ff_pw_15 ) = 0x000F000F000F000FULL;
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_16 ) = {0x0010001000100010ULL, 0x0010001000100010ULL};
+DECLARE_ALIGNED(16, const xmm_reg, ff_pw_17 ) = {0x0011001100110011ULL, 0x0011001100110011ULL};
+DECLARE_ALIGNED(16, const xmm_reg, ff_pw_18 ) = {0x0012001200120012ULL, 0x0012001200120012ULL};
DECLARE_ALIGNED(8, const uint64_t, ff_pw_20 ) = 0x0014001400140014ULL;
+DECLARE_ALIGNED(16, const xmm_reg, ff_pw_27 ) = {0x001B001B001B001BULL, 0x001B001B001B001BULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_28 ) = {0x001C001C001C001CULL, 0x001C001C001C001CULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_32 ) = {0x0020002000200020ULL, 0x0020002000200020ULL};
DECLARE_ALIGNED(8, const uint64_t, ff_pw_42 ) = 0x002A002A002A002AULL;
+DECLARE_ALIGNED(8, const uint64_t, ff_pw_53 ) = 0x0035003500350035ULL;
+DECLARE_ALIGNED(16, const xmm_reg, ff_pw_63 ) = {0x003F003F003F003FULL, 0x003F003F003F003FULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64 ) = {0x0040004000400040ULL, 0x0040004000400040ULL};
DECLARE_ALIGNED(8, const uint64_t, ff_pw_96 ) = 0x0060006000600060ULL;
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(16, const xmm_reg, ff_pb_0 ) = {0x0000000000000000ULL, 0x0000000000000000ULL};
+DECLARE_ALIGNED(16, const xmm_reg, ff_pb_1 ) = {0x0101010101010101ULL, 0x0101010101010101ULL};
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;
@@ -69,7 +73,7 @@ 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_A1 ) = {0xA1A1A1A1A1A1A1A1ULL, 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};
@@ -77,7 +81,7 @@ DECLARE_ALIGNED(16, const xmm_reg, ff_pb_FE ) = {0xFEFEFEFEFEFEFEFEULL, 0xFEFEF
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 };
-#define JUMPALIGN() __asm__ volatile (ASMALIGN(3)::)
+#define JUMPALIGN() __asm__ volatile (".p2align 3"::)
#define MOVQ_ZERO(regd) __asm__ volatile ("pxor %%" #regd ", %%" #regd ::)
#define MOVQ_BFE(regd) \
@@ -227,7 +231,7 @@ DECLARE_ALIGNED(16, const double, ff_pd_2)[2] = { 2.0, 2.0 };
/***********************************/
/* standard MMX */
-void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
+void ff_put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
const DCTELEM *p;
uint8_t *pix;
@@ -303,7 +307,7 @@ DECLARE_ASM_CONST(8, uint8_t, ff_vector128)[8] =
"movq %%mm3, (%0, %3, 2) \n\t"\
"movq %%mm4, (%0, %1) \n\t"
-void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
+void ff_put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
x86_reg line_skip = line_size;
x86_reg line_skip3;
@@ -319,7 +323,7 @@ void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int li
:"memory");
}
-void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
+void ff_add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
{
const DCTELEM *p;
uint8_t *pix;
@@ -364,7 +368,7 @@ static void put_pixels4_mmx(uint8_t *block, const uint8_t *pixels, int line_size
{
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movd (%1), %%mm0 \n\t"
"movd (%1, %3), %%mm1 \n\t"
@@ -390,7 +394,7 @@ static void put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size
{
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%1, %3), %%mm1 \n\t"
@@ -416,7 +420,7 @@ static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, int line_siz
{
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq 8(%1), %%mm4 \n\t"
@@ -610,7 +614,7 @@ static void add_hfyu_median_prediction_cmov(uint8_t *dst, const uint8_t *top, co
__asm__ volatile(
"mov %7, %3 \n"
"1: \n"
- "movzx (%3,%4), %2 \n"
+ "movzbl (%3,%4), %2 \n"
"mov %2, %k3 \n"
"sub %b1, %b3 \n"
"add %b0, %b3 \n"
@@ -727,35 +731,6 @@ static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale){
}
}
-static inline void transpose4x4(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride){
- __asm__ volatile( //FIXME could save 1 instruction if done as 8x4 ...
- "movd %4, %%mm0 \n\t"
- "movd %5, %%mm1 \n\t"
- "movd %6, %%mm2 \n\t"
- "movd %7, %%mm3 \n\t"
- "punpcklbw %%mm1, %%mm0 \n\t"
- "punpcklbw %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "punpcklwd %%mm2, %%mm0 \n\t"
- "punpckhwd %%mm2, %%mm1 \n\t"
- "movd %%mm0, %0 \n\t"
- "punpckhdq %%mm0, %%mm0 \n\t"
- "movd %%mm0, %1 \n\t"
- "movd %%mm1, %2 \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movd %%mm1, %3 \n\t"
-
- : "=m" (*(uint32_t*)(dst + 0*dst_stride)),
- "=m" (*(uint32_t*)(dst + 1*dst_stride)),
- "=m" (*(uint32_t*)(dst + 2*dst_stride)),
- "=m" (*(uint32_t*)(dst + 3*dst_stride))
- : "m" (*(uint32_t*)(src + 0*src_stride)),
- "m" (*(uint32_t*)(src + 1*src_stride)),
- "m" (*(uint32_t*)(src + 2*src_stride)),
- "m" (*(uint32_t*)(src + 3*src_stride))
- );
-}
-
static void h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale){
if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
const int strength= ff_h263_loop_filter_strength[qscale];
@@ -1689,8 +1664,80 @@ QPEL_2TAP(avg_, 8, 3dnow)
static void just_return(void) { return; }
#endif
-static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
- int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height){
+#if HAVE_YASM
+typedef void emu_edge_core_func (uint8_t *buf, const uint8_t *src,
+ x86_reg linesize, x86_reg start_y,
+ x86_reg end_y, x86_reg block_h,
+ x86_reg start_x, x86_reg end_x,
+ x86_reg block_w);
+extern emu_edge_core_func ff_emu_edge_core_mmx;
+extern emu_edge_core_func ff_emu_edge_core_sse;
+
+static av_always_inline
+void emulated_edge_mc(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h,
+ emu_edge_core_func *core_fn)
+{
+ int start_y, start_x, end_y, end_x, src_y_add=0;
+
+ if(src_y>= h){
+ src_y_add = h-1-src_y;
+ src_y=h-1;
+ }else if(src_y<=-block_h){
+ src_y_add = 1-block_h-src_y;
+ src_y=1-block_h;
+ }
+ if(src_x>= w){
+ src+= (w-1-src_x);
+ src_x=w-1;
+ }else if(src_x<=-block_w){
+ src+= (1-block_w-src_x);
+ src_x=1-block_w;
+ }
+
+ start_y= FFMAX(0, -src_y);
+ start_x= FFMAX(0, -src_x);
+ end_y= FFMIN(block_h, h-src_y);
+ end_x= FFMIN(block_w, w-src_x);
+ assert(start_x < end_x && block_w > 0);
+ assert(start_y < end_y && block_h > 0);
+
+ // fill in the to-be-copied part plus all above/below
+ src += (src_y_add+start_y)*linesize + start_x;
+ buf += start_x;
+ core_fn(buf, src, linesize, start_y, end_y, block_h, start_x, end_x, block_w);
+}
+
+#if ARCH_X86_32
+static av_noinline
+void emulated_edge_mc_mmx(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h)
+{
+ emulated_edge_mc(buf, src, linesize, block_w, block_h, src_x, src_y,
+ w, h, &ff_emu_edge_core_mmx);
+}
+#endif
+static av_noinline
+void emulated_edge_mc_sse(uint8_t *buf, const uint8_t *src, int linesize,
+ int block_w, int block_h,
+ int src_x, int src_y, int w, int h)
+{
+ emulated_edge_mc(buf, src, linesize, block_w, block_h, src_x, src_y,
+ w, h, &ff_emu_edge_core_sse);
+}
+#endif /* HAVE_YASM */
+
+typedef void emulated_edge_mc_func (uint8_t *dst, const uint8_t *src,
+ int linesize, int block_w, int block_h,
+ int src_x, int src_y, int w, int h);
+
+static av_always_inline
+void gmc(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height,
+ emulated_edge_mc_func *emu_edge_fn)
+{
const int w = 8;
const int ix = ox>>(16+shift);
const int iy = oy>>(16+shift);
@@ -1726,7 +1773,7 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o
if( (unsigned)ix >= width-w ||
(unsigned)iy >= height-h )
{
- ff_emulated_edge_mc(edge_buf, src, stride, w+1, h+1, ix, iy, width, height);
+ emu_edge_fn(edge_buf, src, stride, w+1, h+1, ix, iy, width, height);
src = edge_buf;
}
@@ -1807,6 +1854,30 @@ static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int o
}
}
+#if HAVE_YASM
+#if ARCH_X86_32
+static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+{
+ gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
+ width, height, &emulated_edge_mc_mmx);
+}
+#endif
+static void gmc_sse(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+{
+ gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
+ width, height, &emulated_edge_mc_sse);
+}
+#else
+static void gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+{
+ gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
+ width, height, &ff_emulated_edge_mc);
+}
+#endif
+
#define PREFETCH(name, op) \
static void name(void *mem, int stride, int h){\
const uint8_t *p= mem;\
@@ -1819,8 +1890,59 @@ PREFETCH(prefetch_mmx2, prefetcht0)
PREFETCH(prefetch_3dnow, prefetch)
#undef PREFETCH
-#include "h264dsp_mmx.c"
-#include "rv40dsp_mmx.c"
+#include "h264_qpel_mmx.c"
+
+void ff_put_h264_chroma_mc8_mmx_rnd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_put_vc1_chroma_mc8_mmx_nornd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_h264_chroma_mc8_mmx2_rnd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_mmx2_nornd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_rv40_chroma_mc8_mmx2 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_h264_chroma_mc8_3dnow_rnd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_3dnow_nornd(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_rv40_chroma_mc8_3dnow (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+
+void ff_put_h264_chroma_mc4_mmx (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_put_rv40_chroma_mc4_mmx (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_h264_chroma_mc4_mmx2 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_rv40_chroma_mc4_mmx2 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_h264_chroma_mc4_3dnow (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_rv40_chroma_mc4_3dnow (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+
+void ff_put_h264_chroma_mc2_mmx2 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_h264_chroma_mc2_mmx2 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+
+void ff_put_h264_chroma_mc8_ssse3_rnd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_put_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_put_h264_chroma_mc4_ssse3 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+
+void ff_avg_h264_chroma_mc8_ssse3_rnd (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+void ff_avg_h264_chroma_mc4_ssse3 (uint8_t *dst, uint8_t *src,
+ int stride, int h, int x, int y);
+
/* CAVS specific */
void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride) {
@@ -1850,43 +1972,43 @@ void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, in
static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_mmx_idct (block);
- put_pixels_clamped_mmx(block, dest, line_size);
+ ff_put_pixels_clamped_mmx(block, dest, line_size);
}
static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_mmx_idct (block);
- add_pixels_clamped_mmx(block, dest, line_size);
+ ff_add_pixels_clamped_mmx(block, dest, line_size);
}
static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_mmxext_idct (block);
- put_pixels_clamped_mmx(block, dest, line_size);
+ ff_put_pixels_clamped_mmx(block, dest, line_size);
}
static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_mmxext_idct (block);
- add_pixels_clamped_mmx(block, dest, line_size);
+ ff_add_pixels_clamped_mmx(block, dest, line_size);
}
#endif
static void ff_idct_xvid_mmx_put(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_idct_xvid_mmx (block);
- put_pixels_clamped_mmx(block, dest, line_size);
+ ff_put_pixels_clamped_mmx(block, dest, line_size);
}
static void ff_idct_xvid_mmx_add(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_idct_xvid_mmx (block);
- add_pixels_clamped_mmx(block, dest, line_size);
+ ff_add_pixels_clamped_mmx(block, dest, line_size);
}
static void ff_idct_xvid_mmx2_put(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_idct_xvid_mmx2 (block);
- put_pixels_clamped_mmx(block, dest, line_size);
+ ff_put_pixels_clamped_mmx(block, dest, line_size);
}
static void ff_idct_xvid_mmx2_add(uint8_t *dest, int line_size, DCTELEM *block)
{
ff_idct_xvid_mmx2 (block);
- add_pixels_clamped_mmx(block, dest, line_size);
+ ff_add_pixels_clamped_mmx(block, dest, line_size);
}
static void vorbis_inverse_coupling_3dnow(float *mag, float *ang, int blocksize)
@@ -1980,7 +2102,9 @@ static void vorbis_inverse_coupling_sse(float *mag, float *ang, int blocksize)
"jl 1b \n"\
:"+&r"(i)\
:"r"(samples[0]+len), "r"(matrix)\
- :"memory"\
+ :XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+ "memory"\
);
#define MIX_MISC(stereo)\
@@ -1988,8 +2112,8 @@ static void vorbis_inverse_coupling_sse(float *mag, float *ang, int blocksize)
"1: \n"\
"movaps (%3,%0), %%xmm0 \n"\
stereo("movaps %%xmm0, %%xmm1 \n")\
- "mulps %%xmm6, %%xmm0 \n"\
- stereo("mulps %%xmm7, %%xmm1 \n")\
+ "mulps %%xmm4, %%xmm0 \n"\
+ stereo("mulps %%xmm5, %%xmm1 \n")\
"lea 1024(%3,%0), %1 \n"\
"mov %5, %2 \n"\
"2: \n"\
@@ -2022,17 +2146,17 @@ static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2], int out_c
} else if(in_ch == 5 && out_ch == 1 && matrix_cmp[0][0]==matrix_cmp[2][0] && matrix_cmp[3][0]==matrix_cmp[4][0]) {
MIX5(IF1,IF0);
} else {
- DECLARE_ALIGNED(16, float, matrix_simd)[in_ch][2][4];
+ DECLARE_ALIGNED(16, float, matrix_simd)[AC3_MAX_CHANNELS][2][4];
j = 2*in_ch*sizeof(float);
__asm__ volatile(
"1: \n"
"sub $8, %0 \n"
- "movss (%2,%0), %%xmm6 \n"
- "movss 4(%2,%0), %%xmm7 \n"
- "shufps $0, %%xmm6, %%xmm6 \n"
- "shufps $0, %%xmm7, %%xmm7 \n"
- "movaps %%xmm6, (%1,%0,4) \n"
- "movaps %%xmm7, 16(%1,%0,4) \n"
+ "movss (%2,%0), %%xmm4 \n"
+ "movss 4(%2,%0), %%xmm5 \n"
+ "shufps $0, %%xmm4, %%xmm4 \n"
+ "shufps $0, %%xmm5, %%xmm5 \n"
+ "movaps %%xmm4, (%1,%0,4) \n"
+ "movaps %%xmm5, 16(%1,%0,4) \n"
"jg 1b \n"
:"+&r"(j)
:"r"(matrix_simd), "r"(matrix)
@@ -2046,38 +2170,38 @@ static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2], int out_c
}
}
-static void vector_fmul_3dnow(float *dst, const float *src, int len){
+static void vector_fmul_3dnow(float *dst, const float *src0, const float *src1, int len){
x86_reg i = (len-4)*4;
__asm__ volatile(
"1: \n\t"
- "movq (%1,%0), %%mm0 \n\t"
- "movq 8(%1,%0), %%mm1 \n\t"
- "pfmul (%2,%0), %%mm0 \n\t"
- "pfmul 8(%2,%0), %%mm1 \n\t"
+ "movq (%2,%0), %%mm0 \n\t"
+ "movq 8(%2,%0), %%mm1 \n\t"
+ "pfmul (%3,%0), %%mm0 \n\t"
+ "pfmul 8(%3,%0), %%mm1 \n\t"
"movq %%mm0, (%1,%0) \n\t"
"movq %%mm1, 8(%1,%0) \n\t"
"sub $16, %0 \n\t"
"jge 1b \n\t"
"femms \n\t"
:"+r"(i)
- :"r"(dst), "r"(src)
+ :"r"(dst), "r"(src0), "r"(src1)
:"memory"
);
}
-static void vector_fmul_sse(float *dst, const float *src, int len){
+static void vector_fmul_sse(float *dst, const float *src0, const float *src1, int len){
x86_reg i = (len-8)*4;
__asm__ volatile(
"1: \n\t"
- "movaps (%1,%0), %%xmm0 \n\t"
- "movaps 16(%1,%0), %%xmm1 \n\t"
- "mulps (%2,%0), %%xmm0 \n\t"
- "mulps 16(%2,%0), %%xmm1 \n\t"
+ "movaps (%2,%0), %%xmm0 \n\t"
+ "movaps 16(%2,%0), %%xmm1 \n\t"
+ "mulps (%3,%0), %%xmm0 \n\t"
+ "mulps 16(%3,%0), %%xmm1 \n\t"
"movaps %%xmm0, (%1,%0) \n\t"
"movaps %%xmm1, 16(%1,%0) \n\t"
"sub $32, %0 \n\t"
"jge 1b \n\t"
:"+r"(i)
- :"r"(dst), "r"(src)
+ :"r"(dst), "r"(src0), "r"(src1)
:"memory"
);
}
@@ -2162,120 +2286,68 @@ static void vector_fmul_add_sse(float *dst, const float *src0, const float *src1
);
}
-static void vector_fmul_window_3dnow2(float *dst, const float *src0, const float *src1,
- const float *win, float add_bias, int len){
#if HAVE_6REGS
- if(add_bias == 0){
- x86_reg i = -len*4;
- x86_reg j = len*4-8;
- __asm__ volatile(
- "1: \n"
- "pswapd (%5,%1), %%mm1 \n"
- "movq (%5,%0), %%mm0 \n"
- "pswapd (%4,%1), %%mm5 \n"
- "movq (%3,%0), %%mm4 \n"
- "movq %%mm0, %%mm2 \n"
- "movq %%mm1, %%mm3 \n"
- "pfmul %%mm4, %%mm2 \n" // src0[len+i]*win[len+i]
- "pfmul %%mm5, %%mm3 \n" // src1[ j]*win[len+j]
- "pfmul %%mm4, %%mm1 \n" // src0[len+i]*win[len+j]
- "pfmul %%mm5, %%mm0 \n" // src1[ j]*win[len+i]
- "pfadd %%mm3, %%mm2 \n"
- "pfsub %%mm0, %%mm1 \n"
- "pswapd %%mm2, %%mm2 \n"
- "movq %%mm1, (%2,%0) \n"
- "movq %%mm2, (%2,%1) \n"
- "sub $8, %1 \n"
- "add $8, %0 \n"
- "jl 1b \n"
- "femms \n"
- :"+r"(i), "+r"(j)
- :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
- );
- }else
-#endif
- ff_vector_fmul_window_c(dst, src0, src1, win, add_bias, len);
-}
-
-static void vector_fmul_window_sse(float *dst, const float *src0, const float *src1,
- const float *win, float add_bias, int len){
-#if HAVE_6REGS
- if(add_bias == 0){
- x86_reg i = -len*4;
- x86_reg j = len*4-16;
- __asm__ volatile(
- "1: \n"
- "movaps (%5,%1), %%xmm1 \n"
- "movaps (%5,%0), %%xmm0 \n"
- "movaps (%4,%1), %%xmm5 \n"
- "movaps (%3,%0), %%xmm4 \n"
- "shufps $0x1b, %%xmm1, %%xmm1 \n"
- "shufps $0x1b, %%xmm5, %%xmm5 \n"
- "movaps %%xmm0, %%xmm2 \n"
- "movaps %%xmm1, %%xmm3 \n"
- "mulps %%xmm4, %%xmm2 \n" // src0[len+i]*win[len+i]
- "mulps %%xmm5, %%xmm3 \n" // src1[ j]*win[len+j]
- "mulps %%xmm4, %%xmm1 \n" // src0[len+i]*win[len+j]
- "mulps %%xmm5, %%xmm0 \n" // src1[ j]*win[len+i]
- "addps %%xmm3, %%xmm2 \n"
- "subps %%xmm0, %%xmm1 \n"
- "shufps $0x1b, %%xmm2, %%xmm2 \n"
- "movaps %%xmm1, (%2,%0) \n"
- "movaps %%xmm2, (%2,%1) \n"
- "sub $16, %1 \n"
- "add $16, %0 \n"
- "jl 1b \n"
- :"+r"(i), "+r"(j)
- :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
- );
- }else
-#endif
- ff_vector_fmul_window_c(dst, src0, src1, win, add_bias, len);
-}
-
-static void int32_to_float_fmul_scalar_sse(float *dst, const int *src, float mul, int len)
-{
- x86_reg i = -4*len;
+static void vector_fmul_window_3dnow2(float *dst, const float *src0, const float *src1,
+ const float *win, int len){
+ x86_reg i = -len*4;
+ x86_reg j = len*4-8;
__asm__ volatile(
- "movss %3, %%xmm4 \n"
- "shufps $0, %%xmm4, %%xmm4 \n"
"1: \n"
- "cvtpi2ps (%2,%0), %%xmm0 \n"
- "cvtpi2ps 8(%2,%0), %%xmm1 \n"
- "cvtpi2ps 16(%2,%0), %%xmm2 \n"
- "cvtpi2ps 24(%2,%0), %%xmm3 \n"
- "movlhps %%xmm1, %%xmm0 \n"
- "movlhps %%xmm3, %%xmm2 \n"
- "mulps %%xmm4, %%xmm0 \n"
- "mulps %%xmm4, %%xmm2 \n"
- "movaps %%xmm0, (%1,%0) \n"
- "movaps %%xmm2, 16(%1,%0) \n"
- "add $32, %0 \n"
+ "pswapd (%5,%1), %%mm1 \n"
+ "movq (%5,%0), %%mm0 \n"
+ "pswapd (%4,%1), %%mm5 \n"
+ "movq (%3,%0), %%mm4 \n"
+ "movq %%mm0, %%mm2 \n"
+ "movq %%mm1, %%mm3 \n"
+ "pfmul %%mm4, %%mm2 \n" // src0[len+i]*win[len+i]
+ "pfmul %%mm5, %%mm3 \n" // src1[ j]*win[len+j]
+ "pfmul %%mm4, %%mm1 \n" // src0[len+i]*win[len+j]
+ "pfmul %%mm5, %%mm0 \n" // src1[ j]*win[len+i]
+ "pfadd %%mm3, %%mm2 \n"
+ "pfsub %%mm0, %%mm1 \n"
+ "pswapd %%mm2, %%mm2 \n"
+ "movq %%mm1, (%2,%0) \n"
+ "movq %%mm2, (%2,%1) \n"
+ "sub $8, %1 \n"
+ "add $8, %0 \n"
"jl 1b \n"
- :"+r"(i)
- :"r"(dst+len), "r"(src+len), "m"(mul)
+ "femms \n"
+ :"+r"(i), "+r"(j)
+ :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
);
}
-static void int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len)
-{
- x86_reg i = -4*len;
+static void vector_fmul_window_sse(float *dst, const float *src0, const float *src1,
+ const float *win, int len){
+ x86_reg i = -len*4;
+ x86_reg j = len*4-16;
__asm__ volatile(
- "movss %3, %%xmm4 \n"
- "shufps $0, %%xmm4, %%xmm4 \n"
"1: \n"
- "cvtdq2ps (%2,%0), %%xmm0 \n"
- "cvtdq2ps 16(%2,%0), %%xmm1 \n"
- "mulps %%xmm4, %%xmm0 \n"
- "mulps %%xmm4, %%xmm1 \n"
- "movaps %%xmm0, (%1,%0) \n"
- "movaps %%xmm1, 16(%1,%0) \n"
- "add $32, %0 \n"
+ "movaps (%5,%1), %%xmm1 \n"
+ "movaps (%5,%0), %%xmm0 \n"
+ "movaps (%4,%1), %%xmm5 \n"
+ "movaps (%3,%0), %%xmm4 \n"
+ "shufps $0x1b, %%xmm1, %%xmm1 \n"
+ "shufps $0x1b, %%xmm5, %%xmm5 \n"
+ "movaps %%xmm0, %%xmm2 \n"
+ "movaps %%xmm1, %%xmm3 \n"
+ "mulps %%xmm4, %%xmm2 \n" // src0[len+i]*win[len+i]
+ "mulps %%xmm5, %%xmm3 \n" // src1[ j]*win[len+j]
+ "mulps %%xmm4, %%xmm1 \n" // src0[len+i]*win[len+j]
+ "mulps %%xmm5, %%xmm0 \n" // src1[ j]*win[len+i]
+ "addps %%xmm3, %%xmm2 \n"
+ "subps %%xmm0, %%xmm1 \n"
+ "shufps $0x1b, %%xmm2, %%xmm2 \n"
+ "movaps %%xmm1, (%2,%0) \n"
+ "movaps %%xmm2, (%2,%1) \n"
+ "sub $16, %1 \n"
+ "add $16, %0 \n"
"jl 1b \n"
- :"+r"(i)
- :"r"(dst+len), "r"(src+len), "m"(mul)
+ :"+r"(i), "+r"(j)
+ :"r"(dst+len), "r"(src0+len), "r"(src1), "r"(win+len)
);
}
+#endif /* HAVE_6REGS */
static void vector_clipf_sse(float *dst, const float *src, float min, float max,
int len)
@@ -2311,73 +2383,19 @@ static void vector_clipf_sse(float *dst, const float *src, float min, float max,
);
}
-static void float_to_int16_3dnow(int16_t *dst, const float *src, long len){
- x86_reg reglen = len;
- // not bit-exact: pf2id uses different rounding than C and SSE
- __asm__ volatile(
- "add %0 , %0 \n\t"
- "lea (%2,%0,2) , %2 \n\t"
- "add %0 , %1 \n\t"
- "neg %0 \n\t"
- "1: \n\t"
- "pf2id (%2,%0,2) , %%mm0 \n\t"
- "pf2id 8(%2,%0,2) , %%mm1 \n\t"
- "pf2id 16(%2,%0,2) , %%mm2 \n\t"
- "pf2id 24(%2,%0,2) , %%mm3 \n\t"
- "packssdw %%mm1 , %%mm0 \n\t"
- "packssdw %%mm3 , %%mm2 \n\t"
- "movq %%mm0 , (%1,%0) \n\t"
- "movq %%mm2 , 8(%1,%0) \n\t"
- "add $16 , %0 \n\t"
- " js 1b \n\t"
- "femms \n\t"
- :"+r"(reglen), "+r"(dst), "+r"(src)
- );
-}
-static void float_to_int16_sse(int16_t *dst, const float *src, long len){
- x86_reg reglen = len;
- __asm__ volatile(
- "add %0 , %0 \n\t"
- "lea (%2,%0,2) , %2 \n\t"
- "add %0 , %1 \n\t"
- "neg %0 \n\t"
- "1: \n\t"
- "cvtps2pi (%2,%0,2) , %%mm0 \n\t"
- "cvtps2pi 8(%2,%0,2) , %%mm1 \n\t"
- "cvtps2pi 16(%2,%0,2) , %%mm2 \n\t"
- "cvtps2pi 24(%2,%0,2) , %%mm3 \n\t"
- "packssdw %%mm1 , %%mm0 \n\t"
- "packssdw %%mm3 , %%mm2 \n\t"
- "movq %%mm0 , (%1,%0) \n\t"
- "movq %%mm2 , 8(%1,%0) \n\t"
- "add $16 , %0 \n\t"
- " js 1b \n\t"
- "emms \n\t"
- :"+r"(reglen), "+r"(dst), "+r"(src)
- );
-}
+void ff_vp3_idct_mmx(int16_t *input_data);
+void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block);
-static void float_to_int16_sse2(int16_t *dst, const float *src, long len){
- x86_reg reglen = len;
- __asm__ volatile(
- "add %0 , %0 \n\t"
- "lea (%2,%0,2) , %2 \n\t"
- "add %0 , %1 \n\t"
- "neg %0 \n\t"
- "1: \n\t"
- "cvtps2dq (%2,%0,2) , %%xmm0 \n\t"
- "cvtps2dq 16(%2,%0,2) , %%xmm1 \n\t"
- "packssdw %%xmm1 , %%xmm0 \n\t"
- "movdqa %%xmm0 , (%1,%0) \n\t"
- "add $16 , %0 \n\t"
- " js 1b \n\t"
- :"+r"(reglen), "+r"(dst), "+r"(src)
- );
-}
+void ff_vp3_idct_dc_add_mmx2(uint8_t *dest, int line_size, const DCTELEM *block);
+
+void ff_vp3_v_loop_filter_mmx2(uint8_t *src, int stride, int *bounding_values);
+void ff_vp3_h_loop_filter_mmx2(uint8_t *src, int stride, int *bounding_values);
+
+void ff_vp3_idct_sse2(int16_t *input_data);
+void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block);
+void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, DCTELEM *block);
-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(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);
@@ -2386,123 +2404,15 @@ int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, const int16_t *v2, co
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);
-void ff_x264_deblock_v_luma_sse2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
-void ff_x264_deblock_h_luma_sse2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
-void ff_x264_deblock_h_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta);
-void ff_x264_deblock_v_luma_intra_sse2(uint8_t *pix, int stride, int alpha, int beta);
-void ff_x264_deblock_h_luma_intra_sse2(uint8_t *pix, int stride, int alpha, int beta);
-
-#if HAVE_YASM && ARCH_X86_32
-void ff_x264_deblock_v8_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta);
-static void ff_x264_deblock_v_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta)
-{
- ff_x264_deblock_v8_luma_intra_mmxext(pix+0, stride, alpha, beta);
- ff_x264_deblock_v8_luma_intra_mmxext(pix+8, stride, alpha, beta);
-}
-#elif !HAVE_YASM
-#define ff_float_to_int16_interleave6_sse(a,b,c) float_to_int16_interleave_misc_sse(a,b,c,6)
-#define ff_float_to_int16_interleave6_3dnow(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
-#define ff_float_to_int16_interleave6_3dn2(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
-#endif
-#define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse
-
-#define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \
-/* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
-static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\
- DECLARE_ALIGNED(16, int16_t, tmp)[len];\
- int i,j,c;\
- for(c=0; c<channels; c++){\
- float_to_int16_##cpu(tmp, src[c], len);\
- for(i=0, j=c; i<len; i++, j+=channels)\
- dst[j] = tmp[i];\
- }\
-}\
-\
-static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\
- if(channels==1)\
- float_to_int16_##cpu(dst, src[0], len);\
- else if(channels==2){\
- x86_reg reglen = len; \
- const float *src0 = src[0];\
- const float *src1 = src[1];\
- __asm__ volatile(\
- "shl $2, %0 \n"\
- "add %0, %1 \n"\
- "add %0, %2 \n"\
- "add %0, %3 \n"\
- "neg %0 \n"\
- body\
- :"+r"(reglen), "+r"(dst), "+r"(src0), "+r"(src1)\
- );\
- }else if(channels==6){\
- ff_float_to_int16_interleave6_##cpu(dst, src, len);\
- }else\
- float_to_int16_interleave_misc_##cpu(dst, src, len, channels);\
-}
-
-FLOAT_TO_INT16_INTERLEAVE(3dnow,
- "1: \n"
- "pf2id (%2,%0), %%mm0 \n"
- "pf2id 8(%2,%0), %%mm1 \n"
- "pf2id (%3,%0), %%mm2 \n"
- "pf2id 8(%3,%0), %%mm3 \n"
- "packssdw %%mm1, %%mm0 \n"
- "packssdw %%mm3, %%mm2 \n"
- "movq %%mm0, %%mm1 \n"
- "punpcklwd %%mm2, %%mm0 \n"
- "punpckhwd %%mm2, %%mm1 \n"
- "movq %%mm0, (%1,%0)\n"
- "movq %%mm1, 8(%1,%0)\n"
- "add $16, %0 \n"
- "js 1b \n"
- "femms \n"
-)
-
-FLOAT_TO_INT16_INTERLEAVE(sse,
- "1: \n"
- "cvtps2pi (%2,%0), %%mm0 \n"
- "cvtps2pi 8(%2,%0), %%mm1 \n"
- "cvtps2pi (%3,%0), %%mm2 \n"
- "cvtps2pi 8(%3,%0), %%mm3 \n"
- "packssdw %%mm1, %%mm0 \n"
- "packssdw %%mm3, %%mm2 \n"
- "movq %%mm0, %%mm1 \n"
- "punpcklwd %%mm2, %%mm0 \n"
- "punpckhwd %%mm2, %%mm1 \n"
- "movq %%mm0, (%1,%0)\n"
- "movq %%mm1, 8(%1,%0)\n"
- "add $16, %0 \n"
- "js 1b \n"
- "emms \n"
-)
-
-FLOAT_TO_INT16_INTERLEAVE(sse2,
- "1: \n"
- "cvtps2dq (%2,%0), %%xmm0 \n"
- "cvtps2dq (%3,%0), %%xmm1 \n"
- "packssdw %%xmm1, %%xmm0 \n"
- "movhlps %%xmm0, %%xmm1 \n"
- "punpcklwd %%xmm1, %%xmm0 \n"
- "movdqa %%xmm0, (%1,%0) \n"
- "add $16, %0 \n"
- "js 1b \n"
-)
-
-static void float_to_int16_interleave_3dn2(int16_t *dst, const float **src, long len, int channels){
- if(channels==6)
- ff_float_to_int16_interleave6_3dn2(dst, src, len);
- else
- float_to_int16_interleave_3dnow(dst, src, len, channels);
-}
float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
- mm_flags = mm_support();
+ int mm_flags = av_get_cpu_flags();
if (avctx->dsp_mask) {
- if (avctx->dsp_mask & FF_MM_FORCE)
+ if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
mm_flags |= (avctx->dsp_mask & 0xffff);
else
mm_flags &= ~(avctx->dsp_mask & 0xffff);
@@ -2510,20 +2420,20 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
#if 0
av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
- if (mm_flags & FF_MM_MMX)
+ if (mm_flags & AV_CPU_FLAG_MMX)
av_log(avctx, AV_LOG_INFO, " mmx");
- if (mm_flags & FF_MM_MMX2)
+ if (mm_flags & AV_CPU_FLAG_MMX2)
av_log(avctx, AV_LOG_INFO, " mmx2");
- if (mm_flags & FF_MM_3DNOW)
+ if (mm_flags & AV_CPU_FLAG_3DNOW)
av_log(avctx, AV_LOG_INFO, " 3dnow");
- if (mm_flags & FF_MM_SSE)
+ if (mm_flags & AV_CPU_FLAG_SSE)
av_log(avctx, AV_LOG_INFO, " sse");
- if (mm_flags & FF_MM_SSE2)
+ if (mm_flags & AV_CPU_FLAG_SSE2)
av_log(avctx, AV_LOG_INFO, " sse2");
av_log(avctx, AV_LOG_INFO, "\n");
#endif
- if (mm_flags & FF_MM_MMX) {
+ if (mm_flags & AV_CPU_FLAG_MMX) {
const int idct_algo= avctx->idct_algo;
if(avctx->lowres==0){
@@ -2534,7 +2444,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
#if CONFIG_GPL
}else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
- if(mm_flags & FF_MM_MMX2){
+ if(mm_flags & AV_CPU_FLAG_MMX2){
c->idct_put= ff_libmpeg2mmx2_idct_put;
c->idct_add= ff_libmpeg2mmx2_idct_add;
c->idct = ff_mmxext_idct;
@@ -2546,8 +2456,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
#endif
}else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) &&
- idct_algo==FF_IDCT_VP3){
- if(mm_flags & FF_MM_SSE2){
+ idct_algo==FF_IDCT_VP3 && HAVE_YASM){
+ if(mm_flags & AV_CPU_FLAG_SSE2){
c->idct_put= ff_vp3_idct_put_sse2;
c->idct_add= ff_vp3_idct_add_sse2;
c->idct = ff_vp3_idct_sse2;
@@ -2561,12 +2471,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
}else if(idct_algo==FF_IDCT_CAVS){
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else if(idct_algo==FF_IDCT_XVIDMMX){
- if(mm_flags & FF_MM_SSE2){
+ if(mm_flags & AV_CPU_FLAG_SSE2){
c->idct_put= ff_idct_xvid_sse2_put;
c->idct_add= ff_idct_xvid_sse2_add;
c->idct = ff_idct_xvid_sse2;
c->idct_permutation_type= FF_SSE2_IDCT_PERM;
- }else if(mm_flags & FF_MM_MMX2){
+ }else if(mm_flags & AV_CPU_FLAG_MMX2){
c->idct_put= ff_idct_xvid_mmx2_put;
c->idct_add= ff_idct_xvid_mmx2_add;
c->idct = ff_idct_xvid_mmx2;
@@ -2578,12 +2488,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
}
}
- c->put_pixels_clamped = put_pixels_clamped_mmx;
- c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
- c->add_pixels_clamped = add_pixels_clamped_mmx;
+ c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
+ c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
+ c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
c->clear_block = clear_block_mmx;
c->clear_blocks = clear_blocks_mmx;
- if ((mm_flags & FF_MM_SSE) &&
+ if ((mm_flags & AV_CPU_FLAG_SSE) &&
!(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)){
/* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
c->clear_block = clear_block_sse;
@@ -2605,7 +2515,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
SET_HPEL_FUNCS(avg, 1, 8, mmx);
SET_HPEL_FUNCS(avg_no_rnd, 1, 8, mmx);
+#if ARCH_X86_32 || !HAVE_YASM
c->gmc= gmc_mmx;
+#endif
+#if ARCH_X86_32 && HAVE_YASM
+ c->emulated_edge_mc = emulated_edge_mc_mmx;
+#endif
c->add_bytes= add_bytes_mmx;
c->add_bytes_l2= add_bytes_l2_mmx;
@@ -2616,18 +2531,17 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->h263_v_loop_filter= h263_v_loop_filter_mmx;
c->h263_h_loop_filter= h263_h_loop_filter_mmx;
}
- c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx_rnd;
- c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
- c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_vc1_chroma_mc8_mmx_nornd;
- c->put_rv40_chroma_pixels_tab[0]= put_rv40_chroma_mc8_mmx;
- c->put_rv40_chroma_pixels_tab[1]= put_rv40_chroma_mc4_mmx;
+#if HAVE_YASM
+ c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_mmx_rnd;
+ c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_mmx;
+ c->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_mmx_nornd;
- if (CONFIG_VP6_DECODER) {
- c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx;
- }
+ c->put_rv40_chroma_pixels_tab[0]= ff_put_rv40_chroma_mc8_mmx;
+ c->put_rv40_chroma_pixels_tab[1]= ff_put_rv40_chroma_mc4_mmx;
+#endif
- if (mm_flags & FF_MM_MMX2) {
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
c->prefetch = prefetch_mmx2;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
@@ -2652,12 +2566,12 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
- if (CONFIG_VP3_DECODER) {
+ if (CONFIG_VP3_DECODER && HAVE_YASM) {
c->vp3_v_loop_filter= ff_vp3_v_loop_filter_mmx2;
c->vp3_h_loop_filter= ff_vp3_h_loop_filter_mmx2;
}
}
- if (CONFIG_VP3_DECODER) {
+ if (CONFIG_VP3_DECODER && HAVE_YASM) {
c->vp3_idct_dc_add = ff_vp3_idct_dc_add_mmx2;
}
@@ -2704,32 +2618,29 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, mmx2);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, mmx2);
- c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_mmx2;
- c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_mmx2;
+#if HAVE_YASM
+ c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2;
+ c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_mmx2;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_vc1_chroma_mc8_mmx2_nornd;
+ c->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_mmx2_nornd;
- c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2_rnd;
- c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;
- c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;
- c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;
+ c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_mmx2_rnd;
+ c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_mmx2;
+ c->avg_h264_chroma_pixels_tab[2]= ff_avg_h264_chroma_mc2_mmx2;
+ c->put_h264_chroma_pixels_tab[2]= ff_put_h264_chroma_mc2_mmx2;
-#if HAVE_YASM
c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_mmx2;
#endif
#if HAVE_7REGS && HAVE_TEN_OPERANDS
- if( mm_flags&FF_MM_3DNOW )
+ if( mm_flags&AV_CPU_FLAG_3DNOW )
c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
#endif
- if (CONFIG_CAVS_DECODER)
- ff_cavsdsp_init_mmx2(c, avctx);
-
if (CONFIG_VC1_DECODER)
ff_vc1dsp_init_mmx(c, avctx);
c->add_png_paeth_prediction= add_png_paeth_prediction_mmx2;
- } else if (mm_flags & FF_MM_3DNOW) {
+ } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
c->prefetch = prefetch_3dnow;
c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
@@ -2780,14 +2691,15 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
SET_QPEL_FUNCS(avg_2tap_qpel, 0, 16, 3dnow);
SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);
- c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow_rnd;
- c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
+#if HAVE_YASM
+ c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_3dnow_rnd;
+ c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_3dnow;
- c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_3dnow;
- c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_3dnow;
+ c->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_3dnow_nornd;
- if (CONFIG_CAVS_DECODER)
- ff_cavsdsp_init_3dnow(c, avctx);
+ c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_3dnow;
+ c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_3dnow;
+#endif
}
@@ -2796,13 +2708,14 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->put_h264_qpel_pixels_tab[1][x+y*4] = put_h264_qpel8_mc##x##y##_##CPU;\
c->avg_h264_qpel_pixels_tab[0][x+y*4] = avg_h264_qpel16_mc##x##y##_##CPU;\
c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;
- if((mm_flags & FF_MM_SSE2) && !(mm_flags & FF_MM_3DNOW)){
+ if((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW)){
// these functions are slower than mmx on AMD, but faster on Intel
c->put_pixels_tab[0][0] = put_pixels16_sse2;
+ c->put_no_rnd_pixels_tab[0][0] = put_pixels16_sse2;
c->avg_pixels_tab[0][0] = avg_pixels16_sse2;
H264_QPEL_FUNCS(0, 0, sse2);
}
- if(mm_flags & FF_MM_SSE2){
+ if(mm_flags & AV_CPU_FLAG_SSE2){
H264_QPEL_FUNCS(0, 1, sse2);
H264_QPEL_FUNCS(0, 2, sse2);
H264_QPEL_FUNCS(0, 3, sse2);
@@ -2815,13 +2728,9 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
H264_QPEL_FUNCS(3, 1, sse2);
H264_QPEL_FUNCS(3, 2, sse2);
H264_QPEL_FUNCS(3, 3, sse2);
-
- if (CONFIG_VP6_DECODER) {
- c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
- }
}
#if HAVE_SSSE3
- if(mm_flags & FF_MM_SSSE3){
+ if(mm_flags & AV_CPU_FLAG_SSSE3){
H264_QPEL_FUNCS(1, 0, ssse3);
H264_QPEL_FUNCS(1, 1, ssse3);
H264_QPEL_FUNCS(1, 2, ssse3);
@@ -2834,69 +2743,63 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
H264_QPEL_FUNCS(3, 1, ssse3);
H264_QPEL_FUNCS(3, 2, ssse3);
H264_QPEL_FUNCS(3, 3, ssse3);
- c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_vc1_chroma_mc8_ssse3_nornd;
- c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_vc1_chroma_mc8_ssse3_nornd;
- c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_ssse3_rnd;
- c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_ssse3_rnd;
- c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_ssse3;
- c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_ssse3;
c->add_png_paeth_prediction= add_png_paeth_prediction_ssse3;
#if HAVE_YASM
+ c->put_no_rnd_vc1_chroma_pixels_tab[0]= ff_put_vc1_chroma_mc8_ssse3_nornd;
+ c->avg_no_rnd_vc1_chroma_pixels_tab[0]= ff_avg_vc1_chroma_mc8_ssse3_nornd;
+ c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd;
+ c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd;
+ c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_ssse3;
+ c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_ssse3;
c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_ssse3;
- if (mm_flags & FF_MM_SSE4) // not really sse4, just slow on Conroe
+ if (mm_flags & AV_CPU_FLAG_SSE4) // not really sse4, just slow on Conroe
c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_sse4;
#endif
}
#endif
- if(mm_flags & FF_MM_3DNOW){
+ if(mm_flags & AV_CPU_FLAG_3DNOW){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;
c->vector_fmul = vector_fmul_3dnow;
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->float_to_int16 = float_to_int16_3dnow;
- c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
- }
}
- if(mm_flags & FF_MM_3DNOWEXT){
+ if(mm_flags & AV_CPU_FLAG_3DNOWEXT){
c->vector_fmul_reverse = vector_fmul_reverse_3dnow2;
+#if HAVE_6REGS
c->vector_fmul_window = vector_fmul_window_3dnow2;
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->float_to_int16_interleave = float_to_int16_interleave_3dn2;
- }
+#endif
}
- if(mm_flags & FF_MM_MMX2){
+ if(mm_flags & AV_CPU_FLAG_MMX2){
#if HAVE_YASM
c->scalarproduct_int16 = ff_scalarproduct_int16_mmx2;
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_mmx2;
#endif
}
- if(mm_flags & FF_MM_SSE){
+ if(mm_flags & AV_CPU_FLAG_SSE){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse;
c->ac3_downmix = ac3_downmix_sse;
c->vector_fmul = vector_fmul_sse;
c->vector_fmul_reverse = vector_fmul_reverse_sse;
c->vector_fmul_add = vector_fmul_add_sse;
+#if HAVE_6REGS
c->vector_fmul_window = vector_fmul_window_sse;
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
+#endif
c->vector_clipf = vector_clipf_sse;
- c->float_to_int16 = float_to_int16_sse;
- c->float_to_int16_interleave = float_to_int16_interleave_sse;
#if HAVE_YASM
c->scalarproduct_float = ff_scalarproduct_float_sse;
#endif
}
- if(mm_flags & FF_MM_3DNOW)
+ if(mm_flags & AV_CPU_FLAG_3DNOW)
c->vector_fmul_add = vector_fmul_add_3dnow; // faster than sse
- if(mm_flags & FF_MM_SSE2){
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
- c->float_to_int16 = float_to_int16_sse2;
- c->float_to_int16_interleave = float_to_int16_interleave_sse2;
+ if(mm_flags & AV_CPU_FLAG_SSE2){
#if HAVE_YASM
c->scalarproduct_int16 = ff_scalarproduct_int16_sse2;
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2;
+
+ c->emulated_edge_mc = emulated_edge_mc_sse;
+ c->gmc= gmc_sse;
#endif
}
- if((mm_flags & FF_MM_SSSE3) && !(mm_flags & (FF_MM_SSE42|FF_MM_3DNOW)) && HAVE_YASM) // cachesplit
+ if((mm_flags & AV_CPU_FLAG_SSSE3) && !(mm_flags & (AV_CPU_FLAG_SSE42|AV_CPU_FLAG_3DNOW)) && HAVE_YASM) // cachesplit
c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_ssse3;
}
@@ -2938,81 +2841,3 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
//ff_idct = just_return;
#endif
}
-
-#if CONFIG_H264DSP
-void ff_h264dsp_init_x86(H264DSPContext *c)
-{
- mm_flags = mm_support();
-
- if (mm_flags & FF_MM_MMX) {
- c->h264_idct_dc_add=
- c->h264_idct_add= ff_h264_idct_add_mmx;
- c->h264_idct8_dc_add=
- c->h264_idct8_add= ff_h264_idct8_add_mmx;
-
- c->h264_idct_add16 = ff_h264_idct_add16_mmx;
- c->h264_idct8_add4 = ff_h264_idct8_add4_mmx;
- c->h264_idct_add8 = ff_h264_idct_add8_mmx;
- c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
-
- if (mm_flags & FF_MM_MMX2) {
- c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
- c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
- c->h264_idct_add16 = ff_h264_idct_add16_mmx2;
- c->h264_idct8_add4 = ff_h264_idct8_add4_mmx2;
- c->h264_idct_add8 = ff_h264_idct_add8_mmx2;
- c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2;
-
- c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
- c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
- c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
- c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;
- c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;
- c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;
- c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
-
- c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
- c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
- c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
- c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
- c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
- c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
- c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
- c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
-
- c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
- c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
- c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
- c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
- c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
- c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
- c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
- c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
- }
- if(mm_flags & FF_MM_SSE2){
- c->h264_idct8_add = ff_h264_idct8_add_sse2;
- c->h264_idct8_add4= ff_h264_idct8_add4_sse2;
- }
-
-#if CONFIG_GPL && HAVE_YASM
- if (mm_flags & FF_MM_MMX2){
-#if ARCH_X86_32
- c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_mmxext;
- c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_mmxext;
-#endif
- if( mm_flags&FF_MM_SSE2 ){
-#if ARCH_X86_64 || !defined(__ICC) || __ICC > 1110
- c->h264_v_loop_filter_luma = ff_x264_deblock_v_luma_sse2;
- c->h264_h_loop_filter_luma = ff_x264_deblock_h_luma_sse2;
- c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_sse2;
- c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_sse2;
-#endif
- c->h264_idct_add16 = ff_h264_idct_add16_sse2;
- c->h264_idct_add8 = ff_h264_idct_add8_sse2;
- c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
- }
- }
-#endif
- }
-}
-#endif /* CONFIG_H264DSP */
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_mmx.h b/lib/ffmpeg/libavcodec/x86/dsputil_mmx.h
index ca3713c6e5..a095e1ef3d 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputil_mmx.h
+++ b/lib/ffmpeg/libavcodec/x86/dsputil_mmx.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include "libavcodec/dsputil.h"
+#include "libavutil/x86_cpu.h"
typedef struct { uint64_t a, b; } xmm_reg;
@@ -32,29 +33,35 @@ extern const uint64_t ff_wtwo;
extern const uint64_t ff_pdw_80000000[2];
-extern const uint64_t ff_pw_3;
+extern const xmm_reg ff_pw_3;
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;
extern const xmm_reg ff_pw_16;
+extern const xmm_reg ff_pw_18;
extern const uint64_t ff_pw_20;
+extern const xmm_reg ff_pw_27;
extern const xmm_reg ff_pw_28;
extern const xmm_reg ff_pw_32;
extern const uint64_t ff_pw_42;
+extern const uint64_t ff_pw_53;
+extern const xmm_reg ff_pw_63;
extern const xmm_reg ff_pw_64;
extern const uint64_t ff_pw_96;
extern const uint64_t ff_pw_128;
extern const uint64_t ff_pw_255;
-extern const uint64_t ff_pb_1;
+extern const xmm_reg ff_pb_1;
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;
extern const uint64_t ff_pb_81;
-extern const uint64_t ff_pb_A1;
+extern const xmm_reg ff_pb_A1;
+extern const xmm_reg ff_pb_F8;
extern const uint64_t ff_pb_FC;
+extern const xmm_reg ff_pb_FE;
extern const double ff_pd_1[2];
extern const double ff_pd_2[2];
@@ -88,6 +95,34 @@ extern const double ff_pd_2[2];
SBUTTERFLY(a,c,d,dq,q) /* a=aeim d=bfjn */\
SBUTTERFLY(t,b,c,dq,q) /* t=cgko c=dhlp */
+static inline void transpose4x4(uint8_t *dst, uint8_t *src, x86_reg dst_stride, x86_reg src_stride){
+ __asm__ volatile( //FIXME could save 1 instruction if done as 8x4 ...
+ "movd (%1), %%mm0 \n\t"
+ "add %3, %1 \n\t"
+ "movd (%1), %%mm1 \n\t"
+ "movd (%1,%3,1), %%mm2 \n\t"
+ "movd (%1,%3,2), %%mm3 \n\t"
+ "punpcklbw %%mm1, %%mm0 \n\t"
+ "punpcklbw %%mm3, %%mm2 \n\t"
+ "movq %%mm0, %%mm1 \n\t"
+ "punpcklwd %%mm2, %%mm0 \n\t"
+ "punpckhwd %%mm2, %%mm1 \n\t"
+ "movd %%mm0, (%0) \n\t"
+ "add %2, %0 \n\t"
+ "punpckhdq %%mm0, %%mm0 \n\t"
+ "movd %%mm0, (%0) \n\t"
+ "movd %%mm1, (%0,%2,1) \n\t"
+ "punpckhdq %%mm1, %%mm1 \n\t"
+ "movd %%mm1, (%0,%2,2) \n\t"
+
+ : "+&r" (dst),
+ "+&r" (src)
+ : "r" (dst_stride),
+ "r" (src_stride)
+ : "memory"
+ );
+}
+
// e,f,g,h can be memory
// out: a,d,t,c
#define TRANSPOSE8x4(a,b,c,d,e,f,g,h,t)\
@@ -152,12 +187,10 @@ extern const double ff_pd_2[2];
void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
-void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
+void ff_add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
+void ff_put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
+void ff_put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx);
-void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx);
void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
@@ -167,10 +200,20 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx);
void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd);
void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
- double *autoc);
-
void ff_mmx_idct(DCTELEM *block);
void ff_mmxext_idct(DCTELEM *block);
+
+void ff_deinterlace_line_mmx(uint8_t *dst,
+ const uint8_t *lum_m4, const uint8_t *lum_m3,
+ const uint8_t *lum_m2, const uint8_t *lum_m1,
+ const uint8_t *lum,
+ int size);
+
+void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4,
+ const uint8_t *lum_m3,
+ const uint8_t *lum_m2,
+ const uint8_t *lum_m1,
+ const uint8_t *lum, int size);
+
#endif /* AVCODEC_X86_DSPUTIL_MMX_H */
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_mmx_avg_template.c b/lib/ffmpeg/libavcodec/x86/dsputil_mmx_avg_template.c
index 69575e3ae7..6f768595c0 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputil_mmx_avg_template.c
+++ b/lib/ffmpeg/libavcodec/x86/dsputil_mmx_avg_template.c
@@ -838,7 +838,7 @@ static void DEF(avg_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line
"lea (%3, %3), %%"REG_a" \n\t"
"movq (%1), %%mm0 \n\t"
PAVGB" 1(%1), %%mm0 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm2 \n\t"
"movq (%1, %3), %%mm1 \n\t"
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_mmx_qns_template.c b/lib/ffmpeg/libavcodec/x86/dsputil_mmx_qns_template.c
index d2dbfc5a58..77a41b9dcb 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputil_mmx_qns_template.c
+++ b/lib/ffmpeg/libavcodec/x86/dsputil_mmx_qns_template.c
@@ -37,7 +37,7 @@ static int DEF(try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[
"movd %4, %%mm5 \n\t"
"punpcklwd %%mm5, %%mm5 \n\t"
"punpcklwd %%mm5, %%mm5 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %0), %%mm0 \n\t"
"movq 8(%1, %0), %%mm1 \n\t"
@@ -77,7 +77,7 @@ static void DEF(add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale)
"movd %3, %%mm5 \n\t"
"punpcklwd %%mm5, %%mm5 \n\t"
"punpcklwd %%mm5, %%mm5 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %0), %%mm0 \n\t"
"movq 8(%1, %0), %%mm1 \n\t"
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_mmx_rnd_template.c b/lib/ffmpeg/libavcodec/x86/dsputil_mmx_rnd_template.c
index 2fc1756f60..e4c91381fa 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputil_mmx_rnd_template.c
+++ b/lib/ffmpeg/libavcodec/x86/dsputil_mmx_rnd_template.c
@@ -30,7 +30,7 @@ static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line
MOVQ_BFE(mm6);
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm1 \n\t"
@@ -71,7 +71,7 @@ static void av_unused DEF(put, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t
"movq %%mm4, (%3) \n\t"
"add %5, %3 \n\t"
"decl %0 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%2), %%mm1 \n\t"
@@ -112,7 +112,7 @@ static void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, int lin
MOVQ_BFE(mm6);
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm1 \n\t"
@@ -170,7 +170,7 @@ static void av_unused DEF(put, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t
"movq %%mm5, 8(%3) \n\t"
"add %5, %3 \n\t"
"decl %0 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%2), %%mm1 \n\t"
@@ -208,7 +208,7 @@ static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
"movq (%1), %%mm0 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq (%1, %%"REG_a"),%%mm2 \n\t"
@@ -248,7 +248,7 @@ static void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int lin
"paddusw %%mm1, %%mm5 \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
"add %3, %1 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
@@ -460,7 +460,7 @@ static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line
__asm__ volatile(
"lea (%3, %3), %%"REG_a" \n\t"
"movq (%1), %%mm0 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq (%1, %%"REG_a"), %%mm2 \n\t"
@@ -511,7 +511,7 @@ static void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int lin
"paddusw %%mm1, %%mm5 \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
"add %3, %1 \n\t"
- ASMALIGN(3)
+ ".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
diff --git a/lib/ffmpeg/libavcodec/x86/dsputil_yasm.asm b/lib/ffmpeg/libavcodec/x86/dsputil_yasm.asm
index bda04727db..b1b37e1fb9 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputil_yasm.asm
+++ b/lib/ffmpeg/libavcodec/x86/dsputil_yasm.asm
@@ -30,75 +30,6 @@ pb_zz11zz55zz99zzdd: db -1,-1,1,1,-1,-1,5,5,-1,-1,9,9,-1,-1,13,13
section .text align=16
-%macro PSWAPD_SSE 2
- pshufw %1, %2, 0x4e
-%endmacro
-%macro PSWAPD_3DN1 2
- movq %1, %2
- psrlq %1, 32
- punpckldq %1, %2
-%endmacro
-
-%macro FLOAT_TO_INT16_INTERLEAVE6 1
-; 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
- mov lend, r2d
-%else
- %define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
-.loop:
- cvtps2pi mm0, [srcq]
- cvtps2pi mm1, [srcq+src1q]
- cvtps2pi mm2, [srcq+src2q]
- cvtps2pi mm3, [srcq+src3q]
- cvtps2pi mm4, [srcq+src4q]
- cvtps2pi mm5, [srcq+src5q]
- packssdw mm0, mm3
- packssdw mm1, mm4
- packssdw mm2, mm5
- pswapd mm3, mm0
- punpcklwd mm0, mm1
- punpckhwd mm1, mm2
- punpcklwd mm2, mm3
- pswapd mm3, mm0
- punpckldq mm0, mm2
- punpckhdq mm2, mm1
- punpckldq mm1, mm3
- movq [dstq ], mm0
- movq [dstq+16], mm2
- movq [dstq+ 8], mm1
- add srcq, 8
- add dstq, 24
- sub lend, 2
- jg .loop
- emms
- RET
-%endmacro ; FLOAT_TO_INT16_INTERLEAVE6
-
-%define pswapd PSWAPD_SSE
-FLOAT_TO_INT16_INTERLEAVE6 sse
-%define cvtps2pi pf2id
-%define pswapd PSWAPD_3DN1
-FLOAT_TO_INT16_INTERLEAVE6 3dnow
-%undef pswapd
-FLOAT_TO_INT16_INTERLEAVE6 3dn2
-%undef cvtps2pi
-
-
-
%macro SCALARPRODUCT 1
; int scalarproduct_int16(int16_t *v1, int16_t *v2, int order, int shift)
cglobal scalarproduct_int16_%1, 3,3,4, v1, v2, order, shift
@@ -421,3 +352,563 @@ cglobal scalarproduct_float_sse, 3,3,2, v1, v2, offset
fld dword r0m
%endif
RET
+
+; extern void ff_emu_edge_core(uint8_t *buf, const uint8_t *src, x86_reg linesize,
+; x86_reg start_y, x86_reg end_y, x86_reg block_h,
+; x86_reg start_x, x86_reg end_x, x86_reg block_w);
+;
+; The actual function itself is below. It basically wraps a very simple
+; w = end_x - start_x
+; if (w) {
+; if (w > 22) {
+; jump to the slow loop functions
+; } else {
+; jump to the fast loop functions
+; }
+; }
+;
+; ... and then the same for left/right extend also. See below for loop
+; function implementations. Fast are fixed-width, slow is variable-width
+
+%macro EMU_EDGE_FUNC 1
+%ifdef ARCH_X86_64
+%define w_reg r10
+cglobal emu_edge_core_%1, 6, 7, 1
+ mov r11, r5 ; save block_h
+%else
+%define w_reg r6
+cglobal emu_edge_core_%1, 2, 7, 0
+ mov r4, r4m ; end_y
+ mov r5, r5m ; block_h
+%endif
+
+ ; start with vertical extend (top/bottom) and body pixel copy
+ mov w_reg, r7m
+ sub w_reg, r6m ; w = start_x - end_x
+ sub r5, r4
+%ifdef ARCH_X86_64
+ sub r4, r3
+%else
+ sub r4, dword r3m
+%endif
+ cmp w_reg, 22
+ jg .slow_v_extend_loop
+%ifdef ARCH_X86_32
+ mov r2, r2m ; linesize
+%endif
+ sal w_reg, 7 ; w * 128
+%ifdef PIC
+ lea rax, [.emuedge_v_extend_1 - (.emuedge_v_extend_2 - .emuedge_v_extend_1)]
+ add w_reg, rax
+%else
+ lea w_reg, [.emuedge_v_extend_1 - (.emuedge_v_extend_2 - .emuedge_v_extend_1)+w_reg]
+%endif
+ call w_reg ; fast top extend, body copy and bottom extend
+.v_extend_end:
+
+ ; horizontal extend (left/right)
+ mov w_reg, r6m ; start_x
+ sub r0, w_reg
+%ifdef ARCH_X86_64
+ mov r3, r0 ; backup of buf+block_h*linesize
+ mov r5, r11
+%else
+ mov r0m, r0 ; backup of buf+block_h*linesize
+ mov r5, r5m
+%endif
+ test w_reg, w_reg
+ jz .right_extend
+ cmp w_reg, 22
+ jg .slow_left_extend_loop
+ mov r1, w_reg
+ dec w_reg
+ ; FIXME we can do a if size == 1 here if that makes any speed difference, test me
+ sar w_reg, 1
+ sal w_reg, 6
+ ; r0=buf+block_h*linesize,r10(64)/r6(32)=start_x offset for funcs
+ ; r6(rax)/r3(ebx)=val,r2=linesize,r1=start_x,r5=block_h
+%ifdef PIC
+ lea rax, [.emuedge_extend_left_2]
+ add w_reg, rax
+%else
+ lea w_reg, [.emuedge_extend_left_2+w_reg]
+%endif
+ call w_reg
+
+ ; now r3(64)/r0(32)=buf,r2=linesize,r11/r5=block_h,r6/r3=val, r10/r6=end_x, r1=block_w
+.right_extend:
+%ifdef ARCH_X86_32
+ mov r0, r0m
+ mov r5, r5m
+%endif
+ mov w_reg, r7m ; end_x
+ mov r1, r8m ; block_w
+ mov r4, r1
+ sub r1, w_reg
+ jz .h_extend_end ; if (end_x == block_w) goto h_extend_end
+ cmp r1, 22
+ jg .slow_right_extend_loop
+ dec r1
+ ; FIXME we can do a if size == 1 here if that makes any speed difference, test me
+ sar r1, 1
+ sal r1, 6
+%ifdef PIC
+ lea rax, [.emuedge_extend_right_2]
+ add r1, rax
+%else
+ lea r1, [.emuedge_extend_right_2+r1]
+%endif
+ call r1
+.h_extend_end:
+ RET
+
+%ifdef ARCH_X86_64
+%define vall al
+%define valh ah
+%define valw ax
+%define valw2 r10w
+%define valw3 r3w
+%define vald eax
+%else
+%define vall bl
+%define valh bh
+%define valw bx
+%define valw2 r6w
+%define valw3 valw2
+%define vald ebx
+%define stack_offset 0x14
+%endif
+
+%endmacro
+
+; macro to read/write a horizontal number of pixels (%2) to/from registers
+; on x86-64, - fills xmm0-15 for consecutive sets of 16 pixels
+; - if (%2 & 15 == 8) fills the last 8 bytes into rax
+; - else if (%2 & 8) fills 8 bytes into mm0
+; - if (%2 & 7 == 4) fills the last 4 bytes into rax
+; - else if (%2 & 4) fills 4 bytes into mm0-1
+; - if (%2 & 3 == 3) fills 2 bytes into r10/r3, and 1 into eax
+; (note that we're using r3 for body/bottom because it's a shorter
+; opcode, and then the loop fits in 128 bytes)
+; - else fills remaining bytes into rax
+; on x86-32, - fills mm0-7 for consecutive sets of 8 pixels
+; - if (%2 & 7 == 4) fills 4 bytes into ebx
+; - else if (%2 & 4) fills 4 bytes into mm0-7
+; - if (%2 & 3 == 3) fills 2 bytes into r6, and 1 into ebx
+; - else fills remaining bytes into ebx
+; writing data out is in the same way
+%macro READ_NUM_BYTES 3
+%assign %%src_off 0 ; offset in source buffer
+%assign %%smidx 0 ; mmx register idx
+%assign %%sxidx 0 ; xmm register idx
+
+%ifnidn %3, mmx
+%rep %2/16
+ movdqu xmm %+ %%sxidx, [r1+%%src_off]
+%assign %%src_off %%src_off+16
+%assign %%sxidx %%sxidx+1
+%endrep ; %2/16
+%endif ; !mmx
+
+%ifdef ARCH_X86_64
+%if (%2-%%src_off) == 8
+ mov rax, [r1+%%src_off]
+%assign %%src_off %%src_off+8
+%endif ; (%2-%%src_off) == 8
+%endif ; x86-64
+
+%rep (%2-%%src_off)/8
+ movq mm %+ %%smidx, [r1+%%src_off]
+%assign %%src_off %%src_off+8
+%assign %%smidx %%smidx+1
+%endrep ; (%2-%%dst_off)/8
+
+%if (%2-%%src_off) == 4
+ mov vald, [r1+%%src_off]
+%elif (%2-%%src_off) & 4
+ movd mm %+ %%smidx, [r1+%%src_off]
+%assign %%src_off %%src_off+4
+%endif ; (%2-%%src_off) ==/& 4
+
+%if (%2-%%src_off) == 1
+ mov vall, [r1+%%src_off]
+%elif (%2-%%src_off) == 2
+ mov valw, [r1+%%src_off]
+%elif (%2-%%src_off) == 3
+%ifidn %1, top
+ mov valw2, [r1+%%src_off]
+%else ; %1 != top
+ mov valw3, [r1+%%src_off]
+%endif ; %1 ==/!= top
+ mov vall, [r1+%%src_off+2]
+%endif ; (%2-%%src_off) == 1/2/3
+%endmacro ; READ_NUM_BYTES
+
+%macro WRITE_NUM_BYTES 3
+%assign %%dst_off 0 ; offset in destination buffer
+%assign %%dmidx 0 ; mmx register idx
+%assign %%dxidx 0 ; xmm register idx
+
+%ifnidn %3, mmx
+%rep %2/16
+ movdqu [r0+%%dst_off], xmm %+ %%dxidx
+%assign %%dst_off %%dst_off+16
+%assign %%dxidx %%dxidx+1
+%endrep ; %2/16
+%endif
+
+%ifdef ARCH_X86_64
+%if (%2-%%dst_off) == 8
+ mov [r0+%%dst_off], rax
+%assign %%dst_off %%dst_off+8
+%endif ; (%2-%%dst_off) == 8
+%endif ; x86-64
+
+%rep (%2-%%dst_off)/8
+ movq [r0+%%dst_off], mm %+ %%dmidx
+%assign %%dst_off %%dst_off+8
+%assign %%dmidx %%dmidx+1
+%endrep ; (%2-%%dst_off)/8
+
+%if (%2-%%dst_off) == 4
+ mov [r0+%%dst_off], vald
+%elif (%2-%%dst_off) & 4
+ movd [r0+%%dst_off], mm %+ %%dmidx
+%assign %%dst_off %%dst_off+4
+%endif ; (%2-%%dst_off) ==/& 4
+
+%if (%2-%%dst_off) == 1
+ mov [r0+%%dst_off], vall
+%elif (%2-%%dst_off) == 2
+ mov [r0+%%dst_off], valw
+%elif (%2-%%dst_off) == 3
+%ifidn %1, top
+ mov [r0+%%dst_off], valw2
+%else ; %1 != top
+ mov [r0+%%dst_off], valw3
+%endif ; %1 ==/!= top
+ mov [r0+%%dst_off+2], vall
+%endif ; (%2-%%dst_off) == 1/2/3
+%endmacro ; WRITE_NUM_BYTES
+
+; vertical top/bottom extend and body copy fast loops
+; these are function pointers to set-width line copy functions, i.e.
+; they read a fixed number of pixels into set registers, and write
+; those out into the destination buffer
+; r0=buf,r1=src,r2=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h
+; r6(eax/64)/r3(ebx/32)=val_reg
+%macro VERTICAL_EXTEND 1
+%assign %%n 1
+%rep 22
+ALIGN 128
+.emuedge_v_extend_ %+ %%n:
+ ; extend pixels above body
+%ifdef ARCH_X86_64
+ test r3 , r3 ; if (!start_y)
+ jz .emuedge_copy_body_ %+ %%n %+ _loop ; goto body
+%else ; ARCH_X86_32
+ cmp dword r3m, 0
+ je .emuedge_copy_body_ %+ %%n %+ _loop
+%endif ; ARCH_X86_64/32
+ READ_NUM_BYTES top, %%n, %1 ; read bytes
+.emuedge_extend_top_ %+ %%n %+ _loop: ; do {
+ WRITE_NUM_BYTES top, %%n, %1 ; write bytes
+ add r0 , r2 ; dst += linesize
+%ifdef ARCH_X86_64
+ dec r3
+%else ; ARCH_X86_32
+ dec dword r3m
+%endif ; ARCH_X86_64/32
+ jnz .emuedge_extend_top_ %+ %%n %+ _loop ; } while (--start_y)
+
+ ; copy body pixels
+.emuedge_copy_body_ %+ %%n %+ _loop: ; do {
+ READ_NUM_BYTES body, %%n, %1 ; read bytes
+ WRITE_NUM_BYTES body, %%n, %1 ; write bytes
+ add r0 , r2 ; dst += linesize
+ add r1 , r2 ; src += linesize
+ dec r4
+ jnz .emuedge_copy_body_ %+ %%n %+ _loop ; } while (--end_y)
+
+ ; copy bottom pixels
+ test r5 , r5 ; if (!block_h)
+ jz .emuedge_v_extend_end_ %+ %%n ; goto end
+ sub r1 , r2 ; src -= linesize
+ READ_NUM_BYTES bottom, %%n, %1 ; read bytes
+.emuedge_extend_bottom_ %+ %%n %+ _loop: ; do {
+ WRITE_NUM_BYTES bottom, %%n, %1 ; write bytes
+ add r0 , r2 ; dst += linesize
+ dec r5
+ jnz .emuedge_extend_bottom_ %+ %%n %+ _loop ; } while (--block_h)
+
+.emuedge_v_extend_end_ %+ %%n:
+%ifdef ARCH_X86_64
+ ret
+%else ; ARCH_X86_32
+ rep ret
+%endif ; ARCH_X86_64/32
+%assign %%n %%n+1
+%endrep
+%endmacro VERTICAL_EXTEND
+
+; left/right (horizontal) fast extend functions
+; these are essentially identical to the vertical extend ones above,
+; just left/right separated because number of pixels to extend is
+; obviously not the same on both sides.
+; for reading, pixels are placed in eax (x86-64) or ebx (x86-64) in the
+; lowest two bytes of the register (so val*0x0101), and are splatted
+; into each byte of mm0 as well if n_pixels >= 8
+
+%macro READ_V_PIXEL 3
+ mov vall, %2
+ mov valh, vall
+%if %1 >= 8
+ movd mm0, vald
+%ifidn %3, mmx
+ punpcklwd mm0, mm0
+ punpckldq mm0, mm0
+%else ; !mmx
+ pshufw mm0, mm0, 0
+%endif ; mmx
+%endif ; %1 >= 8
+%endmacro
+
+%macro WRITE_V_PIXEL 2
+%assign %%dst_off 0
+%rep %1/8
+ movq [%2+%%dst_off], mm0
+%assign %%dst_off %%dst_off+8
+%endrep
+%if %1 & 4
+%if %1 >= 8
+ movd [%2+%%dst_off], mm0
+%else ; %1 < 8
+ mov [%2+%%dst_off] , valw
+ mov [%2+%%dst_off+2], valw
+%endif ; %1 >=/< 8
+%assign %%dst_off %%dst_off+4
+%endif ; %1 & 4
+%if %1&2
+ mov [%2+%%dst_off], valw
+%endif ; %1 & 2
+%endmacro
+
+; r0=buf+block_h*linesize, r1=start_x, r2=linesize, r5=block_h, r6/r3=val
+%macro LEFT_EXTEND 1
+%assign %%n 2
+%rep 11
+ALIGN 64
+.emuedge_extend_left_ %+ %%n: ; do {
+ sub r0, r2 ; dst -= linesize
+ READ_V_PIXEL %%n, [r0+r1], %1 ; read pixels
+ WRITE_V_PIXEL %%n, r0 ; write pixels
+ dec r5
+ jnz .emuedge_extend_left_ %+ %%n ; } while (--block_h)
+%ifdef ARCH_X86_64
+ ret
+%else ; ARCH_X86_32
+ rep ret
+%endif ; ARCH_X86_64/32
+%assign %%n %%n+2
+%endrep
+%endmacro ; LEFT_EXTEND
+
+; r3/r0=buf+block_h*linesize, r2=linesize, r11/r5=block_h, r0/r6=end_x, r6/r3=val
+%macro RIGHT_EXTEND 1
+%assign %%n 2
+%rep 11
+ALIGN 64
+.emuedge_extend_right_ %+ %%n: ; do {
+%ifdef ARCH_X86_64
+ sub r3, r2 ; dst -= linesize
+ READ_V_PIXEL %%n, [r3+w_reg-1], %1 ; read pixels
+ WRITE_V_PIXEL %%n, r3+r4-%%n ; write pixels
+ dec r11
+%else ; ARCH_X86_32
+ sub r0, r2 ; dst -= linesize
+ READ_V_PIXEL %%n, [r0+w_reg-1], %1 ; read pixels
+ WRITE_V_PIXEL %%n, r0+r4-%%n ; write pixels
+ dec r5
+%endif ; ARCH_X86_64/32
+ jnz .emuedge_extend_right_ %+ %%n ; } while (--block_h)
+%ifdef ARCH_X86_64
+ ret
+%else ; ARCH_X86_32
+ rep ret
+%endif ; ARCH_X86_64/32
+%assign %%n %%n+2
+%endrep
+
+%ifdef ARCH_X86_32
+%define stack_offset 0x10
+%endif
+%endmacro ; RIGHT_EXTEND
+
+; below follow the "slow" copy/extend functions, these act on a non-fixed
+; width specified in a register, and run a loop to copy the full amount
+; of bytes. They are optimized for copying of large amounts of pixels per
+; line, so they unconditionally splat data into mm registers to copy 8
+; bytes per loop iteration. It could be considered to use xmm for x86-64
+; also, but I haven't optimized this as much (i.e. FIXME)
+%macro V_COPY_NPX 4-5
+%if %0 == 4
+ test w_reg, %4
+ jz .%1_skip_%4_px
+%else ; %0 == 5
+.%1_%4_px_loop:
+%endif
+ %3 %2, [r1+cnt_reg]
+ %3 [r0+cnt_reg], %2
+ add cnt_reg, %4
+%if %0 == 5
+ sub w_reg, %4
+ test w_reg, %5
+ jnz .%1_%4_px_loop
+%endif
+.%1_skip_%4_px:
+%endmacro
+
+%macro V_COPY_ROW 3
+%ifidn %1, bottom
+ sub r1, linesize
+%endif
+.%1_copy_loop:
+ xor cnt_reg, cnt_reg
+%ifidn %3, mmx
+%define linesize r2m
+ V_COPY_NPX %1, mm0, movq, 8, 0xFFFFFFF8
+%else ; !mmx
+ V_COPY_NPX %1, xmm0, movdqu, 16, 0xFFFFFFF0
+%ifdef ARCH_X86_64
+%define linesize r2
+ V_COPY_NPX %1, rax , mov, 8
+%else ; ARCH_X86_32
+%define linesize r2m
+ V_COPY_NPX %1, mm0, movq, 8
+%endif ; ARCH_X86_64/32
+%endif ; mmx
+ V_COPY_NPX %1, vald, mov, 4
+ V_COPY_NPX %1, valw, mov, 2
+ V_COPY_NPX %1, vall, mov, 1
+ mov w_reg, cnt_reg
+%ifidn %1, body
+ add r1, linesize
+%endif
+ add r0, linesize
+ dec %2
+ jnz .%1_copy_loop
+%endmacro
+
+%macro SLOW_V_EXTEND 1
+.slow_v_extend_loop:
+; r0=buf,r1=src,r2(64)/r2m(32)=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h
+; r11(64)/r3(later-64)/r2(32)=cnt_reg,r6(64)/r3(32)=val_reg,r10(64)/r6(32)=w=end_x-start_x
+%ifdef ARCH_X86_64
+ push r11 ; save old value of block_h
+ test r3, r3
+%define cnt_reg r11
+ jz .do_body_copy ; if (!start_y) goto do_body_copy
+ V_COPY_ROW top, r3, %1
+%else
+ cmp dword r3m, 0
+%define cnt_reg r2
+ je .do_body_copy ; if (!start_y) goto do_body_copy
+ V_COPY_ROW top, dword r3m, %1
+%endif
+
+.do_body_copy:
+ V_COPY_ROW body, r4, %1
+
+%ifdef ARCH_X86_64
+ pop r11 ; restore old value of block_h
+%define cnt_reg r3
+%endif
+ test r5, r5
+%ifdef ARCH_X86_64
+ jz .v_extend_end
+%else
+ jz .skip_bottom_extend
+%endif
+ V_COPY_ROW bottom, r5, %1
+%ifdef ARCH_X86_32
+.skip_bottom_extend:
+ mov r2, r2m
+%endif
+ jmp .v_extend_end
+%endmacro
+
+%macro SLOW_LEFT_EXTEND 1
+.slow_left_extend_loop:
+; r0=buf+block_h*linesize,r2=linesize,r6(64)/r3(32)=val,r5=block_h,r4=cntr,r10/r6=start_x
+ mov r4, 8
+ sub r0, linesize
+ READ_V_PIXEL 8, [r0+w_reg], %1
+.left_extend_8px_loop:
+ movq [r0+r4-8], mm0
+ add r4, 8
+ cmp r4, w_reg
+ jle .left_extend_8px_loop
+ sub r4, 8
+ cmp r4, w_reg
+ jge .left_extend_loop_end
+.left_extend_2px_loop:
+ mov [r0+r4], valw
+ add r4, 2
+ cmp r4, w_reg
+ jl .left_extend_2px_loop
+.left_extend_loop_end:
+ dec r5
+ jnz .slow_left_extend_loop
+%ifdef ARCH_X86_32
+ mov r2, r2m
+%endif
+ jmp .right_extend
+%endmacro
+
+%macro SLOW_RIGHT_EXTEND 1
+.slow_right_extend_loop:
+; r3(64)/r0(32)=buf+block_h*linesize,r2=linesize,r4=block_w,r11(64)/r5(32)=block_h,
+; r10(64)/r6(32)=end_x,r6/r3=val,r1=cntr
+%ifdef ARCH_X86_64
+%define buf_reg r3
+%define bh_reg r11
+%else
+%define buf_reg r0
+%define bh_reg r5
+%endif
+ lea r1, [r4-8]
+ sub buf_reg, linesize
+ READ_V_PIXEL 8, [buf_reg+w_reg-1], %1
+.right_extend_8px_loop:
+ movq [buf_reg+r1], mm0
+ sub r1, 8
+ cmp r1, w_reg
+ jge .right_extend_8px_loop
+ add r1, 8
+ cmp r1, w_reg
+ je .right_extend_loop_end
+.right_extend_2px_loop:
+ sub r1, 2
+ mov [buf_reg+r1], valw
+ cmp r1, w_reg
+ jg .right_extend_2px_loop
+.right_extend_loop_end:
+ dec bh_reg
+ jnz .slow_right_extend_loop
+ jmp .h_extend_end
+%endmacro
+
+%macro emu_edge 1
+EMU_EDGE_FUNC %1
+VERTICAL_EXTEND %1
+LEFT_EXTEND %1
+RIGHT_EXTEND %1
+SLOW_V_EXTEND %1
+SLOW_LEFT_EXTEND %1
+SLOW_RIGHT_EXTEND %1
+%endmacro
+
+emu_edge sse
+%ifdef ARCH_X86_32
+emu_edge mmx
+%endif
diff --git a/lib/ffmpeg/libavcodec/x86/dsputilenc_mmx.c b/lib/ffmpeg/libavcodec/x86/dsputilenc_mmx.c
index f491111ca5..bd31205a6b 100644
--- a/lib/ffmpeg/libavcodec/x86/dsputilenc_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/dsputilenc_mmx.c
@@ -22,6 +22,7 @@
* MMX optimization by Nick Kurshev <nickols_k@mail.ru>
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h"
#include "libavcodec/mpegvideo.h"
@@ -34,7 +35,7 @@ static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
__asm__ volatile(
"mov $-128, %%"REG_a" \n\t"
"pxor %%mm7, %%mm7 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0), %%mm0 \n\t"
"movq (%0, %2), %%mm2 \n\t"
@@ -60,16 +61,16 @@ static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
static void get_pixels_sse2(DCTELEM *block, const uint8_t *pixels, int line_size)
{
__asm__ volatile(
- "pxor %%xmm7, %%xmm7 \n\t"
+ "pxor %%xmm4, %%xmm4 \n\t"
"movq (%0), %%xmm0 \n\t"
"movq (%0, %2), %%xmm1 \n\t"
"movq (%0, %2,2), %%xmm2 \n\t"
"movq (%0, %3), %%xmm3 \n\t"
"lea (%0,%2,4), %0 \n\t"
- "punpcklbw %%xmm7, %%xmm0 \n\t"
- "punpcklbw %%xmm7, %%xmm1 \n\t"
- "punpcklbw %%xmm7, %%xmm2 \n\t"
- "punpcklbw %%xmm7, %%xmm3 \n\t"
+ "punpcklbw %%xmm4, %%xmm0 \n\t"
+ "punpcklbw %%xmm4, %%xmm1 \n\t"
+ "punpcklbw %%xmm4, %%xmm2 \n\t"
+ "punpcklbw %%xmm4, %%xmm3 \n\t"
"movdqa %%xmm0, (%1) \n\t"
"movdqa %%xmm1, 16(%1) \n\t"
"movdqa %%xmm2, 32(%1) \n\t"
@@ -78,10 +79,10 @@ static void get_pixels_sse2(DCTELEM *block, const uint8_t *pixels, int line_size
"movq (%0, %2), %%xmm1 \n\t"
"movq (%0, %2,2), %%xmm2 \n\t"
"movq (%0, %3), %%xmm3 \n\t"
- "punpcklbw %%xmm7, %%xmm0 \n\t"
- "punpcklbw %%xmm7, %%xmm1 \n\t"
- "punpcklbw %%xmm7, %%xmm2 \n\t"
- "punpcklbw %%xmm7, %%xmm3 \n\t"
+ "punpcklbw %%xmm4, %%xmm0 \n\t"
+ "punpcklbw %%xmm4, %%xmm1 \n\t"
+ "punpcklbw %%xmm4, %%xmm2 \n\t"
+ "punpcklbw %%xmm4, %%xmm3 \n\t"
"movdqa %%xmm0, 64(%1) \n\t"
"movdqa %%xmm1, 80(%1) \n\t"
"movdqa %%xmm2, 96(%1) \n\t"
@@ -96,7 +97,7 @@ static inline void diff_pixels_mmx(DCTELEM *block, const uint8_t *s1, const uint
__asm__ volatile(
"pxor %%mm7, %%mm7 \n\t"
"mov $-128, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0), %%mm0 \n\t"
"movq (%1), %%mm2 \n\t"
@@ -322,67 +323,7 @@ static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int
return tmp;
}
-static int sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
- int tmp;
- __asm__ volatile (
- "shr $1,%2\n"
- "pxor %%xmm0,%%xmm0\n" /* mm0 = 0 */
- "pxor %%xmm7,%%xmm7\n" /* mm7 holds the sum */
- "1:\n"
- "movdqu (%0),%%xmm1\n" /* mm1 = pix1[0][0-15] */
- "movdqu (%1),%%xmm2\n" /* mm2 = pix2[0][0-15] */
- "movdqu (%0,%4),%%xmm3\n" /* mm3 = pix1[1][0-15] */
- "movdqu (%1,%4),%%xmm4\n" /* mm4 = pix2[1][0-15] */
-
- /* todo: mm1-mm2, mm3-mm4 */
- /* algo: subtract mm1 from mm2 with saturation and vice versa */
- /* OR the results to get absolute difference */
- "movdqa %%xmm1,%%xmm5\n"
- "movdqa %%xmm3,%%xmm6\n"
- "psubusb %%xmm2,%%xmm1\n"
- "psubusb %%xmm4,%%xmm3\n"
- "psubusb %%xmm5,%%xmm2\n"
- "psubusb %%xmm6,%%xmm4\n"
-
- "por %%xmm1,%%xmm2\n"
- "por %%xmm3,%%xmm4\n"
-
- /* now convert to 16-bit vectors so we can square them */
- "movdqa %%xmm2,%%xmm1\n"
- "movdqa %%xmm4,%%xmm3\n"
-
- "punpckhbw %%xmm0,%%xmm2\n"
- "punpckhbw %%xmm0,%%xmm4\n"
- "punpcklbw %%xmm0,%%xmm1\n" /* mm1 now spread over (mm1,mm2) */
- "punpcklbw %%xmm0,%%xmm3\n" /* mm4 now spread over (mm3,mm4) */
-
- "pmaddwd %%xmm2,%%xmm2\n"
- "pmaddwd %%xmm4,%%xmm4\n"
- "pmaddwd %%xmm1,%%xmm1\n"
- "pmaddwd %%xmm3,%%xmm3\n"
-
- "lea (%0,%4,2), %0\n" /* pix1 += 2*line_size */
- "lea (%1,%4,2), %1\n" /* pix2 += 2*line_size */
-
- "paddd %%xmm2,%%xmm1\n"
- "paddd %%xmm4,%%xmm3\n"
- "paddd %%xmm1,%%xmm7\n"
- "paddd %%xmm3,%%xmm7\n"
-
- "decl %2\n"
- "jnz 1b\n"
-
- "movdqa %%xmm7,%%xmm1\n"
- "psrldq $8, %%xmm7\n" /* shift hi qword to lo */
- "paddd %%xmm1,%%xmm7\n"
- "movdqa %%xmm7,%%xmm1\n"
- "psrldq $4, %%xmm7\n" /* shift hi dword to lo */
- "paddd %%xmm1,%%xmm7\n"
- "movd %%xmm7,%3\n"
- : "+r" (pix1), "+r" (pix2), "+r"(h), "=r"(tmp)
- : "r" ((x86_reg)line_size));
- return tmp;
-}
+int ff_sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h);
static int hf_noise8_mmx(uint8_t * pix1, int line_size, int h) {
int tmp;
@@ -938,55 +879,6 @@ static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *src1, c
*left = src2[w-1];
}
-#define DIFF_PIXELS_1(m,a,t,p1,p2)\
- "mov"#m" "#p1", "#a" \n\t"\
- "mov"#m" "#p2", "#t" \n\t"\
- "punpcklbw "#a", "#t" \n\t"\
- "punpcklbw "#a", "#a" \n\t"\
- "psubw "#t", "#a" \n\t"\
-
-#define DIFF_PIXELS_8(m0,m1,mm,p1,p2,stride,temp) {\
- uint8_t *p1b=p1, *p2b=p2;\
- __asm__ volatile(\
- DIFF_PIXELS_1(m0, mm##0, mm##7, (%1), (%2))\
- DIFF_PIXELS_1(m0, mm##1, mm##7, (%1,%3), (%2,%3))\
- DIFF_PIXELS_1(m0, mm##2, mm##7, (%1,%3,2), (%2,%3,2))\
- "add %4, %1 \n\t"\
- "add %4, %2 \n\t"\
- DIFF_PIXELS_1(m0, mm##3, mm##7, (%1), (%2))\
- DIFF_PIXELS_1(m0, mm##4, mm##7, (%1,%3), (%2,%3))\
- DIFF_PIXELS_1(m0, mm##5, mm##7, (%1,%3,2), (%2,%3,2))\
- DIFF_PIXELS_1(m0, mm##6, mm##7, (%1,%4), (%2,%4))\
- "mov"#m1" "#mm"0, %0 \n\t"\
- DIFF_PIXELS_1(m0, mm##7, mm##0, (%1,%3,4), (%2,%3,4))\
- "mov"#m1" %0, "#mm"0 \n\t"\
- : "+m"(temp), "+r"(p1b), "+r"(p2b)\
- : "r"((x86_reg)stride), "r"((x86_reg)stride*3)\
- );\
-}
- //the "+m"(temp) is needed as gcc 2.95 sometimes fails to compile "=m"(temp)
-
-#define DIFF_PIXELS_4x8(p1,p2,stride,temp) DIFF_PIXELS_8(d, q, %%mm, p1, p2, stride, temp)
-#define DIFF_PIXELS_8x8(p1,p2,stride,temp) DIFF_PIXELS_8(q, dqa, %%xmm, p1, p2, stride, temp)
-
-#define LBUTTERFLY2(a1,b1,a2,b2)\
- "paddw " #b1 ", " #a1 " \n\t"\
- "paddw " #b2 ", " #a2 " \n\t"\
- "paddw " #b1 ", " #b1 " \n\t"\
- "paddw " #b2 ", " #b2 " \n\t"\
- "psubw " #a1 ", " #b1 " \n\t"\
- "psubw " #a2 ", " #b2 " \n\t"
-
-#define HADAMARD8(m0, m1, m2, m3, m4, m5, m6, m7)\
- LBUTTERFLY2(m0, m1, m2, m3)\
- LBUTTERFLY2(m4, m5, m6, m7)\
- LBUTTERFLY2(m0, m2, m1, m3)\
- LBUTTERFLY2(m4, m6, m5, m7)\
- LBUTTERFLY2(m0, m4, m1, m5)\
- LBUTTERFLY2(m2, m6, m3, m7)\
-
-#define HADAMARD48 HADAMARD8(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm6, %%mm7)
-
#define MMABS_MMX(a,z)\
"pxor " #z ", " #z " \n\t"\
"pcmpgtw " #a ", " #z " \n\t"\
@@ -1005,34 +897,6 @@ static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *src1, c
MMABS(a,z)\
"paddusw " #a ", " #sum " \n\t"
-#define MMABS_SUM_8x8_NOSPILL\
- MMABS(%%xmm0, %%xmm8)\
- MMABS(%%xmm1, %%xmm9)\
- MMABS_SUM(%%xmm2, %%xmm8, %%xmm0)\
- MMABS_SUM(%%xmm3, %%xmm9, %%xmm1)\
- MMABS_SUM(%%xmm4, %%xmm8, %%xmm0)\
- MMABS_SUM(%%xmm5, %%xmm9, %%xmm1)\
- MMABS_SUM(%%xmm6, %%xmm8, %%xmm0)\
- MMABS_SUM(%%xmm7, %%xmm9, %%xmm1)\
- "paddusw %%xmm1, %%xmm0 \n\t"
-
-#if ARCH_X86_64
-#define MMABS_SUM_8x8_SSE2 MMABS_SUM_8x8_NOSPILL
-#else
-#define MMABS_SUM_8x8_SSE2\
- "movdqa %%xmm7, (%1) \n\t"\
- MMABS(%%xmm0, %%xmm7)\
- MMABS(%%xmm1, %%xmm7)\
- MMABS_SUM(%%xmm2, %%xmm7, %%xmm0)\
- MMABS_SUM(%%xmm3, %%xmm7, %%xmm1)\
- MMABS_SUM(%%xmm4, %%xmm7, %%xmm0)\
- MMABS_SUM(%%xmm5, %%xmm7, %%xmm1)\
- MMABS_SUM(%%xmm6, %%xmm7, %%xmm0)\
- "movdqa (%1), %%xmm2 \n\t"\
- MMABS_SUM(%%xmm2, %%xmm7, %%xmm1)\
- "paddusw %%xmm1, %%xmm0 \n\t"
-#endif
-
/* FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get up to
* about 100k on extreme inputs. But that's very unlikely to occur in natural video,
* and it's even more unlikely to not have any alternative mvs/modes with lower cost. */
@@ -1061,133 +925,16 @@ static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *src1, c
"paddusw "#t", "#a" \n\t"\
"movd "#a", "#dst" \n\t"\
-#define HADAMARD8_DIFF_MMX(cpu) \
-static int hadamard8_diff_##cpu(void *s, uint8_t *src1, uint8_t *src2, int stride, int h){\
- DECLARE_ALIGNED(8, uint64_t, temp)[13];\
- int sum;\
-\
- assert(h==8);\
-\
- DIFF_PIXELS_4x8(src1, src2, stride, temp[0]);\
-\
- __asm__ volatile(\
- HADAMARD48\
-\
- "movq %%mm7, 96(%1) \n\t"\
-\
- TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)\
- STORE4(8, 0(%1), %%mm0, %%mm3, %%mm7, %%mm2)\
-\
- "movq 96(%1), %%mm7 \n\t"\
- TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)\
- STORE4(8, 64(%1), %%mm4, %%mm7, %%mm0, %%mm6)\
-\
- : "=r" (sum)\
- : "r"(temp)\
- );\
-\
- DIFF_PIXELS_4x8(src1+4, src2+4, stride, temp[4]);\
-\
- __asm__ volatile(\
- HADAMARD48\
-\
- "movq %%mm7, 96(%1) \n\t"\
-\
- TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)\
- STORE4(8, 32(%1), %%mm0, %%mm3, %%mm7, %%mm2)\
-\
- "movq 96(%1), %%mm7 \n\t"\
- TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)\
- "movq %%mm7, %%mm5 \n\t"/*FIXME remove*/\
- "movq %%mm6, %%mm7 \n\t"\
- "movq %%mm0, %%mm6 \n\t"\
-\
- LOAD4(8, 64(%1), %%mm0, %%mm1, %%mm2, %%mm3)\
-\
- HADAMARD48\
- "movq %%mm7, 64(%1) \n\t"\
- MMABS(%%mm0, %%mm7)\
- MMABS(%%mm1, %%mm7)\
- MMABS_SUM(%%mm2, %%mm7, %%mm0)\
- MMABS_SUM(%%mm3, %%mm7, %%mm1)\
- MMABS_SUM(%%mm4, %%mm7, %%mm0)\
- MMABS_SUM(%%mm5, %%mm7, %%mm1)\
- MMABS_SUM(%%mm6, %%mm7, %%mm0)\
- "movq 64(%1), %%mm2 \n\t"\
- MMABS_SUM(%%mm2, %%mm7, %%mm1)\
- "paddusw %%mm1, %%mm0 \n\t"\
- "movq %%mm0, 64(%1) \n\t"\
-\
- LOAD4(8, 0(%1), %%mm0, %%mm1, %%mm2, %%mm3)\
- LOAD4(8, 32(%1), %%mm4, %%mm5, %%mm6, %%mm7)\
-\
- HADAMARD48\
- "movq %%mm7, (%1) \n\t"\
- MMABS(%%mm0, %%mm7)\
- MMABS(%%mm1, %%mm7)\
- MMABS_SUM(%%mm2, %%mm7, %%mm0)\
- MMABS_SUM(%%mm3, %%mm7, %%mm1)\
- MMABS_SUM(%%mm4, %%mm7, %%mm0)\
- MMABS_SUM(%%mm5, %%mm7, %%mm1)\
- MMABS_SUM(%%mm6, %%mm7, %%mm0)\
- "movq (%1), %%mm2 \n\t"\
- MMABS_SUM(%%mm2, %%mm7, %%mm1)\
- "paddusw 64(%1), %%mm0 \n\t"\
- "paddusw %%mm1, %%mm0 \n\t"\
-\
- HSUM(%%mm0, %%mm1, %0)\
-\
- : "=r" (sum)\
- : "r"(temp)\
- );\
- return sum&0xFFFF;\
-}\
-WRAPPER8_16_SQ(hadamard8_diff_##cpu, hadamard8_diff16_##cpu)
+#define hadamard_func(cpu) \
+int ff_hadamard8_diff_##cpu (void *s, uint8_t *src1, uint8_t *src2, \
+ int stride, int h); \
+int ff_hadamard8_diff16_##cpu(void *s, uint8_t *src1, uint8_t *src2, \
+ int stride, int h);
-#define HADAMARD8_DIFF_SSE2(cpu) \
-static int hadamard8_diff_##cpu(void *s, uint8_t *src1, uint8_t *src2, int stride, int h){\
- DECLARE_ALIGNED(16, uint64_t, temp)[4];\
- int sum;\
-\
- assert(h==8);\
-\
- DIFF_PIXELS_8x8(src1, src2, stride, temp[0]);\
-\
- __asm__ volatile(\
- HADAMARD8(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7)\
- TRANSPOSE8(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7, (%1))\
- HADAMARD8(%%xmm0, %%xmm5, %%xmm7, %%xmm3, %%xmm6, %%xmm4, %%xmm2, %%xmm1)\
- MMABS_SUM_8x8\
- HSUM_SSE2(%%xmm0, %%xmm1, %0)\
- : "=r" (sum)\
- : "r"(temp)\
- );\
- return sum&0xFFFF;\
-}\
-WRAPPER8_16_SQ(hadamard8_diff_##cpu, hadamard8_diff16_##cpu)
-
-#define MMABS(a,z) MMABS_MMX(a,z)
-#define HSUM(a,t,dst) HSUM_MMX(a,t,dst)
-HADAMARD8_DIFF_MMX(mmx)
-#undef MMABS
-#undef HSUM
-
-#define MMABS(a,z) MMABS_MMX2(a,z)
-#define MMABS_SUM_8x8 MMABS_SUM_8x8_SSE2
-#define HSUM(a,t,dst) HSUM_MMX2(a,t,dst)
-HADAMARD8_DIFF_MMX(mmx2)
-HADAMARD8_DIFF_SSE2(sse2)
-#undef MMABS
-#undef MMABS_SUM_8x8
-#undef HSUM
-
-#if HAVE_SSSE3
-#define MMABS(a,z) MMABS_SSSE3(a,z)
-#define MMABS_SUM_8x8 MMABS_SUM_8x8_NOSPILL
-HADAMARD8_DIFF_SSE2(ssse3)
-#undef MMABS
-#undef MMABS_SUM_8x8
-#endif
+hadamard_func(mmx)
+hadamard_func(mmx2)
+hadamard_func(sse2)
+hadamard_func(ssse3)
#define DCT_SAD4(m,mm,o)\
"mov"#m" "#o"+ 0(%1), "#mm"2 \n\t"\
@@ -1350,12 +1097,14 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
- if (mm_flags & FF_MM_MMX) {
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = avctx->dct_algo;
if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
- if(mm_flags & FF_MM_SSE2){
+ if(mm_flags & AV_CPU_FLAG_SSE2){
c->fdct = ff_fdct_sse2;
- }else if(mm_flags & FF_MM_MMX2){
+ }else if(mm_flags & AV_CPU_FLAG_MMX2){
c->fdct = ff_fdct_mmx2;
}else{
c->fdct = ff_fdct_mmx;
@@ -1369,11 +1118,13 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->diff_bytes= diff_bytes_mmx;
c->sum_abs_dctelem= sum_abs_dctelem_mmx;
- c->hadamard8_diff[0]= hadamard8_diff16_mmx;
- c->hadamard8_diff[1]= hadamard8_diff_mmx;
+#if HAVE_YASM
+ c->hadamard8_diff[0]= ff_hadamard8_diff16_mmx;
+ c->hadamard8_diff[1]= ff_hadamard8_diff_mmx;
+#endif
c->pix_norm1 = pix_norm1_mmx;
- c->sse[0] = (mm_flags & FF_MM_SSE2) ? sse16_sse2 : sse16_mmx;
+ c->sse[0] = (HAVE_YASM && mm_flags & AV_CPU_FLAG_SSE2) ? ff_sse16_sse2 : sse16_mmx;
c->sse[1] = sse8_mmx;
c->vsad[4]= vsad_intra16_mmx;
@@ -1391,10 +1142,12 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
- if (mm_flags & FF_MM_MMX2) {
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
c->sum_abs_dctelem= sum_abs_dctelem_mmx2;
- c->hadamard8_diff[0]= hadamard8_diff16_mmx2;
- c->hadamard8_diff[1]= hadamard8_diff_mmx2;
+#if HAVE_YASM
+ c->hadamard8_diff[0]= ff_hadamard8_diff16_mmx2;
+ c->hadamard8_diff[1]= ff_hadamard8_diff_mmx2;
+#endif
c->vsad[4]= vsad_intra16_mmx2;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
@@ -1404,29 +1157,30 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2;
}
- if(mm_flags & FF_MM_SSE2){
+ if(mm_flags & AV_CPU_FLAG_SSE2){
c->get_pixels = get_pixels_sse2;
c->sum_abs_dctelem= sum_abs_dctelem_sse2;
- c->hadamard8_diff[0]= hadamard8_diff16_sse2;
- c->hadamard8_diff[1]= hadamard8_diff_sse2;
-#if CONFIG_LPC
- c->lpc_compute_autocorr = ff_lpc_compute_autocorr_sse2;
+#if HAVE_YASM && HAVE_ALIGNED_STACK
+ c->hadamard8_diff[0]= ff_hadamard8_diff16_sse2;
+ c->hadamard8_diff[1]= ff_hadamard8_diff_sse2;
#endif
}
#if HAVE_SSSE3
- if(mm_flags & FF_MM_SSSE3){
+ if(mm_flags & AV_CPU_FLAG_SSSE3){
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_ssse3;
}
c->add_8x8basis= add_8x8basis_ssse3;
c->sum_abs_dctelem= sum_abs_dctelem_ssse3;
- c->hadamard8_diff[0]= hadamard8_diff16_ssse3;
- c->hadamard8_diff[1]= hadamard8_diff_ssse3;
+#if HAVE_YASM && HAVE_ALIGNED_STACK
+ c->hadamard8_diff[0]= ff_hadamard8_diff16_ssse3;
+ c->hadamard8_diff[1]= ff_hadamard8_diff_ssse3;
+#endif
}
#endif
- if(mm_flags & FF_MM_3DNOW){
+ if(mm_flags & AV_CPU_FLAG_3DNOW){
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_3dnow;
}
diff --git a/lib/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm b/lib/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm
new file mode 100644
index 0000000000..b2844a5c72
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm
@@ -0,0 +1,342 @@
+;*****************************************************************************
+;* MMX optimized DSP utils
+;*****************************************************************************
+;* Copyright (c) 2000, 2001 Fabrice Bellard
+;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;*****************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+SECTION .text
+
+%macro DIFF_PIXELS_1 4
+ movh %1, %3
+ movh %2, %4
+ punpcklbw %2, %1
+ punpcklbw %1, %1
+ psubw %1, %2
+%endmacro
+
+; %1=uint8_t *pix1, %2=uint8_t *pix2, %3=static offset, %4=stride, %5=stride*3
+; %6=temporary storage location
+; this macro requires $mmsize stack space (aligned) on %6 (except on SSE+x86-64)
+%macro DIFF_PIXELS_8 6
+ DIFF_PIXELS_1 m0, m7, [%1 +%3], [%2 +%3]
+ DIFF_PIXELS_1 m1, m7, [%1+%4 +%3], [%2+%4 +%3]
+ DIFF_PIXELS_1 m2, m7, [%1+%4*2+%3], [%2+%4*2+%3]
+ add %1, %5
+ add %2, %5
+ DIFF_PIXELS_1 m3, m7, [%1 +%3], [%2 +%3]
+ DIFF_PIXELS_1 m4, m7, [%1+%4 +%3], [%2+%4 +%3]
+ DIFF_PIXELS_1 m5, m7, [%1+%4*2+%3], [%2+%4*2+%3]
+ DIFF_PIXELS_1 m6, m7, [%1+%5 +%3], [%2+%5 +%3]
+%ifdef m8
+ DIFF_PIXELS_1 m7, m8, [%1+%4*4+%3], [%2+%4*4+%3]
+%else
+ mova [%6], m0
+ DIFF_PIXELS_1 m7, m0, [%1+%4*4+%3], [%2+%4*4+%3]
+ mova m0, [%6]
+%endif
+ sub %1, %5
+ sub %2, %5
+%endmacro
+
+%macro HADAMARD8 0
+ SUMSUB_BADC m0, m1, m2, m3
+ SUMSUB_BADC m4, m5, m6, m7
+ SUMSUB_BADC m0, m2, m1, m3
+ SUMSUB_BADC m4, m6, m5, m7
+ SUMSUB_BADC m0, m4, m1, m5
+ SUMSUB_BADC m2, m6, m3, m7
+%endmacro
+
+%macro ABS1_SUM 3
+ ABS1 %1, %2
+ paddusw %3, %1
+%endmacro
+
+%macro ABS2_SUM 6
+ ABS2 %1, %2, %3, %4
+ paddusw %5, %1
+ paddusw %6, %2
+%endmacro
+
+%macro ABS_SUM_8x8_64 1
+ ABS2 m0, m1, m8, m9
+ ABS2_SUM m2, m3, m8, m9, m0, m1
+ ABS2_SUM m4, m5, m8, m9, m0, m1
+ ABS2_SUM m6, m7, m8, m9, m0, m1
+ paddusw m0, m1
+%endmacro
+
+%macro ABS_SUM_8x8_32 1
+ mova [%1], m7
+ ABS1 m0, m7
+ ABS1 m1, m7
+ ABS1_SUM m2, m7, m0
+ ABS1_SUM m3, m7, m1
+ ABS1_SUM m4, m7, m0
+ ABS1_SUM m5, m7, m1
+ ABS1_SUM m6, m7, m0
+ mova m2, [%1]
+ ABS1_SUM m2, m7, m1
+ paddusw m0, m1
+%endmacro
+
+; FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get up to
+; about 100k on extreme inputs. But that's very unlikely to occur in natural video,
+; and it's even more unlikely to not have any alternative mvs/modes with lower cost.
+%macro HSUM_MMX 3
+ mova %2, %1
+ psrlq %1, 32
+ paddusw %1, %2
+ mova %2, %1
+ psrlq %1, 16
+ paddusw %1, %2
+ movd %3, %1
+%endmacro
+
+%macro HSUM_MMX2 3
+ pshufw %2, %1, 0xE
+ paddusw %1, %2
+ pshufw %2, %1, 0x1
+ paddusw %1, %2
+ movd %3, %1
+%endmacro
+
+%macro HSUM_SSE2 3
+ movhlps %2, %1
+ paddusw %1, %2
+ pshuflw %2, %1, 0xE
+ paddusw %1, %2
+ pshuflw %2, %1, 0x1
+ paddusw %1, %2
+ movd %3, %1
+%endmacro
+
+%macro STORE4 5
+ mova [%1+mmsize*0], %2
+ mova [%1+mmsize*1], %3
+ mova [%1+mmsize*2], %4
+ mova [%1+mmsize*3], %5
+%endmacro
+
+%macro LOAD4 5
+ mova %2, [%1+mmsize*0]
+ mova %3, [%1+mmsize*1]
+ mova %4, [%1+mmsize*2]
+ mova %5, [%1+mmsize*3]
+%endmacro
+
+%macro hadamard8_16_wrapper 3
+cglobal hadamard8_diff_%1, 4, 4, %2
+%ifndef m8
+ %assign pad %3*mmsize-(4+stack_offset&(mmsize-1))
+ SUB rsp, pad
+%endif
+ call hadamard8x8_diff_%1
+%ifndef m8
+ ADD rsp, pad
+%endif
+ RET
+
+cglobal hadamard8_diff16_%1, 5, 6, %2
+%ifndef m8
+ %assign pad %3*mmsize-(4+stack_offset&(mmsize-1))
+ SUB rsp, pad
+%endif
+
+ call hadamard8x8_diff_%1
+ mov r5d, eax
+
+ add r1, 8
+ add r2, 8
+ call hadamard8x8_diff_%1
+ add r5d, eax
+
+ cmp r4d, 16
+ jne .done
+
+ lea r1, [r1+r3*8-8]
+ lea r2, [r2+r3*8-8]
+ call hadamard8x8_diff_%1
+ add r5d, eax
+
+ add r1, 8
+ add r2, 8
+ call hadamard8x8_diff_%1
+ add r5d, eax
+
+.done
+ mov eax, r5d
+%ifndef m8
+ ADD rsp, pad
+%endif
+ RET
+%endmacro
+
+%macro HADAMARD8_DIFF_MMX 1
+ALIGN 16
+; int hadamard8_diff_##cpu(void *s, uint8_t *src1, uint8_t *src2,
+; int stride, int h)
+; r0 = void *s = unused, int h = unused (always 8)
+; note how r1, r2 and r3 are not clobbered in this function, so 16x16
+; can simply call this 2x2x (and that's why we access rsp+gprsize
+; everywhere, which is rsp of calling func
+hadamard8x8_diff_%1:
+ lea r0, [r3*3]
+
+ ; first 4x8 pixels
+ DIFF_PIXELS_8 r1, r2, 0, r3, r0, rsp+gprsize+0x60
+ HADAMARD8
+ mova [rsp+gprsize+0x60], m7
+ TRANSPOSE4x4W 0, 1, 2, 3, 7
+ STORE4 rsp+gprsize, m0, m1, m2, m3
+ mova m7, [rsp+gprsize+0x60]
+ TRANSPOSE4x4W 4, 5, 6, 7, 0
+ STORE4 rsp+gprsize+0x40, m4, m5, m6, m7
+
+ ; second 4x8 pixels
+ DIFF_PIXELS_8 r1, r2, 4, r3, r0, rsp+gprsize+0x60
+ HADAMARD8
+ mova [rsp+gprsize+0x60], m7
+ TRANSPOSE4x4W 0, 1, 2, 3, 7
+ STORE4 rsp+gprsize+0x20, m0, m1, m2, m3
+ mova m7, [rsp+gprsize+0x60]
+ TRANSPOSE4x4W 4, 5, 6, 7, 0
+
+ LOAD4 rsp+gprsize+0x40, m0, m1, m2, m3
+ HADAMARD8
+ ABS_SUM_8x8_32 rsp+gprsize+0x60
+ mova [rsp+gprsize+0x60], m0
+
+ LOAD4 rsp+gprsize , m0, m1, m2, m3
+ LOAD4 rsp+gprsize+0x20, m4, m5, m6, m7
+ HADAMARD8
+ ABS_SUM_8x8_32 rsp+gprsize
+ paddusw m0, [rsp+gprsize+0x60]
+
+ HSUM m0, m1, eax
+ and rax, 0xFFFF
+ ret
+
+hadamard8_16_wrapper %1, 0, 14
+%endmacro
+
+%macro HADAMARD8_DIFF_SSE2 2
+hadamard8x8_diff_%1:
+ lea r0, [r3*3]
+ DIFF_PIXELS_8 r1, r2, 0, r3, r0, rsp+gprsize
+ HADAMARD8
+%ifdef ARCH_X86_64
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
+%else
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, [rsp+gprsize], [rsp+mmsize+gprsize]
+%endif
+ HADAMARD8
+ ABS_SUM_8x8 rsp+gprsize
+ HSUM_SSE2 m0, m1, eax
+ and eax, 0xFFFF
+ ret
+
+hadamard8_16_wrapper %1, %2, 3
+%endmacro
+
+INIT_MMX
+%define ABS1 ABS1_MMX
+%define HSUM HSUM_MMX
+HADAMARD8_DIFF_MMX mmx
+
+%define ABS1 ABS1_MMX2
+%define HSUM HSUM_MMX2
+HADAMARD8_DIFF_MMX mmx2
+
+INIT_XMM
+%define ABS2 ABS2_MMX2
+%ifdef ARCH_X86_64
+%define ABS_SUM_8x8 ABS_SUM_8x8_64
+%else
+%define ABS_SUM_8x8 ABS_SUM_8x8_32
+%endif
+HADAMARD8_DIFF_SSE2 sse2, 10
+
+%define ABS2 ABS2_SSSE3
+%define ABS_SUM_8x8 ABS_SUM_8x8_64
+HADAMARD8_DIFF_SSE2 ssse3, 9
+
+INIT_XMM
+; sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+cglobal sse16_sse2, 5, 5, 8
+ shr r4d, 1
+ pxor m0, m0 ; mm0 = 0
+ pxor m7, m7 ; mm7 holds the sum
+
+.next2lines ; FIXME why are these unaligned movs? pix1[] is aligned
+ movu m1, [r1 ] ; mm1 = pix1[0][0-15]
+ movu m2, [r2 ] ; mm2 = pix2[0][0-15]
+ movu m3, [r1+r3] ; mm3 = pix1[1][0-15]
+ movu m4, [r2+r3] ; mm4 = pix2[1][0-15]
+
+ ; todo: mm1-mm2, mm3-mm4
+ ; algo: subtract mm1 from mm2 with saturation and vice versa
+ ; OR the result to get the absolute difference
+ mova m5, m1
+ mova m6, m3
+ psubusb m1, m2
+ psubusb m3, m4
+ psubusb m2, m5
+ psubusb m4, m6
+
+ por m2, m1
+ por m4, m3
+
+ ; now convert to 16-bit vectors so we can square them
+ mova m1, m2
+ mova m3, m4
+
+ punpckhbw m2, m0
+ punpckhbw m4, m0
+ punpcklbw m1, m0 ; mm1 not spread over (mm1,mm2)
+ punpcklbw m3, m0 ; mm4 not spread over (mm3,mm4)
+
+ pmaddwd m2, m2
+ pmaddwd m4, m4
+ pmaddwd m1, m1
+ pmaddwd m3, m3
+
+ lea r1, [r1+r3*2] ; pix1 += 2*line_size
+ lea r2, [r2+r3*2] ; pix2 += 2*line_size
+
+ paddd m1, m2
+ paddd m3, m4
+ paddd m7, m1
+ paddd m7, m3
+
+ dec r4
+ jnz .next2lines
+
+ mova m1, m7
+ psrldq m7, 8 ; shift hi qword to lo
+ paddd m7, m1
+ mova m1, m7
+ psrldq m7, 4 ; shift hi dword to lo
+ paddd m7, m1
+ movd eax, m7 ; return value
+ RET
diff --git a/lib/ffmpeg/libavcodec/x86/fdct_mmx.c b/lib/ffmpeg/libavcodec/x86/fdct_mmx.c
index 6e5228528e..c79a8df04c 100644
--- a/lib/ffmpeg/libavcodec/x86/fdct_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/fdct_mmx.c
@@ -31,6 +31,7 @@
*/
#include "libavutil/common.h"
+#include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h"
//////////////////////////////////////////////////////////////////////
@@ -430,7 +431,10 @@ static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
FDCT_ROW_SSE2_H2(80,192)
FDCT_ROW_SSE2(80)
:
- : "r" (in), "r" (tab_frw_01234567_sse2.tab_frw_01234567_sse2), "r" (fdct_r_row_sse2.fdct_r_row_sse2), "i" (SHIFT_FRW_ROW), "r" (out)
+ : "r" (in), "r" (tab_frw_01234567_sse2.tab_frw_01234567_sse2),
+ "r" (fdct_r_row_sse2.fdct_r_row_sse2), "i" (SHIFT_FRW_ROW), "r" (out)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7")
);
}
diff --git a/lib/ffmpeg/libavcodec/x86/fft.c b/lib/ffmpeg/libavcodec/x86/fft.c
index eb5c65ecbb..771b1e6649 100644
--- a/lib/ffmpeg/libavcodec/x86/fft.c
+++ b/lib/ffmpeg/libavcodec/x86/fft.c
@@ -16,25 +16,26 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavcodec/dsputil.h"
#include "fft.h"
av_cold void ff_fft_init_mmx(FFTContext *s)
{
#if HAVE_YASM
- int has_vectors = mm_support();
- if (has_vectors & FF_MM_SSE && HAVE_SSE) {
+ int has_vectors = av_get_cpu_flags();
+ if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE) {
/* SSE for P3/P4/K8 */
s->imdct_calc = ff_imdct_calc_sse;
s->imdct_half = ff_imdct_half_sse;
s->fft_permute = ff_fft_permute_sse;
s->fft_calc = ff_fft_calc_sse;
- } else if (has_vectors & FF_MM_3DNOWEXT && HAVE_AMD3DNOWEXT) {
+ } else if (has_vectors & AV_CPU_FLAG_3DNOWEXT && HAVE_AMD3DNOWEXT) {
/* 3DNowEx for K7 */
s->imdct_calc = ff_imdct_calc_3dn2;
s->imdct_half = ff_imdct_half_3dn2;
s->fft_calc = ff_fft_calc_3dn2;
- } else if (has_vectors & FF_MM_3DNOW && HAVE_AMD3DNOW) {
+ } else if (has_vectors & AV_CPU_FLAG_3DNOW && HAVE_AMD3DNOW) {
/* 3DNow! for K6-2/3 */
s->imdct_calc = ff_imdct_calc_3dn;
s->imdct_half = ff_imdct_half_3dn;
@@ -46,8 +47,8 @@ av_cold void ff_fft_init_mmx(FFTContext *s)
#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)
+ int has_vectors = av_get_cpu_flags();
+ if (has_vectors & AV_CPU_FLAG_SSE && HAVE_SSE)
s->dct32 = ff_dct32_float_sse;
}
#endif
diff --git a/lib/ffmpeg/libavcodec/x86/fft_3dn2.c b/lib/ffmpeg/libavcodec/x86/fft_3dn2.c
index b3bec4675a..2abb8cfbd7 100644
--- a/lib/ffmpeg/libavcodec/x86/fft_3dn2.c
+++ b/lib/ffmpeg/libavcodec/x86/fft_3dn2.c
@@ -56,7 +56,7 @@ void ff_fft_calc_3dn2(FFTContext *s, FFTComplex *z)
void ff_imdct_half_3dn2(FFTContext *s, FFTSample *output, const FFTSample *input)
{
x86_reg j, k;
- long n = 1 << s->mdct_bits;
+ long n = s->mdct_size;
long n2 = n >> 1;
long n4 = n >> 2;
long n8 = n >> 3;
@@ -147,7 +147,7 @@ void ff_imdct_half_3dn2(FFTContext *s, FFTSample *output, const FFTSample *input
void ff_imdct_calc_3dn2(FFTContext *s, FFTSample *output, const FFTSample *input)
{
x86_reg j, k;
- long n = 1 << s->mdct_bits;
+ long n = s->mdct_size;
long n4 = n >> 2;
ff_imdct_half_3dn2(s, output+n4, input);
diff --git a/lib/ffmpeg/libavcodec/x86/fft_mmx.asm b/lib/ffmpeg/libavcodec/x86/fft_mmx.asm
index ea78396e7c..1dcd629184 100644
--- a/lib/ffmpeg/libavcodec/x86/fft_mmx.asm
+++ b/lib/ffmpeg/libavcodec/x86/fft_mmx.asm
@@ -2,6 +2,9 @@
;* FFT transform with SSE/3DNow optimizations
;* Copyright (c) 2008 Loren Merritt
;*
+;* This algorithm (though not any of the implementation details) is
+;* based on libdjbfft by D. J. Bernstein.
+;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
@@ -26,6 +29,23 @@
%include "x86inc.asm"
+%ifdef ARCH_X86_64
+%define pointer resq
+%else
+%define pointer resd
+%endif
+
+struc FFTContext
+ .nbits: resd 1
+ .reverse: resd 1
+ .revtab: pointer 1
+ .tmpbuf: pointer 1
+ .mdctsize: resd 1
+ .mdctbits: resd 1
+ .tcos: pointer 1
+ .tsin: pointer 1
+endstruc
+
SECTION_RODATA
%define M_SQRT1_2 0.70710678118654752440
@@ -134,9 +154,9 @@ IF%1 mova m5, Z(5)
mova m1, %3 ; wim
mova m3, m5
mulps m2, m0 ; r2*wre
-IF%1 mova m6, Z(6)
+IF%1 mova m6, Z2(6)
mulps m3, m1 ; i2*wim
-IF%1 mova m7, Z(7)
+IF%1 mova m7, Z2(7)
mulps m4, m1 ; r2*wim
mulps m5, m0 ; i2*wre
addps m2, m3 ; r2*wre + i2*wim
@@ -163,14 +183,14 @@ IF%1 mova m7, Z(7)
mova m4, m6
subps m6, m5 ; r3
addps m5, m4 ; r1
- mova Z(6), m6
+ mova Z2(6), m6
mova Z(2), m5
mova m2, Z(3)
addps m3, m0 ; t6
subps m2, m1 ; i3
mova m7, Z(1)
addps m1, Z(3) ; i1
- mova Z(7), m2
+ mova Z2(7), m2
mova Z(3), m1
mova m4, m7
subps m7, m3 ; i2
@@ -188,9 +208,9 @@ IF%1 mova m7, Z(7)
mova m3, m5
mova m1, [wq+o1q] ; wim
mulps m2, m0 ; r2*wre
- mova m6, Z(6) ; r3
+ mova m6, Z2(6) ; r3
mulps m3, m1 ; i2*wim
- mova m7, Z(7) ; i3
+ mova m7, Z2(7) ; i3
mulps m4, m1 ; r2*wim
mulps m5, m0 ; i2*wre
addps m2, m3 ; r2*wre + i2*wim
@@ -217,14 +237,14 @@ IF%1 mova m7, Z(7)
mova m4, m6
subps m6, m5 ; r3
addps m5, m4 ; r1
-IF%1 mova Z(6), m6
+IF%1 mova Z2(6), m6
IF%1 mova Z(2), m5
mova m2, Z(3)
addps m3, m0 ; t6
subps m2, m1 ; i3
mova m7, Z(1)
addps m1, Z(3) ; i1
-IF%1 mova Z(7), m2
+IF%1 mova Z2(7), m2
IF%1 mova Z(3), m1
mova m4, m7
subps m7, m3 ; i2
@@ -242,8 +262,8 @@ IF%1 mova Z(1), m3
mova m2, Z(4)
mova Z(2), m5
mova Z(3), m4
- mova Z(6), m6
- mova Z(7), m0
+ mova Z2(6), m6
+ mova Z2(7), m0
mova m5, m1 ; r0
mova m4, m2 ; r2
unpcklps m1, m3
@@ -267,6 +287,7 @@ INIT_XMM
%define mova movaps
%define Z(x) [r0+mmsize*x]
+%define Z2(x) [r0+mmsize*x]
align 16
fft4_sse:
@@ -306,8 +327,8 @@ fft16_sse:
mova Z(2), m2
mova Z(3), m3
T4_SSE m4, m5, m6
- mova m6, Z(6)
- mova m7, Z(7)
+ mova m6, Z2(6)
+ mova m7, Z2(7)
T4_SSE m6, m7, m0
PASS_SMALL 0, [cos_16], [cos_16+16]
ret
@@ -338,8 +359,8 @@ fft8%1:
T4_3DN m0, m1, m2, m3, m4, m5
mova Z(0), m0
mova Z(2), m2
- T2_3DN m4, m5, Z(4), Z(5)
- T2_3DN m6, m7, Z(6), Z(7)
+ T2_3DN m4, m5, Z(4), Z(5)
+ T2_3DN m6, m7, Z2(6), Z2(7)
pswapd m0, m5
pswapd m2, m7
pxor m0, [ps_m1p1]
@@ -350,7 +371,7 @@ fft8%1:
pfmul m7, [ps_root2]
T4_3DN m1, m3, m5, m7, m0, m2
mova Z(5), m5
- mova Z(7), m7
+ mova Z2(7), m7
mova m0, Z(0)
mova m2, Z(2)
T4_3DN m0, m2, m4, m6, m5, m7
@@ -360,12 +381,12 @@ fft8%1:
mova Z(1), m5
mova Z(2), m2
mova Z(3), m7
- PUNPCK m4, Z(5), m5
- PUNPCK m6, Z(7), m7
+ PUNPCK m4, Z(5), m5
+ PUNPCK m6, Z2(7), m7
mova Z(4), m4
mova Z(5), m5
- mova Z(6), m6
- mova Z(7), m7
+ mova Z2(6), m6
+ mova Z2(7), m7
ret
%endmacro
@@ -385,7 +406,8 @@ FFT48_3DN _3dn2
FFT48_3DN _3dn
-%define Z(x) [zq + o1q*(x&6)*((x/6)^1) + o3q*(x/6) + mmsize*(x&1)]
+%define Z(x) [zq + o1q*(x&6) + mmsize*(x&1)]
+%define Z2(x) [zq + o3q + mmsize*(x&1)]
%macro DECL_PASS 2+ ; name, payload
align 16
@@ -425,6 +447,16 @@ DECL_PASS pass_interleave_3dn, PASS_BIG 0
%define SECTION_REL
%endif
+%macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
+ lea r2, [dispatch_tab%1]
+ mov r2, [r2 + (%2q-2)*gprsize]
+%ifdef PIC
+ lea r3, [$$]
+ add r2, r3
+%endif
+ call r2
+%endmacro ; FFT_DISPATCH
+
%macro DECL_FFT 2-3 ; nbits, cpu, suffix
%xdefine list_of_fft fft4%2 SECTION_REL, fft8%2 SECTION_REL
%if %1==5
@@ -461,13 +493,7 @@ 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]
- mov r2, [r2 + (nbitsq-2)*gprsize]
-%ifdef PIC
- lea r3, [$$]
- add r2, r3
-%endif
- call r2
+ FFT_DISPATCH %3%2, nbits
RET
%endmacro ; DECL_FFT
@@ -478,3 +504,165 @@ DECL_FFT 4, _3dn, _interleave
DECL_FFT 4, _3dn2
DECL_FFT 4, _3dn2, _interleave
+INIT_XMM
+%undef mulps
+%undef addps
+%undef subps
+%undef unpcklps
+%undef unpckhps
+
+%macro PREROTATER 5 ;-2*k, 2*k, input+n4, tcos+n8, tsin+n8
+ movaps xmm0, [%3+%2*4]
+ movaps xmm1, [%3+%1*4-0x10]
+ movaps xmm2, xmm0
+ shufps xmm0, xmm1, 0x88
+ shufps xmm1, xmm2, 0x77
+ movlps xmm4, [%4+%2*2]
+ movlps xmm5, [%5+%2*2+0x0]
+ movhps xmm4, [%4+%1*2-0x8]
+ movhps xmm5, [%5+%1*2-0x8]
+ movaps xmm2, xmm0
+ movaps xmm3, xmm1
+ mulps xmm0, xmm5
+ mulps xmm1, xmm4
+ mulps xmm2, xmm4
+ mulps xmm3, xmm5
+ subps xmm1, xmm0
+ addps xmm2, xmm3
+ movaps xmm0, xmm1
+ unpcklps xmm1, xmm2
+ unpckhps xmm0, xmm2
+%endmacro
+
+%macro CMUL 6 ;j, xmm0, xmm1, 3, 4, 5
+ movaps xmm6, [%4+%1*2]
+ movaps %2, [%4+%1*2+0x10]
+ movaps %3, xmm6
+ movaps xmm7, %2
+ mulps xmm6, [%5+%1]
+ mulps %2, [%6+%1]
+ mulps %3, [%6+%1]
+ mulps xmm7, [%5+%1]
+ subps %2, xmm6
+ addps %3, xmm7
+%endmacro
+
+%macro POSROTATESHUF 5 ;j, k, z+n8, tcos+n8, tsin+n8
+.post:
+ CMUL %1, xmm0, xmm1, %3, %4, %5
+ CMUL %2, xmm4, xmm5, %3, %4, %5
+ shufps xmm1, xmm1, 0x1b
+ shufps xmm5, xmm5, 0x1b
+ movaps xmm6, xmm4
+ unpckhps xmm4, xmm1
+ unpcklps xmm6, xmm1
+ movaps xmm2, xmm0
+ unpcklps xmm0, xmm5
+ unpckhps xmm2, xmm5
+ movaps [%3+%2*2], xmm6
+ movaps [%3+%2*2+0x10], xmm4
+ movaps [%3+%1*2], xmm0
+ movaps [%3+%1*2+0x10], xmm2
+ sub %2, 0x10
+ add %1, 0x10
+ jl .post
+%endmacro
+
+cglobal imdct_half_sse, 3,7,8; FFTContext *s, FFTSample *output, const FFTSample *input
+%ifdef ARCH_X86_64
+%define rrevtab r10
+%define rtcos r11
+%define rtsin r12
+ push r12
+ push r13
+ push r14
+%else
+%define rrevtab r6
+%define rtsin r6
+%define rtcos r5
+%endif
+ mov r3d, [r0+FFTContext.mdctsize]
+ add r2, r3
+ shr r3, 1
+ mov rtcos, [r0+FFTContext.tcos]
+ mov rtsin, [r0+FFTContext.tsin]
+ add rtcos, r3
+ add rtsin, r3
+%ifndef ARCH_X86_64
+ push rtcos
+ push rtsin
+%endif
+ shr r3, 1
+ mov rrevtab, [r0+FFTContext.revtab]
+ add rrevtab, r3
+%ifndef ARCH_X86_64
+ push rrevtab
+%endif
+
+ sub r3, 4
+%ifdef ARCH_X86_64
+ xor r4, r4
+ sub r4, r3
+%endif
+.pre:
+%ifndef ARCH_X86_64
+;unspill
+ xor r4, r4
+ sub r4, r3
+ mov rtsin, [esp+4]
+ mov rtcos, [esp+8]
+%endif
+
+ PREROTATER r4, r3, r2, rtcos, rtsin
+%ifdef ARCH_X86_64
+ movzx r5, word [rrevtab+r4-4]
+ movzx r6, word [rrevtab+r4-2]
+ movzx r13, word [rrevtab+r3]
+ movzx r14, word [rrevtab+r3+2]
+ movlps [r1+r5 *8], xmm0
+ movhps [r1+r6 *8], xmm0
+ movlps [r1+r13*8], xmm1
+ movhps [r1+r14*8], xmm1
+ add r4, 4
+%else
+ mov r6, [esp]
+ movzx r5, word [r6+r4-4]
+ movzx r4, word [r6+r4-2]
+ movlps [r1+r5*8], xmm0
+ movhps [r1+r4*8], xmm0
+ movzx r5, word [r6+r3]
+ movzx r4, word [r6+r3+2]
+ movlps [r1+r5*8], xmm1
+ movhps [r1+r4*8], xmm1
+%endif
+ sub r3, 4
+ jns .pre
+
+ mov r5, r0
+ mov r6, r1
+ mov r0, r1
+ mov r1d, [r5+FFTContext.nbits]
+
+ FFT_DISPATCH _sse, r1
+
+ mov r0d, [r5+FFTContext.mdctsize]
+ add r6, r0
+ shr r0, 1
+%ifndef ARCH_X86_64
+%define rtcos r2
+%define rtsin r3
+ mov rtcos, [esp+8]
+ mov rtsin, [esp+4]
+%endif
+ neg r0
+ mov r1, -16
+ sub r1, r0
+ POSROTATESHUF r0, r1, r6, rtcos, rtsin
+%ifdef ARCH_X86_64
+ pop r14
+ pop r13
+ pop r12
+%else
+ add esp, 12
+%endif
+ RET
diff --git a/lib/ffmpeg/libavcodec/x86/fft_sse.c b/lib/ffmpeg/libavcodec/x86/fft_sse.c
index a4cce69db1..0d151bc446 100644
--- a/lib/ffmpeg/libavcodec/x86/fft_sse.c
+++ b/lib/ffmpeg/libavcodec/x86/fft_sse.c
@@ -23,7 +23,7 @@
#include "libavcodec/dsputil.h"
#include "fft.h"
-DECLARE_ALIGNED(16, static const int, m1m1m1m1)[4] =
+DECLARE_ASM_CONST(16, int, ff_m1m1m1m1)[4] =
{ 1 << 31, 1 << 31, 1 << 31, 1 << 31 };
void ff_fft_dispatch_sse(FFTComplex *z, int nbits);
@@ -71,111 +71,10 @@ void ff_fft_permute_sse(FFTContext *s, FFTComplex *z)
memcpy(z, s->tmp_buf, n*sizeof(FFTComplex));
}
-void ff_imdct_half_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
-{
- av_unused x86_reg i, j, k, l;
- long n = 1 << s->mdct_bits;
- long n2 = n >> 1;
- long n4 = n >> 2;
- long n8 = n >> 3;
- const uint16_t *revtab = s->revtab + n8;
- const FFTSample *tcos = s->tcos;
- const FFTSample *tsin = s->tsin;
- FFTComplex *z = (FFTComplex *)output;
-
- /* pre rotation */
- for(k=n8-2; k>=0; k-=2) {
- __asm__ volatile(
- "movaps (%2,%1,2), %%xmm0 \n" // { z[k].re, z[k].im, z[k+1].re, z[k+1].im }
- "movaps -16(%2,%0,2), %%xmm1 \n" // { z[-k-2].re, z[-k-2].im, z[-k-1].re, z[-k-1].im }
- "movaps %%xmm0, %%xmm2 \n"
- "shufps $0x88, %%xmm1, %%xmm0 \n" // { z[k].re, z[k+1].re, z[-k-2].re, z[-k-1].re }
- "shufps $0x77, %%xmm2, %%xmm1 \n" // { z[-k-1].im, z[-k-2].im, z[k+1].im, z[k].im }
- "movlps (%3,%1), %%xmm4 \n"
- "movlps (%4,%1), %%xmm5 \n"
- "movhps -8(%3,%0), %%xmm4 \n" // { cos[k], cos[k+1], cos[-k-2], cos[-k-1] }
- "movhps -8(%4,%0), %%xmm5 \n" // { sin[k], sin[k+1], sin[-k-2], sin[-k-1] }
- "movaps %%xmm0, %%xmm2 \n"
- "movaps %%xmm1, %%xmm3 \n"
- "mulps %%xmm5, %%xmm0 \n" // re*sin
- "mulps %%xmm4, %%xmm1 \n" // im*cos
- "mulps %%xmm4, %%xmm2 \n" // re*cos
- "mulps %%xmm5, %%xmm3 \n" // im*sin
- "subps %%xmm0, %%xmm1 \n" // -> re
- "addps %%xmm3, %%xmm2 \n" // -> im
- "movaps %%xmm1, %%xmm0 \n"
- "unpcklps %%xmm2, %%xmm1 \n" // { z[k], z[k+1] }
- "unpckhps %%xmm2, %%xmm0 \n" // { z[-k-2], z[-k-1] }
- ::"r"(-4*k), "r"(4*k),
- "r"(input+n4), "r"(tcos+n8), "r"(tsin+n8)
- );
-#if ARCH_X86_64
- // if we have enough regs, don't let gcc make the luts latency-bound
- // but if not, latency is faster than spilling
- __asm__("movlps %%xmm0, %0 \n"
- "movhps %%xmm0, %1 \n"
- "movlps %%xmm1, %2 \n"
- "movhps %%xmm1, %3 \n"
- :"=m"(z[revtab[-k-2]]),
- "=m"(z[revtab[-k-1]]),
- "=m"(z[revtab[ k ]]),
- "=m"(z[revtab[ k+1]])
- );
-#else
- __asm__("movlps %%xmm0, %0" :"=m"(z[revtab[-k-2]]));
- __asm__("movhps %%xmm0, %0" :"=m"(z[revtab[-k-1]]));
- __asm__("movlps %%xmm1, %0" :"=m"(z[revtab[ k ]]));
- __asm__("movhps %%xmm1, %0" :"=m"(z[revtab[ k+1]]));
-#endif
- }
-
- ff_fft_dispatch_sse(z, s->nbits);
-
- /* post rotation + reinterleave + reorder */
-
-#define CMUL(j,xmm0,xmm1)\
- "movaps (%2,"#j",2), %%xmm6 \n"\
- "movaps 16(%2,"#j",2), "#xmm0"\n"\
- "movaps %%xmm6, "#xmm1"\n"\
- "movaps "#xmm0",%%xmm7 \n"\
- "mulps (%3,"#j"), %%xmm6 \n"\
- "mulps (%4,"#j"), "#xmm0"\n"\
- "mulps (%4,"#j"), "#xmm1"\n"\
- "mulps (%3,"#j"), %%xmm7 \n"\
- "subps %%xmm6, "#xmm0"\n"\
- "addps %%xmm7, "#xmm1"\n"
-
- j = -n2;
- k = n2-16;
- __asm__ volatile(
- "1: \n"
- CMUL(%0, %%xmm0, %%xmm1)
- CMUL(%1, %%xmm4, %%xmm5)
- "shufps $0x1b, %%xmm1, %%xmm1 \n"
- "shufps $0x1b, %%xmm5, %%xmm5 \n"
- "movaps %%xmm4, %%xmm6 \n"
- "unpckhps %%xmm1, %%xmm4 \n"
- "unpcklps %%xmm1, %%xmm6 \n"
- "movaps %%xmm0, %%xmm2 \n"
- "unpcklps %%xmm5, %%xmm0 \n"
- "unpckhps %%xmm5, %%xmm2 \n"
- "movaps %%xmm6, (%2,%1,2) \n"
- "movaps %%xmm4, 16(%2,%1,2) \n"
- "movaps %%xmm0, (%2,%0,2) \n"
- "movaps %%xmm2, 16(%2,%0,2) \n"
- "sub $16, %1 \n"
- "add $16, %0 \n"
- "jl 1b \n"
- :"+&r"(j), "+&r"(k)
- :"r"(z+n8), "r"(tcos+n8), "r"(tsin+n8)
- :"memory"
- );
-}
-
void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
{
x86_reg j, k;
- long n = 1 << s->mdct_bits;
+ long n = s->mdct_size;
long n4 = n >> 2;
ff_imdct_half_sse(s, output+n4, input);
@@ -183,7 +82,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
j = -n;
k = n-16;
__asm__ volatile(
- "movaps %4, %%xmm7 \n"
+ "movaps "MANGLE(ff_m1m1m1m1)", %%xmm7 \n"
"1: \n"
"movaps (%2,%1), %%xmm0 \n"
"movaps (%3,%0), %%xmm1 \n"
@@ -196,8 +95,8 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input)
"add $16, %0 \n"
"jl 1b \n"
:"+r"(j), "+r"(k)
- :"r"(output+n4), "r"(output+n4*3),
- "m"(*m1m1m1m1)
+ :"r"(output+n4), "r"(output+n4*3)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm7")
);
}
diff --git a/lib/ffmpeg/libavcodec/x86/fmtconvert.asm b/lib/ffmpeg/libavcodec/x86/fmtconvert.asm
new file mode 100644
index 0000000000..6c744fc581
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/fmtconvert.asm
@@ -0,0 +1,91 @@
+;******************************************************************************
+;* x86 optimized Format Conversion Utils
+;* Copyright (c) 2008 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
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+
+section .text align=16
+
+%macro PSWAPD_SSE 2
+ pshufw %1, %2, 0x4e
+%endmacro
+%macro PSWAPD_3DN1 2
+ movq %1, %2
+ psrlq %1, 32
+ punpckldq %1, %2
+%endmacro
+
+%macro FLOAT_TO_INT16_INTERLEAVE6 1
+; 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
+ mov lend, r2d
+%else
+ %define lend dword r2m
+%endif
+ mov src1q, [srcq+1*gprsize]
+ mov src2q, [srcq+2*gprsize]
+ mov src3q, [srcq+3*gprsize]
+ mov src4q, [srcq+4*gprsize]
+ mov src5q, [srcq+5*gprsize]
+ mov srcq, [srcq]
+ sub src1q, srcq
+ sub src2q, srcq
+ sub src3q, srcq
+ sub src4q, srcq
+ sub src5q, srcq
+.loop:
+ cvtps2pi mm0, [srcq]
+ cvtps2pi mm1, [srcq+src1q]
+ cvtps2pi mm2, [srcq+src2q]
+ cvtps2pi mm3, [srcq+src3q]
+ cvtps2pi mm4, [srcq+src4q]
+ cvtps2pi mm5, [srcq+src5q]
+ packssdw mm0, mm3
+ packssdw mm1, mm4
+ packssdw mm2, mm5
+ pswapd mm3, mm0
+ punpcklwd mm0, mm1
+ punpckhwd mm1, mm2
+ punpcklwd mm2, mm3
+ pswapd mm3, mm0
+ punpckldq mm0, mm2
+ punpckhdq mm2, mm1
+ punpckldq mm1, mm3
+ movq [dstq ], mm0
+ movq [dstq+16], mm2
+ movq [dstq+ 8], mm1
+ add srcq, 8
+ add dstq, 24
+ sub lend, 2
+ jg .loop
+ emms
+ RET
+%endmacro ; FLOAT_TO_INT16_INTERLEAVE6
+
+%define pswapd PSWAPD_SSE
+FLOAT_TO_INT16_INTERLEAVE6 sse
+%define cvtps2pi pf2id
+%define pswapd PSWAPD_3DN1
+FLOAT_TO_INT16_INTERLEAVE6 3dnow
+%undef pswapd
+FLOAT_TO_INT16_INTERLEAVE6 3dn2
+%undef cvtps2pi
diff --git a/lib/ffmpeg/libavcodec/x86/fmtconvert_mmx.c b/lib/ffmpeg/libavcodec/x86/fmtconvert_mmx.c
new file mode 100644
index 0000000000..ea41f730e8
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/fmtconvert_mmx.c
@@ -0,0 +1,266 @@
+/*
+ * Format Conversion Utils
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
+ */
+
+#include "libavutil/cpu.h"
+#include "libavutil/x86_cpu.h"
+#include "libavcodec/fmtconvert.h"
+
+static void int32_to_float_fmul_scalar_sse(float *dst, const int *src, float mul, int len)
+{
+ x86_reg i = -4*len;
+ __asm__ volatile(
+ "movss %3, %%xmm4 \n"
+ "shufps $0, %%xmm4, %%xmm4 \n"
+ "1: \n"
+ "cvtpi2ps (%2,%0), %%xmm0 \n"
+ "cvtpi2ps 8(%2,%0), %%xmm1 \n"
+ "cvtpi2ps 16(%2,%0), %%xmm2 \n"
+ "cvtpi2ps 24(%2,%0), %%xmm3 \n"
+ "movlhps %%xmm1, %%xmm0 \n"
+ "movlhps %%xmm3, %%xmm2 \n"
+ "mulps %%xmm4, %%xmm0 \n"
+ "mulps %%xmm4, %%xmm2 \n"
+ "movaps %%xmm0, (%1,%0) \n"
+ "movaps %%xmm2, 16(%1,%0) \n"
+ "add $32, %0 \n"
+ "jl 1b \n"
+ :"+r"(i)
+ :"r"(dst+len), "r"(src+len), "m"(mul)
+ );
+}
+
+static void int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len)
+{
+ x86_reg i = -4*len;
+ __asm__ volatile(
+ "movss %3, %%xmm4 \n"
+ "shufps $0, %%xmm4, %%xmm4 \n"
+ "1: \n"
+ "cvtdq2ps (%2,%0), %%xmm0 \n"
+ "cvtdq2ps 16(%2,%0), %%xmm1 \n"
+ "mulps %%xmm4, %%xmm0 \n"
+ "mulps %%xmm4, %%xmm1 \n"
+ "movaps %%xmm0, (%1,%0) \n"
+ "movaps %%xmm1, 16(%1,%0) \n"
+ "add $32, %0 \n"
+ "jl 1b \n"
+ :"+r"(i)
+ :"r"(dst+len), "r"(src+len), "m"(mul)
+ );
+}
+
+static void float_to_int16_3dnow(int16_t *dst, const float *src, long len){
+ x86_reg reglen = len;
+ // not bit-exact: pf2id uses different rounding than C and SSE
+ __asm__ volatile(
+ "add %0 , %0 \n\t"
+ "lea (%2,%0,2) , %2 \n\t"
+ "add %0 , %1 \n\t"
+ "neg %0 \n\t"
+ "1: \n\t"
+ "pf2id (%2,%0,2) , %%mm0 \n\t"
+ "pf2id 8(%2,%0,2) , %%mm1 \n\t"
+ "pf2id 16(%2,%0,2) , %%mm2 \n\t"
+ "pf2id 24(%2,%0,2) , %%mm3 \n\t"
+ "packssdw %%mm1 , %%mm0 \n\t"
+ "packssdw %%mm3 , %%mm2 \n\t"
+ "movq %%mm0 , (%1,%0) \n\t"
+ "movq %%mm2 , 8(%1,%0) \n\t"
+ "add $16 , %0 \n\t"
+ " js 1b \n\t"
+ "femms \n\t"
+ :"+r"(reglen), "+r"(dst), "+r"(src)
+ );
+}
+
+static void float_to_int16_sse(int16_t *dst, const float *src, long len){
+ x86_reg reglen = len;
+ __asm__ volatile(
+ "add %0 , %0 \n\t"
+ "lea (%2,%0,2) , %2 \n\t"
+ "add %0 , %1 \n\t"
+ "neg %0 \n\t"
+ "1: \n\t"
+ "cvtps2pi (%2,%0,2) , %%mm0 \n\t"
+ "cvtps2pi 8(%2,%0,2) , %%mm1 \n\t"
+ "cvtps2pi 16(%2,%0,2) , %%mm2 \n\t"
+ "cvtps2pi 24(%2,%0,2) , %%mm3 \n\t"
+ "packssdw %%mm1 , %%mm0 \n\t"
+ "packssdw %%mm3 , %%mm2 \n\t"
+ "movq %%mm0 , (%1,%0) \n\t"
+ "movq %%mm2 , 8(%1,%0) \n\t"
+ "add $16 , %0 \n\t"
+ " js 1b \n\t"
+ "emms \n\t"
+ :"+r"(reglen), "+r"(dst), "+r"(src)
+ );
+}
+
+static void float_to_int16_sse2(int16_t *dst, const float *src, long len){
+ x86_reg reglen = len;
+ __asm__ volatile(
+ "add %0 , %0 \n\t"
+ "lea (%2,%0,2) , %2 \n\t"
+ "add %0 , %1 \n\t"
+ "neg %0 \n\t"
+ "1: \n\t"
+ "cvtps2dq (%2,%0,2) , %%xmm0 \n\t"
+ "cvtps2dq 16(%2,%0,2) , %%xmm1 \n\t"
+ "packssdw %%xmm1 , %%xmm0 \n\t"
+ "movdqa %%xmm0 , (%1,%0) \n\t"
+ "add $16 , %0 \n\t"
+ " js 1b \n\t"
+ :"+r"(reglen), "+r"(dst), "+r"(src)
+ );
+}
+
+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);
+
+#if !HAVE_YASM
+#define ff_float_to_int16_interleave6_sse(a,b,c) float_to_int16_interleave_misc_sse(a,b,c,6)
+#define ff_float_to_int16_interleave6_3dnow(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
+#define ff_float_to_int16_interleave6_3dn2(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6)
+#endif
+#define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse
+
+#define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \
+/* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
+static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\
+ DECLARE_ALIGNED(16, int16_t, tmp)[len];\
+ int i,j,c;\
+ for(c=0; c<channels; c++){\
+ float_to_int16_##cpu(tmp, src[c], len);\
+ for(i=0, j=c; i<len; i++, j+=channels)\
+ dst[j] = tmp[i];\
+ }\
+}\
+\
+static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\
+ if(channels==1)\
+ float_to_int16_##cpu(dst, src[0], len);\
+ else if(channels==2){\
+ x86_reg reglen = len; \
+ const float *src0 = src[0];\
+ const float *src1 = src[1];\
+ __asm__ volatile(\
+ "shl $2, %0 \n"\
+ "add %0, %1 \n"\
+ "add %0, %2 \n"\
+ "add %0, %3 \n"\
+ "neg %0 \n"\
+ body\
+ :"+r"(reglen), "+r"(dst), "+r"(src0), "+r"(src1)\
+ );\
+ }else if(channels==6){\
+ ff_float_to_int16_interleave6_##cpu(dst, src, len);\
+ }else\
+ float_to_int16_interleave_misc_##cpu(dst, src, len, channels);\
+}
+
+FLOAT_TO_INT16_INTERLEAVE(3dnow,
+ "1: \n"
+ "pf2id (%2,%0), %%mm0 \n"
+ "pf2id 8(%2,%0), %%mm1 \n"
+ "pf2id (%3,%0), %%mm2 \n"
+ "pf2id 8(%3,%0), %%mm3 \n"
+ "packssdw %%mm1, %%mm0 \n"
+ "packssdw %%mm3, %%mm2 \n"
+ "movq %%mm0, %%mm1 \n"
+ "punpcklwd %%mm2, %%mm0 \n"
+ "punpckhwd %%mm2, %%mm1 \n"
+ "movq %%mm0, (%1,%0)\n"
+ "movq %%mm1, 8(%1,%0)\n"
+ "add $16, %0 \n"
+ "js 1b \n"
+ "femms \n"
+)
+
+FLOAT_TO_INT16_INTERLEAVE(sse,
+ "1: \n"
+ "cvtps2pi (%2,%0), %%mm0 \n"
+ "cvtps2pi 8(%2,%0), %%mm1 \n"
+ "cvtps2pi (%3,%0), %%mm2 \n"
+ "cvtps2pi 8(%3,%0), %%mm3 \n"
+ "packssdw %%mm1, %%mm0 \n"
+ "packssdw %%mm3, %%mm2 \n"
+ "movq %%mm0, %%mm1 \n"
+ "punpcklwd %%mm2, %%mm0 \n"
+ "punpckhwd %%mm2, %%mm1 \n"
+ "movq %%mm0, (%1,%0)\n"
+ "movq %%mm1, 8(%1,%0)\n"
+ "add $16, %0 \n"
+ "js 1b \n"
+ "emms \n"
+)
+
+FLOAT_TO_INT16_INTERLEAVE(sse2,
+ "1: \n"
+ "cvtps2dq (%2,%0), %%xmm0 \n"
+ "cvtps2dq (%3,%0), %%xmm1 \n"
+ "packssdw %%xmm1, %%xmm0 \n"
+ "movhlps %%xmm0, %%xmm1 \n"
+ "punpcklwd %%xmm1, %%xmm0 \n"
+ "movdqa %%xmm0, (%1,%0) \n"
+ "add $16, %0 \n"
+ "js 1b \n"
+)
+
+static void float_to_int16_interleave_3dn2(int16_t *dst, const float **src, long len, int channels){
+ if(channels==6)
+ ff_float_to_int16_interleave6_3dn2(dst, src, len);
+ else
+ float_to_int16_interleave_3dnow(dst, src, len, channels);
+}
+
+void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx)
+{
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & AV_CPU_FLAG_MMX) {
+
+ if(mm_flags & AV_CPU_FLAG_3DNOW){
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ c->float_to_int16 = float_to_int16_3dnow;
+ c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
+ }
+ }
+ if(mm_flags & AV_CPU_FLAG_3DNOWEXT){
+ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+ c->float_to_int16_interleave = float_to_int16_interleave_3dn2;
+ }
+ }
+ if(mm_flags & AV_CPU_FLAG_SSE){
+ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse;
+ c->float_to_int16 = float_to_int16_sse;
+ c->float_to_int16_interleave = float_to_int16_interleave_sse;
+ }
+ if(mm_flags & AV_CPU_FLAG_SSE2){
+ c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2;
+ c->float_to_int16 = float_to_int16_sse2;
+ c->float_to_int16_interleave = float_to_int16_interleave_sse2;
+ }
+ }
+}
diff --git a/lib/ffmpeg/libavcodec/x86/h264_chromamc.asm b/lib/ffmpeg/libavcodec/x86/h264_chromamc.asm
new file mode 100644
index 0000000000..3bb5ed4855
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/h264_chromamc.asm
@@ -0,0 +1,669 @@
+;******************************************************************************
+;* MMX/SSSE3-optimized functions for H264 chroma MC
+;* Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>,
+;* 2005-2008 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
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+SECTION_RODATA
+
+rnd_rv40_2d_tbl: times 4 dw 0
+ times 4 dw 16
+ times 4 dw 32
+ times 4 dw 16
+ times 4 dw 32
+ times 4 dw 28
+ times 4 dw 32
+ times 4 dw 28
+ times 4 dw 0
+ times 4 dw 32
+ times 4 dw 16
+ times 4 dw 32
+ times 4 dw 32
+ times 4 dw 28
+ times 4 dw 32
+ times 4 dw 28
+rnd_rv40_1d_tbl: times 4 dw 0
+ times 4 dw 2
+ times 4 dw 4
+ times 4 dw 2
+ times 4 dw 4
+ times 4 dw 3
+ times 4 dw 4
+ times 4 dw 3
+ times 4 dw 0
+ times 4 dw 4
+ times 4 dw 2
+ times 4 dw 4
+ times 4 dw 4
+ times 4 dw 3
+ times 4 dw 4
+ times 4 dw 3
+
+cextern pw_3
+cextern pw_4
+cextern pw_8
+cextern pw_28
+cextern pw_32
+cextern pw_64
+
+SECTION .text
+
+%macro mv0_pixels_mc8 0
+ lea r4, [r2*2 ]
+.next4rows
+ movq mm0, [r1 ]
+ movq mm1, [r1+r2]
+ CHROMAMC_AVG mm0, [r0 ]
+ CHROMAMC_AVG mm1, [r0+r2]
+ movq [r0 ], mm0
+ movq [r0+r2], mm1
+ add r0, r4
+ add r1, r4
+ movq mm0, [r1 ]
+ movq mm1, [r1+r2]
+ CHROMAMC_AVG mm0, [r0 ]
+ CHROMAMC_AVG mm1, [r0+r2]
+ add r1, r4
+ movq [r0 ], mm0
+ movq [r0+r2], mm1
+ add r0, r4
+ sub r3d, 4
+ jne .next4rows
+%endmacro
+
+%macro chroma_mc8_mmx_func 3
+; put/avg_h264_chroma_mc8_mmx_*(uint8_t *dst /*align 8*/, uint8_t *src /*align 1*/,
+; int stride, int h, int mx, int my)
+cglobal %1_%2_chroma_mc8_%3, 6, 7, 0
+%ifdef ARCH_X86_64
+ movsxd r2, r2d
+%endif
+ mov r6d, r5d
+ or r6d, r4d
+ jne .at_least_one_non_zero
+ ; mx == 0 AND my == 0 - no filter needed
+ mv0_pixels_mc8
+ REP_RET
+
+.at_least_one_non_zero
+%ifidn %2, rv40
+%ifdef PIC
+%define rnd_1d_rv40 r11
+%define rnd_2d_rv40 r11
+%else ; no-PIC
+%define rnd_1d_rv40 rnd_rv40_1d_tbl
+%define rnd_2d_rv40 rnd_rv40_2d_tbl
+%endif
+%ifdef ARCH_X86_64
+ mov r10, r5
+ and r10, 6 ; &~1 for mx/my=[0,7]
+ lea r10, [r10*4+r4]
+ sar r10d, 1
+%define rnd_bias r10
+%define dest_reg r0
+%else ; x86-32
+ mov r0, r5
+ and r0, 6 ; &~1 for mx/my=[0,7]
+ lea r0, [r0*4+r4]
+ sar r0d, 1
+%define rnd_bias r0
+%define dest_reg r5
+%endif
+%else ; vc1, h264
+%define rnd_bias 0
+%define dest_reg r0
+%endif
+
+ test r5d, r5d
+ mov r6, 1
+ je .my_is_zero
+ test r4d, r4d
+ mov r6, r2 ; dxy = x ? 1 : stride
+ jne .both_non_zero
+.my_is_zero
+ ; mx == 0 XOR my == 0 - 1 dimensional filter only
+ or r4d, r5d ; x + y
+
+%ifidn %2, rv40
+%ifdef PIC
+ lea r11, [rnd_rv40_1d_tbl]
+%endif
+%ifndef ARCH_X86_64
+ mov r5, r0m
+%endif
+%endif
+
+ movd m5, r4d
+ movq m4, [pw_8]
+ movq m6, [rnd_1d_%2+rnd_bias*8] ; mm6 = rnd >> 3
+ punpcklwd m5, m5
+ punpckldq m5, m5 ; mm5 = B = x
+ pxor m7, m7
+ psubw m4, m5 ; mm4 = A = 8-x
+
+.next1drow
+ movq m0, [r1 ] ; mm0 = src[0..7]
+ movq m2, [r1+r6] ; mm1 = src[1..8]
+
+ movq m1, m0
+ movq m3, m2
+ punpcklbw m0, m7
+ punpckhbw m1, m7
+ punpcklbw m2, m7
+ punpckhbw m3, m7
+ pmullw m0, m4 ; [mm0,mm1] = A * src[0..7]
+ pmullw m1, m4
+ pmullw m2, m5 ; [mm2,mm3] = B * src[1..8]
+ pmullw m3, m5
+
+ paddw m0, m6
+ paddw m1, m6
+ paddw m0, m2
+ paddw m1, m3
+ psrlw m0, 3
+ psrlw m1, 3
+ packuswb m0, m1
+ CHROMAMC_AVG m0, [dest_reg]
+ movq [dest_reg], m0 ; dst[0..7] = (A * src[0..7] + B * src[1..8] + (rnd >> 3)) >> 3
+
+ add dest_reg, r2
+ add r1, r2
+ dec r3d
+ jne .next1drow
+ REP_RET
+
+.both_non_zero ; general case, bilinear
+ movd m4, r4d ; x
+ movd m6, r5d ; y
+%ifidn %2, rv40
+%ifdef PIC
+ lea r11, [rnd_rv40_2d_tbl]
+%endif
+%ifndef ARCH_X86_64
+ mov r5, r0m
+%endif
+%endif
+ mov r6, rsp ; backup stack pointer
+ and rsp, ~(mmsize-1) ; align stack
+ sub rsp, 16 ; AA and DD
+
+ punpcklwd m4, m4
+ punpcklwd m6, m6
+ punpckldq m4, m4 ; mm4 = x words
+ punpckldq m6, m6 ; mm6 = y words
+ movq m5, m4
+ pmullw m4, m6 ; mm4 = x * y
+ psllw m5, 3
+ psllw m6, 3
+ movq m7, m5
+ paddw m7, m6
+ movq [rsp+8], m4 ; DD = x * y
+ psubw m5, m4 ; mm5 = B = 8x - xy
+ psubw m6, m4 ; mm6 = C = 8y - xy
+ paddw m4, [pw_64]
+ psubw m4, m7 ; mm4 = A = xy - (8x+8y) + 64
+ pxor m7, m7
+ movq [rsp ], m4
+
+ movq m0, [r1 ] ; mm0 = src[0..7]
+ movq m1, [r1+1] ; mm1 = src[1..8]
+.next2drow
+ add r1, r2
+
+ movq m2, m0
+ movq m3, m1
+ punpckhbw m0, m7
+ punpcklbw m1, m7
+ punpcklbw m2, m7
+ punpckhbw m3, m7
+ pmullw m0, [rsp]
+ pmullw m2, [rsp]
+ pmullw m1, m5
+ pmullw m3, m5
+ paddw m2, m1 ; mm2 = A * src[0..3] + B * src[1..4]
+ paddw m3, m0 ; mm3 = A * src[4..7] + B * src[5..8]
+
+ movq m0, [r1]
+ movq m1, m0
+ punpcklbw m0, m7
+ punpckhbw m1, m7
+ pmullw m0, m6
+ pmullw m1, m6
+ paddw m2, m0
+ paddw m3, m1 ; [mm2,mm3] += C * src[0..7]
+
+ movq m1, [r1+1]
+ movq m0, m1
+ movq m4, m1
+ punpcklbw m0, m7
+ punpckhbw m4, m7
+ pmullw m0, [rsp+8]
+ pmullw m4, [rsp+8]
+ paddw m2, m0
+ paddw m3, m4 ; [mm2,mm3] += D * src[1..8]
+ movq m0, [r1]
+
+ paddw m2, [rnd_2d_%2+rnd_bias*8]
+ paddw m3, [rnd_2d_%2+rnd_bias*8]
+ psrlw m2, 6
+ psrlw m3, 6
+ packuswb m2, m3
+ CHROMAMC_AVG m2, [dest_reg]
+ movq [dest_reg], m2 ; dst[0..7] = ([mm2,mm3] + rnd) >> 6
+
+ add dest_reg, r2
+ dec r3d
+ jne .next2drow
+ mov rsp, r6 ; restore stack pointer
+ RET
+%endmacro
+
+%macro chroma_mc4_mmx_func 3
+cglobal %1_%2_chroma_mc4_%3, 6, 6, 0
+%ifdef ARCH_X86_64
+ movsxd r2, r2d
+%endif
+ pxor m7, m7
+ movd m2, r4d ; x
+ movd m3, r5d ; y
+ movq m4, [pw_8]
+ movq m5, [pw_8]
+ punpcklwd m2, m2
+ punpcklwd m3, m3
+ punpcklwd m2, m2
+ punpcklwd m3, m3
+ psubw m4, m2
+ psubw m5, m3
+
+%ifidn %2, rv40
+%ifdef PIC
+ lea r11, [rnd_rv40_2d_tbl]
+%define rnd_2d_rv40 r11
+%else
+%define rnd_2d_rv40 rnd_rv40_2d_tbl
+%endif
+ and r5, 6 ; &~1 for mx/my=[0,7]
+ lea r5, [r5*4+r4]
+ sar r5d, 1
+%define rnd_bias r5
+%else ; vc1, h264
+%define rnd_bias 0
+%endif
+
+ movd m0, [r1 ]
+ movd m6, [r1+1]
+ add r1, r2
+ punpcklbw m0, m7
+ punpcklbw m6, m7
+ pmullw m0, m4
+ pmullw m6, m2
+ paddw m6, m0
+
+.next2rows
+ movd m0, [r1 ]
+ movd m1, [r1+1]
+ add r1, r2
+ punpcklbw m0, m7
+ punpcklbw m1, m7
+ pmullw m0, m4
+ pmullw m1, m2
+ paddw m1, m0
+ movq m0, m1
+
+ pmullw m6, m5
+ pmullw m1, m3
+ paddw m6, [rnd_2d_%2+rnd_bias*8]
+ paddw m1, m6
+ psrlw m1, 6
+ packuswb m1, m1
+ CHROMAMC_AVG4 m1, m6, [r0]
+ movd [r0], m1
+ add r0, r2
+
+ movd m6, [r1 ]
+ movd m1, [r1+1]
+ add r1, r2
+ punpcklbw m6, m7
+ punpcklbw m1, m7
+ pmullw m6, m4
+ pmullw m1, m2
+ paddw m1, m6
+ movq m6, m1
+ pmullw m0, m5
+ pmullw m1, m3
+ paddw m0, [rnd_2d_%2+rnd_bias*8]
+ paddw m1, m0
+ psrlw m1, 6
+ packuswb m1, m1
+ CHROMAMC_AVG4 m1, m0, [r0]
+ movd [r0], m1
+ add r0, r2
+ sub r3d, 2
+ jnz .next2rows
+ REP_RET
+%endmacro
+
+%macro chroma_mc2_mmx_func 3
+cglobal %1_%2_chroma_mc2_%3, 6, 7, 0
+%ifdef ARCH_X86_64
+ movsxd r2, r2d
+%endif
+
+ mov r6d, r4d
+ shl r4d, 16
+ sub r4d, r6d
+ add r4d, 8
+ imul r5d, r4d ; x*y<<16 | y*(8-x)
+ shl r4d, 3
+ sub r4d, r5d ; x*(8-y)<<16 | (8-x)*(8-y)
+
+ movd m5, r4d
+ movd m6, r5d
+ punpckldq m5, m5 ; mm5 = {A,B,A,B}
+ punpckldq m6, m6 ; mm6 = {C,D,C,D}
+ pxor m7, m7
+ movd m2, [r1]
+ punpcklbw m2, m7
+ pshufw m2, m2, 0x94 ; mm0 = src[0,1,1,2]
+
+.nextrow
+ add r1, r2
+ movq m1, m2
+ pmaddwd m1, m5 ; mm1 = A * src[0,1] + B * src[1,2]
+ movd m0, [r1]
+ punpcklbw m0, m7
+ pshufw m0, m0, 0x94 ; mm0 = src[0,1,1,2]
+ movq m2, m0
+ pmaddwd m0, m6
+ paddw m1, [rnd_2d_%2]
+ paddw m1, m0 ; mm1 += C * src[0,1] + D * src[1,2]
+ psrlw m1, 6
+ packssdw m1, m7
+ packuswb m1, m7
+ CHROMAMC_AVG4 m1, m3, [r0]
+ movd r5d, m1
+ mov [r0], r5w
+ add r0, r2
+ sub r3d, 1
+ jnz .nextrow
+ REP_RET
+%endmacro
+
+%define rnd_1d_h264 pw_4
+%define rnd_2d_h264 pw_32
+%define rnd_1d_vc1 pw_3
+%define rnd_2d_vc1 pw_28
+
+%macro NOTHING 2-3
+%endmacro
+%macro DIRECT_AVG 2
+ PAVG %1, %2
+%endmacro
+%macro COPY_AVG 3
+ movd %2, %3
+ PAVG %1, %2
+%endmacro
+
+INIT_MMX
+%define CHROMAMC_AVG NOTHING
+%define CHROMAMC_AVG4 NOTHING
+chroma_mc8_mmx_func put, h264, mmx_rnd
+chroma_mc8_mmx_func put, vc1, mmx_nornd
+chroma_mc8_mmx_func put, rv40, mmx
+chroma_mc4_mmx_func put, h264, mmx
+chroma_mc4_mmx_func put, rv40, mmx
+chroma_mc2_mmx_func put, h264, mmx2
+
+%define CHROMAMC_AVG DIRECT_AVG
+%define CHROMAMC_AVG4 COPY_AVG
+%define PAVG pavgb
+chroma_mc8_mmx_func avg, h264, mmx2_rnd
+chroma_mc8_mmx_func avg, vc1, mmx2_nornd
+chroma_mc8_mmx_func avg, rv40, mmx2
+chroma_mc4_mmx_func avg, h264, mmx2
+chroma_mc4_mmx_func avg, rv40, mmx2
+chroma_mc2_mmx_func avg, h264, mmx2
+
+%define PAVG pavgusb
+chroma_mc8_mmx_func avg, h264, 3dnow_rnd
+chroma_mc8_mmx_func avg, vc1, 3dnow_nornd
+chroma_mc8_mmx_func avg, rv40, 3dnow
+chroma_mc4_mmx_func avg, h264, 3dnow
+chroma_mc4_mmx_func avg, rv40, 3dnow
+
+%macro chroma_mc8_ssse3_func 3
+cglobal %1_%2_chroma_mc8_%3, 6, 7, 8
+%ifdef ARCH_X86_64
+ movsxd r2, r2d
+%endif
+ mov r6d, r5d
+ or r6d, r4d
+ jne .at_least_one_non_zero
+ ; mx == 0 AND my == 0 - no filter needed
+ mv0_pixels_mc8
+ REP_RET
+
+.at_least_one_non_zero
+ test r5d, r5d
+ je .my_is_zero
+ test r4d, r4d
+ je .mx_is_zero
+
+ ; general case, bilinear
+ mov r6d, r4d
+ shl r4d, 8
+ sub r4, r6
+ add r4, 8 ; x*288+8 = x<<8 | (8-x)
+ mov r6, 8
+ sub r6d, r5d
+ imul r6, r4 ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x)
+ imul r4d, r5d ; y *(x*255+8) = y *x<<8 | y *(8-x)
+
+ movd m7, r6d
+ movd m6, r4d
+ movdqa m5, [rnd_2d_%2]
+ pshuflw m7, m7, 0
+ pshuflw m6, m6, 0
+ movlhps m7, m7
+ movlhps m6, m6
+
+ movq m0, [r1 ]
+ movq m1, [r1 +1]
+ punpcklbw m0, m1
+ add r1, r2
+.next2rows
+ movq m1, [r1 ]
+ movq m2, [r1 +1]
+ movq m3, [r1+r2 ]
+ movq m4, [r1+r2+1]
+ lea r1, [r1+r2*2]
+ punpcklbw m1, m2
+ punpcklbw m3, m4
+ movdqa m2, m1
+ movdqa m4, m3
+ pmaddubsw m0, m7
+ pmaddubsw m1, m6
+ pmaddubsw m2, m7
+ pmaddubsw m3, m6
+ paddw m0, m5
+ paddw m2, m5
+ paddw m1, m0
+ paddw m3, m2
+ movdqa m0, m4
+ psrlw m1, 6
+ psrlw m3, 6
+%ifidn %1, avg
+ movq m2, [r0 ]
+ movhps m2, [r0+r2]
+%endif
+ packuswb m1, m3
+ CHROMAMC_AVG m1, m2
+ movq [r0 ], m1
+ movhps [r0+r2], m1
+ sub r3d, 2
+ lea r0, [r0+r2*2]
+ jg .next2rows
+ REP_RET
+
+.my_is_zero
+ mov r5d, r4d
+ shl r4d, 8
+ add r4, 8
+ sub r4, r5 ; 255*x+8 = x<<8 | (8-x)
+ movd m7, r4d
+ movdqa m6, [rnd_1d_%2]
+ pshuflw m7, m7, 0
+ movlhps m7, m7
+
+.next2xrows
+ movq m0, [r1 ]
+ movq m1, [r1 +1]
+ movq m2, [r1+r2 ]
+ movq m3, [r1+r2+1]
+ punpcklbw m0, m1
+ punpcklbw m2, m3
+ pmaddubsw m0, m7
+ pmaddubsw m2, m7
+%ifidn %1, avg
+ movq m4, [r0 ]
+ movhps m4, [r0+r2]
+%endif
+ paddw m0, m6
+ paddw m2, m6
+ psrlw m0, 3
+ psrlw m2, 3
+ packuswb m0, m2
+ CHROMAMC_AVG m0, m4
+ movq [r0 ], m0
+ movhps [r0+r2], m0
+ sub r3d, 2
+ lea r0, [r0+r2*2]
+ lea r1, [r1+r2*2]
+ jg .next2xrows
+ REP_RET
+
+.mx_is_zero
+ mov r4d, r5d
+ shl r5d, 8
+ add r5, 8
+ sub r5, r4 ; 255*y+8 = y<<8 | (8-y)
+ movd m7, r5d
+ movdqa m6, [rnd_1d_%2]
+ pshuflw m7, m7, 0
+ movlhps m7, m7
+
+.next2yrows
+ movq m0, [r1 ]
+ movq m1, [r1+r2 ]
+ movdqa m2, m1
+ movq m3, [r1+r2*2]
+ punpcklbw m0, m1
+ punpcklbw m2, m3
+ pmaddubsw m0, m7
+ pmaddubsw m2, m7
+%ifidn %1, avg
+ movq m4, [r0 ]
+ movhps m4, [r0+r2]
+%endif
+ paddw m0, m6
+ paddw m2, m6
+ psrlw m0, 3
+ psrlw m2, 3
+ packuswb m0, m2
+ CHROMAMC_AVG m0, m4
+ movq [r0 ], m0
+ movhps [r0+r2], m0
+ sub r3d, 2
+ lea r0, [r0+r2*2]
+ lea r1, [r1+r2*2]
+ jg .next2yrows
+ REP_RET
+%endmacro
+
+%macro chroma_mc4_ssse3_func 3
+cglobal %1_%2_chroma_mc4_%3, 6, 7, 0
+%ifdef ARCH_X86_64
+ movsxd r2, r2d
+%endif
+ mov r6, r4
+ shl r4d, 8
+ sub r4d, r6d
+ add r4d, 8 ; x*288+8
+ mov r6, 8
+ sub r6d, r5d
+ imul r6d, r4d ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x)
+ imul r4d, r5d ; y *(x*255+8) = y *x<<8 | y *(8-x)
+
+ movd m7, r6d
+ movd m6, r4d
+ movq m5, [pw_32]
+ pshufw m7, m7, 0
+ pshufw m6, m6, 0
+
+ movd m0, [r1 ]
+ punpcklbw m0, [r1 +1]
+ add r1, r2
+.next2rows
+ movd m1, [r1 ]
+ movd m3, [r1+r2 ]
+ punpcklbw m1, [r1 +1]
+ punpcklbw m3, [r1+r2+1]
+ lea r1, [r1+r2*2]
+ movq m2, m1
+ movq m4, m3
+ pmaddubsw m0, m7
+ pmaddubsw m1, m6
+ pmaddubsw m2, m7
+ pmaddubsw m3, m6
+ paddw m0, m5
+ paddw m2, m5
+ paddw m1, m0
+ paddw m3, m2
+ movq m0, m4
+ psrlw m1, 6
+ psrlw m3, 6
+ packuswb m1, m1
+ packuswb m3, m3
+ CHROMAMC_AVG m1, [r0 ]
+ CHROMAMC_AVG m3, [r0+r2]
+ movd [r0 ], m1
+ movd [r0+r2], m3
+ sub r3d, 2
+ lea r0, [r0+r2*2]
+ jg .next2rows
+ REP_RET
+%endmacro
+
+%define CHROMAMC_AVG NOTHING
+INIT_XMM
+chroma_mc8_ssse3_func put, h264, ssse3_rnd
+chroma_mc8_ssse3_func put, vc1, ssse3_nornd
+INIT_MMX
+chroma_mc4_ssse3_func put, h264, ssse3
+
+%define CHROMAMC_AVG DIRECT_AVG
+%define PAVG pavgb
+INIT_XMM
+chroma_mc8_ssse3_func avg, h264, ssse3_rnd
+chroma_mc8_ssse3_func avg, vc1, ssse3_nornd
+INIT_MMX
+chroma_mc4_ssse3_func avg, h264, ssse3
diff --git a/lib/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm b/lib/ffmpeg/libavcodec/x86/h264_deblock.asm
index b2aa940236..fb9cacfd11 100644
--- a/lib/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm
+++ b/lib/ffmpeg/libavcodec/x86/h264_deblock.asm
@@ -4,29 +4,34 @@
;* Copyright (C) 2005-2008 x264 project
;*
;* Authors: Loren Merritt <lorenm@u.washington.edu>
+;* Jason Garrett-Glaser <darkshikari@gmail.com>
;*
-;* 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 file is part of FFmpeg.
;*
-;* This program is distributed in the hope that it will be useful,
+;* 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
+;******************************************************************************
%include "x86inc.asm"
+%include "x86util.asm"
SECTION_RODATA
-pb_00: times 16 db 0x00
-pb_01: times 16 db 0x01
-pb_03: times 16 db 0x03
-pb_a1: times 16 db 0xa1
+
+cextern pb_0
+cextern pb_1
+cextern pb_3
+cextern pb_A1
SECTION .text
@@ -102,7 +107,7 @@ SECTION .text
movd %8, m5
%endmacro
-%macro SBUTTERFLY 4
+%macro SBUTTERFLY3 4
movq %4, %2
punpckl%1 %2, %3
punpckh%1 %4, %3
@@ -118,19 +123,19 @@ SECTION .text
movq m4, %5
movq m5, %6
movq m6, %7
- SBUTTERFLY bw, m0, m1, m7
- SBUTTERFLY bw, m2, m3, m1
- SBUTTERFLY bw, m4, m5, m3
+ SBUTTERFLY3 bw, m0, m1, m7
+ SBUTTERFLY3 bw, m2, m3, m1
+ SBUTTERFLY3 bw, m4, m5, m3
movq [%9+0x10], m1
- SBUTTERFLY bw, m6, %8, m5
- SBUTTERFLY wd, m0, m2, m1
- SBUTTERFLY wd, m4, m6, m2
+ SBUTTERFLY3 bw, m6, %8, m5
+ SBUTTERFLY3 wd, m0, m2, m1
+ SBUTTERFLY3 wd, m4, m6, m2
punpckhdq m0, m4
movq [%9+0x00], m0
- SBUTTERFLY wd, m7, [%9+0x10], m6
- SBUTTERFLY wd, m3, m5, m4
- SBUTTERFLY dq, m7, m3, m0
- SBUTTERFLY dq, m1, m2, m5
+ SBUTTERFLY3 wd, m7, [%9+0x10], m6
+ SBUTTERFLY3 wd, m3, m5, m4
+ SBUTTERFLY3 dq, m7, m3, m0
+ SBUTTERFLY3 dq, m1, m2, m5
punpckldq m6, m4
movq [%9+0x10], m1
movq [%9+0x20], m5
@@ -149,25 +154,25 @@ SECTION .text
movq m4, %5
movq m5, %6
movq m6, %7
- SBUTTERFLY bw, m0, m1, m7
- SBUTTERFLY bw, m2, m3, m1
- SBUTTERFLY bw, m4, m5, m3
- SBUTTERFLY bw, m6, %8, m5
+ SBUTTERFLY3 bw, m0, m1, m7
+ SBUTTERFLY3 bw, m2, m3, m1
+ SBUTTERFLY3 bw, m4, m5, m3
+ SBUTTERFLY3 bw, m6, %8, m5
movq %9, m3
- SBUTTERFLY wd, m0, m2, m3
- SBUTTERFLY wd, m4, m6, m2
- SBUTTERFLY wd, m7, m1, m6
+ SBUTTERFLY3 wd, m0, m2, m3
+ SBUTTERFLY3 wd, m4, m6, m2
+ SBUTTERFLY3 wd, m7, m1, m6
movq %11, m2
movq m2, %9
- SBUTTERFLY wd, m2, m5, m1
- SBUTTERFLY dq, m0, m4, m5
- SBUTTERFLY dq, m7, m2, m4
+ SBUTTERFLY3 wd, m2, m5, m1
+ SBUTTERFLY3 dq, m0, m4, m5
+ SBUTTERFLY3 dq, m7, m2, m4
movq %9, m0
movq %10, m5
movq %13, m7
movq %14, m4
- SBUTTERFLY dq, m3, %11, m0
- SBUTTERFLY dq, m6, m1, m5
+ SBUTTERFLY3 dq, m3, %11, m0
+ SBUTTERFLY3 dq, m6, m1, m5
movq %11, m3
movq %12, m0
movq %15, m6
@@ -233,19 +238,19 @@ SECTION .text
; clobbers: m0,3-6
%macro DEBLOCK_P0_Q0 0
mova m5, m1
- pxor m5, m2 ; p0^q0
- pand m5, [pb_01] ; (p0^q0)&1
+ pxor m5, m2 ; p0^q0
+ pand m5, [pb_1] ; (p0^q0)&1
pcmpeqb m4, m4
pxor m3, m4
- pavgb m3, m0 ; (p1 - q1 + 256)>>1
- pavgb m3, [pb_03] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2
+ pavgb m3, m0 ; (p1 - q1 + 256)>>1
+ pavgb m3, [pb_3] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2
pxor m4, m1
- pavgb m4, m2 ; (q0 - p0 + 256)>>1
+ pavgb m4, m2 ; (q0 - p0 + 256)>>1
pavgb m3, m5
- paddusb m3, m4 ; d+128+33
- mova m6, [pb_a1]
+ paddusb m3, m4 ; d+128+33
+ mova m6, [pb_A1]
psubusb m6, m3
- psubusb m3, [pb_a1]
+ psubusb m3, [pb_A1]
pminub m6, m7
pminub m3, m7
psubusb m1, m6
@@ -261,10 +266,10 @@ SECTION .text
%macro LUMA_Q1 6
mova %6, m1
pavgb %6, m2
- pavgb %2, %6 ; avg(p2,avg(p0,q0))
+ pavgb %2, %6 ; avg(p2,avg(p0,q0))
pxor %6, %3
- pand %6, [pb_01] ; (p2^avg(p0,q0))&1
- psubusb %2, %6 ; (p2+((p0+q0+1)>>1))>>1
+ pand %6, [pb_1] ; (p2^avg(p0,q0))&1
+ psubusb %2, %6 ; (p2+((p0+q0+1)>>1))>>1
mova %6, %1
psubusb %6, %5
paddusb %5, %1
@@ -493,6 +498,8 @@ cglobal x264_deblock_h_luma_%1, 0,5
RET
%endmacro ; DEBLOCK_LUMA
+INIT_MMX
+DEBLOCK_LUMA mmxext, v8, 8
INIT_XMM
DEBLOCK_LUMA sse2, v, 16
@@ -515,9 +522,9 @@ DEBLOCK_LUMA sse2, v, 16
mova t3, t2
mova t4, t2
psrlw t2, 1
- pavgb t2, mpb_00
+ pavgb t2, mpb_0
pxor t2, t0
- pand t2, mpb_01
+ pand t2, mpb_1
psubb t0, t2 ; p1' = (p2+p1+p0+q0+2)/4;
mova t1, p2
@@ -526,21 +533,21 @@ DEBLOCK_LUMA sse2, v, 16
psubb t2, q1
paddb t3, t3
psubb t3, t2 ; p2+2*p1+2*p0+2*q0+q1
- pand t2, mpb_01
+ pand t2, mpb_1
psubb t1, t2
pavgb t1, p1
pavgb t1, t5 ; (((p2+q1)/2 + p1+1)/2 + (p0+q0+1)/2 + 1)/2
psrlw t3, 2
- pavgb t3, mpb_00
+ pavgb t3, mpb_0
pxor t3, t1
- pand t3, mpb_01
+ pand t3, mpb_1
psubb t1, t3 ; p0'a = (p2+2*p1+2*p0+2*q0+q1+4)/8
mova t3, p0
mova t2, p0
pxor t3, q1
pavgb t2, q1
- pand t3, mpb_01
+ pand t3, mpb_1
psubb t2, t3
pavgb t2, p1 ; p0'b = (2*p1+p0+q0+2)/4
@@ -560,9 +567,9 @@ DEBLOCK_LUMA sse2, v, 16
paddb t2, t2
paddb t2, t4 ; 2*p3+3*p2+p1+p0+q0
psrlw t2, 2
- pavgb t2, mpb_00
+ pavgb t2, mpb_0
pxor t2, t1
- pand t2, mpb_01
+ pand t2, mpb_1
psubb t1, t2 ; p2' = (2*p3+3*p2+p1+p0+q0+4)/8
pxor t0, p1
@@ -601,8 +608,8 @@ DEBLOCK_LUMA sse2, v, 16
%define mask0 m12
%define mask1p m13
%define mask1q [rsp-24]
- %define mpb_00 m14
- %define mpb_01 m15
+ %define mpb_0 m14
+ %define mpb_1 m15
%else
%define spill(x) [esp+16*x+((stack_offset+4)&15)]
%define p2 [r4+r1]
@@ -612,8 +619,8 @@ DEBLOCK_LUMA sse2, v, 16
%define mask0 spill(2)
%define mask1p spill(3)
%define mask1q spill(4)
- %define mpb_00 [pb_00]
- %define mpb_01 [pb_01]
+ %define mpb_0 [pb_0]
+ %define mpb_1 [pb_1]
%endif
;-----------------------------------------------------------------------------
@@ -636,12 +643,12 @@ cglobal x264_deblock_%2_luma_intra_%1, 4,6,16
mova q0, [r0]
mova q1, [r0+r1]
%ifdef ARCH_X86_64
- pxor mpb_00, mpb_00
- mova mpb_01, [pb_01]
+ pxor mpb_0, mpb_0
+ mova mpb_1, [pb_1]
LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0
SWAP 7, 12 ; m12=mask0
- pavgb t5, mpb_00
- pavgb t5, mpb_01 ; alpha/4+1
+ pavgb t5, mpb_0
+ pavgb t5, mpb_1 ; alpha/4+1
movdqa p2, [r4+r1]
movdqa q2, [r0+2*r1]
DIFF_GT2 p0, q0, t5, t0, t3 ; t0 = |p0-q0| > alpha/4+1
@@ -656,8 +663,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]
- pavgb m4, [pb_01] ; alpha/4+1
+ pavgb m4, [pb_0]
+ pavgb m4, [pb_1] ; 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
@@ -757,3 +764,126 @@ DEBLOCK_LUMA_INTRA sse2, v
INIT_MMX
DEBLOCK_LUMA_INTRA mmxext, v8
%endif
+
+
+
+INIT_MMX
+
+%macro CHROMA_V_START 0
+ dec r2d ; alpha-1
+ dec r3d ; beta-1
+ mov t5, r0
+ sub t5, r1
+ sub t5, r1
+%endmacro
+
+%macro CHROMA_H_START 0
+ dec r2d
+ dec r3d
+ sub r0, 2
+ lea t6, [r1*3]
+ mov t5, r0
+ add r0, t6
+%endmacro
+
+%define t5 r5
+%define t6 r6
+
+;-----------------------------------------------------------------------------
+; void x264_deblock_v_chroma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+;-----------------------------------------------------------------------------
+cglobal x264_deblock_v_chroma_mmxext, 5,6
+ CHROMA_V_START
+ movq m0, [t5]
+ movq m1, [t5+r1]
+ movq m2, [r0]
+ movq m3, [r0+r1]
+ call x264_chroma_inter_body_mmxext
+ movq [t5+r1], m1
+ movq [r0], m2
+ RET
+
+;-----------------------------------------------------------------------------
+; void x264_deblock_h_chroma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+;-----------------------------------------------------------------------------
+cglobal x264_deblock_h_chroma_mmxext, 5,7
+%ifdef ARCH_X86_64
+ %define buf0 [rsp-24]
+ %define buf1 [rsp-16]
+%else
+ %define buf0 r0m
+ %define buf1 r2m
+%endif
+ CHROMA_H_START
+ TRANSPOSE4x8_LOAD PASS8ROWS(t5, r0, r1, t6)
+ movq buf0, m0
+ movq buf1, m3
+ call x264_chroma_inter_body_mmxext
+ movq m0, buf0
+ movq m3, buf1
+ TRANSPOSE8x4_STORE PASS8ROWS(t5, r0, r1, t6)
+ RET
+
+ALIGN 16
+x264_chroma_inter_body_mmxext:
+ LOAD_MASK r2d, r3d
+ movd m6, [r4] ; tc0
+ punpcklbw m6, m6
+ pand m7, m6
+ DEBLOCK_P0_Q0
+ ret
+
+
+
+; in: %1=p0 %2=p1 %3=q1
+; out: p0 = (p0 + q1 + 2*p1 + 2) >> 2
+%macro CHROMA_INTRA_P0 3
+ movq m4, %1
+ pxor m4, %3
+ pand m4, [pb_1] ; m4 = (p0^q1)&1
+ pavgb %1, %3
+ psubusb %1, m4
+ pavgb %1, %2 ; dst = avg(p1, avg(p0,q1) - ((p0^q1)&1))
+%endmacro
+
+%define t5 r4
+%define t6 r5
+
+;-----------------------------------------------------------------------------
+; void x264_deblock_v_chroma_intra( uint8_t *pix, int stride, int alpha, int beta )
+;-----------------------------------------------------------------------------
+cglobal x264_deblock_v_chroma_intra_mmxext, 4,5
+ CHROMA_V_START
+ movq m0, [t5]
+ movq m1, [t5+r1]
+ movq m2, [r0]
+ movq m3, [r0+r1]
+ call x264_chroma_intra_body_mmxext
+ movq [t5+r1], m1
+ movq [r0], m2
+ RET
+
+;-----------------------------------------------------------------------------
+; void x264_deblock_h_chroma_intra( uint8_t *pix, int stride, int alpha, int beta )
+;-----------------------------------------------------------------------------
+cglobal x264_deblock_h_chroma_intra_mmxext, 4,6
+ CHROMA_H_START
+ TRANSPOSE4x8_LOAD PASS8ROWS(t5, r0, r1, t6)
+ call x264_chroma_intra_body_mmxext
+ TRANSPOSE8x4_STORE PASS8ROWS(t5, r0, r1, t6)
+ RET
+
+ALIGN 16
+x264_chroma_intra_body_mmxext:
+ LOAD_MASK r2d, r3d
+ movq m5, m1
+ movq m6, m2
+ CHROMA_INTRA_P0 m1, m0, m3
+ CHROMA_INTRA_P0 m2, m3, m0
+ psubb m1, m5
+ psubb m2, m6
+ pand m1, m7
+ pand m2, m7
+ paddb m1, m5
+ paddb m2, m6
+ ret
diff --git a/lib/ffmpeg/libavcodec/x86/h264_idct.asm b/lib/ffmpeg/libavcodec/x86/h264_idct.asm
new file mode 100644
index 0000000000..fdb35003a8
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/h264_idct.asm
@@ -0,0 +1,1010 @@
+;*****************************************************************************
+;* MMX/SSE2-optimized H.264 iDCT
+;*****************************************************************************
+;* Copyright (C) 2004-2005 Michael Niedermayer, Loren Merritt
+;* Copyright (C) 2003-2008 x264 project
+;*
+;* Authors: Laurent Aimar <fenrir@via.ecp.fr>
+;* Loren Merritt <lorenm@u.washington.edu>
+;* Holger Lubitz <hal@duncan.ol.sub.de>
+;* Min Chen <chenm001.163.com>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;*****************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+SECTION_RODATA
+
+; FIXME this table is a duplicate from h264data.h, and will be removed once the tables from, h264 have been split
+scan8_mem: db 4+1*8, 5+1*8, 4+2*8, 5+2*8
+ db 6+1*8, 7+1*8, 6+2*8, 7+2*8
+ db 4+3*8, 5+3*8, 4+4*8, 5+4*8
+ db 6+3*8, 7+3*8, 6+4*8, 7+4*8
+ db 1+1*8, 2+1*8
+ db 1+2*8, 2+2*8
+ db 1+4*8, 2+4*8
+ db 1+5*8, 2+5*8
+%ifdef PIC
+%define scan8 r11
+%else
+%define scan8 scan8_mem
+%endif
+
+cextern pw_32
+cextern pw_1
+
+SECTION .text
+
+; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
+%macro IDCT4_ADD 3
+ ; Load dct coeffs
+ movq m0, [%2]
+ movq m1, [%2+8]
+ movq m2, [%2+16]
+ movq m3, [%2+24]
+
+ IDCT4_1D 0, 1, 2, 3, 4, 5
+ mova m6, [pw_32]
+ TRANSPOSE4x4W 0, 1, 2, 3, 4
+ paddw m0, m6
+ IDCT4_1D 0, 1, 2, 3, 4, 5
+ pxor m7, m7
+
+ STORE_DIFFx2 m0, m1, m4, m5, m7, 6, %1, %3
+ lea %1, [%1+%3*2]
+ STORE_DIFFx2 m2, m3, m4, m5, m7, 6, %1, %3
+%endmacro
+
+INIT_MMX
+; ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)
+cglobal h264_idct_add_mmx, 3, 3, 0
+ IDCT4_ADD r0, r1, r2
+ RET
+
+%macro IDCT8_1D 2
+ mova m4, m5
+ mova m0, m1
+ psraw m4, 1
+ psraw m1, 1
+ paddw m4, m5
+ paddw m1, m0
+ paddw m4, m7
+ paddw m1, m5
+ psubw m4, m0
+ paddw m1, m3
+
+ psubw m0, m3
+ psubw m5, m3
+ paddw m0, m7
+ psubw m5, m7
+ psraw m3, 1
+ psraw m7, 1
+ psubw m0, m3
+ psubw m5, m7
+
+ mova m3, m4
+ mova m7, m1
+ psraw m1, 2
+ psraw m3, 2
+ paddw m3, m0
+ psraw m0, 2
+ paddw m1, m5
+ psraw m5, 2
+ psubw m0, m4
+ psubw m7, m5
+
+ mova m4, m2
+ mova m5, m6
+ psraw m4, 1
+ psraw m6, 1
+ psubw m4, m5
+ paddw m6, m2
+
+ mova m2, %1
+ mova m5, %2
+ SUMSUB_BA m5, m2
+ SUMSUB_BA m6, m5
+ SUMSUB_BA m4, m2
+ SUMSUB_BA m7, m6
+ SUMSUB_BA m0, m4
+ SUMSUB_BA m3, m2
+ SUMSUB_BA m1, m5
+ SWAP 7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
+%endmacro
+
+%macro IDCT8_1D_FULL 1
+ mova m7, [%1+112]
+ mova m6, [%1+ 96]
+ mova m5, [%1+ 80]
+ mova m3, [%1+ 48]
+ mova m2, [%1+ 32]
+ mova m1, [%1+ 16]
+ IDCT8_1D [%1], [%1+ 64]
+%endmacro
+
+; %1=int16_t *block, %2=int16_t *dstblock
+%macro IDCT8_ADD_MMX_START 2
+ IDCT8_1D_FULL %1
+ mova [%1], m7
+ TRANSPOSE4x4W 0, 1, 2, 3, 7
+ mova m7, [%1]
+ mova [%2 ], m0
+ mova [%2+16], m1
+ mova [%2+32], m2
+ mova [%2+48], m3
+ TRANSPOSE4x4W 4, 5, 6, 7, 3
+ mova [%2+ 8], m4
+ mova [%2+24], m5
+ mova [%2+40], m6
+ mova [%2+56], m7
+%endmacro
+
+; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
+%macro IDCT8_ADD_MMX_END 3
+ IDCT8_1D_FULL %2
+ mova [%2 ], m5
+ mova [%2+16], m6
+ mova [%2+32], m7
+
+ pxor m7, m7
+ STORE_DIFFx2 m0, m1, m5, m6, m7, 6, %1, %3
+ lea %1, [%1+%3*2]
+ STORE_DIFFx2 m2, m3, m5, m6, m7, 6, %1, %3
+ mova m0, [%2 ]
+ mova m1, [%2+16]
+ mova m2, [%2+32]
+ lea %1, [%1+%3*2]
+ STORE_DIFFx2 m4, m0, m5, m6, m7, 6, %1, %3
+ lea %1, [%1+%3*2]
+ STORE_DIFFx2 m1, m2, m5, m6, m7, 6, %1, %3
+%endmacro
+
+INIT_MMX
+; ff_h264_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
+cglobal h264_idct8_add_mmx, 3, 4, 0
+ %assign pad 128+4-(stack_offset&7)
+ SUB rsp, pad
+
+ add word [r1], 32
+ IDCT8_ADD_MMX_START r1 , rsp
+ IDCT8_ADD_MMX_START r1+8, rsp+64
+ lea r3, [r0+4]
+ IDCT8_ADD_MMX_END r0 , rsp, r2
+ IDCT8_ADD_MMX_END r3 , rsp+8, r2
+
+ ADD rsp, pad
+ RET
+
+; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
+%macro IDCT8_ADD_SSE 4
+ IDCT8_1D_FULL %2
+%ifdef ARCH_X86_64
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
+%else
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, [%2], [%2+16]
+%endif
+ paddw m0, [pw_32]
+
+%ifndef ARCH_X86_64
+ mova [%2 ], m0
+ mova [%2+16], m4
+ IDCT8_1D [%2], [%2+ 16]
+ mova [%2 ], m6
+ mova [%2+16], m7
+%else
+ SWAP 0, 8
+ SWAP 4, 9
+ IDCT8_1D m8, m9
+ SWAP 6, 8
+ SWAP 7, 9
+%endif
+
+ pxor m7, m7
+ lea %4, [%3*3]
+ STORE_DIFF m0, m6, m7, [%1 ]
+ STORE_DIFF m1, m6, m7, [%1+%3 ]
+ STORE_DIFF m2, m6, m7, [%1+%3*2]
+ STORE_DIFF m3, m6, m7, [%1+%4 ]
+%ifndef ARCH_X86_64
+ mova m0, [%2 ]
+ mova m1, [%2+16]
+%else
+ SWAP 0, 8
+ SWAP 1, 9
+%endif
+ lea %1, [%1+%3*4]
+ STORE_DIFF m4, m6, m7, [%1 ]
+ STORE_DIFF m5, m6, m7, [%1+%3 ]
+ STORE_DIFF m0, m6, m7, [%1+%3*2]
+ STORE_DIFF m1, m6, m7, [%1+%4 ]
+%endmacro
+
+INIT_XMM
+; ff_h264_idct8_add_sse2(uint8_t *dst, int16_t *block, int stride)
+cglobal h264_idct8_add_sse2, 3, 4, 10
+ IDCT8_ADD_SSE r0, r1, r2, r3
+ RET
+
+%macro DC_ADD_MMX2_INIT 2-3
+%if %0 == 2
+ movsx %1, word [%1]
+ add %1, 32
+ sar %1, 6
+ movd m0, %1d
+ lea %1, [%2*3]
+%else
+ add %3, 32
+ sar %3, 6
+ movd m0, %3d
+ lea %3, [%2*3]
+%endif
+ pshufw m0, m0, 0
+ pxor m1, m1
+ psubw m1, m0
+ packuswb m0, m0
+ packuswb m1, m1
+%endmacro
+
+%macro DC_ADD_MMX2_OP 3-4
+ %1 m2, [%2 ]
+ %1 m3, [%2+%3 ]
+ %1 m4, [%2+%3*2]
+ %1 m5, [%2+%4 ]
+ paddusb m2, m0
+ paddusb m3, m0
+ paddusb m4, m0
+ paddusb m5, m0
+ psubusb m2, m1
+ psubusb m3, m1
+ psubusb m4, m1
+ psubusb m5, m1
+ %1 [%2 ], m2
+ %1 [%2+%3 ], m3
+ %1 [%2+%3*2], m4
+ %1 [%2+%4 ], m5
+%endmacro
+
+INIT_MMX
+; ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
+cglobal h264_idct_dc_add_mmx2, 3, 3, 0
+ DC_ADD_MMX2_INIT r1, r2
+ DC_ADD_MMX2_OP movh, r0, r2, r1
+ RET
+
+; ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
+cglobal h264_idct8_dc_add_mmx2, 3, 3, 0
+ DC_ADD_MMX2_INIT r1, r2
+ DC_ADD_MMX2_OP mova, r0, r2, r1
+ lea r0, [r0+r2*4]
+ DC_ADD_MMX2_OP mova, r0, r2, r1
+ RET
+
+; ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add16_mmx, 5, 7, 0
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .skipblock
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6]
+ IDCT4_ADD r6, r2, r3
+.skipblock
+ inc r5
+ add r2, 32
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+
+; ff_h264_idct8_add4_mmx(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct8_add4_mmx, 5, 7, 0
+ %assign pad 128+4-(stack_offset&7)
+ SUB rsp, pad
+
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .skipblock
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6]
+ add word [r2], 32
+ IDCT8_ADD_MMX_START r2 , rsp
+ IDCT8_ADD_MMX_START r2+8, rsp+64
+ IDCT8_ADD_MMX_END r6 , rsp, r3
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6+4]
+ IDCT8_ADD_MMX_END r6 , rsp+8, r3
+.skipblock
+ add r5, 4
+ add r2, 128
+ cmp r5, 16
+ jl .nextblock
+ ADD rsp, pad
+ RET
+
+; ff_h264_idct_add16_mmx2(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add16_mmx2, 5, 7, 0
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .skipblock
+ cmp r6, 1
+ jnz .no_dc
+ movsx r6, word [r2]
+ test r6, r6
+ jz .no_dc
+ DC_ADD_MMX2_INIT r2, r3, r6
+%ifdef ARCH_X86_64
+%define dst_reg r10
+%define dst_regd r10d
+%else
+%define dst_reg r1
+%define dst_regd r1d
+%endif
+ mov dst_regd, dword [r1+r5*4]
+ lea dst_reg, [r0+dst_reg]
+ DC_ADD_MMX2_OP movh, dst_reg, r3, r6
+%ifndef ARCH_X86_64
+ mov r1, r1m
+%endif
+ inc r5
+ add r2, 32
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+.no_dc
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6]
+ IDCT4_ADD r6, r2, r3
+.skipblock
+ inc r5
+ add r2, 32
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+
+; ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add16intra_mmx, 5, 7, 0
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ or r6w, word [r2]
+ test r6, r6
+ jz .skipblock
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6]
+ IDCT4_ADD r6, r2, r3
+.skipblock
+ inc r5
+ add r2, 32
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+
+; ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add16intra_mmx2, 5, 7, 0
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .try_dc
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6]
+ IDCT4_ADD r6, r2, r3
+ inc r5
+ add r2, 32
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+.try_dc
+ movsx r6, word [r2]
+ test r6, r6
+ jz .skipblock
+ DC_ADD_MMX2_INIT r2, r3, r6
+%ifdef ARCH_X86_64
+%define dst_reg r10
+%define dst_regd r10d
+%else
+%define dst_reg r1
+%define dst_regd r1d
+%endif
+ mov dst_regd, dword [r1+r5*4]
+ lea dst_reg, [r0+dst_reg]
+ DC_ADD_MMX2_OP movh, dst_reg, r3, r6
+%ifndef ARCH_X86_64
+ mov r1, r1m
+%endif
+.skipblock
+ inc r5
+ add r2, 32
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+
+; ff_h264_idct8_add4_mmx2(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct8_add4_mmx2, 5, 7, 0
+ %assign pad 128+4-(stack_offset&7)
+ SUB rsp, pad
+
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .skipblock
+ cmp r6, 1
+ jnz .no_dc
+ movsx r6, word [r2]
+ test r6, r6
+ jz .no_dc
+ DC_ADD_MMX2_INIT r2, r3, r6
+%ifdef ARCH_X86_64
+%define dst_reg r10
+%define dst_regd r10d
+%else
+%define dst_reg r1
+%define dst_regd r1d
+%endif
+ mov dst_regd, dword [r1+r5*4]
+ lea dst_reg, [r0+dst_reg]
+ DC_ADD_MMX2_OP mova, dst_reg, r3, r6
+ lea dst_reg, [dst_reg+r3*4]
+ DC_ADD_MMX2_OP mova, dst_reg, r3, r6
+%ifndef ARCH_X86_64
+ mov r1, r1m
+%endif
+ add r5, 4
+ add r2, 128
+ cmp r5, 16
+ jl .nextblock
+
+ ADD rsp, pad
+ RET
+.no_dc
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6]
+ add word [r2], 32
+ IDCT8_ADD_MMX_START r2 , rsp
+ IDCT8_ADD_MMX_START r2+8, rsp+64
+ IDCT8_ADD_MMX_END r6 , rsp, r3
+ mov r6d, dword [r1+r5*4]
+ lea r6, [r0+r6+4]
+ IDCT8_ADD_MMX_END r6 , rsp+8, r3
+.skipblock
+ add r5, 4
+ add r2, 128
+ cmp r5, 16
+ jl .nextblock
+
+ ADD rsp, pad
+ RET
+
+INIT_XMM
+; ff_h264_idct8_add4_sse2(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct8_add4_sse2, 5, 7, 10
+ xor r5, r5
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .skipblock
+ cmp r6, 1
+ jnz .no_dc
+ movsx r6, word [r2]
+ test r6, r6
+ jz .no_dc
+INIT_MMX
+ DC_ADD_MMX2_INIT r2, r3, r6
+%ifdef ARCH_X86_64
+%define dst_reg r10
+%define dst_regd r10d
+%else
+%define dst_reg r1
+%define dst_regd r1d
+%endif
+ mov dst_regd, dword [r1+r5*4]
+ lea dst_reg, [r0+dst_reg]
+ DC_ADD_MMX2_OP mova, dst_reg, r3, r6
+ lea dst_reg, [dst_reg+r3*4]
+ DC_ADD_MMX2_OP mova, dst_reg, r3, r6
+%ifndef ARCH_X86_64
+ mov r1, r1m
+%endif
+ add r5, 4
+ add r2, 128
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+.no_dc
+INIT_XMM
+ mov dst_regd, dword [r1+r5*4]
+ lea dst_reg, [r0+dst_reg]
+ IDCT8_ADD_SSE dst_reg, r2, r3, r6
+%ifndef ARCH_X86_64
+ mov r1, r1m
+%endif
+.skipblock
+ add r5, 4
+ add r2, 128
+ cmp r5, 16
+ jl .nextblock
+ REP_RET
+
+INIT_MMX
+h264_idct_add8_mmx_plane:
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ or r6w, word [r2]
+ test r6, r6
+ jz .skipblock
+%ifdef ARCH_X86_64
+ mov r0d, dword [r1+r5*4]
+ add r0, [r10]
+%else
+ mov r0, r1m ; XXX r1m here is actually r0m of the calling func
+ mov r0, [r0]
+ add r0, dword [r1+r5*4]
+%endif
+ IDCT4_ADD r0, r2, r3
+.skipblock
+ inc r5
+ add r2, 32
+ test r5, 3
+ jnz .nextblock
+ rep ret
+
+; ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add8_mmx, 5, 7, 0
+ mov r5, 16
+ add r2, 512
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+%ifdef ARCH_X86_64
+ mov r10, r0
+%endif
+ call h264_idct_add8_mmx_plane
+%ifdef ARCH_X86_64
+ add r10, gprsize
+%else
+ add r0mp, gprsize
+%endif
+ call h264_idct_add8_mmx_plane
+ RET
+
+h264_idct_add8_mmx2_plane
+.nextblock
+ movzx r6, byte [scan8+r5]
+ movzx r6, byte [r4+r6]
+ test r6, r6
+ jz .try_dc
+%ifdef ARCH_X86_64
+ mov r0d, dword [r1+r5*4]
+ add r0, [r10]
+%else
+ mov r0, r1m ; XXX r1m here is actually r0m of the calling func
+ mov r0, [r0]
+ add r0, dword [r1+r5*4]
+%endif
+ IDCT4_ADD r0, r2, r3
+ inc r5
+ add r2, 32
+ test r5, 3
+ jnz .nextblock
+ rep ret
+.try_dc
+ movsx r6, word [r2]
+ test r6, r6
+ jz .skipblock
+ DC_ADD_MMX2_INIT r2, r3, r6
+%ifdef ARCH_X86_64
+ mov r0d, dword [r1+r5*4]
+ add r0, [r10]
+%else
+ mov r0, r1m ; XXX r1m here is actually r0m of the calling func
+ mov r0, [r0]
+ add r0, dword [r1+r5*4]
+%endif
+ DC_ADD_MMX2_OP movh, r0, r3, r6
+.skipblock
+ inc r5
+ add r2, 32
+ test r5, 3
+ jnz .nextblock
+ rep ret
+
+; ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add8_mmx2, 5, 7, 0
+ mov r5, 16
+ add r2, 512
+%ifdef ARCH_X86_64
+ mov r10, r0
+%endif
+%ifdef PIC
+ lea r11, [scan8_mem]
+%endif
+ call h264_idct_add8_mmx2_plane
+%ifdef ARCH_X86_64
+ add r10, gprsize
+%else
+ add r0mp, gprsize
+%endif
+ call h264_idct_add8_mmx2_plane
+ RET
+
+INIT_MMX
+; r0 = uint8_t *dst, r2 = int16_t *block, r3 = int stride, r6=clobbered
+h264_idct_dc_add8_mmx2:
+ movd m0, [r2 ] ; 0 0 X D
+ punpcklwd m0, [r2+32] ; x X d D
+ paddsw m0, [pw_32]
+ psraw m0, 6
+ punpcklwd m0, m0 ; d d D D
+ pxor m1, m1 ; 0 0 0 0
+ psubw m1, m0 ; -d-d-D-D
+ packuswb m0, m1 ; -d-d-D-D d d D D
+ pshufw m1, m0, 0xFA ; -d-d-d-d-D-D-D-D
+ punpcklwd m0, m0 ; d d d d D D D D
+ lea r6, [r3*3]
+ DC_ADD_MMX2_OP movq, r0, r3, r6
+ ret
+
+ALIGN 16
+INIT_XMM
+; r0 = uint8_t *dst (clobbered), r2 = int16_t *block, r3 = int stride
+x264_add8x4_idct_sse2:
+ movq m0, [r2+ 0]
+ movq m1, [r2+ 8]
+ movq m2, [r2+16]
+ movq m3, [r2+24]
+ movhps m0, [r2+32]
+ movhps m1, [r2+40]
+ movhps m2, [r2+48]
+ movhps m3, [r2+56]
+ IDCT4_1D 0,1,2,3,4,5
+ TRANSPOSE2x4x4W 0,1,2,3,4
+ paddw m0, [pw_32]
+ IDCT4_1D 0,1,2,3,4,5
+ pxor m7, m7
+ STORE_DIFFx2 m0, m1, m4, m5, m7, 6, r0, r3
+ lea r0, [r0+r3*2]
+ STORE_DIFFx2 m2, m3, m4, m5, m7, 6, r0, r3
+ ret
+
+%macro add16_sse2_cycle 2
+ movzx r0, word [r4+%2]
+ test r0, r0
+ jz .cycle%1end
+ mov r0d, dword [r1+%1*8]
+%ifdef ARCH_X86_64
+ add r0, r10
+%else
+ add r0, r0m
+%endif
+ call x264_add8x4_idct_sse2
+.cycle%1end
+%if %1 < 7
+ add r2, 64
+%endif
+%endmacro
+
+; ff_h264_idct_add16_sse2(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add16_sse2, 5, 5, 8
+%ifdef ARCH_X86_64
+ mov r10, r0
+%endif
+ ; unrolling of the loop leads to an average performance gain of
+ ; 20-25%
+ add16_sse2_cycle 0, 0xc
+ add16_sse2_cycle 1, 0x14
+ add16_sse2_cycle 2, 0xe
+ add16_sse2_cycle 3, 0x16
+ add16_sse2_cycle 4, 0x1c
+ add16_sse2_cycle 5, 0x24
+ add16_sse2_cycle 6, 0x1e
+ add16_sse2_cycle 7, 0x26
+ RET
+
+%macro add16intra_sse2_cycle 2
+ movzx r0, word [r4+%2]
+ test r0, r0
+ jz .try%1dc
+ mov r0d, dword [r1+%1*8]
+%ifdef ARCH_X86_64
+ add r0, r10
+%else
+ add r0, r0m
+%endif
+ call x264_add8x4_idct_sse2
+ jmp .cycle%1end
+.try%1dc
+ movsx r0, word [r2 ]
+ or r0w, word [r2+32]
+ jz .cycle%1end
+ mov r0d, dword [r1+%1*8]
+%ifdef ARCH_X86_64
+ add r0, r10
+%else
+ add r0, r0m
+%endif
+ call h264_idct_dc_add8_mmx2
+.cycle%1end
+%if %1 < 7
+ add r2, 64
+%endif
+%endmacro
+
+; ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add16intra_sse2, 5, 7, 8
+%ifdef ARCH_X86_64
+ mov r10, r0
+%endif
+ add16intra_sse2_cycle 0, 0xc
+ add16intra_sse2_cycle 1, 0x14
+ add16intra_sse2_cycle 2, 0xe
+ add16intra_sse2_cycle 3, 0x16
+ add16intra_sse2_cycle 4, 0x1c
+ add16intra_sse2_cycle 5, 0x24
+ add16intra_sse2_cycle 6, 0x1e
+ add16intra_sse2_cycle 7, 0x26
+ RET
+
+%macro add8_sse2_cycle 2
+ movzx r0, word [r4+%2]
+ test r0, r0
+ jz .try%1dc
+%ifdef ARCH_X86_64
+ mov r0d, dword [r1+%1*8+64]
+ add r0, [r10]
+%else
+ mov r0, r0m
+ mov r0, [r0]
+ add r0, dword [r1+%1*8+64]
+%endif
+ call x264_add8x4_idct_sse2
+ jmp .cycle%1end
+.try%1dc
+ movsx r0, word [r2 ]
+ or r0w, word [r2+32]
+ jz .cycle%1end
+%ifdef ARCH_X86_64
+ mov r0d, dword [r1+%1*8+64]
+ add r0, [r10]
+%else
+ mov r0, r0m
+ mov r0, [r0]
+ add r0, dword [r1+%1*8+64]
+%endif
+ call h264_idct_dc_add8_mmx2
+.cycle%1end
+%if %1 < 3
+ add r2, 64
+%endif
+%endmacro
+
+; ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset,
+; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
+cglobal h264_idct_add8_sse2, 5, 7, 8
+ add r2, 512
+%ifdef ARCH_X86_64
+ mov r10, r0
+%endif
+ add8_sse2_cycle 0, 0x09
+ add8_sse2_cycle 1, 0x11
+%ifdef ARCH_X86_64
+ add r10, gprsize
+%else
+ add r0mp, gprsize
+%endif
+ add8_sse2_cycle 2, 0x21
+ add8_sse2_cycle 3, 0x29
+ RET
+
+;void ff_h264_luma_dc_dequant_idct_mmx(DCTELEM *output, DCTELEM *input, int qmul)
+
+%macro WALSH4_1D 5
+ SUMSUB_BADC m%4, m%3, m%2, m%1, m%5
+ SUMSUB_BADC m%4, m%2, m%3, m%1, m%5
+ SWAP %1, %4, %3
+%endmacro
+
+%macro DEQUANT_MMX 3
+ mova m7, [pw_1]
+ mova m4, %1
+ punpcklwd %1, m7
+ punpckhwd m4, m7
+ mova m5, %2
+ punpcklwd %2, m7
+ punpckhwd m5, m7
+ movd m7, t3d
+ punpckldq m7, m7
+ pmaddwd %1, m7
+ pmaddwd %2, m7
+ pmaddwd m4, m7
+ pmaddwd m5, m7
+ psrad %1, %3
+ psrad %2, %3
+ psrad m4, %3
+ psrad m5, %3
+ packssdw %1, m4
+ packssdw %2, m5
+%endmacro
+
+%macro STORE_WORDS_MMX 5
+ movd t0d, %1
+ psrlq %1, 32
+ movd t1d, %1
+ mov [t2+%2*32], t0w
+ mov [t2+%4*32], t1w
+ shr t0d, 16
+ shr t1d, 16
+ mov [t2+%3*32], t0w
+ mov [t2+%5*32], t1w
+%endmacro
+
+%macro DEQUANT_STORE_MMX 1
+ DEQUANT_MMX m0, m1, %1
+ STORE_WORDS_MMX m0, 0, 1, 4, 5
+ STORE_WORDS_MMX m1, 2, 3, 6, 7
+
+ DEQUANT_MMX m2, m3, %1
+ STORE_WORDS_MMX m2, 8, 9, 12, 13
+ STORE_WORDS_MMX m3, 10, 11, 14, 15
+%endmacro
+
+%macro STORE_WORDS_SSE 9
+ movd t0d, %1
+ psrldq %1, 4
+ movd t1d, %1
+ psrldq %1, 4
+ mov [t2+%2*32], t0w
+ mov [t2+%4*32], t1w
+ shr t0d, 16
+ shr t1d, 16
+ mov [t2+%3*32], t0w
+ mov [t2+%5*32], t1w
+ movd t0d, %1
+ psrldq %1, 4
+ movd t1d, %1
+ mov [t2+%6*32], t0w
+ mov [t2+%8*32], t1w
+ shr t0d, 16
+ shr t1d, 16
+ mov [t2+%7*32], t0w
+ mov [t2+%9*32], t1w
+%endmacro
+
+%macro DEQUANT_STORE_SSE2 1
+ movd xmm4, t3d
+ movq xmm5, [pw_1]
+ pshufd xmm4, xmm4, 0
+ movq2dq xmm0, m0
+ movq2dq xmm1, m1
+ movq2dq xmm2, m2
+ movq2dq xmm3, m3
+ punpcklwd xmm0, xmm5
+ punpcklwd xmm1, xmm5
+ punpcklwd xmm2, xmm5
+ punpcklwd xmm3, xmm5
+ pmaddwd xmm0, xmm4
+ pmaddwd xmm1, xmm4
+ pmaddwd xmm2, xmm4
+ pmaddwd xmm3, xmm4
+ psrad xmm0, %1
+ psrad xmm1, %1
+ psrad xmm2, %1
+ psrad xmm3, %1
+ packssdw xmm0, xmm1
+ packssdw xmm2, xmm3
+ STORE_WORDS_SSE xmm0, 0, 1, 4, 5, 2, 3, 6, 7
+ STORE_WORDS_SSE xmm2, 8, 9, 12, 13, 10, 11, 14, 15
+%endmacro
+
+%macro IDCT_DC_DEQUANT 2
+cglobal h264_luma_dc_dequant_idct_%1, 3,4,%2
+ movq m3, [r1+24]
+ movq m2, [r1+16]
+ movq m1, [r1+ 8]
+ movq m0, [r1+ 0]
+ WALSH4_1D 0,1,2,3,4
+ TRANSPOSE4x4W 0,1,2,3,4
+ WALSH4_1D 0,1,2,3,4
+
+; shift, tmp, output, qmul
+%ifdef WIN64
+ DECLARE_REG_TMP 0,3,1,2
+ ; we can't avoid this, because r0 is the shift register (ecx) on win64
+ xchg r0, t2
+%elifdef ARCH_X86_64
+ DECLARE_REG_TMP 3,1,0,2
+%else
+ DECLARE_REG_TMP 1,3,0,2
+%endif
+
+ cmp t3d, 32767
+ jg .big_qmul
+ add t3d, 128 << 16
+%ifidn %1,mmx
+ DEQUANT_STORE_MMX 8
+%else
+ DEQUANT_STORE_SSE2 8
+%endif
+ RET
+.big_qmul:
+ bsr t0d, t3d
+ add t3d, 128 << 16
+ mov t1d, 7
+ cmp t0d, t1d
+ cmovg t0d, t1d
+ inc t1d
+ shr t3d, t0b
+ sub t1d, t0d
+%ifidn %1,mmx
+ movd m6, t1d
+ DEQUANT_STORE_MMX m6
+%else
+ movd xmm6, t1d
+ DEQUANT_STORE_SSE2 xmm6
+%endif
+ RET
+%endmacro
+
+INIT_MMX
+IDCT_DC_DEQUANT mmx, 0
+IDCT_DC_DEQUANT sse2, 7
diff --git a/lib/ffmpeg/libavcodec/x86/h264_idct_sse2.asm b/lib/ffmpeg/libavcodec/x86/h264_idct_sse2.asm
deleted file mode 100644
index 86c1e66c72..0000000000
--- a/lib/ffmpeg/libavcodec/x86/h264_idct_sse2.asm
+++ /dev/null
@@ -1,54 +0,0 @@
-;*****************************************************************************
-;* SSE2-optimized H.264 iDCT
-;*****************************************************************************
-;* Copyright (C) 2003-2008 x264 project
-;*
-;* Authors: Laurent Aimar <fenrir@via.ecp.fr>
-;* Loren Merritt <lorenm@u.washington.edu>
-;* Holger Lubitz <hal@duncan.ol.sub.de>
-;* Min Chen <chenm001.163.com>
-;*
-;* 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 02111, USA.
-;*****************************************************************************
-
-%include "x86inc.asm"
-%include "x86util.asm"
-
-SECTION_RODATA
-pw_32: times 8 dw 32
-
-SECTION .text
-
-INIT_XMM
-cglobal x264_add8x4_idct_sse2, 3,3,8
- movq m0, [r1+ 0]
- movq m1, [r1+ 8]
- movq m2, [r1+16]
- movq m3, [r1+24]
- movhps m0, [r1+32]
- movhps m1, [r1+40]
- movhps m2, [r1+48]
- movhps m3, [r1+56]
- IDCT4_1D 0,1,2,3,4,5
- TRANSPOSE2x4x4W 0,1,2,3,4
- paddw m0, [pw_32]
- IDCT4_1D 0,1,2,3,4,5
- pxor m7, m7
- STORE_DIFF m0, m4, m7, [r0]
- STORE_DIFF m1, m4, m7, [r0+r2]
- lea r0, [r0+r2*2]
- STORE_DIFF m2, m4, m7, [r0]
- STORE_DIFF m3, m4, m7, [r0+r2]
- RET
diff --git a/lib/ffmpeg/libavcodec/x86/h264_intrapred.asm b/lib/ffmpeg/libavcodec/x86/h264_intrapred.asm
index d36ecfb890..28c2f399c3 100644
--- a/lib/ffmpeg/libavcodec/x86/h264_intrapred.asm
+++ b/lib/ffmpeg/libavcodec/x86/h264_intrapred.asm
@@ -1,6 +1,9 @@
;******************************************************************************
;* H.264 intra prediction asm optimizations
;* Copyright (c) 2010 Jason Garrett-Glaser
+;* Copyright (c) 2010 Holger Lubitz
+;* Copyright (c) 2010 Loren Merritt
+;* Copyright (c) 2010 Ronald S. Bultje
;*
;* This file is part of FFmpeg.
;*
@@ -20,15 +23,31 @@
;******************************************************************************
%include "x86inc.asm"
+%include "x86util.asm"
SECTION_RODATA
tm_shuf: times 8 db 0x03, 0x80
+pw_ff00: times 8 dw 0xff00
+plane_shuf: db -8, -7, -6, -5, -4, -3, -2, -1
+ db 1, 2, 3, 4, 5, 6, 7, 8
+plane8_shuf: db -4, -3, -2, -1, 0, 0, 0, 0
+ db 1, 2, 3, 4, 0, 0, 0, 0
+pw_0to7: dw 0, 1, 2, 3, 4, 5, 6, 7
+pw_1to8: dw 1, 2, 3, 4, 5, 6, 7, 8
+pw_m8tom1: dw -8, -7, -6, -5, -4, -3, -2, -1
+pw_m4to4: dw -4, -3, -2, -1, 1, 2, 3, 4
SECTION .text
cextern pb_1
cextern pb_3
+cextern pw_4
+cextern pw_5
+cextern pw_8
+cextern pw_16
+cextern pw_17
+cextern pw_32
;-----------------------------------------------------------------------------
; void pred16x16_vertical(uint8_t *src, int stride)
@@ -266,6 +285,497 @@ cglobal pred16x16_tm_vp8_sse2, 2,6,6
REP_RET
;-----------------------------------------------------------------------------
+; void pred16x16_plane(uint8_t *src, int stride)
+;-----------------------------------------------------------------------------
+
+%macro H264_PRED16x16_PLANE 3
+cglobal pred16x16_plane_%3_%1, 2, 7, %2
+ mov r2, r1 ; +stride
+ neg r1 ; -stride
+
+ movh m0, [r0+r1 -1]
+%if mmsize == 8
+ pxor m4, m4
+ movh m1, [r0+r1 +3 ]
+ movh m2, [r0+r1 +8 ]
+ movh m3, [r0+r1 +12]
+ punpcklbw m0, m4
+ punpcklbw m1, m4
+ punpcklbw m2, m4
+ punpcklbw m3, m4
+ pmullw m0, [pw_m8tom1 ]
+ pmullw m1, [pw_m8tom1+8]
+ pmullw m2, [pw_1to8 ]
+ pmullw m3, [pw_1to8 +8]
+ paddw m0, m2
+ paddw m1, m3
+%else ; mmsize == 16
+%ifidn %1, sse2
+ pxor m2, m2
+ movh m1, [r0+r1 +8]
+ punpcklbw m0, m2
+ punpcklbw m1, m2
+ pmullw m0, [pw_m8tom1]
+ pmullw m1, [pw_1to8]
+ paddw m0, m1
+%else ; ssse3
+ movhps m0, [r0+r1 +8]
+ pmaddubsw m0, [plane_shuf] ; H coefficients
+%endif
+ movhlps m1, m0
+%endif
+ paddw m0, m1
+%ifidn %1, mmx
+ mova m1, m0
+ psrlq m1, 32
+%elifidn %1, mmx2
+ pshufw m1, m0, 0xE
+%else ; mmsize == 16
+ pshuflw m1, m0, 0xE
+%endif
+ paddw m0, m1
+%ifidn %1, mmx
+ mova m1, m0
+ psrlq m1, 16
+%elifidn %1, mmx2
+ pshufw m1, m0, 0x1
+%else
+ pshuflw m1, m0, 0x1
+%endif
+ paddw m0, m1 ; sum of H coefficients
+
+ lea r4, [r0+r2*8-1]
+ lea r3, [r0+r2*4-1]
+ add r4, r2
+
+%ifdef ARCH_X86_64
+%define e_reg r11
+%else
+%define e_reg r0
+%endif
+
+ movzx e_reg, byte [r3+r2*2 ]
+ movzx r5, byte [r4+r1 ]
+ sub r5, e_reg
+
+ movzx e_reg, byte [r3+r2 ]
+ movzx r6, byte [r4 ]
+ sub r6, e_reg
+ lea r5, [r5+r6*2]
+
+ movzx e_reg, byte [r3+r1 ]
+ movzx r6, byte [r4+r2*2 ]
+ sub r6, e_reg
+ lea r5, [r5+r6*4]
+
+ movzx e_reg, byte [r3 ]
+%ifdef ARCH_X86_64
+ movzx r10, byte [r4+r2 ]
+ sub r10, e_reg
+%else
+ movzx r6, byte [r4+r2 ]
+ sub r6, e_reg
+ lea r5, [r5+r6*4]
+ sub r5, r6
+%endif
+
+ lea e_reg, [r3+r1*4]
+ lea r3, [r4+r2*4]
+
+ movzx r4, byte [e_reg+r2 ]
+ movzx r6, byte [r3 ]
+ sub r6, r4
+%ifdef ARCH_X86_64
+ lea r6, [r10+r6*2]
+ lea r5, [r5+r6*2]
+ add r5, r6
+%else
+ lea r5, [r5+r6*4]
+ lea r5, [r5+r6*2]
+%endif
+
+ movzx r4, byte [e_reg ]
+%ifdef ARCH_X86_64
+ movzx r10, byte [r3 +r2 ]
+ sub r10, r4
+ sub r5, r10
+%else
+ movzx r6, byte [r3 +r2 ]
+ sub r6, r4
+ lea r5, [r5+r6*8]
+ sub r5, r6
+%endif
+
+ movzx r4, byte [e_reg+r1 ]
+ movzx r6, byte [r3 +r2*2]
+ sub r6, r4
+%ifdef ARCH_X86_64
+ add r6, r10
+%endif
+ lea r5, [r5+r6*8]
+
+ movzx r4, byte [e_reg+r2*2]
+ movzx r6, byte [r3 +r1 ]
+ sub r6, r4
+ lea r5, [r5+r6*4]
+ add r5, r6 ; sum of V coefficients
+
+%ifndef ARCH_X86_64
+ mov r0, r0m
+%endif
+
+%ifidn %3, h264
+ lea r5, [r5*5+32]
+ sar r5, 6
+%elifidn %3, rv40
+ lea r5, [r5*5]
+ sar r5, 6
+%elifidn %3, svq3
+ test r5, r5
+ lea r6, [r5+3]
+ cmovs r5, r6
+ sar r5, 2 ; V/4
+ lea r5, [r5*5] ; 5*(V/4)
+ test r5, r5
+ lea r6, [r5+15]
+ cmovs r5, r6
+ sar r5, 4 ; (5*(V/4))/16
+%endif
+
+ movzx r4, byte [r0+r1 +15]
+ movzx r3, byte [r3+r2*2 ]
+ lea r3, [r3+r4+1]
+ shl r3, 4
+
+ movd r1d, m0
+ movsx r1d, r1w
+%ifnidn %3, svq3
+%ifidn %3, h264
+ lea r1d, [r1d*5+32]
+%else ; rv40
+ lea r1d, [r1d*5]
+%endif
+ sar r1d, 6
+%else ; svq3
+ test r1d, r1d
+ lea r4d, [r1d+3]
+ cmovs r1d, r4d
+ sar r1d, 2 ; H/4
+ lea r1d, [r1d*5] ; 5*(H/4)
+ test r1d, r1d
+ lea r4d, [r1d+15]
+ cmovs r1d, r4d
+ sar r1d, 4 ; (5*(H/4))/16
+%endif
+ movd m0, r1d
+
+ add r1d, r5d
+ add r3d, r1d
+ shl r1d, 3
+ sub r3d, r1d ; a
+
+ movd m1, r5d
+ movd m3, r3d
+%ifidn %1, mmx
+ punpcklwd m0, m0
+ punpcklwd m1, m1
+ punpcklwd m3, m3
+ punpckldq m0, m0
+ punpckldq m1, m1
+ punpckldq m3, m3
+%elifidn %1, mmx2
+ pshufw m0, m0, 0x0
+ pshufw m1, m1, 0x0
+ pshufw m3, m3, 0x0
+%else
+ pshuflw m0, m0, 0x0
+ pshuflw m1, m1, 0x0
+ pshuflw m3, m3, 0x0
+ punpcklqdq m0, m0 ; splat H (words)
+ punpcklqdq m1, m1 ; splat V (words)
+ punpcklqdq m3, m3 ; splat a (words)
+%endif
+%ifidn %3, svq3
+ SWAP 0, 1
+%endif
+ mova m2, m0
+%if mmsize == 8
+ mova m5, m0
+%endif
+ pmullw m0, [pw_0to7] ; 0*H, 1*H, ..., 7*H (words)
+%if mmsize == 16
+ psllw m2, 3
+%else
+ psllw m5, 3
+ psllw m2, 2
+ mova m6, m5
+ paddw m6, m2
+%endif
+ paddw m0, m3 ; a + {0,1,2,3,4,5,6,7}*H
+ paddw m2, m0 ; a + {8,9,10,11,12,13,14,15}*H
+%if mmsize == 8
+ paddw m5, m0 ; a + {8,9,10,11}*H
+ paddw m6, m0 ; a + {12,13,14,15}*H
+%endif
+
+ mov r4, 8
+.loop
+ mova m3, m0 ; b[0..7]
+ mova m4, m2 ; b[8..15]
+ psraw m3, 5
+ psraw m4, 5
+ packuswb m3, m4
+ mova [r0], m3
+%if mmsize == 8
+ mova m3, m5 ; b[8..11]
+ mova m4, m6 ; b[12..15]
+ psraw m3, 5
+ psraw m4, 5
+ packuswb m3, m4
+ mova [r0+8], m3
+%endif
+ paddw m0, m1
+ paddw m2, m1
+%if mmsize == 8
+ paddw m5, m1
+ paddw m6, m1
+%endif
+
+ mova m3, m0 ; b[0..7]
+ mova m4, m2 ; b[8..15]
+ psraw m3, 5
+ psraw m4, 5
+ packuswb m3, m4
+ mova [r0+r2], m3
+%if mmsize == 8
+ mova m3, m5 ; b[8..11]
+ mova m4, m6 ; b[12..15]
+ psraw m3, 5
+ psraw m4, 5
+ packuswb m3, m4
+ mova [r0+r2+8], m3
+%endif
+ paddw m0, m1
+ paddw m2, m1
+%if mmsize == 8
+ paddw m5, m1
+ paddw m6, m1
+%endif
+
+ lea r0, [r0+r2*2]
+ dec r4
+ jg .loop
+ REP_RET
+%endmacro
+
+INIT_MMX
+H264_PRED16x16_PLANE mmx, 0, h264
+H264_PRED16x16_PLANE mmx, 0, rv40
+H264_PRED16x16_PLANE mmx, 0, svq3
+H264_PRED16x16_PLANE mmx2, 0, h264
+H264_PRED16x16_PLANE mmx2, 0, rv40
+H264_PRED16x16_PLANE mmx2, 0, svq3
+INIT_XMM
+H264_PRED16x16_PLANE sse2, 8, h264
+H264_PRED16x16_PLANE sse2, 8, rv40
+H264_PRED16x16_PLANE sse2, 8, svq3
+H264_PRED16x16_PLANE ssse3, 8, h264
+H264_PRED16x16_PLANE ssse3, 8, rv40
+H264_PRED16x16_PLANE ssse3, 8, svq3
+
+;-----------------------------------------------------------------------------
+; void pred8x8_plane(uint8_t *src, int stride)
+;-----------------------------------------------------------------------------
+
+%macro H264_PRED8x8_PLANE 2
+cglobal pred8x8_plane_%1, 2, 7, %2
+ mov r2, r1 ; +stride
+ neg r1 ; -stride
+
+ movd m0, [r0+r1 -1]
+%if mmsize == 8
+ pxor m2, m2
+ movh m1, [r0+r1 +4 ]
+ punpcklbw m0, m2
+ punpcklbw m1, m2
+ pmullw m0, [pw_m4to4]
+ pmullw m1, [pw_m4to4+8]
+%else ; mmsize == 16
+%ifidn %1, sse2
+ pxor m2, m2
+ movd m1, [r0+r1 +4]
+ punpckldq m0, m1
+ punpcklbw m0, m2
+ pmullw m0, [pw_m4to4]
+%else ; ssse3
+ movhps m0, [r0+r1 +4] ; this reads 4 bytes more than necessary
+ pmaddubsw m0, [plane8_shuf] ; H coefficients
+%endif
+ movhlps m1, m0
+%endif
+ paddw m0, m1
+
+%ifnidn %1, ssse3
+%ifidn %1, mmx
+ mova m1, m0
+ psrlq m1, 32
+%elifidn %1, mmx2
+ pshufw m1, m0, 0xE
+%else ; mmsize == 16
+ pshuflw m1, m0, 0xE
+%endif
+ paddw m0, m1
+%endif ; !ssse3
+
+%ifidn %1, mmx
+ mova m1, m0
+ psrlq m1, 16
+%elifidn %1, mmx2
+ pshufw m1, m0, 0x1
+%else
+ pshuflw m1, m0, 0x1
+%endif
+ paddw m0, m1 ; sum of H coefficients
+
+ lea r4, [r0+r2*4-1]
+ lea r3, [r0 -1]
+ add r4, r2
+
+%ifdef ARCH_X86_64
+%define e_reg r11
+%else
+%define e_reg r0
+%endif
+
+ movzx e_reg, byte [r3+r2*2 ]
+ movzx r5, byte [r4+r1 ]
+ sub r5, e_reg
+
+ movzx e_reg, byte [r3 ]
+%ifdef ARCH_X86_64
+ movzx r10, byte [r4+r2 ]
+ sub r10, e_reg
+ sub r5, r10
+%else
+ movzx r6, byte [r4+r2 ]
+ sub r6, e_reg
+ lea r5, [r5+r6*4]
+ sub r5, r6
+%endif
+
+ movzx e_reg, byte [r3+r1 ]
+ movzx r6, byte [r4+r2*2 ]
+ sub r6, e_reg
+%ifdef ARCH_X86_64
+ add r6, r10
+%endif
+ lea r5, [r5+r6*4]
+
+ movzx e_reg, byte [r3+r2 ]
+ movzx r6, byte [r4 ]
+ sub r6, e_reg
+ lea r6, [r5+r6*2]
+
+ lea r5, [r6*9+16]
+ lea r5, [r5+r6*8]
+ sar r5, 5
+
+%ifndef ARCH_X86_64
+ mov r0, r0m
+%endif
+
+ movzx r3, byte [r4+r2*2 ]
+ movzx r4, byte [r0+r1 +7]
+ lea r3, [r3+r4+1]
+ shl r3, 4
+ movd r1d, m0
+ movsx r1d, r1w
+ imul r1d, 17
+ add r1d, 16
+ sar r1d, 5
+ movd m0, r1d
+ add r1d, r5d
+ sub r3d, r1d
+ add r1d, r1d
+ sub r3d, r1d ; a
+
+ movd m1, r5d
+ movd m3, r3d
+%ifidn %1, mmx
+ punpcklwd m0, m0
+ punpcklwd m1, m1
+ punpcklwd m3, m3
+ punpckldq m0, m0
+ punpckldq m1, m1
+ punpckldq m3, m3
+%elifidn %1, mmx2
+ pshufw m0, m0, 0x0
+ pshufw m1, m1, 0x0
+ pshufw m3, m3, 0x0
+%else
+ pshuflw m0, m0, 0x0
+ pshuflw m1, m1, 0x0
+ pshuflw m3, m3, 0x0
+ punpcklqdq m0, m0 ; splat H (words)
+ punpcklqdq m1, m1 ; splat V (words)
+ punpcklqdq m3, m3 ; splat a (words)
+%endif
+%if mmsize == 8
+ mova m2, m0
+%endif
+ pmullw m0, [pw_0to7] ; 0*H, 1*H, ..., 7*H (words)
+ paddw m0, m3 ; a + {0,1,2,3,4,5,6,7}*H
+%if mmsize == 8
+ psllw m2, 2
+ paddw m2, m0 ; a + {4,5,6,7}*H
+%endif
+
+ mov r4, 4
+ALIGN 16
+.loop
+%if mmsize == 16
+ mova m3, m0 ; b[0..7]
+ paddw m0, m1
+ psraw m3, 5
+ mova m4, m0 ; V+b[0..7]
+ paddw m0, m1
+ psraw m4, 5
+ packuswb m3, m4
+ movh [r0], m3
+ movhps [r0+r2], m3
+%else ; mmsize == 8
+ mova m3, m0 ; b[0..3]
+ mova m4, m2 ; b[4..7]
+ paddw m0, m1
+ paddw m2, m1
+ psraw m3, 5
+ psraw m4, 5
+ mova m5, m0 ; V+b[0..3]
+ mova m6, m2 ; V+b[4..7]
+ paddw m0, m1
+ paddw m2, m1
+ psraw m5, 5
+ psraw m6, 5
+ packuswb m3, m4
+ packuswb m5, m6
+ mova [r0], m3
+ mova [r0+r2], m5
+%endif
+
+ lea r0, [r0+r2*2]
+ dec r4
+ jg .loop
+ REP_RET
+%endmacro
+
+INIT_MMX
+H264_PRED8x8_PLANE mmx, 0
+H264_PRED8x8_PLANE mmx2, 0
+INIT_XMM
+H264_PRED8x8_PLANE sse2, 8
+H264_PRED8x8_PLANE ssse3, 8
+
+;-----------------------------------------------------------------------------
; void pred8x8_vertical(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
@@ -324,6 +834,102 @@ PRED8x8_H mmxext
PRED8x8_H ssse3
;-----------------------------------------------------------------------------
+; void pred8x8_top_dc_mmxext(uint8_t *src, int stride)
+;-----------------------------------------------------------------------------
+%ifdef CONFIG_GPL
+cglobal pred8x8_top_dc_mmxext, 2,5
+ sub r0, r1
+ movq mm0, [r0]
+ pxor mm1, mm1
+ pxor mm2, mm2
+ lea r2, [r0+r1*2]
+ punpckhbw mm1, mm0
+ punpcklbw mm0, mm2
+ psadbw mm1, mm2 ; s1
+ lea r3, [r2+r1*2]
+ psadbw mm0, mm2 ; s0
+ psrlw mm1, 1
+ psrlw mm0, 1
+ pavgw mm1, mm2
+ lea r4, [r3+r1*2]
+ pavgw mm0, mm2
+ pshufw mm1, mm1, 0
+ pshufw mm0, mm0, 0 ; dc0 (w)
+ packuswb mm0, mm1 ; dc0,dc1 (b)
+ movq [r0+r1*1], mm0
+ movq [r0+r1*2], mm0
+ lea r0, [r3+r1*2]
+ movq [r2+r1*1], mm0
+ movq [r2+r1*2], mm0
+ movq [r3+r1*1], mm0
+ movq [r3+r1*2], mm0
+ movq [r0+r1*1], mm0
+ movq [r0+r1*2], mm0
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred8x8_dc_mmxext(uint8_t *src, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal pred8x8_dc_mmxext, 2,5
+ sub r0, r1
+ pxor m7, m7
+ movd m0, [r0+0]
+ movd m1, [r0+4]
+ psadbw m0, m7 ; s0
+ mov r4, r0
+ psadbw m1, m7 ; s1
+
+ movzx r2d, byte [r0+r1*1-1]
+ movzx r3d, byte [r0+r1*2-1]
+ lea r0, [r0+r1*2]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*1-1]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*2-1]
+ add r2d, r3d
+ lea r0, [r0+r1*2]
+ movd m2, r2d ; s2
+ movzx r2d, byte [r0+r1*1-1]
+ movzx r3d, byte [r0+r1*2-1]
+ lea r0, [r0+r1*2]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*1-1]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*2-1]
+ add r2d, r3d
+ movd m3, r2d ; s3
+
+ punpcklwd m0, m1
+ mov r0, r4
+ punpcklwd m2, m3
+ punpckldq m0, m2 ; s0, s1, s2, s3
+ pshufw m3, m0, 11110110b ; s2, s1, s3, s3
+ lea r2, [r0+r1*2]
+ pshufw m0, m0, 01110100b ; s0, s1, s3, s1
+ paddw m0, m3
+ lea r3, [r2+r1*2]
+ psrlw m0, 2
+ pavgw m0, m7 ; s0+s2, s1, s3, s1+s3
+ lea r4, [r3+r1*2]
+ packuswb m0, m0
+ punpcklbw m0, m0
+ movq m1, m0
+ punpcklbw m0, m0
+ punpckhbw m1, m1
+ movq [r0+r1*1], m0
+ movq [r0+r1*2], m0
+ movq [r2+r1*1], m0
+ movq [r2+r1*2], m0
+ movq [r3+r1*1], m1
+ movq [r3+r1*2], m1
+ movq [r4+r1*1], m1
+ movq [r4+r1*2], m1
+ RET
+%endif
+
+;-----------------------------------------------------------------------------
; void pred8x8_dc_rv40(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
@@ -462,6 +1068,1416 @@ cglobal pred8x8_tm_vp8_ssse3, 2,3,6
jg .loop
REP_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 pred8x8l_top_dc(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+%ifdef CONFIG_GPL
+%macro PRED8x8L_TOP_DC 1
+cglobal pred8x8l_top_dc_%1, 4,4
+ sub r0, r3
+ pxor mm7, mm7
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+ jmp .body
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .body
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+.body
+ PRED4x4_LOWPASS mm0, mm2, mm1, mm3, mm5
+ psadbw mm7, mm0
+ paddw mm7, [pw_4]
+ psrlw mm7, 3
+ pshufw mm7, mm7, 0
+ packuswb mm7, mm7
+%rep 3
+ movq [r0+r3*1], mm7
+ movq [r0+r3*2], mm7
+ lea r0, [r0+r3*2]
+%endrep
+ movq [r0+r3*1], mm7
+ movq [r0+r3*2], mm7
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_TOP_DC mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_TOP_DC ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_dc(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_DC 1
+cglobal pred8x8l_dc_%1, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .body
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .body
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.body
+ lea r1, [r0+r3*2]
+ PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
+ pxor mm0, mm0
+ pxor mm1, mm1
+ lea r2, [r1+r3*2]
+ psadbw mm0, mm7
+ psadbw mm1, mm6
+ paddw mm0, [pw_8]
+ paddw mm0, mm1
+ lea r4, [r2+r3*2]
+ psrlw mm0, 4
+ pshufw mm0, mm0, 0
+ packuswb mm0, mm0
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm0
+ movq [r1+r3*1], mm0
+ movq [r1+r3*2], mm0
+ movq [r2+r3*1], mm0
+ movq [r2+r3*2], mm0
+ movq [r4+r3*1], mm0
+ movq [r4+r3*2], mm0
+ RET
+%endmacro
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_DC mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_DC ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_HORIZONTAL 1
+cglobal pred8x8l_horizontal_%1, 4,4
+ sub r0, r3
+ lea r2, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ test r1, r1
+ lea r1, [r0+r3]
+ cmovnz r1, r0
+ punpckhbw mm0, [r1+r3*0-8]
+ movq mm1, [r2+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r2, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r1+r3*0-8]
+ mov r0, r2
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm3, mm7
+ lea r1, [r0+r3*2]
+ movq mm7, mm3
+ punpckhbw mm3, mm3
+ punpcklbw mm7, mm7
+ pshufw mm0, mm3, 0xff
+ pshufw mm1, mm3, 0xaa
+ lea r2, [r1+r3*2]
+ pshufw mm2, mm3, 0x55
+ pshufw mm3, mm3, 0x00
+ pshufw mm4, mm7, 0xff
+ pshufw mm5, mm7, 0xaa
+ pshufw mm6, mm7, 0x55
+ pshufw mm7, mm7, 0x00
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm1
+ movq [r1+r3*1], mm2
+ movq [r1+r3*2], mm3
+ movq [r2+r3*1], mm4
+ movq [r2+r3*2], mm5
+ lea r0, [r2+r3*2]
+ movq [r0+r3*1], mm6
+ movq [r0+r3*2], mm7
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_HORIZONTAL mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_HORIZONTAL ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_vertical(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_VERTICAL 1
+cglobal pred8x8l_vertical_%1, 4,4
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+ jmp .body
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .body
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+.body
+ PRED4x4_LOWPASS mm0, mm2, mm1, mm3, mm5
+%rep 3
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm0
+ lea r0, [r0+r3*2]
+%endrep
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_VERTICAL mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_VERTICAL ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_down_left(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_down_left_mmxext, 4,5
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+ jmp .do_top
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq mm7, mm4
+ test r2, r2
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ lea r1, [r0+r3*2]
+ movq mm6, mm1
+ psrlq mm1, 56
+ movq mm4, mm1
+ lea r2, [r1+r3*2]
+ movq mm2, mm6
+ PALIGNR mm2, mm7, 1, mm0
+ movq mm3, mm6
+ PALIGNR mm3, mm7, 7, mm0
+ PALIGNR mm4, mm6, 1, mm0
+ movq mm5, mm7
+ movq mm1, mm7
+ movq mm7, mm6
+ lea r4, [r2+r3*2]
+ psllq mm1, 8
+ PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6
+ PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6
+ movq [r4+r3*2], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r4+r3*1], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r2+r3*2], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r2+r3*1], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r1+r3*2], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r1+r3*1], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r0+r3*2], mm1
+ psllq mm1, 8
+ psrlq mm0, 56
+ por mm1, mm0
+ movq [r0+r3*1], mm1
+ RET
+
+%macro PRED8x8L_DOWN_LEFT 1
+cglobal pred8x8l_down_left_%1, 4,4
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+ jmp .do_top
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm3, mm4
+ test r2, r2 ; top_right
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ movq2dq xmm4, mm1
+ psrlq mm1, 56
+ movq2dq xmm5, mm1
+ lea r1, [r0+r3*2]
+ pslldq xmm4, 8
+ por xmm3, xmm4
+ movdqa xmm2, xmm3
+ psrldq xmm2, 1
+ pslldq xmm5, 15
+ por xmm2, xmm5
+ lea r2, [r1+r3*2]
+ movdqa xmm1, xmm3
+ pslldq xmm1, 1
+INIT_XMM
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm4
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r0+r3*2], xmm0
+ psrldq xmm0, 1
+ lea r0, [r2+r3*2]
+ movq [r1+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r1+r3*2], xmm0
+ psrldq xmm0, 1
+ movq [r2+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r2+r3*2], xmm0
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r0+r3*2], xmm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_DOWN_LEFT sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_DOWN_LEFT ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_down_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_down_right_mmxext, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1 ; top_left
+ jz .fix_lt_1
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ movq mm6, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq mm5, mm4
+ jmp .body
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.body
+ lea r1, [r0+r3*2]
+ movq mm1, mm7
+ movq mm7, mm5
+ movq mm5, mm6
+ movq mm2, mm7
+ lea r2, [r1+r3*2]
+ PALIGNR mm2, mm6, 1, mm0
+ movq mm3, mm7
+ PALIGNR mm3, mm6, 7, mm0
+ movq mm4, mm7
+ lea r4, [r2+r3*2]
+ psrlq mm4, 8
+ PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6
+ PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6
+ movq [r4+r3*2], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r4+r3*1], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r2+r3*2], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r2+r3*1], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r1+r3*2], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r1+r3*1], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r0+r3*2], mm0
+ psrlq mm0, 8
+ psllq mm1, 56
+ por mm0, mm1
+ movq [r0+r3*1], mm0
+ RET
+
+%macro PRED8x8L_DOWN_RIGHT 1
+cglobal pred8x8l_down_right_%1, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jz .fix_lt_1
+ jmp .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ movq2dq xmm3, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq2dq xmm1, mm7
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm4, mm4
+ lea r1, [r0+r3*2]
+ movdqa xmm0, xmm3
+ pslldq xmm4, 8
+ por xmm3, xmm4
+ lea r2, [r1+r3*2]
+ pslldq xmm4, 1
+ por xmm1, xmm4
+ psrldq xmm0, 7
+ pslldq xmm0, 15
+ psrldq xmm0, 7
+ por xmm1, xmm0
+ lea r0, [r2+r3*2]
+ movdqa xmm2, xmm3
+ psrldq xmm2, 1
+INIT_XMM
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm4
+ movdqa xmm1, xmm0
+ psrldq xmm1, 1
+ movq [r0+r3*2], xmm0
+ movq [r0+r3*1], xmm1
+ psrldq xmm0, 2
+ psrldq xmm1, 2
+ movq [r2+r3*2], xmm0
+ movq [r2+r3*1], xmm1
+ psrldq xmm0, 2
+ psrldq xmm1, 2
+ movq [r1+r3*2], xmm0
+ movq [r1+r3*1], xmm1
+ psrldq xmm0, 2
+ psrldq xmm1, 2
+ movq [r4+r3*2], xmm0
+ movq [r4+r3*1], xmm1
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_DOWN_RIGHT sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_DOWN_RIGHT ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_vertical_right(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_vertical_right_mmxext, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jz .fix_lt_1
+ jmp .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm7, mm2
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top
+ PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
+ lea r1, [r0+r3*2]
+ movq mm2, mm6
+ movq mm3, mm6
+ PALIGNR mm3, mm7, 7, mm0
+ PALIGNR mm6, mm7, 6, mm1
+ movq mm4, mm3
+ pavgb mm3, mm2
+ lea r2, [r1+r3*2]
+ PRED4x4_LOWPASS mm0, mm6, mm2, mm4, mm5
+ movq [r0+r3*1], mm3
+ movq [r0+r3*2], mm0
+ movq mm5, mm0
+ movq mm6, mm3
+ movq mm1, mm7
+ movq mm2, mm1
+ psllq mm2, 8
+ movq mm3, mm1
+ psllq mm3, 16
+ lea r4, [r2+r3*2]
+ PRED4x4_LOWPASS mm0, mm1, mm3, mm2, mm4
+ PALIGNR mm6, mm0, 7, mm2
+ movq [r1+r3*1], mm6
+ psllq mm0, 8
+ PALIGNR mm5, mm0, 7, mm1
+ movq [r1+r3*2], mm5
+ psllq mm0, 8
+ PALIGNR mm6, mm0, 7, mm2
+ movq [r2+r3*1], mm6
+ psllq mm0, 8
+ PALIGNR mm5, mm0, 7, mm1
+ movq [r2+r3*2], mm5
+ psllq mm0, 8
+ PALIGNR mm6, mm0, 7, mm2
+ movq [r4+r3*1], mm6
+ psllq mm0, 8
+ PALIGNR mm5, mm0, 7, mm1
+ movq [r4+r3*2], mm5
+ RET
+
+%macro PRED8x8L_VERTICAL_RIGHT 1
+cglobal pred8x8l_vertical_right_%1, 4,5,7
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq2dq xmm0, mm2
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top
+ PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
+ lea r1, [r0+r3*2]
+ movq2dq xmm4, mm6
+ pslldq xmm4, 8
+ por xmm0, xmm4
+ movdqa xmm6, [pw_ff00]
+ movdqa xmm1, xmm0
+ lea r2, [r1+r3*2]
+ movdqa xmm2, xmm0
+ movdqa xmm3, xmm0
+ pslldq xmm0, 1
+ pslldq xmm1, 2
+ pavgb xmm2, xmm0
+INIT_XMM
+ PRED4x4_LOWPASS xmm4, xmm3, xmm1, xmm0, xmm5
+ pandn xmm6, xmm4
+ movdqa xmm5, xmm4
+ psrlw xmm4, 8
+ packuswb xmm6, xmm4
+ movhlps xmm4, xmm6
+ movhps [r0+r3*2], xmm5
+ movhps [r0+r3*1], xmm2
+ psrldq xmm5, 4
+ movss xmm5, xmm6
+ psrldq xmm2, 4
+ movss xmm2, xmm4
+ lea r0, [r2+r3*2]
+ psrldq xmm5, 1
+ psrldq xmm2, 1
+ movq [r0+r3*2], xmm5
+ movq [r0+r3*1], xmm2
+ psrldq xmm5, 1
+ psrldq xmm2, 1
+ movq [r2+r3*2], xmm5
+ movq [r2+r3*1], xmm2
+ psrldq xmm5, 1
+ psrldq xmm2, 1
+ movq [r1+r3*2], xmm5
+ movq [r1+r3*1], xmm2
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_VERTICAL_RIGHT sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_VERTICAL_RIGHT ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_vertical_left(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_VERTICAL_LEFT 1
+cglobal pred8x8l_vertical_left_%1, 4,4
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+ jmp .do_top
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm4, mm4
+ test r2, r2
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ movq2dq xmm3, mm1
+ lea r1, [r0+r3*2]
+ pslldq xmm3, 8
+ por xmm4, xmm3
+ movdqa xmm2, xmm4
+ movdqa xmm1, xmm4
+ movdqa xmm3, xmm4
+ psrldq xmm2, 1
+ pslldq xmm1, 1
+ pavgb xmm3, xmm2
+ lea r2, [r1+r3*2]
+INIT_XMM
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm4, xmm5
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm3
+ movq [r0+r3*2], xmm0
+ lea r0, [r2+r3*2]
+ psrldq xmm3, 1
+ psrldq xmm0, 1
+ movq [r1+r3*1], xmm3
+ movq [r1+r3*2], xmm0
+ psrldq xmm3, 1
+ psrldq xmm0, 1
+ movq [r2+r3*1], xmm3
+ movq [r2+r3*2], xmm0
+ psrldq xmm3, 1
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm3
+ movq [r0+r3*2], xmm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_VERTICAL_LEFT sse2
+%define PALIGNR PALIGNR_SSSE3
+INIT_MMX
+PRED8x8L_VERTICAL_LEFT ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_horizontal_up(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_HORIZONTAL_UP 1
+cglobal pred8x8l_horizontal_up_%1, 4,4
+ sub r0, r3
+ lea r2, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ test r1, r1
+ lea r1, [r0+r3]
+ cmovnz r1, r0
+ punpckhbw mm0, [r1+r3*0-8]
+ movq mm1, [r2+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r2, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r1+r3*0-8]
+ mov r0, r2
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ lea r1, [r0+r3*2]
+ pshufw mm0, mm7, 00011011b ; l6 l7 l4 l5 l2 l3 l0 l1
+ psllq mm7, 56 ; l7 .. .. .. .. .. .. ..
+ movq mm2, mm0
+ psllw mm0, 8
+ psrlw mm2, 8
+ por mm2, mm0 ; l7 l6 l5 l4 l3 l2 l1 l0
+ movq mm3, mm2
+ movq mm4, mm2
+ movq mm5, mm2
+ psrlq mm2, 8
+ psrlq mm3, 16
+ lea r2, [r1+r3*2]
+ por mm2, mm7 ; l7 l7 l6 l5 l4 l3 l2 l1
+ punpckhbw mm7, mm7
+ por mm3, mm7 ; l7 l7 l7 l6 l5 l4 l3 l2
+ pavgb mm4, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm5, mm2, mm6
+ movq mm5, mm4
+ punpcklbw mm4, mm1 ; p4 p3 p2 p1
+ punpckhbw mm5, mm1 ; p8 p7 p6 p5
+ movq mm6, mm5
+ movq mm7, mm5
+ movq mm0, mm5
+ PALIGNR mm5, mm4, 2, mm1
+ pshufw mm1, mm6, 11111001b
+ PALIGNR mm6, mm4, 4, mm2
+ pshufw mm2, mm7, 11111110b
+ PALIGNR mm7, mm4, 6, mm3
+ pshufw mm3, mm0, 11111111b
+ movq [r0+r3*1], mm4
+ movq [r0+r3*2], mm5
+ lea r0, [r2+r3*2]
+ movq [r1+r3*1], mm6
+ movq [r1+r3*2], mm7
+ movq [r2+r3*1], mm0
+ movq [r2+r3*2], mm1
+ movq [r0+r3*1], mm2
+ movq [r0+r3*2], mm3
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_HORIZONTAL_UP mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_HORIZONTAL_UP ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_horizontal_down(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_horizontal_down_mmxext, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ movq mm6, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq mm5, mm4
+ lea r1, [r0+r3*2]
+ psllq mm7, 56
+ movq mm2, mm5
+ movq mm3, mm6
+ movq mm4, mm2
+ PALIGNR mm2, mm6, 7, mm5
+ PALIGNR mm6, mm7, 7, mm0
+ lea r2, [r1+r3*2]
+ PALIGNR mm4, mm3, 1, mm7
+ movq mm5, mm3
+ pavgb mm3, mm6
+ PRED4x4_LOWPASS mm0, mm4, mm6, mm5, mm7
+ movq mm4, mm2
+ movq mm1, mm2
+ lea r4, [r2+r3*2]
+ psrlq mm4, 16
+ psrlq mm1, 8
+ PRED4x4_LOWPASS mm6, mm4, mm2, mm1, mm5
+ movq mm7, mm3
+ punpcklbw mm3, mm0
+ punpckhbw mm7, mm0
+ movq mm1, mm7
+ movq mm0, mm7
+ movq mm4, mm7
+ movq [r4+r3*2], mm3
+ PALIGNR mm7, mm3, 2, mm5
+ movq [r4+r3*1], mm7
+ PALIGNR mm1, mm3, 4, mm5
+ movq [r2+r3*2], mm1
+ PALIGNR mm0, mm3, 6, mm3
+ movq [r2+r3*1], mm0
+ movq mm2, mm6
+ movq mm3, mm6
+ movq [r1+r3*2], mm4
+ PALIGNR mm6, mm4, 2, mm5
+ movq [r1+r3*1], mm6
+ PALIGNR mm2, mm4, 4, mm5
+ movq [r0+r3*2], mm2
+ PALIGNR mm3, mm4, 6, mm4
+ movq [r0+r3*1], mm3
+ RET
+
+%macro PRED8x8L_HORIZONTAL_DOWN 1
+cglobal pred8x8l_horizontal_down_%1, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq2dq xmm0, mm2
+ pslldq xmm0, 8
+ movq mm4, mm0
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ movq2dq xmm2, mm1
+ pslldq xmm2, 15
+ psrldq xmm2, 8
+ por xmm0, xmm2
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm1, mm4
+ test r2, r2
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ movq2dq xmm5, mm1
+ pslldq xmm5, 8
+ por xmm1, xmm5
+INIT_XMM
+ lea r2, [r4+r3*2]
+ movdqa xmm2, xmm1
+ movdqa xmm3, xmm1
+ PALIGNR xmm1, xmm0, 7, xmm4
+ PALIGNR xmm2, xmm0, 9, xmm5
+ lea r1, [r2+r3*2]
+ PALIGNR xmm3, xmm0, 8, xmm0
+ movdqa xmm4, xmm1
+ pavgb xmm4, xmm3
+ lea r0, [r1+r3*2]
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm5
+ punpcklbw xmm4, xmm0
+ movhlps xmm0, xmm4
+ movq [r0+r3*2], xmm4
+ movq [r2+r3*2], xmm0
+ psrldq xmm4, 2
+ psrldq xmm0, 2
+ movq [r0+r3*1], xmm4
+ movq [r2+r3*1], xmm0
+ psrldq xmm4, 2
+ psrldq xmm0, 2
+ movq [r1+r3*2], xmm4
+ movq [r4+r3*2], xmm0
+ psrldq xmm4, 2
+ psrldq xmm0, 2
+ movq [r1+r3*1], xmm4
+ movq [r4+r3*1], xmm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_HORIZONTAL_DOWN sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_HORIZONTAL_DOWN ssse3
+%endif
+
;-----------------------------------------------------------------------------
; void pred4x4_dc_mmxext(uint8_t *src, const uint8_t *topright, int stride)
;-----------------------------------------------------------------------------
@@ -569,18 +2585,6 @@ cglobal pred4x4_tm_vp8_ssse3, 3,3
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)
;-----------------------------------------------------------------------------
@@ -600,3 +2604,186 @@ cglobal pred4x4_vertical_vp8_mmxext, 3,3
movd [r1+r2*1], m3
movd [r1+r2*2], m3
RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_down_left_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+%ifdef CONFIG_GPL
+INIT_MMX
+cglobal pred4x4_down_left_mmxext, 3,3
+ sub r0, r2
+ movq m1, [r0]
+ punpckldq m1, [r1]
+ movq m2, m1
+ movq m3, m1
+ movq m4, m1
+ psllq m1, 8
+ pxor m2, m1
+ psrlq m2, 8
+ pxor m3, m2
+ PRED4x4_LOWPASS m0, m1, m3, m4, m5
+ lea r1, [r0+r2*2]
+ psrlq m0, 8
+ movd [r0+r2*1], m0
+ psrlq m0, 8
+ movd [r0+r2*2], m0
+ psrlq m0, 8
+ movd [r1+r2*1], m0
+ psrlq m0, 8
+ movd [r1+r2*2], m0
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal pred4x4_vertical_left_mmxext, 3,3
+ sub r0, r2
+ movq m1, [r0]
+ punpckldq m1, [r1]
+ movq m3, m1
+ movq m2, m1
+ psrlq m3, 8
+ psrlq m2, 16
+ movq m4, m3
+ pavgb m4, m1
+ PRED4x4_LOWPASS m0, m1, m2, m3, m5
+ lea r1, [r0+r2*2]
+ movh [r0+r2*1], m4
+ movh [r0+r2*2], m0
+ psrlq m4, 8
+ psrlq m0, 8
+ movh [r1+r2*1], m4
+ movh [r1+r2*2], m0
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal pred4x4_horizontal_up_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movd m0, [r0+r2*1-4]
+ punpcklbw m0, [r0+r2*2-4]
+ movd m1, [r1+r2*1-4]
+ punpcklbw m1, [r1+r2*2-4]
+ punpckhwd m0, m1
+ movq m1, m0
+ punpckhbw m1, m1
+ pshufw m1, m1, 0xFF
+ punpckhdq m0, m1
+ movq m2, m0
+ movq m3, m0
+ movq m7, m0
+ psrlq m2, 16
+ psrlq m3, 8
+ pavgb m7, m3
+ PRED4x4_LOWPASS m4, m0, m2, m3, m5
+ punpcklbw m7, m4
+ movd [r0+r2*1], m7
+ psrlq m7, 16
+ movd [r0+r2*2], m7
+ psrlq m7, 16
+ movd [r1+r2*1], m7
+ movd [r1+r2*2], m1
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_horizontal_down_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred4x4_horizontal_down_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movh m0, [r0-4] ; lt ..
+ punpckldq m0, [r0] ; t3 t2 t1 t0 lt .. .. ..
+ psllq m0, 8 ; t2 t1 t0 lt .. .. .. ..
+ movd m1, [r1+r2*2-4] ; l3
+ punpcklbw m1, [r1+r2*1-4] ; l2 l3
+ movd m2, [r0+r2*2-4] ; l1
+ punpcklbw m2, [r0+r2*1-4] ; l0 l1
+ punpckhwd m1, m2 ; l0 l1 l2 l3
+ punpckhdq m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3
+ movq m0, m1
+ movq m2, m1
+ movq m5, m1
+ psrlq m0, 16 ; .. .. t2 t1 t0 lt l0 l1
+ psrlq m2, 8 ; .. t2 t1 t0 lt l0 l1 l2
+ pavgb m5, m2
+ PRED4x4_LOWPASS m3, m1, m0, m2, m4
+ punpcklbw m5, m3
+ psrlq m3, 32
+ PALIGNR m3, m5, 6, m4
+ movh [r1+r2*2], m5
+ psrlq m5, 16
+ movh [r1+r2*1], m5
+ psrlq m5, 16
+ movh [r0+r2*2], m5
+ movh [r0+r2*1], m3
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred4x4_vertical_right_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movh m0, [r0] ; ........t3t2t1t0
+ movq m5, m0
+ PALIGNR m0, [r0-8], 7, m1 ; ......t3t2t1t0lt
+ pavgb m5, m0
+ PALIGNR m0, [r0+r2*1-8], 7, m1 ; ....t3t2t1t0ltl0
+ movq m1, m0
+ PALIGNR m0, [r0+r2*2-8], 7, m2 ; ..t3t2t1t0ltl0l1
+ movq m2, m0
+ PALIGNR m0, [r1+r2*1-8], 7, m3 ; t3t2t1t0ltl0l1l2
+ PRED4x4_LOWPASS m3, m1, m0, m2, m4
+ movq m1, m3
+ psrlq m3, 16
+ psllq m1, 48
+ movh [r0+r2*1], m5
+ movh [r0+r2*2], m3
+ PALIGNR m5, m1, 7, m2
+ psllq m1, 8
+ movh [r1+r2*1], m5
+ PALIGNR m3, m1, 7, m1
+ movh [r1+r2*2], m3
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_down_right_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred4x4_down_right_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movq m1, [r1-8]
+ movq m2, [r0+r2*1-8]
+ punpckhbw m2, [r0-8]
+ movh m3, [r0]
+ punpckhwd m1, m2
+ PALIGNR m3, m1, 5, m1
+ movq m1, m3
+ PALIGNR m3, [r1+r2*1-8], 7, m4
+ movq m2, m3
+ PALIGNR m3, [r1+r2*2-8], 7, m4
+ PRED4x4_LOWPASS m0, m3, m1, m2, m4
+ movh [r1+r2*2], m0
+ psrlq m0, 8
+ movh [r1+r2*1], m0
+ psrlq m0, 8
+ movh [r0+r2*2], m0
+ psrlq m0, 8
+ movh [r0+r2*1], m0
+ RET
+%endif
diff --git a/lib/ffmpeg/libavcodec/x86/h264_intrapred_init.c b/lib/ffmpeg/libavcodec/x86/h264_intrapred_init.c
new file mode 100644
index 0000000000..e93fb917cc
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/h264_intrapred_init.c
@@ -0,0 +1,233 @@
+/*
+ * 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/cpu.h"
+#include "libavcodec/h264pred.h"
+
+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_plane_h264_mmx (uint8_t *src, int stride);
+void ff_pred16x16_plane_h264_mmx2 (uint8_t *src, int stride);
+void ff_pred16x16_plane_h264_sse2 (uint8_t *src, int stride);
+void ff_pred16x16_plane_h264_ssse3 (uint8_t *src, int stride);
+void ff_pred16x16_plane_rv40_mmx (uint8_t *src, int stride);
+void ff_pred16x16_plane_rv40_mmx2 (uint8_t *src, int stride);
+void ff_pred16x16_plane_rv40_sse2 (uint8_t *src, int stride);
+void ff_pred16x16_plane_rv40_ssse3 (uint8_t *src, int stride);
+void ff_pred16x16_plane_svq3_mmx (uint8_t *src, int stride);
+void ff_pred16x16_plane_svq3_mmx2 (uint8_t *src, int stride);
+void ff_pred16x16_plane_svq3_sse2 (uint8_t *src, int stride);
+void ff_pred16x16_plane_svq3_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_top_dc_mmxext (uint8_t *src, int stride);
+void ff_pred8x8_dc_rv40_mmxext (uint8_t *src, int stride);
+void ff_pred8x8_dc_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_plane_mmx (uint8_t *src, int stride);
+void ff_pred8x8_plane_mmx2 (uint8_t *src, int stride);
+void ff_pred8x8_plane_sse2 (uint8_t *src, int stride);
+void ff_pred8x8_plane_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_pred8x8l_top_dc_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_top_dc_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_dc_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_dc_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_left_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_left_sse2 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_left_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_right_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_right_sse2 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_right_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_right_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_right_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_left_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_left_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_up_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_up_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_down_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_down_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_down_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred4x4_dc_mmxext (uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_down_left_mmxext (uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_down_right_mmxext (uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_horizontal_down_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);
+
+void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
+{
+ int mm_flags = av_get_cpu_flags();
+
+#if HAVE_YASM
+ if (mm_flags & AV_CPU_FLAG_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;
+ } else {
+ h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx;
+ if (codec_id == CODEC_ID_SVQ3) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
+ } else if (codec_id == CODEC_ID_RV40) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx;
+ } else {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx;
+ }
+ }
+ }
+
+ if (mm_flags & AV_CPU_FLAG_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;
+#if CONFIG_GPL
+ h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
+ h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext;
+ h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext;
+ h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext;
+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext;
+ h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext;
+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext;
+ h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext;
+ h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext;
+ h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext;
+#endif
+ h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
+#if CONFIG_GPL
+ if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
+ h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
+ if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
+ h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext;
+ if (codec_id != CODEC_ID_RV40) {
+ h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext;
+ }
+ if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
+ h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
+ h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
+ }
+#endif
+ 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;
+ } else {
+ h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2;
+ if (codec_id == CODEC_ID_SVQ3) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2;
+ } else if (codec_id == CODEC_ID_RV40) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2;
+ } else {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2;
+ }
+ }
+ }
+
+ if (mm_flags & AV_CPU_FLAG_SSE) {
+ h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse;
+ }
+
+ if (mm_flags & AV_CPU_FLAG_SSE2) {
+ h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
+#if CONFIG_GPL
+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2;
+ h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2;
+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2;
+#endif
+ if (codec_id == CODEC_ID_VP8) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
+ h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
+ } else {
+ h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2;
+ if (codec_id == CODEC_ID_SVQ3) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
+ } else if (codec_id == CODEC_ID_RV40) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2;
+ } else {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2;
+ }
+ }
+ }
+
+ if (mm_flags & AV_CPU_FLAG_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 CONFIG_GPL
+ h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
+ h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3;
+ h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3;
+ h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3;
+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3;
+ h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3;
+ h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3;
+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3;
+#endif
+ 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;
+ } else {
+ h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3;
+ if (codec_id == CODEC_ID_SVQ3) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
+ } else if (codec_id == CODEC_ID_RV40) {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3;
+ } else {
+ h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3;
+ }
+ }
+ }
+#endif
+}
diff --git a/lib/ffmpeg/libavcodec/x86/h264_qpel_mmx.c b/lib/ffmpeg/libavcodec/x86/h264_qpel_mmx.c
new file mode 100644
index 0000000000..d8ceca1819
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/h264_qpel_mmx.c
@@ -0,0 +1,1201 @@
+/*
+ * Copyright (c) 2004-2005 Michael Niedermayer, 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 "dsputil_mmx.h"
+
+/***********************************/
+/* motion compensation */
+
+#define QPEL_H264V_MM(A,B,C,D,E,F,OP,T,Z,d,q)\
+ "mov"#q" "#C", "#T" \n\t"\
+ "mov"#d" (%0), "#F" \n\t"\
+ "paddw "#D", "#T" \n\t"\
+ "psllw $2, "#T" \n\t"\
+ "psubw "#B", "#T" \n\t"\
+ "psubw "#E", "#T" \n\t"\
+ "punpcklbw "#Z", "#F" \n\t"\
+ "pmullw "MANGLE(ff_pw_5)", "#T"\n\t"\
+ "paddw "MANGLE(ff_pw_16)", "#A"\n\t"\
+ "add %2, %0 \n\t"\
+ "paddw "#F", "#A" \n\t"\
+ "paddw "#A", "#T" \n\t"\
+ "psraw $5, "#T" \n\t"\
+ "packuswb "#T", "#T" \n\t"\
+ OP(T, (%1), A, d)\
+ "add %3, %1 \n\t"
+
+#define QPEL_H264HV_MM(A,B,C,D,E,F,OF,T,Z,d,q)\
+ "mov"#q" "#C", "#T" \n\t"\
+ "mov"#d" (%0), "#F" \n\t"\
+ "paddw "#D", "#T" \n\t"\
+ "psllw $2, "#T" \n\t"\
+ "paddw "MANGLE(ff_pw_16)", "#A"\n\t"\
+ "psubw "#B", "#T" \n\t"\
+ "psubw "#E", "#T" \n\t"\
+ "punpcklbw "#Z", "#F" \n\t"\
+ "pmullw "MANGLE(ff_pw_5)", "#T"\n\t"\
+ "paddw "#F", "#A" \n\t"\
+ "add %2, %0 \n\t"\
+ "paddw "#A", "#T" \n\t"\
+ "mov"#q" "#T", "#OF"(%1) \n\t"
+
+#define QPEL_H264V(A,B,C,D,E,F,OP) QPEL_H264V_MM(A,B,C,D,E,F,OP,%%mm6,%%mm7,d,q)
+#define QPEL_H264HV(A,B,C,D,E,F,OF) QPEL_H264HV_MM(A,B,C,D,E,F,OF,%%mm6,%%mm7,d,q)
+#define QPEL_H264V_XMM(A,B,C,D,E,F,OP) QPEL_H264V_MM(A,B,C,D,E,F,OP,%%xmm6,%%xmm7,q,dqa)
+#define QPEL_H264HV_XMM(A,B,C,D,E,F,OF) QPEL_H264HV_MM(A,B,C,D,E,F,OF,%%xmm6,%%xmm7,q,dqa)
+
+
+#define QPEL_H264(OPNAME, OP, MMX)\
+static av_noinline void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ int h=4;\
+\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movq "MANGLE(ff_pw_5) ", %%mm4\n\t"\
+ "movq "MANGLE(ff_pw_16)", %%mm5\n\t"\
+ "1: \n\t"\
+ "movd -1(%0), %%mm1 \n\t"\
+ "movd (%0), %%mm2 \n\t"\
+ "movd 1(%0), %%mm3 \n\t"\
+ "movd 2(%0), %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "paddw %%mm0, %%mm1 \n\t"\
+ "paddw %%mm3, %%mm2 \n\t"\
+ "movd -2(%0), %%mm0 \n\t"\
+ "movd 3(%0), %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "paddw %%mm3, %%mm0 \n\t"\
+ "psllw $2, %%mm2 \n\t"\
+ "psubw %%mm1, %%mm2 \n\t"\
+ "pmullw %%mm4, %%mm2 \n\t"\
+ "paddw %%mm5, %%mm0 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "packuswb %%mm0, %%mm0 \n\t"\
+ OP(%%mm0, (%1),%%mm6, d)\
+ "add %3, %0 \n\t"\
+ "add %4, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(src), "+c"(dst), "+g"(h)\
+ : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
+ : "memory"\
+ );\
+}\
+static av_noinline void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+ int h=4;\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movq %0, %%mm4 \n\t"\
+ "movq %1, %%mm5 \n\t"\
+ :: "m"(ff_pw_5), "m"(ff_pw_16)\
+ );\
+ do{\
+ __asm__ volatile(\
+ "movd -1(%0), %%mm1 \n\t"\
+ "movd (%0), %%mm2 \n\t"\
+ "movd 1(%0), %%mm3 \n\t"\
+ "movd 2(%0), %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "paddw %%mm0, %%mm1 \n\t"\
+ "paddw %%mm3, %%mm2 \n\t"\
+ "movd -2(%0), %%mm0 \n\t"\
+ "movd 3(%0), %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "paddw %%mm3, %%mm0 \n\t"\
+ "psllw $2, %%mm2 \n\t"\
+ "psubw %%mm1, %%mm2 \n\t"\
+ "pmullw %%mm4, %%mm2 \n\t"\
+ "paddw %%mm5, %%mm0 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "movd (%2), %%mm3 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "packuswb %%mm0, %%mm0 \n\t"\
+ PAVGB" %%mm3, %%mm0 \n\t"\
+ OP(%%mm0, (%1),%%mm6, d)\
+ "add %4, %0 \n\t"\
+ "add %4, %1 \n\t"\
+ "add %3, %2 \n\t"\
+ : "+a"(src), "+c"(dst), "+d"(src2)\
+ : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride)\
+ : "memory"\
+ );\
+ }while(--h);\
+}\
+static av_noinline void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ src -= 2*srcStride;\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movd (%0), %%mm0 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm1 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm2 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm3 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm4 \n\t"\
+ "add %2, %0 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm4 \n\t"\
+ QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
+ QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
+ QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
+ QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
+ \
+ : "+a"(src), "+c"(dst)\
+ : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
+ : "memory"\
+ );\
+}\
+static av_noinline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
+ int h=4;\
+ int w=3;\
+ src -= 2*srcStride+2;\
+ while(w--){\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movd (%0), %%mm0 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm1 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm2 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm3 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm4 \n\t"\
+ "add %2, %0 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm4 \n\t"\
+ QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*3)\
+ QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*3)\
+ QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*3)\
+ QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*3)\
+ \
+ : "+a"(src)\
+ : "c"(tmp), "S"((x86_reg)srcStride)\
+ : "memory"\
+ );\
+ tmp += 4;\
+ src += 4 - 9*srcStride;\
+ }\
+ tmp -= 3*4;\
+ __asm__ volatile(\
+ "1: \n\t"\
+ "movq (%0), %%mm0 \n\t"\
+ "paddw 10(%0), %%mm0 \n\t"\
+ "movq 2(%0), %%mm1 \n\t"\
+ "paddw 8(%0), %%mm1 \n\t"\
+ "movq 4(%0), %%mm2 \n\t"\
+ "paddw 6(%0), %%mm2 \n\t"\
+ "psubw %%mm1, %%mm0 \n\t"/*a-b (abccba)*/\
+ "psraw $2, %%mm0 \n\t"/*(a-b)/4 */\
+ "psubw %%mm1, %%mm0 \n\t"/*(a-b)/4-b */\
+ "paddsw %%mm2, %%mm0 \n\t"\
+ "psraw $2, %%mm0 \n\t"/*((a-b)/4-b+c)/4 */\
+ "paddw %%mm2, %%mm0 \n\t"/*(a-5*b+20*c)/16 */\
+ "psraw $6, %%mm0 \n\t"\
+ "packuswb %%mm0, %%mm0 \n\t"\
+ OP(%%mm0, (%1),%%mm7, d)\
+ "add $24, %0 \n\t"\
+ "add %3, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(tmp), "+c"(dst), "+g"(h)\
+ : "S"((x86_reg)dstStride)\
+ : "memory"\
+ );\
+}\
+\
+static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ int h=8;\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movq "MANGLE(ff_pw_5)", %%mm6\n\t"\
+ "1: \n\t"\
+ "movq (%0), %%mm0 \n\t"\
+ "movq 1(%0), %%mm2 \n\t"\
+ "movq %%mm0, %%mm1 \n\t"\
+ "movq %%mm2, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpckhbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpckhbw %%mm7, %%mm3 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "paddw %%mm3, %%mm1 \n\t"\
+ "psllw $2, %%mm0 \n\t"\
+ "psllw $2, %%mm1 \n\t"\
+ "movq -1(%0), %%mm2 \n\t"\
+ "movq 2(%0), %%mm4 \n\t"\
+ "movq %%mm2, %%mm3 \n\t"\
+ "movq %%mm4, %%mm5 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpckhbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm4 \n\t"\
+ "punpckhbw %%mm7, %%mm5 \n\t"\
+ "paddw %%mm4, %%mm2 \n\t"\
+ "paddw %%mm3, %%mm5 \n\t"\
+ "psubw %%mm2, %%mm0 \n\t"\
+ "psubw %%mm5, %%mm1 \n\t"\
+ "pmullw %%mm6, %%mm0 \n\t"\
+ "pmullw %%mm6, %%mm1 \n\t"\
+ "movd -2(%0), %%mm2 \n\t"\
+ "movd 7(%0), %%mm5 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm5 \n\t"\
+ "paddw %%mm3, %%mm2 \n\t"\
+ "paddw %%mm5, %%mm4 \n\t"\
+ "movq "MANGLE(ff_pw_16)", %%mm5\n\t"\
+ "paddw %%mm5, %%mm2 \n\t"\
+ "paddw %%mm5, %%mm4 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "paddw %%mm4, %%mm1 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "psraw $5, %%mm1 \n\t"\
+ "packuswb %%mm1, %%mm0 \n\t"\
+ OP(%%mm0, (%1),%%mm5, q)\
+ "add %3, %0 \n\t"\
+ "add %4, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(src), "+c"(dst), "+g"(h)\
+ : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
+ : "memory"\
+ );\
+}\
+\
+static av_noinline void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+ int h=8;\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movq "MANGLE(ff_pw_5)", %%mm6\n\t"\
+ "1: \n\t"\
+ "movq (%0), %%mm0 \n\t"\
+ "movq 1(%0), %%mm2 \n\t"\
+ "movq %%mm0, %%mm1 \n\t"\
+ "movq %%mm2, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpckhbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpckhbw %%mm7, %%mm3 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "paddw %%mm3, %%mm1 \n\t"\
+ "psllw $2, %%mm0 \n\t"\
+ "psllw $2, %%mm1 \n\t"\
+ "movq -1(%0), %%mm2 \n\t"\
+ "movq 2(%0), %%mm4 \n\t"\
+ "movq %%mm2, %%mm3 \n\t"\
+ "movq %%mm4, %%mm5 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpckhbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm4 \n\t"\
+ "punpckhbw %%mm7, %%mm5 \n\t"\
+ "paddw %%mm4, %%mm2 \n\t"\
+ "paddw %%mm3, %%mm5 \n\t"\
+ "psubw %%mm2, %%mm0 \n\t"\
+ "psubw %%mm5, %%mm1 \n\t"\
+ "pmullw %%mm6, %%mm0 \n\t"\
+ "pmullw %%mm6, %%mm1 \n\t"\
+ "movd -2(%0), %%mm2 \n\t"\
+ "movd 7(%0), %%mm5 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm5 \n\t"\
+ "paddw %%mm3, %%mm2 \n\t"\
+ "paddw %%mm5, %%mm4 \n\t"\
+ "movq "MANGLE(ff_pw_16)", %%mm5\n\t"\
+ "paddw %%mm5, %%mm2 \n\t"\
+ "paddw %%mm5, %%mm4 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "paddw %%mm4, %%mm1 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "psraw $5, %%mm1 \n\t"\
+ "movq (%2), %%mm4 \n\t"\
+ "packuswb %%mm1, %%mm0 \n\t"\
+ PAVGB" %%mm4, %%mm0 \n\t"\
+ OP(%%mm0, (%1),%%mm5, q)\
+ "add %5, %0 \n\t"\
+ "add %5, %1 \n\t"\
+ "add %4, %2 \n\t"\
+ "decl %3 \n\t"\
+ "jg 1b \n\t"\
+ : "+a"(src), "+c"(dst), "+d"(src2), "+g"(h)\
+ : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride)\
+ : "memory"\
+ );\
+}\
+\
+static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
+ int w= 2;\
+ src -= 2*srcStride;\
+ \
+ while(w--){\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movd (%0), %%mm0 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm1 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm2 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm3 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm4 \n\t"\
+ "add %2, %0 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm4 \n\t"\
+ QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
+ QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
+ QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
+ QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
+ QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
+ QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
+ QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
+ QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
+ "cmpl $16, %4 \n\t"\
+ "jne 2f \n\t"\
+ QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
+ QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
+ QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
+ QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
+ QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
+ QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
+ QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
+ QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
+ "2: \n\t"\
+ \
+ : "+a"(src), "+c"(dst)\
+ : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
+ : "memory"\
+ );\
+ src += 4-(h+5)*srcStride;\
+ dst += 4-h*dstStride;\
+ }\
+}\
+static av_always_inline void OPNAME ## h264_qpel8or16_hv1_lowpass_ ## MMX(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){\
+ int w = (size+8)>>2;\
+ src -= 2*srcStride+2;\
+ while(w--){\
+ __asm__ volatile(\
+ "pxor %%mm7, %%mm7 \n\t"\
+ "movd (%0), %%mm0 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm1 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm2 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm3 \n\t"\
+ "add %2, %0 \n\t"\
+ "movd (%0), %%mm4 \n\t"\
+ "add %2, %0 \n\t"\
+ "punpcklbw %%mm7, %%mm0 \n\t"\
+ "punpcklbw %%mm7, %%mm1 \n\t"\
+ "punpcklbw %%mm7, %%mm2 \n\t"\
+ "punpcklbw %%mm7, %%mm3 \n\t"\
+ "punpcklbw %%mm7, %%mm4 \n\t"\
+ QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*48)\
+ QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*48)\
+ QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*48)\
+ QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*48)\
+ QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 4*48)\
+ QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 5*48)\
+ QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 6*48)\
+ QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 7*48)\
+ "cmpl $16, %3 \n\t"\
+ "jne 2f \n\t"\
+ QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 8*48)\
+ QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 9*48)\
+ QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 10*48)\
+ QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 11*48)\
+ QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 12*48)\
+ QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 13*48)\
+ QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 14*48)\
+ QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
+ "2: \n\t"\
+ : "+a"(src)\
+ : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
+ : "memory"\
+ );\
+ tmp += 4;\
+ src += 4 - (size+5)*srcStride;\
+ }\
+}\
+static av_always_inline void OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
+ int w = size>>4;\
+ do{\
+ int h = size;\
+ __asm__ volatile(\
+ "1: \n\t"\
+ "movq (%0), %%mm0 \n\t"\
+ "movq 8(%0), %%mm3 \n\t"\
+ "movq 2(%0), %%mm1 \n\t"\
+ "movq 10(%0), %%mm4 \n\t"\
+ "paddw %%mm4, %%mm0 \n\t"\
+ "paddw %%mm3, %%mm1 \n\t"\
+ "paddw 18(%0), %%mm3 \n\t"\
+ "paddw 16(%0), %%mm4 \n\t"\
+ "movq 4(%0), %%mm2 \n\t"\
+ "movq 12(%0), %%mm5 \n\t"\
+ "paddw 6(%0), %%mm2 \n\t"\
+ "paddw 14(%0), %%mm5 \n\t"\
+ "psubw %%mm1, %%mm0 \n\t"\
+ "psubw %%mm4, %%mm3 \n\t"\
+ "psraw $2, %%mm0 \n\t"\
+ "psraw $2, %%mm3 \n\t"\
+ "psubw %%mm1, %%mm0 \n\t"\
+ "psubw %%mm4, %%mm3 \n\t"\
+ "paddsw %%mm2, %%mm0 \n\t"\
+ "paddsw %%mm5, %%mm3 \n\t"\
+ "psraw $2, %%mm0 \n\t"\
+ "psraw $2, %%mm3 \n\t"\
+ "paddw %%mm2, %%mm0 \n\t"\
+ "paddw %%mm5, %%mm3 \n\t"\
+ "psraw $6, %%mm0 \n\t"\
+ "psraw $6, %%mm3 \n\t"\
+ "packuswb %%mm3, %%mm0 \n\t"\
+ OP(%%mm0, (%1),%%mm7, q)\
+ "add $48, %0 \n\t"\
+ "add %3, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(tmp), "+c"(dst), "+g"(h)\
+ : "S"((x86_reg)dstStride)\
+ : "memory"\
+ );\
+ tmp += 8 - size*24;\
+ dst += 8 - size*dstStride;\
+ }while(w--);\
+}\
+\
+static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
+}\
+static av_noinline void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
+ OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
+}\
+\
+static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
+ src += 8*srcStride;\
+ dst += 8*dstStride;\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
+}\
+\
+static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
+ src += 8*dstStride;\
+ dst += 8*dstStride;\
+ src2 += 8*src2Stride;\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
+}\
+\
+static av_noinline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
+ put_h264_qpel8or16_hv1_lowpass_ ## MMX(tmp, src, tmpStride, srcStride, size);\
+ OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
+}\
+static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\
+}\
+\
+static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\
+}\
+\
+static av_noinline void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
+{\
+ __asm__ volatile(\
+ "movq (%1), %%mm0 \n\t"\
+ "movq 24(%1), %%mm1 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "psraw $5, %%mm1 \n\t"\
+ "packuswb %%mm0, %%mm0 \n\t"\
+ "packuswb %%mm1, %%mm1 \n\t"\
+ PAVGB" (%0), %%mm0 \n\t"\
+ PAVGB" (%0,%3), %%mm1 \n\t"\
+ OP(%%mm0, (%2), %%mm4, d)\
+ OP(%%mm1, (%2,%4), %%mm5, d)\
+ "lea (%0,%3,2), %0 \n\t"\
+ "lea (%2,%4,2), %2 \n\t"\
+ "movq 48(%1), %%mm0 \n\t"\
+ "movq 72(%1), %%mm1 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "psraw $5, %%mm1 \n\t"\
+ "packuswb %%mm0, %%mm0 \n\t"\
+ "packuswb %%mm1, %%mm1 \n\t"\
+ PAVGB" (%0), %%mm0 \n\t"\
+ PAVGB" (%0,%3), %%mm1 \n\t"\
+ OP(%%mm0, (%2), %%mm4, d)\
+ OP(%%mm1, (%2,%4), %%mm5, d)\
+ :"+a"(src8), "+c"(src16), "+d"(dst)\
+ :"S"((x86_reg)src8Stride), "D"((x86_reg)dstStride)\
+ :"memory");\
+}\
+static av_noinline void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
+{\
+ do{\
+ __asm__ volatile(\
+ "movq (%1), %%mm0 \n\t"\
+ "movq 8(%1), %%mm1 \n\t"\
+ "movq 48(%1), %%mm2 \n\t"\
+ "movq 8+48(%1), %%mm3 \n\t"\
+ "psraw $5, %%mm0 \n\t"\
+ "psraw $5, %%mm1 \n\t"\
+ "psraw $5, %%mm2 \n\t"\
+ "psraw $5, %%mm3 \n\t"\
+ "packuswb %%mm1, %%mm0 \n\t"\
+ "packuswb %%mm3, %%mm2 \n\t"\
+ PAVGB" (%0), %%mm0 \n\t"\
+ PAVGB" (%0,%3), %%mm2 \n\t"\
+ OP(%%mm0, (%2), %%mm5, q)\
+ OP(%%mm2, (%2,%4), %%mm5, q)\
+ ::"a"(src8), "c"(src16), "d"(dst),\
+ "r"((x86_reg)src8Stride), "r"((x86_reg)dstStride)\
+ :"memory");\
+ src8 += 2L*src8Stride;\
+ src16 += 48;\
+ dst += 2L*dstStride;\
+ }while(h-=2);\
+}\
+static void OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
+{\
+ OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\
+ OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\
+}\
+
+
+#if ARCH_X86_64
+#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
+static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+ int h=16;\
+ __asm__ volatile(\
+ "pxor %%xmm15, %%xmm15 \n\t"\
+ "movdqa %6, %%xmm14 \n\t"\
+ "movdqa %7, %%xmm13 \n\t"\
+ "1: \n\t"\
+ "lddqu 6(%0), %%xmm1 \n\t"\
+ "lddqu -2(%0), %%xmm7 \n\t"\
+ "movdqa %%xmm1, %%xmm0 \n\t"\
+ "punpckhbw %%xmm15, %%xmm1 \n\t"\
+ "punpcklbw %%xmm15, %%xmm0 \n\t"\
+ "punpcklbw %%xmm15, %%xmm7 \n\t"\
+ "movdqa %%xmm1, %%xmm2 \n\t"\
+ "movdqa %%xmm0, %%xmm6 \n\t"\
+ "movdqa %%xmm1, %%xmm3 \n\t"\
+ "movdqa %%xmm0, %%xmm8 \n\t"\
+ "movdqa %%xmm1, %%xmm4 \n\t"\
+ "movdqa %%xmm0, %%xmm9 \n\t"\
+ "movdqa %%xmm0, %%xmm12 \n\t"\
+ "movdqa %%xmm1, %%xmm11 \n\t"\
+ "palignr $10,%%xmm0, %%xmm11\n\t"\
+ "palignr $10,%%xmm7, %%xmm12\n\t"\
+ "palignr $2, %%xmm0, %%xmm4 \n\t"\
+ "palignr $2, %%xmm7, %%xmm9 \n\t"\
+ "palignr $4, %%xmm0, %%xmm3 \n\t"\
+ "palignr $4, %%xmm7, %%xmm8 \n\t"\
+ "palignr $6, %%xmm0, %%xmm2 \n\t"\
+ "palignr $6, %%xmm7, %%xmm6 \n\t"\
+ "paddw %%xmm0 ,%%xmm11 \n\t"\
+ "palignr $8, %%xmm0, %%xmm1 \n\t"\
+ "palignr $8, %%xmm7, %%xmm0 \n\t"\
+ "paddw %%xmm12,%%xmm7 \n\t"\
+ "paddw %%xmm3, %%xmm2 \n\t"\
+ "paddw %%xmm8, %%xmm6 \n\t"\
+ "paddw %%xmm4, %%xmm1 \n\t"\
+ "paddw %%xmm9, %%xmm0 \n\t"\
+ "psllw $2, %%xmm2 \n\t"\
+ "psllw $2, %%xmm6 \n\t"\
+ "psubw %%xmm1, %%xmm2 \n\t"\
+ "psubw %%xmm0, %%xmm6 \n\t"\
+ "paddw %%xmm13,%%xmm11 \n\t"\
+ "paddw %%xmm13,%%xmm7 \n\t"\
+ "pmullw %%xmm14,%%xmm2 \n\t"\
+ "pmullw %%xmm14,%%xmm6 \n\t"\
+ "lddqu (%2), %%xmm3 \n\t"\
+ "paddw %%xmm11,%%xmm2 \n\t"\
+ "paddw %%xmm7, %%xmm6 \n\t"\
+ "psraw $5, %%xmm2 \n\t"\
+ "psraw $5, %%xmm6 \n\t"\
+ "packuswb %%xmm2,%%xmm6 \n\t"\
+ "pavgb %%xmm3, %%xmm6 \n\t"\
+ OP(%%xmm6, (%1), %%xmm4, dqa)\
+ "add %5, %0 \n\t"\
+ "add %5, %1 \n\t"\
+ "add %4, %2 \n\t"\
+ "decl %3 \n\t"\
+ "jg 1b \n\t"\
+ : "+a"(src), "+c"(dst), "+d"(src2), "+g"(h)\
+ : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\
+ "m"(ff_pw_5), "m"(ff_pw_16)\
+ : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , \
+ "%xmm4" , "%xmm5" , "%xmm6" , "%xmm7" , \
+ "%xmm8" , "%xmm9" , "%xmm10", "%xmm11", \
+ "%xmm12", "%xmm13", "%xmm14", "%xmm15",)\
+ "memory"\
+ );\
+}
+#else // ARCH_X86_64
+#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
+static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
+ src += 8*dstStride;\
+ dst += 8*dstStride;\
+ src2 += 8*src2Stride;\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
+ OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
+}
+#endif // ARCH_X86_64
+
+#define QPEL_H264_H_XMM(OPNAME, OP, MMX)\
+static av_noinline void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+ int h=8;\
+ __asm__ volatile(\
+ "pxor %%xmm7, %%xmm7 \n\t"\
+ "movdqa "MANGLE(ff_pw_5)", %%xmm6\n\t"\
+ "1: \n\t"\
+ "lddqu -2(%0), %%xmm1 \n\t"\
+ "movdqa %%xmm1, %%xmm0 \n\t"\
+ "punpckhbw %%xmm7, %%xmm1 \n\t"\
+ "punpcklbw %%xmm7, %%xmm0 \n\t"\
+ "movdqa %%xmm1, %%xmm2 \n\t"\
+ "movdqa %%xmm1, %%xmm3 \n\t"\
+ "movdqa %%xmm1, %%xmm4 \n\t"\
+ "movdqa %%xmm1, %%xmm5 \n\t"\
+ "palignr $2, %%xmm0, %%xmm4 \n\t"\
+ "palignr $4, %%xmm0, %%xmm3 \n\t"\
+ "palignr $6, %%xmm0, %%xmm2 \n\t"\
+ "palignr $8, %%xmm0, %%xmm1 \n\t"\
+ "palignr $10,%%xmm0, %%xmm5 \n\t"\
+ "paddw %%xmm5, %%xmm0 \n\t"\
+ "paddw %%xmm3, %%xmm2 \n\t"\
+ "paddw %%xmm4, %%xmm1 \n\t"\
+ "psllw $2, %%xmm2 \n\t"\
+ "movq (%2), %%xmm3 \n\t"\
+ "psubw %%xmm1, %%xmm2 \n\t"\
+ "paddw "MANGLE(ff_pw_16)", %%xmm0\n\t"\
+ "pmullw %%xmm6, %%xmm2 \n\t"\
+ "paddw %%xmm0, %%xmm2 \n\t"\
+ "psraw $5, %%xmm2 \n\t"\
+ "packuswb %%xmm2, %%xmm2 \n\t"\
+ "pavgb %%xmm3, %%xmm2 \n\t"\
+ OP(%%xmm2, (%1), %%xmm4, q)\
+ "add %5, %0 \n\t"\
+ "add %5, %1 \n\t"\
+ "add %4, %2 \n\t"\
+ "decl %3 \n\t"\
+ "jg 1b \n\t"\
+ : "+a"(src), "+c"(dst), "+d"(src2), "+g"(h)\
+ : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride)\
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+ "memory"\
+ );\
+}\
+QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
+\
+static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ int h=8;\
+ __asm__ volatile(\
+ "pxor %%xmm7, %%xmm7 \n\t"\
+ "movdqa "MANGLE(ff_pw_5)", %%xmm6\n\t"\
+ "1: \n\t"\
+ "lddqu -2(%0), %%xmm1 \n\t"\
+ "movdqa %%xmm1, %%xmm0 \n\t"\
+ "punpckhbw %%xmm7, %%xmm1 \n\t"\
+ "punpcklbw %%xmm7, %%xmm0 \n\t"\
+ "movdqa %%xmm1, %%xmm2 \n\t"\
+ "movdqa %%xmm1, %%xmm3 \n\t"\
+ "movdqa %%xmm1, %%xmm4 \n\t"\
+ "movdqa %%xmm1, %%xmm5 \n\t"\
+ "palignr $2, %%xmm0, %%xmm4 \n\t"\
+ "palignr $4, %%xmm0, %%xmm3 \n\t"\
+ "palignr $6, %%xmm0, %%xmm2 \n\t"\
+ "palignr $8, %%xmm0, %%xmm1 \n\t"\
+ "palignr $10,%%xmm0, %%xmm5 \n\t"\
+ "paddw %%xmm5, %%xmm0 \n\t"\
+ "paddw %%xmm3, %%xmm2 \n\t"\
+ "paddw %%xmm4, %%xmm1 \n\t"\
+ "psllw $2, %%xmm2 \n\t"\
+ "psubw %%xmm1, %%xmm2 \n\t"\
+ "paddw "MANGLE(ff_pw_16)", %%xmm0\n\t"\
+ "pmullw %%xmm6, %%xmm2 \n\t"\
+ "paddw %%xmm0, %%xmm2 \n\t"\
+ "psraw $5, %%xmm2 \n\t"\
+ "packuswb %%xmm2, %%xmm2 \n\t"\
+ OP(%%xmm2, (%1), %%xmm4, q)\
+ "add %3, %0 \n\t"\
+ "add %4, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(src), "+c"(dst), "+g"(h)\
+ : "D"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+ "memory"\
+ );\
+}\
+static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
+ src += 8*srcStride;\
+ dst += 8*dstStride;\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
+ OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
+}\
+
+#define QPEL_H264_V_XMM(OPNAME, OP, MMX)\
+static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
+ src -= 2*srcStride;\
+ \
+ __asm__ volatile(\
+ "pxor %%xmm7, %%xmm7 \n\t"\
+ "movq (%0), %%xmm0 \n\t"\
+ "add %2, %0 \n\t"\
+ "movq (%0), %%xmm1 \n\t"\
+ "add %2, %0 \n\t"\
+ "movq (%0), %%xmm2 \n\t"\
+ "add %2, %0 \n\t"\
+ "movq (%0), %%xmm3 \n\t"\
+ "add %2, %0 \n\t"\
+ "movq (%0), %%xmm4 \n\t"\
+ "add %2, %0 \n\t"\
+ "punpcklbw %%xmm7, %%xmm0 \n\t"\
+ "punpcklbw %%xmm7, %%xmm1 \n\t"\
+ "punpcklbw %%xmm7, %%xmm2 \n\t"\
+ "punpcklbw %%xmm7, %%xmm3 \n\t"\
+ "punpcklbw %%xmm7, %%xmm4 \n\t"\
+ QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\
+ QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\
+ QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\
+ QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\
+ QPEL_H264V_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, OP)\
+ QPEL_H264V_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, OP)\
+ QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\
+ QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\
+ "cmpl $16, %4 \n\t"\
+ "jne 2f \n\t"\
+ QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\
+ QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\
+ QPEL_H264V_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, OP)\
+ QPEL_H264V_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, OP)\
+ QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\
+ QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\
+ QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\
+ QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\
+ "2: \n\t"\
+ \
+ : "+a"(src), "+c"(dst)\
+ : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+ "memory"\
+ );\
+}\
+static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
+}\
+static av_noinline void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
+ OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
+}
+
+static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){
+ int w = (size+8)>>3;
+ src -= 2*srcStride+2;
+ while(w--){
+ __asm__ volatile(
+ "pxor %%xmm7, %%xmm7 \n\t"
+ "movq (%0), %%xmm0 \n\t"
+ "add %2, %0 \n\t"
+ "movq (%0), %%xmm1 \n\t"
+ "add %2, %0 \n\t"
+ "movq (%0), %%xmm2 \n\t"
+ "add %2, %0 \n\t"
+ "movq (%0), %%xmm3 \n\t"
+ "add %2, %0 \n\t"
+ "movq (%0), %%xmm4 \n\t"
+ "add %2, %0 \n\t"
+ "punpcklbw %%xmm7, %%xmm0 \n\t"
+ "punpcklbw %%xmm7, %%xmm1 \n\t"
+ "punpcklbw %%xmm7, %%xmm2 \n\t"
+ "punpcklbw %%xmm7, %%xmm3 \n\t"
+ "punpcklbw %%xmm7, %%xmm4 \n\t"
+ QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 0*48)
+ QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 1*48)
+ QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 2*48)
+ QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 3*48)
+ QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 4*48)
+ QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 5*48)
+ QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 6*48)
+ QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 7*48)
+ "cmpl $16, %3 \n\t"
+ "jne 2f \n\t"
+ QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 8*48)
+ QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 9*48)
+ QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 10*48)
+ QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 11*48)
+ QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 12*48)
+ QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 13*48)
+ QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 14*48)
+ QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
+ "2: \n\t"
+ : "+a"(src)
+ : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
+ "memory"
+ );
+ tmp += 8;
+ src += 8 - (size+5)*srcStride;
+ }
+}
+
+#define QPEL_H264_HV2_XMM(OPNAME, OP, MMX)\
+static av_always_inline void OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
+ int h = size;\
+ if(size == 16){\
+ __asm__ volatile(\
+ "1: \n\t"\
+ "movdqa 32(%0), %%xmm4 \n\t"\
+ "movdqa 16(%0), %%xmm5 \n\t"\
+ "movdqa (%0), %%xmm7 \n\t"\
+ "movdqa %%xmm4, %%xmm3 \n\t"\
+ "movdqa %%xmm4, %%xmm2 \n\t"\
+ "movdqa %%xmm4, %%xmm1 \n\t"\
+ "movdqa %%xmm4, %%xmm0 \n\t"\
+ "palignr $10, %%xmm5, %%xmm0 \n\t"\
+ "palignr $8, %%xmm5, %%xmm1 \n\t"\
+ "palignr $6, %%xmm5, %%xmm2 \n\t"\
+ "palignr $4, %%xmm5, %%xmm3 \n\t"\
+ "palignr $2, %%xmm5, %%xmm4 \n\t"\
+ "paddw %%xmm5, %%xmm0 \n\t"\
+ "paddw %%xmm4, %%xmm1 \n\t"\
+ "paddw %%xmm3, %%xmm2 \n\t"\
+ "movdqa %%xmm5, %%xmm6 \n\t"\
+ "movdqa %%xmm5, %%xmm4 \n\t"\
+ "movdqa %%xmm5, %%xmm3 \n\t"\
+ "palignr $8, %%xmm7, %%xmm4 \n\t"\
+ "palignr $2, %%xmm7, %%xmm6 \n\t"\
+ "palignr $10, %%xmm7, %%xmm3 \n\t"\
+ "paddw %%xmm6, %%xmm4 \n\t"\
+ "movdqa %%xmm5, %%xmm6 \n\t"\
+ "palignr $6, %%xmm7, %%xmm5 \n\t"\
+ "palignr $4, %%xmm7, %%xmm6 \n\t"\
+ "paddw %%xmm7, %%xmm3 \n\t"\
+ "paddw %%xmm6, %%xmm5 \n\t"\
+ \
+ "psubw %%xmm1, %%xmm0 \n\t"\
+ "psubw %%xmm4, %%xmm3 \n\t"\
+ "psraw $2, %%xmm0 \n\t"\
+ "psraw $2, %%xmm3 \n\t"\
+ "psubw %%xmm1, %%xmm0 \n\t"\
+ "psubw %%xmm4, %%xmm3 \n\t"\
+ "paddw %%xmm2, %%xmm0 \n\t"\
+ "paddw %%xmm5, %%xmm3 \n\t"\
+ "psraw $2, %%xmm0 \n\t"\
+ "psraw $2, %%xmm3 \n\t"\
+ "paddw %%xmm2, %%xmm0 \n\t"\
+ "paddw %%xmm5, %%xmm3 \n\t"\
+ "psraw $6, %%xmm0 \n\t"\
+ "psraw $6, %%xmm3 \n\t"\
+ "packuswb %%xmm0, %%xmm3 \n\t"\
+ OP(%%xmm3, (%1), %%xmm7, dqa)\
+ "add $48, %0 \n\t"\
+ "add %3, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(tmp), "+c"(dst), "+g"(h)\
+ : "S"((x86_reg)dstStride)\
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+ "memory"\
+ );\
+ }else{\
+ __asm__ volatile(\
+ "1: \n\t"\
+ "movdqa 16(%0), %%xmm1 \n\t"\
+ "movdqa (%0), %%xmm0 \n\t"\
+ "movdqa %%xmm1, %%xmm2 \n\t"\
+ "movdqa %%xmm1, %%xmm3 \n\t"\
+ "movdqa %%xmm1, %%xmm4 \n\t"\
+ "movdqa %%xmm1, %%xmm5 \n\t"\
+ "palignr $10, %%xmm0, %%xmm5 \n\t"\
+ "palignr $8, %%xmm0, %%xmm4 \n\t"\
+ "palignr $6, %%xmm0, %%xmm3 \n\t"\
+ "palignr $4, %%xmm0, %%xmm2 \n\t"\
+ "palignr $2, %%xmm0, %%xmm1 \n\t"\
+ "paddw %%xmm5, %%xmm0 \n\t"\
+ "paddw %%xmm4, %%xmm1 \n\t"\
+ "paddw %%xmm3, %%xmm2 \n\t"\
+ "psubw %%xmm1, %%xmm0 \n\t"\
+ "psraw $2, %%xmm0 \n\t"\
+ "psubw %%xmm1, %%xmm0 \n\t"\
+ "paddw %%xmm2, %%xmm0 \n\t"\
+ "psraw $2, %%xmm0 \n\t"\
+ "paddw %%xmm2, %%xmm0 \n\t"\
+ "psraw $6, %%xmm0 \n\t"\
+ "packuswb %%xmm0, %%xmm0 \n\t"\
+ OP(%%xmm0, (%1), %%xmm7, q)\
+ "add $48, %0 \n\t"\
+ "add %3, %1 \n\t"\
+ "decl %2 \n\t"\
+ " jnz 1b \n\t"\
+ : "+a"(tmp), "+c"(dst), "+g"(h)\
+ : "S"((x86_reg)dstStride)\
+ : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+ "memory"\
+ );\
+ }\
+}
+
+#define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
+static av_noinline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
+ put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, tmpStride, srcStride, size);\
+ OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
+}\
+static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 8);\
+}\
+static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
+ OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 16);\
+}\
+
+#define put_pixels8_l2_sse2 put_pixels8_l2_mmx2
+#define avg_pixels8_l2_sse2 avg_pixels8_l2_mmx2
+#define put_pixels16_l2_sse2 put_pixels16_l2_mmx2
+#define avg_pixels16_l2_sse2 avg_pixels16_l2_mmx2
+#define put_pixels8_l2_ssse3 put_pixels8_l2_mmx2
+#define avg_pixels8_l2_ssse3 avg_pixels8_l2_mmx2
+#define put_pixels16_l2_ssse3 put_pixels16_l2_mmx2
+#define avg_pixels16_l2_ssse3 avg_pixels16_l2_mmx2
+
+#define put_pixels8_l2_shift5_sse2 put_pixels8_l2_shift5_mmx2
+#define avg_pixels8_l2_shift5_sse2 avg_pixels8_l2_shift5_mmx2
+#define put_pixels16_l2_shift5_sse2 put_pixels16_l2_shift5_mmx2
+#define avg_pixels16_l2_shift5_sse2 avg_pixels16_l2_shift5_mmx2
+#define put_pixels8_l2_shift5_ssse3 put_pixels8_l2_shift5_mmx2
+#define avg_pixels8_l2_shift5_ssse3 avg_pixels8_l2_shift5_mmx2
+#define put_pixels16_l2_shift5_ssse3 put_pixels16_l2_shift5_mmx2
+#define avg_pixels16_l2_shift5_ssse3 avg_pixels16_l2_shift5_mmx2
+
+#define put_h264_qpel8_h_lowpass_l2_sse2 put_h264_qpel8_h_lowpass_l2_mmx2
+#define avg_h264_qpel8_h_lowpass_l2_sse2 avg_h264_qpel8_h_lowpass_l2_mmx2
+#define put_h264_qpel16_h_lowpass_l2_sse2 put_h264_qpel16_h_lowpass_l2_mmx2
+#define avg_h264_qpel16_h_lowpass_l2_sse2 avg_h264_qpel16_h_lowpass_l2_mmx2
+
+#define put_h264_qpel8_v_lowpass_ssse3 put_h264_qpel8_v_lowpass_sse2
+#define avg_h264_qpel8_v_lowpass_ssse3 avg_h264_qpel8_v_lowpass_sse2
+#define put_h264_qpel16_v_lowpass_ssse3 put_h264_qpel16_v_lowpass_sse2
+#define avg_h264_qpel16_v_lowpass_ssse3 avg_h264_qpel16_v_lowpass_sse2
+
+#define put_h264_qpel8or16_hv2_lowpass_sse2 put_h264_qpel8or16_hv2_lowpass_mmx2
+#define avg_h264_qpel8or16_hv2_lowpass_sse2 avg_h264_qpel8or16_hv2_lowpass_mmx2
+
+#define H264_MC(OPNAME, SIZE, MMX, ALIGN) \
+H264_MC_C(OPNAME, SIZE, MMX, ALIGN)\
+H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\
+H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\
+H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\
+
+static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
+ put_pixels16_sse2(dst, src, stride, 16);
+}
+static void avg_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
+ avg_pixels16_sse2(dst, src, stride, 16);
+}
+#define put_h264_qpel8_mc00_sse2 put_h264_qpel8_mc00_mmx2
+#define avg_h264_qpel8_mc00_sse2 avg_h264_qpel8_mc00_mmx2
+
+#define H264_MC_C(OPNAME, SIZE, MMX, ALIGN) \
+static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
+ OPNAME ## pixels ## SIZE ## _ ## MMX(dst, src, stride, SIZE);\
+}\
+
+#define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \
+static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\
+}\
+
+#define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \
+static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
+ put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
+ OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, temp, stride, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
+ put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
+ OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\
+}\
+
+#define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \
+static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
+ put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
+ put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
+ put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
+ put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint16_t, temp)[SIZE*(SIZE<8?12:24)];\
+ OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, temp, src, stride, SIZE, stride);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
+ uint8_t * const halfHV= temp;\
+ int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
+ assert(((int)temp & 7) == 0);\
+ put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
+ uint8_t * const halfHV= temp;\
+ int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
+ assert(((int)temp & 7) == 0);\
+ put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
+ OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
+ uint8_t * const halfHV= temp;\
+ int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
+ assert(((int)temp & 7) == 0);\
+ put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
+ OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+2, halfHV, stride, SIZE, SIZE);\
+}\
+\
+static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
+ DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
+ uint8_t * const halfHV= temp;\
+ int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
+ assert(((int)temp & 7) == 0);\
+ put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
+ OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+3, halfHV, stride, SIZE, SIZE);\
+}\
+
+#define H264_MC_4816(MMX)\
+H264_MC(put_, 4, MMX, 8)\
+H264_MC(put_, 8, MMX, 8)\
+H264_MC(put_, 16,MMX, 8)\
+H264_MC(avg_, 4, MMX, 8)\
+H264_MC(avg_, 8, MMX, 8)\
+H264_MC(avg_, 16,MMX, 8)\
+
+#define H264_MC_816(QPEL, XMM)\
+QPEL(put_, 8, XMM, 16)\
+QPEL(put_, 16,XMM, 16)\
+QPEL(avg_, 8, XMM, 16)\
+QPEL(avg_, 16,XMM, 16)\
+
+
+#define AVG_3DNOW_OP(a,b,temp, size) \
+"mov" #size " " #b ", " #temp " \n\t"\
+"pavgusb " #temp ", " #a " \n\t"\
+"mov" #size " " #a ", " #b " \n\t"
+#define AVG_MMX2_OP(a,b,temp, size) \
+"mov" #size " " #b ", " #temp " \n\t"\
+"pavgb " #temp ", " #a " \n\t"\
+"mov" #size " " #a ", " #b " \n\t"
+
+#define PAVGB "pavgusb"
+QPEL_H264(put_, PUT_OP, 3dnow)
+QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow)
+#undef PAVGB
+#define PAVGB "pavgb"
+QPEL_H264(put_, PUT_OP, mmx2)
+QPEL_H264(avg_, AVG_MMX2_OP, mmx2)
+QPEL_H264_V_XMM(put_, PUT_OP, sse2)
+QPEL_H264_V_XMM(avg_, AVG_MMX2_OP, sse2)
+QPEL_H264_HV_XMM(put_, PUT_OP, sse2)
+QPEL_H264_HV_XMM(avg_, AVG_MMX2_OP, sse2)
+#if HAVE_SSSE3
+QPEL_H264_H_XMM(put_, PUT_OP, ssse3)
+QPEL_H264_H_XMM(avg_, AVG_MMX2_OP, ssse3)
+QPEL_H264_HV2_XMM(put_, PUT_OP, ssse3)
+QPEL_H264_HV2_XMM(avg_, AVG_MMX2_OP, ssse3)
+QPEL_H264_HV_XMM(put_, PUT_OP, ssse3)
+QPEL_H264_HV_XMM(avg_, AVG_MMX2_OP, ssse3)
+#endif
+#undef PAVGB
+
+H264_MC_4816(3dnow)
+H264_MC_4816(mmx2)
+H264_MC_816(H264_MC_V, sse2)
+H264_MC_816(H264_MC_HV, sse2)
+#if HAVE_SSSE3
+H264_MC_816(H264_MC_H, ssse3)
+H264_MC_816(H264_MC_HV, ssse3)
+#endif
diff --git a/lib/ffmpeg/libavcodec/x86/h264_weight.asm b/lib/ffmpeg/libavcodec/x86/h264_weight.asm
new file mode 100644
index 0000000000..53aa210473
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/h264_weight.asm
@@ -0,0 +1,375 @@
+;*****************************************************************************
+;* SSE2-optimized weighted prediction code
+;*****************************************************************************
+;* Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
+;* Copyright (C) 2010 Eli Friedman <eli.friedman@gmail.com>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+
+SECTION .text
+
+;-----------------------------------------------------------------------------
+; biweight pred:
+;
+; void h264_biweight_16x16_sse2(uint8_t *dst, uint8_t *src, int stride,
+; int log2_denom, int weightd, int weights,
+; int offset);
+; and
+; void h264_weight_16x16_sse2(uint8_t *dst, int stride,
+; int log2_denom, int weight,
+; int offset);
+;-----------------------------------------------------------------------------
+
+%macro WEIGHT_SETUP 0
+ add r4, r4
+ inc r4
+ movd m3, r3d
+ movd m5, r4d
+ movd m6, r2d
+ pslld m5, m6
+ psrld m5, 1
+%if mmsize == 16
+ pshuflw m3, m3, 0
+ pshuflw m5, m5, 0
+ punpcklqdq m3, m3
+ punpcklqdq m5, m5
+%else
+ pshufw m3, m3, 0
+ pshufw m5, m5, 0
+%endif
+ pxor m7, m7
+%endmacro
+
+%macro WEIGHT_OP 2
+ movh m0, [r0+%1]
+ movh m1, [r0+%2]
+ punpcklbw m0, m7
+ punpcklbw m1, m7
+ pmullw m0, m3
+ pmullw m1, m3
+ paddsw m0, m5
+ paddsw m1, m5
+ psraw m0, m6
+ psraw m1, m6
+ packuswb m0, m1
+%endmacro
+
+%macro WEIGHT_FUNC_DBL_MM 1
+cglobal h264_weight_16x%1_mmx2, 5, 5, 0
+ WEIGHT_SETUP
+ mov r2, %1
+%if %1 == 16
+.nextrow
+ WEIGHT_OP 0, 4
+ mova [r0 ], m0
+ WEIGHT_OP 8, 12
+ mova [r0+8], m0
+ add r0, r1
+ dec r2
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_weight_16x16_mmx2.nextrow)
+%endif
+%endmacro
+
+INIT_MMX
+WEIGHT_FUNC_DBL_MM 16
+WEIGHT_FUNC_DBL_MM 8
+
+%macro WEIGHT_FUNC_MM 4
+cglobal h264_weight_%1x%2_%4, 7, 7, %3
+ WEIGHT_SETUP
+ mov r2, %2
+%if %2 == 16
+.nextrow
+ WEIGHT_OP 0, mmsize/2
+ mova [r0], m0
+ add r0, r1
+ dec r2
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_weight_%1x16_%4.nextrow)
+%endif
+%endmacro
+
+INIT_MMX
+WEIGHT_FUNC_MM 8, 16, 0, mmx2
+WEIGHT_FUNC_MM 8, 8, 0, mmx2
+WEIGHT_FUNC_MM 8, 4, 0, mmx2
+INIT_XMM
+WEIGHT_FUNC_MM 16, 16, 8, sse2
+WEIGHT_FUNC_MM 16, 8, 8, sse2
+
+%macro WEIGHT_FUNC_HALF_MM 5
+cglobal h264_weight_%1x%2_%5, 5, 5, %4
+ WEIGHT_SETUP
+ mov r2, %2/2
+ lea r3, [r1*2]
+%if %2 == mmsize
+.nextrow
+ WEIGHT_OP 0, r1
+ movh [r0], m0
+%if mmsize == 16
+ movhps [r0+r1], m0
+%else
+ psrlq m0, 32
+ movh [r0+r1], m0
+%endif
+ add r0, r3
+ dec r2
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_weight_%1x%3_%5.nextrow)
+%endif
+%endmacro
+
+INIT_MMX
+WEIGHT_FUNC_HALF_MM 4, 8, 8, 0, mmx2
+WEIGHT_FUNC_HALF_MM 4, 4, 8, 0, mmx2
+WEIGHT_FUNC_HALF_MM 4, 2, 8, 0, mmx2
+INIT_XMM
+WEIGHT_FUNC_HALF_MM 8, 16, 16, 8, sse2
+WEIGHT_FUNC_HALF_MM 8, 8, 16, 8, sse2
+WEIGHT_FUNC_HALF_MM 8, 4, 16, 8, sse2
+
+%macro BIWEIGHT_SETUP 0
+ add r6, 1
+ or r6, 1
+ add r3, 1
+ movd m3, r4d
+ movd m4, r5d
+ movd m5, r6d
+ movd m6, r3d
+ pslld m5, m6
+ psrld m5, 1
+%if mmsize == 16
+ pshuflw m3, m3, 0
+ pshuflw m4, m4, 0
+ pshuflw m5, m5, 0
+ punpcklqdq m3, m3
+ punpcklqdq m4, m4
+ punpcklqdq m5, m5
+%else
+ pshufw m3, m3, 0
+ pshufw m4, m4, 0
+ pshufw m5, m5, 0
+%endif
+ pxor m7, m7
+%endmacro
+
+%macro BIWEIGHT_STEPA 3
+ movh m%1, [r0+%3]
+ movh m%2, [r1+%3]
+ punpcklbw m%1, m7
+ punpcklbw m%2, m7
+ pmullw m%1, m3
+ pmullw m%2, m4
+ paddsw m%1, m%2
+%endmacro
+
+%macro BIWEIGHT_STEPB 0
+ paddsw m0, m5
+ paddsw m1, m5
+ psraw m0, m6
+ psraw m1, m6
+ packuswb m0, m1
+%endmacro
+
+%macro BIWEIGHT_FUNC_DBL_MM 1
+cglobal h264_biweight_16x%1_mmx2, 7, 7, 0
+ BIWEIGHT_SETUP
+ mov r3, %1
+%if %1 == 16
+.nextrow
+ BIWEIGHT_STEPA 0, 1, 0
+ BIWEIGHT_STEPA 1, 2, 4
+ BIWEIGHT_STEPB
+ mova [r0], m0
+ BIWEIGHT_STEPA 0, 1, 8
+ BIWEIGHT_STEPA 1, 2, 12
+ BIWEIGHT_STEPB
+ mova [r0+8], m0
+ add r0, r2
+ add r1, r2
+ dec r3
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_biweight_16x16_mmx2.nextrow)
+%endif
+%endmacro
+
+INIT_MMX
+BIWEIGHT_FUNC_DBL_MM 16
+BIWEIGHT_FUNC_DBL_MM 8
+
+%macro BIWEIGHT_FUNC_MM 4
+cglobal h264_biweight_%1x%2_%4, 7, 7, %3
+ BIWEIGHT_SETUP
+ mov r3, %2
+%if %2 == 16
+.nextrow
+ BIWEIGHT_STEPA 0, 1, 0
+ BIWEIGHT_STEPA 1, 2, mmsize/2
+ BIWEIGHT_STEPB
+ mova [r0], m0
+ add r0, r2
+ add r1, r2
+ dec r3
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_biweight_%1x16_%4.nextrow)
+%endif
+%endmacro
+
+INIT_MMX
+BIWEIGHT_FUNC_MM 8, 16, 0, mmx2
+BIWEIGHT_FUNC_MM 8, 8, 0, mmx2
+BIWEIGHT_FUNC_MM 8, 4, 0, mmx2
+INIT_XMM
+BIWEIGHT_FUNC_MM 16, 16, 8, sse2
+BIWEIGHT_FUNC_MM 16, 8, 8, sse2
+
+%macro BIWEIGHT_FUNC_HALF_MM 5
+cglobal h264_biweight_%1x%2_%5, 7, 7, %4
+ BIWEIGHT_SETUP
+ mov r3, %2/2
+ lea r4, [r2*2]
+%if %2 == mmsize
+.nextrow
+ BIWEIGHT_STEPA 0, 1, 0
+ BIWEIGHT_STEPA 1, 2, r2
+ BIWEIGHT_STEPB
+ movh [r0], m0
+%if mmsize == 16
+ movhps [r0+r2], m0
+%else
+ psrlq m0, 32
+ movh [r0+r2], m0
+%endif
+ add r0, r4
+ add r1, r4
+ dec r3
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_biweight_%1x%3_%5.nextrow)
+%endif
+%endmacro
+
+INIT_MMX
+BIWEIGHT_FUNC_HALF_MM 4, 8, 8, 0, mmx2
+BIWEIGHT_FUNC_HALF_MM 4, 4, 8, 0, mmx2
+BIWEIGHT_FUNC_HALF_MM 4, 2, 8, 0, mmx2
+INIT_XMM
+BIWEIGHT_FUNC_HALF_MM 8, 16, 16, 8, sse2
+BIWEIGHT_FUNC_HALF_MM 8, 8, 16, 8, sse2
+BIWEIGHT_FUNC_HALF_MM 8, 4, 16, 8, sse2
+
+%macro BIWEIGHT_SSSE3_SETUP 0
+ add r6, 1
+ or r6, 1
+ add r3, 1
+ movd m4, r4d
+ movd m0, r5d
+ movd m5, r6d
+ movd m6, r3d
+ pslld m5, m6
+ psrld m5, 1
+ punpcklbw m4, m0
+ pshuflw m4, m4, 0
+ pshuflw m5, m5, 0
+ punpcklqdq m4, m4
+ punpcklqdq m5, m5
+%endmacro
+
+%macro BIWEIGHT_SSSE3_OP 0
+ pmaddubsw m0, m4
+ pmaddubsw m2, m4
+ paddsw m0, m5
+ paddsw m2, m5
+ psraw m0, m6
+ psraw m2, m6
+ packuswb m0, m2
+%endmacro
+
+%macro BIWEIGHT_SSSE3_16 1
+cglobal h264_biweight_16x%1_ssse3, 7, 7, 8
+ BIWEIGHT_SSSE3_SETUP
+ mov r3, %1
+
+%if %1 == 16
+.nextrow
+ movh m0, [r0]
+ movh m2, [r0+8]
+ movh m3, [r1+8]
+ punpcklbw m0, [r1]
+ punpcklbw m2, m3
+ BIWEIGHT_SSSE3_OP
+ mova [r0], m0
+ add r0, r2
+ add r1, r2
+ dec r3
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_biweight_16x16_ssse3.nextrow)
+%endif
+%endmacro
+
+INIT_XMM
+BIWEIGHT_SSSE3_16 16
+BIWEIGHT_SSSE3_16 8
+
+%macro BIWEIGHT_SSSE3_8 1
+cglobal h264_biweight_8x%1_ssse3, 7, 7, 8
+ BIWEIGHT_SSSE3_SETUP
+ mov r3, %1/2
+ lea r4, [r2*2]
+
+%if %1 == 16
+.nextrow
+ movh m0, [r0]
+ movh m1, [r1]
+ movh m2, [r0+r2]
+ movh m3, [r1+r2]
+ punpcklbw m0, m1
+ punpcklbw m2, m3
+ BIWEIGHT_SSSE3_OP
+ movh [r0], m0
+ movhps [r0+r2], m0
+ add r0, r4
+ add r1, r4
+ dec r3
+ jnz .nextrow
+ REP_RET
+%else
+ jmp mangle(ff_h264_biweight_8x16_ssse3.nextrow)
+%endif
+%endmacro
+
+INIT_XMM
+BIWEIGHT_SSSE3_8 16
+BIWEIGHT_SSSE3_8 8
+BIWEIGHT_SSSE3_8 4
diff --git a/lib/ffmpeg/libavcodec/x86/h264dsp_mmx.c b/lib/ffmpeg/libavcodec/x86/h264dsp_mmx.c
index b9d2c32346..d9e45f8b03 100644
--- a/lib/ffmpeg/libavcodec/x86/h264dsp_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/h264dsp_mmx.c
@@ -18,784 +18,169 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
+#include "libavutil/x86_cpu.h"
+#include "libavcodec/h264dsp.h"
#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;
/***********************************/
/* IDCT */
-#define SUMSUB_BADC( a, b, c, d ) \
- "paddw "#b", "#a" \n\t"\
- "paddw "#d", "#c" \n\t"\
- "paddw "#b", "#b" \n\t"\
- "paddw "#d", "#d" \n\t"\
- "psubw "#a", "#b" \n\t"\
- "psubw "#c", "#d" \n\t"
-
-#define SUMSUBD2_AB( a, b, t ) \
- "movq "#b", "#t" \n\t"\
- "psraw $1 , "#b" \n\t"\
- "paddw "#a", "#b" \n\t"\
- "psraw $1 , "#a" \n\t"\
- "psubw "#t", "#a" \n\t"
-
-#define IDCT4_1D( s02, s13, d02, d13, t ) \
- SUMSUB_BA ( s02, d02 )\
- SUMSUBD2_AB( s13, d13, t )\
- SUMSUB_BADC( d13, s02, s13, d02 )
-
-#define STORE_DIFF_4P( p, t, z ) \
- "psraw $6, "#p" \n\t"\
- "movd (%0), "#t" \n\t"\
- "punpcklbw "#z", "#t" \n\t"\
- "paddsw "#t", "#p" \n\t"\
- "packuswb "#z", "#p" \n\t"\
- "movd "#p", (%0) \n\t"
-
-static void ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)
-{
- /* Load dct coeffs */
- __asm__ volatile(
- "movq (%0), %%mm0 \n\t"
- "movq 8(%0), %%mm1 \n\t"
- "movq 16(%0), %%mm2 \n\t"
- "movq 24(%0), %%mm3 \n\t"
- :: "r"(block) );
-
- __asm__ volatile(
- /* mm1=s02+s13 mm2=s02-s13 mm4=d02+d13 mm0=d02-d13 */
- IDCT4_1D( %%mm2, %%mm1, %%mm0, %%mm3, %%mm4 )
-
- "movq %0, %%mm6 \n\t"
- /* in: 1,4,0,2 out: 1,2,3,0 */
- TRANSPOSE4( %%mm3, %%mm1, %%mm0, %%mm2, %%mm4 )
-
- "paddw %%mm6, %%mm3 \n\t"
-
- /* mm2=s02+s13 mm3=s02-s13 mm4=d02+d13 mm1=d02-d13 */
- IDCT4_1D( %%mm4, %%mm2, %%mm3, %%mm0, %%mm1 )
-
- "pxor %%mm7, %%mm7 \n\t"
- :: "m"(ff_pw_32));
-
- __asm__ volatile(
- STORE_DIFF_4P( %%mm0, %%mm1, %%mm7)
- "add %1, %0 \n\t"
- STORE_DIFF_4P( %%mm2, %%mm1, %%mm7)
- "add %1, %0 \n\t"
- STORE_DIFF_4P( %%mm3, %%mm1, %%mm7)
- "add %1, %0 \n\t"
- STORE_DIFF_4P( %%mm4, %%mm1, %%mm7)
- : "+r"(dst)
- : "r" ((x86_reg)stride)
- );
-}
-
-static inline void h264_idct8_1d(int16_t *block)
-{
- __asm__ volatile(
- "movq 112(%0), %%mm7 \n\t"
- "movq 80(%0), %%mm0 \n\t"
- "movq 48(%0), %%mm3 \n\t"
- "movq 16(%0), %%mm5 \n\t"
-
- "movq %%mm0, %%mm4 \n\t"
- "movq %%mm5, %%mm1 \n\t"
- "psraw $1, %%mm4 \n\t"
- "psraw $1, %%mm1 \n\t"
- "paddw %%mm0, %%mm4 \n\t"
- "paddw %%mm5, %%mm1 \n\t"
- "paddw %%mm7, %%mm4 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "psubw %%mm5, %%mm4 \n\t"
- "paddw %%mm3, %%mm1 \n\t"
-
- "psubw %%mm3, %%mm5 \n\t"
- "psubw %%mm3, %%mm0 \n\t"
- "paddw %%mm7, %%mm5 \n\t"
- "psubw %%mm7, %%mm0 \n\t"
- "psraw $1, %%mm3 \n\t"
- "psraw $1, %%mm7 \n\t"
- "psubw %%mm3, %%mm5 \n\t"
- "psubw %%mm7, %%mm0 \n\t"
-
- "movq %%mm4, %%mm3 \n\t"
- "movq %%mm1, %%mm7 \n\t"
- "psraw $2, %%mm1 \n\t"
- "psraw $2, %%mm3 \n\t"
- "paddw %%mm5, %%mm3 \n\t"
- "psraw $2, %%mm5 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "psraw $2, %%mm0 \n\t"
- "psubw %%mm4, %%mm5 \n\t"
- "psubw %%mm0, %%mm7 \n\t"
-
- "movq 32(%0), %%mm2 \n\t"
- "movq 96(%0), %%mm6 \n\t"
- "movq %%mm2, %%mm4 \n\t"
- "movq %%mm6, %%mm0 \n\t"
- "psraw $1, %%mm4 \n\t"
- "psraw $1, %%mm6 \n\t"
- "psubw %%mm0, %%mm4 \n\t"
- "paddw %%mm2, %%mm6 \n\t"
-
- "movq (%0), %%mm2 \n\t"
- "movq 64(%0), %%mm0 \n\t"
- SUMSUB_BA( %%mm0, %%mm2 )
- SUMSUB_BA( %%mm6, %%mm0 )
- SUMSUB_BA( %%mm4, %%mm2 )
- SUMSUB_BA( %%mm7, %%mm6 )
- SUMSUB_BA( %%mm5, %%mm4 )
- SUMSUB_BA( %%mm3, %%mm2 )
- SUMSUB_BA( %%mm1, %%mm0 )
- :: "r"(block)
- );
-}
-
-static void ff_h264_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
-{
- int i;
- DECLARE_ALIGNED(8, int16_t, b2)[64];
-
- block[0] += 32;
-
- for(i=0; i<2; i++){
- DECLARE_ALIGNED(8, uint64_t, tmp);
-
- h264_idct8_1d(block+4*i);
-
- __asm__ volatile(
- "movq %%mm7, %0 \n\t"
- TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
- "movq %%mm0, 8(%1) \n\t"
- "movq %%mm6, 24(%1) \n\t"
- "movq %%mm7, 40(%1) \n\t"
- "movq %%mm4, 56(%1) \n\t"
- "movq %0, %%mm7 \n\t"
- TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
- "movq %%mm7, (%1) \n\t"
- "movq %%mm1, 16(%1) \n\t"
- "movq %%mm0, 32(%1) \n\t"
- "movq %%mm3, 48(%1) \n\t"
- : "=m"(tmp)
- : "r"(b2+32*i)
- : "memory"
- );
- }
-
- for(i=0; i<2; i++){
- h264_idct8_1d(b2+4*i);
-
- __asm__ volatile(
- "psraw $6, %%mm7 \n\t"
- "psraw $6, %%mm6 \n\t"
- "psraw $6, %%mm5 \n\t"
- "psraw $6, %%mm4 \n\t"
- "psraw $6, %%mm3 \n\t"
- "psraw $6, %%mm2 \n\t"
- "psraw $6, %%mm1 \n\t"
- "psraw $6, %%mm0 \n\t"
-
- "movq %%mm7, (%0) \n\t"
- "movq %%mm5, 16(%0) \n\t"
- "movq %%mm3, 32(%0) \n\t"
- "movq %%mm1, 48(%0) \n\t"
- "movq %%mm0, 64(%0) \n\t"
- "movq %%mm2, 80(%0) \n\t"
- "movq %%mm4, 96(%0) \n\t"
- "movq %%mm6, 112(%0) \n\t"
- :: "r"(b2+4*i)
- : "memory"
- );
- }
-
- add_pixels_clamped_mmx(b2, dst, stride);
-}
-
-#define STORE_DIFF_8P( p, d, t, z )\
- "movq "#d", "#t" \n"\
- "psraw $6, "#p" \n"\
- "punpcklbw "#z", "#t" \n"\
- "paddsw "#t", "#p" \n"\
- "packuswb "#p", "#p" \n"\
- "movq "#p", "#d" \n"
-
-#define H264_IDCT8_1D_SSE2(a,b,c,d,e,f,g,h)\
- "movdqa "#c", "#a" \n"\
- "movdqa "#g", "#e" \n"\
- "psraw $1, "#c" \n"\
- "psraw $1, "#g" \n"\
- "psubw "#e", "#c" \n"\
- "paddw "#a", "#g" \n"\
- "movdqa "#b", "#e" \n"\
- "psraw $1, "#e" \n"\
- "paddw "#b", "#e" \n"\
- "paddw "#d", "#e" \n"\
- "paddw "#f", "#e" \n"\
- "movdqa "#f", "#a" \n"\
- "psraw $1, "#a" \n"\
- "paddw "#f", "#a" \n"\
- "paddw "#h", "#a" \n"\
- "psubw "#b", "#a" \n"\
- "psubw "#d", "#b" \n"\
- "psubw "#d", "#f" \n"\
- "paddw "#h", "#b" \n"\
- "psubw "#h", "#f" \n"\
- "psraw $1, "#d" \n"\
- "psraw $1, "#h" \n"\
- "psubw "#d", "#b" \n"\
- "psubw "#h", "#f" \n"\
- "movdqa "#e", "#d" \n"\
- "movdqa "#a", "#h" \n"\
- "psraw $2, "#d" \n"\
- "psraw $2, "#h" \n"\
- "paddw "#f", "#d" \n"\
- "paddw "#b", "#h" \n"\
- "psraw $2, "#f" \n"\
- "psraw $2, "#b" \n"\
- "psubw "#f", "#e" \n"\
- "psubw "#a", "#b" \n"\
- "movdqa 0x00(%1), "#a" \n"\
- "movdqa 0x40(%1), "#f" \n"\
- SUMSUB_BA(f, a)\
- SUMSUB_BA(g, f)\
- SUMSUB_BA(c, a)\
- SUMSUB_BA(e, g)\
- SUMSUB_BA(b, c)\
- SUMSUB_BA(h, a)\
- SUMSUB_BA(d, f)
-
-static void ff_h264_idct8_add_sse2(uint8_t *dst, int16_t *block, int stride)
-{
- __asm__ volatile(
- "movdqa 0x10(%1), %%xmm1 \n"
- "movdqa 0x20(%1), %%xmm2 \n"
- "movdqa 0x30(%1), %%xmm3 \n"
- "movdqa 0x50(%1), %%xmm5 \n"
- "movdqa 0x60(%1), %%xmm6 \n"
- "movdqa 0x70(%1), %%xmm7 \n"
- H264_IDCT8_1D_SSE2(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7)
- TRANSPOSE8(%%xmm4, %%xmm1, %%xmm7, %%xmm3, %%xmm5, %%xmm0, %%xmm2, %%xmm6, (%1))
- "paddw %4, %%xmm4 \n"
- "movdqa %%xmm4, 0x00(%1) \n"
- "movdqa %%xmm2, 0x40(%1) \n"
- H264_IDCT8_1D_SSE2(%%xmm4, %%xmm0, %%xmm6, %%xmm3, %%xmm2, %%xmm5, %%xmm7, %%xmm1)
- "movdqa %%xmm6, 0x60(%1) \n"
- "movdqa %%xmm7, 0x70(%1) \n"
- "pxor %%xmm7, %%xmm7 \n"
- STORE_DIFF_8P(%%xmm2, (%0), %%xmm6, %%xmm7)
- STORE_DIFF_8P(%%xmm0, (%0,%2), %%xmm6, %%xmm7)
- STORE_DIFF_8P(%%xmm1, (%0,%2,2), %%xmm6, %%xmm7)
- STORE_DIFF_8P(%%xmm3, (%0,%3), %%xmm6, %%xmm7)
- "lea (%0,%2,4), %0 \n"
- STORE_DIFF_8P(%%xmm5, (%0), %%xmm6, %%xmm7)
- STORE_DIFF_8P(%%xmm4, (%0,%2), %%xmm6, %%xmm7)
- "movdqa 0x60(%1), %%xmm0 \n"
- "movdqa 0x70(%1), %%xmm1 \n"
- STORE_DIFF_8P(%%xmm0, (%0,%2,2), %%xmm6, %%xmm7)
- STORE_DIFF_8P(%%xmm1, (%0,%3), %%xmm6, %%xmm7)
- :"+r"(dst)
- :"r"(block), "r"((x86_reg)stride), "r"((x86_reg)3L*stride), "m"(ff_pw_32)
- );
-}
-
-static void ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
-{
- int dc = (block[0] + 32) >> 6;
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- ::"r"(dc)
- );
- __asm__ volatile(
- "movd %0, %%mm2 \n\t"
- "movd %1, %%mm3 \n\t"
- "movd %2, %%mm4 \n\t"
- "movd %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movd %%mm2, %0 \n\t"
- "movd %%mm3, %1 \n\t"
- "movd %%mm4, %2 \n\t"
- "movd %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dst+0*stride)),
- "+m"(*(uint32_t*)(dst+1*stride)),
- "+m"(*(uint32_t*)(dst+2*stride)),
- "+m"(*(uint32_t*)(dst+3*stride))
- );
-}
-
-static void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
-{
- int dc = (block[0] + 32) >> 6;
- int y;
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- ::"r"(dc)
- );
- for(y=2; y--; dst += 4*stride){
- __asm__ volatile(
- "movq %0, %%mm2 \n\t"
- "movq %1, %%mm3 \n\t"
- "movq %2, %%mm4 \n\t"
- "movq %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movq %%mm2, %0 \n\t"
- "movq %%mm3, %1 \n\t"
- "movq %%mm4, %2 \n\t"
- "movq %%mm5, %3 \n\t"
- :"+m"(*(uint64_t*)(dst+0*stride)),
- "+m"(*(uint64_t*)(dst+1*stride)),
- "+m"(*(uint64_t*)(dst+2*stride)),
- "+m"(*(uint64_t*)(dst+3*stride))
- );
- }
-}
-
-//FIXME this table is a duplicate from h264data.h, and will be removed once the tables from, h264 have been split
-static const uint8_t scan8[16 + 2*4]={
- 4+1*8, 5+1*8, 4+2*8, 5+2*8,
- 6+1*8, 7+1*8, 6+2*8, 7+2*8,
- 4+3*8, 5+3*8, 4+4*8, 5+4*8,
- 6+3*8, 7+3*8, 6+4*8, 7+4*8,
- 1+1*8, 2+1*8,
- 1+2*8, 2+2*8,
- 1+4*8, 2+4*8,
- 1+5*8, 2+5*8,
-};
-
-static void ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i++){
- if(nnzc[ scan8[i] ])
- ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride);
- }
-}
-
-static void ff_h264_idct8_add4_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i+=4){
- if(nnzc[ scan8[i] ])
- ff_h264_idct8_add_mmx(dst + block_offset[i], block + i*16, stride);
- }
-}
-
-
-static void ff_h264_idct_add16_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i++){
- int nnz = nnzc[ scan8[i] ];
- if(nnz){
- if(nnz==1 && block[i*16]) ff_h264_idct_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);
- else ff_h264_idct_add_mmx (dst + block_offset[i], block + i*16, stride);
- }
- }
-}
-
-static void ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i++){
- if(nnzc[ scan8[i] ] || block[i*16])
- ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride);
- }
-}
-
-static void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i++){
- if(nnzc[ scan8[i] ]) ff_h264_idct_add_mmx (dst + block_offset[i], block + i*16, stride);
- else if(block[i*16]) ff_h264_idct_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);
- }
-}
-
-static void ff_h264_idct8_add4_mmx2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i+=4){
- int nnz = nnzc[ scan8[i] ];
- if(nnz){
- if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);
- else ff_h264_idct8_add_mmx (dst + block_offset[i], block + i*16, stride);
- }
- }
-}
-
-static void ff_h264_idct8_add4_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i+=4){
- int nnz = nnzc[ scan8[i] ];
- if(nnz){
- if(nnz==1 && block[i*16]) ff_h264_idct8_dc_add_mmx2(dst + block_offset[i], block + i*16, stride);
- else ff_h264_idct8_add_sse2 (dst + block_offset[i], block + i*16, stride);
- }
- }
-}
-
-static void ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=16; i<16+8; i++){
- if(nnzc[ scan8[i] ] || block[i*16])
- ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
- }
-}
-
-static void ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=16; i<16+8; i++){
- if(nnzc[ scan8[i] ])
- ff_h264_idct_add_mmx (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
- else if(block[i*16])
- ff_h264_idct_dc_add_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
- }
-}
-
-#if CONFIG_GPL && HAVE_YASM
-static void ff_h264_idct_dc_add8_mmx2(uint8_t *dst, int16_t *block, int stride)
-{
- __asm__ volatile(
- "movd %0, %%mm0 \n\t" // 0 0 X D
- "punpcklwd %1, %%mm0 \n\t" // x X d D
- "paddsw %2, %%mm0 \n\t"
- "psraw $6, %%mm0 \n\t"
- "punpcklwd %%mm0, %%mm0 \n\t" // d d D D
- "pxor %%mm1, %%mm1 \n\t" // 0 0 0 0
- "psubw %%mm0, %%mm1 \n\t" // -d-d-D-D
- "packuswb %%mm1, %%mm0 \n\t" // -d-d-D-D d d D D
- "pshufw $0xFA, %%mm0, %%mm1 \n\t" // -d-d-d-d-D-D-D-D
- "punpcklwd %%mm0, %%mm0 \n\t" // d d d d D D D D
- ::"m"(block[ 0]),
- "m"(block[16]),
- "m"(ff_pw_32)
- );
- __asm__ volatile(
- "movq %0, %%mm2 \n\t"
- "movq %1, %%mm3 \n\t"
- "movq %2, %%mm4 \n\t"
- "movq %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movq %%mm2, %0 \n\t"
- "movq %%mm3, %1 \n\t"
- "movq %%mm4, %2 \n\t"
- "movq %%mm5, %3 \n\t"
- :"+m"(*(uint64_t*)(dst+0*stride)),
- "+m"(*(uint64_t*)(dst+1*stride)),
- "+m"(*(uint64_t*)(dst+2*stride)),
- "+m"(*(uint64_t*)(dst+3*stride))
- );
-}
-
-extern void ff_x264_add8x4_idct_sse2(uint8_t *dst, int16_t *block, int stride);
-
-static void ff_h264_idct_add16_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i+=2)
- if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ])
- ff_x264_add8x4_idct_sse2 (dst + block_offset[i], block + i*16, stride);
-}
-
-static void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=0; i<16; i+=2){
- if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ])
- ff_x264_add8x4_idct_sse2 (dst + block_offset[i], block + i*16, stride);
- else if(block[i*16]|block[i*16+16])
- ff_h264_idct_dc_add8_mmx2(dst + block_offset[i], block + i*16, stride);
- }
-}
-
-static void ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
- int i;
- for(i=16; i<16+8; i+=2){
- if(nnzc[ scan8[i+0] ]|nnzc[ scan8[i+1] ])
- ff_x264_add8x4_idct_sse2 (dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
- else if(block[i*16]|block[i*16+16])
- ff_h264_idct_dc_add8_mmx2(dest[(i&4)>>2] + block_offset[i], block + i*16, stride);
- }
-}
-#endif
+void ff_h264_idct_add_mmx (uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct8_add_mmx (uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct8_add_sse2 (uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct_dc_add_mmx2 (uint8_t *dst, int16_t *block, int stride);
+void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride);
+
+void ff_h264_idct_add16_mmx (uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct8_add4_mmx (uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add16_mmx2 (uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add16intra_mmx (uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct8_add4_mmx2 (uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct8_add4_sse2 (uint8_t *dst, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add8_mmx (uint8_t **dest, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add8_mmx2 (uint8_t **dest, const int *block_offset,
+ DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
+
+void ff_h264_idct_add16_sse2 (uint8_t *dst, const int *block_offset, DCTELEM *block,
+ int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block,
+ int stride, const uint8_t nnzc[6*8]);
+void ff_h264_idct_add8_sse2 (uint8_t **dest, const int *block_offset, DCTELEM *block,
+ int stride, const uint8_t nnzc[6*8]);
+void ff_h264_luma_dc_dequant_idct_mmx (DCTELEM *output, DCTELEM *input, int qmul);
+void ff_h264_luma_dc_dequant_idct_sse2(DCTELEM *output, DCTELEM *input, int qmul);
/***********************************/
/* deblocking */
-// out: o = |x-y|>a
-// clobbers: t
-#define DIFF_GT_MMX(x,y,a,o,t)\
- "movq "#y", "#t" \n\t"\
- "movq "#x", "#o" \n\t"\
- "psubusb "#x", "#t" \n\t"\
- "psubusb "#y", "#o" \n\t"\
- "por "#t", "#o" \n\t"\
- "psubusb "#a", "#o" \n\t"
-
-// out: o = |x-y|>a
-// clobbers: t
-#define DIFF_GT2_MMX(x,y,a,o,t)\
- "movq "#y", "#t" \n\t"\
- "movq "#x", "#o" \n\t"\
- "psubusb "#x", "#t" \n\t"\
- "psubusb "#y", "#o" \n\t"\
- "psubusb "#a", "#t" \n\t"\
- "psubusb "#a", "#o" \n\t"\
- "pcmpeqb "#t", "#o" \n\t"\
-
-// in: mm0=p1 mm1=p0 mm2=q0 mm3=q1
-// out: mm5=beta-1, mm7=mask
-// clobbers: mm4,mm6
-#define H264_DEBLOCK_MASK(alpha1, beta1) \
- "pshufw $0, "#alpha1", %%mm4 \n\t"\
- "pshufw $0, "#beta1 ", %%mm5 \n\t"\
- "packuswb %%mm4, %%mm4 \n\t"\
- "packuswb %%mm5, %%mm5 \n\t"\
- DIFF_GT_MMX(%%mm1, %%mm2, %%mm4, %%mm7, %%mm6) /* |p0-q0| > alpha-1 */\
- DIFF_GT_MMX(%%mm0, %%mm1, %%mm5, %%mm4, %%mm6) /* |p1-p0| > beta-1 */\
- "por %%mm4, %%mm7 \n\t"\
- DIFF_GT_MMX(%%mm3, %%mm2, %%mm5, %%mm4, %%mm6) /* |q1-q0| > beta-1 */\
- "por %%mm4, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- "pcmpeqb %%mm6, %%mm7 \n\t"
-
-// in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask)
-// out: mm1=p0' mm2=q0'
-// clobbers: mm0,3-6
-#define H264_DEBLOCK_P0_Q0(pb_01, pb_3f)\
- "movq %%mm1 , %%mm5 \n\t"\
- "pxor %%mm2 , %%mm5 \n\t" /* p0^q0*/\
- "pand "#pb_01" , %%mm5 \n\t" /* (p0^q0)&1*/\
- "pcmpeqb %%mm4 , %%mm4 \n\t"\
- "pxor %%mm4 , %%mm3 \n\t"\
- "pavgb %%mm0 , %%mm3 \n\t" /* (p1 - q1 + 256)>>1*/\
- "pavgb "MANGLE(ff_pb_3)" , %%mm3 \n\t" /*(((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2*/\
- "pxor %%mm1 , %%mm4 \n\t"\
- "pavgb %%mm2 , %%mm4 \n\t" /* (q0 - p0 + 256)>>1*/\
- "pavgb %%mm5 , %%mm3 \n\t"\
- "paddusb %%mm4 , %%mm3 \n\t" /* d+128+33*/\
- "movq "MANGLE(ff_pb_A1)" , %%mm6 \n\t"\
- "psubusb %%mm3 , %%mm6 \n\t"\
- "psubusb "MANGLE(ff_pb_A1)" , %%mm3 \n\t"\
- "pminub %%mm7 , %%mm6 \n\t"\
- "pminub %%mm7 , %%mm3 \n\t"\
- "psubusb %%mm6 , %%mm1 \n\t"\
- "psubusb %%mm3 , %%mm2 \n\t"\
- "paddusb %%mm3 , %%mm1 \n\t"\
- "paddusb %%mm6 , %%mm2 \n\t"
-
-// in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) %8=ff_bone
-// out: (q1addr) = av_clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 )
-// clobbers: q2, tmp, tc0
-#define H264_DEBLOCK_Q1(p1, q2, q2addr, q1addr, tc0, tmp)\
- "movq %%mm1, "#tmp" \n\t"\
- "pavgb %%mm2, "#tmp" \n\t"\
- "pavgb "#tmp", "#q2" \n\t" /* avg(p2,avg(p0,q0)) */\
- "pxor "q2addr", "#tmp" \n\t"\
- "pand %9, "#tmp" \n\t" /* (p2^avg(p0,q0))&1 */\
- "psubusb "#tmp", "#q2" \n\t" /* (p2+((p0+q0+1)>>1))>>1 */\
- "movq "#p1", "#tmp" \n\t"\
- "psubusb "#tc0", "#tmp" \n\t"\
- "paddusb "#p1", "#tc0" \n\t"\
- "pmaxub "#tmp", "#q2" \n\t"\
- "pminub "#tc0", "#q2" \n\t"\
- "movq "#q2", "q1addr" \n\t"
-
-static inline void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0)
-{
- DECLARE_ALIGNED(8, uint64_t, tmp0)[2];
-
- __asm__ volatile(
- "movq (%2,%4), %%mm0 \n\t" //p1
- "movq (%2,%4,2), %%mm1 \n\t" //p0
- "movq (%3), %%mm2 \n\t" //q0
- "movq (%3,%4), %%mm3 \n\t" //q1
- H264_DEBLOCK_MASK(%7, %8)
-
- "movd %6, %%mm4 \n\t"
- "punpcklbw %%mm4, %%mm4 \n\t"
- "punpcklwd %%mm4, %%mm4 \n\t"
- "pcmpeqb %%mm3, %%mm3 \n\t"
- "movq %%mm4, %%mm6 \n\t"
- "pcmpgtb %%mm3, %%mm4 \n\t"
- "movq %%mm6, %1 \n\t"
- "pand %%mm4, %%mm7 \n\t"
- "movq %%mm7, %0 \n\t"
-
- /* filter p1 */
- "movq (%2), %%mm3 \n\t" //p2
- DIFF_GT2_MMX(%%mm1, %%mm3, %%mm5, %%mm6, %%mm4) // |p2-p0|>beta-1
- "pand %%mm7, %%mm6 \n\t" // mask & |p2-p0|<beta
- "pand %1, %%mm7 \n\t" // mask & tc0
- "movq %%mm7, %%mm4 \n\t"
- "psubb %%mm6, %%mm7 \n\t"
- "pand %%mm4, %%mm6 \n\t" // mask & |p2-p0|<beta & tc0
- H264_DEBLOCK_Q1(%%mm0, %%mm3, "(%2)", "(%2,%4)", %%mm6, %%mm4)
-
- /* filter q1 */
- "movq (%3,%4,2), %%mm4 \n\t" //q2
- DIFF_GT2_MMX(%%mm2, %%mm4, %%mm5, %%mm6, %%mm3) // |q2-q0|>beta-1
- "pand %0, %%mm6 \n\t"
- "movq %1, %%mm5 \n\t" // can be merged with the and below but is slower then
- "pand %%mm6, %%mm5 \n\t"
- "psubb %%mm6, %%mm7 \n\t"
- "movq (%3,%4), %%mm3 \n\t"
- H264_DEBLOCK_Q1(%%mm3, %%mm4, "(%3,%4,2)", "(%3,%4)", %%mm5, %%mm6)
-
- /* filter p0, q0 */
- H264_DEBLOCK_P0_Q0(%9, unused)
- "movq %%mm1, (%2,%4,2) \n\t"
- "movq %%mm2, (%3) \n\t"
-
- : "=m"(tmp0[0]), "=m"(tmp0[1])
- : "r"(pix-3*stride), "r"(pix), "r"((x86_reg)stride),
- "m"(*tmp0/*unused*/), "m"(*(uint32_t*)tc0), "m"(alpha1), "m"(beta1),
- "m"(ff_bone)
- );
-}
-
-static void h264_v_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- if((tc0[0] & tc0[1]) >= 0)
- h264_loop_filter_luma_mmx2(pix, stride, alpha-1, beta-1, tc0);
- if((tc0[2] & tc0[3]) >= 0)
- h264_loop_filter_luma_mmx2(pix+8, stride, alpha-1, beta-1, tc0+2);
-}
-static void h264_h_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- //FIXME: could cut some load/stores by merging transpose with filter
- // also, it only needs to transpose 6x8
- DECLARE_ALIGNED(8, uint8_t, trans)[8*8];
- int i;
- for(i=0; i<2; i++, pix+=8*stride, tc0+=2) {
- if((tc0[0] & tc0[1]) < 0)
- continue;
- transpose4x4(trans, pix-4, 8, stride);
- transpose4x4(trans +4*8, pix, 8, stride);
- transpose4x4(trans+4, pix-4+4*stride, 8, stride);
- transpose4x4(trans+4+4*8, pix +4*stride, 8, stride);
- h264_loop_filter_luma_mmx2(trans+4*8, 8, alpha-1, beta-1, tc0);
- transpose4x4(pix-2, trans +2*8, stride, 8);
- transpose4x4(pix-2+4*stride, trans+4+2*8, stride, 8);
- }
-}
-
-static inline void h264_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0)
-{
- __asm__ volatile(
- "movq (%0), %%mm0 \n\t" //p1
- "movq (%0,%2), %%mm1 \n\t" //p0
- "movq (%1), %%mm2 \n\t" //q0
- "movq (%1,%2), %%mm3 \n\t" //q1
- H264_DEBLOCK_MASK(%4, %5)
- "movd %3, %%mm6 \n\t"
- "punpcklbw %%mm6, %%mm6 \n\t"
- "pand %%mm6, %%mm7 \n\t" // mm7 = tc&mask
- H264_DEBLOCK_P0_Q0(%6, %7)
- "movq %%mm1, (%0,%2) \n\t"
- "movq %%mm2, (%1) \n\t"
-
- :: "r"(pix-2*stride), "r"(pix), "r"((x86_reg)stride),
- "r"(*(uint32_t*)tc0),
- "m"(alpha1), "m"(beta1), "m"(ff_bone), "m"(ff_pb_3F)
- );
-}
-
-static void h264_v_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- h264_loop_filter_chroma_mmx2(pix, stride, alpha-1, beta-1, tc0);
-}
-
-static void h264_h_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- //FIXME: could cut some load/stores by merging transpose with filter
- DECLARE_ALIGNED(8, uint8_t, trans)[8*4];
- transpose4x4(trans, pix-2, 8, stride);
- transpose4x4(trans+4, pix-2+4*stride, 8, stride);
- h264_loop_filter_chroma_mmx2(trans+2*8, 8, alpha-1, beta-1, tc0);
- transpose4x4(pix-2, trans, stride, 8);
- transpose4x4(pix-2+4*stride, trans+4, stride, 8);
-}
-
-// p0 = (p0 + q1 + 2*p1 + 2) >> 2
-#define H264_FILTER_CHROMA4(p0, p1, q1, one) \
- "movq "#p0", %%mm4 \n\t"\
- "pxor "#q1", %%mm4 \n\t"\
- "pand "#one", %%mm4 \n\t" /* mm4 = (p0^q1)&1 */\
- "pavgb "#q1", "#p0" \n\t"\
- "psubusb %%mm4, "#p0" \n\t"\
- "pavgb "#p1", "#p0" \n\t" /* dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) */\
-
-static inline void h264_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha1, int beta1)
-{
- __asm__ volatile(
- "movq (%0), %%mm0 \n\t"
- "movq (%0,%2), %%mm1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "movq (%1,%2), %%mm3 \n\t"
- H264_DEBLOCK_MASK(%3, %4)
- "movq %%mm1, %%mm5 \n\t"
- "movq %%mm2, %%mm6 \n\t"
- H264_FILTER_CHROMA4(%%mm1, %%mm0, %%mm3, %5) //p0'
- H264_FILTER_CHROMA4(%%mm2, %%mm3, %%mm0, %5) //q0'
- "psubb %%mm5, %%mm1 \n\t"
- "psubb %%mm6, %%mm2 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "paddb %%mm5, %%mm1 \n\t"
- "paddb %%mm6, %%mm2 \n\t"
- "movq %%mm1, (%0,%2) \n\t"
- "movq %%mm2, (%1) \n\t"
- :: "r"(pix-2*stride), "r"(pix), "r"((x86_reg)stride),
- "m"(alpha1), "m"(beta1), "m"(ff_bone)
- );
-}
-
-static void h264_v_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta)
-{
- h264_loop_filter_chroma_intra_mmx2(pix, stride, alpha-1, beta-1);
-}
-
-static void h264_h_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta)
-{
- //FIXME: could cut some load/stores by merging transpose with filter
- DECLARE_ALIGNED(8, uint8_t, trans)[8*4];
- transpose4x4(trans, pix-2, 8, stride);
- transpose4x4(trans+4, pix-2+4*stride, 8, stride);
- h264_loop_filter_chroma_intra_mmx2(trans+2*8, 8, alpha-1, beta-1);
- transpose4x4(pix-2, trans, stride, 8);
- transpose4x4(pix-2+4*stride, trans+4, stride, 8);
-}
+#define h264_loop_filter_strength_iteration_mmx2(bS, nz, ref, mv, bidir, edges, step, mask_mv, dir, d_idx, mask_dir) \
+ do { \
+ x86_reg b_idx; \
+ mask_mv <<= 3; \
+ for( b_idx=0; b_idx<edges; b_idx+=step ) { \
+ if (!mask_dir) \
+ __asm__ volatile( \
+ "pxor %%mm0, %%mm0 \n\t" \
+ :: \
+ ); \
+ if(!(mask_mv & b_idx)) { \
+ if(bidir) { \
+ __asm__ volatile( \
+ "movd %a3(%0,%2), %%mm2 \n" \
+ "punpckldq %a4(%0,%2), %%mm2 \n" /* { ref0[bn], ref1[bn] } */ \
+ "pshufw $0x44, 12(%0,%2), %%mm0 \n" /* { ref0[b], ref0[b] } */ \
+ "pshufw $0x44, 52(%0,%2), %%mm1 \n" /* { ref1[b], ref1[b] } */ \
+ "pshufw $0x4E, %%mm2, %%mm3 \n" \
+ "psubb %%mm2, %%mm0 \n" /* { ref0[b]!=ref0[bn], ref0[b]!=ref1[bn] } */ \
+ "psubb %%mm3, %%mm1 \n" /* { ref1[b]!=ref1[bn], ref1[b]!=ref0[bn] } */ \
+ \
+ "por %%mm1, %%mm0 \n" \
+ "movq %a5(%1,%2,4), %%mm1 \n" \
+ "movq %a6(%1,%2,4), %%mm2 \n" \
+ "movq %%mm1, %%mm3 \n" \
+ "movq %%mm2, %%mm4 \n" \
+ "psubw 48(%1,%2,4), %%mm1 \n" \
+ "psubw 56(%1,%2,4), %%mm2 \n" \
+ "psubw 208(%1,%2,4), %%mm3 \n" \
+ "psubw 216(%1,%2,4), %%mm4 \n" \
+ "packsswb %%mm2, %%mm1 \n" \
+ "packsswb %%mm4, %%mm3 \n" \
+ "paddb %%mm6, %%mm1 \n" \
+ "paddb %%mm6, %%mm3 \n" \
+ "psubusb %%mm5, %%mm1 \n" /* abs(mv[b] - mv[bn]) >= limit */ \
+ "psubusb %%mm5, %%mm3 \n" \
+ "packsswb %%mm3, %%mm1 \n" \
+ \
+ "por %%mm1, %%mm0 \n" \
+ "movq %a7(%1,%2,4), %%mm1 \n" \
+ "movq %a8(%1,%2,4), %%mm2 \n" \
+ "movq %%mm1, %%mm3 \n" \
+ "movq %%mm2, %%mm4 \n" \
+ "psubw 48(%1,%2,4), %%mm1 \n" \
+ "psubw 56(%1,%2,4), %%mm2 \n" \
+ "psubw 208(%1,%2,4), %%mm3 \n" \
+ "psubw 216(%1,%2,4), %%mm4 \n" \
+ "packsswb %%mm2, %%mm1 \n" \
+ "packsswb %%mm4, %%mm3 \n" \
+ "paddb %%mm6, %%mm1 \n" \
+ "paddb %%mm6, %%mm3 \n" \
+ "psubusb %%mm5, %%mm1 \n" /* abs(mv[b] - mv[bn]) >= limit */ \
+ "psubusb %%mm5, %%mm3 \n" \
+ "packsswb %%mm3, %%mm1 \n" \
+ \
+ "pshufw $0x4E, %%mm1, %%mm1 \n" \
+ "por %%mm1, %%mm0 \n" \
+ "pshufw $0x4E, %%mm0, %%mm1 \n" \
+ "pminub %%mm1, %%mm0 \n" \
+ ::"r"(ref), \
+ "r"(mv), \
+ "r"(b_idx), \
+ "i"(d_idx+12), \
+ "i"(d_idx+52), \
+ "i"(d_idx*4+48), \
+ "i"(d_idx*4+56), \
+ "i"(d_idx*4+208), \
+ "i"(d_idx*4+216) \
+ ); \
+ } else { \
+ __asm__ volatile( \
+ "movd 12(%0,%2), %%mm0 \n" \
+ "psubb %a3(%0,%2), %%mm0 \n" /* ref[b] != ref[bn] */ \
+ "movq 48(%1,%2,4), %%mm1 \n" \
+ "movq 56(%1,%2,4), %%mm2 \n" \
+ "psubw %a4(%1,%2,4), %%mm1 \n" \
+ "psubw %a5(%1,%2,4), %%mm2 \n" \
+ "packsswb %%mm2, %%mm1 \n" \
+ "paddb %%mm6, %%mm1 \n" \
+ "psubusb %%mm5, %%mm1 \n" /* abs(mv[b] - mv[bn]) >= limit */ \
+ "packsswb %%mm1, %%mm1 \n" \
+ "por %%mm1, %%mm0 \n" \
+ ::"r"(ref), \
+ "r"(mv), \
+ "r"(b_idx), \
+ "i"(d_idx+12), \
+ "i"(d_idx*4+48), \
+ "i"(d_idx*4+56) \
+ ); \
+ } \
+ } \
+ __asm__ volatile( \
+ "movd 12(%0,%1), %%mm1 \n" \
+ "por %a2(%0,%1), %%mm1 \n" /* nnz[b] || nnz[bn] */ \
+ ::"r"(nnz), \
+ "r"(b_idx), \
+ "i"(d_idx+12) \
+ ); \
+ __asm__ volatile( \
+ "pminub %%mm7, %%mm1 \n" \
+ "pminub %%mm7, %%mm0 \n" \
+ "psllw $1, %%mm1 \n" \
+ "pxor %%mm2, %%mm2 \n" \
+ "pmaxub %%mm0, %%mm1 \n" \
+ "punpcklbw %%mm2, %%mm1 \n" \
+ "movq %%mm1, %a1(%0,%2) \n" \
+ ::"r"(bS), \
+ "i"(32*dir), \
+ "r"(b_idx) \
+ :"memory" \
+ ); \
+ } \
+ } while (0)
static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2],
int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field ) {
- int dir;
__asm__ volatile(
"movq %0, %%mm7 \n"
"movq %1, %%mm6 \n"
@@ -813,95 +198,11 @@ static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40]
// could do a special case for dir==0 && edges==1, but it only reduces the
// average filter time by 1.2%
- for( dir=1; dir>=0; dir-- ) {
- const x86_reg d_idx = dir ? -8 : -1;
- const int mask_mv = dir ? mask_mv1 : mask_mv0;
- DECLARE_ALIGNED(8, const uint64_t, mask_dir) = dir ? 0 : 0xffffffffffffffffULL;
- int b_idx, edge;
- for( b_idx=12, edge=0; edge<edges; edge+=step, b_idx+=8*step ) {
- __asm__ volatile(
- "pand %0, %%mm0 \n\t"
- ::"m"(mask_dir)
- );
- if(!(mask_mv & edge)) {
- if(bidir) {
- __asm__ volatile(
- "movd (%1,%0), %%mm2 \n"
- "punpckldq 40(%1,%0), %%mm2 \n" // { ref0[bn], ref1[bn] }
- "pshufw $0x44, (%1), %%mm0 \n" // { ref0[b], ref0[b] }
- "pshufw $0x44, 40(%1), %%mm1 \n" // { ref1[b], ref1[b] }
- "pshufw $0x4E, %%mm2, %%mm3 \n"
- "psubb %%mm2, %%mm0 \n" // { ref0[b]!=ref0[bn], ref0[b]!=ref1[bn] }
- "psubb %%mm3, %%mm1 \n" // { ref1[b]!=ref1[bn], ref1[b]!=ref0[bn] }
- "1: \n"
- "por %%mm1, %%mm0 \n"
- "movq (%2,%0,4), %%mm1 \n"
- "movq 8(%2,%0,4), %%mm2 \n"
- "movq %%mm1, %%mm3 \n"
- "movq %%mm2, %%mm4 \n"
- "psubw (%2), %%mm1 \n"
- "psubw 8(%2), %%mm2 \n"
- "psubw 160(%2), %%mm3 \n"
- "psubw 168(%2), %%mm4 \n"
- "packsswb %%mm2, %%mm1 \n"
- "packsswb %%mm4, %%mm3 \n"
- "paddb %%mm6, %%mm1 \n"
- "paddb %%mm6, %%mm3 \n"
- "psubusb %%mm5, %%mm1 \n" // abs(mv[b] - mv[bn]) >= limit
- "psubusb %%mm5, %%mm3 \n"
- "packsswb %%mm3, %%mm1 \n"
- "add $40, %0 \n"
- "cmp $40, %0 \n"
- "jl 1b \n"
- "sub $80, %0 \n"
- "pshufw $0x4E, %%mm1, %%mm1 \n"
- "por %%mm1, %%mm0 \n"
- "pshufw $0x4E, %%mm0, %%mm1 \n"
- "pminub %%mm1, %%mm0 \n"
- ::"r"(d_idx),
- "r"(ref[0]+b_idx),
- "r"(mv[0]+b_idx)
- );
- } else {
- __asm__ volatile(
- "movd (%1), %%mm0 \n"
- "psubb (%1,%0), %%mm0 \n" // ref[b] != ref[bn]
- "movq (%2), %%mm1 \n"
- "movq 8(%2), %%mm2 \n"
- "psubw (%2,%0,4), %%mm1 \n"
- "psubw 8(%2,%0,4), %%mm2 \n"
- "packsswb %%mm2, %%mm1 \n"
- "paddb %%mm6, %%mm1 \n"
- "psubusb %%mm5, %%mm1 \n" // abs(mv[b] - mv[bn]) >= limit
- "packsswb %%mm1, %%mm1 \n"
- "por %%mm1, %%mm0 \n"
- ::"r"(d_idx),
- "r"(ref[0]+b_idx),
- "r"(mv[0]+b_idx)
- );
- }
- }
- __asm__ volatile(
- "movd %0, %%mm1 \n"
- "por %1, %%mm1 \n" // nnz[b] || nnz[bn]
- ::"m"(nnz[b_idx]),
- "m"(nnz[b_idx+d_idx])
- );
- __asm__ volatile(
- "pminub %%mm7, %%mm1 \n"
- "pminub %%mm7, %%mm0 \n"
- "psllw $1, %%mm1 \n"
- "pxor %%mm2, %%mm2 \n"
- "pmaxub %%mm0, %%mm1 \n"
- "punpcklbw %%mm2, %%mm1 \n"
- "movq %%mm1, %0 \n"
- :"=m"(*bS[dir][edge])
- ::"memory"
- );
- }
- edges = 4;
- step = 1;
- }
+ step <<= 3;
+ edges <<= 3;
+ h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, edges, step, mask_mv1, 1, -8, 0);
+ h264_loop_filter_strength_iteration_mmx2(bS, nnz, ref, mv, bidir, 32, 8, mask_mv0, 0, -1, -1);
+
__asm__ volatile(
"movq (%0), %%mm0 \n\t"
"movq 8(%0), %%mm1 \n\t"
@@ -917,1491 +218,165 @@ static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40]
);
}
-/***********************************/
-/* motion compensation */
-
-#define QPEL_H264V_MM(A,B,C,D,E,F,OP,T,Z,d,q)\
- "mov"#q" "#C", "#T" \n\t"\
- "mov"#d" (%0), "#F" \n\t"\
- "paddw "#D", "#T" \n\t"\
- "psllw $2, "#T" \n\t"\
- "psubw "#B", "#T" \n\t"\
- "psubw "#E", "#T" \n\t"\
- "punpcklbw "#Z", "#F" \n\t"\
- "pmullw %4, "#T" \n\t"\
- "paddw %5, "#A" \n\t"\
- "add %2, %0 \n\t"\
- "paddw "#F", "#A" \n\t"\
- "paddw "#A", "#T" \n\t"\
- "psraw $5, "#T" \n\t"\
- "packuswb "#T", "#T" \n\t"\
- OP(T, (%1), A, d)\
- "add %3, %1 \n\t"
-
-#define QPEL_H264HV_MM(A,B,C,D,E,F,OF,T,Z,d,q)\
- "mov"#q" "#C", "#T" \n\t"\
- "mov"#d" (%0), "#F" \n\t"\
- "paddw "#D", "#T" \n\t"\
- "psllw $2, "#T" \n\t"\
- "paddw %4, "#A" \n\t"\
- "psubw "#B", "#T" \n\t"\
- "psubw "#E", "#T" \n\t"\
- "punpcklbw "#Z", "#F" \n\t"\
- "pmullw %3, "#T" \n\t"\
- "paddw "#F", "#A" \n\t"\
- "add %2, %0 \n\t"\
- "paddw "#A", "#T" \n\t"\
- "mov"#q" "#T", "#OF"(%1) \n\t"
-
-#define QPEL_H264V(A,B,C,D,E,F,OP) QPEL_H264V_MM(A,B,C,D,E,F,OP,%%mm6,%%mm7,d,q)
-#define QPEL_H264HV(A,B,C,D,E,F,OF) QPEL_H264HV_MM(A,B,C,D,E,F,OF,%%mm6,%%mm7,d,q)
-#define QPEL_H264V_XMM(A,B,C,D,E,F,OP) QPEL_H264V_MM(A,B,C,D,E,F,OP,%%xmm6,%%xmm7,q,dqa)
-#define QPEL_H264HV_XMM(A,B,C,D,E,F,OF) QPEL_H264HV_MM(A,B,C,D,E,F,OF,%%xmm6,%%xmm7,q,dqa)
-
-
-#define QPEL_H264(OPNAME, OP, MMX)\
-static av_noinline void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- int h=4;\
-\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movq "MANGLE(ff_pw_5) ", %%mm4\n\t"\
- "movq "MANGLE(ff_pw_16)", %%mm5\n\t"\
- "1: \n\t"\
- "movd -1(%0), %%mm1 \n\t"\
- "movd (%0), %%mm2 \n\t"\
- "movd 1(%0), %%mm3 \n\t"\
- "movd 2(%0), %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "paddw %%mm0, %%mm1 \n\t"\
- "paddw %%mm3, %%mm2 \n\t"\
- "movd -2(%0), %%mm0 \n\t"\
- "movd 3(%0), %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "paddw %%mm3, %%mm0 \n\t"\
- "psllw $2, %%mm2 \n\t"\
- "psubw %%mm1, %%mm2 \n\t"\
- "pmullw %%mm4, %%mm2 \n\t"\
- "paddw %%mm5, %%mm0 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "packuswb %%mm0, %%mm0 \n\t"\
- OP(%%mm0, (%1),%%mm6, d)\
- "add %3, %0 \n\t"\
- "add %4, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(src), "+c"(dst), "+g"(h)\
- : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
- : "memory"\
- );\
-}\
-static av_noinline void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- int h=4;\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movq %0, %%mm4 \n\t"\
- "movq %1, %%mm5 \n\t"\
- :: "m"(ff_pw_5), "m"(ff_pw_16)\
- );\
- do{\
- __asm__ volatile(\
- "movd -1(%0), %%mm1 \n\t"\
- "movd (%0), %%mm2 \n\t"\
- "movd 1(%0), %%mm3 \n\t"\
- "movd 2(%0), %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "paddw %%mm0, %%mm1 \n\t"\
- "paddw %%mm3, %%mm2 \n\t"\
- "movd -2(%0), %%mm0 \n\t"\
- "movd 3(%0), %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "paddw %%mm3, %%mm0 \n\t"\
- "psllw $2, %%mm2 \n\t"\
- "psubw %%mm1, %%mm2 \n\t"\
- "pmullw %%mm4, %%mm2 \n\t"\
- "paddw %%mm5, %%mm0 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "movd (%2), %%mm3 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "packuswb %%mm0, %%mm0 \n\t"\
- PAVGB" %%mm3, %%mm0 \n\t"\
- OP(%%mm0, (%1),%%mm6, d)\
- "add %4, %0 \n\t"\
- "add %4, %1 \n\t"\
- "add %3, %2 \n\t"\
- : "+a"(src), "+c"(dst), "+d"(src2)\
- : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride)\
- : "memory"\
- );\
- }while(--h);\
-}\
-static av_noinline void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- src -= 2*srcStride;\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movd (%0), %%mm0 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm1 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm2 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm3 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm4 \n\t"\
- "add %2, %0 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm4 \n\t"\
- QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
- QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
- QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
- QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
- \
- : "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
-}\
-static av_noinline void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- int h=4;\
- int w=3;\
- src -= 2*srcStride+2;\
- while(w--){\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movd (%0), %%mm0 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm1 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm2 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm3 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm4 \n\t"\
- "add %2, %0 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm4 \n\t"\
- QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*3)\
- QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*3)\
- QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*3)\
- QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*3)\
- \
- : "+a"(src)\
- : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- tmp += 4;\
- src += 4 - 9*srcStride;\
- }\
- tmp -= 3*4;\
- __asm__ volatile(\
- "1: \n\t"\
- "movq (%0), %%mm0 \n\t"\
- "paddw 10(%0), %%mm0 \n\t"\
- "movq 2(%0), %%mm1 \n\t"\
- "paddw 8(%0), %%mm1 \n\t"\
- "movq 4(%0), %%mm2 \n\t"\
- "paddw 6(%0), %%mm2 \n\t"\
- "psubw %%mm1, %%mm0 \n\t"/*a-b (abccba)*/\
- "psraw $2, %%mm0 \n\t"/*(a-b)/4 */\
- "psubw %%mm1, %%mm0 \n\t"/*(a-b)/4-b */\
- "paddsw %%mm2, %%mm0 \n\t"\
- "psraw $2, %%mm0 \n\t"/*((a-b)/4-b+c)/4 */\
- "paddw %%mm2, %%mm0 \n\t"/*(a-5*b+20*c)/16 */\
- "psraw $6, %%mm0 \n\t"\
- "packuswb %%mm0, %%mm0 \n\t"\
- OP(%%mm0, (%1),%%mm7, d)\
- "add $24, %0 \n\t"\
- "add %3, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(tmp), "+c"(dst), "+g"(h)\
- : "S"((x86_reg)dstStride)\
- : "memory"\
- );\
-}\
-\
-static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- int h=8;\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movq "MANGLE(ff_pw_5)", %%mm6\n\t"\
- "1: \n\t"\
- "movq (%0), %%mm0 \n\t"\
- "movq 1(%0), %%mm2 \n\t"\
- "movq %%mm0, %%mm1 \n\t"\
- "movq %%mm2, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpckhbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpckhbw %%mm7, %%mm3 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "paddw %%mm3, %%mm1 \n\t"\
- "psllw $2, %%mm0 \n\t"\
- "psllw $2, %%mm1 \n\t"\
- "movq -1(%0), %%mm2 \n\t"\
- "movq 2(%0), %%mm4 \n\t"\
- "movq %%mm2, %%mm3 \n\t"\
- "movq %%mm4, %%mm5 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpckhbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm4 \n\t"\
- "punpckhbw %%mm7, %%mm5 \n\t"\
- "paddw %%mm4, %%mm2 \n\t"\
- "paddw %%mm3, %%mm5 \n\t"\
- "psubw %%mm2, %%mm0 \n\t"\
- "psubw %%mm5, %%mm1 \n\t"\
- "pmullw %%mm6, %%mm0 \n\t"\
- "pmullw %%mm6, %%mm1 \n\t"\
- "movd -2(%0), %%mm2 \n\t"\
- "movd 7(%0), %%mm5 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm5 \n\t"\
- "paddw %%mm3, %%mm2 \n\t"\
- "paddw %%mm5, %%mm4 \n\t"\
- "movq "MANGLE(ff_pw_16)", %%mm5\n\t"\
- "paddw %%mm5, %%mm2 \n\t"\
- "paddw %%mm5, %%mm4 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "paddw %%mm4, %%mm1 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "psraw $5, %%mm1 \n\t"\
- "packuswb %%mm1, %%mm0 \n\t"\
- OP(%%mm0, (%1),%%mm5, q)\
- "add %3, %0 \n\t"\
- "add %4, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(src), "+c"(dst), "+g"(h)\
- : "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
- : "memory"\
- );\
-}\
-\
-static av_noinline void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- int h=8;\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movq %0, %%mm6 \n\t"\
- :: "m"(ff_pw_5)\
- );\
- do{\
- __asm__ volatile(\
- "movq (%0), %%mm0 \n\t"\
- "movq 1(%0), %%mm2 \n\t"\
- "movq %%mm0, %%mm1 \n\t"\
- "movq %%mm2, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpckhbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpckhbw %%mm7, %%mm3 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "paddw %%mm3, %%mm1 \n\t"\
- "psllw $2, %%mm0 \n\t"\
- "psllw $2, %%mm1 \n\t"\
- "movq -1(%0), %%mm2 \n\t"\
- "movq 2(%0), %%mm4 \n\t"\
- "movq %%mm2, %%mm3 \n\t"\
- "movq %%mm4, %%mm5 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpckhbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm4 \n\t"\
- "punpckhbw %%mm7, %%mm5 \n\t"\
- "paddw %%mm4, %%mm2 \n\t"\
- "paddw %%mm3, %%mm5 \n\t"\
- "psubw %%mm2, %%mm0 \n\t"\
- "psubw %%mm5, %%mm1 \n\t"\
- "pmullw %%mm6, %%mm0 \n\t"\
- "pmullw %%mm6, %%mm1 \n\t"\
- "movd -2(%0), %%mm2 \n\t"\
- "movd 7(%0), %%mm5 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm5 \n\t"\
- "paddw %%mm3, %%mm2 \n\t"\
- "paddw %%mm5, %%mm4 \n\t"\
- "movq %5, %%mm5 \n\t"\
- "paddw %%mm5, %%mm2 \n\t"\
- "paddw %%mm5, %%mm4 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "paddw %%mm4, %%mm1 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "psraw $5, %%mm1 \n\t"\
- "movq (%2), %%mm4 \n\t"\
- "packuswb %%mm1, %%mm0 \n\t"\
- PAVGB" %%mm4, %%mm0 \n\t"\
- OP(%%mm0, (%1),%%mm5, q)\
- "add %4, %0 \n\t"\
- "add %4, %1 \n\t"\
- "add %3, %2 \n\t"\
- : "+a"(src), "+c"(dst), "+d"(src2)\
- : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\
- "m"(ff_pw_16)\
- : "memory"\
- );\
- }while(--h);\
-}\
-\
-static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- int w= 2;\
- src -= 2*srcStride;\
- \
- while(w--){\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movd (%0), %%mm0 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm1 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm2 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm3 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm4 \n\t"\
- "add %2, %0 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm4 \n\t"\
- QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
- QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
- QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
- QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
- QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
- QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
- QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
- QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
- \
- : "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- if(h==16){\
- __asm__ volatile(\
- QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
- QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
- QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
- QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
- QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
- QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
- QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
- QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
- \
- : "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- }\
- src += 4-(h+5)*srcStride;\
- dst += 4-h*dstStride;\
- }\
-}\
-static av_always_inline void OPNAME ## h264_qpel8or16_hv1_lowpass_ ## MMX(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){\
- int w = (size+8)>>2;\
- src -= 2*srcStride+2;\
- while(w--){\
- __asm__ volatile(\
- "pxor %%mm7, %%mm7 \n\t"\
- "movd (%0), %%mm0 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm1 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm2 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm3 \n\t"\
- "add %2, %0 \n\t"\
- "movd (%0), %%mm4 \n\t"\
- "add %2, %0 \n\t"\
- "punpcklbw %%mm7, %%mm0 \n\t"\
- "punpcklbw %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm7, %%mm2 \n\t"\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm7, %%mm4 \n\t"\
- QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*48)\
- QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*48)\
- QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*48)\
- QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*48)\
- QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 4*48)\
- QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 5*48)\
- QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 6*48)\
- QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 7*48)\
- : "+a"(src)\
- : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- if(size==16){\
- __asm__ volatile(\
- QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 8*48)\
- QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 9*48)\
- QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 10*48)\
- QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 11*48)\
- QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 12*48)\
- QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 13*48)\
- QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 14*48)\
- QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
- : "+a"(src)\
- : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- }\
- tmp += 4;\
- src += 4 - (size+5)*srcStride;\
- }\
-}\
-static av_always_inline void OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
- int w = size>>4;\
- do{\
- int h = size;\
- __asm__ volatile(\
- "1: \n\t"\
- "movq (%0), %%mm0 \n\t"\
- "movq 8(%0), %%mm3 \n\t"\
- "movq 2(%0), %%mm1 \n\t"\
- "movq 10(%0), %%mm4 \n\t"\
- "paddw %%mm4, %%mm0 \n\t"\
- "paddw %%mm3, %%mm1 \n\t"\
- "paddw 18(%0), %%mm3 \n\t"\
- "paddw 16(%0), %%mm4 \n\t"\
- "movq 4(%0), %%mm2 \n\t"\
- "movq 12(%0), %%mm5 \n\t"\
- "paddw 6(%0), %%mm2 \n\t"\
- "paddw 14(%0), %%mm5 \n\t"\
- "psubw %%mm1, %%mm0 \n\t"\
- "psubw %%mm4, %%mm3 \n\t"\
- "psraw $2, %%mm0 \n\t"\
- "psraw $2, %%mm3 \n\t"\
- "psubw %%mm1, %%mm0 \n\t"\
- "psubw %%mm4, %%mm3 \n\t"\
- "paddsw %%mm2, %%mm0 \n\t"\
- "paddsw %%mm5, %%mm3 \n\t"\
- "psraw $2, %%mm0 \n\t"\
- "psraw $2, %%mm3 \n\t"\
- "paddw %%mm2, %%mm0 \n\t"\
- "paddw %%mm5, %%mm3 \n\t"\
- "psraw $6, %%mm0 \n\t"\
- "psraw $6, %%mm3 \n\t"\
- "packuswb %%mm3, %%mm0 \n\t"\
- OP(%%mm0, (%1),%%mm7, q)\
- "add $48, %0 \n\t"\
- "add %3, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(tmp), "+c"(dst), "+g"(h)\
- : "S"((x86_reg)dstStride)\
- : "memory"\
- );\
- tmp += 8 - size*24;\
- dst += 8 - size*dstStride;\
- }while(w--);\
-}\
-\
-static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
-}\
-static av_noinline void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
- OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
-}\
-\
-static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
- src += 8*dstStride;\
- dst += 8*dstStride;\
- src2 += 8*src2Stride;\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
-}\
-\
-static av_noinline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
- put_h264_qpel8or16_hv1_lowpass_ ## MMX(tmp, src, tmpStride, srcStride, size);\
- OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
-}\
-static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\
-}\
-\
-static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\
-}\
-\
-static av_noinline void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
-{\
- __asm__ volatile(\
- "movq (%1), %%mm0 \n\t"\
- "movq 24(%1), %%mm1 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "psraw $5, %%mm1 \n\t"\
- "packuswb %%mm0, %%mm0 \n\t"\
- "packuswb %%mm1, %%mm1 \n\t"\
- PAVGB" (%0), %%mm0 \n\t"\
- PAVGB" (%0,%3), %%mm1 \n\t"\
- OP(%%mm0, (%2), %%mm4, d)\
- OP(%%mm1, (%2,%4), %%mm5, d)\
- "lea (%0,%3,2), %0 \n\t"\
- "lea (%2,%4,2), %2 \n\t"\
- "movq 48(%1), %%mm0 \n\t"\
- "movq 72(%1), %%mm1 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "psraw $5, %%mm1 \n\t"\
- "packuswb %%mm0, %%mm0 \n\t"\
- "packuswb %%mm1, %%mm1 \n\t"\
- PAVGB" (%0), %%mm0 \n\t"\
- PAVGB" (%0,%3), %%mm1 \n\t"\
- OP(%%mm0, (%2), %%mm4, d)\
- OP(%%mm1, (%2,%4), %%mm5, d)\
- :"+a"(src8), "+c"(src16), "+d"(dst)\
- :"S"((x86_reg)src8Stride), "D"((x86_reg)dstStride)\
- :"memory");\
-}\
-static av_noinline void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
-{\
- do{\
- __asm__ volatile(\
- "movq (%1), %%mm0 \n\t"\
- "movq 8(%1), %%mm1 \n\t"\
- "movq 48(%1), %%mm2 \n\t"\
- "movq 8+48(%1), %%mm3 \n\t"\
- "psraw $5, %%mm0 \n\t"\
- "psraw $5, %%mm1 \n\t"\
- "psraw $5, %%mm2 \n\t"\
- "psraw $5, %%mm3 \n\t"\
- "packuswb %%mm1, %%mm0 \n\t"\
- "packuswb %%mm3, %%mm2 \n\t"\
- PAVGB" (%0), %%mm0 \n\t"\
- PAVGB" (%0,%3), %%mm2 \n\t"\
- OP(%%mm0, (%2), %%mm5, q)\
- OP(%%mm2, (%2,%4), %%mm5, q)\
- ::"a"(src8), "c"(src16), "d"(dst),\
- "r"((x86_reg)src8Stride), "r"((x86_reg)dstStride)\
- :"memory");\
- src8 += 2L*src8Stride;\
- src16 += 48;\
- dst += 2L*dstStride;\
- }while(h-=2);\
-}\
-static void OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
-{\
- OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\
- OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\
-}\
-
-
-#if ARCH_X86_64
-#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
-static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- int h=16;\
- __asm__ volatile(\
- "pxor %%xmm15, %%xmm15 \n\t"\
- "movdqa %6, %%xmm14 \n\t"\
- "movdqa %7, %%xmm13 \n\t"\
- "1: \n\t"\
- "lddqu 6(%0), %%xmm1 \n\t"\
- "lddqu -2(%0), %%xmm7 \n\t"\
- "movdqa %%xmm1, %%xmm0 \n\t"\
- "punpckhbw %%xmm15, %%xmm1 \n\t"\
- "punpcklbw %%xmm15, %%xmm0 \n\t"\
- "punpcklbw %%xmm15, %%xmm7 \n\t"\
- "movdqa %%xmm1, %%xmm2 \n\t"\
- "movdqa %%xmm0, %%xmm6 \n\t"\
- "movdqa %%xmm1, %%xmm3 \n\t"\
- "movdqa %%xmm0, %%xmm8 \n\t"\
- "movdqa %%xmm1, %%xmm4 \n\t"\
- "movdqa %%xmm0, %%xmm9 \n\t"\
- "movdqa %%xmm0, %%xmm12 \n\t"\
- "movdqa %%xmm1, %%xmm11 \n\t"\
- "palignr $10,%%xmm0, %%xmm11\n\t"\
- "palignr $10,%%xmm7, %%xmm12\n\t"\
- "palignr $2, %%xmm0, %%xmm4 \n\t"\
- "palignr $2, %%xmm7, %%xmm9 \n\t"\
- "palignr $4, %%xmm0, %%xmm3 \n\t"\
- "palignr $4, %%xmm7, %%xmm8 \n\t"\
- "palignr $6, %%xmm0, %%xmm2 \n\t"\
- "palignr $6, %%xmm7, %%xmm6 \n\t"\
- "paddw %%xmm0 ,%%xmm11 \n\t"\
- "palignr $8, %%xmm0, %%xmm1 \n\t"\
- "palignr $8, %%xmm7, %%xmm0 \n\t"\
- "paddw %%xmm12,%%xmm7 \n\t"\
- "paddw %%xmm3, %%xmm2 \n\t"\
- "paddw %%xmm8, %%xmm6 \n\t"\
- "paddw %%xmm4, %%xmm1 \n\t"\
- "paddw %%xmm9, %%xmm0 \n\t"\
- "psllw $2, %%xmm2 \n\t"\
- "psllw $2, %%xmm6 \n\t"\
- "psubw %%xmm1, %%xmm2 \n\t"\
- "psubw %%xmm0, %%xmm6 \n\t"\
- "paddw %%xmm13,%%xmm11 \n\t"\
- "paddw %%xmm13,%%xmm7 \n\t"\
- "pmullw %%xmm14,%%xmm2 \n\t"\
- "pmullw %%xmm14,%%xmm6 \n\t"\
- "lddqu (%2), %%xmm3 \n\t"\
- "paddw %%xmm11,%%xmm2 \n\t"\
- "paddw %%xmm7, %%xmm6 \n\t"\
- "psraw $5, %%xmm2 \n\t"\
- "psraw $5, %%xmm6 \n\t"\
- "packuswb %%xmm2,%%xmm6 \n\t"\
- "pavgb %%xmm3, %%xmm6 \n\t"\
- OP(%%xmm6, (%1), %%xmm4, dqa)\
- "add %5, %0 \n\t"\
- "add %5, %1 \n\t"\
- "add %4, %2 \n\t"\
- "decl %3 \n\t"\
- "jg 1b \n\t"\
- : "+a"(src), "+c"(dst), "+d"(src2), "+g"(h)\
- : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\
- "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
-}
-#else // ARCH_X86_64
-#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
-static av_noinline void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
- src += 8*dstStride;\
- dst += 8*dstStride;\
- src2 += 8*src2Stride;\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
-}
-#endif // ARCH_X86_64
-
-#define QPEL_H264_H_XMM(OPNAME, OP, MMX)\
-static av_noinline void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- int h=8;\
- __asm__ volatile(\
- "pxor %%xmm7, %%xmm7 \n\t"\
- "movdqa %0, %%xmm6 \n\t"\
- :: "m"(ff_pw_5)\
- );\
- do{\
- __asm__ volatile(\
- "lddqu -2(%0), %%xmm1 \n\t"\
- "movdqa %%xmm1, %%xmm0 \n\t"\
- "punpckhbw %%xmm7, %%xmm1 \n\t"\
- "punpcklbw %%xmm7, %%xmm0 \n\t"\
- "movdqa %%xmm1, %%xmm2 \n\t"\
- "movdqa %%xmm1, %%xmm3 \n\t"\
- "movdqa %%xmm1, %%xmm4 \n\t"\
- "movdqa %%xmm1, %%xmm5 \n\t"\
- "palignr $2, %%xmm0, %%xmm4 \n\t"\
- "palignr $4, %%xmm0, %%xmm3 \n\t"\
- "palignr $6, %%xmm0, %%xmm2 \n\t"\
- "palignr $8, %%xmm0, %%xmm1 \n\t"\
- "palignr $10,%%xmm0, %%xmm5 \n\t"\
- "paddw %%xmm5, %%xmm0 \n\t"\
- "paddw %%xmm3, %%xmm2 \n\t"\
- "paddw %%xmm4, %%xmm1 \n\t"\
- "psllw $2, %%xmm2 \n\t"\
- "movq (%2), %%xmm3 \n\t"\
- "psubw %%xmm1, %%xmm2 \n\t"\
- "paddw %5, %%xmm0 \n\t"\
- "pmullw %%xmm6, %%xmm2 \n\t"\
- "paddw %%xmm0, %%xmm2 \n\t"\
- "psraw $5, %%xmm2 \n\t"\
- "packuswb %%xmm2, %%xmm2 \n\t"\
- "pavgb %%xmm3, %%xmm2 \n\t"\
- OP(%%xmm2, (%1), %%xmm4, q)\
- "add %4, %0 \n\t"\
- "add %4, %1 \n\t"\
- "add %3, %2 \n\t"\
- : "+a"(src), "+c"(dst), "+d"(src2)\
- : "D"((x86_reg)src2Stride), "S"((x86_reg)dstStride),\
- "m"(ff_pw_16)\
- : "memory"\
- );\
- }while(--h);\
-}\
-QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
-\
-static av_noinline void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- int h=8;\
- __asm__ volatile(\
- "pxor %%xmm7, %%xmm7 \n\t"\
- "movdqa "MANGLE(ff_pw_5)", %%xmm6\n\t"\
- "1: \n\t"\
- "lddqu -2(%0), %%xmm1 \n\t"\
- "movdqa %%xmm1, %%xmm0 \n\t"\
- "punpckhbw %%xmm7, %%xmm1 \n\t"\
- "punpcklbw %%xmm7, %%xmm0 \n\t"\
- "movdqa %%xmm1, %%xmm2 \n\t"\
- "movdqa %%xmm1, %%xmm3 \n\t"\
- "movdqa %%xmm1, %%xmm4 \n\t"\
- "movdqa %%xmm1, %%xmm5 \n\t"\
- "palignr $2, %%xmm0, %%xmm4 \n\t"\
- "palignr $4, %%xmm0, %%xmm3 \n\t"\
- "palignr $6, %%xmm0, %%xmm2 \n\t"\
- "palignr $8, %%xmm0, %%xmm1 \n\t"\
- "palignr $10,%%xmm0, %%xmm5 \n\t"\
- "paddw %%xmm5, %%xmm0 \n\t"\
- "paddw %%xmm3, %%xmm2 \n\t"\
- "paddw %%xmm4, %%xmm1 \n\t"\
- "psllw $2, %%xmm2 \n\t"\
- "psubw %%xmm1, %%xmm2 \n\t"\
- "paddw "MANGLE(ff_pw_16)", %%xmm0\n\t"\
- "pmullw %%xmm6, %%xmm2 \n\t"\
- "paddw %%xmm0, %%xmm2 \n\t"\
- "psraw $5, %%xmm2 \n\t"\
- "packuswb %%xmm2, %%xmm2 \n\t"\
- OP(%%xmm2, (%1), %%xmm4, q)\
- "add %3, %0 \n\t"\
- "add %4, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(src), "+c"(dst), "+g"(h)\
- : "D"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
- : "memory"\
- );\
-}\
-static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-}\
-
-#define QPEL_H264_V_XMM(OPNAME, OP, MMX)\
-static av_noinline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- src -= 2*srcStride;\
- \
- __asm__ volatile(\
- "pxor %%xmm7, %%xmm7 \n\t"\
- "movq (%0), %%xmm0 \n\t"\
- "add %2, %0 \n\t"\
- "movq (%0), %%xmm1 \n\t"\
- "add %2, %0 \n\t"\
- "movq (%0), %%xmm2 \n\t"\
- "add %2, %0 \n\t"\
- "movq (%0), %%xmm3 \n\t"\
- "add %2, %0 \n\t"\
- "movq (%0), %%xmm4 \n\t"\
- "add %2, %0 \n\t"\
- "punpcklbw %%xmm7, %%xmm0 \n\t"\
- "punpcklbw %%xmm7, %%xmm1 \n\t"\
- "punpcklbw %%xmm7, %%xmm2 \n\t"\
- "punpcklbw %%xmm7, %%xmm3 \n\t"\
- "punpcklbw %%xmm7, %%xmm4 \n\t"\
- QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\
- QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\
- QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\
- QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\
- QPEL_H264V_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, OP)\
- QPEL_H264V_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, OP)\
- QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\
- QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\
- \
- : "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- if(h==16){\
- __asm__ volatile(\
- QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\
- QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\
- QPEL_H264V_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, OP)\
- QPEL_H264V_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, OP)\
- QPEL_H264V_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, OP)\
- QPEL_H264V_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, OP)\
- QPEL_H264V_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, OP)\
- QPEL_H264V_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, OP)\
- \
- : "+a"(src), "+c"(dst)\
- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
- : "memory"\
- );\
- }\
-}\
-static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
-}\
-static av_noinline void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
- OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
-}
-
-static av_always_inline void put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){
- int w = (size+8)>>3;
- src -= 2*srcStride+2;
- while(w--){
- __asm__ volatile(
- "pxor %%xmm7, %%xmm7 \n\t"
- "movq (%0), %%xmm0 \n\t"
- "add %2, %0 \n\t"
- "movq (%0), %%xmm1 \n\t"
- "add %2, %0 \n\t"
- "movq (%0), %%xmm2 \n\t"
- "add %2, %0 \n\t"
- "movq (%0), %%xmm3 \n\t"
- "add %2, %0 \n\t"
- "movq (%0), %%xmm4 \n\t"
- "add %2, %0 \n\t"
- "punpcklbw %%xmm7, %%xmm0 \n\t"
- "punpcklbw %%xmm7, %%xmm1 \n\t"
- "punpcklbw %%xmm7, %%xmm2 \n\t"
- "punpcklbw %%xmm7, %%xmm3 \n\t"
- "punpcklbw %%xmm7, %%xmm4 \n\t"
- QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 0*48)
- QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 1*48)
- QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 2*48)
- QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 3*48)
- QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 4*48)
- QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 5*48)
- QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 6*48)
- QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 7*48)
- : "+a"(src)
- : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)
- : "memory"
- );
- if(size==16){
- __asm__ volatile(
- QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 8*48)
- QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 9*48)
- QPEL_H264HV_XMM(%%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, 10*48)
- QPEL_H264HV_XMM(%%xmm5, %%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, 11*48)
- QPEL_H264HV_XMM(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, 12*48)
- QPEL_H264HV_XMM(%%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, 13*48)
- QPEL_H264HV_XMM(%%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, 14*48)
- QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
- : "+a"(src)
- : "c"(tmp), "S"((x86_reg)srcStride), "m"(ff_pw_5), "m"(ff_pw_16)
- : "memory"
- );
- }
- tmp += 8;
- src += 8 - (size+5)*srcStride;
- }
-}
-
-#define QPEL_H264_HV2_XMM(OPNAME, OP, MMX)\
-static av_always_inline void OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
- int h = size;\
- if(size == 16){\
- __asm__ volatile(\
- "1: \n\t"\
- "movdqa 32(%0), %%xmm4 \n\t"\
- "movdqa 16(%0), %%xmm5 \n\t"\
- "movdqa (%0), %%xmm7 \n\t"\
- "movdqa %%xmm4, %%xmm3 \n\t"\
- "movdqa %%xmm4, %%xmm2 \n\t"\
- "movdqa %%xmm4, %%xmm1 \n\t"\
- "movdqa %%xmm4, %%xmm0 \n\t"\
- "palignr $10, %%xmm5, %%xmm0 \n\t"\
- "palignr $8, %%xmm5, %%xmm1 \n\t"\
- "palignr $6, %%xmm5, %%xmm2 \n\t"\
- "palignr $4, %%xmm5, %%xmm3 \n\t"\
- "palignr $2, %%xmm5, %%xmm4 \n\t"\
- "paddw %%xmm5, %%xmm0 \n\t"\
- "paddw %%xmm4, %%xmm1 \n\t"\
- "paddw %%xmm3, %%xmm2 \n\t"\
- "movdqa %%xmm5, %%xmm6 \n\t"\
- "movdqa %%xmm5, %%xmm4 \n\t"\
- "movdqa %%xmm5, %%xmm3 \n\t"\
- "palignr $8, %%xmm7, %%xmm4 \n\t"\
- "palignr $2, %%xmm7, %%xmm6 \n\t"\
- "palignr $10, %%xmm7, %%xmm3 \n\t"\
- "paddw %%xmm6, %%xmm4 \n\t"\
- "movdqa %%xmm5, %%xmm6 \n\t"\
- "palignr $6, %%xmm7, %%xmm5 \n\t"\
- "palignr $4, %%xmm7, %%xmm6 \n\t"\
- "paddw %%xmm7, %%xmm3 \n\t"\
- "paddw %%xmm6, %%xmm5 \n\t"\
- \
- "psubw %%xmm1, %%xmm0 \n\t"\
- "psubw %%xmm4, %%xmm3 \n\t"\
- "psraw $2, %%xmm0 \n\t"\
- "psraw $2, %%xmm3 \n\t"\
- "psubw %%xmm1, %%xmm0 \n\t"\
- "psubw %%xmm4, %%xmm3 \n\t"\
- "paddw %%xmm2, %%xmm0 \n\t"\
- "paddw %%xmm5, %%xmm3 \n\t"\
- "psraw $2, %%xmm0 \n\t"\
- "psraw $2, %%xmm3 \n\t"\
- "paddw %%xmm2, %%xmm0 \n\t"\
- "paddw %%xmm5, %%xmm3 \n\t"\
- "psraw $6, %%xmm0 \n\t"\
- "psraw $6, %%xmm3 \n\t"\
- "packuswb %%xmm0, %%xmm3 \n\t"\
- OP(%%xmm3, (%1), %%xmm7, dqa)\
- "add $48, %0 \n\t"\
- "add %3, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(tmp), "+c"(dst), "+g"(h)\
- : "S"((x86_reg)dstStride)\
- : "memory"\
- );\
- }else{\
- __asm__ volatile(\
- "1: \n\t"\
- "movdqa 16(%0), %%xmm1 \n\t"\
- "movdqa (%0), %%xmm0 \n\t"\
- "movdqa %%xmm1, %%xmm2 \n\t"\
- "movdqa %%xmm1, %%xmm3 \n\t"\
- "movdqa %%xmm1, %%xmm4 \n\t"\
- "movdqa %%xmm1, %%xmm5 \n\t"\
- "palignr $10, %%xmm0, %%xmm5 \n\t"\
- "palignr $8, %%xmm0, %%xmm4 \n\t"\
- "palignr $6, %%xmm0, %%xmm3 \n\t"\
- "palignr $4, %%xmm0, %%xmm2 \n\t"\
- "palignr $2, %%xmm0, %%xmm1 \n\t"\
- "paddw %%xmm5, %%xmm0 \n\t"\
- "paddw %%xmm4, %%xmm1 \n\t"\
- "paddw %%xmm3, %%xmm2 \n\t"\
- "psubw %%xmm1, %%xmm0 \n\t"\
- "psraw $2, %%xmm0 \n\t"\
- "psubw %%xmm1, %%xmm0 \n\t"\
- "paddw %%xmm2, %%xmm0 \n\t"\
- "psraw $2, %%xmm0 \n\t"\
- "paddw %%xmm2, %%xmm0 \n\t"\
- "psraw $6, %%xmm0 \n\t"\
- "packuswb %%xmm0, %%xmm0 \n\t"\
- OP(%%xmm0, (%1), %%xmm7, q)\
- "add $48, %0 \n\t"\
- "add %3, %1 \n\t"\
- "decl %2 \n\t"\
- " jnz 1b \n\t"\
- : "+a"(tmp), "+c"(dst), "+g"(h)\
- : "S"((x86_reg)dstStride)\
- : "memory"\
- );\
- }\
-}
-
-#define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
-static av_noinline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
- put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, tmpStride, srcStride, size);\
- OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
-}\
-static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 8);\
-}\
-static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 16);\
-}\
-
-#define put_pixels8_l2_sse2 put_pixels8_l2_mmx2
-#define avg_pixels8_l2_sse2 avg_pixels8_l2_mmx2
-#define put_pixels16_l2_sse2 put_pixels16_l2_mmx2
-#define avg_pixels16_l2_sse2 avg_pixels16_l2_mmx2
-#define put_pixels8_l2_ssse3 put_pixels8_l2_mmx2
-#define avg_pixels8_l2_ssse3 avg_pixels8_l2_mmx2
-#define put_pixels16_l2_ssse3 put_pixels16_l2_mmx2
-#define avg_pixels16_l2_ssse3 avg_pixels16_l2_mmx2
-
-#define put_pixels8_l2_shift5_sse2 put_pixels8_l2_shift5_mmx2
-#define avg_pixels8_l2_shift5_sse2 avg_pixels8_l2_shift5_mmx2
-#define put_pixels16_l2_shift5_sse2 put_pixels16_l2_shift5_mmx2
-#define avg_pixels16_l2_shift5_sse2 avg_pixels16_l2_shift5_mmx2
-#define put_pixels8_l2_shift5_ssse3 put_pixels8_l2_shift5_mmx2
-#define avg_pixels8_l2_shift5_ssse3 avg_pixels8_l2_shift5_mmx2
-#define put_pixels16_l2_shift5_ssse3 put_pixels16_l2_shift5_mmx2
-#define avg_pixels16_l2_shift5_ssse3 avg_pixels16_l2_shift5_mmx2
-
-#define put_h264_qpel8_h_lowpass_l2_sse2 put_h264_qpel8_h_lowpass_l2_mmx2
-#define avg_h264_qpel8_h_lowpass_l2_sse2 avg_h264_qpel8_h_lowpass_l2_mmx2
-#define put_h264_qpel16_h_lowpass_l2_sse2 put_h264_qpel16_h_lowpass_l2_mmx2
-#define avg_h264_qpel16_h_lowpass_l2_sse2 avg_h264_qpel16_h_lowpass_l2_mmx2
-
-#define put_h264_qpel8_v_lowpass_ssse3 put_h264_qpel8_v_lowpass_sse2
-#define avg_h264_qpel8_v_lowpass_ssse3 avg_h264_qpel8_v_lowpass_sse2
-#define put_h264_qpel16_v_lowpass_ssse3 put_h264_qpel16_v_lowpass_sse2
-#define avg_h264_qpel16_v_lowpass_ssse3 avg_h264_qpel16_v_lowpass_sse2
-
-#define put_h264_qpel8or16_hv2_lowpass_sse2 put_h264_qpel8or16_hv2_lowpass_mmx2
-#define avg_h264_qpel8or16_hv2_lowpass_sse2 avg_h264_qpel8or16_hv2_lowpass_mmx2
-
-#define H264_MC(OPNAME, SIZE, MMX, ALIGN) \
-H264_MC_C(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\
-
-static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
- put_pixels16_sse2(dst, src, stride, 16);
-}
-static void avg_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
- avg_pixels16_sse2(dst, src, stride, 16);
-}
-#define put_h264_qpel8_mc00_sse2 put_h264_qpel8_mc00_mmx2
-#define avg_h264_qpel8_mc00_sse2 avg_h264_qpel8_mc00_mmx2
-
-#define H264_MC_C(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## pixels ## SIZE ## _ ## MMX(dst, src, stride, SIZE);\
-}\
-
-#define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\
-}\
-
-#define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, temp, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\
-}\
-
-#define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint16_t, temp)[SIZE*(SIZE<8?12:24)];\
- OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, temp, src, stride, SIZE, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+2, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- OPNAME ## pixels ## SIZE ## _l2_shift5_ ## MMX(dst, halfV+3, halfHV, stride, SIZE, SIZE);\
-}\
-
-#define H264_MC_4816(MMX)\
-H264_MC(put_, 4, MMX, 8)\
-H264_MC(put_, 8, MMX, 8)\
-H264_MC(put_, 16,MMX, 8)\
-H264_MC(avg_, 4, MMX, 8)\
-H264_MC(avg_, 8, MMX, 8)\
-H264_MC(avg_, 16,MMX, 8)\
-
-#define H264_MC_816(QPEL, XMM)\
-QPEL(put_, 8, XMM, 16)\
-QPEL(put_, 16,XMM, 16)\
-QPEL(avg_, 8, XMM, 16)\
-QPEL(avg_, 16,XMM, 16)\
-
-
-#define AVG_3DNOW_OP(a,b,temp, size) \
-"mov" #size " " #b ", " #temp " \n\t"\
-"pavgusb " #temp ", " #a " \n\t"\
-"mov" #size " " #a ", " #b " \n\t"
-#define AVG_MMX2_OP(a,b,temp, size) \
-"mov" #size " " #b ", " #temp " \n\t"\
-"pavgb " #temp ", " #a " \n\t"\
-"mov" #size " " #a ", " #b " \n\t"
-
-#define PAVGB "pavgusb"
-QPEL_H264(put_, PUT_OP, 3dnow)
-QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow)
-#undef PAVGB
-#define PAVGB "pavgb"
-QPEL_H264(put_, PUT_OP, mmx2)
-QPEL_H264(avg_, AVG_MMX2_OP, mmx2)
-QPEL_H264_V_XMM(put_, PUT_OP, sse2)
-QPEL_H264_V_XMM(avg_, AVG_MMX2_OP, sse2)
-QPEL_H264_HV_XMM(put_, PUT_OP, sse2)
-QPEL_H264_HV_XMM(avg_, AVG_MMX2_OP, sse2)
-#if HAVE_SSSE3
-QPEL_H264_H_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_H_XMM(avg_, AVG_MMX2_OP, ssse3)
-QPEL_H264_HV2_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_HV2_XMM(avg_, AVG_MMX2_OP, ssse3)
-QPEL_H264_HV_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_HV_XMM(avg_, AVG_MMX2_OP, ssse3)
-#endif
-#undef PAVGB
-
-H264_MC_4816(3dnow)
-H264_MC_4816(mmx2)
-H264_MC_816(H264_MC_V, sse2)
-H264_MC_816(H264_MC_HV, sse2)
-#if HAVE_SSSE3
-H264_MC_816(H264_MC_H, ssse3)
-H264_MC_816(H264_MC_HV, ssse3)
-#endif
-
-/* rnd interleaved with rnd div 8, use p+1 to access rnd div 8 */
-DECLARE_ALIGNED(8, static const uint64_t, h264_rnd_reg)[4] = {
- 0x0020002000200020ULL, 0x0004000400040004ULL, 0x001C001C001C001CULL, 0x0003000300030003ULL
-};
-
-#define H264_CHROMA_OP(S,D)
-#define H264_CHROMA_OP4(S,D,T)
-#define H264_CHROMA_MC8_TMPL put_h264_chroma_generic_mc8_mmx
-#define H264_CHROMA_MC4_TMPL put_h264_chroma_generic_mc4_mmx
-#define H264_CHROMA_MC2_TMPL put_h264_chroma_mc2_mmx2
-#define H264_CHROMA_MC8_MV0 put_pixels8_mmx
-#include "dsputil_h264_template_mmx.c"
-
-static void put_h264_chroma_mc8_mmx_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_generic_mc8_mmx(dst, src, stride, h, x, y, h264_rnd_reg);
-}
-static void put_vc1_chroma_mc8_mmx_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_generic_mc8_mmx(dst, src, stride, h, x, y, h264_rnd_reg+2);
-}
-static void put_h264_chroma_mc4_mmx(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_generic_mc4_mmx(dst, src, stride, h, x, y, h264_rnd_reg);
-}
-
-#undef H264_CHROMA_OP
-#undef H264_CHROMA_OP4
-#undef H264_CHROMA_MC8_TMPL
-#undef H264_CHROMA_MC4_TMPL
-#undef H264_CHROMA_MC2_TMPL
-#undef H264_CHROMA_MC8_MV0
+#define LF_FUNC(DIR, TYPE, OPT) \
+void ff_x264_deblock_ ## DIR ## _ ## TYPE ## _ ## OPT (uint8_t *pix, int stride, \
+ int alpha, int beta, int8_t *tc0);
+#define LF_IFUNC(DIR, TYPE, OPT) \
+void ff_x264_deblock_ ## DIR ## _ ## TYPE ## _ ## OPT (uint8_t *pix, int stride, \
+ int alpha, int beta);
-#define H264_CHROMA_OP(S,D) "pavgb " #S ", " #D " \n\t"
-#define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\
- "pavgb " #T ", " #D " \n\t"
-#define H264_CHROMA_MC8_TMPL avg_h264_chroma_generic_mc8_mmx2
-#define H264_CHROMA_MC4_TMPL avg_h264_chroma_generic_mc4_mmx2
-#define H264_CHROMA_MC2_TMPL avg_h264_chroma_mc2_mmx2
-#define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2
-#include "dsputil_h264_template_mmx.c"
-static void avg_h264_chroma_mc8_mmx2_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc8_mmx2(dst, src, stride, h, x, y, h264_rnd_reg);
-}
-static void avg_vc1_chroma_mc8_mmx2_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc8_mmx2(dst, src, stride, h, x, y, h264_rnd_reg+2);
-}
-static void avg_h264_chroma_mc4_mmx2(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc4_mmx2(dst, src, stride, h, x, y, h264_rnd_reg);
-}
-#undef H264_CHROMA_OP
-#undef H264_CHROMA_OP4
-#undef H264_CHROMA_MC8_TMPL
-#undef H264_CHROMA_MC4_TMPL
-#undef H264_CHROMA_MC2_TMPL
-#undef H264_CHROMA_MC8_MV0
+LF_FUNC (h, chroma, mmxext)
+LF_IFUNC(h, chroma_intra, mmxext)
+LF_FUNC (v, chroma, mmxext)
+LF_IFUNC(v, chroma_intra, mmxext)
-#define H264_CHROMA_OP(S,D) "pavgusb " #S ", " #D " \n\t"
-#define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\
- "pavgusb " #T ", " #D " \n\t"
-#define H264_CHROMA_MC8_TMPL avg_h264_chroma_generic_mc8_3dnow
-#define H264_CHROMA_MC4_TMPL avg_h264_chroma_generic_mc4_3dnow
-#define H264_CHROMA_MC8_MV0 avg_pixels8_3dnow
-#include "dsputil_h264_template_mmx.c"
-static void avg_h264_chroma_mc8_3dnow_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc8_3dnow(dst, src, stride, h, x, y, h264_rnd_reg);
-}
-static void avg_h264_chroma_mc4_3dnow(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+LF_FUNC (h, luma, mmxext)
+LF_IFUNC(h, luma_intra, mmxext)
+#if HAVE_YASM && ARCH_X86_32
+LF_FUNC (v8, luma, mmxext)
+static void ff_x264_deblock_v_luma_mmxext(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
{
- avg_h264_chroma_generic_mc4_3dnow(dst, src, stride, h, x, y, h264_rnd_reg);
-}
-#undef H264_CHROMA_OP
-#undef H264_CHROMA_OP4
-#undef H264_CHROMA_MC8_TMPL
-#undef H264_CHROMA_MC4_TMPL
-#undef H264_CHROMA_MC8_MV0
-
-#if HAVE_SSSE3
-#define AVG_OP(X)
-#undef H264_CHROMA_MC8_TMPL
-#undef H264_CHROMA_MC4_TMPL
-#define H264_CHROMA_MC8_TMPL put_h264_chroma_mc8_ssse3
-#define H264_CHROMA_MC4_TMPL put_h264_chroma_mc4_ssse3
-#define H264_CHROMA_MC8_MV0 put_pixels8_mmx
-#include "dsputil_h264_template_ssse3.c"
-static void put_h264_chroma_mc8_ssse3_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 1);
-}
-static void put_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 0);
-}
-
-#undef AVG_OP
-#undef H264_CHROMA_MC8_TMPL
-#undef H264_CHROMA_MC4_TMPL
-#undef H264_CHROMA_MC8_MV0
-#define AVG_OP(X) X
-#define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_ssse3
-#define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_ssse3
-#define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2
-#include "dsputil_h264_template_ssse3.c"
-static void avg_h264_chroma_mc8_ssse3_rnd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 1);
+ if((tc0[0] & tc0[1]) >= 0)
+ ff_x264_deblock_v8_luma_mmxext(pix+0, stride, alpha, beta, tc0);
+ if((tc0[2] & tc0[3]) >= 0)
+ ff_x264_deblock_v8_luma_mmxext(pix+8, stride, alpha, beta, tc0+2);
}
-static void avg_vc1_chroma_mc8_ssse3_nornd(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
+LF_IFUNC(v8, luma_intra, mmxext)
+static void ff_x264_deblock_v_luma_intra_mmxext(uint8_t *pix, int stride, int alpha, int beta)
{
- avg_h264_chroma_mc8_ssse3(dst, src, stride, h, x, y, 0);
+ ff_x264_deblock_v8_luma_intra_mmxext(pix+0, stride, alpha, beta);
+ ff_x264_deblock_v8_luma_intra_mmxext(pix+8, stride, alpha, beta);
}
-#undef AVG_OP
-#undef H264_CHROMA_MC8_TMPL
-#undef H264_CHROMA_MC4_TMPL
-#undef H264_CHROMA_MC8_MV0
#endif
+LF_FUNC (h, luma, sse2)
+LF_IFUNC(h, luma_intra, sse2)
+LF_FUNC (v, luma, sse2)
+LF_IFUNC(v, luma_intra, sse2)
+
/***********************************/
/* weighted prediction */
-static inline void ff_h264_weight_WxH_mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset, int w, int h)
+#define H264_WEIGHT(W, H, OPT) \
+void ff_h264_weight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \
+ int stride, int log2_denom, int weight, int offset);
+
+#define H264_BIWEIGHT(W, H, OPT) \
+void ff_h264_biweight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \
+ uint8_t *src, int stride, int log2_denom, int weightd, \
+ int weights, int offset);
+
+#define H264_BIWEIGHT_MMX(W,H) \
+H264_WEIGHT (W, H, mmx2) \
+H264_BIWEIGHT(W, H, mmx2)
+
+#define H264_BIWEIGHT_MMX_SSE(W,H) \
+H264_BIWEIGHT_MMX(W, H) \
+H264_WEIGHT (W, H, sse2) \
+H264_BIWEIGHT (W, H, sse2) \
+H264_BIWEIGHT (W, H, ssse3)
+
+H264_BIWEIGHT_MMX_SSE(16, 16)
+H264_BIWEIGHT_MMX_SSE(16, 8)
+H264_BIWEIGHT_MMX_SSE( 8, 16)
+H264_BIWEIGHT_MMX_SSE( 8, 8)
+H264_BIWEIGHT_MMX_SSE( 8, 4)
+H264_BIWEIGHT_MMX ( 4, 8)
+H264_BIWEIGHT_MMX ( 4, 4)
+H264_BIWEIGHT_MMX ( 4, 2)
+
+void ff_h264dsp_init_x86(H264DSPContext *c)
{
- int x, y;
- offset <<= log2_denom;
- offset += (1 << log2_denom) >> 1;
- __asm__ volatile(
- "movd %0, %%mm4 \n\t"
- "movd %1, %%mm5 \n\t"
- "movd %2, %%mm6 \n\t"
- "pshufw $0, %%mm4, %%mm4 \n\t"
- "pshufw $0, %%mm5, %%mm5 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- :: "g"(weight), "g"(offset), "g"(log2_denom)
- );
- for(y=0; y<h; y+=2){
- for(x=0; x<w; x+=4){
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "movd %1, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "pmullw %%mm4, %%mm0 \n\t"
- "pmullw %%mm4, %%mm1 \n\t"
- "paddsw %%mm5, %%mm0 \n\t"
- "paddsw %%mm5, %%mm1 \n\t"
- "psraw %%mm6, %%mm0 \n\t"
- "psraw %%mm6, %%mm1 \n\t"
- "packuswb %%mm7, %%mm0 \n\t"
- "packuswb %%mm7, %%mm1 \n\t"
- "movd %%mm0, %0 \n\t"
- "movd %%mm1, %1 \n\t"
- : "+m"(*(uint32_t*)(dst+x)),
- "+m"(*(uint32_t*)(dst+x+stride))
- );
- }
- dst += 2*stride;
- }
-}
+ int mm_flags = av_get_cpu_flags();
-static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset, int w, int h)
-{
- int x, y;
- offset = ((offset + 1) | 1) << log2_denom;
- __asm__ volatile(
- "movd %0, %%mm3 \n\t"
- "movd %1, %%mm4 \n\t"
- "movd %2, %%mm5 \n\t"
- "movd %3, %%mm6 \n\t"
- "pshufw $0, %%mm3, %%mm3 \n\t"
- "pshufw $0, %%mm4, %%mm4 \n\t"
- "pshufw $0, %%mm5, %%mm5 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- :: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1)
- );
- for(y=0; y<h; y++){
- for(x=0; x<w; x+=4){
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "movd %1, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "pmullw %%mm3, %%mm0 \n\t"
- "pmullw %%mm4, %%mm1 \n\t"
- "paddsw %%mm1, %%mm0 \n\t"
- "paddsw %%mm5, %%mm0 \n\t"
- "psraw %%mm6, %%mm0 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "movd %%mm0, %0 \n\t"
- : "+m"(*(uint32_t*)(dst+x))
- : "m"(*(uint32_t*)(src+x))
- );
- }
- src += stride;
- dst += stride;
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
+ c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
}
-}
-
-#define H264_WEIGHT(W,H) \
-static void ff_h264_biweight_ ## W ## x ## H ## _mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset){ \
- ff_h264_biweight_WxH_mmx2(dst, src, stride, log2_denom, weightd, weights, offset, W, H); \
-} \
-static void ff_h264_weight_ ## W ## x ## H ## _mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset){ \
- ff_h264_weight_WxH_mmx2(dst, stride, log2_denom, weight, offset, W, H); \
-}
-
-H264_WEIGHT(16,16)
-H264_WEIGHT(16, 8)
-H264_WEIGHT( 8,16)
-H264_WEIGHT( 8, 8)
-H264_WEIGHT( 8, 4)
-H264_WEIGHT( 4, 8)
-H264_WEIGHT( 4, 4)
-H264_WEIGHT( 4, 2)
-
-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 & AV_CPU_FLAG_MMX) {
+ c->h264_idct_dc_add=
+ c->h264_idct_add= ff_h264_idct_add_mmx;
+ c->h264_idct8_dc_add=
+ c->h264_idct8_add= ff_h264_idct8_add_mmx;
+
+ c->h264_idct_add16 = ff_h264_idct_add16_mmx;
+ c->h264_idct8_add4 = ff_h264_idct8_add4_mmx;
+ c->h264_idct_add8 = ff_h264_idct_add8_mmx;
+ c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
+ c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx;
+
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
+ c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
+ c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
+ c->h264_idct_add16 = ff_h264_idct_add16_mmx2;
+ c->h264_idct8_add4 = ff_h264_idct8_add4_mmx2;
+ c->h264_idct_add8 = ff_h264_idct_add8_mmx2;
+ c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2;
+
+ c->h264_v_loop_filter_chroma= ff_x264_deblock_v_chroma_mmxext;
+ c->h264_h_loop_filter_chroma= ff_x264_deblock_h_chroma_mmxext;
+ c->h264_v_loop_filter_chroma_intra= ff_x264_deblock_v_chroma_intra_mmxext;
+ c->h264_h_loop_filter_chroma_intra= ff_x264_deblock_h_chroma_intra_mmxext;
+#if ARCH_X86_32
+ c->h264_v_loop_filter_luma= ff_x264_deblock_v_luma_mmxext;
+ c->h264_h_loop_filter_luma= ff_x264_deblock_h_luma_mmxext;
+ c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_mmxext;
+ c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_mmxext;
+#endif
+ c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
+ c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
+ c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
+ c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
+ c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
+ c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
+ c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
+ c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
+
+ c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
+ c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
+ c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
+ c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
+ c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
+ c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
+ c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
+ c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
+
+ if (mm_flags&AV_CPU_FLAG_SSE2) {
+ c->h264_idct8_add = ff_h264_idct8_add_sse2;
+ c->h264_idct8_add4= ff_h264_idct8_add4_sse2;
+ c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2;
+
+ c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_sse2;
+ c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_sse2;
+ c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_sse2;
+ c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_sse2;
+ c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_sse2;
+
+ c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_sse2;
+ c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_sse2;
+ c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_sse2;
+ c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_sse2;
+ c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_sse2;
+
+#if HAVE_ALIGNED_STACK
+ c->h264_v_loop_filter_luma = ff_x264_deblock_v_luma_sse2;
+ c->h264_h_loop_filter_luma = ff_x264_deblock_h_luma_sse2;
+ c->h264_v_loop_filter_luma_intra = ff_x264_deblock_v_luma_intra_sse2;
+ c->h264_h_loop_filter_luma_intra = ff_x264_deblock_h_luma_intra_sse2;
+#endif
- 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;
+ c->h264_idct_add16 = ff_h264_idct_add16_sse2;
+ c->h264_idct_add8 = ff_h264_idct_add8_sse2;
+ c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
+ }
+ if (mm_flags&AV_CPU_FLAG_SSSE3) {
+ c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
+ c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_ssse3;
+ c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_ssse3;
+ c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_ssse3;
+ c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_ssse3;
+ }
}
}
#endif
}
-#endif
diff --git a/lib/ffmpeg/libavcodec/x86/idct_mmx.c b/lib/ffmpeg/libavcodec/x86/idct_mmx.c
index d6ab04e8d2..57fa81892d 100644
--- a/lib/ffmpeg/libavcodec/x86/idct_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/idct_mmx.c
@@ -23,8 +23,8 @@
#include "libavutil/common.h"
#include "libavcodec/dsputil.h"
+#include "libavutil/x86_cpu.h"
#include "dsputil_mmx.h"
-#include "mmx.h"
#define ROW_SHIFT 11
#define COL_SHIFT 6
@@ -87,104 +87,115 @@ static inline void idct_row (int16_t * row, int offset,
static inline void mmxext_row_head (int16_t * const row, const int offset,
const int16_t * const table)
{
- movq_m2r (*(row+offset), mm2); /* mm2 = x6 x4 x2 x0 */
+ __asm__ volatile(
+ "movq (%0), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
- movq_m2r (*(row+offset+4), mm5); /* mm5 = x7 x5 x3 x1 */
- movq_r2r (mm2, mm0); /* mm0 = x6 x4 x2 x0 */
+ "movq 8(%0), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
+ "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
- movq_m2r (*table, mm3); /* mm3 = -C2 -C4 C2 C4 */
- movq_r2r (mm5, mm6); /* mm6 = x7 x5 x3 x1 */
+ "movq (%1), %%mm3 \n\t" /* mm3 = -C2 -C4 C2 C4 */
+ "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
- movq_m2r (*(table+4), mm4); /* mm4 = C6 C4 C6 C4 */
- pmaddwd_r2r (mm0, mm3); /* mm3 = -C4*x4-C2*x6 C4*x0+C2*x2 */
+ "movq 8(%1), %%mm4 \n\t" /* mm4 = C6 C4 C6 C4 */
+ "pmaddwd %%mm0, %%mm3 \n\t" /* mm3 = -C4*x4-C2*x6 C4*x0+C2*x2 */
- pshufw_r2r (mm2, mm2, 0x4e); /* mm2 = x2 x0 x6 x4 */
+ "pshufw $0x4e, %%mm2, %%mm2 \n\t" /* mm2 = x2 x0 x6 x4 */
+ :: "r" ((row+offset)), "r" (table)
+ );
}
static inline void mmxext_row (const int16_t * const table,
const int32_t * const rounder)
{
- movq_m2r (*(table+8), mm1); /* mm1 = -C5 -C1 C3 C1 */
- pmaddwd_r2r (mm2, mm4); /* mm4 = C4*x0+C6*x2 C4*x4+C6*x6 */
+ __asm__ volatile (
+ "movq 16(%0), %%mm1 \n\t" /* mm1 = -C5 -C1 C3 C1 */
+ "pmaddwd %%mm2, %%mm4 \n\t" /* mm4 = C4*x0+C6*x2 C4*x4+C6*x6 */
- pmaddwd_m2r (*(table+16), mm0); /* mm0 = C4*x4-C6*x6 C4*x0-C6*x2 */
- pshufw_r2r (mm6, mm6, 0x4e); /* mm6 = x3 x1 x7 x5 */
+ "pmaddwd 32(%0), %%mm0 \n\t" /* mm0 = C4*x4-C6*x6 C4*x0-C6*x2 */
+ "pshufw $0x4e, %%mm6, %%mm6 \n\t" /* mm6 = x3 x1 x7 x5 */
- movq_m2r (*(table+12), mm7); /* mm7 = -C7 C3 C7 C5 */
- pmaddwd_r2r (mm5, mm1); /* mm1 = -C1*x5-C5*x7 C1*x1+C3*x3 */
+ "movq 24(%0), %%mm7 \n\t" /* mm7 = -C7 C3 C7 C5 */
+ "pmaddwd %%mm5, %%mm1 \n\t" /* mm1= -C1*x5-C5*x7 C1*x1+C3*x3 */
- paddd_m2r (*rounder, mm3); /* mm3 += rounder */
- pmaddwd_r2r (mm6, mm7); /* mm7 = C3*x1-C7*x3 C5*x5+C7*x7 */
+ "paddd (%1), %%mm3 \n\t" /* mm3 += rounder */
+ "pmaddwd %%mm6, %%mm7 \n\t" /* mm7 = C3*x1-C7*x3 C5*x5+C7*x7 */
- pmaddwd_m2r (*(table+20), mm2); /* mm2 = C4*x0-C2*x2 -C4*x4+C2*x6 */
- paddd_r2r (mm4, mm3); /* mm3 = a1 a0 + rounder */
+ "pmaddwd 40(%0), %%mm2 \n\t" /* mm2= C4*x0-C2*x2 -C4*x4+C2*x6 */
+ "paddd %%mm4, %%mm3 \n\t" /* mm3 = a1 a0 + rounder */
- pmaddwd_m2r (*(table+24), mm5); /* mm5 = C3*x5-C1*x7 C5*x1-C1*x3 */
- movq_r2r (mm3, mm4); /* mm4 = a1 a0 + rounder */
+ "pmaddwd 48(%0), %%mm5 \n\t" /* mm5 = C3*x5-C1*x7 C5*x1-C1*x3 */
+ "movq %%mm3, %%mm4 \n\t" /* mm4 = a1 a0 + rounder */
- pmaddwd_m2r (*(table+28), mm6); /* mm6 = C7*x1-C5*x3 C7*x5+C3*x7 */
- paddd_r2r (mm7, mm1); /* mm1 = b1 b0 */
+ "pmaddwd 56(%0), %%mm6 \n\t" /* mm6 = C7*x1-C5*x3 C7*x5+C3*x7 */
+ "paddd %%mm7, %%mm1 \n\t" /* mm1 = b1 b0 */
- paddd_m2r (*rounder, mm0); /* mm0 += rounder */
- psubd_r2r (mm1, mm3); /* mm3 = a1-b1 a0-b0 + rounder */
+ "paddd (%1), %%mm0 \n\t" /* mm0 += rounder */
+ "psubd %%mm1, %%mm3 \n\t" /* mm3 = a1-b1 a0-b0 + rounder */
- psrad_i2r (ROW_SHIFT, mm3); /* mm3 = y6 y7 */
- paddd_r2r (mm4, mm1); /* mm1 = a1+b1 a0+b0 + rounder */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm3 \n\t" /* mm3 = y6 y7 */
+ "paddd %%mm4, %%mm1 \n\t" /* mm1 = a1+b1 a0+b0 + rounder */
- paddd_r2r (mm2, mm0); /* mm0 = a3 a2 + rounder */
- psrad_i2r (ROW_SHIFT, mm1); /* mm1 = y1 y0 */
+ "paddd %%mm2, %%mm0 \n\t" /* mm0 = a3 a2 + rounder */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm1 \n\t" /* mm1 = y1 y0 */
- paddd_r2r (mm6, mm5); /* mm5 = b3 b2 */
- movq_r2r (mm0, mm4); /* mm4 = a3 a2 + rounder */
+ "paddd %%mm6, %%mm5 \n\t" /* mm5 = b3 b2 */
+ "movq %%mm0, %%mm4 \n\t" /* mm4 = a3 a2 + rounder */
- paddd_r2r (mm5, mm0); /* mm0 = a3+b3 a2+b2 + rounder */
- psubd_r2r (mm5, mm4); /* mm4 = a3-b3 a2-b2 + rounder */
+ "paddd %%mm5, %%mm0 \n\t" /* mm0 = a3+b3 a2+b2 + rounder */
+ "psubd %%mm5, %%mm4 \n\t" /* mm4 = a3-b3 a2-b2 + rounder */
+ : : "r" (table), "r" (rounder));
}
static inline void mmxext_row_tail (int16_t * const row, const int store)
{
- psrad_i2r (ROW_SHIFT, mm0); /* mm0 = y3 y2 */
+ __asm__ volatile (
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
- psrad_i2r (ROW_SHIFT, mm4); /* mm4 = y4 y5 */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm4 \n\t" /* mm4 = y4 y5 */
- packssdw_r2r (mm0, mm1); /* mm1 = y3 y2 y1 y0 */
+ "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
- packssdw_r2r (mm3, mm4); /* mm4 = y6 y7 y4 y5 */
+ "packssdw %%mm3, %%mm4 \n\t" /* mm4 = y6 y7 y4 y5 */
- movq_r2m (mm1, *(row+store)); /* save y3 y2 y1 y0 */
- pshufw_r2r (mm4, mm4, 0xb1); /* mm4 = y7 y6 y5 y4 */
+ "movq %%mm1, (%0) \n\t" /* save y3 y2 y1 y0 */
+ "pshufw $0xb1, %%mm4, %%mm4 \n\t" /* mm4 = y7 y6 y5 y4 */
- /* slot */
+ /* slot */
- movq_r2m (mm4, *(row+store+4)); /* save y7 y6 y5 y4 */
+ "movq %%mm4, 8(%0) \n\t" /* save y7 y6 y5 y4 */
+ :: "r" (row+store)
+ );
}
static inline void mmxext_row_mid (int16_t * const row, const int store,
const int offset,
const int16_t * const table)
{
- movq_m2r (*(row+offset), mm2); /* mm2 = x6 x4 x2 x0 */
- psrad_i2r (ROW_SHIFT, mm0); /* mm0 = y3 y2 */
+ __asm__ volatile (
+ "movq (%0,%1), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
- movq_m2r (*(row+offset+4), mm5); /* mm5 = x7 x5 x3 x1 */
- psrad_i2r (ROW_SHIFT, mm4); /* mm4 = y4 y5 */
+ "movq 8(%0,%1), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm4 \n\t" /* mm4 = y4 y5 */
- packssdw_r2r (mm0, mm1); /* mm1 = y3 y2 y1 y0 */
- movq_r2r (mm5, mm6); /* mm6 = x7 x5 x3 x1 */
+ "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
+ "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
- packssdw_r2r (mm3, mm4); /* mm4 = y6 y7 y4 y5 */
- movq_r2r (mm2, mm0); /* mm0 = x6 x4 x2 x0 */
+ "packssdw %%mm3, %%mm4 \n\t" /* mm4 = y6 y7 y4 y5 */
+ "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
- movq_r2m (mm1, *(row+store)); /* save y3 y2 y1 y0 */
- pshufw_r2r (mm4, mm4, 0xb1); /* mm4 = y7 y6 y5 y4 */
+ "movq %%mm1, (%0,%2) \n\t" /* save y3 y2 y1 y0 */
+ "pshufw $0xb1, %%mm4, %%mm4\n\t" /* mm4 = y7 y6 y5 y4 */
- movq_m2r (*table, mm3); /* mm3 = -C2 -C4 C2 C4 */
- movq_r2m (mm4, *(row+store+4)); /* save y7 y6 y5 y4 */
+ "movq (%3), %%mm3 \n\t" /* mm3 = -C2 -C4 C2 C4 */
+ "movq %%mm4, 8(%0,%2) \n\t" /* save y7 y6 y5 y4 */
- pmaddwd_r2r (mm0, mm3); /* mm3 = -C4*x4-C2*x6 C4*x0+C2*x2 */
+ "pmaddwd %%mm0, %%mm3 \n\t" /* mm3= -C4*x4-C2*x6 C4*x0+C2*x2 */
- movq_m2r (*(table+4), mm4); /* mm4 = C6 C4 C6 C4 */
- pshufw_r2r (mm2, mm2, 0x4e); /* mm2 = x2 x0 x6 x4 */
+ "movq 8(%3), %%mm4 \n\t" /* mm4 = C6 C4 C6 C4 */
+ "pshufw $0x4e, %%mm2, %%mm2\n\t" /* mm2 = x2 x0 x6 x4 */
+ :: "r" (row), "r" ((x86_reg) (2*offset)), "r" ((x86_reg) (2*store)), "r" (table)
+ );
}
@@ -202,119 +213,132 @@ static inline void mmxext_row_mid (int16_t * const row, const int store,
static inline void mmx_row_head (int16_t * const row, const int offset,
const int16_t * const table)
{
- movq_m2r (*(row+offset), mm2); /* mm2 = x6 x4 x2 x0 */
+ __asm__ volatile (
+ "movq (%0), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
- movq_m2r (*(row+offset+4), mm5); /* mm5 = x7 x5 x3 x1 */
- movq_r2r (mm2, mm0); /* mm0 = x6 x4 x2 x0 */
+ "movq 8(%0), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
+ "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
- movq_m2r (*table, mm3); /* mm3 = C6 C4 C2 C4 */
- movq_r2r (mm5, mm6); /* mm6 = x7 x5 x3 x1 */
+ "movq (%1), %%mm3 \n\t" /* mm3 = C6 C4 C2 C4 */
+ "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
- punpckldq_r2r (mm0, mm0); /* mm0 = x2 x0 x2 x0 */
+ "punpckldq %%mm0, %%mm0 \n\t" /* mm0 = x2 x0 x2 x0 */
- movq_m2r (*(table+4), mm4); /* mm4 = -C2 -C4 C6 C4 */
- pmaddwd_r2r (mm0, mm3); /* mm3 = C4*x0+C6*x2 C4*x0+C2*x2 */
+ "movq 8(%1), %%mm4 \n\t" /* mm4 = -C2 -C4 C6 C4 */
+ "pmaddwd %%mm0, %%mm3 \n\t" /* mm3 = C4*x0+C6*x2 C4*x0+C2*x2 */
- movq_m2r (*(table+8), mm1); /* mm1 = -C7 C3 C3 C1 */
- punpckhdq_r2r (mm2, mm2); /* mm2 = x6 x4 x6 x4 */
+ "movq 16(%1), %%mm1 \n\t" /* mm1 = -C7 C3 C3 C1 */
+ "punpckhdq %%mm2, %%mm2 \n\t" /* mm2 = x6 x4 x6 x4 */
+ :: "r" ((row+offset)), "r" (table)
+ );
}
static inline void mmx_row (const int16_t * const table,
const int32_t * const rounder)
{
- pmaddwd_r2r (mm2, mm4); /* mm4 = -C4*x4-C2*x6 C4*x4+C6*x6 */
- punpckldq_r2r (mm5, mm5); /* mm5 = x3 x1 x3 x1 */
+ __asm__ volatile (
+ "pmaddwd %%mm2, %%mm4 \n\t" /* mm4 = -C4*x4-C2*x6 C4*x4+C6*x6 */
+ "punpckldq %%mm5, %%mm5 \n\t" /* mm5 = x3 x1 x3 x1 */
- pmaddwd_m2r (*(table+16), mm0); /* mm0 = C4*x0-C2*x2 C4*x0-C6*x2 */
- punpckhdq_r2r (mm6, mm6); /* mm6 = x7 x5 x7 x5 */
+ "pmaddwd 32(%0), %%mm0 \n\t" /* mm0 = C4*x0-C2*x2 C4*x0-C6*x2 */
+ "punpckhdq %%mm6, %%mm6 \n\t" /* mm6 = x7 x5 x7 x5 */
- movq_m2r (*(table+12), mm7); /* mm7 = -C5 -C1 C7 C5 */
- pmaddwd_r2r (mm5, mm1); /* mm1 = C3*x1-C7*x3 C1*x1+C3*x3 */
+ "movq 24(%0), %%mm7 \n\t" /* mm7 = -C5 -C1 C7 C5 */
+ "pmaddwd %%mm5, %%mm1 \n\t" /* mm1 = C3*x1-C7*x3 C1*x1+C3*x3 */
- paddd_m2r (*rounder, mm3); /* mm3 += rounder */
- pmaddwd_r2r (mm6, mm7); /* mm7 = -C1*x5-C5*x7 C5*x5+C7*x7 */
+ "paddd (%1), %%mm3 \n\t" /* mm3 += rounder */
+ "pmaddwd %%mm6, %%mm7 \n\t" /* mm7 = -C1*x5-C5*x7 C5*x5+C7*x7 */
- pmaddwd_m2r (*(table+20), mm2); /* mm2 = C4*x4-C6*x6 -C4*x4+C2*x6 */
- paddd_r2r (mm4, mm3); /* mm3 = a1 a0 + rounder */
+ "pmaddwd 40(%0), %%mm2 \n\t" /* mm2 = C4*x4-C6*x6 -C4*x4+C2*x6 */
+ "paddd %%mm4, %%mm3 \n\t" /* mm3 = a1 a0 + rounder */
- pmaddwd_m2r (*(table+24), mm5); /* mm5 = C7*x1-C5*x3 C5*x1-C1*x3 */
- movq_r2r (mm3, mm4); /* mm4 = a1 a0 + rounder */
+ "pmaddwd 48(%0), %%mm5 \n\t" /* mm5 = C7*x1-C5*x3 C5*x1-C1*x3 */
+ "movq %%mm3, %%mm4 \n\t" /* mm4 = a1 a0 + rounder */
- pmaddwd_m2r (*(table+28), mm6); /* mm6 = C3*x5-C1*x7 C7*x5+C3*x7 */
- paddd_r2r (mm7, mm1); /* mm1 = b1 b0 */
+ "pmaddwd 56(%0), %%mm6 \n\t" /* mm6 = C3*x5-C1*x7 C7*x5+C3*x7 */
+ "paddd %%mm7, %%mm1 \n\t" /* mm1 = b1 b0 */
- paddd_m2r (*rounder, mm0); /* mm0 += rounder */
- psubd_r2r (mm1, mm3); /* mm3 = a1-b1 a0-b0 + rounder */
+ "paddd (%1), %%mm0 \n\t" /* mm0 += rounder */
+ "psubd %%mm1, %%mm3 \n\t" /* mm3 = a1-b1 a0-b0 + rounder */
- psrad_i2r (ROW_SHIFT, mm3); /* mm3 = y6 y7 */
- paddd_r2r (mm4, mm1); /* mm1 = a1+b1 a0+b0 + rounder */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm3 \n\t" /* mm3 = y6 y7 */
+ "paddd %%mm4, %%mm1 \n\t" /* mm1 = a1+b1 a0+b0 + rounder */
- paddd_r2r (mm2, mm0); /* mm0 = a3 a2 + rounder */
- psrad_i2r (ROW_SHIFT, mm1); /* mm1 = y1 y0 */
+ "paddd %%mm2, %%mm0 \n\t" /* mm0 = a3 a2 + rounder */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm1 \n\t" /* mm1 = y1 y0 */
- paddd_r2r (mm6, mm5); /* mm5 = b3 b2 */
- movq_r2r (mm0, mm7); /* mm7 = a3 a2 + rounder */
+ "paddd %%mm6, %%mm5 \n\t" /* mm5 = b3 b2 */
+ "movq %%mm0, %%mm7 \n\t" /* mm7 = a3 a2 + rounder */
- paddd_r2r (mm5, mm0); /* mm0 = a3+b3 a2+b2 + rounder */
- psubd_r2r (mm5, mm7); /* mm7 = a3-b3 a2-b2 + rounder */
+ "paddd %%mm5, %%mm0 \n\t" /* mm0 = a3+b3 a2+b2 + rounder */
+ "psubd %%mm5, %%mm7 \n\t" /* mm7 = a3-b3 a2-b2 + rounder */
+ :: "r" (table), "r" (rounder)
+ );
}
static inline void mmx_row_tail (int16_t * const row, const int store)
{
- psrad_i2r (ROW_SHIFT, mm0); /* mm0 = y3 y2 */
+ __asm__ volatile (
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
- psrad_i2r (ROW_SHIFT, mm7); /* mm7 = y4 y5 */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm7 \n\t" /* mm7 = y4 y5 */
- packssdw_r2r (mm0, mm1); /* mm1 = y3 y2 y1 y0 */
+ "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
- packssdw_r2r (mm3, mm7); /* mm7 = y6 y7 y4 y5 */
+ "packssdw %%mm3, %%mm7 \n\t" /* mm7 = y6 y7 y4 y5 */
- movq_r2m (mm1, *(row+store)); /* save y3 y2 y1 y0 */
- movq_r2r (mm7, mm4); /* mm4 = y6 y7 y4 y5 */
+ "movq %%mm1, (%0) \n\t" /* save y3 y2 y1 y0 */
+ "movq %%mm7, %%mm4 \n\t" /* mm4 = y6 y7 y4 y5 */
- pslld_i2r (16, mm7); /* mm7 = y7 0 y5 0 */
+ "pslld $16, %%mm7 \n\t" /* mm7 = y7 0 y5 0 */
- psrld_i2r (16, mm4); /* mm4 = 0 y6 0 y4 */
+ "psrld $16, %%mm4 \n\t" /* mm4 = 0 y6 0 y4 */
- por_r2r (mm4, mm7); /* mm7 = y7 y6 y5 y4 */
+ "por %%mm4, %%mm7 \n\t" /* mm7 = y7 y6 y5 y4 */
- /* slot */
+ /* slot */
- movq_r2m (mm7, *(row+store+4)); /* save y7 y6 y5 y4 */
+ "movq %%mm7, 8(%0) \n\t" /* save y7 y6 y5 y4 */
+ :: "r" (row+store)
+ );
}
static inline void mmx_row_mid (int16_t * const row, const int store,
const int offset, const int16_t * const table)
{
- movq_m2r (*(row+offset), mm2); /* mm2 = x6 x4 x2 x0 */
- psrad_i2r (ROW_SHIFT, mm0); /* mm0 = y3 y2 */
- movq_m2r (*(row+offset+4), mm5); /* mm5 = x7 x5 x3 x1 */
- psrad_i2r (ROW_SHIFT, mm7); /* mm7 = y4 y5 */
+ __asm__ volatile (
+ "movq (%0,%1), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
- packssdw_r2r (mm0, mm1); /* mm1 = y3 y2 y1 y0 */
- movq_r2r (mm5, mm6); /* mm6 = x7 x5 x3 x1 */
+ "movq 8(%0,%1), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
+ "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm7 \n\t" /* mm7 = y4 y5 */
- packssdw_r2r (mm3, mm7); /* mm7 = y6 y7 y4 y5 */
- movq_r2r (mm2, mm0); /* mm0 = x6 x4 x2 x0 */
+ "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
+ "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
- movq_r2m (mm1, *(row+store)); /* save y3 y2 y1 y0 */
- movq_r2r (mm7, mm1); /* mm1 = y6 y7 y4 y5 */
+ "packssdw %%mm3, %%mm7 \n\t" /* mm7 = y6 y7 y4 y5 */
+ "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
- punpckldq_r2r (mm0, mm0); /* mm0 = x2 x0 x2 x0 */
- psrld_i2r (16, mm7); /* mm7 = 0 y6 0 y4 */
+ "movq %%mm1, (%0,%2) \n\t" /* save y3 y2 y1 y0 */
+ "movq %%mm7, %%mm1 \n\t" /* mm1 = y6 y7 y4 y5 */
- movq_m2r (*table, mm3); /* mm3 = C6 C4 C2 C4 */
- pslld_i2r (16, mm1); /* mm1 = y7 0 y5 0 */
+ "punpckldq %%mm0, %%mm0 \n\t" /* mm0 = x2 x0 x2 x0 */
+ "psrld $16, %%mm7 \n\t" /* mm7 = 0 y6 0 y4 */
- movq_m2r (*(table+4), mm4); /* mm4 = -C2 -C4 C6 C4 */
- por_r2r (mm1, mm7); /* mm7 = y7 y6 y5 y4 */
+ "movq (%3), %%mm3 \n\t" /* mm3 = C6 C4 C2 C4 */
+ "pslld $16, %%mm1 \n\t" /* mm1 = y7 0 y5 0 */
- movq_m2r (*(table+8), mm1); /* mm1 = -C7 C3 C3 C1 */
- punpckhdq_r2r (mm2, mm2); /* mm2 = x6 x4 x6 x4 */
+ "movq 8(%3), %%mm4 \n\t" /* mm4 = -C2 -C4 C6 C4 */
+ "por %%mm1, %%mm7 \n\t" /* mm7 = y7 y6 y5 y4 */
- movq_r2m (mm7, *(row+store+4)); /* save y7 y6 y5 y4 */
- pmaddwd_r2r (mm0, mm3); /* mm3 = C4*x0+C6*x2 C4*x0+C2*x2 */
+ "movq 16(%3), %%mm1 \n\t" /* mm1 = -C7 C3 C3 C1 */
+ "punpckhdq %%mm2, %%mm2 \n\t" /* mm2 = x6 x4 x6 x4 */
+
+ "movq %%mm7, 8(%0,%2) \n\t" /* save y7 y6 y5 y4 */
+ "pmaddwd %%mm0, %%mm3 \n\t" /* mm3 = C4*x0+C6*x2 C4*x0+C2*x2 */
+ : : "r" (row), "r" ((x86_reg) (2*offset)), "r" ((x86_reg) (2*store)), "r" (table)
+ );
}
@@ -398,140 +422,145 @@ static inline void idct_col (int16_t * const col, const int offset)
#define T3 43790
#define C4 23170
- DECLARE_ALIGNED(8, static const short, t1_vector)[] = {T1,T1,T1,T1};
- DECLARE_ALIGNED(8, static const short, t2_vector)[] = {T2,T2,T2,T2};
- DECLARE_ALIGNED(8, static const short, t3_vector)[] = {T3,T3,T3,T3};
- DECLARE_ALIGNED(8, static const short, c4_vector)[] = {C4,C4,C4,C4};
+ DECLARE_ALIGNED(8, static const short, t1_vector)[] = {
+ T1,T1,T1,T1,
+ T2,T2,T2,T2,
+ T3,T3,T3,T3,
+ C4,C4,C4,C4
+ };
/* column code adapted from Peter Gubanov */
/* http://www.elecard.com/peter/idct.shtml */
- movq_m2r (*t1_vector, mm0); /* mm0 = T1 */
+ __asm__ volatile (
+ "movq (%0), %%mm0 \n\t" /* mm0 = T1 */
- movq_m2r (*(col+offset+1*8), mm1); /* mm1 = x1 */
- movq_r2r (mm0, mm2); /* mm2 = T1 */
+ "movq 2*8(%1), %%mm1 \n\t" /* mm1 = x1 */
+ "movq %%mm0, %%mm2 \n\t" /* mm2 = T1 */
- movq_m2r (*(col+offset+7*8), mm4); /* mm4 = x7 */
- pmulhw_r2r (mm1, mm0); /* mm0 = T1*x1 */
+ "movq 7*2*8(%1), %%mm4 \n\t" /* mm4 = x7 */
+ "pmulhw %%mm1, %%mm0 \n\t" /* mm0 = T1*x1 */
- movq_m2r (*t3_vector, mm5); /* mm5 = T3 */
- pmulhw_r2r (mm4, mm2); /* mm2 = T1*x7 */
+ "movq 16(%0), %%mm5 \n\t" /* mm5 = T3 */
+ "pmulhw %%mm4, %%mm2 \n\t" /* mm2 = T1*x7 */
- movq_m2r (*(col+offset+5*8), mm6); /* mm6 = x5 */
- movq_r2r (mm5, mm7); /* mm7 = T3-1 */
+ "movq 2*5*8(%1), %%mm6 \n\t" /* mm6 = x5 */
+ "movq %%mm5, %%mm7 \n\t" /* mm7 = T3-1 */
- movq_m2r (*(col+offset+3*8), mm3); /* mm3 = x3 */
- psubsw_r2r (mm4, mm0); /* mm0 = v17 */
+ "movq 3*8*2(%1), %%mm3 \n\t" /* mm3 = x3 */
+ "psubsw %%mm4, %%mm0 \n\t" /* mm0 = v17 */
- movq_m2r (*t2_vector, mm4); /* mm4 = T2 */
- pmulhw_r2r (mm3, mm5); /* mm5 = (T3-1)*x3 */
+ "movq 8(%0), %%mm4 \n\t" /* mm4 = T2 */
+ "pmulhw %%mm3, %%mm5 \n\t" /* mm5 = (T3-1)*x3 */
- paddsw_r2r (mm2, mm1); /* mm1 = u17 */
- pmulhw_r2r (mm6, mm7); /* mm7 = (T3-1)*x5 */
+ "paddsw %%mm2, %%mm1 \n\t" /* mm1 = u17 */
+ "pmulhw %%mm6, %%mm7 \n\t" /* mm7 = (T3-1)*x5 */
- /* slot */
+ /* slot */
- movq_r2r (mm4, mm2); /* mm2 = T2 */
- paddsw_r2r (mm3, mm5); /* mm5 = T3*x3 */
+ "movq %%mm4, %%mm2 \n\t" /* mm2 = T2 */
+ "paddsw %%mm3, %%mm5 \n\t" /* mm5 = T3*x3 */
- pmulhw_m2r (*(col+offset+2*8), mm4);/* mm4 = T2*x2 */
- paddsw_r2r (mm6, mm7); /* mm7 = T3*x5 */
+ "pmulhw 2*8*2(%1), %%mm4 \n\t" /* mm4 = T2*x2 */
+ "paddsw %%mm6, %%mm7 \n\t" /* mm7 = T3*x5 */
- psubsw_r2r (mm6, mm5); /* mm5 = v35 */
- paddsw_r2r (mm3, mm7); /* mm7 = u35 */
+ "psubsw %%mm6, %%mm5 \n\t" /* mm5 = v35 */
+ "paddsw %%mm3, %%mm7 \n\t" /* mm7 = u35 */
- movq_m2r (*(col+offset+6*8), mm3); /* mm3 = x6 */
- movq_r2r (mm0, mm6); /* mm6 = v17 */
+ "movq 6*8*2(%1), %%mm3 \n\t" /* mm3 = x6 */
+ "movq %%mm0, %%mm6 \n\t" /* mm6 = v17 */
- pmulhw_r2r (mm3, mm2); /* mm2 = T2*x6 */
- psubsw_r2r (mm5, mm0); /* mm0 = b3 */
+ "pmulhw %%mm3, %%mm2 \n\t" /* mm2 = T2*x6 */
+ "psubsw %%mm5, %%mm0 \n\t" /* mm0 = b3 */
- psubsw_r2r (mm3, mm4); /* mm4 = v26 */
- paddsw_r2r (mm6, mm5); /* mm5 = v12 */
+ "psubsw %%mm3, %%mm4 \n\t" /* mm4 = v26 */
+ "paddsw %%mm6, %%mm5 \n\t" /* mm5 = v12 */
- movq_r2m (mm0, *(col+offset+3*8)); /* save b3 in scratch0 */
- movq_r2r (mm1, mm6); /* mm6 = u17 */
+ "movq %%mm0, 3*8*2(%1)\n\t" /* save b3 in scratch0 */
+ "movq %%mm1, %%mm6 \n\t" /* mm6 = u17 */
- paddsw_m2r (*(col+offset+2*8), mm2);/* mm2 = u26 */
- paddsw_r2r (mm7, mm6); /* mm6 = b0 */
+ "paddsw 2*8*2(%1), %%mm2 \n\t" /* mm2 = u26 */
+ "paddsw %%mm7, %%mm6 \n\t" /* mm6 = b0 */
- psubsw_r2r (mm7, mm1); /* mm1 = u12 */
- movq_r2r (mm1, mm7); /* mm7 = u12 */
+ "psubsw %%mm7, %%mm1 \n\t" /* mm1 = u12 */
+ "movq %%mm1, %%mm7 \n\t" /* mm7 = u12 */
- movq_m2r (*(col+offset+0*8), mm3); /* mm3 = x0 */
- paddsw_r2r (mm5, mm1); /* mm1 = u12+v12 */
+ "movq 0*8(%1), %%mm3 \n\t" /* mm3 = x0 */
+ "paddsw %%mm5, %%mm1 \n\t" /* mm1 = u12+v12 */
- movq_m2r (*c4_vector, mm0); /* mm0 = C4/2 */
- psubsw_r2r (mm5, mm7); /* mm7 = u12-v12 */
+ "movq 24(%0), %%mm0 \n\t" /* mm0 = C4/2 */
+ "psubsw %%mm5, %%mm7 \n\t" /* mm7 = u12-v12 */
- movq_r2m (mm6, *(col+offset+5*8)); /* save b0 in scratch1 */
- pmulhw_r2r (mm0, mm1); /* mm1 = b1/2 */
+ "movq %%mm6, 5*8*2(%1)\n\t" /* save b0 in scratch1 */
+ "pmulhw %%mm0, %%mm1 \n\t" /* mm1 = b1/2 */
- movq_r2r (mm4, mm6); /* mm6 = v26 */
- pmulhw_r2r (mm0, mm7); /* mm7 = b2/2 */
+ "movq %%mm4, %%mm6 \n\t" /* mm6 = v26 */
+ "pmulhw %%mm0, %%mm7 \n\t" /* mm7 = b2/2 */
- movq_m2r (*(col+offset+4*8), mm5); /* mm5 = x4 */
- movq_r2r (mm3, mm0); /* mm0 = x0 */
+ "movq 4*8*2(%1), %%mm5 \n\t" /* mm5 = x4 */
+ "movq %%mm3, %%mm0 \n\t" /* mm0 = x0 */
- psubsw_r2r (mm5, mm3); /* mm3 = v04 */
- paddsw_r2r (mm5, mm0); /* mm0 = u04 */
+ "psubsw %%mm5, %%mm3 \n\t" /* mm3 = v04 */
+ "paddsw %%mm5, %%mm0 \n\t" /* mm0 = u04 */
- paddsw_r2r (mm3, mm4); /* mm4 = a1 */
- movq_r2r (mm0, mm5); /* mm5 = u04 */
+ "paddsw %%mm3, %%mm4 \n\t" /* mm4 = a1 */
+ "movq %%mm0, %%mm5 \n\t" /* mm5 = u04 */
- psubsw_r2r (mm6, mm3); /* mm3 = a2 */
- paddsw_r2r (mm2, mm5); /* mm5 = a0 */
+ "psubsw %%mm6, %%mm3 \n\t" /* mm3 = a2 */
+ "paddsw %%mm2, %%mm5 \n\t" /* mm5 = a0 */
- paddsw_r2r (mm1, mm1); /* mm1 = b1 */
- psubsw_r2r (mm2, mm0); /* mm0 = a3 */
+ "paddsw %%mm1, %%mm1 \n\t" /* mm1 = b1 */
+ "psubsw %%mm2, %%mm0 \n\t" /* mm0 = a3 */
- paddsw_r2r (mm7, mm7); /* mm7 = b2 */
- movq_r2r (mm3, mm2); /* mm2 = a2 */
+ "paddsw %%mm7, %%mm7 \n\t" /* mm7 = b2 */
+ "movq %%mm3, %%mm2 \n\t" /* mm2 = a2 */
- movq_r2r (mm4, mm6); /* mm6 = a1 */
- paddsw_r2r (mm7, mm3); /* mm3 = a2+b2 */
+ "movq %%mm4, %%mm6 \n\t" /* mm6 = a1 */
+ "paddsw %%mm7, %%mm3 \n\t" /* mm3 = a2+b2 */
- psraw_i2r (COL_SHIFT, mm3); /* mm3 = y2 */
- paddsw_r2r (mm1, mm4); /* mm4 = a1+b1 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm3\n\t" /* mm3 = y2 */
+ "paddsw %%mm1, %%mm4\n\t" /* mm4 = a1+b1 */
- psraw_i2r (COL_SHIFT, mm4); /* mm4 = y1 */
- psubsw_r2r (mm1, mm6); /* mm6 = a1-b1 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm4\n\t" /* mm4 = y1 */
+ "psubsw %%mm1, %%mm6 \n\t" /* mm6 = a1-b1 */
- movq_m2r (*(col+offset+5*8), mm1); /* mm1 = b0 */
- psubsw_r2r (mm7, mm2); /* mm2 = a2-b2 */
+ "movq 5*8*2(%1), %%mm1 \n\t" /* mm1 = b0 */
+ "psubsw %%mm7, %%mm2 \n\t" /* mm2 = a2-b2 */
- psraw_i2r (COL_SHIFT, mm6); /* mm6 = y6 */
- movq_r2r (mm5, mm7); /* mm7 = a0 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm6\n\t" /* mm6 = y6 */
+ "movq %%mm5, %%mm7 \n\t" /* mm7 = a0 */
- movq_r2m (mm4, *(col+offset+1*8)); /* save y1 */
- psraw_i2r (COL_SHIFT, mm2); /* mm2 = y5 */
+ "movq %%mm4, 1*8*2(%1)\n\t" /* save y1 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm2\n\t" /* mm2 = y5 */
- movq_r2m (mm3, *(col+offset+2*8)); /* save y2 */
- paddsw_r2r (mm1, mm5); /* mm5 = a0+b0 */
+ "movq %%mm3, 2*8*2(%1)\n\t" /* save y2 */
+ "paddsw %%mm1, %%mm5 \n\t" /* mm5 = a0+b0 */
- movq_m2r (*(col+offset+3*8), mm4); /* mm4 = b3 */
- psubsw_r2r (mm1, mm7); /* mm7 = a0-b0 */
+ "movq 3*8*2(%1), %%mm4 \n\t" /* mm4 = b3 */
+ "psubsw %%mm1, %%mm7 \n\t" /* mm7 = a0-b0 */
- psraw_i2r (COL_SHIFT, mm5); /* mm5 = y0 */
- movq_r2r (mm0, mm3); /* mm3 = a3 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm5\n\t" /* mm5 = y0 */
+ "movq %%mm0, %%mm3 \n\t" /* mm3 = a3 */
- movq_r2m (mm2, *(col+offset+5*8)); /* save y5 */
- psubsw_r2r (mm4, mm3); /* mm3 = a3-b3 */
+ "movq %%mm2, 5*8*2(%1)\n\t" /* save y5 */
+ "psubsw %%mm4, %%mm3 \n\t" /* mm3 = a3-b3 */
- psraw_i2r (COL_SHIFT, mm7); /* mm7 = y7 */
- paddsw_r2r (mm0, mm4); /* mm4 = a3+b3 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm7\n\t" /* mm7 = y7 */
+ "paddsw %%mm0, %%mm4 \n\t" /* mm4 = a3+b3 */
- movq_r2m (mm5, *(col+offset+0*8)); /* save y0 */
- psraw_i2r (COL_SHIFT, mm3); /* mm3 = y4 */
+ "movq %%mm5, 0*8*2(%1)\n\t" /* save y0 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm3\n\t" /* mm3 = y4 */
- movq_r2m (mm6, *(col+offset+6*8)); /* save y6 */
- psraw_i2r (COL_SHIFT, mm4); /* mm4 = y3 */
+ "movq %%mm6, 6*8*2(%1)\n\t" /* save y6 */
+ "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm4\n\t" /* mm4 = y3 */
- movq_r2m (mm7, *(col+offset+7*8)); /* save y7 */
+ "movq %%mm7, 7*8*2(%1)\n\t" /* save y7 */
- movq_r2m (mm3, *(col+offset+4*8)); /* save y4 */
+ "movq %%mm3, 4*8*2(%1)\n\t" /* save y4 */
- movq_r2m (mm4, *(col+offset+3*8)); /* save y3 */
+ "movq %%mm4, 3*8*2(%1)\n\t" /* save y3 */
+ :: "r" (t1_vector), "r" (col+offset)
+ );
#undef T1
#undef T2
diff --git a/lib/ffmpeg/libavcodec/x86/idct_sse2_xvid.c b/lib/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
index fc670e25d4..5185d61e54 100644
--- a/lib/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
+++ b/lib/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
@@ -39,6 +39,7 @@
*/
#include "libavcodec/dsputil.h"
+#include "libavutil/x86_cpu.h"
#include "idct_xvid.h"
#include "dsputil_mmx.h"
@@ -355,7 +356,7 @@ inline void ff_idct_xvid_sse2(short *block)
TEST_TWO_ROWS("5*16(%0)", "6*16(%0)", "%%eax", "%%edx", CLEAR_ODD(ROW5), CLEAR_EVEN(ROW6))
TEST_ONE_ROW("7*16(%0)", "%%esi", CLEAR_ODD(ROW7))
iLLM_HEAD
- ASMALIGN(4)
+ ".p2align 4 \n\t"
JNZ("%%ecx", "2f")
JNZ("%%eax", "3f")
JNZ("%%edx", "4f")
@@ -379,17 +380,24 @@ inline void ff_idct_xvid_sse2(short *block)
"6: \n\t"
: "+r"(block)
:
- : "%eax", "%ecx", "%edx", "%esi", "memory");
+ : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" ,
+ "%xmm4" , "%xmm5" , "%xmm6" , "%xmm7" ,)
+#if ARCH_X86_64
+ XMM_CLOBBERS("%xmm8" , "%xmm9" , "%xmm10", "%xmm11",
+ "%xmm12", "%xmm13", "%xmm14",)
+#endif
+ "%eax", "%ecx", "%edx", "%esi", "memory"
+ );
}
void ff_idct_xvid_sse2_put(uint8_t *dest, int line_size, short *block)
{
ff_idct_xvid_sse2(block);
- put_pixels_clamped_mmx(block, dest, line_size);
+ ff_put_pixels_clamped_mmx(block, dest, line_size);
}
void ff_idct_xvid_sse2_add(uint8_t *dest, int line_size, short *block)
{
ff_idct_xvid_sse2(block);
- add_pixels_clamped_mmx(block, dest, line_size);
+ ff_add_pixels_clamped_mmx(block, dest, line_size);
}
diff --git a/lib/ffmpeg/libavcodec/x86/lpc_mmx.c b/lib/ffmpeg/libavcodec/x86/lpc_mmx.c
index 2ef5fa6de3..1c202e2ccc 100644
--- a/lib/ffmpeg/libavcodec/x86/lpc_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/lpc_mmx.c
@@ -20,25 +20,26 @@
*/
#include "libavutil/x86_cpu.h"
-#include "dsputil_mmx.h"
+#include "libavutil/cpu.h"
+#include "libavcodec/lpc.h"
-static void apply_welch_window_sse2(const int32_t *data, int len, double *w_data)
+static void lpc_apply_welch_window_sse2(const int32_t *data, int len,
+ double *w_data)
{
double c = 2.0 / (len-1.0);
int n2 = len>>1;
x86_reg i = -n2*sizeof(int32_t);
x86_reg j = n2*sizeof(int32_t);
__asm__ volatile(
- "movsd %0, %%xmm7 \n\t"
+ "movsd %4, %%xmm7 \n\t"
"movapd "MANGLE(ff_pd_1)", %%xmm6 \n\t"
"movapd "MANGLE(ff_pd_2)", %%xmm5 \n\t"
"movlhps %%xmm7, %%xmm7 \n\t"
"subpd %%xmm5, %%xmm7 \n\t"
"addsd %%xmm6, %%xmm7 \n\t"
- ::"m"(c)
- );
+ "test $1, %5 \n\t"
+ "jz 2f \n\t"
#define WELCH(MOVPD, offset)\
- __asm__ volatile(\
"1: \n\t"\
"movapd %%xmm7, %%xmm1 \n\t"\
"mulpd %%xmm1, %%xmm1 \n\t"\
@@ -55,31 +56,27 @@ static void apply_welch_window_sse2(const int32_t *data, int len, double *w_data
"sub $8, %1 \n\t"\
"add $8, %0 \n\t"\
"jl 1b \n\t"\
- :"+&r"(i), "+&r"(j)\
- :"r"(w_data+n2), "r"(data+n2)\
- );
- if(len&1)
+
WELCH("movupd", -1)
- else
+ "jmp 3f \n\t"
+ "2: \n\t"
WELCH("movapd", -2)
+ "3: \n\t"
+ :"+&r"(i), "+&r"(j)
+ :"r"(w_data+n2), "r"(data+n2), "m"(c), "r"(len)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm5", "%xmm6", "%xmm7")
+ );
#undef WELCH
}
-void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
- double *autoc)
+static void lpc_compute_autocorr_sse2(const double *data, int len, int lag,
+ double *autoc)
{
- double tmp[len + lag + 2];
- double *data1 = tmp + lag;
int j;
- if((x86_reg)data1 & 15)
- data1++;
-
- apply_welch_window_sse2(data, len, data1);
-
- for(j=0; j<lag; j++)
- data1[j-lag]= 0.0;
- data1[len] = 0.0;
+ if((x86_reg)data & 15)
+ data++;
for(j=0; j<lag; j+=2){
x86_reg i = -len*sizeof(double);
@@ -110,7 +107,7 @@ void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
"movsd %%xmm1, 8(%1) \n\t"
"movsd %%xmm2, 16(%1) \n\t"
:"+&r"(i)
- :"r"(autoc+j), "r"(data1+len), "r"(data1+len-j)
+ :"r"(autoc+j), "r"(data+len), "r"(data+len-j)
:"memory"
);
} else {
@@ -133,8 +130,18 @@ void ff_lpc_compute_autocorr_sse2(const int32_t *data, int len, int lag,
"movsd %%xmm0, %1 \n\t"
"movsd %%xmm1, %2 \n\t"
:"+&r"(i), "=m"(autoc[j]), "=m"(autoc[j+1])
- :"r"(data1+len), "r"(data1+len-j)
+ :"r"(data+len), "r"(data+len-j)
);
}
}
}
+
+av_cold void ff_lpc_init_x86(LPCContext *c)
+{
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
+ c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;
+ c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
+ }
+}
diff --git a/lib/ffmpeg/libavcodec/x86/mmx.h b/lib/ffmpeg/libavcodec/x86/mmx.h
deleted file mode 100644
index d7a76bbd7d..0000000000
--- a/lib/ffmpeg/libavcodec/x86/mmx.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * mmx.h
- * Copyright (C) 1997-2001 H. Dietz and R. Fisher
- *
- * 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_X86_MMX_H
-#define AVCODEC_X86_MMX_H
-
-#warning Everything in this header is deprecated, use plain __asm__()! New code using this header will be rejected.
-
-
-#define mmx_i2r(op,imm,reg) \
- __asm__ volatile (#op " %0, %%" #reg \
- : /* nothing */ \
- : "i" (imm) )
-
-#define mmx_m2r(op,mem,reg) \
- __asm__ volatile (#op " %0, %%" #reg \
- : /* nothing */ \
- : "m" (mem))
-
-#define mmx_r2m(op,reg,mem) \
- __asm__ volatile (#op " %%" #reg ", %0" \
- : "=m" (mem) \
- : /* nothing */ )
-
-#define mmx_r2r(op,regs,regd) \
- __asm__ volatile (#op " %" #regs ", %" #regd)
-
-
-#define emms() __asm__ volatile ("emms")
-
-#define movd_m2r(var,reg) mmx_m2r (movd, var, reg)
-#define movd_r2m(reg,var) mmx_r2m (movd, reg, var)
-#define movd_r2r(regs,regd) mmx_r2r (movd, regs, regd)
-
-#define movq_m2r(var,reg) mmx_m2r (movq, var, reg)
-#define movq_r2m(reg,var) mmx_r2m (movq, reg, var)
-#define movq_r2r(regs,regd) mmx_r2r (movq, regs, regd)
-
-#define packssdw_m2r(var,reg) mmx_m2r (packssdw, var, reg)
-#define packssdw_r2r(regs,regd) mmx_r2r (packssdw, regs, regd)
-#define packsswb_m2r(var,reg) mmx_m2r (packsswb, var, reg)
-#define packsswb_r2r(regs,regd) mmx_r2r (packsswb, regs, regd)
-
-#define packuswb_m2r(var,reg) mmx_m2r (packuswb, var, reg)
-#define packuswb_r2r(regs,regd) mmx_r2r (packuswb, regs, regd)
-
-#define paddb_m2r(var,reg) mmx_m2r (paddb, var, reg)
-#define paddb_r2r(regs,regd) mmx_r2r (paddb, regs, regd)
-#define paddd_m2r(var,reg) mmx_m2r (paddd, var, reg)
-#define paddd_r2r(regs,regd) mmx_r2r (paddd, regs, regd)
-#define paddw_m2r(var,reg) mmx_m2r (paddw, var, reg)
-#define paddw_r2r(regs,regd) mmx_r2r (paddw, regs, regd)
-
-#define paddsb_m2r(var,reg) mmx_m2r (paddsb, var, reg)
-#define paddsb_r2r(regs,regd) mmx_r2r (paddsb, regs, regd)
-#define paddsw_m2r(var,reg) mmx_m2r (paddsw, var, reg)
-#define paddsw_r2r(regs,regd) mmx_r2r (paddsw, regs, regd)
-
-#define paddusb_m2r(var,reg) mmx_m2r (paddusb, var, reg)
-#define paddusb_r2r(regs,regd) mmx_r2r (paddusb, regs, regd)
-#define paddusw_m2r(var,reg) mmx_m2r (paddusw, var, reg)
-#define paddusw_r2r(regs,regd) mmx_r2r (paddusw, regs, regd)
-
-#define pand_m2r(var,reg) mmx_m2r (pand, var, reg)
-#define pand_r2r(regs,regd) mmx_r2r (pand, regs, regd)
-
-#define pandn_m2r(var,reg) mmx_m2r (pandn, var, reg)
-#define pandn_r2r(regs,regd) mmx_r2r (pandn, regs, regd)
-
-#define pcmpeqb_m2r(var,reg) mmx_m2r (pcmpeqb, var, reg)
-#define pcmpeqb_r2r(regs,regd) mmx_r2r (pcmpeqb, regs, regd)
-#define pcmpeqd_m2r(var,reg) mmx_m2r (pcmpeqd, var, reg)
-#define pcmpeqd_r2r(regs,regd) mmx_r2r (pcmpeqd, regs, regd)
-#define pcmpeqw_m2r(var,reg) mmx_m2r (pcmpeqw, var, reg)
-#define pcmpeqw_r2r(regs,regd) mmx_r2r (pcmpeqw, regs, regd)
-
-#define pcmpgtb_m2r(var,reg) mmx_m2r (pcmpgtb, var, reg)
-#define pcmpgtb_r2r(regs,regd) mmx_r2r (pcmpgtb, regs, regd)
-#define pcmpgtd_m2r(var,reg) mmx_m2r (pcmpgtd, var, reg)
-#define pcmpgtd_r2r(regs,regd) mmx_r2r (pcmpgtd, regs, regd)
-#define pcmpgtw_m2r(var,reg) mmx_m2r (pcmpgtw, var, reg)
-#define pcmpgtw_r2r(regs,regd) mmx_r2r (pcmpgtw, regs, regd)
-
-#define pmaddwd_m2r(var,reg) mmx_m2r (pmaddwd, var, reg)
-#define pmaddwd_r2r(regs,regd) mmx_r2r (pmaddwd, regs, regd)
-
-#define pmulhw_m2r(var,reg) mmx_m2r (pmulhw, var, reg)
-#define pmulhw_r2r(regs,regd) mmx_r2r (pmulhw, regs, regd)
-
-#define pmullw_m2r(var,reg) mmx_m2r (pmullw, var, reg)
-#define pmullw_r2r(regs,regd) mmx_r2r (pmullw, regs, regd)
-
-#define por_m2r(var,reg) mmx_m2r (por, var, reg)
-#define por_r2r(regs,regd) mmx_r2r (por, regs, regd)
-
-#define pslld_i2r(imm,reg) mmx_i2r (pslld, imm, reg)
-#define pslld_m2r(var,reg) mmx_m2r (pslld, var, reg)
-#define pslld_r2r(regs,regd) mmx_r2r (pslld, regs, regd)
-#define psllq_i2r(imm,reg) mmx_i2r (psllq, imm, reg)
-#define psllq_m2r(var,reg) mmx_m2r (psllq, var, reg)
-#define psllq_r2r(regs,regd) mmx_r2r (psllq, regs, regd)
-#define psllw_i2r(imm,reg) mmx_i2r (psllw, imm, reg)
-#define psllw_m2r(var,reg) mmx_m2r (psllw, var, reg)
-#define psllw_r2r(regs,regd) mmx_r2r (psllw, regs, regd)
-
-#define psrad_i2r(imm,reg) mmx_i2r (psrad, imm, reg)
-#define psrad_m2r(var,reg) mmx_m2r (psrad, var, reg)
-#define psrad_r2r(regs,regd) mmx_r2r (psrad, regs, regd)
-#define psraw_i2r(imm,reg) mmx_i2r (psraw, imm, reg)
-#define psraw_m2r(var,reg) mmx_m2r (psraw, var, reg)
-#define psraw_r2r(regs,regd) mmx_r2r (psraw, regs, regd)
-
-#define psrld_i2r(imm,reg) mmx_i2r (psrld, imm, reg)
-#define psrld_m2r(var,reg) mmx_m2r (psrld, var, reg)
-#define psrld_r2r(regs,regd) mmx_r2r (psrld, regs, regd)
-#define psrlq_i2r(imm,reg) mmx_i2r (psrlq, imm, reg)
-#define psrlq_m2r(var,reg) mmx_m2r (psrlq, var, reg)
-#define psrlq_r2r(regs,regd) mmx_r2r (psrlq, regs, regd)
-#define psrlw_i2r(imm,reg) mmx_i2r (psrlw, imm, reg)
-#define psrlw_m2r(var,reg) mmx_m2r (psrlw, var, reg)
-#define psrlw_r2r(regs,regd) mmx_r2r (psrlw, regs, regd)
-
-#define psubb_m2r(var,reg) mmx_m2r (psubb, var, reg)
-#define psubb_r2r(regs,regd) mmx_r2r (psubb, regs, regd)
-#define psubd_m2r(var,reg) mmx_m2r (psubd, var, reg)
-#define psubd_r2r(regs,regd) mmx_r2r (psubd, regs, regd)
-#define psubw_m2r(var,reg) mmx_m2r (psubw, var, reg)
-#define psubw_r2r(regs,regd) mmx_r2r (psubw, regs, regd)
-
-#define psubsb_m2r(var,reg) mmx_m2r (psubsb, var, reg)
-#define psubsb_r2r(regs,regd) mmx_r2r (psubsb, regs, regd)
-#define psubsw_m2r(var,reg) mmx_m2r (psubsw, var, reg)
-#define psubsw_r2r(regs,regd) mmx_r2r (psubsw, regs, regd)
-
-#define psubusb_m2r(var,reg) mmx_m2r (psubusb, var, reg)
-#define psubusb_r2r(regs,regd) mmx_r2r (psubusb, regs, regd)
-#define psubusw_m2r(var,reg) mmx_m2r (psubusw, var, reg)
-#define psubusw_r2r(regs,regd) mmx_r2r (psubusw, regs, regd)
-
-#define punpckhbw_m2r(var,reg) mmx_m2r (punpckhbw, var, reg)
-#define punpckhbw_r2r(regs,regd) mmx_r2r (punpckhbw, regs, regd)
-#define punpckhdq_m2r(var,reg) mmx_m2r (punpckhdq, var, reg)
-#define punpckhdq_r2r(regs,regd) mmx_r2r (punpckhdq, regs, regd)
-#define punpckhwd_m2r(var,reg) mmx_m2r (punpckhwd, var, reg)
-#define punpckhwd_r2r(regs,regd) mmx_r2r (punpckhwd, regs, regd)
-
-#define punpcklbw_m2r(var,reg) mmx_m2r (punpcklbw, var, reg)
-#define punpcklbw_r2r(regs,regd) mmx_r2r (punpcklbw, regs, regd)
-#define punpckldq_m2r(var,reg) mmx_m2r (punpckldq, var, reg)
-#define punpckldq_r2r(regs,regd) mmx_r2r (punpckldq, regs, regd)
-#define punpcklwd_m2r(var,reg) mmx_m2r (punpcklwd, var, reg)
-#define punpcklwd_r2r(regs,regd) mmx_r2r (punpcklwd, regs, regd)
-
-#define pxor_m2r(var,reg) mmx_m2r (pxor, var, reg)
-#define pxor_r2r(regs,regd) mmx_r2r (pxor, regs, regd)
-
-
-/* 3DNOW extensions */
-
-#define pavgusb_m2r(var,reg) mmx_m2r (pavgusb, var, reg)
-#define pavgusb_r2r(regs,regd) mmx_r2r (pavgusb, regs, regd)
-
-
-/* AMD MMX extensions - also available in intel SSE */
-
-
-#define mmx_m2ri(op,mem,reg,imm) \
- __asm__ volatile (#op " %1, %0, %%" #reg \
- : /* nothing */ \
- : "m" (mem), "i" (imm))
-#define mmx_r2ri(op,regs,regd,imm) \
- __asm__ volatile (#op " %0, %%" #regs ", %%" #regd \
- : /* nothing */ \
- : "i" (imm) )
-
-#define mmx_fetch(mem,hint) \
- __asm__ volatile ("prefetch" #hint " %0" \
- : /* nothing */ \
- : "m" (mem))
-
-
-#define maskmovq(regs,maskreg) mmx_r2ri (maskmovq, regs, maskreg)
-
-#define movntq_r2m(mmreg,var) mmx_r2m (movntq, mmreg, var)
-
-#define pavgb_m2r(var,reg) mmx_m2r (pavgb, var, reg)
-#define pavgb_r2r(regs,regd) mmx_r2r (pavgb, regs, regd)
-#define pavgw_m2r(var,reg) mmx_m2r (pavgw, var, reg)
-#define pavgw_r2r(regs,regd) mmx_r2r (pavgw, regs, regd)
-
-#define pextrw_r2r(mmreg,reg,imm) mmx_r2ri (pextrw, mmreg, reg, imm)
-
-#define pinsrw_r2r(reg,mmreg,imm) mmx_r2ri (pinsrw, reg, mmreg, imm)
-
-#define pmaxsw_m2r(var,reg) mmx_m2r (pmaxsw, var, reg)
-#define pmaxsw_r2r(regs,regd) mmx_r2r (pmaxsw, regs, regd)
-
-#define pmaxub_m2r(var,reg) mmx_m2r (pmaxub, var, reg)
-#define pmaxub_r2r(regs,regd) mmx_r2r (pmaxub, regs, regd)
-
-#define pminsw_m2r(var,reg) mmx_m2r (pminsw, var, reg)
-#define pminsw_r2r(regs,regd) mmx_r2r (pminsw, regs, regd)
-
-#define pminub_m2r(var,reg) mmx_m2r (pminub, var, reg)
-#define pminub_r2r(regs,regd) mmx_r2r (pminub, regs, regd)
-
-#define pmovmskb(mmreg,reg) \
- __asm__ volatile ("movmskps %" #mmreg ", %" #reg)
-
-#define pmulhuw_m2r(var,reg) mmx_m2r (pmulhuw, var, reg)
-#define pmulhuw_r2r(regs,regd) mmx_r2r (pmulhuw, regs, regd)
-
-#define prefetcht0(mem) mmx_fetch (mem, t0)
-#define prefetcht1(mem) mmx_fetch (mem, t1)
-#define prefetcht2(mem) mmx_fetch (mem, t2)
-#define prefetchnta(mem) mmx_fetch (mem, nta)
-
-#define psadbw_m2r(var,reg) mmx_m2r (psadbw, var, reg)
-#define psadbw_r2r(regs,regd) mmx_r2r (psadbw, regs, regd)
-
-#define pshufw_m2r(var,reg,imm) mmx_m2ri(pshufw, var, reg, imm)
-#define pshufw_r2r(regs,regd,imm) mmx_r2ri(pshufw, regs, regd, imm)
-
-#define sfence() __asm__ volatile ("sfence\n\t")
-
-/* SSE2 */
-#define pshufhw_m2r(var,reg,imm) mmx_m2ri(pshufhw, var, reg, imm)
-#define pshufhw_r2r(regs,regd,imm) mmx_r2ri(pshufhw, regs, regd, imm)
-#define pshuflw_m2r(var,reg,imm) mmx_m2ri(pshuflw, var, reg, imm)
-#define pshuflw_r2r(regs,regd,imm) mmx_r2ri(pshuflw, regs, regd, imm)
-
-#define pshufd_r2r(regs,regd,imm) mmx_r2ri(pshufd, regs, regd, imm)
-
-#define movdqa_m2r(var,reg) mmx_m2r (movdqa, var, reg)
-#define movdqa_r2m(reg,var) mmx_r2m (movdqa, reg, var)
-#define movdqa_r2r(regs,regd) mmx_r2r (movdqa, regs, regd)
-#define movdqu_m2r(var,reg) mmx_m2r (movdqu, var, reg)
-#define movdqu_r2m(reg,var) mmx_r2m (movdqu, reg, var)
-#define movdqu_r2r(regs,regd) mmx_r2r (movdqu, regs, regd)
-
-#define pmullw_r2m(reg,var) mmx_r2m (pmullw, reg, var)
-
-#define pslldq_i2r(imm,reg) mmx_i2r (pslldq, imm, reg)
-#define psrldq_i2r(imm,reg) mmx_i2r (psrldq, imm, reg)
-
-#define punpcklqdq_r2r(regs,regd) mmx_r2r (punpcklqdq, regs, regd)
-#define punpckhqdq_r2r(regs,regd) mmx_r2r (punpckhqdq, regs, regd)
-
-
-#endif /* AVCODEC_X86_MMX_H */
diff --git a/lib/ffmpeg/libavcodec/x86/motion_est_mmx.c b/lib/ffmpeg/libavcodec/x86/motion_est_mmx.c
index 0272410dc5..fefef41058 100644
--- a/lib/ffmpeg/libavcodec/x86/motion_est_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/motion_est_mmx.c
@@ -38,7 +38,7 @@ static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
x86_reg len= -(stride*h);
__asm__ volatile(
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq (%2, %%"REG_a"), %%mm2 \n\t"
@@ -73,7 +73,7 @@ static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
static inline void sad8_1_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
__asm__ volatile(
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%1, %3), %%mm1 \n\t"
@@ -94,35 +94,32 @@ static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
{
int ret;
__asm__ volatile(
- "pxor %%xmm6, %%xmm6 \n\t"
- ASMALIGN(4)
+ "pxor %%xmm2, %%xmm2 \n\t"
+ ".p2align 4 \n\t"
"1: \n\t"
"movdqu (%1), %%xmm0 \n\t"
- "movdqu (%1, %3), %%xmm1 \n\t"
+ "movdqu (%1, %4), %%xmm1 \n\t"
"psadbw (%2), %%xmm0 \n\t"
- "psadbw (%2, %3), %%xmm1 \n\t"
- "paddw %%xmm0, %%xmm6 \n\t"
- "paddw %%xmm1, %%xmm6 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%2,%3,2), %2 \n\t"
+ "psadbw (%2, %4), %%xmm1 \n\t"
+ "paddw %%xmm0, %%xmm2 \n\t"
+ "paddw %%xmm1, %%xmm2 \n\t"
+ "lea (%1,%4,2), %1 \n\t"
+ "lea (%2,%4,2), %2 \n\t"
"sub $2, %0 \n\t"
" jg 1b \n\t"
- : "+r" (h), "+r" (blk1), "+r" (blk2)
+ "movhlps %%xmm2, %%xmm0 \n\t"
+ "paddw %%xmm0, %%xmm2 \n\t"
+ "movd %%xmm2, %3 \n\t"
+ : "+r" (h), "+r" (blk1), "+r" (blk2), "=r"(ret)
: "r" ((x86_reg)stride)
);
- __asm__ volatile(
- "movhlps %%xmm6, %%xmm0 \n\t"
- "paddw %%xmm0, %%xmm6 \n\t"
- "movd %%xmm6, %0 \n\t"
- : "=r"(ret)
- );
return ret;
}
static inline void sad8_x2a_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
{
__asm__ volatile(
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%1, %3), %%mm1 \n\t"
@@ -146,7 +143,7 @@ static inline void sad8_y2a_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h
__asm__ volatile(
"movq (%1), %%mm0 \n\t"
"add %3, %1 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1, %3), %%mm2 \n\t"
@@ -173,7 +170,7 @@ static inline void sad8_4_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
"movq (%1), %%mm0 \n\t"
"pavgb 1(%1), %%mm0 \n\t"
"add %3, %1 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1), %%mm1 \n\t"
"movq (%1,%3), %%mm2 \n\t"
@@ -200,7 +197,7 @@ static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int
{
x86_reg len= -(stride*h);
__asm__ volatile(
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq (%2, %%"REG_a"), %%mm1 \n\t"
@@ -248,7 +245,7 @@ static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
"punpckhbw %%mm7, %%mm3 \n\t"
"paddw %%mm2, %%mm0 \n\t"
"paddw %%mm3, %%mm1 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%2, %%"REG_a"), %%mm2 \n\t"
"movq 1(%2, %%"REG_a"), %%mm4 \n\t"
@@ -427,7 +424,9 @@ PIX_SAD(mmx2)
void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
{
- if (mm_flags & FF_MM_MMX) {
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & AV_CPU_FLAG_MMX) {
c->pix_abs[0][0] = sad16_mmx;
c->pix_abs[0][1] = sad16_x2_mmx;
c->pix_abs[0][2] = sad16_y2_mmx;
@@ -440,7 +439,7 @@ void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
c->sad[0]= sad16_mmx;
c->sad[1]= sad8_mmx;
}
- if (mm_flags & FF_MM_MMX2) {
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
c->pix_abs[0][0] = sad16_mmx2;
c->pix_abs[1][0] = sad8_mmx2;
@@ -456,7 +455,7 @@ void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
c->pix_abs[1][3] = sad8_xy2_mmx2;
}
}
- if ((mm_flags & FF_MM_SSE2) && !(mm_flags & FF_MM_3DNOW) && avctx->codec_id != CODEC_ID_SNOW) {
+ if ((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW) && avctx->codec_id != CODEC_ID_SNOW) {
c->sad[0]= sad16_sse2;
}
}
diff --git a/lib/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c b/lib/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c
index e7e1150789..2f34281510 100644
--- a/lib/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#define CONFIG_FLOAT 1
@@ -149,9 +150,9 @@ static void apply_window_mp3(float *in, float *win, int *unused, float *out,
void ff_mpegaudiodec_init_mmx(MPADecodeContext *s)
{
- mm_flags = mm_support();
+ int mm_flags = av_get_cpu_flags();
- if (mm_flags & FF_MM_SSE2) {
+ if (mm_flags & AV_CPU_FLAG_SSE2) {
s->apply_window_mp3 = apply_window_mp3;
}
}
diff --git a/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx.c b/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx.c
index 5deb68d28d..3b8513d3f0 100644
--- a/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx.c
@@ -22,6 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/dsputil.h"
@@ -65,7 +66,7 @@ __asm__ volatile(
"packssdw %%mm5, %%mm5 \n\t"
"psubw %%mm5, %%mm7 \n\t"
"pxor %%mm4, %%mm4 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %3), %%mm0 \n\t"
"movq 8(%0, %3), %%mm1 \n\t"
@@ -128,7 +129,7 @@ __asm__ volatile(
"packssdw %%mm5, %%mm5 \n\t"
"psubw %%mm5, %%mm7 \n\t"
"pxor %%mm4, %%mm4 \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %3), %%mm0 \n\t"
"movq 8(%0, %3), %%mm1 \n\t"
@@ -221,7 +222,7 @@ __asm__ volatile(
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"mov %3, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq 8(%0, %%"REG_a"), %%mm1 \n\t"
@@ -284,7 +285,7 @@ __asm__ volatile(
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"mov %3, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq 8(%0, %%"REG_a"), %%mm1 \n\t"
@@ -356,7 +357,7 @@ __asm__ volatile(
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"mov %3, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq 8(%0, %%"REG_a"), %%mm1 \n\t"
@@ -417,7 +418,7 @@ __asm__ volatile(
"packssdw %%mm6, %%mm6 \n\t"
"packssdw %%mm6, %%mm6 \n\t"
"mov %3, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
"movq (%0, %%"REG_a"), %%mm0 \n\t"
"movq 8(%0, %%"REG_a"), %%mm1 \n\t"
@@ -580,6 +581,8 @@ static void denoise_dct_sse2(MpegEncContext *s, DCTELEM *block){
" jb 1b \n\t"
: "+r" (block), "+r" (sum), "+r" (offset)
: "r"(block+64)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7")
);
}
@@ -625,7 +628,9 @@ static void denoise_dct_sse2(MpegEncContext *s, DCTELEM *block){
void MPV_common_init_mmx(MpegEncContext *s)
{
- if (mm_flags & FF_MM_MMX) {
+ int mm_flags = av_get_cpu_flags();
+
+ if (mm_flags & AV_CPU_FLAG_MMX) {
const int dct_algo = s->avctx->dct_algo;
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_mmx;
@@ -636,7 +641,7 @@ void MPV_common_init_mmx(MpegEncContext *s)
s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx;
s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx;
- if (mm_flags & FF_MM_SSE2) {
+ if (mm_flags & AV_CPU_FLAG_SSE2) {
s->denoise_dct= denoise_dct_sse2;
} else {
s->denoise_dct= denoise_dct_mmx;
@@ -644,13 +649,13 @@ void MPV_common_init_mmx(MpegEncContext *s)
if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
#if HAVE_SSSE3
- if(mm_flags & FF_MM_SSSE3){
+ if(mm_flags & AV_CPU_FLAG_SSSE3){
s->dct_quantize= dct_quantize_SSSE3;
} else
#endif
- if(mm_flags & FF_MM_SSE2){
+ if(mm_flags & AV_CPU_FLAG_SSE2){
s->dct_quantize= dct_quantize_SSE2;
- } else if(mm_flags & FF_MM_MMX2){
+ } else if(mm_flags & AV_CPU_FLAG_MMX2){
s->dct_quantize= dct_quantize_MMX2;
} else {
s->dct_quantize= dct_quantize_MMX;
diff --git a/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx_template.c b/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx_template.c
index 0d927921e2..0df4600a11 100644
--- a/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx_template.c
+++ b/lib/ffmpeg/libavcodec/x86/mpegvideo_mmx_template.c
@@ -158,7 +158,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
"pxor "MM"6, "MM"6 \n\t"
"psubw (%3), "MM"6 \n\t" // -bias[0]
"mov $-128, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
MOVQ" (%1, %%"REG_a"), "MM"0 \n\t" // block[i]
SAVE_SIGN(MM"1", MM"0") // ABS(block[i])
@@ -180,6 +180,8 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
: "+a" (last_non_zero_p1)
: "r" (block+64), "r" (qmat), "r" (bias),
"r" (inv_zigzag_direct16+64), "r" (temp_block+64)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7")
);
}else{ // FMT_H263
__asm__ volatile(
@@ -188,7 +190,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
"pxor "MM"7, "MM"7 \n\t" // 0
"pxor "MM"4, "MM"4 \n\t" // 0
"mov $-128, %%"REG_a" \n\t"
- ASMALIGN(4)
+ ".p2align 4 \n\t"
"1: \n\t"
MOVQ" (%1, %%"REG_a"), "MM"0 \n\t" // block[i]
SAVE_SIGN(MM"1", MM"0") // ABS(block[i])
@@ -212,6 +214,8 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
: "+a" (last_non_zero_p1)
: "r" (block+64), "r" (qmat+64), "r" (bias+64),
"r" (inv_zigzag_direct16+64), "r" (temp_block+64)
+ XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+ "%xmm4", "%xmm5", "%xmm6", "%xmm7")
);
}
__asm__ volatile(
diff --git a/lib/ffmpeg/libavcodec/x86/rv40dsp_mmx.c b/lib/ffmpeg/libavcodec/x86/rv40dsp_mmx.c
deleted file mode 100644
index 2b154c0a0b..0000000000
--- a/lib/ffmpeg/libavcodec/x86/rv40dsp_mmx.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2008 Konstantin Shishkov, Mathieu Velten
- *
- * MMX-optimized DSP functions for RV40, based on H.264 optimizations by
- * Michael Niedermayer and 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 "dsputil_mmx.h"
-
-/* bias interleaved with bias div 8, use p+1 to access bias div 8 */
-DECLARE_ALIGNED(8, static const uint64_t, rv40_bias_reg)[4][8] = {
- { 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0010001000100010ULL, 0x0002000200020002ULL,
- 0x0020002000200020ULL, 0x0004000400040004ULL, 0x0010001000100010ULL, 0x0002000200020002ULL },
- { 0x0020002000200020ULL, 0x0004000400040004ULL, 0x001C001C001C001CULL, 0x0003000300030003ULL,
- 0x0020002000200020ULL, 0x0004000400040004ULL, 0x001C001C001C001CULL, 0x0003000300030003ULL },
- { 0x0000000000000000ULL, 0x0000000000000000ULL, 0x0020002000200020ULL, 0x0004000400040004ULL,
- 0x0010001000100010ULL, 0x0002000200020002ULL, 0x0020002000200020ULL, 0x0004000400040004ULL },
- { 0x0020002000200020ULL, 0x0004000400040004ULL, 0x001C001C001C001CULL, 0x0003000300030003ULL,
- 0x0020002000200020ULL, 0x0004000400040004ULL, 0x001C001C001C001CULL, 0x0003000300030003ULL }
-};
-
-static void put_rv40_chroma_mc8_mmx(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_generic_mc8_mmx(dst, src, stride, h, x, y, &rv40_bias_reg[y>>1][x&(~1)]);
-}
-static void put_rv40_chroma_mc4_mmx(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- put_h264_chroma_generic_mc4_mmx(dst, src, stride, h, x, y, &rv40_bias_reg[y>>1][x&(~1)]);
-}
-static void avg_rv40_chroma_mc8_mmx2(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc8_mmx2(dst, src, stride, h, x, y, &rv40_bias_reg[y>>1][x&(~1)]);
-}
-static void avg_rv40_chroma_mc4_mmx2(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc4_mmx2(dst, src, stride, h, x, y, &rv40_bias_reg[y>>1][x&(~1)]);
-}
-static void avg_rv40_chroma_mc8_3dnow(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc8_3dnow(dst, src, stride, h, x, y, &rv40_bias_reg[y>>1][x&(~1)]);
-}
-static void avg_rv40_chroma_mc4_3dnow(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
- avg_h264_chroma_generic_mc4_3dnow(dst, src, stride, h, x, y, &rv40_bias_reg[y>>1][x&(~1)]);
-}
diff --git a/lib/ffmpeg/libavcodec/x86/simple_idct_mmx.c b/lib/ffmpeg/libavcodec/x86/simple_idct_mmx.c
index 5ea4c84ed9..92cc18465c 100644
--- a/lib/ffmpeg/libavcodec/x86/simple_idct_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/simple_idct_mmx.c
@@ -789,7 +789,7 @@ IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4) \
+ "# .p2align 4 \n\t"\
"4: \n\t"
Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 6f)
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 5f)
@@ -864,7 +864,7 @@ IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4) \
+ "# .p2align 4 \n\t"\
"6: \n\t"
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 7f)
@@ -930,7 +930,7 @@ IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4) \
+ "# .p2align 4 \n\t"\
"2: \n\t"
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 3f)
@@ -1007,7 +1007,7 @@ IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4) \
+ "# .p2align 4 \n\t"\
"3: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -1071,7 +1071,7 @@ IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4) \
+ "# .p2align 4 \n\t"\
"5: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -1136,7 +1136,7 @@ IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4) \
+ "# .p2align 4 \n\t"\
"1: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -1210,7 +1210,7 @@ IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
"jmp 9f \n\t"
- "#" ASMALIGN(4)
+ "# .p2align 4 \n\t"
"7: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, shift) \
@@ -1287,10 +1287,10 @@ void ff_simple_idct_mmx(int16_t *block)
void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block)
{
idct(block);
- put_pixels_clamped_mmx(block, dest, line_size);
+ ff_put_pixels_clamped_mmx(block, dest, line_size);
}
void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block)
{
idct(block);
- add_pixels_clamped_mmx(block, dest, line_size);
+ ff_add_pixels_clamped_mmx(block, dest, line_size);
}
diff --git a/lib/ffmpeg/libavcodec/x86/snowdsp_mmx.c b/lib/ffmpeg/libavcodec/x86/snowdsp_mmx.c
index 263f0bbf69..9c1fa429a8 100644
--- a/lib/ffmpeg/libavcodec/x86/snowdsp_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/snowdsp_mmx.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/snow.h"
@@ -811,7 +812,7 @@ snow_inner_add_yblock_sse2_end_16
"add %%"REG_c", "PTR_SIZE"*2(%%"REG_a");\n\t"\
"add %%"REG_c", "PTR_SIZE"*1(%%"REG_a");\n\t"\
"add %%"REG_c", (%%"REG_a") \n\t"\
- "add $"PTR_SIZE"*1, %1 \n\t"\
+ "add"OPSIZE " $"PTR_SIZE"*1, %1 \n\t"\
"add %%"REG_c", %0 \n\t"\
"dec %2 \n\t"\
"jnz 1b \n\t"\
@@ -874,10 +875,10 @@ static void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_str
void ff_dwt_init_x86(DWTContext *c)
{
- mm_flags = mm_support();
+ int mm_flags = av_get_cpu_flags();
- if (mm_flags & FF_MM_MMX) {
- if(mm_flags & FF_MM_SSE2 & 0){
+ if (mm_flags & AV_CPU_FLAG_MMX) {
+ if(mm_flags & AV_CPU_FLAG_SSE2 & 0){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;
#if HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
@@ -885,7 +886,7 @@ void ff_dwt_init_x86(DWTContext *c)
c->inner_add_yblock = ff_snow_inner_add_yblock_sse2;
}
else{
- if(mm_flags & FF_MM_MMX2){
+ if(mm_flags & AV_CPU_FLAG_MMX2){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx;
#if HAVE_7REGS
c->vertical_compose97i = ff_snow_vertical_compose97i_mmx;
diff --git a/lib/ffmpeg/libavcodec/x86/vc1dsp_mmx.c b/lib/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
index 3012ec5d1a..04b4abaad3 100644
--- a/lib/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
+++ b/lib/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
@@ -24,6 +24,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/dsputil.h"
#include "dsputil_mmx.h"
@@ -73,8 +74,6 @@
"movq %%mm"#R1", "#OFF"(%1) \n\t" \
"add %2, %0 \n\t"
-DECLARE_ALIGNED(16, const uint64_t, ff_pw_9) = 0x0009000900090009ULL;
-
/** Sacrifying mm6 allows to pipeline loads from src */
static void vc1_put_ver_16b_shift2_mmx(int16_t *dst,
const uint8_t *src, x86_reg stride,
@@ -215,13 +214,6 @@ VC1_SHIFT2(OP_PUT, put_)
VC1_SHIFT2(OP_AVG, avg_)
/**
- * Filter coefficients made global to allow access by all 1 or 3 quarter shift
- * interpolation functions.
- */
-DECLARE_ASM_CONST(16, uint64_t, ff_pw_53) = 0x0035003500350035ULL;
-DECLARE_ASM_CONST(16, uint64_t, ff_pw_18) = 0x0012001200120012ULL;
-
-/**
* Core of the 1/4 and 3/4 shift bicubic interpolation.
*
* @param UNPACK Macro unpacking arguments from 8 to 16bits (can be empty).
@@ -283,7 +275,7 @@ vc1_put_ver_16b_ ## NAME ## _mmx(int16_t *dst, const uint8_t *src, \
LOAD_ROUNDER_MMX("%5") \
"movq "MANGLE(ff_pw_53)", %%mm5\n\t" \
"movq "MANGLE(ff_pw_18)", %%mm6\n\t" \
- ASMALIGN(3) \
+ ".p2align 3 \n\t" \
"1: \n\t" \
MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
NORMALIZE_MMX("%6") \
@@ -339,7 +331,7 @@ OPNAME ## vc1_hor_16b_ ## NAME ## _mmx(uint8_t *dst, x86_reg stride, \
LOAD_ROUNDER_MMX("%4") \
"movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
"movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
- ASMALIGN(3) \
+ ".p2align 3 \n\t" \
"1: \n\t" \
MSPEL_FILTER13_CORE(DONT_UNPACK, "movq 2", A1, A2, A3, A4) \
NORMALIZE_MMX("$7") \
@@ -377,7 +369,7 @@ OPNAME ## vc1_## NAME ## _mmx(uint8_t *dst, const uint8_t *src, \
LOAD_ROUNDER_MMX("%6") \
"movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
"movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
- ASMALIGN(3) \
+ ".p2align 3 \n\t" \
"1: \n\t" \
MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
NORMALIZE_MMX("$6") \
@@ -723,7 +715,7 @@ static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq)
#endif
void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
- mm_flags = mm_support();
+ int mm_flags = av_get_cpu_flags();
dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx;
dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_mmx;
@@ -745,7 +737,7 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_mmx;
dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_mmx;
- if (mm_flags & FF_MM_MMX2){
+ if (mm_flags & AV_CPU_FLAG_MMX2){
dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_vc1_mspel_mc00_mmx2;
dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_mmx2;
dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_mmx2;
@@ -781,23 +773,23 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) {
dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
#if HAVE_YASM
- if (mm_flags & FF_MM_MMX) {
+ if (mm_flags & AV_CPU_FLAG_MMX) {
ASSIGN_LF(mmx);
}
return;
- if (mm_flags & FF_MM_MMX2) {
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
ASSIGN_LF(mmx2);
}
- if (mm_flags & FF_MM_SSE2) {
+ if (mm_flags & AV_CPU_FLAG_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) {
+ if (mm_flags & AV_CPU_FLAG_SSSE3) {
ASSIGN_LF(ssse3);
}
- if (mm_flags & FF_MM_SSE4) {
+ if (mm_flags & AV_CPU_FLAG_SSE4) {
dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
}
diff --git a/lib/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm b/lib/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm
index 660ff11693..3ea9d8db47 100644
--- a/lib/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm
+++ b/lib/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm
@@ -36,7 +36,7 @@ section .text
%endmacro
%macro STORE_4_WORDS_MMX 6
- movd %6, %5
+ movd %6d, %5
%if mmsize==16
psrldq %5, 4
%else
@@ -45,7 +45,7 @@ section .text
mov %1, %6w
shr %6, 16
mov %2, %6w
- movd %6, %5
+ movd %6d, %5
mov %3, %6w
shr %6, 16
mov %4, %6w
@@ -88,7 +88,7 @@ section .text
pxor m7, m3 ; d_sign ^= a0_sign
pxor m5, m5
- movd m3, r2
+ movd m3, r2d
%if %1 > 4
punpcklbw m3, m3
%endif
diff --git a/lib/ffmpeg/libavcodec/x86/vp3dsp.asm b/lib/ffmpeg/libavcodec/x86/vp3dsp.asm
new file mode 100644
index 0000000000..f2b0af3266
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/vp3dsp.asm
@@ -0,0 +1,618 @@
+;******************************************************************************
+;* MMX/SSE2-optimized functions for the VP3 decoder
+;* Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org>
+;*
+;* 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"
+
+; MMX-optimized functions cribbed from the original VP3 source code.
+
+SECTION_RODATA
+
+vp3_idct_data: times 8 dw 64277
+ times 8 dw 60547
+ times 8 dw 54491
+ times 8 dw 46341
+ times 8 dw 36410
+ times 8 dw 25080
+ times 8 dw 12785
+
+cextern pb_1
+cextern pb_3
+cextern pb_7
+cextern pb_1F
+cextern pb_81
+
+cextern pw_8
+
+cextern put_signed_pixels_clamped_mmx
+cextern add_pixels_clamped_mmx
+
+SECTION .text
+
+; this is off by one or two for some cases when filter_limit is greater than 63
+; in: p0 in mm6, p1 in mm4, p2 in mm2, p3 in mm1
+; out: p1 in mm4, p2 in mm3
+%macro VP3_LOOP_FILTER 0
+ movq m7, m6
+ pand m6, [pb_7] ; p0&7
+ psrlw m7, 3
+ pand m7, [pb_1F] ; p0>>3
+ movq m3, m2 ; p2
+ pxor m2, m4
+ pand m2, [pb_1] ; (p2^p1)&1
+ movq m5, m2
+ paddb m2, m2
+ paddb m2, m5 ; 3*(p2^p1)&1
+ paddb m2, m6 ; extra bits lost in shifts
+ pcmpeqb m0, m0
+ pxor m1, m0 ; 255 - p3
+ pavgb m1, m2 ; (256 - p3 + extrabits) >> 1
+ pxor m0, m4 ; 255 - p1
+ pavgb m0, m3 ; (256 + p2-p1) >> 1
+ paddb m1, [pb_3]
+ pavgb m1, m0 ; 128+2+( p2-p1 - p3) >> 2
+ pavgb m1, m0 ; 128+1+(3*(p2-p1) - p3) >> 3
+ paddusb m7, m1 ; d+128+1
+ movq m6, [pb_81]
+ psubusb m6, m7
+ psubusb m7, [pb_81]
+
+ movq m5, [r2+516] ; flim
+ pminub m6, m5
+ pminub m7, m5
+ movq m0, m6
+ movq m1, m7
+ paddb m6, m6
+ paddb m7, m7
+ pminub m6, m5
+ pminub m7, m5
+ psubb m6, m0
+ psubb m7, m1
+ paddusb m4, m7
+ psubusb m4, m6
+ psubusb m3, m7
+ paddusb m3, m6
+%endmacro
+
+%macro STORE_4_WORDS 1
+ movd r2d, %1
+ mov [r0 -1], r2w
+ psrlq %1, 32
+ shr r2, 16
+ mov [r0+r1 -1], r2w
+ movd r2d, %1
+ mov [r0+r1*2-1], r2w
+ shr r2, 16
+ mov [r0+r3 -1], r2w
+%endmacro
+
+INIT_MMX
+cglobal vp3_v_loop_filter_mmx2, 3, 4
+%ifdef ARCH_X86_64
+ movsxd r1, r1d
+%endif
+ mov r3, r1
+ neg r1
+ movq m6, [r0+r1*2]
+ movq m4, [r0+r1 ]
+ movq m2, [r0 ]
+ movq m1, [r0+r3 ]
+
+ VP3_LOOP_FILTER
+
+ movq [r0+r1], m4
+ movq [r0 ], m3
+ RET
+
+cglobal vp3_h_loop_filter_mmx2, 3, 4
+%ifdef ARCH_X86_64
+ movsxd r1, r1d
+%endif
+ lea r3, [r1*3]
+
+ movd m6, [r0 -2]
+ movd m4, [r0+r1 -2]
+ movd m2, [r0+r1*2-2]
+ movd m1, [r0+r3 -2]
+ lea r0, [r0+r1*4 ]
+ punpcklbw m6, [r0 -2]
+ punpcklbw m4, [r0+r1 -2]
+ punpcklbw m2, [r0+r1*2-2]
+ punpcklbw m1, [r0+r3 -2]
+ sub r0, r3
+ sub r0, r1
+
+ TRANSPOSE4x4B 6, 4, 2, 1, 0
+ VP3_LOOP_FILTER
+ SBUTTERFLY bw, 4, 3, 5
+
+ STORE_4_WORDS m4
+ lea r0, [r0+r1*4 ]
+ STORE_4_WORDS m3
+ RET
+
+; from original comments: The Macro does IDct on 4 1-D Dcts
+%macro BeginIDCT 0
+ movq m2, I(3)
+ movq m6, C(3)
+ movq m4, m2
+ movq m7, J(5)
+ pmulhw m4, m6 ; r4 = c3*i3 - i3
+ movq m1, C(5)
+ pmulhw m6, m7 ; r6 = c3*i5 - i5
+ movq m5, m1
+ pmulhw m1, m2 ; r1 = c5*i3 - i3
+ movq m3, I(1)
+ pmulhw m5, m7 ; r5 = c5*i5 - i5
+ movq m0, C(1)
+ paddw m4, m2 ; r4 = c3*i3
+ paddw m6, m7 ; r6 = c3*i5
+ paddw m2, m1 ; r2 = c5*i3
+ movq m1, J(7)
+ paddw m7, m5 ; r7 = c5*i5
+ movq m5, m0 ; r5 = c1
+ pmulhw m0, m3 ; r0 = c1*i1 - i1
+ paddsw m4, m7 ; r4 = C = c3*i3 + c5*i5
+ pmulhw m5, m1 ; r5 = c1*i7 - i7
+ movq m7, C(7)
+ psubsw m6, m2 ; r6 = D = c3*i5 - c5*i3
+ paddw m0, m3 ; r0 = c1*i1
+ pmulhw m3, m7 ; r3 = c7*i1
+ movq m2, I(2)
+ pmulhw m7, m1 ; r7 = c7*i7
+ paddw m5, m1 ; r5 = c1*i7
+ movq m1, m2 ; r1 = i2
+ pmulhw m2, C(2) ; r2 = c2*i2 - i2
+ psubsw m3, m5 ; r3 = B = c7*i1 - c1*i7
+ movq m5, J(6)
+ paddsw m0, m7 ; r0 = A = c1*i1 + c7*i7
+ movq m7, m5 ; r7 = i6
+ psubsw m0, m4 ; r0 = A - C
+ pmulhw m5, C(2) ; r5 = c2*i6 - i6
+ paddw m2, m1 ; r2 = c2*i2
+ pmulhw m1, C(6) ; r1 = c6*i2
+ paddsw m4, m4 ; r4 = C + C
+ paddsw m4, m0 ; r4 = C. = A + C
+ psubsw m3, m6 ; r3 = B - D
+ paddw m5, m7 ; r5 = c2*i6
+ paddsw m6, m6 ; r6 = D + D
+ pmulhw m7, C(6) ; r7 = c6*i6
+ paddsw m6, m3 ; r6 = D. = B + D
+ movq I(1), m4 ; save C. at I(1)
+ psubsw m1, m5 ; r1 = H = c6*i2 - c2*i6
+ movq m4, C(4)
+ movq m5, m3 ; r5 = B - D
+ pmulhw m3, m4 ; r3 = (c4 - 1) * (B - D)
+ paddsw m7, m2 ; r3 = (c4 - 1) * (B - D)
+ movq I(2), m6 ; save D. at I(2)
+ movq m2, m0 ; r2 = A - C
+ movq m6, I(0)
+ pmulhw m0, m4 ; r0 = (c4 - 1) * (A - C)
+ paddw m5, m3 ; r5 = B. = c4 * (B - D)
+ movq m3, J(4)
+ psubsw m5, m1 ; r5 = B.. = B. - H
+ paddw m2, m0 ; r0 = A. = c4 * (A - C)
+ psubsw m6, m3 ; r6 = i0 - i4
+ movq m0, m6
+ pmulhw m6, m4 ; r6 = (c4 - 1) * (i0 - i4)
+ paddsw m3, m3 ; r3 = i4 + i4
+ paddsw m1, m1 ; r1 = H + H
+ paddsw m3, m0 ; r3 = i0 + i4
+ paddsw m1, m5 ; r1 = H. = B + H
+ pmulhw m4, m3 ; r4 = (c4 - 1) * (i0 + i4)
+ paddsw m6, m0 ; r6 = F = c4 * (i0 - i4)
+ psubsw m6, m2 ; r6 = F. = F - A.
+ paddsw m2, m2 ; r2 = A. + A.
+ movq m0, I(1) ; r0 = C.
+ paddsw m2, m6 ; r2 = A.. = F + A.
+ paddw m4, m3 ; r4 = E = c4 * (i0 + i4)
+ psubsw m2, m1 ; r2 = R2 = A.. - H.
+%endmacro
+
+; RowIDCT gets ready to transpose
+%macro RowIDCT 0
+ BeginIDCT
+ movq m3, I(2) ; r3 = D.
+ psubsw m4, m7 ; r4 = E. = E - G
+ paddsw m1, m1 ; r1 = H. + H.
+ paddsw m7, m7 ; r7 = G + G
+ paddsw m1, m2 ; r1 = R1 = A.. + H.
+ paddsw m7, m4 ; r1 = R1 = A.. + H.
+ psubsw m4, m3 ; r4 = R4 = E. - D.
+ paddsw m3, m3
+ psubsw m6, m5 ; r6 = R6 = F. - B..
+ paddsw m5, m5
+ paddsw m3, m4 ; r3 = R3 = E. + D.
+ paddsw m5, m6 ; r5 = R5 = F. + B..
+ psubsw m7, m0 ; r7 = R7 = G. - C.
+ paddsw m0, m0
+ movq I(1), m1 ; save R1
+ paddsw m0, m7 ; r0 = R0 = G. + C.
+%endmacro
+
+; Column IDCT normalizes and stores final results
+%macro ColumnIDCT 0
+ BeginIDCT
+ paddsw m2, OC_8 ; adjust R2 (and R1) for shift
+ paddsw m1, m1 ; r1 = H. + H.
+ paddsw m1, m2 ; r1 = R1 = A.. + H.
+ psraw m2, 4 ; r2 = NR2
+ psubsw m4, m7 ; r4 = E. = E - G
+ psraw m1, 4 ; r1 = NR2
+ movq m3, I(2) ; r3 = D.
+ paddsw m7, m7 ; r7 = G + G
+ movq I(2), m2 ; store NR2 at I2
+ paddsw m7, m4 ; r7 = G. = E + G
+ movq I(1), m1 ; store NR1 at I1
+ psubsw m4, m3 ; r4 = R4 = E. - D.
+ paddsw m4, OC_8 ; adjust R4 (and R3) for shift
+ paddsw m3, m3 ; r3 = D. + D.
+ paddsw m3, m4 ; r3 = R3 = E. + D.
+ psraw m4, 4 ; r4 = NR4
+ psubsw m6, m5 ; r6 = R6 = F. - B..
+ psraw m3, 4 ; r3 = NR3
+ paddsw m6, OC_8 ; adjust R6 (and R5) for shift
+ paddsw m5, m5 ; r5 = B.. + B..
+ paddsw m5, m6 ; r5 = R5 = F. + B..
+ psraw m6, 4 ; r6 = NR6
+ movq J(4), m4 ; store NR4 at J4
+ psraw m5, 4 ; r5 = NR5
+ movq I(3), m3 ; store NR3 at I3
+ psubsw m7, m0 ; r7 = R7 = G. - C.
+ paddsw m7, OC_8 ; adjust R7 (and R0) for shift
+ paddsw m0, m0 ; r0 = C. + C.
+ paddsw m0, m7 ; r0 = R0 = G. + C.
+ psraw m7, 4 ; r7 = NR7
+ movq J(6), m6 ; store NR6 at J6
+ psraw m0, 4 ; r0 = NR0
+ movq J(5), m5 ; store NR5 at J5
+ movq J(7), m7 ; store NR7 at J7
+ movq I(0), m0 ; store NR0 at I0
+%endmacro
+
+; Following macro does two 4x4 transposes in place.
+;
+; At entry (we assume):
+;
+; r0 = a3 a2 a1 a0
+; I(1) = b3 b2 b1 b0
+; r2 = c3 c2 c1 c0
+; r3 = d3 d2 d1 d0
+;
+; r4 = e3 e2 e1 e0
+; r5 = f3 f2 f1 f0
+; r6 = g3 g2 g1 g0
+; r7 = h3 h2 h1 h0
+;
+; At exit, we have:
+;
+; I(0) = d0 c0 b0 a0
+; I(1) = d1 c1 b1 a1
+; I(2) = d2 c2 b2 a2
+; I(3) = d3 c3 b3 a3
+;
+; J(4) = h0 g0 f0 e0
+; J(5) = h1 g1 f1 e1
+; J(6) = h2 g2 f2 e2
+; J(7) = h3 g3 f3 e3
+;
+; I(0) I(1) I(2) I(3) is the transpose of r0 I(1) r2 r3.
+; J(4) J(5) J(6) J(7) is the transpose of r4 r5 r6 r7.
+;
+; Since r1 is free at entry, we calculate the Js first.
+%macro Transpose 0
+ movq m1, m4 ; r1 = e3 e2 e1 e0
+ punpcklwd m4, m5 ; r4 = f1 e1 f0 e0
+ movq I(0), m0 ; save a3 a2 a1 a0
+ punpckhwd m1, m5 ; r1 = f3 e3 f2 e2
+ movq m0, m6 ; r0 = g3 g2 g1 g0
+ punpcklwd m6, m7 ; r6 = h1 g1 h0 g0
+ movq m5, m4 ; r5 = f1 e1 f0 e0
+ punpckldq m4, m6 ; r4 = h0 g0 f0 e0 = R4
+ punpckhdq m5, m6 ; r5 = h1 g1 f1 e1 = R5
+ movq m6, m1 ; r6 = f3 e3 f2 e2
+ movq J(4), m4
+ punpckhwd m0, m7 ; r0 = h3 g3 h2 g2
+ movq J(5), m5
+ punpckhdq m6, m0 ; r6 = h3 g3 f3 e3 = R7
+ movq m4, I(0) ; r4 = a3 a2 a1 a0
+ punpckldq m1, m0 ; r1 = h2 g2 f2 e2 = R6
+ movq m5, I(1) ; r5 = b3 b2 b1 b0
+ movq m0, m4 ; r0 = a3 a2 a1 a0
+ movq J(7), m6
+ punpcklwd m0, m5 ; r0 = b1 a1 b0 a0
+ movq J(6), m1
+ punpckhwd m4, m5 ; r4 = b3 a3 b2 a2
+ movq m5, m2 ; r5 = c3 c2 c1 c0
+ punpcklwd m2, m3 ; r2 = d1 c1 d0 c0
+ movq m1, m0 ; r1 = b1 a1 b0 a0
+ punpckldq m0, m2 ; r0 = d0 c0 b0 a0 = R0
+ punpckhdq m1, m2 ; r1 = d1 c1 b1 a1 = R1
+ movq m2, m4 ; r2 = b3 a3 b2 a2
+ movq I(0), m0
+ punpckhwd m5, m3 ; r5 = d3 c3 d2 c2
+ movq I(1), m1
+ punpckhdq m4, m5 ; r4 = d3 c3 b3 a3 = R3
+ punpckldq m2, m5 ; r2 = d2 c2 b2 a2 = R2
+ movq I(3), m4
+ movq I(2), m2
+%endmacro
+
+%macro VP3_IDCT_mmx 1
+ ; eax = quantized input
+ ; ebx = dequantizer matrix
+ ; ecx = IDCT constants
+ ; M(I) = ecx + MaskOffset(0) + I * 8
+ ; C(I) = ecx + CosineOffset(32) + (I-1) * 8
+ ; edx = output
+ ; r0..r7 = mm0..mm7
+%define OC_8 [pw_8]
+%define C(x) [vp3_idct_data+16*(x-1)]
+
+ ; at this point, function has completed dequantization + dezigzag +
+ ; partial transposition; now do the idct itself
+%define I(x) [%1+16* x ]
+%define J(x) [%1+16*(x-4)+8]
+ RowIDCT
+ Transpose
+
+%define I(x) [%1+16* x +64]
+%define J(x) [%1+16*(x-4)+72]
+ RowIDCT
+ Transpose
+
+%define I(x) [%1+16*x]
+%define J(x) [%1+16*x]
+ ColumnIDCT
+
+%define I(x) [%1+16*x+8]
+%define J(x) [%1+16*x+8]
+ ColumnIDCT
+%endmacro
+
+%macro VP3_1D_IDCT_SSE2 0
+ movdqa m2, I(3) ; xmm2 = i3
+ movdqa m6, C(3) ; xmm6 = c3
+ movdqa m4, m2 ; xmm4 = i3
+ movdqa m7, I(5) ; xmm7 = i5
+ pmulhw m4, m6 ; xmm4 = c3 * i3 - i3
+ movdqa m1, C(5) ; xmm1 = c5
+ pmulhw m6, m7 ; xmm6 = c3 * i5 - i5
+ movdqa m5, m1 ; xmm5 = c5
+ pmulhw m1, m2 ; xmm1 = c5 * i3 - i3
+ movdqa m3, I(1) ; xmm3 = i1
+ pmulhw m5, m7 ; xmm5 = c5 * i5 - i5
+ movdqa m0, C(1) ; xmm0 = c1
+ paddw m4, m2 ; xmm4 = c3 * i3
+ paddw m6, m7 ; xmm6 = c3 * i5
+ paddw m2, m1 ; xmm2 = c5 * i3
+ movdqa m1, I(7) ; xmm1 = i7
+ paddw m7, m5 ; xmm7 = c5 * i5
+ movdqa m5, m0 ; xmm5 = c1
+ pmulhw m0, m3 ; xmm0 = c1 * i1 - i1
+ paddsw m4, m7 ; xmm4 = c3 * i3 + c5 * i5 = C
+ pmulhw m5, m1 ; xmm5 = c1 * i7 - i7
+ movdqa m7, C(7) ; xmm7 = c7
+ psubsw m6, m2 ; xmm6 = c3 * i5 - c5 * i3 = D
+ paddw m0, m3 ; xmm0 = c1 * i1
+ pmulhw m3, m7 ; xmm3 = c7 * i1
+ movdqa m2, I(2) ; xmm2 = i2
+ pmulhw m7, m1 ; xmm7 = c7 * i7
+ paddw m5, m1 ; xmm5 = c1 * i7
+ movdqa m1, m2 ; xmm1 = i2
+ pmulhw m2, C(2) ; xmm2 = i2 * c2 -i2
+ psubsw m3, m5 ; xmm3 = c7 * i1 - c1 * i7 = B
+ movdqa m5, I(6) ; xmm5 = i6
+ paddsw m0, m7 ; xmm0 = c1 * i1 + c7 * i7 = A
+ movdqa m7, m5 ; xmm7 = i6
+ psubsw m0, m4 ; xmm0 = A - C
+ pmulhw m5, C(2) ; xmm5 = c2 * i6 - i6
+ paddw m2, m1 ; xmm2 = i2 * c2
+ pmulhw m1, C(6) ; xmm1 = c6 * i2
+ paddsw m4, m4 ; xmm4 = C + C
+ paddsw m4, m0 ; xmm4 = A + C = C.
+ psubsw m3, m6 ; xmm3 = B - D
+ paddw m5, m7 ; xmm5 = c2 * i6
+ paddsw m6, m6 ; xmm6 = D + D
+ pmulhw m7, C(6) ; xmm7 = c6 * i6
+ paddsw m6, m3 ; xmm6 = B + D = D.
+ movdqa I(1), m4 ; Save C. at I(1)
+ psubsw m1, m5 ; xmm1 = c6 * i2 - c2 * i6 = H
+ movdqa m4, C(4) ; xmm4 = C4
+ movdqa m5, m3 ; xmm5 = B - D
+ pmulhw m3, m4 ; xmm3 = ( c4 -1 ) * ( B - D )
+ paddsw m7, m2 ; xmm7 = c2 * i2 + c6 * i6 = G
+ movdqa I(2), m6 ; save D. at I(2)
+ movdqa m2, m0 ; xmm2 = A - C
+ movdqa m6, I(0) ; xmm6 = i0
+ pmulhw m0, m4 ; xmm0 = ( c4 - 1 ) * ( A - C ) = A.
+ paddw m5, m3 ; xmm5 = c4 * ( B - D ) = B.
+ movdqa m3, I(4) ; xmm3 = i4
+ psubsw m5, m1 ; xmm5 = B. - H = B..
+ paddw m2, m0 ; xmm2 = c4 * ( A - C) = A.
+ psubsw m6, m3 ; xmm6 = i0 - i4
+ movdqa m0, m6 ; xmm0 = i0 - i4
+ pmulhw m6, m4 ; xmm6 = (c4 - 1) * (i0 - i4) = F
+ paddsw m3, m3 ; xmm3 = i4 + i4
+ paddsw m1, m1 ; xmm1 = H + H
+ paddsw m3, m0 ; xmm3 = i0 + i4
+ paddsw m1, m5 ; xmm1 = B. + H = H.
+ pmulhw m4, m3 ; xmm4 = ( c4 - 1 ) * ( i0 + i4 )
+ paddw m6, m0 ; xmm6 = c4 * ( i0 - i4 )
+ psubsw m6, m2 ; xmm6 = F - A. = F.
+ paddsw m2, m2 ; xmm2 = A. + A.
+ movdqa m0, I(1) ; Load C. from I(1)
+ paddsw m2, m6 ; xmm2 = F + A. = A..
+ paddw m4, m3 ; xmm4 = c4 * ( i0 + i4 ) = 3
+ psubsw m2, m1 ; xmm2 = A.. - H. = R2
+ ADD(m2) ; Adjust R2 and R1 before shifting
+ paddsw m1, m1 ; xmm1 = H. + H.
+ paddsw m1, m2 ; xmm1 = A.. + H. = R1
+ SHIFT(m2) ; xmm2 = op2
+ psubsw m4, m7 ; xmm4 = E - G = E.
+ SHIFT(m1) ; xmm1 = op1
+ movdqa m3, I(2) ; Load D. from I(2)
+ paddsw m7, m7 ; xmm7 = G + G
+ paddsw m7, m4 ; xmm7 = E + G = G.
+ psubsw m4, m3 ; xmm4 = E. - D. = R4
+ ADD(m4) ; Adjust R4 and R3 before shifting
+ paddsw m3, m3 ; xmm3 = D. + D.
+ paddsw m3, m4 ; xmm3 = E. + D. = R3
+ SHIFT(m4) ; xmm4 = op4
+ psubsw m6, m5 ; xmm6 = F. - B..= R6
+ SHIFT(m3) ; xmm3 = op3
+ ADD(m6) ; Adjust R6 and R5 before shifting
+ paddsw m5, m5 ; xmm5 = B.. + B..
+ paddsw m5, m6 ; xmm5 = F. + B.. = R5
+ SHIFT(m6) ; xmm6 = op6
+ SHIFT(m5) ; xmm5 = op5
+ psubsw m7, m0 ; xmm7 = G. - C. = R7
+ ADD(m7) ; Adjust R7 and R0 before shifting
+ paddsw m0, m0 ; xmm0 = C. + C.
+ paddsw m0, m7 ; xmm0 = G. + C.
+ SHIFT(m7) ; xmm7 = op7
+ SHIFT(m0) ; xmm0 = op0
+%endmacro
+
+%macro PUT_BLOCK 8
+ movdqa O(0), m%1
+ movdqa O(1), m%2
+ movdqa O(2), m%3
+ movdqa O(3), m%4
+ movdqa O(4), m%5
+ movdqa O(5), m%6
+ movdqa O(6), m%7
+ movdqa O(7), m%8
+%endmacro
+
+%macro VP3_IDCT_sse2 1
+%define I(x) [%1+16*x]
+%define O(x) [%1+16*x]
+%define C(x) [vp3_idct_data+16*(x-1)]
+%define SHIFT(x)
+%define ADD(x)
+ VP3_1D_IDCT_SSE2
+%ifdef ARCH_X86_64
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
+%else
+ TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, [%1], [%1+16]
+%endif
+ PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7
+
+%define SHIFT(x) psraw x, 4
+%define ADD(x) paddsw x, [pw_8]
+ VP3_1D_IDCT_SSE2
+ PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7
+%endmacro
+
+%macro vp3_idct_funcs 3
+cglobal vp3_idct_%1, 1, 1, %2
+ VP3_IDCT_%1 r0
+ RET
+
+cglobal vp3_idct_put_%1, 3, %3, %2
+ VP3_IDCT_%1 r2
+%ifdef ARCH_X86_64
+ mov r3, r2
+ mov r2, r1
+ mov r1, r0
+ mov r0, r3
+%else
+ mov r0m, r2
+ mov r1m, r0
+ mov r2m, r1
+%endif
+%ifdef WIN64
+ call put_signed_pixels_clamped_mmx
+ RET
+%else
+ jmp put_signed_pixels_clamped_mmx
+%endif
+
+cglobal vp3_idct_add_%1, 3, %3, %2
+ VP3_IDCT_%1 r2
+%ifdef ARCH_X86_64
+ mov r3, r2
+ mov r2, r1
+ mov r1, r0
+ mov r0, r3
+%else
+ mov r0m, r2
+ mov r1m, r0
+ mov r2m, r1
+%endif
+%ifdef WIN64
+ call add_pixels_clamped_mmx
+ RET
+%else
+ jmp add_pixels_clamped_mmx
+%endif
+%endmacro
+
+%ifdef ARCH_X86_64
+%define REGS 4
+%else
+%define REGS 3
+%endif
+INIT_MMX
+vp3_idct_funcs mmx, 0, REGS
+INIT_XMM
+vp3_idct_funcs sse2, 9, REGS
+%undef REGS
+
+%macro DC_ADD 0
+ movq m2, [r0 ]
+ movq m3, [r0+r1 ]
+ paddusb m2, m0
+ movq m4, [r0+r1*2]
+ paddusb m3, m0
+ movq m5, [r0+r3 ]
+ paddusb m4, m0
+ paddusb m5, m0
+ psubusb m2, m1
+ psubusb m3, m1
+ movq [r0 ], m2
+ psubusb m4, m1
+ movq [r0+r1 ], m3
+ psubusb m5, m1
+ movq [r0+r1*2], m4
+ movq [r0+r3 ], m5
+%endmacro
+
+INIT_MMX
+cglobal vp3_idct_dc_add_mmx2, 3, 4
+%ifdef ARCH_X86_64
+ movsxd r1, r1d
+%endif
+ lea r3, [r1*3]
+ movsx r2, word [r2]
+ add r2, 15
+ sar r2, 5
+ movd m0, r2d
+ pshufw m0, m0, 0x0
+ pxor m1, m1
+ psubw m1, m0
+ packuswb m0, m0
+ packuswb m1, m1
+ DC_ADD
+ lea r0, [r0+r1*4]
+ DC_ADD
+ RET
diff --git a/lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.c b/lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.c
deleted file mode 100644
index 188240dd08..0000000000
--- a/lib/ffmpeg/libavcodec/x86/vp3dsp_mmx.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Copyright (C) 2004 the ffmpeg project
- *
- * 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
- * MMX-optimized functions cribbed from the original VP3 source code.
- */
-
-#include "libavutil/x86_cpu.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_mmx.h"
-#include "vp3dsp_mmx.h"
-
-extern const uint16_t ff_vp3_idct_data[];
-
-// this is off by one or two for some cases when filter_limit is greater than 63
-// in: p0 in mm6, p1 in mm4, p2 in mm2, p3 in mm1
-// out: p1 in mm4, p2 in mm3
-#define VP3_LOOP_FILTER(flim) \
- "movq %%mm6, %%mm7 \n\t" \
- "pand "MANGLE(ff_pb_7 )", %%mm6 \n\t" /* p0&7 */ \
- "psrlw $3, %%mm7 \n\t" \
- "pand "MANGLE(ff_pb_1F)", %%mm7 \n\t" /* p0>>3 */ \
- "movq %%mm2, %%mm3 \n\t" /* mm3 = p2 */ \
- "pxor %%mm4, %%mm2 \n\t" \
- "pand "MANGLE(ff_pb_1 )", %%mm2 \n\t" /* (p2^p1)&1 */ \
- "movq %%mm2, %%mm5 \n\t" \
- "paddb %%mm2, %%mm2 \n\t" \
- "paddb %%mm5, %%mm2 \n\t" /* 3*(p2^p1)&1 */ \
- "paddb %%mm6, %%mm2 \n\t" /* extra bits lost in shifts */ \
- "pcmpeqb %%mm0, %%mm0 \n\t" \
- "pxor %%mm0, %%mm1 \n\t" /* 255 - p3 */ \
- "pavgb %%mm2, %%mm1 \n\t" /* (256 - p3 + extrabits) >> 1 */ \
- "pxor %%mm4, %%mm0 \n\t" /* 255 - p1 */ \
- "pavgb %%mm3, %%mm0 \n\t" /* (256 + p2-p1) >> 1 */ \
- "paddb "MANGLE(ff_pb_3 )", %%mm1 \n\t" \
- "pavgb %%mm0, %%mm1 \n\t" /* 128+2+( p2-p1 - p3) >> 2 */ \
- "pavgb %%mm0, %%mm1 \n\t" /* 128+1+(3*(p2-p1) - p3) >> 3 */ \
- "paddusb %%mm1, %%mm7 \n\t" /* d+128+1 */ \
- "movq "MANGLE(ff_pb_81)", %%mm6 \n\t" \
- "psubusb %%mm7, %%mm6 \n\t" \
- "psubusb "MANGLE(ff_pb_81)", %%mm7 \n\t" \
-\
- "movq "#flim", %%mm5 \n\t" \
- "pminub %%mm5, %%mm6 \n\t" \
- "pminub %%mm5, %%mm7 \n\t" \
- "movq %%mm6, %%mm0 \n\t" \
- "movq %%mm7, %%mm1 \n\t" \
- "paddb %%mm6, %%mm6 \n\t" \
- "paddb %%mm7, %%mm7 \n\t" \
- "pminub %%mm5, %%mm6 \n\t" \
- "pminub %%mm5, %%mm7 \n\t" \
- "psubb %%mm0, %%mm6 \n\t" \
- "psubb %%mm1, %%mm7 \n\t" \
- "paddusb %%mm7, %%mm4 \n\t" \
- "psubusb %%mm6, %%mm4 \n\t" \
- "psubusb %%mm7, %%mm3 \n\t" \
- "paddusb %%mm6, %%mm3 \n\t"
-
-#define STORE_4_WORDS(dst0, dst1, dst2, dst3, mm) \
- "movd "#mm", %0 \n\t" \
- "movw %w0, -1"#dst0" \n\t" \
- "psrlq $32, "#mm" \n\t" \
- "shr $16, %0 \n\t" \
- "movw %w0, -1"#dst1" \n\t" \
- "movd "#mm", %0 \n\t" \
- "movw %w0, -1"#dst2" \n\t" \
- "shr $16, %0 \n\t" \
- "movw %w0, -1"#dst3" \n\t"
-
-void ff_vp3_v_loop_filter_mmx2(uint8_t *src, int stride, int *bounding_values)
-{
- __asm__ volatile(
- "movq %0, %%mm6 \n\t"
- "movq %1, %%mm4 \n\t"
- "movq %2, %%mm2 \n\t"
- "movq %3, %%mm1 \n\t"
-
- VP3_LOOP_FILTER(%4)
-
- "movq %%mm4, %1 \n\t"
- "movq %%mm3, %2 \n\t"
-
- : "+m" (*(uint64_t*)(src - 2*stride)),
- "+m" (*(uint64_t*)(src - 1*stride)),
- "+m" (*(uint64_t*)(src + 0*stride)),
- "+m" (*(uint64_t*)(src + 1*stride))
- : "m"(*(uint64_t*)(bounding_values+129))
- );
-}
-
-void ff_vp3_h_loop_filter_mmx2(uint8_t *src, int stride, int *bounding_values)
-{
- x86_reg tmp;
-
- __asm__ volatile(
- "movd -2(%1), %%mm6 \n\t"
- "movd -2(%1,%3), %%mm0 \n\t"
- "movd -2(%1,%3,2), %%mm1 \n\t"
- "movd -2(%1,%4), %%mm4 \n\t"
-
- TRANSPOSE8x4(%%mm6, %%mm0, %%mm1, %%mm4, -2(%2), -2(%2,%3), -2(%2,%3,2), -2(%2,%4), %%mm2)
- VP3_LOOP_FILTER(%5)
- SBUTTERFLY(%%mm4, %%mm3, %%mm5, bw, q)
-
- STORE_4_WORDS((%1), (%1,%3), (%1,%3,2), (%1,%4), %%mm4)
- STORE_4_WORDS((%2), (%2,%3), (%2,%3,2), (%2,%4), %%mm5)
-
- : "=&r"(tmp)
- : "r"(src), "r"(src+4*stride), "r"((x86_reg)stride), "r"((x86_reg)3*stride),
- "m"(*(uint64_t*)(bounding_values+129))
- : "memory"
- );
-}
-
-/* from original comments: The Macro does IDct on 4 1-D Dcts */
-#define BeginIDCT() \
- "movq "I(3)", %%mm2 \n\t" \
- "movq "C(3)", %%mm6 \n\t" \
- "movq %%mm2, %%mm4 \n\t" \
- "movq "J(5)", %%mm7 \n\t" \
- "pmulhw %%mm6, %%mm4 \n\t" /* r4 = c3*i3 - i3 */ \
- "movq "C(5)", %%mm1 \n\t" \
- "pmulhw %%mm7, %%mm6 \n\t" /* r6 = c3*i5 - i5 */ \
- "movq %%mm1, %%mm5 \n\t" \
- "pmulhw %%mm2, %%mm1 \n\t" /* r1 = c5*i3 - i3 */ \
- "movq "I(1)", %%mm3 \n\t" \
- "pmulhw %%mm7, %%mm5 \n\t" /* r5 = c5*i5 - i5 */ \
- "movq "C(1)", %%mm0 \n\t" \
- "paddw %%mm2, %%mm4 \n\t" /* r4 = c3*i3 */ \
- "paddw %%mm7, %%mm6 \n\t" /* r6 = c3*i5 */ \
- "paddw %%mm1, %%mm2 \n\t" /* r2 = c5*i3 */ \
- "movq "J(7)", %%mm1 \n\t" \
- "paddw %%mm5, %%mm7 \n\t" /* r7 = c5*i5 */ \
- "movq %%mm0, %%mm5 \n\t" /* r5 = c1 */ \
- "pmulhw %%mm3, %%mm0 \n\t" /* r0 = c1*i1 - i1 */ \
- "paddsw %%mm7, %%mm4 \n\t" /* r4 = C = c3*i3 + c5*i5 */ \
- "pmulhw %%mm1, %%mm5 \n\t" /* r5 = c1*i7 - i7 */ \
- "movq "C(7)", %%mm7 \n\t" \
- "psubsw %%mm2, %%mm6 \n\t" /* r6 = D = c3*i5 - c5*i3 */ \
- "paddw %%mm3, %%mm0 \n\t" /* r0 = c1*i1 */ \
- "pmulhw %%mm7, %%mm3 \n\t" /* r3 = c7*i1 */ \
- "movq "I(2)", %%mm2 \n\t" \
- "pmulhw %%mm1, %%mm7 \n\t" /* r7 = c7*i7 */ \
- "paddw %%mm1, %%mm5 \n\t" /* r5 = c1*i7 */ \
- "movq %%mm2, %%mm1 \n\t" /* r1 = i2 */ \
- "pmulhw "C(2)", %%mm2 \n\t" /* r2 = c2*i2 - i2 */ \
- "psubsw %%mm5, %%mm3 \n\t" /* r3 = B = c7*i1 - c1*i7 */ \
- "movq "J(6)", %%mm5 \n\t" \
- "paddsw %%mm7, %%mm0 \n\t" /* r0 = A = c1*i1 + c7*i7 */ \
- "movq %%mm5, %%mm7 \n\t" /* r7 = i6 */ \
- "psubsw %%mm4, %%mm0 \n\t" /* r0 = A - C */ \
- "pmulhw "C(2)", %%mm5 \n\t" /* r5 = c2*i6 - i6 */ \
- "paddw %%mm1, %%mm2 \n\t" /* r2 = c2*i2 */ \
- "pmulhw "C(6)", %%mm1 \n\t" /* r1 = c6*i2 */ \
- "paddsw %%mm4, %%mm4 \n\t" /* r4 = C + C */ \
- "paddsw %%mm0, %%mm4 \n\t" /* r4 = C. = A + C */ \
- "psubsw %%mm6, %%mm3 \n\t" /* r3 = B - D */ \
- "paddw %%mm7, %%mm5 \n\t" /* r5 = c2*i6 */ \
- "paddsw %%mm6, %%mm6 \n\t" /* r6 = D + D */ \
- "pmulhw "C(6)", %%mm7 \n\t" /* r7 = c6*i6 */ \
- "paddsw %%mm3, %%mm6 \n\t" /* r6 = D. = B + D */ \
- "movq %%mm4, "I(1)"\n\t" /* save C. at I(1) */ \
- "psubsw %%mm5, %%mm1 \n\t" /* r1 = H = c6*i2 - c2*i6 */ \
- "movq "C(4)", %%mm4 \n\t" \
- "movq %%mm3, %%mm5 \n\t" /* r5 = B - D */ \
- "pmulhw %%mm4, %%mm3 \n\t" /* r3 = (c4 - 1) * (B - D) */ \
- "paddsw %%mm2, %%mm7 \n\t" /* r3 = (c4 - 1) * (B - D) */ \
- "movq %%mm6, "I(2)"\n\t" /* save D. at I(2) */ \
- "movq %%mm0, %%mm2 \n\t" /* r2 = A - C */ \
- "movq "I(0)", %%mm6 \n\t" \
- "pmulhw %%mm4, %%mm0 \n\t" /* r0 = (c4 - 1) * (A - C) */ \
- "paddw %%mm3, %%mm5 \n\t" /* r5 = B. = c4 * (B - D) */ \
- "movq "J(4)", %%mm3 \n\t" \
- "psubsw %%mm1, %%mm5 \n\t" /* r5 = B.. = B. - H */ \
- "paddw %%mm0, %%mm2 \n\t" /* r0 = A. = c4 * (A - C) */ \
- "psubsw %%mm3, %%mm6 \n\t" /* r6 = i0 - i4 */ \
- "movq %%mm6, %%mm0 \n\t" \
- "pmulhw %%mm4, %%mm6 \n\t" /* r6 = (c4 - 1) * (i0 - i4) */ \
- "paddsw %%mm3, %%mm3 \n\t" /* r3 = i4 + i4 */ \
- "paddsw %%mm1, %%mm1 \n\t" /* r1 = H + H */ \
- "paddsw %%mm0, %%mm3 \n\t" /* r3 = i0 + i4 */ \
- "paddsw %%mm5, %%mm1 \n\t" /* r1 = H. = B + H */ \
- "pmulhw %%mm3, %%mm4 \n\t" /* r4 = (c4 - 1) * (i0 + i4) */ \
- "paddsw %%mm0, %%mm6 \n\t" /* r6 = F = c4 * (i0 - i4) */ \
- "psubsw %%mm2, %%mm6 \n\t" /* r6 = F. = F - A. */ \
- "paddsw %%mm2, %%mm2 \n\t" /* r2 = A. + A. */ \
- "movq "I(1)", %%mm0 \n\t" /* r0 = C. */ \
- "paddsw %%mm6, %%mm2 \n\t" /* r2 = A.. = F + A. */ \
- "paddw %%mm3, %%mm4 \n\t" /* r4 = E = c4 * (i0 + i4) */ \
- "psubsw %%mm1, %%mm2 \n\t" /* r2 = R2 = A.. - H. */
-
-/* RowIDCT gets ready to transpose */
-#define RowIDCT() \
- BeginIDCT() \
- "movq "I(2)", %%mm3 \n\t" /* r3 = D. */ \
- "psubsw %%mm7, %%mm4 \n\t" /* r4 = E. = E - G */ \
- "paddsw %%mm1, %%mm1 \n\t" /* r1 = H. + H. */ \
- "paddsw %%mm7, %%mm7 \n\t" /* r7 = G + G */ \
- "paddsw %%mm2, %%mm1 \n\t" /* r1 = R1 = A.. + H. */ \
- "paddsw %%mm4, %%mm7 \n\t" /* r1 = R1 = A.. + H. */ \
- "psubsw %%mm3, %%mm4 \n\t" /* r4 = R4 = E. - D. */ \
- "paddsw %%mm3, %%mm3 \n\t" \
- "psubsw %%mm5, %%mm6 \n\t" /* r6 = R6 = F. - B.. */ \
- "paddsw %%mm5, %%mm5 \n\t" \
- "paddsw %%mm4, %%mm3 \n\t" /* r3 = R3 = E. + D. */ \
- "paddsw %%mm6, %%mm5 \n\t" /* r5 = R5 = F. + B.. */ \
- "psubsw %%mm0, %%mm7 \n\t" /* r7 = R7 = G. - C. */ \
- "paddsw %%mm0, %%mm0 \n\t" \
- "movq %%mm1, "I(1)"\n\t" /* save R1 */ \
- "paddsw %%mm7, %%mm0 \n\t" /* r0 = R0 = G. + C. */
-
-/* Column IDCT normalizes and stores final results */
-#define ColumnIDCT() \
- BeginIDCT() \
- "paddsw "OC_8", %%mm2 \n\t" /* adjust R2 (and R1) for shift */ \
- "paddsw %%mm1, %%mm1 \n\t" /* r1 = H. + H. */ \
- "paddsw %%mm2, %%mm1 \n\t" /* r1 = R1 = A.. + H. */ \
- "psraw $4, %%mm2 \n\t" /* r2 = NR2 */ \
- "psubsw %%mm7, %%mm4 \n\t" /* r4 = E. = E - G */ \
- "psraw $4, %%mm1 \n\t" /* r1 = NR1 */ \
- "movq "I(2)", %%mm3 \n\t" /* r3 = D. */ \
- "paddsw %%mm7, %%mm7 \n\t" /* r7 = G + G */ \
- "movq %%mm2, "I(2)"\n\t" /* store NR2 at I2 */ \
- "paddsw %%mm4, %%mm7 \n\t" /* r7 = G. = E + G */ \
- "movq %%mm1, "I(1)"\n\t" /* store NR1 at I1 */ \
- "psubsw %%mm3, %%mm4 \n\t" /* r4 = R4 = E. - D. */ \
- "paddsw "OC_8", %%mm4 \n\t" /* adjust R4 (and R3) for shift */ \
- "paddsw %%mm3, %%mm3 \n\t" /* r3 = D. + D. */ \
- "paddsw %%mm4, %%mm3 \n\t" /* r3 = R3 = E. + D. */ \
- "psraw $4, %%mm4 \n\t" /* r4 = NR4 */ \
- "psubsw %%mm5, %%mm6 \n\t" /* r6 = R6 = F. - B.. */ \
- "psraw $4, %%mm3 \n\t" /* r3 = NR3 */ \
- "paddsw "OC_8", %%mm6 \n\t" /* adjust R6 (and R5) for shift */ \
- "paddsw %%mm5, %%mm5 \n\t" /* r5 = B.. + B.. */ \
- "paddsw %%mm6, %%mm5 \n\t" /* r5 = R5 = F. + B.. */ \
- "psraw $4, %%mm6 \n\t" /* r6 = NR6 */ \
- "movq %%mm4, "J(4)"\n\t" /* store NR4 at J4 */ \
- "psraw $4, %%mm5 \n\t" /* r5 = NR5 */ \
- "movq %%mm3, "I(3)"\n\t" /* store NR3 at I3 */ \
- "psubsw %%mm0, %%mm7 \n\t" /* r7 = R7 = G. - C. */ \
- "paddsw "OC_8", %%mm7 \n\t" /* adjust R7 (and R0) for shift */ \
- "paddsw %%mm0, %%mm0 \n\t" /* r0 = C. + C. */ \
- "paddsw %%mm7, %%mm0 \n\t" /* r0 = R0 = G. + C. */ \
- "psraw $4, %%mm7 \n\t" /* r7 = NR7 */ \
- "movq %%mm6, "J(6)"\n\t" /* store NR6 at J6 */ \
- "psraw $4, %%mm0 \n\t" /* r0 = NR0 */ \
- "movq %%mm5, "J(5)"\n\t" /* store NR5 at J5 */ \
- "movq %%mm7, "J(7)"\n\t" /* store NR7 at J7 */ \
- "movq %%mm0, "I(0)"\n\t" /* store NR0 at I0 */
-
-/* Following macro does two 4x4 transposes in place.
-
- At entry (we assume):
-
- r0 = a3 a2 a1 a0
- I(1) = b3 b2 b1 b0
- r2 = c3 c2 c1 c0
- r3 = d3 d2 d1 d0
-
- r4 = e3 e2 e1 e0
- r5 = f3 f2 f1 f0
- r6 = g3 g2 g1 g0
- r7 = h3 h2 h1 h0
-
- At exit, we have:
-
- I(0) = d0 c0 b0 a0
- I(1) = d1 c1 b1 a1
- I(2) = d2 c2 b2 a2
- I(3) = d3 c3 b3 a3
-
- J(4) = h0 g0 f0 e0
- J(5) = h1 g1 f1 e1
- J(6) = h2 g2 f2 e2
- J(7) = h3 g3 f3 e3
-
- I(0) I(1) I(2) I(3) is the transpose of r0 I(1) r2 r3.
- J(4) J(5) J(6) J(7) is the transpose of r4 r5 r6 r7.
-
- Since r1 is free at entry, we calculate the Js first. */
-#define Transpose() \
- "movq %%mm4, %%mm1 \n\t" /* r1 = e3 e2 e1 e0 */ \
- "punpcklwd %%mm5, %%mm4 \n\t" /* r4 = f1 e1 f0 e0 */ \
- "movq %%mm0, "I(0)"\n\t" /* save a3 a2 a1 a0 */ \
- "punpckhwd %%mm5, %%mm1 \n\t" /* r1 = f3 e3 f2 e2 */ \
- "movq %%mm6, %%mm0 \n\t" /* r0 = g3 g2 g1 g0 */ \
- "punpcklwd %%mm7, %%mm6 \n\t" /* r6 = h1 g1 h0 g0 */ \
- "movq %%mm4, %%mm5 \n\t" /* r5 = f1 e1 f0 e0 */ \
- "punpckldq %%mm6, %%mm4 \n\t" /* r4 = h0 g0 f0 e0 = R4 */ \
- "punpckhdq %%mm6, %%mm5 \n\t" /* r5 = h1 g1 f1 e1 = R5 */ \
- "movq %%mm1, %%mm6 \n\t" /* r6 = f3 e3 f2 e2 */ \
- "movq %%mm4, "J(4)"\n\t" \
- "punpckhwd %%mm7, %%mm0 \n\t" /* r0 = h3 g3 h2 g2 */ \
- "movq %%mm5, "J(5)"\n\t" \
- "punpckhdq %%mm0, %%mm6 \n\t" /* r6 = h3 g3 f3 e3 = R7 */ \
- "movq "I(0)", %%mm4 \n\t" /* r4 = a3 a2 a1 a0 */ \
- "punpckldq %%mm0, %%mm1 \n\t" /* r1 = h2 g2 f2 e2 = R6 */ \
- "movq "I(1)", %%mm5 \n\t" /* r5 = b3 b2 b1 b0 */ \
- "movq %%mm4, %%mm0 \n\t" /* r0 = a3 a2 a1 a0 */ \
- "movq %%mm6, "J(7)"\n\t" \
- "punpcklwd %%mm5, %%mm0 \n\t" /* r0 = b1 a1 b0 a0 */ \
- "movq %%mm1, "J(6)"\n\t" \
- "punpckhwd %%mm5, %%mm4 \n\t" /* r4 = b3 a3 b2 a2 */ \
- "movq %%mm2, %%mm5 \n\t" /* r5 = c3 c2 c1 c0 */ \
- "punpcklwd %%mm3, %%mm2 \n\t" /* r2 = d1 c1 d0 c0 */ \
- "movq %%mm0, %%mm1 \n\t" /* r1 = b1 a1 b0 a0 */ \
- "punpckldq %%mm2, %%mm0 \n\t" /* r0 = d0 c0 b0 a0 = R0 */ \
- "punpckhdq %%mm2, %%mm1 \n\t" /* r1 = d1 c1 b1 a1 = R1 */ \
- "movq %%mm4, %%mm2 \n\t" /* r2 = b3 a3 b2 a2 */ \
- "movq %%mm0, "I(0)"\n\t" \
- "punpckhwd %%mm3, %%mm5 \n\t" /* r5 = d3 c3 d2 c2 */ \
- "movq %%mm1, "I(1)"\n\t" \
- "punpckhdq %%mm5, %%mm4 \n\t" /* r4 = d3 c3 b3 a3 = R3 */ \
- "punpckldq %%mm5, %%mm2 \n\t" /* r2 = d2 c2 b2 a2 = R2 */ \
- "movq %%mm4, "I(3)"\n\t" \
- "movq %%mm2, "I(2)"\n\t"
-
-void ff_vp3_idct_mmx(int16_t *output_data)
-{
- /* eax = quantized input
- * ebx = dequantizer matrix
- * ecx = IDCT constants
- * M(I) = ecx + MaskOffset(0) + I * 8
- * C(I) = ecx + CosineOffset(32) + (I-1) * 8
- * edx = output
- * r0..r7 = mm0..mm7
- */
-
-#define C(x) AV_STRINGIFY(16*(x-1))"(%1)"
-#define OC_8 "%2"
-
- /* at this point, function has completed dequantization + dezigzag +
- * partial transposition; now do the idct itself */
-#define I(x) AV_STRINGIFY(16* x )"(%0)"
-#define J(x) AV_STRINGIFY(16*(x-4) + 8)"(%0)"
-
- __asm__ volatile (
- RowIDCT()
- Transpose()
-
-#undef I
-#undef J
-#define I(x) AV_STRINGIFY(16* x + 64)"(%0)"
-#define J(x) AV_STRINGIFY(16*(x-4) + 72)"(%0)"
-
- RowIDCT()
- Transpose()
-
-#undef I
-#undef J
-#define I(x) AV_STRINGIFY(16*x)"(%0)"
-#define J(x) AV_STRINGIFY(16*x)"(%0)"
-
- ColumnIDCT()
-
-#undef I
-#undef J
-#define I(x) AV_STRINGIFY(16*x + 8)"(%0)"
-#define J(x) AV_STRINGIFY(16*x + 8)"(%0)"
-
- ColumnIDCT()
- :: "r"(output_data), "r"(ff_vp3_idct_data), "m"(ff_pw_8)
- );
-#undef I
-#undef J
-
-}
-
-void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block)
-{
- ff_vp3_idct_mmx(block);
- put_signed_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block)
-{
- ff_vp3_idct_mmx(block);
- add_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_vp3_idct_dc_add_mmx2(uint8_t *dest, int linesize, const DCTELEM *block)
-{
- int dc = (block[0] + 15) >> 5;
-
- __asm__ volatile(
- "movd %3, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
-
-#define DC_ADD \
- "movq (%0), %%mm2 \n\t" \
- "movq (%0,%1), %%mm3 \n\t" \
- "paddusb %%mm0, %%mm2 \n\t" \
- "movq (%0,%1,2), %%mm4 \n\t" \
- "paddusb %%mm0, %%mm3 \n\t" \
- "movq (%0,%2), %%mm5 \n\t" \
- "paddusb %%mm0, %%mm4 \n\t" \
- "paddusb %%mm0, %%mm5 \n\t" \
- "psubusb %%mm1, %%mm2 \n\t" \
- "psubusb %%mm1, %%mm3 \n\t" \
- "movq %%mm2, (%0) \n\t" \
- "psubusb %%mm1, %%mm4 \n\t" \
- "movq %%mm3, (%0,%1) \n\t" \
- "psubusb %%mm1, %%mm5 \n\t" \
- "movq %%mm4, (%0,%1,2) \n\t" \
- "movq %%mm5, (%0,%2) \n\t"
-
- DC_ADD
- "lea (%0,%1,4), %0 \n\t"
- DC_ADD
-
- : "+r"(dest)
- : "r"((x86_reg)linesize), "r"((x86_reg)3*linesize), "r"(dc)
- );
-}
diff --git a/lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.c b/lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.c
deleted file mode 100644
index e0ebd42427..0000000000
--- a/lib/ffmpeg/libavcodec/x86/vp3dsp_sse2.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2004 the ffmpeg project
- *
- * 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
- * SSE2-optimized functions cribbed from the original VP3 source code.
- */
-
-#include "libavcodec/dsputil.h"
-#include "dsputil_mmx.h"
-#include "vp3dsp_sse2.h"
-
-DECLARE_ALIGNED(16, const uint16_t, ff_vp3_idct_data)[7 * 8] =
-{
- 64277,64277,64277,64277,64277,64277,64277,64277,
- 60547,60547,60547,60547,60547,60547,60547,60547,
- 54491,54491,54491,54491,54491,54491,54491,54491,
- 46341,46341,46341,46341,46341,46341,46341,46341,
- 36410,36410,36410,36410,36410,36410,36410,36410,
- 25080,25080,25080,25080,25080,25080,25080,25080,
- 12785,12785,12785,12785,12785,12785,12785,12785
-};
-
-
-#define VP3_1D_IDCT_SSE2(ADD, SHIFT) \
- "movdqa "I(3)", %%xmm2 \n\t" /* xmm2 = i3 */ \
- "movdqa "C(3)", %%xmm6 \n\t" /* xmm6 = c3 */ \
- "movdqa %%xmm2, %%xmm4 \n\t" /* xmm4 = i3 */ \
- "movdqa "I(5)", %%xmm7 \n\t" /* xmm7 = i5 */ \
- "pmulhw %%xmm6, %%xmm4 \n\t" /* xmm4 = c3 * i3 - i3 */ \
- "movdqa "C(5)", %%xmm1 \n\t" /* xmm1 = c5 */ \
- "pmulhw %%xmm7, %%xmm6 \n\t" /* xmm6 = c3 * i5 - i5 */ \
- "movdqa %%xmm1, %%xmm5 \n\t" /* xmm5 = c5 */ \
- "pmulhw %%xmm2, %%xmm1 \n\t" /* xmm1 = c5 * i3 - i3 */ \
- "movdqa "I(1)", %%xmm3 \n\t" /* xmm3 = i1 */ \
- "pmulhw %%xmm7, %%xmm5 \n\t" /* xmm5 = c5 * i5 - i5 */ \
- "movdqa "C(1)", %%xmm0 \n\t" /* xmm0 = c1 */ \
- "paddw %%xmm2, %%xmm4 \n\t" /* xmm4 = c3 * i3 */ \
- "paddw %%xmm7, %%xmm6 \n\t" /* xmm6 = c3 * i5 */ \
- "paddw %%xmm1, %%xmm2 \n\t" /* xmm2 = c5 * i3 */ \
- "movdqa "I(7)", %%xmm1 \n\t" /* xmm1 = i7 */ \
- "paddw %%xmm5, %%xmm7 \n\t" /* xmm7 = c5 * i5 */ \
- "movdqa %%xmm0, %%xmm5 \n\t" /* xmm5 = c1 */ \
- "pmulhw %%xmm3, %%xmm0 \n\t" /* xmm0 = c1 * i1 - i1 */ \
- "paddsw %%xmm7, %%xmm4 \n\t" /* xmm4 = c3 * i3 + c5 * i5 = C */ \
- "pmulhw %%xmm1, %%xmm5 \n\t" /* xmm5 = c1 * i7 - i7 */ \
- "movdqa "C(7)", %%xmm7 \n\t" /* xmm7 = c7 */ \
- "psubsw %%xmm2, %%xmm6 \n\t" /* xmm6 = c3 * i5 - c5 * i3 = D */ \
- "paddw %%xmm3, %%xmm0 \n\t" /* xmm0 = c1 * i1 */ \
- "pmulhw %%xmm7, %%xmm3 \n\t" /* xmm3 = c7 * i1 */ \
- "movdqa "I(2)", %%xmm2 \n\t" /* xmm2 = i2 */ \
- "pmulhw %%xmm1, %%xmm7 \n\t" /* xmm7 = c7 * i7 */ \
- "paddw %%xmm1, %%xmm5 \n\t" /* xmm5 = c1 * i7 */ \
- "movdqa %%xmm2, %%xmm1 \n\t" /* xmm1 = i2 */ \
- "pmulhw "C(2)", %%xmm2 \n\t" /* xmm2 = i2 * c2 -i2 */ \
- "psubsw %%xmm5, %%xmm3 \n\t" /* xmm3 = c7 * i1 - c1 * i7 = B */ \
- "movdqa "I(6)", %%xmm5 \n\t" /* xmm5 = i6 */ \
- "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = c1 * i1 + c7 * i7 = A */ \
- "movdqa %%xmm5, %%xmm7 \n\t" /* xmm7 = i6 */ \
- "psubsw %%xmm4, %%xmm0 \n\t" /* xmm0 = A - C */ \
- "pmulhw "C(2)", %%xmm5 \n\t" /* xmm5 = c2 * i6 - i6 */ \
- "paddw %%xmm1, %%xmm2 \n\t" /* xmm2 = i2 * c2 */ \
- "pmulhw "C(6)", %%xmm1 \n\t" /* xmm1 = c6 * i2 */ \
- "paddsw %%xmm4, %%xmm4 \n\t" /* xmm4 = C + C */ \
- "paddsw %%xmm0, %%xmm4 \n\t" /* xmm4 = A + C = C. */ \
- "psubsw %%xmm6, %%xmm3 \n\t" /* xmm3 = B - D */ \
- "paddw %%xmm7, %%xmm5 \n\t" /* xmm5 = c2 * i6 */ \
- "paddsw %%xmm6, %%xmm6 \n\t" /* xmm6 = D + D */ \
- "pmulhw "C(6)", %%xmm7 \n\t" /* xmm7 = c6 * i6 */ \
- "paddsw %%xmm3, %%xmm6 \n\t" /* xmm6 = B + D = D. */ \
- "movdqa %%xmm4, "I(1)" \n\t" /* Save C. at I(1) */ \
- "psubsw %%xmm5, %%xmm1 \n\t" /* xmm1 = c6 * i2 - c2 * i6 = H */ \
- "movdqa "C(4)", %%xmm4 \n\t" /* xmm4 = c4 */ \
- "movdqa %%xmm3, %%xmm5 \n\t" /* xmm5 = B - D */ \
- "pmulhw %%xmm4, %%xmm3 \n\t" /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
- "paddsw %%xmm2, %%xmm7 \n\t" /* xmm7 = c2 * i2 + c6 * i6 = G */ \
- "movdqa %%xmm6, "I(2)" \n\t" /* Save D. at I(2) */ \
- "movdqa %%xmm0, %%xmm2 \n\t" /* xmm2 = A - C */ \
- "movdqa "I(0)", %%xmm6 \n\t" /* xmm6 = i0 */ \
- "pmulhw %%xmm4, %%xmm0 \n\t" /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
- "paddw %%xmm3, %%xmm5 \n\t" /* xmm5 = c4 * ( B - D ) = B. */ \
- "movdqa "I(4)", %%xmm3 \n\t" /* xmm3 = i4 */ \
- "psubsw %%xmm1, %%xmm5 \n\t" /* xmm5 = B. - H = B.. */ \
- "paddw %%xmm0, %%xmm2 \n\t" /* xmm2 = c4 * ( A - C) = A. */ \
- "psubsw %%xmm3, %%xmm6 \n\t" /* xmm6 = i0 - i4 */ \
- "movdqa %%xmm6, %%xmm0 \n\t" /* xmm0 = i0 - i4 */ \
- "pmulhw %%xmm4, %%xmm6 \n\t" /* xmm6 = (c4 - 1) * (i0 - i4) = F */ \
- "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = i4 + i4 */ \
- "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H + H */ \
- "paddsw %%xmm0, %%xmm3 \n\t" /* xmm3 = i0 + i4 */ \
- "paddsw %%xmm5, %%xmm1 \n\t" /* xmm1 = B. + H = H. */ \
- "pmulhw %%xmm3, %%xmm4 \n\t" /* xmm4 = ( c4 - 1 ) * ( i0 + i4 ) */ \
- "paddw %%xmm0, %%xmm6 \n\t" /* xmm6 = c4 * ( i0 - i4 ) */ \
- "psubsw %%xmm2, %%xmm6 \n\t" /* xmm6 = F - A. = F. */ \
- "paddsw %%xmm2, %%xmm2 \n\t" /* xmm2 = A. + A. */ \
- "movdqa "I(1)", %%xmm0 \n\t" /* Load C. from I(1) */ \
- "paddsw %%xmm6, %%xmm2 \n\t" /* xmm2 = F + A. = A.. */ \
- "paddw %%xmm3, %%xmm4 \n\t" /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
- "psubsw %%xmm1, %%xmm2 \n\t" /* xmm2 = A.. - H. = R2 */ \
- ADD(%%xmm2) /* Adjust R2 and R1 before shifting */ \
- "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H. + H. */ \
- "paddsw %%xmm2, %%xmm1 \n\t" /* xmm1 = A.. + H. = R1 */ \
- SHIFT(%%xmm2) /* xmm2 = op2 */ \
- "psubsw %%xmm7, %%xmm4 \n\t" /* xmm4 = E - G = E. */ \
- SHIFT(%%xmm1) /* xmm1 = op1 */ \
- "movdqa "I(2)", %%xmm3 \n\t" /* Load D. from I(2) */ \
- "paddsw %%xmm7, %%xmm7 \n\t" /* xmm7 = G + G */ \
- "paddsw %%xmm4, %%xmm7 \n\t" /* xmm7 = E + G = G. */ \
- "psubsw %%xmm3, %%xmm4 \n\t" /* xmm4 = E. - D. = R4 */ \
- ADD(%%xmm4) /* Adjust R4 and R3 before shifting */ \
- "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = D. + D. */ \
- "paddsw %%xmm4, %%xmm3 \n\t" /* xmm3 = E. + D. = R3 */ \
- SHIFT(%%xmm4) /* xmm4 = op4 */ \
- "psubsw %%xmm5, %%xmm6 \n\t" /* xmm6 = F. - B..= R6 */ \
- SHIFT(%%xmm3) /* xmm3 = op3 */ \
- ADD(%%xmm6) /* Adjust R6 and R5 before shifting */ \
- "paddsw %%xmm5, %%xmm5 \n\t" /* xmm5 = B.. + B.. */ \
- "paddsw %%xmm6, %%xmm5 \n\t" /* xmm5 = F. + B.. = R5 */ \
- SHIFT(%%xmm6) /* xmm6 = op6 */ \
- SHIFT(%%xmm5) /* xmm5 = op5 */ \
- "psubsw %%xmm0, %%xmm7 \n\t" /* xmm7 = G. - C. = R7 */ \
- ADD(%%xmm7) /* Adjust R7 and R0 before shifting */ \
- "paddsw %%xmm0, %%xmm0 \n\t" /* xmm0 = C. + C. */ \
- "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = G. + C. */ \
- SHIFT(%%xmm7) /* xmm7 = op7 */ \
- SHIFT(%%xmm0) /* xmm0 = op0 */
-
-#define PUT_BLOCK(r0, r1, r2, r3, r4, r5, r6, r7) \
- "movdqa " #r0 ", " O(0) "\n\t" \
- "movdqa " #r1 ", " O(1) "\n\t" \
- "movdqa " #r2 ", " O(2) "\n\t" \
- "movdqa " #r3 ", " O(3) "\n\t" \
- "movdqa " #r4 ", " O(4) "\n\t" \
- "movdqa " #r5 ", " O(5) "\n\t" \
- "movdqa " #r6 ", " O(6) "\n\t" \
- "movdqa " #r7 ", " O(7) "\n\t"
-
-#define NOP(xmm)
-#define SHIFT4(xmm) "psraw $4, "#xmm"\n\t"
-#define ADD8(xmm) "paddsw %2, "#xmm"\n\t"
-
-void ff_vp3_idct_sse2(int16_t *input_data)
-{
-#define I(x) AV_STRINGIFY(16*x)"(%0)"
-#define O(x) I(x)
-#define C(x) AV_STRINGIFY(16*(x-1))"(%1)"
-
- __asm__ volatile (
- VP3_1D_IDCT_SSE2(NOP, NOP)
-
- TRANSPOSE8(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7, (%0))
- PUT_BLOCK(%%xmm0, %%xmm5, %%xmm7, %%xmm3, %%xmm6, %%xmm4, %%xmm2, %%xmm1)
-
- VP3_1D_IDCT_SSE2(ADD8, SHIFT4)
- PUT_BLOCK(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7)
- :: "r"(input_data), "r"(ff_vp3_idct_data), "m"(ff_pw_8)
- );
-}
-
-void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block)
-{
- ff_vp3_idct_sse2(block);
- put_signed_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, DCTELEM *block)
-{
- ff_vp3_idct_sse2(block);
- add_pixels_clamped_mmx(block, dest, line_size);
-}
diff --git a/lib/ffmpeg/libavcodec/x86/vp56_arith.h b/lib/ffmpeg/libavcodec/x86/vp56_arith.h
new file mode 100644
index 0000000000..ddbf38b1a9
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/vp56_arith.h
@@ -0,0 +1,54 @@
+/**
+ * VP5 and VP6 compatible video decoder (arith decoder)
+ *
+ * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
+ * Copyright (C) 2010 Eli Friedman
+ *
+ * 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_X86_VP56_ARITH_H
+#define AVCODEC_X86_VP56_ARITH_H
+
+#if HAVE_FAST_CMOV
+#define vp56_rac_get_prob vp56_rac_get_prob
+static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
+{
+ unsigned int code_word = vp56_rac_renorm(c);
+ unsigned int high = c->high;
+ unsigned int low = 1 + (((high - 1) * prob) >> 8);
+ unsigned int low_shift = low << 16;
+ int bit = 0;
+
+ __asm__(
+ "subl %4, %1 \n\t"
+ "subl %3, %2 \n\t"
+ "leal (%2, %3), %3 \n\t"
+ "setae %b0 \n\t"
+ "cmovb %4, %1 \n\t"
+ "cmovb %3, %2 \n\t"
+ : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift)
+ : "r"(low)
+ );
+
+ c->high = high;
+ c->code_word = code_word;
+ return bit;
+}
+#endif
+
+#endif /* AVCODEC_X86_VP56_ARITH_H */
diff --git a/lib/ffmpeg/libavcodec/x86/vp56dsp.asm b/lib/ffmpeg/libavcodec/x86/vp56dsp.asm
new file mode 100644
index 0000000000..0543ba00ce
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/vp56dsp.asm
@@ -0,0 +1,173 @@
+;******************************************************************************
+;* MMX/SSE2-optimized functions for the VP6 decoder
+;* Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
+;* Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com>
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;******************************************************************************
+
+%include "x86inc.asm"
+%include "x86util.asm"
+
+cextern pw_64
+
+SECTION .text
+
+%macro DIAG4_MMX 6
+ movq m0, [%1+%2]
+ movq m1, [%1+%3]
+ movq m3, m0
+ movq m4, m1
+ punpcklbw m0, m7
+ punpcklbw m1, m7
+ punpckhbw m3, m7
+ punpckhbw m4, m7
+ pmullw m0, [rsp+8*11] ; src[x-8 ] * biweight [0]
+ pmullw m1, [rsp+8*12] ; src[x ] * biweight [1]
+ pmullw m3, [rsp+8*11] ; src[x-8 ] * biweight [0]
+ pmullw m4, [rsp+8*12] ; src[x ] * biweight [1]
+ paddw m0, m1
+ paddw m3, m4
+ movq m1, [%1+%4]
+ movq m2, [%1+%5]
+ movq m4, m1
+ movq m5, m2
+ punpcklbw m1, m7
+ punpcklbw m2, m7
+ punpckhbw m4, m7
+ punpckhbw m5, m7
+ pmullw m1, [rsp+8*13] ; src[x+8 ] * biweight [2]
+ pmullw m2, [rsp+8*14] ; src[x+16] * biweight [3]
+ pmullw m4, [rsp+8*13] ; src[x+8 ] * biweight [2]
+ pmullw m5, [rsp+8*14] ; src[x+16] * biweight [3]
+ paddw m1, m2
+ paddw m4, m5
+ paddsw m0, m1
+ paddsw m3, m4
+ paddsw m0, m6 ; Add 64
+ paddsw m3, m6 ; Add 64
+ psraw m0, 7
+ psraw m3, 7
+ packuswb m0, m3
+ movq [%6], m0
+%endmacro
+
+%macro DIAG4_SSE2 6
+ movq m0, [%1+%2]
+ movq m1, [%1+%3]
+ punpcklbw m0, m7
+ punpcklbw m1, m7
+ pmullw m0, m4 ; src[x-8 ] * biweight [0]
+ pmullw m1, m5 ; src[x ] * biweight [1]
+ paddw m0, m1
+ movq m1, [%1+%4]
+ movq m2, [%1+%5]
+ punpcklbw m1, m7
+ punpcklbw m2, m7
+ pmullw m1, m6 ; src[x+8 ] * biweight [2]
+ pmullw m2, m3 ; src[x+16] * biweight [3]
+ paddw m1, m2
+ paddsw m0, m1
+ paddsw m0, [pw_64] ; Add 64
+ psraw m0, 7
+ packuswb m0, m0
+ movq [%6], m0
+%endmacro
+
+%macro SPLAT4REGS_MMX 0
+ movq m5, m3
+ punpcklwd m3, m3
+ movq m4, m3
+ punpckldq m3, m3
+ punpckhdq m4, m4
+ punpckhwd m5, m5
+ movq m2, m5
+ punpckhdq m2, m2
+ punpckldq m5, m5
+ movq [rsp+8*11], m3
+ movq [rsp+8*12], m4
+ movq [rsp+8*13], m5
+ movq [rsp+8*14], m2
+%endmacro
+
+%macro SPLAT4REGS_SSE2 0
+ pshuflw m4, m3, 0x0
+ pshuflw m5, m3, 0x55
+ pshuflw m6, m3, 0xAA
+ pshuflw m3, m3, 0xFF
+ punpcklqdq m4, m4
+ punpcklqdq m5, m5
+ punpcklqdq m6, m6
+ punpcklqdq m3, m3
+%endmacro
+
+%macro vp6_filter_diag4 2
+; void ff_vp6_filter_diag4_<opt>(uint8_t *dst, uint8_t *src, int stride,
+; const int16_t h_weight[4], const int16_t v_weights[4])
+cglobal vp6_filter_diag4_%1, 5, 7, %2
+ mov r5, rsp ; backup stack pointer
+ and rsp, ~(mmsize-1) ; align stack
+%ifidn %1, sse2
+ sub rsp, 8*11
+%else
+ sub rsp, 8*15
+ movq m6, [pw_64]
+%endif
+%ifdef ARCH_X86_64
+ movsxd r2, r2d
+%endif
+
+ sub r1, r2
+
+ pxor m7, m7
+ movq m3, [r3]
+ SPLAT4REGS
+
+ mov r3, rsp
+ mov r6, 11
+.nextrow
+ DIAG4 r1, -1, 0, 1, 2, r3
+ add r3, 8
+ add r1, r2
+ dec r6
+ jnz .nextrow
+
+ movq m3, [r4]
+ SPLAT4REGS
+
+ lea r3, [rsp+8]
+ mov r6, 8
+.nextcol
+ DIAG4 r3, -8, 0, 8, 16, r0
+ add r3, 8
+ add r0, r2
+ dec r6
+ jnz .nextcol
+
+ mov rsp, r5 ; restore stack pointer
+ RET
+%endmacro
+
+INIT_MMX
+%define DIAG4 DIAG4_MMX
+%define SPLAT4REGS SPLAT4REGS_MMX
+vp6_filter_diag4 mmx, 0
+
+INIT_XMM
+%define DIAG4 DIAG4_SSE2
+%define SPLAT4REGS SPLAT4REGS_SSE2
+vp6_filter_diag4 sse2, 8
diff --git a/lib/ffmpeg/libavcodec/x86/vp56dsp_init.c b/lib/ffmpeg/libavcodec/x86/vp56dsp_init.c
new file mode 100644
index 0000000000..87fc935315
--- /dev/null
+++ b/lib/ffmpeg/libavcodec/x86/vp56dsp_init.c
@@ -0,0 +1,48 @@
+/*
+ * VP6 MMX/SSE2 optimizations
+ * Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
+ * Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/cpu.h"
+#include "libavutil/x86_cpu.h"
+#include "libavcodec/dsputil.h"
+#include "libavcodec/vp56dsp.h"
+
+void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride,
+ const int16_t *h_weights,const int16_t *v_weights);
+void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride,
+ const int16_t *h_weights,const int16_t *v_weights);
+
+av_cold void ff_vp56dsp_init_x86(VP56DSPContext* c, enum CodecID codec)
+{
+#if HAVE_YASM
+ int mm_flags = av_get_cpu_flags();
+
+ if (CONFIG_VP6_DECODER && codec == CODEC_ID_VP6) {
+ if (mm_flags & AV_CPU_FLAG_MMX) {
+ c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx;
+ }
+
+ if (mm_flags & AV_CPU_FLAG_SSE2) {
+ c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
+ }
+ }
+#endif
+}
diff --git a/lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.c b/lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.c
deleted file mode 100644
index 905b3a7f0d..0000000000
--- a/lib/ffmpeg/libavcodec/x86/vp6dsp_mmx.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * @file
- * MMX-optimized functions for the VP6 decoder
- *
- * Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/x86_cpu.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_mmx.h"
-#include "vp6dsp_mmx.h"
-
-
-#define DIAG4_MMX(in1,in2,in3,in4) \
- "movq "#in1"(%0), %%mm0 \n\t" \
- "movq "#in2"(%0), %%mm1 \n\t" \
- "movq %%mm0, %%mm3 \n\t" \
- "movq %%mm1, %%mm4 \n\t" \
- "punpcklbw %%mm7, %%mm0 \n\t" \
- "punpcklbw %%mm7, %%mm1 \n\t" \
- "punpckhbw %%mm7, %%mm3 \n\t" \
- "punpckhbw %%mm7, %%mm4 \n\t" \
- "pmullw 0(%2), %%mm0 \n\t" /* src[x-8 ] * biweight [0] */ \
- "pmullw 8(%2), %%mm1 \n\t" /* src[x ] * biweight [1] */ \
- "pmullw 0(%2), %%mm3 \n\t" /* src[x-8 ] * biweight [0] */ \
- "pmullw 8(%2), %%mm4 \n\t" /* src[x ] * biweight [1] */ \
- "paddw %%mm1, %%mm0 \n\t" \
- "paddw %%mm4, %%mm3 \n\t" \
- "movq "#in3"(%0), %%mm1 \n\t" \
- "movq "#in4"(%0), %%mm2 \n\t" \
- "movq %%mm1, %%mm4 \n\t" \
- "movq %%mm2, %%mm5 \n\t" \
- "punpcklbw %%mm7, %%mm1 \n\t" \
- "punpcklbw %%mm7, %%mm2 \n\t" \
- "punpckhbw %%mm7, %%mm4 \n\t" \
- "punpckhbw %%mm7, %%mm5 \n\t" \
- "pmullw 16(%2), %%mm1 \n\t" /* src[x+8 ] * biweight [2] */ \
- "pmullw 24(%2), %%mm2 \n\t" /* src[x+16] * biweight [3] */ \
- "pmullw 16(%2), %%mm4 \n\t" /* src[x+8 ] * biweight [2] */ \
- "pmullw 24(%2), %%mm5 \n\t" /* src[x+16] * biweight [3] */ \
- "paddw %%mm2, %%mm1 \n\t" \
- "paddw %%mm5, %%mm4 \n\t" \
- "paddsw %%mm1, %%mm0 \n\t" \
- "paddsw %%mm4, %%mm3 \n\t" \
- "paddsw %%mm6, %%mm0 \n\t" /* Add 64 */ \
- "paddsw %%mm6, %%mm3 \n\t" /* Add 64 */ \
- "psraw $7, %%mm0 \n\t" \
- "psraw $7, %%mm3 \n\t" \
- "packuswb %%mm3, %%mm0 \n\t" \
- "movq %%mm0, (%1) \n\t"
-
-void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights, const int16_t *v_weights)
-{
- uint8_t tmp[8*11], *t = tmp;
- int16_t weights[4*4];
- int i;
- src -= stride;
-
- for (i=0; i<4*4; i++)
- weights[i] = h_weights[i>>2];
-
- __asm__ volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movq "MANGLE(ff_pw_64)", %%mm6 \n\t"
- "1: \n\t"
- DIAG4_MMX(-1,0,1,2)
- "add $8, %1 \n\t"
- "add %3, %0 \n\t"
- "decl %4 \n\t"
- "jnz 1b \n\t"
- : "+r"(src), "+r"(t)
- : "r"(weights), "r"((x86_reg)stride), "r"(11)
- : "memory");
-
- t = tmp + 8;
- for (i=0; i<4*4; i++)
- weights[i] = v_weights[i>>2];
-
- __asm__ volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movq "MANGLE(ff_pw_64)", %%mm6 \n\t"
- "1: \n\t"
- DIAG4_MMX(-8,0,8,16)
- "add $8, %0 \n\t"
- "add %3, %1 \n\t"
- "decl %4 \n\t"
- "jnz 1b \n\t"
- : "+r"(t), "+r"(dst)
- : "r"(weights), "r"((x86_reg)stride), "r"(8)
- : "memory");
-}
diff --git a/lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.c b/lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.c
deleted file mode 100644
index bfd733aa7f..0000000000
--- a/lib/ffmpeg/libavcodec/x86/vp6dsp_sse2.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * @file
- * SSE2-optimized functions for the VP6 decoder
- *
- * Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/x86_cpu.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_mmx.h"
-#include "vp6dsp_sse2.h"
-
-#define DIAG4_SSE2(in1,in2,in3,in4) \
- "movq "#in1"(%0), %%xmm0 \n\t" \
- "movq "#in2"(%0), %%xmm1 \n\t" \
- "punpcklbw %%xmm7, %%xmm0 \n\t" \
- "punpcklbw %%xmm7, %%xmm1 \n\t" \
- "pmullw %%xmm4, %%xmm0 \n\t" /* src[x-8 ] * biweight [0] */ \
- "pmullw %%xmm5, %%xmm1 \n\t" /* src[x ] * biweight [1] */ \
- "paddw %%xmm1, %%xmm0 \n\t" \
- "movq "#in3"(%0), %%xmm1 \n\t" \
- "movq "#in4"(%0), %%xmm2 \n\t" \
- "punpcklbw %%xmm7, %%xmm1 \n\t" \
- "punpcklbw %%xmm7, %%xmm2 \n\t" \
- "pmullw %%xmm6, %%xmm1 \n\t" /* src[x+8 ] * biweight [2] */ \
- "pmullw %%xmm3, %%xmm2 \n\t" /* src[x+16] * biweight [3] */ \
- "paddw %%xmm2, %%xmm1 \n\t" \
- "paddsw %%xmm1, %%xmm0 \n\t" \
- "paddsw "MANGLE(ff_pw_64)", %%xmm0 \n\t" /* Add 64 */ \
- "psraw $7, %%xmm0 \n\t" \
- "packuswb %%xmm0, %%xmm0 \n\t" \
- "movq %%xmm0, (%1) \n\t" \
-
-void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights)
-{
- uint8_t tmp[8*11], *t = tmp;
- src -= stride;
-
- __asm__ volatile(
- "pxor %%xmm7, %%xmm7 \n\t"
- "movq %4, %%xmm3 \n\t"
- "pshuflw $0, %%xmm3, %%xmm4 \n\t"
- "punpcklqdq %%xmm4, %%xmm4 \n\t"
- "pshuflw $85, %%xmm3, %%xmm5 \n\t"
- "punpcklqdq %%xmm5, %%xmm5 \n\t"
- "pshuflw $170, %%xmm3, %%xmm6 \n\t"
- "punpcklqdq %%xmm6, %%xmm6 \n\t"
- "pshuflw $255, %%xmm3, %%xmm3 \n\t"
- "punpcklqdq %%xmm3, %%xmm3 \n\t"
- "1: \n\t"
- DIAG4_SSE2(-1,0,1,2)
- "add $8, %1 \n\t"
- "add %2, %0 \n\t"
- "decl %3 \n\t"
- "jnz 1b \n\t"
- : "+r"(src), "+r"(t)
- : "g"((x86_reg)stride), "r"(11), "m"(*(const int64_t*)h_weights)
- : "memory");
-
- t = tmp + 8;
-
- __asm__ volatile(
- "movq %4, %%xmm3 \n\t"
- "pshuflw $0, %%xmm3, %%xmm4 \n\t"
- "punpcklqdq %%xmm4, %%xmm4 \n\t"
- "pshuflw $85, %%xmm3, %%xmm5 \n\t"
- "punpcklqdq %%xmm5, %%xmm5 \n\t"
- "pshuflw $170, %%xmm3, %%xmm6 \n\t"
- "punpcklqdq %%xmm6, %%xmm6 \n\t"
- "pshuflw $255, %%xmm3, %%xmm3 \n\t"
- "punpcklqdq %%xmm3, %%xmm3 \n\t"
- "1: \n\t"
- DIAG4_SSE2(-8,0,8,16)
- "add $8, %0 \n\t"
- "add %2, %1 \n\t"
- "decl %3 \n\t"
- "jnz 1b \n\t"
- : "+r"(t), "+r"(dst)
- : "g"((x86_reg)stride), "r"(8), "m"(*(const int64_t*)v_weights)
- : "memory");
-}
diff --git a/lib/ffmpeg/libavcodec/x86/vp8dsp-init.c b/lib/ffmpeg/libavcodec/x86/vp8dsp-init.c
index 9cd72b6955..201b34e243 100644
--- a/lib/ffmpeg/libavcodec/x86/vp8dsp-init.c
+++ b/lib/ffmpeg/libavcodec/x86/vp8dsp-init.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/cpu.h"
#include "libavutil/x86_cpu.h"
#include "libavcodec/vp8dsp.h"
@@ -220,15 +221,40 @@ 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_dc_add4y_mmx(uint8_t *dst, DCTELEM block[4][16], int stride);
+extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, DCTELEM block[4][16], int stride);
+extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, DCTELEM block[2][16], int stride);
+extern void ff_vp8_luma_dc_wht_mmx(DCTELEM block[4][4][16], DCTELEM dc[16]);
+extern void ff_vp8_luma_dc_wht_sse(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_idct_add_sse(uint8_t *dst, DCTELEM block[16], int stride);
+
+#define DECLARE_LOOP_FILTER(NAME)\
+extern void ff_vp8_v_loop_filter_simple_ ## NAME(uint8_t *dst, int stride, int flim);\
+extern void ff_vp8_h_loop_filter_simple_ ## NAME(uint8_t *dst, int stride, int flim);\
+extern void ff_vp8_v_loop_filter16y_inner_ ## NAME (uint8_t *dst, int stride,\
+ int e, int i, int hvt);\
+extern void ff_vp8_h_loop_filter16y_inner_ ## NAME (uint8_t *dst, int stride,\
+ int e, int i, int hvt);\
+extern void ff_vp8_v_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, uint8_t *dstV,\
+ int s, int e, int i, int hvt);\
+extern void ff_vp8_h_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, uint8_t *dstV,\
+ int s, int e, int i, int hvt);\
+extern void ff_vp8_v_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, int stride,\
+ int e, int i, int hvt);\
+extern void ff_vp8_h_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, int stride,\
+ int e, int i, int hvt);\
+extern void ff_vp8_v_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, uint8_t *dstV,\
+ int s, int e, int i, int hvt);\
+extern void ff_vp8_h_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, uint8_t *dstV,\
+ int s, int e, int i, int hvt);
+
+DECLARE_LOOP_FILTER(mmx)
+DECLARE_LOOP_FILTER(mmxext)
+DECLARE_LOOP_FILTER(sse2)
+DECLARE_LOOP_FILTER(ssse3)
+DECLARE_LOOP_FILTER(sse4)
-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) \
@@ -257,12 +283,15 @@ extern void ff_vp8_h_loop_filter_simple_sse2 (uint8_t *dst, int stride, int fli
av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
{
- mm_flags = mm_support();
+ int mm_flags = av_get_cpu_flags();
#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;
+ if (mm_flags & AV_CPU_FLAG_MMX) {
+ c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
+ c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx;
+ c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;
+ c->vp8_idct_add = ff_vp8_idct_add_mmx;
+ c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_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] =
@@ -270,12 +299,21 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
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;
+
+ c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx;
+ c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx;
+ c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx;
+ c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx;
+
+ c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmx;
+ c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmx;
+ c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmx;
+ c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_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;
+ if (mm_flags & AV_CPU_FLAG_MMX2) {
VP8_LUMA_MC_FUNC(0, 16, mmxext);
VP8_MC_FUNC(1, 8, mmxext);
VP8_MC_FUNC(2, 4, mmxext);
@@ -285,34 +323,80 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
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;
+
+ c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmxext;
+ c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmxext;
+ c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmxext;
+ c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmxext;
+
+ c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmxext;
+ c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmxext;
+ c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext;
+ c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmxext;
}
- if (mm_flags & FF_MM_SSE) {
+ if (mm_flags & AV_CPU_FLAG_SSE) {
+ c->vp8_idct_add = ff_vp8_idct_add_sse;
+ c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_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) {
+ if (mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
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_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2;
+ c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_sse2;
+
+ c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_sse2;
+ c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_sse2;
+ }
+
+ if (mm_flags & AV_CPU_FLAG_SSE2) {
+ c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_sse2;
+
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;
+
+ c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2;
+ c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2;
+
+ c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_sse2;
+ c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_sse2;
}
- if (mm_flags & FF_MM_SSSE3) {
+ if (mm_flags & AV_CPU_FLAG_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);
+
+ c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_ssse3;
+ c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_ssse3;
+
+ c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_ssse3;
+ c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_ssse3;
+ c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_ssse3;
+ c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_ssse3;
+
+ c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_ssse3;
+ c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_ssse3;
+ c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_ssse3;
+ c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_ssse3;
}
- if (mm_flags & FF_MM_SSE4) {
+ if (mm_flags & AV_CPU_FLAG_SSE4) {
c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4;
+
+ c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse4;
+ c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_sse4;
+ c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_sse4;
}
#endif
}
diff --git a/lib/ffmpeg/libavcodec/x86/vp8dsp.asm b/lib/ffmpeg/libavcodec/x86/vp8dsp.asm
index aedd09e5ac..bc5ccc8e3a 100644
--- a/lib/ffmpeg/libavcodec/x86/vp8dsp.asm
+++ b/lib/ffmpeg/libavcodec/x86/vp8dsp.asm
@@ -145,10 +145,19 @@ 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
+pb_27_63: times 8 db 27, 63
+pb_18_63: times 8 db 18, 63
+pb_9_63: times 8 db 9, 63
+
+cextern pb_1
cextern pw_3
cextern pb_3
cextern pw_4
cextern pb_4
+cextern pw_9
+cextern pw_18
+cextern pw_27
+cextern pw_63
cextern pw_64
cextern pb_80
cextern pb_F8
@@ -202,7 +211,7 @@ cglobal put_vp8_epel%1_h6_ssse3, 6, 6, %2
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
@@ -233,7 +242,7 @@ cglobal put_vp8_epel%1_h4_ssse3, 6, 6, %3
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
@@ -272,7 +281,7 @@ cglobal put_vp8_epel%1_v4_ssse3, 7, 7, %2
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
@@ -319,7 +328,7 @@ cglobal put_vp8_epel%1_v6_ssse3, 7, 7, %2
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
%endmacro
@@ -372,7 +381,7 @@ cglobal put_vp8_epel4_h4_mmxext, 6, 6
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
@@ -429,52 +438,47 @@ cglobal put_vp8_epel4_h6_mmxext, 6, 6
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; 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
+cglobal put_vp8_epel8_h4_sse2, 6, 6, 10
+ shl r5d, 5
%ifdef PIC
- lea r11, [fourtap_filter_hw_m]
+ lea r11, [fourtap_filter_v_m]
%endif
- mova m5, [fourtap_filter_hw+r5-16] ; set up 4tap filter in words
- mova m6, [fourtap_filter_hw+r5]
+ lea r5, [fourtap_filter_v+r5-32]
pxor m7, m7
-
+ mova m4, [pw_64]
+ mova m5, [r5+ 0]
+ mova m6, [r5+16]
+%ifdef m8
+ mova m8, [r5+32]
+ mova m9, [r5+48]
+%endif
.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]
+ movq m0, [r2-1]
+ movq m1, [r2-0]
+ movq m2, [r2+1]
+ movq m3, [r2+2]
+ punpcklbw m0, m7
+ punpcklbw m1, m7
+ punpcklbw m2, m7
+ punpcklbw m3, m7
+ pmullw m0, m5
+ pmullw m1, m6
+%ifdef m8
+ pmullw m2, m8
+ pmullw m3, m9
+%else
+ pmullw m2, [r5+32]
+ pmullw m3, [r5+48]
+%endif
+ paddsw m0, m1
+ paddsw m2, m3
+ paddsw m0, m2
+ paddsw m0, m4
psraw m0, 7
packuswb m0, m7
movh [r0], m0 ; store
@@ -482,66 +486,61 @@ cglobal put_vp8_epel8_h4_sse2, 6, 6, 8
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
-cglobal put_vp8_epel8_h6_sse2, 6, 6, 8
+cglobal put_vp8_epel8_h6_sse2, 6, 6, 14
lea r5d, [r5*3]
+ shl r5d, 4
%ifdef PIC
- lea r11, [sixtap_filter_hw_m]
+ lea r11, [sixtap_filter_v_m]
%endif
- lea r5, [sixtap_filter_hw+r5*8]
+ lea r5, [sixtap_filter_v+r5-96]
pxor m7, m7
-
+ mova m6, [pw_64]
+%ifdef m8
+ mova m8, [r5+ 0]
+ mova m9, [r5+16]
+ mova m10, [r5+32]
+ mova m11, [r5+48]
+ mova m12, [r5+64]
+ mova m13, [r5+80]
+%endif
.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]
+ movq m0, [r2-2]
+ movq m1, [r2-1]
+ movq m2, [r2-0]
+ movq m3, [r2+1]
+ movq m4, [r2+2]
+ movq m5, [r2+3]
+ punpcklbw m0, m7
+ punpcklbw m1, m7
+ punpcklbw m2, m7
+ punpcklbw m3, m7
+ punpcklbw m4, m7
+ punpcklbw m5, m7
+%ifdef m8
+ pmullw m0, m8
+ pmullw m1, m9
+ pmullw m2, m10
+ pmullw m3, m11
+ pmullw m4, m12
+ pmullw m5, m13
+%else
+ pmullw m0, [r5+ 0]
+ pmullw m1, [r5+16]
+ pmullw m2, [r5+32]
+ pmullw m3, [r5+48]
+ pmullw m4, [r5+64]
+ pmullw m5, [r5+80]
+%endif
+ paddsw m1, m4
+ paddsw m0, m5
+ paddsw m1, m2
+ paddsw m0, m3
+ paddsw m0, m1
+ paddsw m0, m6
psraw m0, 7
packuswb m0, m7
movh [r0], m0 ; store
@@ -549,7 +548,7 @@ cglobal put_vp8_epel8_h6_sse2, 6, 6, 8
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
@@ -602,7 +601,7 @@ cglobal put_vp8_epel%2_v4_%1, 7, 7, %3
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
@@ -667,7 +666,7 @@ cglobal put_vp8_epel%2_v6_%1, 7, 7, %3
; go to next line
add r0, r1
add r2, r3
- dec r4 ; next row
+ dec r4d ; next row
jg .nextrow
REP_RET
%endmacro
@@ -719,7 +718,7 @@ cglobal put_vp8_bilinear%2_v_%1, 7,7,%3
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
- sub r4, 2
+ sub r4d, 2
jg .nextrow
REP_RET
@@ -765,7 +764,7 @@ cglobal put_vp8_bilinear%2_h_%1, 7,7,%3
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
- sub r4, 2
+ sub r4d, 2
jg .nextrow
REP_RET
%endmacro
@@ -808,7 +807,7 @@ cglobal put_vp8_bilinear%1_v_ssse3, 7,7
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
- sub r4, 2
+ sub r4d, 2
jg .nextrow
REP_RET
@@ -844,7 +843,7 @@ cglobal put_vp8_bilinear%1_h_ssse3, 7,7
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
- sub r4, 2
+ sub r4d, 2
jg .nextrow
REP_RET
%endmacro
@@ -895,74 +894,189 @@ cglobal put_vp8_pixels16_sse, 5,5,2
REP_RET
;-----------------------------------------------------------------------------
-; IDCT functions:
-;
; void vp8_idct_dc_add_<opt>(uint8_t *dst, DCTELEM block[16], int stride);
;-----------------------------------------------------------------------------
+%macro ADD_DC 4
+ %4 m2, [r0+%3]
+ %4 m3, [r0+r2+%3]
+ %4 m4, [r1+%3]
+ %4 m5, [r1+r2+%3]
+ paddusb m2, %1
+ paddusb m3, %1
+ paddusb m4, %1
+ paddusb m5, %1
+ psubusb m2, %2
+ psubusb m3, %2
+ psubusb m4, %2
+ psubusb m5, %2
+ %4 [r0+%3], m2
+ %4 [r0+r2+%3], m3
+ %4 [r1+%3], m4
+ %4 [r1+r2+%3], m5
+%endmacro
+
+INIT_MMX
cglobal vp8_idct_dc_add_mmx, 3, 3
; load data
- movd mm0, [r1]
+ movd m0, [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
+ paddw m0, [pw_4]
+ pxor m1, m1
+ psraw m0, 3
+ movd [r1], m1
+ psubw m1, m0
+ packuswb m0, m0
+ packuswb m1, m1
+ punpcklbw m0, m0
+ punpcklbw m1, m1
+ punpcklwd m0, m0
+ punpcklwd m1, m1
; 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
+ lea r1, [r0+r2*2]
+ ADD_DC m0, m1, 0, movh
RET
+INIT_XMM
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]
+ movd m0, [r1]
+ pxor m1, m1
; 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
+ paddw m0, [pw_4]
+ movd [r1], m1
+ lea r1, [r0+r2*2]
+ movd m2, [r0]
+ movd m3, [r0+r2]
+ movd m4, [r1]
+ movd m5, [r1+r2]
+ psraw m0, 3
+ pshuflw m0, m0, 0
+ punpcklqdq m0, m0
+ punpckldq m2, m3
+ punpckldq m4, m5
+ punpcklbw m2, m1
+ punpcklbw m4, m1
+ paddw m2, m0
+ paddw m4, m0
+ packuswb m2, m4
+ movd [r0], m2
+ pextrd [r0+r2], m2, 1
+ pextrd [r1], m2, 2
+ pextrd [r1+r2], m2, 3
+ RET
+
+;-----------------------------------------------------------------------------
+; void vp8_idct_dc_add4y_<opt>(uint8_t *dst, DCTELEM block[4][16], int stride);
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal vp8_idct_dc_add4y_mmx, 3, 3
+ ; load data
+ movd m0, [r1+32*0] ; A
+ movd m1, [r1+32*2] ; C
+ punpcklwd m0, [r1+32*1] ; A B
+ punpcklwd m1, [r1+32*3] ; C D
+ punpckldq m0, m1 ; A B C D
+ pxor m6, m6
+
+ ; calculate DC
+ paddw m0, [pw_4]
+ movd [r1+32*0], m6
+ movd [r1+32*1], m6
+ movd [r1+32*2], m6
+ movd [r1+32*3], m6
+ psraw m0, 3
+ psubw m6, m0
+ packuswb m0, m0
+ packuswb m6, m6
+ punpcklbw m0, m0 ; AABBCCDD
+ punpcklbw m6, m6 ; AABBCCDD
+ movq m1, m0
+ movq m7, m6
+ punpcklbw m0, m0 ; AAAABBBB
+ punpckhbw m1, m1 ; CCCCDDDD
+ punpcklbw m6, m6 ; AAAABBBB
+ punpckhbw m7, m7 ; CCCCDDDD
+
+ ; add DC
+ lea r1, [r0+r2*2]
+ ADD_DC m0, m6, 0, mova
+ ADD_DC m1, m7, 8, mova
+ RET
+
+INIT_XMM
+cglobal vp8_idct_dc_add4y_sse2, 3, 3, 6
+ ; load data
+ movd m0, [r1+32*0] ; A
+ movd m1, [r1+32*2] ; C
+ punpcklwd m0, [r1+32*1] ; A B
+ punpcklwd m1, [r1+32*3] ; C D
+ punpckldq m0, m1 ; A B C D
+ pxor m1, m1
+
+ ; calculate DC
+ paddw m0, [pw_4]
+ movd [r1+32*0], m1
+ movd [r1+32*1], m1
+ movd [r1+32*2], m1
+ movd [r1+32*3], m1
+ psraw m0, 3
+ psubw m1, m0
+ packuswb m0, m0
+ packuswb m1, m1
+ punpcklbw m0, m0
+ punpcklbw m1, m1
+ punpcklbw m0, m0
+ punpcklbw m1, m1
+
+ ; add DC
+ lea r1, [r0+r2*2]
+ ADD_DC m0, m1, 0, mova
+ RET
+
+;-----------------------------------------------------------------------------
+; void vp8_idct_dc_add4uv_<opt>(uint8_t *dst, DCTELEM block[4][16], int stride);
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal vp8_idct_dc_add4uv_mmx, 3, 3
+ ; load data
+ movd m0, [r1+32*0] ; A
+ movd m1, [r1+32*2] ; C
+ punpcklwd m0, [r1+32*1] ; A B
+ punpcklwd m1, [r1+32*3] ; C D
+ punpckldq m0, m1 ; A B C D
+ pxor m6, m6
+
+ ; calculate DC
+ paddw m0, [pw_4]
+ movd [r1+32*0], m6
+ movd [r1+32*1], m6
+ movd [r1+32*2], m6
+ movd [r1+32*3], m6
+ psraw m0, 3
+ psubw m6, m0
+ packuswb m0, m0
+ packuswb m6, m6
+ punpcklbw m0, m0 ; AABBCCDD
+ punpcklbw m6, m6 ; AABBCCDD
+ movq m1, m0
+ movq m7, m6
+ punpcklbw m0, m0 ; AAAABBBB
+ punpckhbw m1, m1 ; CCCCDDDD
+ punpcklbw m6, m6 ; AAAABBBB
+ punpckhbw m7, m7 ; CCCCDDDD
+
+ ; add DC
+ lea r1, [r0+r2*2]
+ ADD_DC m0, m6, 0, mova
+ lea r0, [r0+r2*4]
+ lea r1, [r1+r2*4]
+ ADD_DC m1, m7, 0, mova
RET
;-----------------------------------------------------------------------------
@@ -1001,14 +1115,26 @@ cglobal vp8_idct_dc_add_sse4, 3, 3, 6
%endmacro
INIT_MMX
-cglobal vp8_idct_add_mmx, 3, 3
+%macro VP8_IDCT_ADD 1
+cglobal vp8_idct_add_%1, 3, 3
; load block data
- movq m0, [r1]
- movq m1, [r1+8]
+ movq m0, [r1+ 0]
+ movq m1, [r1+ 8]
movq m2, [r1+16]
movq m3, [r1+24]
movq m6, [pw_20091]
movq m7, [pw_17734]
+%ifidn %1, sse
+ xorps xmm0, xmm0
+ movaps [r1+ 0], xmm0
+ movaps [r1+16], xmm0
+%else
+ pxor m4, m4
+ movq [r1+ 0], m4
+ movq [r1+ 8], m4
+ movq [r1+16], m4
+ movq [r1+24], m4
+%endif
; actual IDCT
VP8_IDCT_TRANSFORM4x4_1D 0, 1, 2, 3, 4, 5
@@ -1024,20 +1150,34 @@ cglobal vp8_idct_add_mmx, 3, 3
STORE_DIFFx2 m2, m3, m6, m7, m4, 3, r1, r2
RET
+%endmacro
+
+VP8_IDCT_ADD mmx
+VP8_IDCT_ADD sse
;-----------------------------------------------------------------------------
; 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
+%macro SCATTER_WHT 3
+ movd r1d, m%1
+ movd r2d, m%2
+ mov [r0+2*16*(0+%3)], r1w
+ mov [r0+2*16*(1+%3)], r2w
+ shr r1d, 16
+ shr r2d, 16
+ psrlq m%1, 32
+ psrlq m%2, 32
+ mov [r0+2*16*(4+%3)], r1w
+ mov [r0+2*16*(5+%3)], r2w
+ movd r1d, m%1
+ movd r2d, m%2
+ mov [r0+2*16*(8+%3)], r1w
+ mov [r0+2*16*(9+%3)], r2w
+ shr r1d, 16
+ shr r2d, 16
+ mov [r0+2*16*(12+%3)], r1w
+ mov [r0+2*16*(13+%3)], r2w
%endmacro
%macro HADAMARD4_1D 4
@@ -1046,12 +1186,23 @@ cglobal vp8_idct_add_mmx, 3, 3
SWAP %1, %4, %3
%endmacro
-INIT_MMX
-cglobal vp8_luma_dc_wht_mmxext, 2,3
+%macro VP8_DC_WHT 1
+cglobal vp8_luma_dc_wht_%1, 2,3
movq m0, [r1]
movq m1, [r1+8]
movq m2, [r1+16]
movq m3, [r1+24]
+%ifidn %1, sse
+ xorps xmm0, xmm0
+ movaps [r1+ 0], xmm0
+ movaps [r1+16], xmm0
+%else
+ pxor m4, m4
+ movq [r1+ 0], m4
+ movq [r1+ 8], m4
+ movq [r1+16], m4
+ movq [r1+24], m4
+%endif
HADAMARD4_1D 0, 1, 2, 3
TRANSPOSE4x4W 0, 1, 2, 3, 4
paddw m0, [pw_3]
@@ -1060,14 +1211,14 @@ cglobal vp8_luma_dc_wht_mmxext, 2,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
+ SCATTER_WHT 0, 1, 0
+ SCATTER_WHT 2, 3, 2
RET
+%endmacro
+
+INIT_MMX
+VP8_DC_WHT mmx
+VP8_DC_WHT sse
;-----------------------------------------------------------------------------
; void vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim);
@@ -1163,12 +1314,16 @@ cglobal vp8_luma_dc_wht_mmxext, 2,3
; 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
+; the 10th argument is 16 if it's a Y filter (i.e. all regular registers cover the
+; same memory region), or 8 if they cover two separate buffers (third one points to
+; a different memory region than the first two), allowing for more optimal code for
+; the 16-width case
+%macro WRITE_4x4D 10
; 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
+ movd [%7+%8*4], m%3
+ movd [%7], m%4
; store dwords 1
psrldq m%1, 4
@@ -1177,15 +1332,23 @@ cglobal vp8_luma_dc_wht_mmxext, 2,3
psrldq m%4, 4
movd [%6+%8*4], m%1
movd [%6], m%2
+%if %10 == 16
movd [%6+%9*4], m%3
- movd [%6+%9*8], m%4
+%endif
+ movd [%7+%9], m%4
; write dwords 2
psrldq m%1, 4
psrldq m%2, 4
+%if %10 == 8
+ movd [%5+%8*2], m%1
+ movd %5d, m%3
+%endif
psrldq m%3, 4
psrldq m%4, 4
+%if %10 == 16
movd [%5+%8*2], m%1
+%endif
movd [%6+%9], m%2
movd [%7+%8*2], m%3
movd [%7+%9*2], m%4
@@ -1196,41 +1359,134 @@ cglobal vp8_luma_dc_wht_mmxext, 2,3
psrldq m%2, 4
psrldq m%3, 4
psrldq m%4, 4
+%if %10 == 8
+ mov [%7+%8*4], %5d
+ movd [%6+%8*2], m%1
+%else
movd [%5+%8], m%1
+%endif
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
+; write 4 or 8 words in the mmx/xmm registers as 8 lines
+; 1 and 2 are the registers to write, this can be the same (for SSE2)
+; for pre-SSE4:
+; 3 is a general-purpose register that we will clobber
+; for SSE4:
+; 3 is a pointer to the destination's 5th line
+; 4 is a pointer to the destination's 4th line
+; 5/6 is -stride and +stride
+%macro WRITE_2x4W 6
+ movd %3d, %1
+ punpckhdq %1, %1
+ mov [%4+%5*4], %3w
+ shr %3, 16
+ add %4, %6
+ mov [%4+%5*4], %3w
+
+ movd %3d, %1
+ add %4, %5
+ mov [%4+%5*2], %3w
+ shr %3, 16
+ mov [%4+%5 ], %3w
+
+ movd %3d, %2
+ punpckhdq %2, %2
+ mov [%4 ], %3w
+ shr %3, 16
+ mov [%4+%6 ], %3w
+
+ movd %3d, %2
+ add %4, %6
+ mov [%4+%6 ], %3w
+ shr %3, 16
+ mov [%4+%6*2], %3w
+ add %4, %5
+%endmacro
+
+%macro WRITE_8W_SSE2 5
+ movd %2d, %1
+ psrldq %1, 4
+ mov [%3+%4*4], %2w
+ shr %2, 16
+ add %3, %5
+ mov [%3+%4*4], %2w
+
+ movd %2d, %1
+ psrldq %1, 4
+ add %3, %4
+ mov [%3+%4*2], %2w
+ shr %2, 16
+ mov [%3+%4 ], %2w
+
+ movd %2d, %1
+ psrldq %1, 4
+ mov [%3 ], %2w
+ shr %2, 16
+ mov [%3+%5 ], %2w
+
+ movd %2d, %1
+ add %3, %5
+ mov [%3+%5 ], %2w
+ shr %2, 16
+ mov [%3+%5*2], %2w
+%endmacro
+
+%macro WRITE_8W_SSE4 5
+ pextrw [%3+%4*4], %1, 0
+ pextrw [%2+%4*4], %1, 1
+ pextrw [%3+%4*2], %1, 2
+ pextrw [%3+%4 ], %1, 3
+ pextrw [%3 ], %1, 4
+ pextrw [%2 ], %1, 5
+ pextrw [%2+%5 ], %1, 6
+ pextrw [%2+%5*2], %1, 7
+%endmacro
+
+%macro SPLATB_REG_MMX 2-3
+ movd %1, %2d
+ punpcklbw %1, %1
+ punpcklwd %1, %1
+ punpckldq %1, %1
+%endmacro
+
+%macro SPLATB_REG_MMXEXT 2-3
+ movd %1, %2d
+ punpcklbw %1, %1
+ pshufw %1, %1, 0x0
+%endmacro
+
+%macro SPLATB_REG_SSE2 2-3
+ movd %1, %2d
+ punpcklbw %1, %1
+ pshuflw %1, %1, 0x0
+ punpcklqdq %1, %1
+%endmacro
+
+%macro SPLATB_REG_SSSE3 3
+ movd %1, %2d
+ pshufb %1, %3
+%endmacro
+
+%macro SIMPLE_LOOPFILTER 4
+cglobal vp8_%2_loop_filter_simple_%1, 3, %3, %4
%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
+%ifnidn %1, sse2
+%if mmsize == 16
+ pxor m0, m0
%endif
+%endif
+ SPLATB_REG m7, r2, m0 ; splat "flim" into register
; 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
@@ -1251,9 +1507,6 @@ cglobal vp8_%2_loop_filter_simple_%1, 3, %3
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
@@ -1324,17 +1577,21 @@ cglobal vp8_%2_loop_filter_simple_%1, 3, %3
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
+ inc r0
+ SBUTTERFLY bw, 6, 4, 0
- 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
+%ifidn %1, sse4
+ inc r4
+%endif
+ WRITE_8W m6, r4, r0, r1, r2
+ lea r4, [r3+r1+1]
+%ifidn %1, sse4
+ inc r3
+%endif
+ WRITE_8W m4, r3, r4, r1, r2
%else ; mmx/mmxext
- WRITE_4x2D 0, 1, 2, 3, r0, r4, r1, r2
+ WRITE_2x4W m6, m4, r4, r0, r1, r2
%endif
%endif
@@ -1343,29 +1600,1259 @@ cglobal vp8_%2_loop_filter_simple_%1, 3, %3
%ifidn %2, v
add r0, 8 ; advance 8 cols = pixels
%else ; h
- lea r0, [r0+r2*8] ; advance 8 rows = lines
+ lea r0, [r0+r2*8-1] ; advance 8 rows = lines
%endif
dec r3
jg .next8px
-%ifidn %2, v
REP_RET
-%else ; h
- mov rsp, r5 ; restore stack pointer
+%else ; sse2
RET
%endif
-%else ; sse2
+%endmacro
+
+INIT_MMX
+%define SPLATB_REG SPLATB_REG_MMX
+SIMPLE_LOOPFILTER mmx, v, 4, 0
+SIMPLE_LOOPFILTER mmx, h, 5, 0
+%define SPLATB_REG SPLATB_REG_MMXEXT
+SIMPLE_LOOPFILTER mmxext, v, 4, 0
+SIMPLE_LOOPFILTER mmxext, h, 5, 0
+INIT_XMM
+%define SPLATB_REG SPLATB_REG_SSE2
+%define WRITE_8W WRITE_8W_SSE2
+SIMPLE_LOOPFILTER sse2, v, 3, 8
+SIMPLE_LOOPFILTER sse2, h, 5, 8
+%define SPLATB_REG SPLATB_REG_SSSE3
+SIMPLE_LOOPFILTER ssse3, v, 3, 8
+SIMPLE_LOOPFILTER ssse3, h, 5, 8
+%define WRITE_8W WRITE_8W_SSE4
+SIMPLE_LOOPFILTER sse4, h, 5, 8
+
+;-----------------------------------------------------------------------------
+; void vp8_h/v_loop_filter<size>_inner_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
+; int flimE, int flimI, int hev_thr);
+;-----------------------------------------------------------------------------
+
+%macro INNER_LOOPFILTER 5
+%if %4 == 8 ; chroma
+cglobal vp8_%2_loop_filter8uv_inner_%1, 6, %3, %5
+%define dst8_reg r1
+%define mstride_reg r2
+%define E_reg r3
+%define I_reg r4
+%define hev_thr_reg r5
+%else ; luma
+cglobal vp8_%2_loop_filter16y_inner_%1, 5, %3, %5
+%define mstride_reg r1
+%define E_reg r2
+%define I_reg r3
+%define hev_thr_reg r4
+%ifdef m8 ; x86-64, sse2
+%define dst8_reg r4
+%elif mmsize == 16 ; x86-32, sse2
+%define dst8_reg r5
+%else ; x86-32, mmx/mmxext
+%define cnt_reg r5
+%endif
+%endif
+%define dst_reg r0
+%define stride_reg E_reg
+%define dst2_reg I_reg
+%ifndef m8
+%define stack_reg hev_thr_reg
+%endif
+
+%ifnidn %1, sse2
+%if mmsize == 16
+ pxor m7, m7
+%endif
+%endif
+
+%ifndef m8 ; mmx/mmxext or sse2 on x86-32
+ ; splat function arguments
+ SPLATB_REG m0, E_reg, m7 ; E
+ SPLATB_REG m1, I_reg, m7 ; I
+ SPLATB_REG m2, hev_thr_reg, m7 ; hev_thresh
+
+ ; align stack
+ mov stack_reg, rsp ; backup stack pointer
+ and rsp, ~(mmsize-1) ; align stack
+%ifidn %2, v
+ sub rsp, mmsize * 4 ; stack layout: [0]=E, [1]=I, [2]=hev_thr
+ ; [3]=hev() result
+%else ; h
+ sub rsp, mmsize * 5 ; extra storage space for transposes
+%endif
+
+%define flim_E [rsp]
+%define flim_I [rsp+mmsize]
+%define hev_thr [rsp+mmsize*2]
+%define mask_res [rsp+mmsize*3]
+%define p0backup [rsp+mmsize*3]
+%define q0backup [rsp+mmsize*4]
+
+ mova flim_E, m0
+ mova flim_I, m1
+ mova hev_thr, m2
+
+%else ; sse2 on x86-64
+
+%define flim_E m9
+%define flim_I m10
+%define hev_thr m11
+%define mask_res m12
+%define p0backup m12
+%define q0backup m8
+
+ ; splat function arguments
+ SPLATB_REG flim_E, E_reg, m7 ; E
+ SPLATB_REG flim_I, I_reg, m7 ; I
+ SPLATB_REG hev_thr, hev_thr_reg, m7 ; hev_thresh
+%endif
+
+%if mmsize == 8 && %4 == 16 ; mmx/mmxext
+ mov cnt_reg, 2
+%endif
+ mov stride_reg, mstride_reg
+ neg mstride_reg
+%ifidn %2, h
+ lea dst_reg, [dst_reg + stride_reg*4-4]
+%if %4 == 8
+ lea dst8_reg, [dst8_reg+ stride_reg*4-4]
+%endif
+%endif
+
+%if mmsize == 8
+.next8px
+%endif
+ ; read
+ lea dst2_reg, [dst_reg + stride_reg]
+%ifidn %2, v
+%if %4 == 8 && mmsize == 16
+%define movrow movh
+%else
+%define movrow mova
+%endif
+ movrow m0, [dst_reg +mstride_reg*4] ; p3
+ movrow m1, [dst2_reg+mstride_reg*4] ; p2
+ movrow m2, [dst_reg +mstride_reg*2] ; p1
+ movrow m5, [dst2_reg] ; q1
+ movrow m6, [dst2_reg+ stride_reg] ; q2
+ movrow m7, [dst2_reg+ stride_reg*2] ; q3
+%if mmsize == 16 && %4 == 8
+ movhps m0, [dst8_reg+mstride_reg*4]
+ movhps m2, [dst8_reg+mstride_reg*2]
+ add dst8_reg, stride_reg
+ movhps m1, [dst8_reg+mstride_reg*4]
+ movhps m5, [dst8_reg]
+ movhps m6, [dst8_reg+ stride_reg]
+ movhps m7, [dst8_reg+ stride_reg*2]
+ add dst8_reg, mstride_reg
+%endif
+%elif mmsize == 8 ; mmx/mmxext (h)
+ ; read 8 rows of 8px each
+ movu m0, [dst_reg +mstride_reg*4]
+ movu m1, [dst2_reg+mstride_reg*4]
+ movu m2, [dst_reg +mstride_reg*2]
+ movu m3, [dst_reg +mstride_reg]
+ movu m4, [dst_reg]
+ movu m5, [dst2_reg]
+ movu m6, [dst2_reg+ stride_reg]
+
+ ; 8x8 transpose
+ TRANSPOSE4x4B 0, 1, 2, 3, 7
+ mova q0backup, m1
+ movu m7, [dst2_reg+ stride_reg*2]
+ TRANSPOSE4x4B 4, 5, 6, 7, 1
+ SBUTTERFLY dq, 0, 4, 1 ; p3/p2
+ SBUTTERFLY dq, 2, 6, 1 ; q0/q1
+ SBUTTERFLY dq, 3, 7, 1 ; q2/q3
+ mova m1, q0backup
+ mova q0backup, m2 ; store q0
+ SBUTTERFLY dq, 1, 5, 2 ; p1/p0
+ mova p0backup, m5 ; store p0
+ SWAP 1, 4
+ SWAP 2, 4
+ SWAP 6, 3
+ SWAP 5, 3
+%else ; sse2 (h)
+%if %4 == 16
+ lea dst8_reg, [dst_reg + stride_reg*8]
+%endif
+
+ ; read 16 rows of 8px each, interleave
+ movh m0, [dst_reg +mstride_reg*4]
+ movh m1, [dst8_reg+mstride_reg*4]
+ movh m2, [dst_reg +mstride_reg*2]
+ movh m5, [dst8_reg+mstride_reg*2]
+ movh m3, [dst_reg +mstride_reg]
+ movh m6, [dst8_reg+mstride_reg]
+ movh m4, [dst_reg]
+ movh m7, [dst8_reg]
+ punpcklbw m0, m1 ; A/I
+ punpcklbw m2, m5 ; C/K
+ punpcklbw m3, m6 ; D/L
+ punpcklbw m4, m7 ; E/M
+
+ add dst8_reg, stride_reg
+ movh m1, [dst2_reg+mstride_reg*4]
+ movh m6, [dst8_reg+mstride_reg*4]
+ movh m5, [dst2_reg]
+ movh m7, [dst8_reg]
+ punpcklbw m1, m6 ; B/J
+ punpcklbw m5, m7 ; F/N
+ movh m6, [dst2_reg+ stride_reg]
+ movh m7, [dst8_reg+ stride_reg]
+ punpcklbw m6, m7 ; G/O
+
+ ; 8x16 transpose
+ TRANSPOSE4x4B 0, 1, 2, 3, 7
+%ifdef m8
+ SWAP 1, 8
+%else
+ mova q0backup, m1
+%endif
+ movh m7, [dst2_reg+ stride_reg*2]
+ movh m1, [dst8_reg+ stride_reg*2]
+ punpcklbw m7, m1 ; H/P
+ TRANSPOSE4x4B 4, 5, 6, 7, 1
+ SBUTTERFLY dq, 0, 4, 1 ; p3/p2
+ SBUTTERFLY dq, 2, 6, 1 ; q0/q1
+ SBUTTERFLY dq, 3, 7, 1 ; q2/q3
+%ifdef m8
+ SWAP 1, 8
+ SWAP 2, 8
+%else
+ mova m1, q0backup
+ mova q0backup, m2 ; store q0
+%endif
+ SBUTTERFLY dq, 1, 5, 2 ; p1/p0
+%ifdef m12
+ SWAP 5, 12
+%else
+ mova p0backup, m5 ; store p0
+%endif
+ SWAP 1, 4
+ SWAP 2, 4
+ SWAP 6, 3
+ SWAP 5, 3
+%endif
+
+ ; normal_limit for p3-p2, p2-p1, q3-q2 and q2-q1
+ mova m4, m1
+ SWAP 4, 1
+ psubusb m4, m0 ; p2-p3
+ psubusb m0, m1 ; p3-p2
+ por m0, m4 ; abs(p3-p2)
+
+ mova m4, m2
+ SWAP 4, 2
+ psubusb m4, m1 ; p1-p2
+ psubusb m1, m2 ; p2-p1
+ por m1, m4 ; abs(p2-p1)
+
+ mova m4, m6
+ SWAP 4, 6
+ psubusb m4, m7 ; q2-q3
+ psubusb m7, m6 ; q3-q2
+ por m7, m4 ; abs(q3-q2)
+
+ mova m4, m5
+ SWAP 4, 5
+ psubusb m4, m6 ; q1-q2
+ psubusb m6, m5 ; q2-q1
+ por m6, m4 ; abs(q2-q1)
+
+%ifidn %1, mmx
+ mova m4, flim_I
+ pxor m3, m3
+ psubusb m0, m4
+ psubusb m1, m4
+ psubusb m7, m4
+ psubusb m6, m4
+ pcmpeqb m0, m3 ; abs(p3-p2) <= I
+ pcmpeqb m1, m3 ; abs(p2-p1) <= I
+ pcmpeqb m7, m3 ; abs(q3-q2) <= I
+ pcmpeqb m6, m3 ; abs(q2-q1) <= I
+ pand m0, m1
+ pand m7, m6
+ pand m0, m7
+%else ; mmxext/sse2
+ pmaxub m0, m1
+ pmaxub m6, m7
+ pmaxub m0, m6
+%endif
+
+ ; normal_limit and high_edge_variance for p1-p0, q1-q0
+ SWAP 7, 3 ; now m7 is zero
+%ifidn %2, v
+ movrow m3, [dst_reg +mstride_reg] ; p0
+%if mmsize == 16 && %4 == 8
+ movhps m3, [dst8_reg+mstride_reg]
+%endif
+%elifdef m12
+ SWAP 3, 12
+%else
+ mova m3, p0backup
+%endif
+
+ mova m1, m2
+ SWAP 1, 2
+ mova m6, m3
+ SWAP 3, 6
+ psubusb m1, m3 ; p1-p0
+ psubusb m6, m2 ; p0-p1
+ por m1, m6 ; abs(p1-p0)
+%ifidn %1, mmx
+ mova m6, m1
+ psubusb m1, m4
+ psubusb m6, hev_thr
+ pcmpeqb m1, m7 ; abs(p1-p0) <= I
+ pcmpeqb m6, m7 ; abs(p1-p0) <= hev_thresh
+ pand m0, m1
+ mova mask_res, m6
+%else ; mmxext/sse2
+ pmaxub m0, m1 ; max_I
+ SWAP 1, 4 ; max_hev_thresh
+%endif
+
+ SWAP 6, 4 ; now m6 is I
+%ifidn %2, v
+ movrow m4, [dst_reg] ; q0
+%if mmsize == 16 && %4 == 8
+ movhps m4, [dst8_reg]
+%endif
+%elifdef m8
+ SWAP 4, 8
+%else
+ mova m4, q0backup
+%endif
+ mova m1, m4
+ SWAP 1, 4
+ mova m7, m5
+ SWAP 7, 5
+ psubusb m1, m5 ; q0-q1
+ psubusb m7, m4 ; q1-q0
+ por m1, m7 ; abs(q1-q0)
+%ifidn %1, mmx
+ mova m7, m1
+ psubusb m1, m6
+ psubusb m7, hev_thr
+ pxor m6, m6
+ pcmpeqb m1, m6 ; abs(q1-q0) <= I
+ pcmpeqb m7, m6 ; abs(q1-q0) <= hev_thresh
+ mova m6, mask_res
+ pand m0, m1 ; abs([pq][321]-[pq][210]) <= I
+ pand m6, m7
+%else ; mmxext/sse2
+ pxor m7, m7
+ pmaxub m0, m1
+ pmaxub m6, m1
+ psubusb m0, flim_I
+ psubusb m6, hev_thr
+ pcmpeqb m0, m7 ; max(abs(..)) <= I
+ pcmpeqb m6, m7 ; !(max(abs..) > thresh)
+%endif
+%ifdef m12
+ SWAP 6, 12
+%else
+ mova mask_res, m6 ; !(abs(p1-p0) > hev_t || abs(q1-q0) > hev_t)
+%endif
+
+ ; simple_limit
+ mova m1, m3
+ SWAP 1, 3
+ mova m6, m4 ; keep copies of p0/q0 around for later use
+ SWAP 6, 4
+ psubusb m1, m4 ; p0-q0
+ psubusb m6, m3 ; q0-p0
+ por m1, m6 ; abs(q0-p0)
+ paddusb m1, m1 ; m1=2*abs(q0-p0)
+
+ mova m7, m2
+ SWAP 7, 2
+ mova m6, m5
+ SWAP 6, 5
+ psubusb m7, m5 ; p1-q1
+ psubusb m6, m2 ; q1-p1
+ por m7, m6 ; abs(q1-p1)
+ pxor m6, m6
+ pand m7, [pb_FE]
+ psrlq m7, 1 ; abs(q1-p1)/2
+ paddusb m7, m1 ; abs(q0-p0)*2+abs(q1-p1)/2
+ psubusb m7, flim_E
+ pcmpeqb m7, m6 ; abs(q0-p0)*2+abs(q1-p1)/2 <= E
+ pand m0, m7 ; normal_limit result
+
+ ; filter_common; at this point, m2-m5=p1-q1 and m0 is filter_mask
+%ifdef m8 ; x86-64 && sse2
+ mova m8, [pb_80]
+%define pb_80_var m8
+%else ; x86-32 or mmx/mmxext
+%define pb_80_var [pb_80]
+%endif
+ mova m1, m4
+ mova m7, m3
+ pxor m1, pb_80_var
+ pxor m7, pb_80_var
+ psubsb m1, m7 ; (signed) q0-p0
+ mova m6, m2
+ mova m7, m5
+ pxor m6, pb_80_var
+ pxor m7, pb_80_var
+ psubsb m6, m7 ; (signed) p1-q1
+ mova m7, mask_res
+ pandn m7, m6
+ paddsb m7, m1
+ paddsb m7, m1
+ paddsb m7, m1 ; 3*(q0-p0)+is4tap?(p1-q1)
+
+ pand m7, m0
+ mova m1, [pb_F8]
+ mova m6, m7
+ paddsb m7, [pb_3]
+ paddsb m6, [pb_4]
+ pand m7, m1
+ pand m6, m1
+
+ pxor m1, m1
+ pxor m0, m0
+ pcmpgtb m1, m7
+ psubb m0, m7
+ psrlq m7, 3 ; +f2
+ psrlq m0, 3 ; -f2
+ pand m0, m1
+ pandn m1, m7
+ psubusb m3, m0
+ paddusb m3, m1 ; p0+f2
+
+ pxor m1, m1
+ pxor m0, m0
+ pcmpgtb m0, m6
+ psubb m1, m6
+ psrlq m6, 3 ; +f1
+ psrlq m1, 3 ; -f1
+ pand m1, m0
+ pandn m0, m6
+ psubusb m4, m0
+ paddusb m4, m1 ; q0-f1
+
+%ifdef m12
+ SWAP 6, 12
+%else
+ mova m6, mask_res
+%endif
+%ifidn %1, mmx
+ mova m7, [pb_1]
+%else ; mmxext/sse2
+ pxor m7, m7
+%endif
+ pand m0, m6
+ pand m1, m6
+%ifidn %1, mmx
+ paddusb m0, m7
+ pand m1, [pb_FE]
+ pandn m7, m0
+ psrlq m1, 1
+ psrlq m7, 1
+ SWAP 0, 7
+%else ; mmxext/sse2
+ psubusb m1, [pb_1]
+ pavgb m0, m7 ; a
+ pavgb m1, m7 ; -a
+%endif
+ psubusb m5, m0
+ psubusb m2, m1
+ paddusb m5, m1 ; q1-a
+ paddusb m2, m0 ; p1+a
+
+ ; store
+%ifidn %2, v
+ movrow [dst_reg +mstride_reg*2], m2
+ movrow [dst_reg +mstride_reg ], m3
+ movrow [dst_reg], m4
+ movrow [dst_reg + stride_reg ], m5
+%if mmsize == 16 && %4 == 8
+ movhps [dst8_reg+mstride_reg*2], m2
+ movhps [dst8_reg+mstride_reg ], m3
+ movhps [dst8_reg], m4
+ movhps [dst8_reg+ stride_reg ], m5
+%endif
+%else ; h
+ add dst_reg, 2
+ add dst2_reg, 2
+
+ ; 4x8/16 transpose
+ TRANSPOSE4x4B 2, 3, 4, 5, 6
+
+%if mmsize == 8 ; mmx/mmxext (h)
+ WRITE_4x2D 2, 3, 4, 5, dst_reg, dst2_reg, mstride_reg, stride_reg
+%else ; sse2 (h)
+ lea dst8_reg, [dst8_reg+mstride_reg+2]
+ WRITE_4x4D 2, 3, 4, 5, dst_reg, dst2_reg, dst8_reg, mstride_reg, stride_reg, %4
+%endif
+%endif
+
+%if mmsize == 8
+%if %4 == 8 ; chroma
%ifidn %2, h
- mov rsp, r5 ; restore stack pointer
+ sub dst_reg, 2
+%endif
+ cmp dst_reg, dst8_reg
+ mov dst_reg, dst8_reg
+ jnz .next8px
+%else
+%ifidn %2, h
+ lea dst_reg, [dst_reg + stride_reg*8-2]
+%else ; v
+ add dst_reg, 8
+%endif
+ dec cnt_reg
+ jg .next8px
+%endif
+%endif
+
+%ifndef m8 ; sse2 on x86-32 or mmx/mmxext
+ mov rsp, stack_reg ; restore stack pointer
%endif
RET
+%endmacro
+
+INIT_MMX
+%define SPLATB_REG SPLATB_REG_MMX
+INNER_LOOPFILTER mmx, v, 6, 16, 0
+INNER_LOOPFILTER mmx, h, 6, 16, 0
+INNER_LOOPFILTER mmx, v, 6, 8, 0
+INNER_LOOPFILTER mmx, h, 6, 8, 0
+
+%define SPLATB_REG SPLATB_REG_MMXEXT
+INNER_LOOPFILTER mmxext, v, 6, 16, 0
+INNER_LOOPFILTER mmxext, h, 6, 16, 0
+INNER_LOOPFILTER mmxext, v, 6, 8, 0
+INNER_LOOPFILTER mmxext, h, 6, 8, 0
+
+INIT_XMM
+%define SPLATB_REG SPLATB_REG_SSE2
+INNER_LOOPFILTER sse2, v, 5, 16, 13
+%ifdef m8
+INNER_LOOPFILTER sse2, h, 5, 16, 13
+%else
+INNER_LOOPFILTER sse2, h, 6, 16, 13
+%endif
+INNER_LOOPFILTER sse2, v, 6, 8, 13
+INNER_LOOPFILTER sse2, h, 6, 8, 13
+
+%define SPLATB_REG SPLATB_REG_SSSE3
+INNER_LOOPFILTER ssse3, v, 5, 16, 13
+%ifdef m8
+INNER_LOOPFILTER ssse3, h, 5, 16, 13
+%else
+INNER_LOOPFILTER ssse3, h, 6, 16, 13
+%endif
+INNER_LOOPFILTER ssse3, v, 6, 8, 13
+INNER_LOOPFILTER ssse3, h, 6, 8, 13
+
+;-----------------------------------------------------------------------------
+; void vp8_h/v_loop_filter<size>_mbedge_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
+; int flimE, int flimI, int hev_thr);
+;-----------------------------------------------------------------------------
+
+%macro MBEDGE_LOOPFILTER 5
+%if %4 == 8 ; chroma
+cglobal vp8_%2_loop_filter8uv_mbedge_%1, 6, %3, %5
+%define dst8_reg r1
+%define mstride_reg r2
+%define E_reg r3
+%define I_reg r4
+%define hev_thr_reg r5
+%else ; luma
+cglobal vp8_%2_loop_filter16y_mbedge_%1, 5, %3, %5
+%define mstride_reg r1
+%define E_reg r2
+%define I_reg r3
+%define hev_thr_reg r4
+%ifdef m8 ; x86-64, sse2
+%define dst8_reg r4
+%elif mmsize == 16 ; x86-32, sse2
+%define dst8_reg r5
+%else ; x86-32, mmx/mmxext
+%define cnt_reg r5
%endif
+%endif
+%define dst_reg r0
+%define stride_reg E_reg
+%define dst2_reg I_reg
+%ifndef m8
+%define stack_reg hev_thr_reg
+%endif
+
+%define ssse3_or_higher 0
+%ifnidn %1, sse2
+%if mmsize == 16
+%define ssse3_or_higher 1
+%endif
+%endif
+
+%if ssse3_or_higher
+ pxor m7, m7
+%endif
+
+%ifndef m8 ; mmx/mmxext or sse2 on x86-32
+ ; splat function arguments
+ SPLATB_REG m0, E_reg, m7 ; E
+ SPLATB_REG m1, I_reg, m7 ; I
+ SPLATB_REG m2, hev_thr_reg, m7 ; hev_thresh
+
+ ; align stack
+ mov stack_reg, rsp ; backup stack pointer
+ and rsp, ~(mmsize-1) ; align stack
+%if mmsize == 16
+ sub rsp, mmsize * 7
+%else
+ sub rsp, mmsize * 8 ; stack layout: [0]=E, [1]=I, [2]=hev_thr
+ ; [3]=hev() result
+ ; [4]=filter tmp result
+ ; [5]/[6] = p2/q2 backup
+ ; [7]=lim_res sign result
+%endif
+
+%define flim_E [rsp]
+%define flim_I [rsp+mmsize]
+%define hev_thr [rsp+mmsize*2]
+%define mask_res [rsp+mmsize*3]
+%define lim_res [rsp+mmsize*4]
+%define p0backup [rsp+mmsize*3]
+%define q0backup [rsp+mmsize*4]
+%define p2backup [rsp+mmsize*5]
+%define q2backup [rsp+mmsize*6]
+%if mmsize == 16
+%define lim_sign [rsp]
+%else
+%define lim_sign [rsp+mmsize*7]
+%endif
+
+ mova flim_E, m0
+ mova flim_I, m1
+ mova hev_thr, m2
+
+%else ; sse2 on x86-64
+
+%define flim_E m9
+%define flim_I m10
+%define hev_thr m11
+%define mask_res m12
+%define lim_res m8
+%define p0backup m12
+%define q0backup m8
+%define p2backup m13
+%define q2backup m14
+%define lim_sign m9
+
+ ; splat function arguments
+ SPLATB_REG flim_E, E_reg, m7 ; E
+ SPLATB_REG flim_I, I_reg, m7 ; I
+ SPLATB_REG hev_thr, hev_thr_reg, m7 ; hev_thresh
+%endif
+
+%if mmsize == 8 && %4 == 16 ; mmx/mmxext
+ mov cnt_reg, 2
+%endif
+ mov stride_reg, mstride_reg
+ neg mstride_reg
+%ifidn %2, h
+ lea dst_reg, [dst_reg + stride_reg*4-4]
+%if %4 == 8
+ lea dst8_reg, [dst8_reg+ stride_reg*4-4]
+%endif
+%endif
+
+%if mmsize == 8
+.next8px
+%endif
+ ; read
+ lea dst2_reg, [dst_reg + stride_reg]
+%ifidn %2, v
+%if %4 == 8 && mmsize == 16
+%define movrow movh
+%else
+%define movrow mova
+%endif
+ movrow m0, [dst_reg +mstride_reg*4] ; p3
+ movrow m1, [dst2_reg+mstride_reg*4] ; p2
+ movrow m2, [dst_reg +mstride_reg*2] ; p1
+ movrow m5, [dst2_reg] ; q1
+ movrow m6, [dst2_reg+ stride_reg] ; q2
+ movrow m7, [dst2_reg+ stride_reg*2] ; q3
+%if mmsize == 16 && %4 == 8
+ movhps m0, [dst8_reg+mstride_reg*4]
+ movhps m2, [dst8_reg+mstride_reg*2]
+ add dst8_reg, stride_reg
+ movhps m1, [dst8_reg+mstride_reg*4]
+ movhps m5, [dst8_reg]
+ movhps m6, [dst8_reg+ stride_reg]
+ movhps m7, [dst8_reg+ stride_reg*2]
+ add dst8_reg, mstride_reg
+%endif
+%elif mmsize == 8 ; mmx/mmxext (h)
+ ; read 8 rows of 8px each
+ movu m0, [dst_reg +mstride_reg*4]
+ movu m1, [dst2_reg+mstride_reg*4]
+ movu m2, [dst_reg +mstride_reg*2]
+ movu m3, [dst_reg +mstride_reg]
+ movu m4, [dst_reg]
+ movu m5, [dst2_reg]
+ movu m6, [dst2_reg+ stride_reg]
+
+ ; 8x8 transpose
+ TRANSPOSE4x4B 0, 1, 2, 3, 7
+ mova q0backup, m1
+ movu m7, [dst2_reg+ stride_reg*2]
+ TRANSPOSE4x4B 4, 5, 6, 7, 1
+ SBUTTERFLY dq, 0, 4, 1 ; p3/p2
+ SBUTTERFLY dq, 2, 6, 1 ; q0/q1
+ SBUTTERFLY dq, 3, 7, 1 ; q2/q3
+ mova m1, q0backup
+ mova q0backup, m2 ; store q0
+ SBUTTERFLY dq, 1, 5, 2 ; p1/p0
+ mova p0backup, m5 ; store p0
+ SWAP 1, 4
+ SWAP 2, 4
+ SWAP 6, 3
+ SWAP 5, 3
+%else ; sse2 (h)
+%if %4 == 16
+ lea dst8_reg, [dst_reg + stride_reg*8]
+%endif
+
+ ; read 16 rows of 8px each, interleave
+ movh m0, [dst_reg +mstride_reg*4]
+ movh m1, [dst8_reg+mstride_reg*4]
+ movh m2, [dst_reg +mstride_reg*2]
+ movh m5, [dst8_reg+mstride_reg*2]
+ movh m3, [dst_reg +mstride_reg]
+ movh m6, [dst8_reg+mstride_reg]
+ movh m4, [dst_reg]
+ movh m7, [dst8_reg]
+ punpcklbw m0, m1 ; A/I
+ punpcklbw m2, m5 ; C/K
+ punpcklbw m3, m6 ; D/L
+ punpcklbw m4, m7 ; E/M
+
+ add dst8_reg, stride_reg
+ movh m1, [dst2_reg+mstride_reg*4]
+ movh m6, [dst8_reg+mstride_reg*4]
+ movh m5, [dst2_reg]
+ movh m7, [dst8_reg]
+ punpcklbw m1, m6 ; B/J
+ punpcklbw m5, m7 ; F/N
+ movh m6, [dst2_reg+ stride_reg]
+ movh m7, [dst8_reg+ stride_reg]
+ punpcklbw m6, m7 ; G/O
+
+ ; 8x16 transpose
+ TRANSPOSE4x4B 0, 1, 2, 3, 7
+%ifdef m8
+ SWAP 1, 8
+%else
+ mova q0backup, m1
+%endif
+ movh m7, [dst2_reg+ stride_reg*2]
+ movh m1, [dst8_reg+ stride_reg*2]
+ punpcklbw m7, m1 ; H/P
+ TRANSPOSE4x4B 4, 5, 6, 7, 1
+ SBUTTERFLY dq, 0, 4, 1 ; p3/p2
+ SBUTTERFLY dq, 2, 6, 1 ; q0/q1
+ SBUTTERFLY dq, 3, 7, 1 ; q2/q3
+%ifdef m8
+ SWAP 1, 8
+ SWAP 2, 8
+%else
+ mova m1, q0backup
+ mova q0backup, m2 ; store q0
+%endif
+ SBUTTERFLY dq, 1, 5, 2 ; p1/p0
+%ifdef m12
+ SWAP 5, 12
+%else
+ mova p0backup, m5 ; store p0
+%endif
+ SWAP 1, 4
+ SWAP 2, 4
+ SWAP 6, 3
+ SWAP 5, 3
+%endif
+
+ ; normal_limit for p3-p2, p2-p1, q3-q2 and q2-q1
+ mova m4, m1
+ SWAP 4, 1
+ psubusb m4, m0 ; p2-p3
+ psubusb m0, m1 ; p3-p2
+ por m0, m4 ; abs(p3-p2)
+
+ mova m4, m2
+ SWAP 4, 2
+ psubusb m4, m1 ; p1-p2
+ mova p2backup, m1
+ psubusb m1, m2 ; p2-p1
+ por m1, m4 ; abs(p2-p1)
+
+ mova m4, m6
+ SWAP 4, 6
+ psubusb m4, m7 ; q2-q3
+ psubusb m7, m6 ; q3-q2
+ por m7, m4 ; abs(q3-q2)
+
+ mova m4, m5
+ SWAP 4, 5
+ psubusb m4, m6 ; q1-q2
+ mova q2backup, m6
+ psubusb m6, m5 ; q2-q1
+ por m6, m4 ; abs(q2-q1)
+
+%ifidn %1, mmx
+ mova m4, flim_I
+ pxor m3, m3
+ psubusb m0, m4
+ psubusb m1, m4
+ psubusb m7, m4
+ psubusb m6, m4
+ pcmpeqb m0, m3 ; abs(p3-p2) <= I
+ pcmpeqb m1, m3 ; abs(p2-p1) <= I
+ pcmpeqb m7, m3 ; abs(q3-q2) <= I
+ pcmpeqb m6, m3 ; abs(q2-q1) <= I
+ pand m0, m1
+ pand m7, m6
+ pand m0, m7
+%else ; mmxext/sse2
+ pmaxub m0, m1
+ pmaxub m6, m7
+ pmaxub m0, m6
+%endif
+
+ ; normal_limit and high_edge_variance for p1-p0, q1-q0
+ SWAP 7, 3 ; now m7 is zero
+%ifidn %2, v
+ movrow m3, [dst_reg +mstride_reg] ; p0
+%if mmsize == 16 && %4 == 8
+ movhps m3, [dst8_reg+mstride_reg]
+%endif
+%elifdef m12
+ SWAP 3, 12
+%else
+ mova m3, p0backup
+%endif
+
+ mova m1, m2
+ SWAP 1, 2
+ mova m6, m3
+ SWAP 3, 6
+ psubusb m1, m3 ; p1-p0
+ psubusb m6, m2 ; p0-p1
+ por m1, m6 ; abs(p1-p0)
+%ifidn %1, mmx
+ mova m6, m1
+ psubusb m1, m4
+ psubusb m6, hev_thr
+ pcmpeqb m1, m7 ; abs(p1-p0) <= I
+ pcmpeqb m6, m7 ; abs(p1-p0) <= hev_thresh
+ pand m0, m1
+ mova mask_res, m6
+%else ; mmxext/sse2
+ pmaxub m0, m1 ; max_I
+ SWAP 1, 4 ; max_hev_thresh
+%endif
+
+ SWAP 6, 4 ; now m6 is I
+%ifidn %2, v
+ movrow m4, [dst_reg] ; q0
+%if mmsize == 16 && %4 == 8
+ movhps m4, [dst8_reg]
+%endif
+%elifdef m8
+ SWAP 4, 8
+%else
+ mova m4, q0backup
+%endif
+ mova m1, m4
+ SWAP 1, 4
+ mova m7, m5
+ SWAP 7, 5
+ psubusb m1, m5 ; q0-q1
+ psubusb m7, m4 ; q1-q0
+ por m1, m7 ; abs(q1-q0)
+%ifidn %1, mmx
+ mova m7, m1
+ psubusb m1, m6
+ psubusb m7, hev_thr
+ pxor m6, m6
+ pcmpeqb m1, m6 ; abs(q1-q0) <= I
+ pcmpeqb m7, m6 ; abs(q1-q0) <= hev_thresh
+ mova m6, mask_res
+ pand m0, m1 ; abs([pq][321]-[pq][210]) <= I
+ pand m6, m7
+%else ; mmxext/sse2
+ pxor m7, m7
+ pmaxub m0, m1
+ pmaxub m6, m1
+ psubusb m0, flim_I
+ psubusb m6, hev_thr
+ pcmpeqb m0, m7 ; max(abs(..)) <= I
+ pcmpeqb m6, m7 ; !(max(abs..) > thresh)
+%endif
+%ifdef m12
+ SWAP 6, 12
+%else
+ mova mask_res, m6 ; !(abs(p1-p0) > hev_t || abs(q1-q0) > hev_t)
+%endif
+
+ ; simple_limit
+ mova m1, m3
+ SWAP 1, 3
+ mova m6, m4 ; keep copies of p0/q0 around for later use
+ SWAP 6, 4
+ psubusb m1, m4 ; p0-q0
+ psubusb m6, m3 ; q0-p0
+ por m1, m6 ; abs(q0-p0)
+ paddusb m1, m1 ; m1=2*abs(q0-p0)
+
+ mova m7, m2
+ SWAP 7, 2
+ mova m6, m5
+ SWAP 6, 5
+ psubusb m7, m5 ; p1-q1
+ psubusb m6, m2 ; q1-p1
+ por m7, m6 ; abs(q1-p1)
+ pxor m6, m6
+ pand m7, [pb_FE]
+ psrlq m7, 1 ; abs(q1-p1)/2
+ paddusb m7, m1 ; abs(q0-p0)*2+abs(q1-p1)/2
+ psubusb m7, flim_E
+ pcmpeqb m7, m6 ; abs(q0-p0)*2+abs(q1-p1)/2 <= E
+ pand m0, m7 ; normal_limit result
+
+ ; filter_common; at this point, m2-m5=p1-q1 and m0 is filter_mask
+%ifdef m8 ; x86-64 && sse2
+ mova m8, [pb_80]
+%define pb_80_var m8
+%else ; x86-32 or mmx/mmxext
+%define pb_80_var [pb_80]
+%endif
+ mova m1, m4
+ mova m7, m3
+ pxor m1, pb_80_var
+ pxor m7, pb_80_var
+ psubsb m1, m7 ; (signed) q0-p0
+ mova m6, m2
+ mova m7, m5
+ pxor m6, pb_80_var
+ pxor m7, pb_80_var
+ psubsb m6, m7 ; (signed) p1-q1
+ mova m7, mask_res
+ paddsb m6, m1
+ paddsb m6, m1
+ paddsb m6, m1
+ pand m6, m0
+%ifdef m8
+ mova lim_res, m6 ; 3*(qp-p0)+(p1-q1) masked for filter_mbedge
+ pand lim_res, m7
+%else
+ mova m0, m6
+ pand m0, m7
+ mova lim_res, m0
+%endif
+ pandn m7, m6 ; 3*(q0-p0)+(p1-q1) masked for filter_common
+
+ mova m1, [pb_F8]
+ mova m6, m7
+ paddsb m7, [pb_3]
+ paddsb m6, [pb_4]
+ pand m7, m1
+ pand m6, m1
+
+ pxor m1, m1
+ pxor m0, m0
+ pcmpgtb m1, m7
+ psubb m0, m7
+ psrlq m7, 3 ; +f2
+ psrlq m0, 3 ; -f2
+ pand m0, m1
+ pandn m1, m7
+ psubusb m3, m0
+ paddusb m3, m1 ; p0+f2
+
+ pxor m1, m1
+ pxor m0, m0
+ pcmpgtb m0, m6
+ psubb m1, m6
+ psrlq m6, 3 ; +f1
+ psrlq m1, 3 ; -f1
+ pand m1, m0
+ pandn m0, m6
+ psubusb m4, m0
+ paddusb m4, m1 ; q0-f1
+
+ ; filter_mbedge (m2-m5 = p1-q1; lim_res carries w)
+%if ssse3_or_higher
+ mova m7, [pb_1]
+%else
+ mova m7, [pw_63]
+%endif
+%ifdef m8
+ SWAP 1, 8
+%else
+ mova m1, lim_res
+%endif
+ pxor m0, m0
+ mova m6, m1
+ pcmpgtb m0, m1 ; which are negative
+%if ssse3_or_higher
+ punpcklbw m6, m7 ; interleave with "1" for rounding
+ punpckhbw m1, m7
+%else
+ punpcklbw m6, m0 ; signed byte->word
+ punpckhbw m1, m0
+%endif
+ mova lim_sign, m0
+%if ssse3_or_higher
+ mova m7, [pb_27_63]
+%ifndef m8
+ mova lim_res, m1
+%endif
+%ifdef m10
+ SWAP 0, 10 ; don't lose lim_sign copy
+%endif
+ mova m0, m7
+ pmaddubsw m7, m6
+ SWAP 6, 7
+ pmaddubsw m0, m1
+ SWAP 1, 0
+%ifdef m10
+ SWAP 0, 10
+%else
+ mova m0, lim_sign
+%endif
+%else
+ mova mask_res, m6 ; backup for later in filter
+ mova lim_res, m1
+ pmullw m6, [pw_27]
+ pmullw m1, [pw_27]
+ paddw m6, m7
+ paddw m1, m7
+%endif
+ psraw m6, 7
+ psraw m1, 7
+ packsswb m6, m1 ; a0
+ pxor m1, m1
+ psubb m1, m6
+ pand m1, m0 ; -a0
+ pandn m0, m6 ; +a0
+%if ssse3_or_higher
+ mova m6, [pb_18_63] ; pipelining
+%endif
+ psubusb m3, m1
+ paddusb m4, m1
+ paddusb m3, m0 ; p0+a0
+ psubusb m4, m0 ; q0-a0
+
+%if ssse3_or_higher
+ SWAP 6, 7
+%ifdef m10
+ SWAP 1, 10
+%else
+ mova m1, lim_res
+%endif
+ mova m0, m7
+ pmaddubsw m7, m6
+ SWAP 6, 7
+ pmaddubsw m0, m1
+ SWAP 1, 0
+%ifdef m10
+ SWAP 0, 10
+%endif
+ mova m0, lim_sign
+%else
+ mova m6, mask_res
+ mova m1, lim_res
+ pmullw m6, [pw_18]
+ pmullw m1, [pw_18]
+ paddw m6, m7
+ paddw m1, m7
+%endif
+ mova m0, lim_sign
+ psraw m6, 7
+ psraw m1, 7
+ packsswb m6, m1 ; a1
+ pxor m1, m1
+ psubb m1, m6
+ pand m1, m0 ; -a1
+ pandn m0, m6 ; +a1
+%if ssse3_or_higher
+ mova m6, [pb_9_63]
+%endif
+ psubusb m2, m1
+ paddusb m5, m1
+ paddusb m2, m0 ; p1+a1
+ psubusb m5, m0 ; q1-a1
+
+%if ssse3_or_higher
+ SWAP 6, 7
+%ifdef m10
+ SWAP 1, 10
+%else
+ mova m1, lim_res
+%endif
+ mova m0, m7
+ pmaddubsw m7, m6
+ SWAP 6, 7
+ pmaddubsw m0, m1
+ SWAP 1, 0
+%else
+%ifdef m8
+ SWAP 6, 12
+ SWAP 1, 8
+%else
+ mova m6, mask_res
+ mova m1, lim_res
+%endif
+ pmullw m6, [pw_9]
+ pmullw m1, [pw_9]
+ paddw m6, m7
+ paddw m1, m7
+%endif
+%ifdef m9
+ SWAP 7, 9
+%else
+ mova m7, lim_sign
+%endif
+ psraw m6, 7
+ psraw m1, 7
+ packsswb m6, m1 ; a1
+ pxor m0, m0
+ psubb m0, m6
+ pand m0, m7 ; -a1
+ pandn m7, m6 ; +a1
+%ifdef m8
+ SWAP 1, 13
+ SWAP 6, 14
+%else
+ mova m1, p2backup
+ mova m6, q2backup
+%endif
+ psubusb m1, m0
+ paddusb m6, m0
+ paddusb m1, m7 ; p1+a1
+ psubusb m6, m7 ; q1-a1
+
+ ; store
+%ifidn %2, v
+ movrow [dst2_reg+mstride_reg*4], m1
+ movrow [dst_reg +mstride_reg*2], m2
+ movrow [dst_reg +mstride_reg ], m3
+ movrow [dst_reg], m4
+ movrow [dst2_reg], m5
+ movrow [dst2_reg+ stride_reg ], m6
+%if mmsize == 16 && %4 == 8
+ add dst8_reg, mstride_reg
+ movhps [dst8_reg+mstride_reg*2], m1
+ movhps [dst8_reg+mstride_reg ], m2
+ movhps [dst8_reg], m3
+ add dst8_reg, stride_reg
+ movhps [dst8_reg], m4
+ movhps [dst8_reg+ stride_reg ], m5
+ movhps [dst8_reg+ stride_reg*2], m6
+%endif
+%else ; h
+ inc dst_reg
+ inc dst2_reg
+
+ ; 4x8/16 transpose
+ TRANSPOSE4x4B 1, 2, 3, 4, 0
+ SBUTTERFLY bw, 5, 6, 0
+
+%if mmsize == 8 ; mmx/mmxext (h)
+ WRITE_4x2D 1, 2, 3, 4, dst_reg, dst2_reg, mstride_reg, stride_reg
+ add dst_reg, 4
+ WRITE_2x4W m5, m6, dst2_reg, dst_reg, mstride_reg, stride_reg
+%else ; sse2 (h)
+ lea dst8_reg, [dst8_reg+mstride_reg+1]
+ WRITE_4x4D 1, 2, 3, 4, dst_reg, dst2_reg, dst8_reg, mstride_reg, stride_reg, %4
+ lea dst_reg, [dst2_reg+mstride_reg+4]
+ lea dst8_reg, [dst8_reg+mstride_reg+4]
+%ifidn %1, sse4
+ add dst2_reg, 4
+%endif
+ WRITE_8W m5, dst2_reg, dst_reg, mstride_reg, stride_reg
+%ifidn %1, sse4
+ lea dst2_reg, [dst8_reg+ stride_reg]
+%endif
+ WRITE_8W m6, dst2_reg, dst8_reg, mstride_reg, stride_reg
+%endif
+%endif
+
+%if mmsize == 8
+%if %4 == 8 ; chroma
+%ifidn %2, h
+ sub dst_reg, 5
+%endif
+ cmp dst_reg, dst8_reg
+ mov dst_reg, dst8_reg
+ jnz .next8px
+%else
+%ifidn %2, h
+ lea dst_reg, [dst_reg + stride_reg*8-5]
+%else ; v
+ add dst_reg, 8
+%endif
+ dec cnt_reg
+ jg .next8px
+%endif
+%endif
+
+%ifndef m8 ; sse2 on x86-32 or mmx/mmxext
+ mov rsp, stack_reg ; restore stack pointer
+%endif
+ RET
%endmacro
INIT_MMX
-SIMPLE_LOOPFILTER mmx, v, 4
-SIMPLE_LOOPFILTER mmx, h, 6
-SIMPLE_LOOPFILTER mmxext, v, 4
-SIMPLE_LOOPFILTER mmxext, h, 6
+%define SPLATB_REG SPLATB_REG_MMX
+MBEDGE_LOOPFILTER mmx, v, 6, 16, 0
+MBEDGE_LOOPFILTER mmx, h, 6, 16, 0
+MBEDGE_LOOPFILTER mmx, v, 6, 8, 0
+MBEDGE_LOOPFILTER mmx, h, 6, 8, 0
+
+%define SPLATB_REG SPLATB_REG_MMXEXT
+MBEDGE_LOOPFILTER mmxext, v, 6, 16, 0
+MBEDGE_LOOPFILTER mmxext, h, 6, 16, 0
+MBEDGE_LOOPFILTER mmxext, v, 6, 8, 0
+MBEDGE_LOOPFILTER mmxext, h, 6, 8, 0
+
INIT_XMM
-SIMPLE_LOOPFILTER sse2, v, 3
-SIMPLE_LOOPFILTER sse2, h, 6
+%define SPLATB_REG SPLATB_REG_SSE2
+%define WRITE_8W WRITE_8W_SSE2
+MBEDGE_LOOPFILTER sse2, v, 5, 16, 15
+%ifdef m8
+MBEDGE_LOOPFILTER sse2, h, 5, 16, 15
+%else
+MBEDGE_LOOPFILTER sse2, h, 6, 16, 15
+%endif
+MBEDGE_LOOPFILTER sse2, v, 6, 8, 15
+MBEDGE_LOOPFILTER sse2, h, 6, 8, 15
+
+%define SPLATB_REG SPLATB_REG_SSSE3
+MBEDGE_LOOPFILTER ssse3, v, 5, 16, 15
+%ifdef m8
+MBEDGE_LOOPFILTER ssse3, h, 5, 16, 15
+%else
+MBEDGE_LOOPFILTER ssse3, h, 6, 16, 15
+%endif
+MBEDGE_LOOPFILTER ssse3, v, 6, 8, 15
+MBEDGE_LOOPFILTER ssse3, h, 6, 8, 15
+
+%define WRITE_8W WRITE_8W_SSE4
+%ifdef m8
+MBEDGE_LOOPFILTER sse4, h, 5, 16, 15
+%else
+MBEDGE_LOOPFILTER sse4, h, 6, 16, 15
+%endif
+MBEDGE_LOOPFILTER sse4, h, 6, 8, 15
diff --git a/lib/ffmpeg/libavcodec/x86/x86inc.asm b/lib/ffmpeg/libavcodec/x86/x86inc.asm
index 410b11bb28..b7d17742e4 100644
--- a/lib/ffmpeg/libavcodec/x86/x86inc.asm
+++ b/lib/ffmpeg/libavcodec/x86/x86inc.asm
@@ -271,13 +271,21 @@ DECLARE_REG 6, rax, eax, ax, al, [rsp + stack_offset + 56]
ASSERT %2 >= %1
%assign regs_used %2
ASSERT regs_used <= 7
- %assign xmm_regs_used %3
- ASSERT xmm_regs_used <= 16
%if regs_used > 4
push r4
push r5
%assign stack_offset stack_offset+16
%endif
+ WIN64_SPILL_XMM %3
+ LOAD_IF_USED 4, %1
+ LOAD_IF_USED 5, %1
+ LOAD_IF_USED 6, %1
+ DEFINE_ARGS %4
+%endmacro
+
+%macro WIN64_SPILL_XMM 1
+ %assign xmm_regs_used %1
+ ASSERT xmm_regs_used <= 16
%if xmm_regs_used > 6
sub rsp, (xmm_regs_used-6)*16+16
%assign stack_offset stack_offset+(xmm_regs_used-6)*16+16
@@ -287,13 +295,9 @@ DECLARE_REG 6, rax, eax, ax, al, [rsp + stack_offset + 56]
movdqa [rsp + (%%i-6)*16+8], xmm %+ %%i
%endrep
%endif
- LOAD_IF_USED 4, %1
- LOAD_IF_USED 5, %1
- LOAD_IF_USED 6, %1
- DEFINE_ARGS %4
%endmacro
-%macro RESTORE_XMM_INTERNAL 1
+%macro WIN64_RESTORE_XMM_INTERNAL 1
%if xmm_regs_used > 6
%assign %%i xmm_regs_used
%rep (xmm_regs_used-6)
@@ -304,14 +308,14 @@ DECLARE_REG 6, rax, eax, ax, al, [rsp + stack_offset + 56]
%endif
%endmacro
-%macro RESTORE_XMM 1
- RESTORE_XMM_INTERNAL %1
+%macro WIN64_RESTORE_XMM 1
+ WIN64_RESTORE_XMM_INTERNAL %1
%assign stack_offset stack_offset-(xmm_regs_used-6)*16+16
%assign xmm_regs_used 0
%endmacro
%macro RET 0
- RESTORE_XMM_INTERNAL rsp
+ WIN64_RESTORE_XMM_INTERNAL rsp
%if regs_used > 4
pop r5
pop r4
@@ -428,6 +432,13 @@ DECLARE_REG 6, ebp, ebp, bp, null, [esp + stack_offset + 28]
%endif ;======================================================================
+%ifndef WIN64
+%macro WIN64_SPILL_XMM 1
+%endmacro
+%macro WIN64_RESTORE_XMM 1
+%endmacro
+%endif
+
;=============================================================================
@@ -494,7 +505,7 @@ SECTION .note.GNU-stack noalloc noexec nowrite progbits
%define mova movq
%define movu movq
%define movh movd
- %define movnt movntq
+ %define movnta movntq
%assign %%i 0
%rep 8
CAT_XDEFINE m, %%i, mm %+ %%i
@@ -518,7 +529,7 @@ SECTION .note.GNU-stack noalloc noexec nowrite progbits
%define mova movdqa
%define movu movdqu
%define movh movq
- %define movnt movntdq
+ %define movnta movntdq
%assign %%i 0
%rep num_mmregs
CAT_XDEFINE m, %%i, xmm %+ %%i
diff --git a/lib/ffmpeg/libavcodec/x86/x86util.asm b/lib/ffmpeg/libavcodec/x86/x86util.asm
index 5dd65dca5c..7cabc70b31 100644
--- a/lib/ffmpeg/libavcodec/x86/x86util.asm
+++ b/lib/ffmpeg/libavcodec/x86/x86util.asm
@@ -148,12 +148,30 @@
%endmacro
%macro ABS1_MMX 2 ; a, tmp
+ pxor %2, %2
+ pcmpgtw %2, %1
+ pxor %1, %2
+ psubw %1, %2
+%endmacro
+
+%macro ABS2_MMX 4 ; a, b, tmp0, tmp1
+ pxor %3, %3
+ pxor %4, %4
+ pcmpgtw %3, %1
+ pcmpgtw %4, %2
+ pxor %1, %3
+ pxor %2, %4
+ psubw %1, %3
+ psubw %2, %4
+%endmacro
+
+%macro ABS1_MMX2 2 ; a, tmp
pxor %2, %2
psubw %2, %1
pmaxsw %1, %2
%endmacro
-%macro ABS2_MMX 4 ; a, b, tmp0, tmp1
+%macro ABS2_MMX2 4 ; a, b, tmp0, tmp1
pxor %3, %3
pxor %4, %4
psubw %3, %1
diff --git a/lib/ffmpeg/libavcodec/xan.c b/lib/ffmpeg/libavcodec/xan.c
index 3f6aa8cee5..0ae84a6903 100644
--- a/lib/ffmpeg/libavcodec/xan.c
+++ b/lib/ffmpeg/libavcodec/xan.c
@@ -40,6 +40,15 @@
// for av_memcpy_backptr
#include "libavutil/lzo.h"
+#define RUNTIME_GAMMA 0
+
+#define VGA__TAG MKTAG('V', 'G', 'A', ' ')
+#define PALT_TAG MKTAG('P', 'A', 'L', 'T')
+#define SHOT_TAG MKTAG('S', 'H', 'O', 'T')
+#define PALETTE_COUNT 256
+#define PALETTE_SIZE (PALETTE_COUNT * 3)
+#define PALETTES_MAX 256
+
typedef struct XanContext {
AVCodecContext *avctx;
@@ -55,6 +64,10 @@ typedef struct XanContext {
unsigned char *buffer2;
int buffer2_size;
+ unsigned *palettes;
+ int palettes_count;
+ int cur_palette;
+
int frame_size;
} XanContext;
@@ -66,23 +79,17 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->frame_size = 0;
- if ((avctx->codec->id == CODEC_ID_XAN_WC3) &&
- (s->avctx->palctrl == NULL)) {
- av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n");
- return -1;
- }
-
avctx->pix_fmt = PIX_FMT_PAL8;
s->buffer1_size = avctx->width * avctx->height;
s->buffer1 = av_malloc(s->buffer1_size);
if (!s->buffer1)
- return -1;
+ return AVERROR(ENOMEM);
s->buffer2_size = avctx->width * avctx->height;
s->buffer2 = av_malloc(s->buffer2_size + 130);
if (!s->buffer2) {
av_freep(&s->buffer1);
- return -1;
+ return AVERROR(ENOMEM);
}
return 0;
@@ -354,28 +361,169 @@ static void xan_wc3_decode_frame(XanContext *s) {
static void xan_wc4_decode_frame(XanContext *s) {
}
+#if RUNTIME_GAMMA
+static inline unsigned mul(unsigned a, unsigned b)
+{
+ return (a * b) >> 16;
+}
+
+static inline unsigned pow4(unsigned a)
+{
+ unsigned square = mul(a, a);
+ return mul(square, square);
+}
+
+static inline unsigned pow5(unsigned a)
+{
+ return mul(pow4(a), a);
+}
+
+static uint8_t gamma_corr(uint8_t in) {
+ unsigned lo, hi = 0xff40, target;
+ int i = 15;
+ in = (in << 2) | (in >> 6);
+ /* equivalent float code:
+ if (in >= 252)
+ return 253;
+ return round(pow(in / 256.0, 0.8) * 256);
+ */
+ lo = target = in << 8;
+ do {
+ unsigned mid = (lo + hi) >> 1;
+ unsigned pow = pow5(mid);
+ if (pow > target) hi = mid;
+ else lo = mid;
+ } while (--i);
+ return (pow4((lo + hi) >> 1) + 0x80) >> 8;
+}
+#else
+/**
+ * This is a gamma correction that xan3 applies to all palette entries.
+ *
+ * There is a peculiarity, namely that the values are clamped to 253 -
+ * it seems likely that this table was calculated by a buggy fixed-point
+ * implementation, the one above under RUNTIME_GAMMA behaves like this for
+ * example.
+ * The exponent value of 0.8 can be explained by this as well, since 0.8 = 4/5
+ * and thus pow(x, 0.8) is still easy to calculate.
+ * Also, the input values are first rotated to the left by 2.
+ */
+static const uint8_t gamma_lookup[256] = {
+ 0x00, 0x09, 0x10, 0x16, 0x1C, 0x21, 0x27, 0x2C,
+ 0x31, 0x35, 0x3A, 0x3F, 0x43, 0x48, 0x4C, 0x50,
+ 0x54, 0x59, 0x5D, 0x61, 0x65, 0x69, 0x6D, 0x71,
+ 0x75, 0x79, 0x7D, 0x80, 0x84, 0x88, 0x8C, 0x8F,
+ 0x93, 0x97, 0x9A, 0x9E, 0xA2, 0xA5, 0xA9, 0xAC,
+ 0xB0, 0xB3, 0xB7, 0xBA, 0xBE, 0xC1, 0xC5, 0xC8,
+ 0xCB, 0xCF, 0xD2, 0xD5, 0xD9, 0xDC, 0xDF, 0xE3,
+ 0xE6, 0xE9, 0xED, 0xF0, 0xF3, 0xF6, 0xFA, 0xFD,
+ 0x03, 0x0B, 0x12, 0x18, 0x1D, 0x23, 0x28, 0x2D,
+ 0x32, 0x36, 0x3B, 0x40, 0x44, 0x49, 0x4D, 0x51,
+ 0x56, 0x5A, 0x5E, 0x62, 0x66, 0x6A, 0x6E, 0x72,
+ 0x76, 0x7A, 0x7D, 0x81, 0x85, 0x89, 0x8D, 0x90,
+ 0x94, 0x98, 0x9B, 0x9F, 0xA2, 0xA6, 0xAA, 0xAD,
+ 0xB1, 0xB4, 0xB8, 0xBB, 0xBF, 0xC2, 0xC5, 0xC9,
+ 0xCC, 0xD0, 0xD3, 0xD6, 0xDA, 0xDD, 0xE0, 0xE4,
+ 0xE7, 0xEA, 0xED, 0xF1, 0xF4, 0xF7, 0xFA, 0xFD,
+ 0x05, 0x0D, 0x13, 0x19, 0x1F, 0x24, 0x29, 0x2E,
+ 0x33, 0x38, 0x3C, 0x41, 0x45, 0x4A, 0x4E, 0x52,
+ 0x57, 0x5B, 0x5F, 0x63, 0x67, 0x6B, 0x6F, 0x73,
+ 0x77, 0x7B, 0x7E, 0x82, 0x86, 0x8A, 0x8D, 0x91,
+ 0x95, 0x99, 0x9C, 0xA0, 0xA3, 0xA7, 0xAA, 0xAE,
+ 0xB2, 0xB5, 0xB9, 0xBC, 0xBF, 0xC3, 0xC6, 0xCA,
+ 0xCD, 0xD0, 0xD4, 0xD7, 0xDA, 0xDE, 0xE1, 0xE4,
+ 0xE8, 0xEB, 0xEE, 0xF1, 0xF5, 0xF8, 0xFB, 0xFD,
+ 0x07, 0x0E, 0x15, 0x1A, 0x20, 0x25, 0x2A, 0x2F,
+ 0x34, 0x39, 0x3D, 0x42, 0x46, 0x4B, 0x4F, 0x53,
+ 0x58, 0x5C, 0x60, 0x64, 0x68, 0x6C, 0x70, 0x74,
+ 0x78, 0x7C, 0x7F, 0x83, 0x87, 0x8B, 0x8E, 0x92,
+ 0x96, 0x99, 0x9D, 0xA1, 0xA4, 0xA8, 0xAB, 0xAF,
+ 0xB2, 0xB6, 0xB9, 0xBD, 0xC0, 0xC4, 0xC7, 0xCB,
+ 0xCE, 0xD1, 0xD5, 0xD8, 0xDB, 0xDF, 0xE2, 0xE5,
+ 0xE9, 0xEC, 0xEF, 0xF2, 0xF6, 0xF9, 0xFC, 0xFD
+};
+#endif
+
static int xan_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
+ int ret, buf_size = avpkt->size;
XanContext *s = avctx->priv_data;
- AVPaletteControl *palette_control = avctx->palctrl;
- if (avctx->get_buffer(avctx, &s->current_frame)) {
- av_log(s->avctx, AV_LOG_ERROR, " Xan Video: get_buffer() failed\n");
- return -1;
+ if (avctx->codec->id == CODEC_ID_XAN_WC3) {
+ const uint8_t *buf_end = buf + buf_size;
+ int tag = 0;
+ while (buf_end - buf > 8 && tag != VGA__TAG) {
+ unsigned *tmpptr;
+ uint32_t new_pal;
+ int size;
+ int i;
+ tag = bytestream_get_le32(&buf);
+ size = bytestream_get_be32(&buf);
+ size = FFMIN(size, buf_end - buf);
+ switch (tag) {
+ case PALT_TAG:
+ if (size < PALETTE_SIZE)
+ return AVERROR_INVALIDDATA;
+ if (s->palettes_count >= PALETTES_MAX)
+ return AVERROR_INVALIDDATA;
+ tmpptr = av_realloc(s->palettes, (s->palettes_count + 1) * AVPALETTE_SIZE);
+ if (!tmpptr)
+ return AVERROR(ENOMEM);
+ s->palettes = tmpptr;
+ tmpptr += s->palettes_count * AVPALETTE_COUNT;
+ for (i = 0; i < PALETTE_COUNT; i++) {
+#if RUNTIME_GAMMA
+ int r = gamma_corr(*buf++);
+ int g = gamma_corr(*buf++);
+ int b = gamma_corr(*buf++);
+#else
+ int r = gamma_lookup[*buf++];
+ int g = gamma_lookup[*buf++];
+ int b = gamma_lookup[*buf++];
+#endif
+ *tmpptr++ = (r << 16) | (g << 8) | b;
+ }
+ s->palettes_count++;
+ break;
+ case SHOT_TAG:
+ if (size < 4)
+ return AVERROR_INVALIDDATA;
+ new_pal = bytestream_get_le32(&buf);
+ if (new_pal < s->palettes_count) {
+ s->cur_palette = new_pal;
+ } else
+ av_log(avctx, AV_LOG_ERROR, "Invalid palette selected\n");
+ break;
+ case VGA__TAG:
+ break;
+ default:
+ buf += size;
+ break;
+ }
+ }
+ buf_size = buf_end - buf;
+ }
+ if ((ret = avctx->get_buffer(avctx, &s->current_frame))) {
+ av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
}
s->current_frame.reference = 3;
if (!s->frame_size)
s->frame_size = s->current_frame.linesize[0] * s->avctx->height;
- palette_control->palette_changed = 0;
- memcpy(s->current_frame.data[1], palette_control->palette,
- AVPALETTE_SIZE);
- s->current_frame.palette_has_changed = 1;
+ if (avctx->codec->id == CODEC_ID_XAN_WC3) {
+ memcpy(s->current_frame.data[1], s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE);
+ } else {
+ AVPaletteControl *palette_control = avctx->palctrl;
+ palette_control->palette_changed = 0;
+ memcpy(s->current_frame.data[1], palette_control->palette,
+ AVPALETTE_SIZE);
+ s->current_frame.palette_has_changed = 1;
+ }
s->buf = buf;
s->size = buf_size;
@@ -411,11 +559,12 @@ static av_cold int xan_decode_end(AVCodecContext *avctx)
av_freep(&s->buffer1);
av_freep(&s->buffer2);
+ av_freep(&s->palettes);
return 0;
}
-AVCodec xan_wc3_decoder = {
+AVCodec ff_xan_wc3_decoder = {
"xan_wc3",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_XAN_WC3,
@@ -429,7 +578,7 @@ AVCodec xan_wc3_decoder = {
};
/*
-AVCodec xan_wc4_decoder = {
+AVCodec ff_xan_wc4_decoder = {
"xan_wc4",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_XAN_WC4,
diff --git a/lib/ffmpeg/libavcodec/xl.c b/lib/ffmpeg/libavcodec/xl.c
index f7d025eca4..7fbe626d58 100644
--- a/lib/ffmpeg/libavcodec/xl.c
+++ b/lib/ffmpeg/libavcodec/xl.c
@@ -138,7 +138,7 @@ static av_cold int decode_end(AVCodecContext *avctx){
return 0;
}
-AVCodec xl_decoder = {
+AVCodec ff_xl_decoder = {
"xl",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_VIXL,
diff --git a/lib/ffmpeg/libavcodec/xsubdec.c b/lib/ffmpeg/libavcodec/xsubdec.c
index 0055ebb20b..872b227d64 100644
--- a/lib/ffmpeg/libavcodec/xsubdec.c
+++ b/lib/ffmpeg/libavcodec/xsubdec.c
@@ -18,6 +18,7 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
@@ -76,7 +77,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
// read header
w = bytestream_get_le16(&buf);
h = bytestream_get_le16(&buf);
- if (avcodec_check_dimensions(avctx, w, h) < 0)
+ if (av_image_check_size(w, h, 0, avctx) < 0)
return -1;
x = bytestream_get_le16(&buf);
y = bytestream_get_le16(&buf);
@@ -130,7 +131,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
return buf_size;
}
-AVCodec xsub_decoder = {
+AVCodec ff_xsub_decoder = {
"xsub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_XSUB,
diff --git a/lib/ffmpeg/libavcodec/xsubenc.c b/lib/ffmpeg/libavcodec/xsubenc.c
index 60f4979edb..c448a2271c 100644
--- a/lib/ffmpeg/libavcodec/xsubenc.c
+++ b/lib/ffmpeg/libavcodec/xsubenc.c
@@ -210,7 +210,7 @@ static av_cold int xsub_encoder_init(AVCodecContext *avctx)
return 0;
}
-AVCodec xsub_encoder = {
+AVCodec ff_xsub_encoder = {
"xsub",
AVMEDIA_TYPE_SUBTITLE,
CODEC_ID_XSUB,
diff --git a/lib/ffmpeg/libavcodec/yop.c b/lib/ffmpeg/libavcodec/yop.c
index 72aebc68da..6a75e74b7a 100644
--- a/lib/ffmpeg/libavcodec/yop.c
+++ b/lib/ffmpeg/libavcodec/yop.c
@@ -24,6 +24,7 @@
*/
#include "libavutil/intreadwrite.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
@@ -84,7 +85,7 @@ static av_cold int yop_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
if (avctx->width & 1 || avctx->height & 1 ||
- avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+ av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
return -1;
}
@@ -247,7 +248,7 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
return avpkt->size;
}
-AVCodec yop_decoder = {
+AVCodec ff_yop_decoder = {
"yop",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_YOP,
diff --git a/lib/ffmpeg/libavcodec/zmbv.c b/lib/ffmpeg/libavcodec/zmbv.c
index 6ac908919d..f660cd4693 100644
--- a/lib/ffmpeg/libavcodec/zmbv.c
+++ b/lib/ffmpeg/libavcodec/zmbv.c
@@ -650,7 +650,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec zmbv_decoder = {
+AVCodec ff_zmbv_decoder = {
"zmbv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ZMBV,
diff --git a/lib/ffmpeg/libavcodec/zmbvenc.c b/lib/ffmpeg/libavcodec/zmbvenc.c
index 95f2906268..b830bb4a8e 100644
--- a/lib/ffmpeg/libavcodec/zmbvenc.c
+++ b/lib/ffmpeg/libavcodec/zmbvenc.c
@@ -323,7 +323,7 @@ static av_cold int encode_end(AVCodecContext *avctx)
return 0;
}
-AVCodec zmbv_encoder = {
+AVCodec ff_zmbv_encoder = {
"zmbv",
AVMEDIA_TYPE_VIDEO,
CODEC_ID_ZMBV,