summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-04-03 01:18:24 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-04-03 01:18:24 +0200
commitfb09531720a4aa2dfa97e5a9a246a453b6278fd2 (patch)
tree61525c3a8ddb419d3838a26e488fc3659079bbcd
parent294d01046724e28b7193bcb65bf2a0391b0135b6 (diff)
downloadxine-lib-fb09531720a4aa2dfa97e5a9a246a453b6278fd2.tar.gz
xine-lib-fb09531720a4aa2dfa97e5a9a246a453b6278fd2.tar.bz2
Sync with a more recent version of FFmpeg.
-rw-r--r--Makefile.in151
-rw-r--r--configure.ac1
-rw-r--r--contrib/ffmpeg/Changelog13
-rw-r--r--contrib/ffmpeg/MAINTAINERS21
-rw-r--r--contrib/ffmpeg/Makefile56
-rw-r--r--contrib/ffmpeg/README4
-rw-r--r--contrib/ffmpeg/berrno.h44
-rw-r--r--contrib/ffmpeg/cmdutils.c4
-rw-r--r--contrib/ffmpeg/cmdutils.h23
-rw-r--r--contrib/ffmpeg/common.mak17
-rwxr-xr-xcontrib/ffmpeg/configure1901
-rw-r--r--contrib/ffmpeg/doc/TODO15
-rw-r--r--contrib/ffmpeg/doc/avutil.txt37
-rw-r--r--contrib/ffmpeg/doc/faq.texi111
-rw-r--r--contrib/ffmpeg/doc/ffmpeg-doc.texi159
-rw-r--r--contrib/ffmpeg/doc/ffplay-doc.texi31
-rw-r--r--contrib/ffmpeg/doc/hooks.texi161
-rw-r--r--contrib/ffmpeg/doc/optimization.txt9
-rw-r--r--contrib/ffmpeg/doc/snow.txt259
-rw-r--r--contrib/ffmpeg/ffmpeg.c636
-rw-r--r--contrib/ffmpeg/ffplay.c235
-rw-r--r--contrib/ffmpeg/ffserver.c158
-rw-r--r--contrib/ffmpeg/ffserver.h20
-rw-r--r--contrib/ffmpeg/libavcodec/4xm.c10
-rw-r--r--contrib/ffmpeg/libavcodec/8bps.c10
-rw-r--r--contrib/ffmpeg/libavcodec/Makefile94
-rw-r--r--contrib/ffmpeg/libavcodec/a52dec.c20
-rw-r--r--contrib/ffmpeg/libavcodec/aasc.c1
-rw-r--r--contrib/ffmpeg/libavcodec/ac3.c287
-rw-r--r--contrib/ffmpeg/libavcodec/ac3.h128
-rw-r--r--contrib/ffmpeg/libavcodec/ac3dec.c184
-rw-r--r--contrib/ffmpeg/libavcodec/ac3enc.c316
-rw-r--r--contrib/ffmpeg/libavcodec/ac3tab.h78
-rw-r--r--contrib/ffmpeg/libavcodec/adpcm.c112
-rw-r--r--contrib/ffmpeg/libavcodec/alac.c12
-rw-r--r--contrib/ffmpeg/libavcodec/allcodecs.c66
-rw-r--r--contrib/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S6
-rw-r--r--contrib/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S2
-rw-r--r--contrib/ffmpeg/libavcodec/amr.c266
-rw-r--r--contrib/ffmpeg/libavcodec/apiexample.c9
-rw-r--r--contrib/ffmpeg/libavcodec/armv4l/dsputil_arm.c15
-rw-r--r--contrib/ffmpeg/libavcodec/armv4l/dsputil_iwmmxt.c12
-rw-r--r--contrib/ffmpeg/libavcodec/armv4l/mpegvideo_arm.c8
-rw-r--r--contrib/ffmpeg/libavcodec/armv4l/mpegvideo_armv5te.c213
-rw-r--r--contrib/ffmpeg/libavcodec/armv4l/simple_idct_armv6.S448
-rw-r--r--contrib/ffmpeg/libavcodec/avcodec.h866
-rw-r--r--contrib/ffmpeg/libavcodec/avs.c4
-rw-r--r--contrib/ffmpeg/libavcodec/bfin/config_bfin.h46
-rw-r--r--contrib/ffmpeg/libavcodec/bfin/dsputil_bfin.c311
-rw-r--r--contrib/ffmpeg/libavcodec/bfin/fdct_bfin.S324
-rw-r--r--contrib/ffmpeg/libavcodec/bfin/idct_bfin.S297
-rw-r--r--contrib/ffmpeg/libavcodec/bfin/pixels_bfin.S723
-rw-r--r--contrib/ffmpeg/libavcodec/bitstream.c17
-rw-r--r--contrib/ffmpeg/libavcodec/bitstream.h14
-rw-r--r--contrib/ffmpeg/libavcodec/bitstream_filter.c8
-rw-r--r--contrib/ffmpeg/libavcodec/bmp.c74
-rw-r--r--contrib/ffmpeg/libavcodec/bmp.h31
-rw-r--r--contrib/ffmpeg/libavcodec/bmpenc.c98
-rw-r--r--contrib/ffmpeg/libavcodec/bytestream.h69
-rw-r--r--contrib/ffmpeg/libavcodec/cabac.h32
-rw-r--r--contrib/ffmpeg/libavcodec/cavs.c6
-rw-r--r--contrib/ffmpeg/libavcodec/cavsdsp.c20
-rw-r--r--contrib/ffmpeg/libavcodec/cinepak.c56
-rw-r--r--contrib/ffmpeg/libavcodec/cook.c713
-rw-r--r--contrib/ffmpeg/libavcodec/cscd.c6
-rw-r--r--contrib/ffmpeg/libavcodec/dca.c1322
-rw-r--r--contrib/ffmpeg/libavcodec/dcadata.h8454
-rw-r--r--contrib/ffmpeg/libavcodec/dcahuff.h1068
-rw-r--r--contrib/ffmpeg/libavcodec/dct-test.c114
-rw-r--r--contrib/ffmpeg/libavcodec/dnxhddata.h106
-rw-r--r--contrib/ffmpeg/libavcodec/dnxhddec.c368
-rw-r--r--contrib/ffmpeg/libavcodec/dpcm.c10
-rw-r--r--contrib/ffmpeg/libavcodec/dsicinav.c6
-rw-r--r--contrib/ffmpeg/libavcodec/dsputil.c70
-rw-r--r--contrib/ffmpeg/libavcodec/dsputil.h44
-rw-r--r--contrib/ffmpeg/libavcodec/dtsdec.c404
-rw-r--r--contrib/ffmpeg/libavcodec/dv.c40
-rw-r--r--contrib/ffmpeg/libavcodec/dvbsubdec.c30
-rw-r--r--contrib/ffmpeg/libavcodec/dvdata.h6
-rw-r--r--contrib/ffmpeg/libavcodec/dvdsubdec.c19
-rw-r--r--contrib/ffmpeg/libavcodec/dxa.c333
-rw-r--r--contrib/ffmpeg/libavcodec/error_resilience.c9
-rw-r--r--contrib/ffmpeg/libavcodec/eval.c6
-rw-r--r--contrib/ffmpeg/libavcodec/faac.c11
-rw-r--r--contrib/ffmpeg/libavcodec/faad.c21
-rw-r--r--contrib/ffmpeg/libavcodec/faandct.c2
-rw-r--r--contrib/ffmpeg/libavcodec/fft-test.c2
-rw-r--r--contrib/ffmpeg/libavcodec/ffv1.c8
-rw-r--r--contrib/ffmpeg/libavcodec/flac.c14
-rw-r--r--contrib/ffmpeg/libavcodec/flacenc.c4
-rw-r--r--contrib/ffmpeg/libavcodec/flashsv.c20
-rw-r--r--contrib/ffmpeg/libavcodec/flashsvenc.c346
-rw-r--r--contrib/ffmpeg/libavcodec/flicvideo.c66
-rw-r--r--contrib/ffmpeg/libavcodec/fraps.c8
-rw-r--r--contrib/ffmpeg/libavcodec/g726.c12
-rw-r--r--contrib/ffmpeg/libavcodec/gifdec.c50
-rw-r--r--contrib/ffmpeg/libavcodec/h261.c6
-rw-r--r--contrib/ffmpeg/libavcodec/h263.c55
-rw-r--r--contrib/ffmpeg/libavcodec/h263dec.c5
-rw-r--r--contrib/ffmpeg/libavcodec/h264.c1076
-rw-r--r--contrib/ffmpeg/libavcodec/h264data.h27
-rw-r--r--contrib/ffmpeg/libavcodec/h264dsp.c81
-rw-r--r--contrib/ffmpeg/libavcodec/h264enc.c107
-rw-r--r--contrib/ffmpeg/libavcodec/h264idct.c2
-rw-r--r--contrib/ffmpeg/libavcodec/huffyuv.c112
-rw-r--r--contrib/ffmpeg/libavcodec/i386/cputest.c6
-rw-r--r--contrib/ffmpeg/libavcodec/i386/dsputil_h264_template_mmx.c215
-rw-r--r--contrib/ffmpeg/libavcodec/i386/dsputil_mmx.c42
-rw-r--r--contrib/ffmpeg/libavcodec/i386/fdct_mmx.c8
-rw-r--r--contrib/ffmpeg/libavcodec/i386/h264dsp_mmx.c30
-rw-r--r--contrib/ffmpeg/libavcodec/i386/idct_mmx.c2
-rw-r--r--contrib/ffmpeg/libavcodec/i386/idct_mmx_xvid.c2
-rw-r--r--contrib/ffmpeg/libavcodec/i386/snowdsp_mmx.c12
-rw-r--r--contrib/ffmpeg/libavcodec/imc.c2
-rw-r--r--contrib/ffmpeg/libavcodec/imgconvert.c256
-rw-r--r--contrib/ffmpeg/libavcodec/imgconvert_template.h14
-rw-r--r--contrib/ffmpeg/libavcodec/imgresample.c4
-rw-r--r--contrib/ffmpeg/libavcodec/indeo2.c8
-rw-r--r--contrib/ffmpeg/libavcodec/indeo3.c10
-rw-r--r--contrib/ffmpeg/libavcodec/jfdctfst.c2
-rw-r--r--contrib/ffmpeg/libavcodec/jfdctint.c2
-rw-r--r--contrib/ffmpeg/libavcodec/jpeg_ls.c29
-rw-r--r--contrib/ffmpeg/libavcodec/kmvc.c5
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/a52.h73
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/a52_internal.h162
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/a52_util.h32
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/bit_allocate.c260
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/bitstream.c91
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/bitstream.h77
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/crc.c73
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/downmix.c679
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/imdct.c411
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/mm_accel.h42
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/parse.c939
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/resample.c63
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/resample_c.c203
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/resample_mmx.c537
-rw-r--r--contrib/ffmpeg/libavcodec/liba52/tables.h246
-rw-r--r--contrib/ffmpeg/libavcodec/libgsm.c78
-rw-r--r--contrib/ffmpeg/libavcodec/libtheoraenc.c280
-rw-r--r--contrib/ffmpeg/libavcodec/loco.c10
-rw-r--r--contrib/ffmpeg/libavcodec/lzw.c97
-rw-r--r--contrib/ffmpeg/libavcodec/mathops.h2
-rw-r--r--contrib/ffmpeg/libavcodec/mjpeg.c152
-rw-r--r--contrib/ffmpeg/libavcodec/mmvideo.c4
-rw-r--r--contrib/ffmpeg/libavcodec/motion_est.c55
-rw-r--r--contrib/ffmpeg/libavcodec/motion_est_template.c213
-rw-r--r--contrib/ffmpeg/libavcodec/motion_test.c1
-rw-r--r--contrib/ffmpeg/libavcodec/mpc.c355
-rw-r--r--contrib/ffmpeg/libavcodec/mpcdata.h206
-rw-r--r--contrib/ffmpeg/libavcodec/mpeg12.c166
-rw-r--r--contrib/ffmpeg/libavcodec/mpeg12data.h5
-rw-r--r--contrib/ffmpeg/libavcodec/mpegaudio.c2
-rw-r--r--contrib/ffmpeg/libavcodec/mpegaudiodec.c121
-rw-r--r--contrib/ffmpeg/libavcodec/mpegvideo.c234
-rw-r--r--contrib/ffmpeg/libavcodec/mpegvideo.h38
-rw-r--r--contrib/ffmpeg/libavcodec/msmpeg4.c6
-rw-r--r--contrib/ffmpeg/libavcodec/msvideo1.c16
-rw-r--r--contrib/ffmpeg/libavcodec/nuv.c6
-rw-r--r--contrib/ffmpeg/libavcodec/oggvorbis.c4
-rw-r--r--contrib/ffmpeg/libavcodec/opt.c60
-rw-r--r--contrib/ffmpeg/libavcodec/opt.h20
-rw-r--r--contrib/ffmpeg/libavcodec/parser.c136
-rw-r--r--contrib/ffmpeg/libavcodec/pcm.c46
-rw-r--r--contrib/ffmpeg/libavcodec/png.c20
-rw-r--r--contrib/ffmpeg/libavcodec/pnm.c10
-rw-r--r--contrib/ffmpeg/libavcodec/ppc/dsputil_altivec.c6
-rw-r--r--contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.c10
-rw-r--r--contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.h6
-rw-r--r--contrib/ffmpeg/libavcodec/ppc/float_altivec.c3
-rw-r--r--contrib/ffmpeg/libavcodec/ppc/h264_altivec.c129
-rw-r--r--contrib/ffmpeg/libavcodec/ppc/idct_altivec.c4
-rw-r--r--contrib/ffmpeg/libavcodec/pthread.c2
-rw-r--r--contrib/ffmpeg/libavcodec/qdm2.c16
-rw-r--r--contrib/ffmpeg/libavcodec/qdrw.c6
-rw-r--r--contrib/ffmpeg/libavcodec/qpeg.c1
-rw-r--r--contrib/ffmpeg/libavcodec/qtrle.c38
-rw-r--r--contrib/ffmpeg/libavcodec/rangecoder.c30
-rw-r--r--contrib/ffmpeg/libavcodec/ratecontrol.c12
-rw-r--r--contrib/ffmpeg/libavcodec/raw.c44
-rw-r--r--contrib/ffmpeg/libavcodec/resample.c3
-rw-r--r--contrib/ffmpeg/libavcodec/resample2.c88
-rw-r--r--contrib/ffmpeg/libavcodec/rl.h42
-rw-r--r--contrib/ffmpeg/libavcodec/roqvideo.c63
-rw-r--r--contrib/ffmpeg/libavcodec/rpza.c10
-rw-r--r--contrib/ffmpeg/libavcodec/rv10.c4
-rw-r--r--contrib/ffmpeg/libavcodec/shorten.c4
-rw-r--r--contrib/ffmpeg/libavcodec/simple_idct.c6
-rw-r--r--contrib/ffmpeg/libavcodec/smacker.c36
-rw-r--r--contrib/ffmpeg/libavcodec/smc.c6
-rw-r--r--contrib/ffmpeg/libavcodec/snow.c174
-rw-r--r--contrib/ffmpeg/libavcodec/snow.h10
-rw-r--r--contrib/ffmpeg/libavcodec/sonic.c2
-rw-r--r--contrib/ffmpeg/libavcodec/svq1.c18
-rw-r--r--contrib/ffmpeg/libavcodec/svq3.c15
-rw-r--r--contrib/ffmpeg/libavcodec/targa.c22
-rw-r--r--contrib/ffmpeg/libavcodec/targaenc.c199
-rw-r--r--contrib/ffmpeg/libavcodec/tiff.c7
-rw-r--r--contrib/ffmpeg/libavcodec/truemotion1.c15
-rw-r--r--contrib/ffmpeg/libavcodec/truemotion2.c25
-rw-r--r--contrib/ffmpeg/libavcodec/truespeech.c22
-rw-r--r--contrib/ffmpeg/libavcodec/tscc.c11
-rw-r--r--contrib/ffmpeg/libavcodec/ulti.c1
-rw-r--r--contrib/ffmpeg/libavcodec/utils.c351
-rw-r--r--contrib/ffmpeg/libavcodec/vc1.c470
-rw-r--r--contrib/ffmpeg/libavcodec/vc1data.h2
-rw-r--r--contrib/ffmpeg/libavcodec/vc1dsp.c6
-rw-r--r--contrib/ffmpeg/libavcodec/vmdav.c16
-rw-r--r--contrib/ffmpeg/libavcodec/vmnc.c27
-rw-r--r--contrib/ffmpeg/libavcodec/vorbis.c30
-rw-r--r--contrib/ffmpeg/libavcodec/vorbis_enc.c4
-rw-r--r--contrib/ffmpeg/libavcodec/vp3.c36
-rw-r--r--contrib/ffmpeg/libavcodec/vp3dsp.c2
-rw-r--r--contrib/ffmpeg/libavcodec/vp5.c12
-rw-r--r--contrib/ffmpeg/libavcodec/vp56.c58
-rw-r--r--contrib/ffmpeg/libavcodec/vp56.h5
-rw-r--r--contrib/ffmpeg/libavcodec/vp56data.h1
-rw-r--r--contrib/ffmpeg/libavcodec/vp6.c82
-rw-r--r--contrib/ffmpeg/libavcodec/vp6data.h10
-rw-r--r--contrib/ffmpeg/libavcodec/vqavideo.c30
-rw-r--r--contrib/ffmpeg/libavcodec/wavpack.c44
-rw-r--r--contrib/ffmpeg/libavcodec/wma.c386
-rw-r--r--contrib/ffmpeg/libavcodec/wma.h149
-rw-r--r--contrib/ffmpeg/libavcodec/wmadata.h22
-rw-r--r--contrib/ffmpeg/libavcodec/wmadec.c703
-rw-r--r--contrib/ffmpeg/libavcodec/wmaenc.c407
-rw-r--r--contrib/ffmpeg/libavcodec/wmv2.c14
-rw-r--r--contrib/ffmpeg/libavcodec/ws-snd1.c4
-rw-r--r--contrib/ffmpeg/libavcodec/x264.c1
-rw-r--r--contrib/ffmpeg/libavcodec/xan.c10
-rw-r--r--contrib/ffmpeg/libavcodec/xiph.c56
-rw-r--r--contrib/ffmpeg/libavcodec/xiph.h38
-rw-r--r--contrib/ffmpeg/libavcodec/xl.c2
-rw-r--r--contrib/ffmpeg/libavcodec/xvmc_render.h (renamed from contrib/ffmpeg/xvmc_render.h)5
-rw-r--r--contrib/ffmpeg/libavcodec/zmbv.c7
-rw-r--r--contrib/ffmpeg/libavcodec/zmbvenc.c328
-rw-r--r--contrib/ffmpeg/libavformat/4xm.c28
-rw-r--r--contrib/ffmpeg/libavformat/Makefile52
-rw-r--r--contrib/ffmpeg/libavformat/aiff.c32
-rw-r--r--contrib/ffmpeg/libavformat/allformats.c28
-rw-r--r--contrib/ffmpeg/libavformat/allformats.h8
-rw-r--r--contrib/ffmpeg/libavformat/asf-enc.c179
-rw-r--r--contrib/ffmpeg/libavformat/asf.c432
-rw-r--r--contrib/ffmpeg/libavformat/asf.h127
-rw-r--r--contrib/ffmpeg/libavformat/au.c10
-rw-r--r--contrib/ffmpeg/libavformat/audio.c14
-rw-r--r--contrib/ffmpeg/libavformat/avformat.h503
-rw-r--r--contrib/ffmpeg/libavformat/avidec.c123
-rw-r--r--contrib/ffmpeg/libavformat/avienc.c60
-rw-r--r--contrib/ffmpeg/libavformat/avio.c36
-rw-r--r--contrib/ffmpeg/libavformat/avio.h93
-rw-r--r--contrib/ffmpeg/libavformat/aviobuf.c65
-rw-r--r--contrib/ffmpeg/libavformat/beosaudio.cpp24
-rw-r--r--contrib/ffmpeg/libavformat/dc1394.c4
-rw-r--r--contrib/ffmpeg/libavformat/dsicin.c4
-rw-r--r--contrib/ffmpeg/libavformat/dv.c14
-rw-r--r--contrib/ffmpeg/libavformat/dv.h2
-rw-r--r--contrib/ffmpeg/libavformat/dv1394.c8
-rw-r--r--contrib/ffmpeg/libavformat/dvenc.c12
-rw-r--r--contrib/ffmpeg/libavformat/dxa.c214
-rw-r--r--contrib/ffmpeg/libavformat/electronicarts.c6
-rw-r--r--contrib/ffmpeg/libavformat/ffm.c12
-rw-r--r--contrib/ffmpeg/libavformat/file.c12
-rw-r--r--contrib/ffmpeg/libavformat/flic.c20
-rw-r--r--contrib/ffmpeg/libavformat/flv.h110
-rw-r--r--contrib/ffmpeg/libavformat/flvdec.c346
-rw-r--r--contrib/ffmpeg/libavformat/flvenc.c144
-rw-r--r--contrib/ffmpeg/libavformat/framehook.c11
-rw-r--r--contrib/ffmpeg/libavformat/framehook.h4
-rw-r--r--contrib/ffmpeg/libavformat/gifdec.c6
-rw-r--r--contrib/ffmpeg/libavformat/grab.c30
-rw-r--r--contrib/ffmpeg/libavformat/grab_bktr.c30
-rw-r--r--contrib/ffmpeg/libavformat/gxf.c15
-rw-r--r--contrib/ffmpeg/libavformat/gxfenc.c21
-rw-r--r--contrib/ffmpeg/libavformat/http.c137
-rw-r--r--contrib/ffmpeg/libavformat/idcin.c10
-rw-r--r--contrib/ffmpeg/libavformat/idroq.c22
-rw-r--r--contrib/ffmpeg/libavformat/img.c400
-rw-r--r--contrib/ffmpeg/libavformat/img2.c13
-rw-r--r--contrib/ffmpeg/libavformat/ipmovie.c30
-rw-r--r--contrib/ffmpeg/libavformat/isom.c130
-rw-r--r--contrib/ffmpeg/libavformat/isom.h4
-rw-r--r--contrib/ffmpeg/libavformat/jpeg.c240
-rw-r--r--contrib/ffmpeg/libavformat/libnut.c59
-rw-r--r--contrib/ffmpeg/libavformat/matroska.c565
-rw-r--r--contrib/ffmpeg/libavformat/mm.c8
-rw-r--r--contrib/ffmpeg/libavformat/mov.c292
-rw-r--r--contrib/ffmpeg/libavformat/movenc.c77
-rw-r--r--contrib/ffmpeg/libavformat/mp3.c3
-rw-r--r--contrib/ffmpeg/libavformat/mpc.c231
-rw-r--r--contrib/ffmpeg/libavformat/mpeg.c109
-rw-r--r--contrib/ffmpeg/libavformat/mpegts.c97
-rw-r--r--contrib/ffmpeg/libavformat/mpegts.h2
-rw-r--r--contrib/ffmpeg/libavformat/mpegtsenc.c69
-rw-r--r--contrib/ffmpeg/libavformat/mxf.c726
-rw-r--r--contrib/ffmpeg/libavformat/network.h (renamed from contrib/ffmpeg/libavformat/barpainet.h)34
-rw-r--r--contrib/ffmpeg/libavformat/nsvdec.c14
-rw-r--r--contrib/ffmpeg/libavformat/nut.c2
-rw-r--r--contrib/ffmpeg/libavformat/nutdec.c24
-rw-r--r--contrib/ffmpeg/libavformat/nuv.c8
-rw-r--r--contrib/ffmpeg/libavformat/ogg.c4
-rw-r--r--contrib/ffmpeg/libavformat/ogg2.c13
-rw-r--r--contrib/ffmpeg/libavformat/ogg2.h1
-rw-r--r--contrib/ffmpeg/libavformat/os_support.c77
-rw-r--r--contrib/ffmpeg/libavformat/os_support.h60
-rw-r--r--contrib/ffmpeg/libavformat/png.c889
-rw-r--r--contrib/ffmpeg/libavformat/pnm.c478
-rw-r--r--contrib/ffmpeg/libavformat/psxstr.c18
-rw-r--r--contrib/ffmpeg/libavformat/qtpalette.h16
-rw-r--r--contrib/ffmpeg/libavformat/raw.c64
-rw-r--r--contrib/ffmpeg/libavformat/riff.c106
-rw-r--r--contrib/ffmpeg/libavformat/riff.h30
-rw-r--r--contrib/ffmpeg/libavformat/rm.c7
-rw-r--r--contrib/ffmpeg/libavformat/rtp.c18
-rw-r--r--contrib/ffmpeg/libavformat/rtp.h15
-rw-r--r--contrib/ffmpeg/libavformat/rtp_h264.c16
-rw-r--r--contrib/ffmpeg/libavformat/rtpproto.c14
-rw-r--r--contrib/ffmpeg/libavformat/rtsp.c11
-rw-r--r--contrib/ffmpeg/libavformat/rtsp.h26
-rw-r--r--contrib/ffmpeg/libavformat/rtspcodes.h27
-rw-r--r--contrib/ffmpeg/libavformat/segafilm.c51
-rw-r--r--contrib/ffmpeg/libavformat/sgi.c460
-rw-r--r--contrib/ffmpeg/libavformat/sierravmd.c22
-rw-r--r--contrib/ffmpeg/libavformat/smacker.c4
-rw-r--r--contrib/ffmpeg/libavformat/sol.c4
-rw-r--r--contrib/ffmpeg/libavformat/swf.c355
-rw-r--r--contrib/ffmpeg/libavformat/tcp.c52
-rw-r--r--contrib/ffmpeg/libavformat/thp.c170
-rw-r--r--contrib/ffmpeg/libavformat/tiertexseq.c5
-rw-r--r--contrib/ffmpeg/libavformat/tta.c12
-rw-r--r--contrib/ffmpeg/libavformat/udp.c32
-rw-r--r--contrib/ffmpeg/libavformat/utils.c708
-rw-r--r--contrib/ffmpeg/libavformat/v4l2.c192
-rw-r--r--contrib/ffmpeg/libavformat/voc.c2
-rw-r--r--contrib/ffmpeg/libavformat/voc.h2
-rw-r--r--contrib/ffmpeg/libavformat/vocdec.c6
-rw-r--r--contrib/ffmpeg/libavformat/vocenc.c11
-rw-r--r--contrib/ffmpeg/libavformat/wav.c42
-rw-r--r--contrib/ffmpeg/libavformat/wc3movie.c24
-rw-r--r--contrib/ffmpeg/libavformat/westwood.c50
-rw-r--r--contrib/ffmpeg/libavformat/wv.c49
-rw-r--r--contrib/ffmpeg/libavformat/x11grab.c529
-rw-r--r--contrib/ffmpeg/libavformat/yuv.c161
-rw-r--r--contrib/ffmpeg/libavutil/Makefile14
-rw-r--r--contrib/ffmpeg/libavutil/aes.c239
-rw-r--r--contrib/ffmpeg/libavutil/aes.h45
-rw-r--r--contrib/ffmpeg/libavutil/avutil.h4
-rw-r--r--contrib/ffmpeg/libavutil/base64.c (renamed from contrib/ffmpeg/libavformat/base64.c)9
-rw-r--r--contrib/ffmpeg/libavutil/base64.h (renamed from contrib/ffmpeg/libavformat/base64.h)14
-rw-r--r--contrib/ffmpeg/libavutil/bswap.h14
-rw-r--r--contrib/ffmpeg/libavutil/common.h159
-rw-r--r--contrib/ffmpeg/libavutil/crc.c7
-rw-r--r--contrib/ffmpeg/libavutil/crc.h7
-rw-r--r--contrib/ffmpeg/libavutil/fifo.c75
-rw-r--r--contrib/ffmpeg/libavutil/fifo.h75
-rw-r--r--contrib/ffmpeg/libavutil/integer.c26
-rw-r--r--contrib/ffmpeg/libavutil/integer.h33
-rw-r--r--contrib/ffmpeg/libavutil/internal.h74
-rw-r--r--contrib/ffmpeg/libavutil/intreadwrite.h99
-rw-r--r--contrib/ffmpeg/libavutil/log.c2
-rw-r--r--contrib/ffmpeg/libavutil/log.h54
-rw-r--r--contrib/ffmpeg/libavutil/lzo.c (renamed from contrib/ffmpeg/libavcodec/lzo.c)149
-rw-r--r--contrib/ffmpeg/libavutil/lzo.h (renamed from contrib/ffmpeg/libavcodec/lzo.h)4
-rw-r--r--contrib/ffmpeg/libavutil/md5.c44
-rw-r--r--contrib/ffmpeg/libavutil/mem.c21
-rw-r--r--contrib/ffmpeg/libavutil/mem.h65
-rw-r--r--contrib/ffmpeg/libavutil/random.c104
-rw-r--r--contrib/ffmpeg/libavutil/random.h69
-rw-r--r--contrib/ffmpeg/libavutil/rational.c24
-rw-r--r--contrib/ffmpeg/libavutil/rational.h51
-rw-r--r--contrib/ffmpeg/libavutil/sha1.c160
-rw-r--r--contrib/ffmpeg/libavutil/sha1.h11
-rw-r--r--contrib/ffmpeg/libavutil/tree.h30
-rw-r--r--contrib/ffmpeg/libavutil/x86_cpu.h4
-rw-r--r--contrib/ffmpeg/libpostproc/Makefile2
-rw-r--r--contrib/ffmpeg/libpostproc/postprocess.c2
-rw-r--r--contrib/ffmpeg/libpostproc/postprocess_altivec_template.c13
-rw-r--r--contrib/ffmpeg/libpostproc/postprocess_template.c6
-rw-r--r--contrib/ffmpeg/libswscale/Makefile14
-rw-r--r--contrib/ffmpeg/libswscale/cs_test.c29
-rw-r--r--contrib/ffmpeg/libswscale/rgb2rgb.c12
-rw-r--r--contrib/ffmpeg/libswscale/swscale.c240
-rw-r--r--contrib/ffmpeg/libswscale/swscale.h4
-rw-r--r--contrib/ffmpeg/libswscale/swscale_altivec_template.c10
-rw-r--r--contrib/ffmpeg/libswscale/swscale_internal.h24
-rw-r--r--contrib/ffmpeg/libswscale/swscale_template.c77
-rw-r--r--contrib/ffmpeg/libswscale/yuv2rgb.c31
-rw-r--r--contrib/ffmpeg/libswscale/yuv2rgb_altivec.c18
-rw-r--r--contrib/ffmpeg/libswscale/yuv2rgb_init.c412
-rw-r--r--contrib/ffmpeg/libswscale/yuv2rgb_mlib.c5
-rw-r--r--contrib/ffmpeg/libswscale/yuv2rgb_template.c12
-rw-r--r--contrib/ffmpeg/output_example.c4
-rw-r--r--contrib/ffmpeg/pktdumper.c20
-rw-r--r--contrib/ffmpeg/qt-faststart.c2
-rw-r--r--contrib/ffmpeg/tests/Makefile33
-rw-r--r--contrib/ffmpeg/tests/audiogen.c19
-rw-r--r--contrib/ffmpeg/tests/ffmpeg.regression.ref128
-rw-r--r--contrib/ffmpeg/tests/ffserver.regression.ref20
-rw-r--r--contrib/ffmpeg/tests/lena.pnm2
-rw-r--r--contrib/ffmpeg/tests/libav.regression.ref51
-rwxr-xr-xcontrib/ffmpeg/tests/regression.sh367
-rw-r--r--contrib/ffmpeg/tests/rotozoom.c21
-rw-r--r--contrib/ffmpeg/tests/rotozoom.regression.ref128
-rw-r--r--contrib/ffmpeg/tests/seek_test.c91
-rwxr-xr-xcontrib/ffmpeg/tests/seek_test.sh25
-rwxr-xr-xcontrib/ffmpeg/tests/server-regression.sh18
-rw-r--r--contrib/ffmpeg/tests/test.conf7
-rw-r--r--contrib/ffmpeg/tests/videogen.c19
-rw-r--r--contrib/ffmpeg/vhook/Makefile7
-rw-r--r--contrib/ffmpeg/vhook/fish.c2
-rw-r--r--contrib/ffmpeg/vhook/imlib2.c11
-rw-r--r--contrib/ffmpeg/vhook/null.c4
-rw-r--r--contrib/ffmpeg/vhook/ppm.c6
-rw-r--r--contrib/ffmpeg/vhook/watermark.c46
414 files changed, 32909 insertions, 17507 deletions
diff --git a/Makefile.in b/Makefile.in
index 9cf5fcf8c..9c8d9ba9e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -40,41 +40,32 @@ build_triplet = @build@
host_triplet = @host@
DIST_COMMON = README $(am__configure_deps) $(noinst_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/config.h.in $(top_srcdir)/configure \
- $(top_srcdir)/contrib/Makefile.in \
- $(top_srcdir)/contrib/ffmpeg/makefile.xine.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/alpha/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/armv4l/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/i386/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/libpostproc/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/mlib/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/ppc/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavcodec/sparc/Makefile.in \
- $(top_srcdir)/src/libffmpeg/libavutil/Makefile.in ABOUT-NLS \
- AUTHORS COPYING ChangeLog INSTALL NEWS TODO compile \
- config.guess config.rpath config.sub depcomp install-sh \
- ltmain.sh missing mkinstalldirs
+ $(srcdir)/config.h.in $(top_srcdir)/configure ABOUT-NLS \
+ AUTHORS COPYING COPYING.LIB ChangeLog INSTALL NEWS TODO \
+ compile config.guess config.rpath config.sub depcomp \
+ install-sh ltmain.sh missing
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/_xine.m4 $(top_srcdir)/m4/aa.m4 \
- $(top_srcdir)/m4/arts.m4 $(top_srcdir)/m4/as.m4 \
- $(top_srcdir)/m4/attributes.m4 $(top_srcdir)/m4/directx.m4 \
- $(top_srcdir)/m4/dl.m4 $(top_srcdir)/m4/dvdnav.m4 \
+ $(top_srcdir)/m4/arts.m4 $(top_srcdir)/m4/attributes.m4 \
+ $(top_srcdir)/m4/directx.m4 $(top_srcdir)/m4/dl.m4 \
+ $(top_srcdir)/m4/dvdnav.m4 $(top_srcdir)/m4/gas.m4 \
$(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
- $(top_srcdir)/m4/irixal.m4 $(top_srcdir)/m4/isc-posix.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libFLAC.m4 \
- $(top_srcdir)/m4/libfame.m4 $(top_srcdir)/m4/libtool15.m4 \
- $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/opengl.m4 \
- $(top_srcdir)/m4/optimizations.m4 $(top_srcdir)/m4/pkg.m4 \
- $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
- $(top_srcdir)/m4/xv.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/ioctl_request.m4 $(top_srcdir)/m4/irixal.m4 \
+ $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libFLAC.m4 $(top_srcdir)/m4/libfame.m4 \
+ $(top_srcdir)/m4/libtool15.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/opengl.m4 $(top_srcdir)/m4/optimizations.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/pthreads.m4 \
+ $(top_srcdir)/m4/symbol.m4 $(top_srcdir)/m4/xv.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
SOURCES =
DIST_SOURCES =
@@ -95,8 +86,8 @@ am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
-DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
+DIST_ARCHIVES = $(distdir).tar.bz2
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
A52_FALSE = @A52_FALSE@
@@ -113,6 +104,8 @@ AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
+ARCH_X86_FALSE = @ARCH_X86_FALSE@
+ARCH_X86_TRUE = @ARCH_X86_TRUE@
ARTS_CFLAGS = @ARTS_CFLAGS@
ARTS_CONFIG = @ARTS_CONFIG@
ARTS_LIBS = @ARTS_LIBS@
@@ -134,7 +127,6 @@ CACA_CFLAGS = @CACA_CFLAGS@
CACA_LIBS = @CACA_LIBS@
CC = @CC@
CCAS = @CCAS@
-CCASCOMPILE = @CCASCOMPILE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
@@ -167,6 +159,8 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ENABLE_REAL_FALSE = @ENABLE_REAL_FALSE@
+ENABLE_REAL_TRUE = @ENABLE_REAL_TRUE@
ENABLE_VCD_FALSE = @ENABLE_VCD_FALSE@
ENABLE_VCD_TRUE = @ENABLE_VCD_TRUE@
ENABLE_VIS_FALSE = @ENABLE_VIS_FALSE@
@@ -180,6 +174,8 @@ EXTERNAL_LIBDTS_FALSE = @EXTERNAL_LIBDTS_FALSE@
EXTERNAL_LIBDTS_TRUE = @EXTERNAL_LIBDTS_TRUE@
EXTERNAL_LIBMAD_FALSE = @EXTERNAL_LIBMAD_FALSE@
EXTERNAL_LIBMAD_TRUE = @EXTERNAL_LIBMAD_TRUE@
+EXTERNAL_MPCDEC_FALSE = @EXTERNAL_MPCDEC_FALSE@
+EXTERNAL_MPCDEC_TRUE = @EXTERNAL_MPCDEC_TRUE@
EXTRA_X_CFLAGS = @EXTRA_X_CFLAGS@
EXTRA_X_LIBS = @EXTRA_X_LIBS@
FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
@@ -231,14 +227,10 @@ HAVE_ESD_FALSE = @HAVE_ESD_FALSE@
HAVE_ESD_TRUE = @HAVE_ESD_TRUE@
HAVE_FB_FALSE = @HAVE_FB_FALSE@
HAVE_FB_TRUE = @HAVE_FB_TRUE@
-HAVE_FFMMX_FALSE = @HAVE_FFMMX_FALSE@
-HAVE_FFMMX_TRUE = @HAVE_FFMMX_TRUE@
HAVE_FFMPEG_FALSE = @HAVE_FFMPEG_FALSE@
HAVE_FFMPEG_TRUE = @HAVE_FFMPEG_TRUE@
HAVE_FIG2DEV_FALSE = @HAVE_FIG2DEV_FALSE@
HAVE_FIG2DEV_TRUE = @HAVE_FIG2DEV_TRUE@
-HAVE_FLAC_FALSE = @HAVE_FLAC_FALSE@
-HAVE_FLAC_TRUE = @HAVE_FLAC_TRUE@
HAVE_FREEBSD_CDROM = @HAVE_FREEBSD_CDROM@
HAVE_FUSIONSOUND_FALSE = @HAVE_FUSIONSOUND_FALSE@
HAVE_FUSIONSOUND_TRUE = @HAVE_FUSIONSOUND_TRUE@
@@ -248,11 +240,12 @@ HAVE_GNOME_VFS_FALSE = @HAVE_GNOME_VFS_FALSE@
HAVE_GNOME_VFS_TRUE = @HAVE_GNOME_VFS_TRUE@
HAVE_IRIXAL_FALSE = @HAVE_IRIXAL_FALSE@
HAVE_IRIXAL_TRUE = @HAVE_IRIXAL_TRUE@
-HAVE_JACK = @HAVE_JACK@
HAVE_JACK_FALSE = @HAVE_JACK_FALSE@
HAVE_JACK_TRUE = @HAVE_JACK_TRUE@
HAVE_LIBFAME_FALSE = @HAVE_LIBFAME_FALSE@
HAVE_LIBFAME_TRUE = @HAVE_LIBFAME_TRUE@
+HAVE_LIBFLAC_FALSE = @HAVE_LIBFLAC_FALSE@
+HAVE_LIBFLAC_TRUE = @HAVE_LIBFLAC_TRUE@
HAVE_LIBMNG_FALSE = @HAVE_LIBMNG_FALSE@
HAVE_LIBMNG_TRUE = @HAVE_LIBMNG_TRUE@
HAVE_LIBRTE_FALSE = @HAVE_LIBRTE_FALSE@
@@ -266,6 +259,8 @@ HAVE_MACOSX_VIDEO_FALSE = @HAVE_MACOSX_VIDEO_FALSE@
HAVE_MACOSX_VIDEO_TRUE = @HAVE_MACOSX_VIDEO_TRUE@
HAVE_MLIB_FALSE = @HAVE_MLIB_FALSE@
HAVE_MLIB_TRUE = @HAVE_MLIB_TRUE@
+HAVE_MMX_FALSE = @HAVE_MMX_FALSE@
+HAVE_MMX_TRUE = @HAVE_MMX_TRUE@
HAVE_OPENGL_FALSE = @HAVE_OPENGL_FALSE@
HAVE_OPENGL_TRUE = @HAVE_OPENGL_TRUE@
HAVE_OSS_FALSE = @HAVE_OSS_FALSE@
@@ -305,9 +300,17 @@ HAVE_W32DLL_FALSE = @HAVE_W32DLL_FALSE@
HAVE_W32DLL_TRUE = @HAVE_W32DLL_TRUE@
HAVE_WAND_FALSE = @HAVE_WAND_FALSE@
HAVE_WAND_TRUE = @HAVE_WAND_TRUE@
+HAVE_WAVPACK_FALSE = @HAVE_WAVPACK_FALSE@
+HAVE_WAVPACK_TRUE = @HAVE_WAVPACK_TRUE@
HAVE_WIN32_CDROM = @HAVE_WIN32_CDROM@
HAVE_X11_FALSE = @HAVE_X11_FALSE@
HAVE_X11_TRUE = @HAVE_X11_TRUE@
+HAVE_XCBSHM_FALSE = @HAVE_XCBSHM_FALSE@
+HAVE_XCBSHM_TRUE = @HAVE_XCBSHM_TRUE@
+HAVE_XCBXV_FALSE = @HAVE_XCBXV_FALSE@
+HAVE_XCBXV_TRUE = @HAVE_XCBXV_TRUE@
+HAVE_XCB_FALSE = @HAVE_XCB_FALSE@
+HAVE_XCB_TRUE = @HAVE_XCB_TRUE@
HAVE_XVMC_FALSE = @HAVE_XVMC_FALSE@
HAVE_XVMC_TRUE = @HAVE_XVMC_TRUE@
HAVE_XV_FALSE = @HAVE_XV_FALSE@
@@ -359,6 +362,7 @@ LIBSTK_CFLAGS = @LIBSTK_CFLAGS@
LIBSTK_LIBS = @LIBSTK_LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIBVCDINFO_CFLAGS = @LIBVCDINFO_CFLAGS@
LIBVCDINFO_LIBS = @LIBVCDINFO_LIBS@
LIBVCD_CFLAGS = @LIBVCD_CFLAGS@
LIBVCD_LIBS = @LIBVCD_LIBS@
@@ -379,7 +383,10 @@ MLIB_LIBS = @MLIB_LIBS@
MNG_LIBS = @MNG_LIBS@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
+MUSEPACK_FALSE = @MUSEPACK_FALSE@
+MUSEPACK_TRUE = @MUSEPACK_TRUE@
NET_LIBS = @NET_LIBS@
+NOUNDEF = @NOUNDEF@
OBJC = @OBJC@
OBJCDEPMODE = @OBJCDEPMODE@
OBJCFLAGS = @OBJCFLAGS@
@@ -400,6 +407,8 @@ PKG_CONFIG = @PKG_CONFIG@
POSUB = @POSUB@
PPC_ARCH_FALSE = @PPC_ARCH_FALSE@
PPC_ARCH_TRUE = @PPC_ARCH_TRUE@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@
PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@
RANLIB = @RANLIB@
@@ -413,28 +422,32 @@ SPEC_VERSION = @SPEC_VERSION@
SPEEX_CFLAGS = @SPEEX_CFLAGS@
SPEEX_LIBS = @SPEEX_LIBS@
STATIC = @STATIC@
+STRINGS = @STRINGS@
STRIP = @STRIP@
SUNDGA_CFLAGS = @SUNDGA_CFLAGS@
SUNDGA_LIBS = @SUNDGA_LIBS@
TAR_NAME = @TAR_NAME@
THEORA_CFLAGS = @THEORA_CFLAGS@
THEORA_LIBS = @THEORA_LIBS@
-THREAD_CPPFLAGS = @THREAD_CPPFLAGS@
-THREAD_LIBS = @THREAD_LIBS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
VISIBILITY_FLAG = @VISIBILITY_FLAG@
VORBIS_CFLAGS = @VORBIS_CFLAGS@
VORBIS_LIBS = @VORBIS_LIBS@
-W32DLL_DEP = @W32DLL_DEP@
W32_NO_OPTIMIZE = @W32_NO_OPTIMIZE@
WAND_CFLAGS = @WAND_CFLAGS@
WAND_LIBS = @WAND_LIBS@
+WAVPACK_CFLAGS = @WAVPACK_CFLAGS@
+WAVPACK_LIBS = @WAVPACK_LIBS@
WIN32_CPPFLAGS = @WIN32_CPPFLAGS@
WIN32_FALSE = @WIN32_FALSE@
WIN32_TRUE = @WIN32_TRUE@
-X11_CFLAGS = @X11_CFLAGS@
-X11_LIBS = @X11_LIBS@
+XCBSHM_CFLAGS = @XCBSHM_CFLAGS@
+XCBSHM_LIBS = @XCBSHM_LIBS@
+XCBXV_CFLAGS = @XCBXV_CFLAGS@
+XCBXV_LIBS = @XCBXV_LIBS@
+XCB_CFLAGS = @XCB_CFLAGS@
+XCB_LIBS = @XCB_LIBS@
XGETTEXT = @XGETTEXT@
XINERAMA_CFLAGS = @XINERAMA_CFLAGS@
XINERAMA_LIBS = @XINERAMA_LIBS@
@@ -472,6 +485,7 @@ ZLIB_CPPFLAGS = @ZLIB_CPPFLAGS@
ZLIB_LIBS = @ZLIB_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
+ac_ct_OBJC = @ac_ct_OBJC@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -519,7 +533,7 @@ sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
w32_path = @w32_path@
-AUTOMAKE_OPTIONS = 1.3
+AUTOMAKE_OPTIONS = 1.8 no-dist-gzip dist-bzip2
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = doc m4 po misc include lib src win32 contrib
DEBFILES = debian/README.Debian debian/changelog debian/control \
@@ -601,28 +615,6 @@ $(srcdir)/config.h.in: $(am__configure_deps)
distclean-hdr:
-rm -f config.h stamp-h1
-contrib/Makefile: $(top_builddir)/config.status $(top_srcdir)/contrib/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-contrib/ffmpeg/makefile.xine: $(top_builddir)/config.status $(top_srcdir)/contrib/ffmpeg/makefile.xine.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/armv4l/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/armv4l/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/i386/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/i386/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/mlib/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/mlib/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/alpha/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/alpha/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/ppc/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/ppc/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/sparc/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/sparc/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavcodec/libpostproc/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavcodec/libpostproc/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-src/libffmpeg/libavutil/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/libffmpeg/libavutil/Makefile.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
@@ -769,7 +761,7 @@ distclean-tags:
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
- $(mkdir_p) $(distdir)/contrib $(distdir)/contrib/ffmpeg $(distdir)/include $(distdir)/m4 $(distdir)/misc $(distdir)/po $(distdir)/src/libffmpeg/libavcodec $(distdir)/src/libffmpeg/libavcodec/alpha $(distdir)/src/libffmpeg/libavcodec/armv4l $(distdir)/src/libffmpeg/libavcodec/i386 $(distdir)/src/libffmpeg/libavcodec/libpostproc $(distdir)/src/libffmpeg/libavcodec/mlib $(distdir)/src/libffmpeg/libavcodec/ppc $(distdir)/src/libffmpeg/libavcodec/sparc $(distdir)/src/libffmpeg/libavutil
+ $(mkdir_p) $(distdir)/include $(distdir)/m4 $(distdir)/misc $(distdir)/po
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
@@ -819,7 +811,6 @@ distdir: $(DISTFILES)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
-
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
@@ -838,7 +829,7 @@ dist-zip: distdir
$(am__remove_distdir)
dist dist-all: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
@@ -957,6 +948,8 @@ install-data-am:
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
install-exec-am:
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
install-info: install-info-recursive
@@ -983,6 +976,8 @@ ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
+ @$(NORMAL_INSTALL)
+ $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
uninstall-info: uninstall-info-recursive
@@ -994,13 +989,14 @@ uninstall-info: uninstall-info-recursive
distclean-recursive distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am \
- install-data-hook install-exec install-exec-am install-info \
- install-info-am install-man install-strip installcheck \
- installcheck-am installdirs installdirs-am maintainer-clean \
- maintainer-clean-generic maintainer-clean-recursive \
- mostlyclean mostlyclean-generic mostlyclean-libtool \
- mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
- uninstall uninstall-am uninstall-info-am
+ install-data-hook install-exec install-exec-am \
+ install-exec-hook install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ installdirs-am maintainer-clean maintainer-clean-generic \
+ maintainer-clean-recursive mostlyclean mostlyclean-generic \
+ mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \
+ tags tags-recursive uninstall uninstall-am uninstall-hook \
+ uninstall-info-am
docs:
@@ -1041,6 +1037,17 @@ slackbuild:
@(cd misc && $(MAKE) SlackBuild) && \
PREFIX="/usr" misc/SlackBuild
+install-exec-hook:
+ find $(top_builddir) -name \*.so | \
+ xargs $(STRINGS) -a | \
+ $(EGREP) '^([-a-z]+/[-+.a-z0-9]+:[^:]+:[^;]+;[ \t]*)+' | \
+ sed -e 's/:[^;]\+;/\n/g' | \
+ sort -u | \
+ sed -e '1 d' >$(DESTDIR)$(XINE_PLUGINDIR)/mime.types
+
+uninstall-hook:
+ rm -f $(DESTDIR)$(XINE_PLUGINDIR)/mime.types
+
install-data-hook:
@rm -f $(DESTDIR)$(XINE_PLUGINDIR)/*.la
@rm -f $(DESTDIR)$(XINE_PLUGINDIR)/*/*.la
diff --git a/configure.ac b/configure.ac
index 97702dd5f..dc3663bf9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2588,7 +2588,6 @@ doc/man/en/Makefile
doc/hackersguide/Makefile
doc/faq/Makefile
contrib/Makefile
-contrib/ffmpeg/makefile.xine
include/Makefile
include/xine.h
lib/Makefile
diff --git a/contrib/ffmpeg/Changelog b/contrib/ffmpeg/Changelog
index 5267b5321..0b96efe85 100644
--- a/contrib/ffmpeg/Changelog
+++ b/contrib/ffmpeg/Changelog
@@ -38,7 +38,7 @@ version <next>
- ADTS AAC file reading and writing
- Creative VOC file reading and writing
- American Laser Games multimedia (*.mm) playback system
-- Zip Blocks Motion Video decoder
+- Zip Blocks Motion Video decoder and encoder
- Improved Theora/VP3 decoder
- True Audio (TTA) decoder
- AVS demuxer and video decoder
@@ -66,6 +66,17 @@ version <next>
- TIFF picture decoder
- GIF picture decoder
- Intel Music decoder
+- Musepack decoder
+- Flash Screen Video encoder
+- Theora encoding via libtheora
+- BMP encoder
+- WMA encoder
+- GSM-MS encoder and decoder
+- DCA decoder
+- DXA demuxer and decoder
+- DNxHD decoder
+- Gamecube movie (.THP) playback system
+- Blackfin optimizations
version 0.4.9-pre1:
diff --git a/contrib/ffmpeg/MAINTAINERS b/contrib/ffmpeg/MAINTAINERS
index 410523390..beff7bb76 100644
--- a/contrib/ffmpeg/MAINTAINERS
+++ b/contrib/ffmpeg/MAINTAINERS
@@ -31,7 +31,7 @@ ffplay:
ffplay.c
ffserver:
- ffserver.c, ffserver.h
+ ffserver.c, ffserver.h Alex Beregszaszi
Commandline utility code:
cmdutils.c, cmdutils.h
@@ -88,6 +88,7 @@ Generic Parts:
dsputils.c, dsputils.h Michael Niedermayer
entropy coding:
rangecoder.c, rangecoder.h Michael Niedermayer
+ lzw.* Michael Niedermayer
floating point AAN DCT:
faandct.c, faandct.h Michael Niedermayer
Golomb coding:
@@ -106,6 +107,7 @@ Codecs:
4xm.c Michael Niedermayer
8bps.c Roberto Togni
aasc.c Kostya Shishkov
+ ac3* Justin Ruggles
asv* Michael Niedermayer
bmp.c Mans Rullgard
cavs* Stefan Gehrer
@@ -113,12 +115,14 @@ Codecs:
cljr Alex Beregszaszi
cook.c, cookdata.h Benjamin Larsson
cscd.c Reimar Doeffinger
+ dnxhddec.c Baptiste Coudurier
dpcm.c Mike Melanson
+ dxa.c Kostya Shishkov
dv.c Roman Shaposhnik
ffv1.c Michael Niedermayer
flac.c Alex Beregszaszi
flacenc.c Justin Ruggles
- flashsv.c Benjamin Larsson
+ flashsv* Benjamin Larsson
flicvideo.c Mike Melanson
g726.c Roman Shaposhnik
gifdec.c Baptiste Coudurier
@@ -133,10 +137,12 @@ Codecs:
jpeg_ls.c Kostya Shishkov
kmvc.c Kostya Shishkov
lcl.c Roberto Togni
+ libgsm.c Michel Bardiaux
loco.c Kostya Shishkov
lzo.h, lzo.c Reimar Doeffinger
mdec.c Michael Niedermayer
mjpeg.c Michael Niedermayer
+ mpc* Kostya Shishkov
mpeg12.c, mpeg12data.h Michael Niedermayer
mpegvideo.c, mpegvideo.h Michael Niedermayer
msmpeg4.c, msmpeg4data.h Michael Niedermayer
@@ -179,7 +185,7 @@ Codecs:
xan.c Mike Melanson
xl.c Kostya Shishkov
xvmcvideo.c Ivan Kalvachev
- zmbv.c Kostya Shishkov
+ zmbv* Kostya Shishkov
libavformat
@@ -200,6 +206,7 @@ Muxers/Demuxers:
crc.c Michael Niedermayer
daud.c Reimar Doeffinger
dc1394.c, dv.c Roman Shaposhnik
+ dxa.c Kostya Shishkov
flic.c Mike Melanson
flvdec.c, flvenc.c Michael Niedermayer
gxf.c Reimar Doeffinger
@@ -208,14 +215,16 @@ Muxers/Demuxers:
idroq.c Mike Melanson
ipmovie.c Mike Melanson
img2.c Michael Niedermayer
+ libnut.c Oded Shimon
matroska.c Aurelien Jacobs
- mov.c Francois Revol, Michael Niedermayer
+ mov.c Michael Niedermayer, Baptiste Coudurier
movenc.c Michael Niedermayer, Baptiste Coudurier
+ mpc.c Kostya Shishkov
mpegts* Mans Rullgard
mtv.c Reynaldo H. Verdejo Pinochet
mxf.c Baptiste Coudurier
nsvdec.c Francois Revol
- nut.c Alex Beregszaszi
+ nut.c Michael Niedermayer
nuv.c Reimar Doeffinger
ogg2.c, ogg2.h Mans Rullgard
oggparsevorbis.c Mans Rullgard
@@ -224,6 +233,7 @@ Muxers/Demuxers:
raw.c Michael Niedermayer
rm.c Roberto Togni
segafilm.c Mike Melanson
+ swf.c Baptiste Coudurier
v4l2.c Luca Abeni
voc.c Aurelien Jacobs
wav.c Michael Niedermayer
@@ -241,3 +251,4 @@ i386 Michael Niedermayer
Mac OS X / PowerPC Romain Dolbeau
Amiga / PowerPC Colin Ward
Linux / PowerPC Luca Barbato
+Windows MinGW Alex Beregszaszi
diff --git a/contrib/ffmpeg/Makefile b/contrib/ffmpeg/Makefile
index 929522c3b..d49bb1c76 100644
--- a/contrib/ffmpeg/Makefile
+++ b/contrib/ffmpeg/Makefile
@@ -11,22 +11,13 @@ CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE
LDFLAGS+= -g
-ifeq ($(CONFIG_FFMPEG),yes)
-MANPAGES=doc/ffmpeg.1
-PROGS_G+=ffmpeg_g$(EXESUF)
-PROGS+=ffmpeg$(EXESUF)
-endif
-
-ifeq ($(CONFIG_FFSERVER),yes)
-MANPAGES+=doc/ffserver.1
-PROGS+=ffserver$(EXESUF)
-endif
+PROGS-$(CONFIG_FFMPEG) += ffmpeg
+PROGS-$(CONFIG_FFPLAY) += ffplay
+PROGS-$(CONFIG_FFSERVER) += ffserver
-ifeq ($(CONFIG_FFPLAY),yes)
-MANPAGES+=doc/ffplay.1
-PROGS_G+=ffplay_g$(EXESUF)
-PROGS+=ffplay$(EXESUF)
-endif
+PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
+PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
+MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
BASENAMES=ffmpeg ffplay ffserver
ALLPROGS=$(addsuffix $(EXESUF), $(BASENAMES))
@@ -40,17 +31,16 @@ DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(L
endif
ifeq ($(CONFIG_VHOOK),yes)
-VHOOK=videohook
-INSTALLVHOOK=install-vhook
+all: videohook
+install: install-vhook
endif
ifeq ($(BUILD_DOC),yes)
-DOC=documentation
-INSTALLMAN=install-man
+all: documentation
+install: install-man
endif
-OBJS = ffmpeg.o ffserver.o cmdutils.o ffplay.o
-SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
+SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
LDFLAGS := -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
EXTRALIBS := -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
@@ -59,7 +49,7 @@ LDFLAGS+=-L./libswscale
EXTRALIBS+=-lswscale$(BUILDSUF)
endif
-all: lib $(PROGS_G) $(PROGS) $(VHOOK) $(DOC)
+all: lib $(PROGS)
lib:
$(MAKE) -C libavutil all
@@ -85,6 +75,11 @@ ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
cp -p $< $@
$(STRIP) $@
+SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
+ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
+version.h: $(SVN_ENTRIES)
+endif
+
version.h:
$(SRC_PATH)/version.sh $(SRC_PATH)
@@ -111,7 +106,7 @@ videohook: .libs
documentation:
$(MAKE) -C doc all
-install: install-progs install-libs install-headers $(INSTALLMAN) $(INSTALLVHOOK)
+install: install-progs install-libs install-headers
ifeq ($(BUILD_SHARED),yes)
install-progs: $(PROGS) install-libs
@@ -119,9 +114,9 @@ else
install-progs: $(PROGS)
endif
install -d "$(bindir)"
- install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
+ install -c -m 755 $(PROGS) "$(bindir)"
-# create the window installer
+# Create the Windows installer.
wininstaller: all install
makensis ffinstall.nsi
@@ -198,9 +193,10 @@ endif
.depend: $(SRCS) version.h
$(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
-.libs: lib
- @test -f .libs || touch .libs
- @for i in $(DEP_LIBS) ; do if test $$i -nt .libs ; then touch .libs; fi ; done
+$(DEP_LIBS): lib
+
+.libs: $(DEP_LIBS)
+ touch $@
clean:
$(MAKE) -C libavutil clean
@@ -236,6 +232,4 @@ codectest libavtest test-server fulltest test mpeg4 mpeg: $(PROGS)
.PHONY: dep depend clean distclean TAGS
.PHONY: codectest libavtest test-server fulltest test mpeg4 mpeg
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+-include .depend
diff --git a/contrib/ffmpeg/README b/contrib/ffmpeg/README
index ad98fc645..9f905357e 100644
--- a/contrib/ffmpeg/README
+++ b/contrib/ffmpeg/README
@@ -10,10 +10,10 @@ FFmpeg README
------------
* Read the file COPYING. ffmpeg and the associated libraries EXCEPT
- liba52 and libpostproc are licensed under the Lesser GNU General
+ libpostproc and libswscale are licensed under the GNU Lesser General
Public License.
-* liba52 and libpostproc are distributed under the GNU General Public
+* libpostproc and libswscale are distributed under the GNU General Public
License and their compilation and use is optional in ffmpeg.
Fabrice Bellard.
diff --git a/contrib/ffmpeg/berrno.h b/contrib/ffmpeg/berrno.h
deleted file mode 100644
index eb3bd0cd4..000000000
--- a/contrib/ffmpeg/berrno.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef BERRNO_H
-#define BERRNO_H
-
-#include <Errors.h>
-
-// mmu_man: this is needed for http.c (defined errno)
-#include <errno.h>
-
-#ifdef ENOENT
-#undef ENOENT
-#endif
-#define ENOENT 2
-
-#ifdef EINTR
-#undef EINTR
-#endif
-#define EINTR 4
-
-#ifdef EIO
-#undef EIO
-#endif
-#define EIO 5
-
-#ifdef EAGAIN
-#undef EAGAIN
-#endif
-#define EAGAIN 11
-
-#ifdef ENOMEM
-#undef ENOMEM
-#endif
-#define ENOMEM 12
-
-#ifdef EINVAL
-#undef EINVAL
-#endif
-#define EINVAL 22
-
-#ifdef EPIPE
-#undef EPIPE
-#endif
-#define EPIPE 32
-
-#endif /* BERRNO_H */
diff --git a/contrib/ffmpeg/cmdutils.c b/contrib/ffmpeg/cmdutils.c
index 2c53d90da..d5095cec8 100644
--- a/contrib/ffmpeg/cmdutils.c
+++ b/contrib/ffmpeg/cmdutils.c
@@ -24,6 +24,8 @@
#include "cmdutils.h"
+#undef exit
+
void show_help_options(const OptionDef *options, const char *msg, int mask, int value)
{
const OptionDef *po;
@@ -96,6 +98,8 @@ unknown_opt:
*po->u.int_arg = 1;
} else if (po->flags & OPT_INT) {
*po->u.int_arg = atoi(arg);
+ } else if (po->flags & OPT_INT64) {
+ *po->u.int64_arg = atoll(arg);
} else if (po->flags & OPT_FLOAT) {
*po->u.float_arg = atof(arg);
} else if (po->flags & OPT_FUNC2) {
diff --git a/contrib/ffmpeg/cmdutils.h b/contrib/ffmpeg/cmdutils.h
index d9c66f015..13a61c09d 100644
--- a/contrib/ffmpeg/cmdutils.h
+++ b/contrib/ffmpeg/cmdutils.h
@@ -1,3 +1,24 @@
+/*
+ * Various utilities for command line tools
+ * copyright (c) 2003 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
+ */
+
#ifndef _CMD_UTILS_H
#define _CMD_UTILS_H
@@ -15,12 +36,14 @@ typedef struct {
#define OPT_FLOAT 0x0100
#define OPT_SUBTITLE 0x0200
#define OPT_FUNC2 0x0400
+#define OPT_INT64 0x0800
union {
void (*func_arg)(const char *); //FIXME passing error code as int return would be nicer then exit() in the func
int *int_arg;
char **str_arg;
float *float_arg;
int (*func2_arg)(const char *, const char *);
+ int64_t *int64_arg;
} u;
const char *help;
const char *argname;
diff --git a/contrib/ffmpeg/common.mak b/contrib/ffmpeg/common.mak
index d4a8dca41..7989b9021 100644
--- a/contrib/ffmpeg/common.mak
+++ b/contrib/ffmpeg/common.mak
@@ -5,6 +5,10 @@
VPATH = $(SRC_PATH_BARE)/lib$(NAME)
SRC_DIR = "$(VPATH)"
+CFLAGS += $(CFLAGS-yes)
+OBJS += $(OBJS-yes)
+ASM_OBJS += $(ASM_OBJS-yes)
+
CFLAGS += -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-D_ISOC9X_SOURCE -I$(BUILD_ROOT) -I$(SRC_PATH) \
-I$(SRC_PATH)/libavutil $(OPTFLAGS)
@@ -33,10 +37,6 @@ $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
%.o: %.S
$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
-# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
-%.o: %.cpp
- g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
-
%: %.o $(LIB)
$(CC) $(LDFLAGS) -o $@ $^ $(EXTRALIBS)
@@ -63,12 +63,13 @@ install-libs: $(INSTLIBTARGETS)
install-lib-shared: $(SLIBNAME)
install -d "$(shlibdir)"
- install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
- "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
+ install -m 755 $(SLIBNAME) "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
+ $(STRIP) "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
cd "$(shlibdir)" && \
ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
cd "$(shlibdir)" && \
ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
+ $(SLIB_INSTALL_EXTRA_CMD)
install-lib-static: $(LIB)
install -d "$(libdir)"
@@ -95,6 +96,4 @@ uninstall-headers:
.PHONY: all depend dep clean distclean install* uninstall*
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+-include .depend
diff --git a/contrib/ffmpeg/configure b/contrib/ffmpeg/configure
index 8da8f0916..12f2877d2 100755
--- a/contrib/ffmpeg/configure
+++ b/contrib/ffmpeg/configure
@@ -11,12 +11,19 @@
# try to make this part work with most shells
try_exec(){
+ echo "Trying shell $1"
type "$1" >/dev/null 2>&1 && exec "$@"
}
unset foo
-(: ${foo%%bar}) 2>/dev/null && ! (: ${foo?}) 2>/dev/null
-if test "$?" != 0; then
+(: ${foo%%bar}) 2>/dev/null
+E1="$?"
+
+(: ${foo?}) 2>/dev/null
+E2="$?"
+
+if test "$E1" != 0 || test "$E2" = 0; then
+ echo "Broken shell detected. Trying alternatives."
export FF_CONF_EXEC
if test "0$FF_CONF_EXEC" -lt 1; then
FF_CONF_EXEC=1
@@ -31,8 +38,11 @@ if test "$?" != 0; then
try_exec /usr/xpg4/bin/sh "$0" "$@"
fi
echo "No compatible shell script interpreter found."
- echo "This configure script requires a POSIX compatible shell"
+ echo "This configure script requires a POSIX-compatible shell"
echo "such as bash or ksh."
+ echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
+ echo "Instead, install a working POSIX-compatible shell."
+ echo "Disabling this configure test will create a broken FFmpeg."
if test "$BASH_VERSION" = '2.04.0(1)-release'; then
echo "This bash version ($BASH_VERSION) is broken on your platform."
echo "Upgrade to a later version if available."
@@ -52,44 +62,53 @@ show_help(){
echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
echo " --incdir=DIR install includes in DIR [PREFIX/include/ffmpeg]"
echo " --mandir=DIR install man page in DIR [PREFIX/man]"
- echo " --enable-mp3lame enable MP3 encoding via libmp3lame [default=no]"
- echo " --enable-libnut enable NUT support via libnut [default=no]"
- echo " --enable-libogg enable Ogg support via libogg [default=no]"
- echo " --enable-vorbis enable Vorbis support via libvorbis [default=no]"
- echo " --enable-faad enable FAAD support via libfaad [default=no]"
- echo " --enable-faadbin build FAAD support with runtime linking [default=no]"
- echo " --enable-faac enable FAAC support via libfaac [default=no]"
- echo " --enable-libgsm enable GSM support via libgsm [default=no]"
- echo " --enable-xvid enable XviD support via xvidcore [default=no]"
- echo " --enable-x264 enable H.264 encoding via x264 [default=no]"
- echo " --enable-mingw32 enable MinGW native/cross Windows compile"
echo " --enable-mingwce enable MinGW native/cross WinCE compile"
- echo " --enable-a52 enable GPLed A52 support [default=no]"
- echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
- echo " --enable-dts enable GPLed DTS support [default=no]"
- echo " --enable-pp enable GPLed postprocessing support [default=no]"
echo " --enable-static build static libraries [default=yes]"
echo " --disable-static do not build static libraries [default=no]"
echo " --enable-shared build shared libraries [default=no]"
echo " --disable-shared do not build shared libraries [default=yes]"
- echo " --enable-amr_nb enable amr_nb float audio codec"
- echo " --enable-amr_nb-fixed use fixed point for amr-nb codec"
- echo " --enable-amr_wb enable amr_wb float audio codec"
- echo " --enable-amr_if2 enable amr_wb IF2 audio codec"
- echo " --enable-sunmlib use Sun medialib [default=no]"
+ echo " --enable-gpl allow use of GPL code, the resulting libav*"
+ echo " and ffmpeg will be under GPL [default=no]"
+ echo " --enable-pp enable GPLed postprocessing support [default=no]"
+ echo " --enable-swscaler software scaler support [default=no]"
+ echo " --enable-beosthreads use BeOS threads [default=no]"
+ echo " --enable-os2threads use OS/2 threads [default=no]"
echo " --enable-pthreads use pthreads [default=no]"
+ echo " --enable-w32threads use Win32 threads [default=no]"
+ echo " --enable-x11grab enable X11 grabbing [default=no]"
+ echo
+ echo "External library support:"
+ echo " --enable-sunmlib use Sun medialib [default=no]"
echo " --enable-dc1394 enable IIDC-1394 grabbing using libdc1394"
echo " and libraw1394 [default=no]"
- echo " --enable-swscaler software scaler support [default=no]"
+ echo " --enable-liba52 enable GPLed liba52 support [default=no]"
+ echo " --enable-liba52bin open liba52.so.0 at runtime [default=no]"
echo " --enable-avisynth allow reading AVISynth script files [default=no]"
- echo " --enable-gpl allow use of GPL code, the resulting libav*"
- echo " and ffmpeg will be under GPL [default=no]"
+ echo " --enable-libdts enable GPLed libdts support [default=no]"
+ echo " --enable-libfaac enable FAAC support via libfaac [default=no]"
+ echo " --enable-libfaad enable FAAD support via libfaad [default=no]"
+ echo " --enable-libfaadbin build FAAD support with runtime linking [default=no]"
+ echo " --enable-libgsm enable GSM support via libgsm [default=no]"
+ echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [default=no]"
+ echo " --enable-libnut enable NUT (de)muxing via libnut,"
+ echo " native demuxer exists [default=no]"
+ echo " --enable-libogg enable Ogg muxing via libogg [default=no]"
+ echo " --enable-libtheora enable Theora encoding via libtheora [default=no]"
+ echo " --enable-libvorbis enable Vorbis en/decoding via libvorbis,"
+ echo " native implementations exist [default=no]"
+ echo " --enable-x264 enable H.264 encoding via x264 [default=no]"
+ echo " --enable-xvid enable Xvid encoding via xvidcore,"
+ echo " native MPEG-4/Xvid encoder exists [default=no]"
+ echo " --enable-amr-nb enable amr-nb floating point audio codec"
+ echo " --enable-amr-nb-fixed enable amr-nb fixed-point codec"
+ echo " --enable-amr-wb enable amr-wb floating point audio codec"
+ echo " --enable-amr-if2 enable amr-wb IF2 audio codec"
echo ""
echo "Advanced options (experts only):"
echo " --source-path=PATH path to source code [$source_path]"
- echo " --build-path=PATH path to build directory [.]"
echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
echo " --cross-compile assume a cross-compiler is used"
+ echo " --target-os=OS compiler targets OS [$targetos]"
echo " --cc=CC use C compiler CC [$cc]"
echo " --make=MAKE use specified make [$make]"
echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
@@ -97,12 +116,13 @@ show_help(){
echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
echo " --build-suffix=SUFFIX suffix for application specific build []"
echo " --arch=ARCH select architecture [$arch]"
- echo " --cpu=CPU selects the minimum cpu required (affects
- instruction selection, may crash on older CPUs)"
- echo " --powerpc-perf-enable enable performance report on PPC"
+ echo " --cpu=CPU selects the minimum cpu required (affects"
+ echo " instruction selection, may crash on older CPUs)"
+ echo " --enable-powerpc-perf enable performance report on PPC"
echo " (requires enabling PMC)"
echo " --disable-mmx disable MMX usage"
echo " --disable-armv5te disable armv5te usage"
+ echo " --disable-armv6 disable armv6 usage"
echo " --disable-iwmmxt disable iwmmxt usage"
echo " --disable-altivec disable AltiVec usage"
echo " --disable-audio-oss disable OSS audio support [default=no]"
@@ -115,10 +135,7 @@ show_help(){
echo " --disable-ipv6 disable ipv6 support [default=no]"
echo " --disable-zlib disable zlib [default=no]"
echo " --disable-vhook disable video hooking support"
- echo " --enable-gprof enable profiling with gprof [$gprof]"
echo " --disable-debug disable debugging symbols"
- echo " --disable-opts disable compiler optimizations"
- echo " --enable-extra-warnings enable more compiler warnings"
echo " --disable-mpegaudio-hp faster (but less accurate)"
echo " MPEG audio decoding [default=no]"
echo " --disable-protocols disable I/O protocols support [default=no]"
@@ -127,7 +144,6 @@ show_help(){
echo " --disable-ffplay disable ffplay build"
echo " --enable-small optimize for size instead of speed"
echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
- echo " --disable-strip disable stripping of executables and shared libraries"
echo " --disable-encoder=NAME disables encoder NAME"
echo " --enable-encoder=NAME enables encoder NAME"
echo " --disable-decoder=NAME disables decoder NAME"
@@ -143,6 +159,12 @@ show_help(){
echo " --enable-parser=NAME enables parser NAME"
echo " --disable-parser=NAME disables parser NAME"
echo " --disable-parsers disables all parsers"
+ echo
+ echo "Developer options (useful when working on FFmpeg itself):"
+ echo " --enable-gprof enable profiling with gprof [$gprof]"
+ echo " --disable-opts disable compiler optimizations"
+ echo " --enable-extra-warnings enable more compiler warnings"
+ echo " --disable-strip disable stripping of executables and shared libraries"
echo ""
echo "NOTE: Object files are built at the place where configure is launched."
exit 1
@@ -190,6 +212,10 @@ toupper(){
echo "$@" | tr '[a-z]' '[A-Z]'
}
+tolower(){
+ echo "$@" | tr '[A-Z]' '[a-z]'
+}
+
set_all(){
value=$1
shift
@@ -198,6 +224,25 @@ set_all(){
done
}
+pushvar(){
+ for var in $*; do
+ eval level=\${${var}_level:=0}
+ eval ${var}_${level}="\$$var"
+ eval ${var}_level=$(($level+1))
+ done
+}
+
+popvar(){
+ for var in $*; do
+ eval level=\${${var}_level:-0}
+ test $level = 0 && continue
+ eval level=$(($level-1))
+ eval $var="\${${var}_${level}}"
+ eval ${var}_level=$level
+ eval unset ${var}_${level}
+ done
+}
+
enable(){
set_all yes $*
}
@@ -210,18 +255,54 @@ enabled(){
eval test "x\$$1" = "xyes"
}
+disabled(){
+ eval test "x\$$1" = "xno"
+}
+
enabled_all(){
for opt; do
enabled $opt || return 1
done
}
+disabled_all(){
+ for opt; do
+ disabled $opt || return 1
+ done
+}
+
enabled_any(){
for opt; do
enabled $opt && return 0
done
}
+disabled_any(){
+ for opt; do
+ disabled $opt && return 0
+ done
+}
+
+check_deps(){
+ for cfg; do
+ enabled ${cfg}_checking && die "Circular dependency for $cfg."
+ disabled ${cfg}_checking && continue
+ enable ${cfg}_checking
+
+ eval dep_all="\$${cfg}_deps"
+ eval dep_any="\$${cfg}_deps_any"
+
+ pushvar cfg dep_all dep_any
+ check_deps $dep_all $dep_any
+ popvar cfg dep_all dep_any
+
+ enabled_all $dep_all || disable $cfg
+ enabled_any $dep_any || disable $cfg
+
+ disable ${cfg}_checking
+ done
+}
+
print_config(){
pfx=$1
header=$2
@@ -248,6 +329,7 @@ save_flags(){
}
restore_flags(){
+ flags_saved || return
CFLAGS="$SAVE_CFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
extralibs="$SAVE_extralibs"
@@ -335,29 +417,45 @@ check_header(){
log check_header "$@"
header=$1
shift
- check_cpp "$@" <<EOF
+ var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
+ disable $var
+ check_cpp "$@" <<EOF && enable $var
#include <$header>
int x;
EOF
- err=$?
- var=`echo $header | sed 's/[^[:alnum:]]/_/g'`
- test "$err" = 0 && enable $var || disable $var
- return $err
}
check_func(){
log check_func "$@"
func=$1
shift
- check_ld "$@" <<EOF
+ disable $func
+ check_ld "$@" <<EOF && enable $func
extern int $func();
int main(){
$func();
}
EOF
- err=$?
- test "$err" = 0 && enable $func || disable $func
- return $err
+}
+
+check_func2(){
+ log check_func2 "$@"
+ headers=$1
+ func=$2
+ shift 2
+ disable $func
+ incs=""
+ for hdr in $headers; do
+ incs="$incs
+#include <$hdr>"
+ done
+ check_ld "$@" <<EOF && enable $func
+$incs
+int main(){
+ (void) $func;
+ return 0;
+}
+EOF
}
check_lib(){
@@ -372,8 +470,20 @@ check_lib(){
return $err
}
+check_lib2(){
+ log check_lib2 "$@"
+ headers="$1"
+ func="$2"
+ shift 2
+ temp_extralibs "$@"
+ check_func2 "$headers" $func && add_extralibs "$@"
+ err=$?
+ restore_flags
+ return $err
+}
+
check_exec(){
- check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
+ check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
}
require(){
@@ -384,14 +494,43 @@ require(){
check_lib $header $func "$@" || die "ERROR: $name not found"
}
+require2(){
+ name="$1"
+ headers="$2"
+ func="$3"
+ shift 3
+ check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
+}
+
+check_foo_config(){
+ cfg=$1
+ pkg=$2
+ header=$3
+ func=$4
+ shift 4
+ disable $cfg
+ check_cmd ${pkg}-config --version
+ err=$?
+ if test "$err" = 0; then
+ temp_cflags `${pkg}-config --cflags`
+ temp_extralibs `${pkg}-config --libs`
+ check_lib "$@" $header $func && enable $cfg
+ fi
+ return $err
+}
+
+apply(){
+ file=$1
+ shift
+ "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
+}
+
CONFIG_LIST='
encoders
decoders
parsers
muxers
demuxers
- a52
- a52bin
amr
amr_nb
amr_nb_fixed
@@ -402,61 +541,161 @@ CONFIG_LIST='
beos_netserver
bktr
dc1394
- dts
dv1394
- faac
- faad
- faadbin
+ ebp_available
+ ebx_available
ffmpeg
ffplay
ffserver
gpl
+ gprof
ipv6
+ liba52
+ liba52bin
+ libdts
+ libfaac
+ libfaad
+ libfaadbin
libgsm
+ libmp3lame
libnut
libogg
+ libtheora
libvorbis
memalign_hack
- mp3lame
mpegaudio_hp
network
+ powerpc_perf
pp
protocols
swscaler
vhook
- video4linux
- video4linux2
+ v4l
+ v4l2
wince
+ x11grab
x264
xvid
zlib
'
-HAVE_LIST='
- altivec_h
+THREADS_LIST='
beosthreads
+ os2threads
+ pthreads
+ w32threads
+'
+
+HAVE_LIST="
+ $THREADS_LIST
+ altivec
+ altivec_h
+ armv5te
+ armv6
+ arpa_inet_h
byteswap_h
+ cmov
dcbzl
+ dev_bktr_ioctl_bt848_h
+ dev_bktr_ioctl_meteor_h
+ dev_ic_bt8xx_h
+ dev_video_meteor_ioctl_meteor_h
+ dev_video_bktr_ioctl_bt848_h
dlfcn_h
dlopen
+ fast_64bit
+ fast_cmov
freetype2
- gprof
imlib2
inet_aton
+ iwmmxt
localtime_r
lrintf
+ machine_ioctl_bt848_h
+ machine_ioctl_meteor_h
malloc_h
memalign
mlib
+ mmi
+ mmx
os2
- os2threads
- pthreads
sdl
sdl_video_size
+ soundcard_h
+ sys_poll_h
+ sys_soundcard_h
threads
- w32threads
+"
+
+TARGET_LIST='
+ altivec
+ armv5te
+ armv6
+ iwmmxt
+ mmi
+ mmx
'
+CMDLINE_SELECT="
+ $CONFIG_LIST
+ $TARGET_LIST
+ $THREADS_LIST
+ amr_if2
+ debug
+ extra_warnings
+ shared
+ static
+"
+
+dxa_decoder_deps="zlib"
+flashsv_decoder_deps="zlib"
+flashsv_encoder_deps="zlib"
+mpeg_xvmc_decoder_deps="xvmc"
+png_decoder_deps="zlib"
+png_encoder_deps="zlib"
+x264_encoder_deps="x264"
+xvid_encoder_deps="xvid"
+zmbv_decoder_deps="zlib"
+zmbv_encoder_deps="zlib"
+
+aac_decoder_deps="libfaad"
+mpeg4aac_decoder_deps="libfaad"
+amr_nb_decoder_deps_any="amr_nb amr_nb_fixed"
+amr_nb_encoder_deps_any="amr_nb amr_nb_fixed"
+amr_wb_decoder_deps="amr_wb"
+amr_wb_encoder_deps="amr_wb"
+dts_decoder_deps="libdts"
+faac_encoder_deps="libfaac"
+liba52_decoder_deps="liba52"
+libgsm_decoder_deps="libgsm"
+libgsm_encoder_deps="libgsm"
+libgsm_ms_decoder_deps="libgsm"
+libgsm_ms_encoder_deps="libgsm"
+libtheora_encoder_deps="libtheora"
+mp3lame_encoder_deps="libmp3lame"
+oggvorbis_decoder_deps="libvorbis"
+oggvorbis_encoder_deps="libvorbis"
+
+audio_demuxer_deps_any="audio_oss audio_beos"
+audio_muxer_deps_any="audio_oss audio_beos"
+dc1394_demuxer_deps="dc1394"
+dv1394_demuxer_deps="dv1394"
+gxf_muxer_deps="gpl"
+libnut_demuxer_deps="libnut"
+libnut_muxer_deps="libnut"
+ogg_muxer_deps="libogg"
+redir_demuxer_deps="network"
+rtp_muxer_deps="network"
+rtsp_demuxer_deps="network"
+sdp_demuxer_deps="network"
+v4l2_demuxer_deps="v4l2"
+video_grab_device_demuxer_deps_any="v4l bktr"
+x11_grab_device_demuxer_deps="x11grab"
+
+ffplay_deps="sdl"
+ffserver_deps="network protocols muxers"
+network_deps="protocols"
+
# set temporary file name
if test ! -z "$TMPDIR" ; then
TMPDIR1="${TMPDIR}"
@@ -473,14 +712,19 @@ TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
# default parameters
+
logging="yes"
logfile="config.err"
+
+# installation paths
PREFIX="/usr/local"
libdir='${PREFIX}/lib'
shlibdir="$libdir"
incdir='${PREFIX}/include/ffmpeg'
mandir='${PREFIX}/man'
bindir='${PREFIX}/bin'
+
+# toolchain
cross_prefix=""
cross_compile="no"
cc="gcc"
@@ -488,120 +732,96 @@ ar="ar"
ranlib="ranlib"
make="make"
strip="strip"
+asmalign_pot="unknown"
+
+# machine
arch=`uname -m`
cpu="generic"
powerpc_perf="no"
mmx="default"
cmov="no"
-cmov_is_fast="no"
+fast_cmov="no"
armv5te="default"
+armv6="default"
iwmmxt="default"
altivec="default"
dcbzl="no"
mmi="default"
-case "$arch" in
- i386|i486|i586|i686|i86pc|BePC)
- arch="x86_32"
- ;;
- x86_64|amd64)
- arch="x86_32"
- canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
- if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
- if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
- arch="x86_64"
- fi
- fi
- ;;
- # armv4l is a subset of armv[567]*l
- arm|armv[4567]*l)
- arch="armv4l"
- ;;
- alpha)
- arch="alpha"
- ;;
- "Power Macintosh"|ppc|ppc64|powerpc)
- arch="powerpc"
- ;;
- mips|mipsel|IP*)
- arch="mips"
- ;;
- sun4u|sparc64)
- arch="sparc64"
- ;;
- sparc)
- arch="sparc"
- ;;
- sh4)
- arch="sh4"
- ;;
- parisc|parisc64)
- arch="parisc"
- ;;
- s390|s390x)
- arch="s390"
- ;;
- m68k)
- arch="m68k"
- ;;
- ia64)
- arch="ia64"
- ;;
- bfin)
- arch="bfin"
- ;;
- *)
- arch="unknown"
- ;;
-esac
-gprof="no"
-video4linux="yes"
-video4linux2="yes"
-bktr="no"
+bigendian="no"
+
+# OS
+targetos=$(tolower $(uname -s))
+beos_netserver="no"
+os2="no"
+wince="no"
+
+# non-library system interfaces
+audio_beos="default"
audio_oss="yes"
-audio_beos="no"
+bktr="yes"
dv1394="yes"
+v4l2="yes"
+v4l="yes"
+
+# libraries
+amr_if2="no"
+amr_nb="no"
+amr_nb_fixed="no"
+amr_wb="no"
+avisynth="no"
dc1394="no"
-network="yes"
-ipv6="yes"
-zlib="yes"
+dlfcn_h="no"
+dlopen="no"
+liba52="no"
+liba52bin="no"
+libdts="no"
+libfaac="no"
+libfaad2="no"
+libfaad="no"
+libfaadbin="no"
libgsm="no"
-mp3lame="no"
+libmp3lame="no"
libnut="no"
libogg="no"
+libtheora="no"
libvorbis="no"
-faad="no"
-faadbin="no"
-faac="no"
-xvid="no"
+mlib="no"
+x11grab="no"
x264="no"
-a52="no"
-a52bin="no"
-dts="no"
-pp="no"
-mingw32="no"
-wince="no"
-os2="no"
-lstatic="yes"
-lshared="no"
-optimize="yes"
+xvid="no"
+zlib="yes"
+
+# configurable options
debug="yes"
-extrawarnings="no"
dostrip="yes"
-installstrip="-s"
-extralibs="-lm"
-bigendian="no"
-vhook="default"
-avisynth="no"
-dlfcn_h="no"
-dlopen="no"
+extra_warnings="no"
+ffmpeg="yes"
+ffplay="yes"
+ffserver="yes"
+gpl="no"
+gprof="no"
+ipv6="yes"
+shared="no"
+static="yes"
+memalign_hack="no"
mpegaudio_hp="yes"
+network="yes"
+optimize="yes"
+pp="no"
+protocols="yes"
+swscaler="no"
+vhook="default"
+
+# threading
+beosthreads="no"
+os2threads="no"
+pthreads="no"
+w32threads="no"
+thread_type="no"
+
+# build settings
SHFLAGS='-shared -Wl,-soname,$@'
VHOOKSHFLAGS='$(SHFLAGS)'
-beos_netserver="no"
-protocols="yes"
-ffmpeg="yes"
-ffserver="yes"
-ffplay="yes"
LIBOBJFLAGS=""
FFLDFLAGS=-Wl,--warn-common
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
@@ -617,191 +837,7 @@ SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
EXESUF=""
BUILDSUF=""
-amr_nb="no"
-amr_wb="no"
-amr_nb_fixed="no"
-amr_if2="no"
-mlib="no"
-pthreads="no"
-swscaler="no"
-gpl="no"
-memalign_hack="no"
-asmalign_pot="unknown"
-LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
-
-# OS specific
-targetos=`uname -s`
-case $targetos in
-BeOS)
-PREFIX="/boot/home/config"
-# helps building libavcodec
-add_cflags "-DPIC -fomit-frame-pointer"
-# 3 gcc releases known for BeOS, each with ugly bugs
-gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
-case "$gcc_version" in
-2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
-mmx="no"
-;;
-*20010315*) echo "BeBits gcc"
-add_cflags "-fno-expensive-optimizations"
-;;
-esac
-SHFLAGS=-nostart
-# disable Linux things
-audio_oss="no"
-video4linux="no"
-video4linux2="no"
-dv1394="no"
-# enable BeOS things
-audio_beos="yes"
-beosthreads="yes"
-# no need for libm, but the inet stuff
-# Check for BONE
-if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
-extralibs="-lbind -lsocket"
-else
-beos_netserver="yes"
-extralibs="-lnet"
-fi ;;
-SunOS)
-video4linux="no"
-video4linux2="no"
-audio_oss="no"
-dv1394="no"
-make="gmake"
-FFLDFLAGS=""
-FFSERVERLDFLAGS=""
-SHFLAGS="-shared -Wl,-h,\$@"
-add_extralibs "-lsocket -lnsl"
-;;
-NetBSD)
-video4linux="no"
-video4linux2="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-make="gmake"
-add_extralibs "-lossaudio"
-;;
-OpenBSD)
-video4linux="no"
-video4linux2="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-make="gmake"
-LIBOBJFLAGS="\$(PIC)"
-LDCONFIG="ldconfig -m \$(shlibdir)"
-add_extralibs "-lossaudio"
-;;
-FreeBSD)
-video4linux="no"
-video4linux2="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-make="gmake"
-add_cflags "-pthread"
-;;
-GNU/kFreeBSD)
-video4linux="no"
-video4linux2="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-add_cflags "-pthread"
-;;
-BSD/OS)
-video4linux="no"
-video4linux2="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-extralibs="-lpoll -lgnugetopt -lm"
-make="gmake"
-strip="strip -d"
-installstrip=""
-;;
-Darwin)
-cc="cc"
-video4linux="no"
-video4linux2="no"
-audio_oss="no"
-dv1394="no"
-SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION)"
-VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
-extralibs=""
-strip="strip -x"
-installstrip=""
-FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
-SLIBSUF=".dylib"
-SLIBNAME_WITH_FULLVERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
-SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
-FFSERVERLDFLAGS=-Wl,-bind_at_load
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
-;;
-MINGW32*)
-# Note: the rest of the mingw32 config is done afterwards as mingw32
-# can be forced on the command line for Linux cross compilation.
-mingw32="yes"
-;;
-CYGWIN*)
-targetos=CYGWIN
-shlibdir='${PREFIX}/bin'
-video4linux="no"
-video4linux2="no"
-audio_oss="yes"
-dv1394="no"
-VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
-VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
-extralibs=""
-EXESUF=".exe"
-SLIBPREF="cyg"
-SLIBSUF=".dll"
-SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
-SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
-SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
-;;
-Linux)
-LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
-;;
-IRIX*)
-targetos=IRIX
-ranlib="echo ignoring ranlib"
-video4linux="no"
-video4linux2="no"
-audio_oss="no"
-make="gmake"
-;;
-OS/2)
-TMPE=$TMPE".exe"
-ar="emxomfar -p128"
-ranlib="echo ignoring ranlib"
-strip="echo ignoring strip"
-add_cflags "-Zomf"
-FFLDFLAGS="-Zomf -Zstack 16384 -s"
-SHFLAGS="-Zdll -Zomf"
-FFSERVERLDFLAGS=""
-LIBPREF=""
-LIBSUF=".lib"
-SLIBPREF=""
-SLIBSUF=".dll"
-EXESUF=".exe"
-extralibs=""
-pkg_requires=""
-video4linux="no"
-video4linux2="no"
-audio_oss="no"
-dv1394="no"
-ffserver="no"
-vhook="no"
-os2="yes"
-os2threads="yes"
-;;
-*)
-targetos="${targetos}-UNKNOWN"
-;;
-esac
# find source path
source_path="`dirname \"$0\"`"
@@ -819,10 +855,7 @@ if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
show_help
fi
-FFMPEG_CONFIGURATION=" "
-for opt do
- FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
-done
+FFMPEG_CONFIGURATION="$@"
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
@@ -832,6 +865,12 @@ DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/li
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
+die_unknown(){
+ echo "Unknown option \"$1\"."
+ echo "See $0 --help for available options."
+ exit 1
+}
+
for opt do
optval="${opt#*=}"
case "$opt" in
@@ -839,9 +878,9 @@ for opt do
;;
--log=*) logging="$optval"
;;
- --prefix=*) PREFIX="$optval"; force_prefix=yes
+ --prefix=*) PREFIX="$optval"
;;
- --libdir=*) libdir="$optval"; force_libdir=yes
+ --libdir=*) libdir="$optval"
;;
--shlibdir=*) shlibdir="$optval"
;;
@@ -851,11 +890,11 @@ for opt do
;;
--source-path=*) source_path="$optval"
;;
- --build-path=*) build_path="$optval"
- ;;
--cross-prefix=*) cross_prefix="$optval"
;;
- --cross-compile) cross_compile=yes
+ --cross-compile) cross_compile="yes"
+ ;;
+ --target-os=*) targetos="$optval"
;;
--cc=*) cc="$optval"
;;
@@ -873,175 +912,197 @@ for opt do
;;
--cpu=*) cpu="$optval"
;;
- --powerpc-perf-enable) powerpc_perf="yes"
- ;;
- --disable-mmx) mmx="no"
- ;;
- --disable-armv5te) armv5te="no"
- ;;
- --disable-iwmmxt) iwmmxt="no"
- ;;
- --disable-altivec) altivec="no"
- ;;
- --enable-gprof) gprof="yes"
- ;;
- --disable-v4l) video4linux="no"
- ;;
- --disable-v4l2) video4linux2="no"
- ;;
- --disable-bktr) bktr="no"
- ;;
- --disable-audio-oss) audio_oss="no"
- ;;
- --disable-audio-beos) audio_beos="no"
- ;;
- --disable-dv1394) dv1394="no"
- ;;
- --disable-network) network="no"; ffserver="no"
- ;;
- --disable-ipv6) ipv6="no";
- ;;
- --disable-zlib) zlib="no"
- ;;
- --enable-a52) a52="yes"
- ;;
- --enable-a52bin) a52bin="yes"
- ;;
- --enable-dts) dts="yes"
- ;;
- --enable-pp) pp="yes"
- ;;
- --enable-libgsm) libgsm="yes"
- ;;
- --enable-mp3lame) mp3lame="yes"
- ;;
- --enable-libnut) libnut="yes"
- ;;
- --enable-libogg) libogg="yes"
- pkg_requires="$pkg_requires ogg >= 1.1"
- ;;
- --enable-vorbis) libvorbis="yes"
- pkg_requires="$pkg_requires vorbis vorbisenc"
- ;;
- --enable-faad) faad="yes"
- ;;
- --enable-faadbin) faadbin="yes"
- ;;
- --enable-faac) faac="yes"
- ;;
- --enable-xvid) xvid="yes"
- ;;
- --enable-x264) x264="yes"
- ;;
- --enable-avisynth) avisynth="yes";
- ;;
- --enable-dc1394) dc1394="yes"
- pkg_requires="$pkg_requires libraw1394"
- ;;
- --disable-vhook) vhook="no"
- ;;
- --enable-mingw32) mingw32="yes"
- ;;
--enable-mingwce) wince="yes"
;;
- --enable-static) lstatic="yes"
- ;;
- --disable-static) lstatic="no"
- ;;
- --enable-shared) lshared="yes"
- ;;
- --disable-shared) lshared="no"
- ;;
- --disable-debug) debug="no"
- ;;
--disable-opts) optimize="no"
;;
- --enable-extra-warnings) extrawarnings="yes"
- ;;
- --disable-mpegaudio-hp) mpegaudio_hp="no"
- ;;
- --disable-protocols) protocols="no"; network="no"; ffserver="no"
- ;;
- --disable-ffmpeg) ffmpeg="no"
- ;;
- --disable-ffserver) ffserver="no"
- ;;
- --disable-ffplay) ffplay="no"
- ;;
--enable-small) optimize="small"
;;
- --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
+ --enable-sunmlib) mlib="yes"
;;
- --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
+ --disable-strip) dostrip="no"
;;
- --enable-amr_wb) amr="yes"; amr_wb="yes"
+ --disable-encoders) disable $ENCODER_LIST
;;
- --enable-amr_if2) amr="yes"; amr_if2="yes"
+ --disable-decoders) disable $DECODER_LIST
;;
- --enable-sunmlib) mlib="yes"
+ --disable-muxers) disable $MUXER_LIST
;;
- --enable-pthreads) pthreads="yes"
+ --disable-demuxers) disable $DEMUXER_LIST
;;
- --enable-swscaler) swscaler="yes"
+ --disable-parsers) disable $PARSER_LIST
;;
- --enable-gpl) gpl="yes"
+ --enable-*=*|--disable-*=*)
+ eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
+ case "$thing" in
+ encoder|decoder|muxer|demuxer|parser) $action ${optval}_${thing} ;;
+ *) die_unknown "$opt" ;;
+ esac
;;
- --enable-memalign-hack) memalign_hack="yes"
+ --enable-?*|--disable-?*)
+ eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
+ echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
+ $action $option
;;
- --disable-strip) dostrip="no"
+ --help) show_help
;;
- --enable-encoder=*) enable ${optval}_encoder
+ *)
+ die_unknown $opt
;;
- --enable-decoder=*) enable ${optval}_decoder
+ esac
+done
+
+case "$arch" in
+ i386|i486|i586|i686|i86pc|BePC)
+ arch="x86_32"
;;
- --disable-encoder=*) disable ${optval}_encoder
+ x86_64|amd64)
+ arch="x86_32"
+ canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
+ if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
+ if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
+ arch="x86_64"
+ enable fast_64bit
+ fi
+ fi
;;
- --disable-decoder=*) disable ${optval}_decoder
+ # armv4l is a subset of armv[567]*l
+ arm|armv[4567]*l)
+ arch="armv4l"
;;
- --disable-encoders) disable $ENCODER_LIST
+ alpha)
+ arch="alpha"
+ enable fast_64bit
;;
- --disable-decoders) disable $DECODER_LIST
+ "Power Macintosh"|ppc|powerpc)
+ arch="powerpc"
;;
- --enable-muxer=*) enable ${optval}_muxer
+ ppc64)
+ arch="powerpc"
+ enable fast_64bit
;;
- --disable-muxer=*) disable ${optval}_muxer
+ mips|mipsel|IP*)
+ arch="mips"
;;
- --disable-muxers) disable $MUXER_LIST; ffserver="no"
+ sun4u|sparc64)
+ arch="sparc64"
+ enable fast_64bit
;;
- --enable-demuxer=*) enable ${optval}_demuxer
+ sparc)
+ arch="sparc"
;;
- --disable-demuxer=*) disable ${optval}_demuxer
+ sh4)
+ arch="sh4"
;;
- --disable-demuxers) disable $DEMUXER_LIST
+ parisc)
+ arch="parisc"
;;
- --enable-parser=*) enable ${optval}_parser
+ parisc64)
+ arch="parisc"
+ enable fast_64bit
;;
- --disable-parser=*) disable ${optval}_parser
+ s390|s390x)
+ arch="s390"
;;
- --disable-parsers) disable $PARSER_LIST
+ m68k)
+ arch="m68k"
;;
- --help) show_help
+ ia64)
+ arch="ia64"
+ enable fast_64bit
+ ;;
+ bfin)
+ arch="bfin"
;;
*)
- echo "Unknown option \"$opt\"."
- echo "See $0 --help for available options."
- exit 1
+ arch="unknown"
;;
- esac
-done
-
-cd "$build_path"
-
-if test "$logging" != no; then
- test "$logging" = yes || logfile="$logging"
- echo "# $0 $@" >$logfile
- set >>$logfile
-else
- logfile=/dev/null
-fi
+esac
-if test "$mingw32" = "yes" -o "$wince" = "yes"; then
- if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
+# OS specific
+osextralibs="-lm"
+case $targetos in
+ beos|haiku|zeta)
+ PREFIX="$HOME/config"
+ # helps building libavcodec
+ add_cflags "-DPIC -fomit-frame-pointer"
+ # 3 gcc releases known for BeOS, each with ugly bugs
+ gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
+ case "$gcc_version" in
+ 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
+ mmx="no"
+ ;;
+ *20010315*) echo "BeBits gcc"
+ add_cflags "-fno-expensive-optimizations"
+ ;;
+ esac
+ LDCONFIG="echo ignoring ldconfig"
+ SHFLAGS=-nostart
+ # disable Linux things
+ dv1394="no"
+ # enable BeOS things
+ disabled audio_beos || enable_audio_beos
+ # no need for libm, but the inet stuff
+ # Check for BONE
+ # XXX: actually should check for NOT net_server
+ if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
+ osextralibs="-lbind -lsocket"
+ else
+ beos_netserver="yes"
+ osextralibs="-lnet"
+ fi ;;
+ sunos)
+ dv1394="no"
+ FFLDFLAGS=""
+ FFSERVERLDFLAGS=""
+ SHFLAGS="-shared -Wl,-h,\$@"
+ add_extralibs "-lsocket -lnsl"
+ ;;
+ netbsd)
+ dv1394="no"
+ add_extralibs "-lossaudio"
+ ;;
+ openbsd)
+ dv1394="no"
+ need_memalign="no"
+ LIBOBJFLAGS="\$(PIC)"
+ LDCONFIG="ldconfig -m \$(shlibdir)"
+ SHFLAGS='-shared'
+ SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
+ SLIBNAME_WITH_VERSION='$(SLIBNAME)'
+ SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
+ add_extralibs "-lossaudio"
+ ;;
+ freebsd)
+ dv1394="no"
+ need_memalign="no"
+ add_cflags "-pthread"
+ ;;
+ gnu/kfreebsd)
+ dv1394="no"
+ add_cflags "-pthread"
+ ;;
+ bsd/os)
+ dv1394="no"
+ osextralibs="-lpoll -lgnugetopt -lm"
+ strip="strip -d"
+ ;;
+ darwin)
+ dv1394="no"
+ need_memalign="no"
+ SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
+ VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
+ osextralibs=""
+ strip="strip -x"
+ FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
+ SLIBSUF=".dylib"
+ SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
+ SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
+ FFSERVERLDFLAGS=-Wl,-bind_at_load
+ ;;
+ mingw32*)
+ targetos=mingw32
+ if enabled_all shared static; then
cat <<EOF
You can only build one library type at once on MinGW.
Specify --disable-static --enable-shared to only build
@@ -1050,18 +1111,10 @@ you do not need to pass additional options.
EOF
exit 1
fi
- video4linux="no"
- video4linux2="no"
- bktr="no"
- audio_oss="no"
dv1394="no"
- dc1394="no"
ffserver="no"
network="no"
- if enabled mingw32; then
- w32threads="yes"
- fi
- if test "$wince" = "yes"; then
+ if enabled wince; then
protocols="no"
fi
SLIBPREF=""
@@ -1070,10 +1123,65 @@ EOF
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
- SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a)"
- if test "$force_prefix" != yes; then PREFIX="$PROGRAMFILES/FFmpeg"; fi
- if test "$force_libdir" != yes; then bindir='${PREFIX}'; fi
- shlibdir='${PREFIX}'
+ SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
+ SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
+ add_extralibs -lws2_32
+ ;;
+ cygwin*)
+ targetos=cygwin
+ shlibdir="$bindir"
+ dv1394="no"
+ VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libswscale -L$(BUILD_ROOT)/libavutil'
+ VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lswscale$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
+ osextralibs=""
+ EXESUF=".exe"
+ SLIBPREF="cyg"
+ SLIBSUF=".dll"
+ SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
+ SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
+ SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
+ ;;
+ linux)
+ LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
+ ;;
+ irix*)
+ targetos=irix
+ ranlib="echo ignoring ranlib"
+ ;;
+ os/2)
+ TMPE=$TMPE".exe"
+ ar="emxomfar -p128"
+ ranlib="echo ignoring ranlib"
+ strip="echo ignoring strip"
+ add_cflags "-Zomf"
+ FFLDFLAGS="-Zomf -Zstack 16384 -s"
+ SHFLAGS="-Zdll -Zomf"
+ FFSERVERLDFLAGS=""
+ LIBPREF=""
+ LIBSUF=".lib"
+ SLIBPREF=""
+ SLIBSUF=".dll"
+ EXESUF=".exe"
+ osextralibs=""
+ pkg_requires=""
+ dv1394="no"
+ ffserver="no"
+ vhook="no"
+ os2="yes"
+ ;;
+ *)
+ targetos="${targetos}-UNKNOWN"
+ ;;
+esac
+
+add_extralibs $osextralibs
+
+if ! disabled logging ; then
+ enabled logging || logfile="$logging"
+ echo "# $0 $@" >$logfile
+ set >>$logfile
+else
+ logfile=/dev/null
fi
# Combine FFLDFLAGS and the LDFLAGS environment variable.
@@ -1085,8 +1193,12 @@ ar="${cross_prefix}${ar}"
ranlib="${cross_prefix}${ranlib}"
strip="${cross_prefix}${strip}"
+# Disable core dumps so that intentional execution of broken apps doesn't
+# pollute the current directory.
+ulimit -c 0
+
# we need to build at least one lib type
-if test "$lstatic" = "no" && test "$lshared" = "no" ; then
+if disabled_all static shared; then
cat <<EOF
At least one library type must be built.
Specify --enable-static to build the static libraries or --enable-shared to
@@ -1096,67 +1208,41 @@ EOF
exit 1;
fi
-if test "$libvorbis" = "yes" ; then
- if test "$libogg" = "no"; then
- echo "libogg must be enabled to enable Vorbis."
- fail="yes"
- fi
+if disabled libogg; then
+ enabled libtheora && die "libogg must be enabled to enable libtheora."
+ enabled libvorbis && die "libogg must be enabled to enable libvorbis."
fi
-if test "$gpl" != "yes"; then
- if test "$pp" != "no"; then
- echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
- fail="yes"
- fi
-
- if test "$a52" != "no" -o "$a52bin" != "no"; then
- echo "liba52 is under GPL and --enable-gpl is not specified."
- fail="yes"
- fi
-
- if test "$xvid" != "no"; then
- echo "libxvidcore is under GPL and --enable-gpl is not specified."
- fail="yes"
- fi
-
- if test "$x264" != "no"; then
- echo "x264 is under GPL and --enable-gpl is not specified."
- fail="yes"
- fi
-
- if test "$dts" != "no"; then
- echo "libdts is under GPL and --enable-gpl is not specified."
- fail="yes"
- fi
-
- if test "$faad" != "no" -o "$faadbin" != "no"; then
- if check_header faad.h; then
- check_cc << EOF
- #include <faad.h>
- #ifndef FAAD2_VERSION
- ok faad1
- #endif
- int main( void ) { return 0; }
+if enabled_any libfaad libfaadbin ; then
+ if check_header faad.h; then
+ check_cc << EOF
+#include <faad.h>
+#ifndef FAAD2_VERSION
+ok faad1
+#endif
+int main( void ) { return 0; }
EOF
- if test $? = 0 ; then
- echo "FAAD2 is under GPL and --enable-gpl is not specified."
- fail="yes"
- fi
- else
- faad="no"
- faadbin="no"
- echo "FAAD test failed."
- fi
- fi
-
- if test "$swscaler" != "no"; then
- echo "The software scaler is under GPL and --enable-gpl is not specified."
- fail="yes"
+ test $? = 0 && enable libfaad2
+ else
+ die "FAAD test failed."
fi
fi
-if test "$fail" = "yes"; then
- exit 1
+
+if disabled gpl ; then
+ die_gpl_disabled(){
+ name=$1
+ shift
+ enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
+ }
+ die_gpl_disabled "The Postprocessing code" pp
+ die_gpl_disabled "liba52" liba52
+ die_gpl_disabled "libxvidcore" xvid
+ die_gpl_disabled "x264" x264
+ die_gpl_disabled "libdts" libdts
+ die_gpl_disabled "FAAD2" libfaad2
+ die_gpl_disabled "The X11 grabber" x11grab
+ die_gpl_disabled "The software scaler" swscaler
fi
# compute MMX state
@@ -1168,9 +1254,11 @@ if test $mmx = "default"; then
fi
fi
+test -z "$need_memalign" && need_memalign="$mmx"
+
#Darwin CC versions
needmdynamicnopic="no"
-if test $targetos = Darwin; then
+if test $targetos = darwin; then
if test -n "`$cc -v 2>&1 | grep xlc`"; then
add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
else
@@ -1181,13 +1269,13 @@ if test $targetos = Darwin; then
;;
*[34].*)
add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
- if test "$lshared" = no; then
+ if disabled shared; then
needmdynamicnopic="yes"
fi
;;
*)
add_cflags "-no-cpp-precomp -pipe"
- if test "$lshared" = no; then
+ if disabled shared; then
needmdynamicnopic="yes"
fi
;;
@@ -1195,9 +1283,7 @@ if test $targetos = Darwin; then
fi
fi
-if test $optimize != "no"; then
- add_cflags "-fomit-frame-pointer"
-fi
+disabled optimize || add_cflags -fomit-frame-pointer
# Can only do AltiVec on PowerPC
if test $altivec = "default"; then
@@ -1211,48 +1297,37 @@ fi
# Add processor-specific flags
POWERPCMODE="32bits"
if test $cpu != "generic"; then
+ warn_altivec(){
+ $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
+ }
case $cpu in
601|ppc601|PowerPC601)
add_cflags "-mcpu=601"
- if test $altivec = "yes"; then
- echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
- fi
+ warn_altivec enabled PPC601
;;
603*|ppc603*|PowerPC603*)
add_cflags "-mcpu=603"
- if test $altivec = "yes"; then
- echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
- fi
+ warn_altivec enabled PPC603
;;
604*|ppc604*|PowerPC604*)
add_cflags "-mcpu=604"
- if test $altivec = "yes"; then
- echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
- fi
+ warn_altivec enabled PPC604
;;
G3|g3|75*|ppc75*|PowerPC75*)
add_cflags "-mcpu=750 -mpowerpc-gfxopt"
- if test $altivec = "yes"; then
- echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
- fi
+ warn_altivec enabled PPC75x
;;
G4|g4|745*|ppc745*|PowerPC745*)
add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
- if test $altivec = "no"; then
- echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
- fi
+ warn_altivec disabled PPC745x
;;
74*|ppc74*|PowerPC74*)
add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
- if test $altivec = "no"; then
- echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
- fi
+ warn_altivec disabled PPC74xx
;;
G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
- if test $altivec = "no"; then
- echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
- fi
+ warn_altivec disabled PPC970
POWERPCMODE="64bits"
;;
# targets that do NOT support conditional mov (cmov)
@@ -1261,26 +1336,38 @@ if test $cpu != "generic"; then
cmov="no"
;;
# targets that do support conditional mov (cmov)
- i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx)
+ i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
add_cflags "-march=$cpu"
cmov="yes"
- cmov_is_fast="yes"
+ fast_cmov="yes"
;;
# targets that do support conditional mov but on which it's slow
pentium4|prescott|nocona)
add_cflags "-march=$cpu"
cmov="yes"
- cmov_is_fast="no"
+ fast_cmov="no"
;;
sparc64)
add_cflags "-mcpu=v9"
;;
+ bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
+ add_cflags "-mfdpic"
+ add_ldflags "-mfdpic"
+ ;;
*)
echo "WARNING: Unknown CPU \"$cpu\", ignored."
;;
esac
fi
+gnu_make(){
+ $1 --version 2>&1 | grep -q GNU
+}
+
+if ! gnu_make $make; then
+ gnu_make gmake && make=gmake || die "GNU make not found."
+fi
+
# make sure we can execute files in $TMPDIR
cat >$TMPE 2>>$logfile <<EOF
#! /bin/sh
@@ -1304,13 +1391,44 @@ int main(){
EOF
if test "$?" != 0; then
echo "$cc is unable to create an executable file."
- if test -z "$cross_prefix" -a "$cross_compile" = no; then
+ if test -z "$cross_prefix" && disabled cross_compile ; then
echo "If $cc is a cross-compiler, use the --cross-compile option."
echo "Only do this if you know what cross compiling means."
fi
die "C compiler test failed."
fi
+if test $arch = "x86_32" -o $arch = "x86_64"; then
+ if test "$targetos" = mingw32 -o "$targetos" = cygwin; then
+ cat <<EOF
+WARNING: The following test might cause a testapp to crash (intentionally)
+resulting in the appearance of a dialog box. Please click "Don't send" and
+ignore it.
+EOF
+ fi
+
+ # check whether EBP is available on x86
+ # As 'i' is stored on the stack, this program will crash
+ # if the base pointer is used to access it because the
+ # base pointer is cleared in the inline assembly code.
+ (check_exec) <<EOF >>$logfile 2>&1 && enable ebp_available
+int main(){
+ volatile int i=0;
+ asm volatile (
+ "xorl %%ebp, %%ebp"
+ ::: "%ebp");
+ return i;
+}
+EOF
+
+ # check wether EBX is available on x86
+ check_cc <<EOF && enable ebx_available
+int main(){
+ asm volatile ("":::"%ebx");
+}
+EOF
+fi
+
# check for assembler specific support
if test $arch = "powerpc"; then
@@ -1328,7 +1446,7 @@ fi
# AltiVec flags: The FSF version of GCC differs from the Apple version
if test $arch = "powerpc"; then
- if test $altivec = "yes"; then
+ if enabled altivec; then
if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
add_cflags "-faltivec"
else
@@ -1340,8 +1458,8 @@ fi
check_header altivec.h
# check if our compiler supports Motorola AltiVec C API
-if test $altivec = "yes"; then
- if test $altivec_h = "yes"; then
+if enabled altivec; then
+ if enabled altivec_h; then
inc_altivec_h="#include <altivec.h>"
else
inc_altivec_h=
@@ -1366,6 +1484,14 @@ if test $armv5te = "default" -a $arch = "armv4l"; then
EOF
fi
+if test $armv6 = "default" -a $arch = "armv4l"; then
+ check_cc <<EOF && armv6=yes || armv6=no
+int main(void) {
+ __asm__ __volatile__ ("sadd16 r0, r0, r0");
+}
+EOF
+fi
+
# check iwmmxt support
if test $iwmmxt = "default" -a $arch = "armv4l"; then
iwmmxt=no
@@ -1395,7 +1521,7 @@ EOF
# ---
# big/little-endian test
-if test "$cross_compile" = "no"; then
+if disabled cross_compile; then
check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
#include <inttypes.h>
int main(int argc, char ** argv){
@@ -1416,18 +1542,24 @@ fi
check_header malloc.h
check_func memalign
-if test "$memalign" = "no" -a "$mmx" = "yes" -a \
- "$memalign_hack" != "yes" -a "$targetos" != "Darwin" -a \
- "$targetos" != "FreeBSD" ; then
+if disabled_all memalign memalign_hack && enabled need_memalign ; then
die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
fi
check_header byteswap.h
+check_header arpa/inet.h
+
check_func inet_aton
check_func localtime_r
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
+# ffserver uses poll(),
+# if it's not found we can emulate it using select().
+if enabled ffserver; then
+ check_header sys/poll.h
+fi
+
# check for some common methods of building with pthread support
# do this before the optional library checks as some of them require pthreads
if enabled pthreads; then
@@ -1444,65 +1576,36 @@ if enabled pthreads; then
fi
fi
-# these are off by default, so fail if requested and not available
-enabled dts && require libdts dts.h dts_init -ldts -lm
-enabled libgsm && require libgsm gsm.h gsm_create -lgsm
-enabled mp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
-enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
-enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
-enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
-enabled xvid && require XviD xvid.h xvid_global -lxvidcore
-enabled x264 && require x264 x264.h x264_encoder_open -lx264
-enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
-enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
-
-# Ugh, faac uses stdcall calling convention on win32 so we can't use
-# the generic test functions
-if enabled faac; then
- save_flags
- temp_extralibs -lfaac
- check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
-#include <stdint.h>
-#include <faac.h>
-int main(){
- char *id, *cpr;
- faacEncGetVersion(&id, &cpr);
- return 0;
-}
-EOF
- restore_flags
-fi
-
-# Ugh, recent faad2 versions have renamed all functions and #define the
-# old names in faad.h. Generic tests won't work.
-if enabled faad; then
- save_flags
- temp_extralibs -lfaad
- check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
-#include <faad.h>
-int main(){
- faacDecOpen();
- return 0;
-}
-EOF
- restore_flags
-fi
+for thread in $THREADS_LIST; do
+ if enabled $thread; then
+ if ! disabled thread_type ; then
+ die "ERROR: Only one thread type must be selected."
+ else
+ thread_type="$thread"
+ fi
+ fi
+done
-# Ugh, avisynth uses WINAPI calls. Generic tests won't work.
-if enabled avisynth; then
- save_flags
- temp_extralibs -lvfw32
- check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
-#include <windows.h>
-#include <vfw.h>
-int main(){
- AVIFileInit();
- return 0;
-}
-EOF
- restore_flags
-fi
+enabled_any amr_nb amr_nb_fixed amr_wb amr_if2 && enable amr
+enabled_all amr_nb amr_nb_fixed &&
+ die "Only one of amr_nb and amr_nb_fixed may be enabled."
+# these are off by default, so fail if requested and not available
+enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
+enabled libdts && require libdts dts.h dts_init -ldts -lm
+enabled libgsm && require libgsm gsm.h gsm_create -lgsm
+enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
+enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
+enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
+enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
+enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
+enabled xvid && require XviD xvid.h xvid_global -lxvidcore
+enabled x264 && require x264 x264.h x264_encoder_open -lx264
+enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
+enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
+enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
+enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
+enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
# test for lrintf in math.h
check_exec <<EOF && lrintf=yes || lrintf=no
@@ -1528,15 +1631,11 @@ elif check_func dlopen -ldl; then
ldl=-ldl
fi
-if test "$vhook" = "default"; then
- vhook="$dlopen"
-fi
+test "$vhook" = "default" && vhook="$dlopen"
-if enabled_any vhook a52bin faadbin; then
- add_extralibs $ldl
-fi
+enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
-if test "$targetos" = "CYGWIN" -a "$lstatic" = "yes" ; then
+if test "$targetos" = cygwin && enabled static ; then
vhook="no"
echo
echo "At the moment vhooks don't work on Cygwin static builds."
@@ -1549,36 +1648,10 @@ if enabled vhook; then
check_ldflags -export-dynamic
fi
-if enabled audio_beos; then
- add_extralibs "-lmedia -lbe"
-fi
-
-##########################################
-# imlib check
+enabled audio_beos && add_extralibs "-lmedia -lbe"
-temp_extralibs -lImlib2
-check_ld <<EOF && imlib2=yes || imlib2=no
-#include <X11/Xlib.h>
-#include <Imlib2.h>
-int main( void ) { return (int) imlib_load_font("foo"); }
-EOF
-restore_flags
-
-##########################################
-# FreeType check
-
-freetype2=no
-if test "x$targetos" != "xBeOS"; then
- if (freetype-config --version) >/dev/null 2>&1 ; then
- temp_cflags `freetype-config --cflags`
- temp_extralibs `freetype-config --libs`
- check_ld <<EOF && freetype2=yes
-#include <ft2build.h>
-int main( void ) { return (int) FT_Init_FreeType(0); }
-EOF
- restore_flags
- fi
-fi
+check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
+check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
##########################################
# SDL check
@@ -1586,21 +1659,17 @@ fi
sdl_too_old=no
sdl=no
SDL_CONFIG="${cross_prefix}sdl-config"
-if ("${SDL_CONFIG}" --version) >/dev/null 2>&1 ; then
- temp_cflags `"${SDL_CONFIG}" --cflags`
+if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
+ sdl_cflags=`"${SDL_CONFIG}" --cflags`
+ temp_cflags $sdl_cflags
temp_extralibs `"${SDL_CONFIG}" --libs`
- check_ld <<EOF
-#include <SDL.h>
-#undef main /* We don't want SDL to override our main() */
-int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
-EOF
- if test $? = 0; then
+ if check_lib SDL.h SDL_Init; then
_sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
if test "$_sdlversion" -lt 121 ; then
sdl_too_old=yes
else
sdl=yes
- check_cc <<EOF && sdl_video_size=yes || sdl_video_size=no
+ check_cc $sdl_cflags <<EOF && enable sdl_video_size
#include <SDL.h>
int main(void){
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
@@ -1613,15 +1682,7 @@ EOF
restore_flags
fi
-enabled sdl || ffplay=no
-
-##########################################
-# texi2html check
-
-texi2html=no
-if (texi2html -version) >/dev/null 2>&1; then
-texi2html=yes
-fi
+texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
##########################################
# IPv6 check
@@ -1640,14 +1701,36 @@ int main( void ) {
}
EOF
-# check for video4linux2 --- V4L2_PIX_FMT_YUV420
-enabled video4linux2 && check_cc <<EOF || video4linux2="no"
-#include <sys/time.h>
-#include <asm/types.h>
-#include <linux/videodev2.h>
-int dummy = V4L2_PIX_FMT_YUV420;
-struct v4l2_buffer dummy1;
-EOF
+enabled v4l && check_header linux/videodev.h || disable v4l
+enabled v4l2 && check_header linux/videodev2.h || disable v4l2
+
+# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
+if enabled bktr; then
+ { check_header dev/bktr/ioctl_meteor.h &&
+ check_header dev/bktr/ioctl_bt848.h; } ||
+ { check_header machine/ioctl_meteor.h &&
+ check_header machine/ioctl_bt848.h; } ||
+ { check_header dev/video/meteor/ioctl_meteor.h &&
+ check_header dev/video/bktr/ioctl_bt848.h; } ||
+ check_header dev/ic/bt8xx.h ||
+ disable bktr
+fi
+
+enabled audio_oss &&
+ check_header sys/soundcard.h ||
+ check_header soundcard.h ||
+ disable audio_oss
+
+# Deal with the x11 frame grabber
+enabled x11grab &&
+enabled gpl &&
+enabled x11_grab_device_demuxer &&
+check_header X11/Xlib.h &&
+check_header X11/extensions/XShm.h &&
+check_func XOpenDisplay -lX11 &&
+check_func XShmCreateImage -lX11 -lXext &&
+add_extralibs -lX11 -lXext ||
+disable x11_grab_device_demuxer
enabled debug && add_cflags -g
@@ -1658,7 +1741,8 @@ check_cflags -Wno-switch
check_cflags -Wdisabled-optimization
check_cflags -Wpointer-arith
check_cflags -Wredundant-decls
-enabled extrawarnings && check_cflags -Winline
+check_cflags -Wno-pointer-sign
+enabled extra_warnings && check_cflags -Winline
# add some linker flags
check_ldflags $LDLATEFLAGS
@@ -1676,22 +1760,22 @@ if enabled optimize; then
fi
# PIC flags for shared library objects where they are needed
-if test "$lshared" = "yes" ; then
+if enabled shared; then
# LIBOBJFLAGS may have already been set in the OS configuration
if test -z "$LIBOBJFLAGS" ; then
case "$arch" in
- x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
+ x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
esac
fi
fi
-if test "$gprof" = "yes" ; then
+if enabled gprof; then
add_cflags "-p"
add_ldflags "-p"
fi
VHOOKCFLAGS="-fPIC $CFLAGS"
-test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
+enabled needmdynamicnopic && add_cflags -mdynamic-no-pic
# find if .align arg is power-of-two or not
if test $asmalign_pot = "unknown"; then
@@ -1699,76 +1783,92 @@ if test $asmalign_pot = "unknown"; then
echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
fi
-echo "install prefix $PREFIX"
-echo "source path $source_path"
-echo "C compiler $cc"
-echo "make $make"
-echo "ARCH $arch ($cpu)"
+enabled_any $ENCODER_LIST && enable encoders
+enabled_any $DECODER_LIST && enable decoders
+enabled_any $MUXER_LIST && enable muxers
+enabled_any $DEMUXER_LIST && enable demuxers
+
+enabled_any $THREADS_LIST && enable threads
+
+check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
+ $DEMUXER_LIST $MUXER_LIST
+
+enabled libogg && append pkg_requires "ogg >= 1.1"
+enabled libtheora && append pkg_requires "theora"
+enabled libvorbis && append pkg_requires "vorbis vorbisenc"
+enabled dc1394 && append pkg_requires "libraw1394"
+
+echo "install prefix $PREFIX"
+echo "source path $source_path"
+echo "C compiler $cc"
+echo "make $make"
+echo ".align is power-of-two $asmalign_pot"
+echo "ARCH $arch ($cpu)"
if test "$BUILDSUF" != ""; then
- echo "build suffix $BUILDSUF"
+ echo "build suffix $BUILDSUF"
fi
-echo "big-endian $bigendian"
+echo "big-endian $bigendian"
if test $arch = "x86_32" -o $arch = "x86_64"; then
- echo "MMX enabled $mmx"
- echo "CMOV enabled $cmov"
- echo "CMOV is fast $cmov_is_fast"
+ echo "MMX enabled $mmx"
+ echo "CMOV enabled $cmov"
+ echo "CMOV is fast $fast_cmov"
fi
if test $arch = "armv4l"; then
- echo "ARMv5TE enabled $armv5te"
- echo "IWMMXT enabled $iwmmxt"
+ echo "ARMv5TE enabled $armv5te"
+ echo "ARMv6 enabled $armv6"
+ echo "IWMMXT enabled $iwmmxt"
fi
if test $arch = "mips"; then
- echo "MMI enabled $mmi"
+ echo "MMI enabled $mmi"
fi
if test $arch = "powerpc"; then
- echo "AltiVec enabled $altivec"
- echo "dcbzl available $dcbzl"
-fi
-echo "gprof enabled $gprof"
-echo "zlib enabled $zlib"
-echo "libgsm enabled $libgsm"
-echo "mp3lame enabled $mp3lame"
-echo "libnut enabled $libnut"
-echo "libogg enabled $libogg"
-echo "Vorbis enabled $libvorbis"
-echo "FAAD enabled $faad"
-echo "faadbin enabled $faadbin"
-echo "FAAC enabled $faac"
-echo "XviD enabled $xvid"
-echo "x264 enabled $x264"
-echo "a52 support $a52"
-echo "a52 dlopened $a52bin"
-echo "DTS support $dts"
-echo "pp support $pp"
-echo "Software Scaler enabled $swscaler"
-echo "AVISynth enabled $avisynth"
-echo "debug symbols $debug"
-echo "strip symbols $dostrip"
-echo "optimize $optimize"
-echo "static $lstatic"
-echo "shared $lshared"
-echo "video hooking $vhook"
-echo "SDL support $sdl"
-if test $sdl_too_old = "yes"; then
- echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
+ echo "AltiVec enabled $altivec"
+ echo "dcbzl available $dcbzl"
+fi
+echo "gprof enabled $gprof"
+echo "debug symbols $debug"
+echo "strip symbols $dostrip"
+echo "optimize $optimize"
+echo "static $static"
+echo "shared $shared"
+echo "postprocessing support $pp"
+echo "software scaler enabled $swscaler"
+echo "video hooking $vhook"
+if enabled vhook; then
+ echo "Imlib2 support $imlib2"
+ echo "FreeType support $freetype2"
fi
-
-if test "$vhook" = "yes"; then
- echo "Imlib2 support $imlib2"
- echo "FreeType support $freetype2"
+echo "network support $network"
+if enabled network; then
+ echo "IPv6 support $ipv6"
fi
-echo "Sun medialib support" $mlib
-echo "pthreads support" $pthreads
-echo "AMR-NB float support" $amr_nb
-echo "AMR-NB fixed support" $amr_nb_fixed
-echo "AMR-WB float support" $amr_wb
-echo "AMR-WB IF2 support" $amr_if2
-echo "network support $network"
-if test "$network" = "yes" ; then
- echo "IPv6 support $ipv6"
+echo "threading support $thread_type"
+echo "SDL support $sdl"
+if enabled sdl_too_old; then
+ echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
fi
-echo ".align is power-of-two" $asmalign_pot
-if test "$gpl" = "no" ; then
+echo "Sun medialib support $mlib"
+echo "AVISynth enabled $avisynth"
+echo "liba52 support $liba52"
+echo "liba52 dlopened $liba52bin"
+echo "libdts support $libdts"
+echo "libfaac enabled $libfaac"
+echo "libfaad enabled $libfaad"
+echo "faadbin enabled $libfaadbin"
+echo "libgsm enabled $libgsm"
+echo "libmp3lame enabled $libmp3lame"
+echo "libnut enabled $libnut"
+echo "libogg enabled $libogg"
+echo "libtheora enabled $libtheora"
+echo "libvorbis enabled $libvorbis"
+echo "x264 enabled $x264"
+echo "XviD enabled $xvid"
+echo "zlib enabled $zlib"
+echo "AMR-NB float support $amr_nb"
+echo "AMR-NB fixed support $amr_nb_fixed"
+echo "AMR-WB float support $amr_wb"
+echo "AMR-WB IF2 support $amr_if2"
+if disabled gpl; then
echo "License: LGPL"
else
echo "License: GPL"
@@ -1778,7 +1878,7 @@ echo "Creating config.mak and config.h..."
echo "# Automatically generated by configure - do not modify!" > config.mak
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
-echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
+echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
echo "PREFIX=$PREFIX" >> config.mak
echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
@@ -1791,12 +1891,10 @@ echo "MAKE=$make" >> config.mak
echo "CC=$cc" >> config.mak
echo "AR=$ar" >> config.mak
echo "RANLIB=$ranlib" >> config.mak
-if test "$dostrip" = "yes" ; then
+if enabled dostrip; then
echo "STRIP=$strip" >> config.mak
- echo "INSTALLSTRIP=$installstrip" >> config.mak
else
echo "STRIP=echo ignoring strip" >> config.mak
- echo "INSTALLSTRIP=" >> config.mak
fi
echo "OPTFLAGS=$CFLAGS" >> config.mak
@@ -1808,11 +1906,11 @@ echo "SHFLAGS=$SHFLAGS" >> config.mak
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
-echo "BUILD_STATIC=$lstatic" >> config.mak
+echo "BUILD_STATIC=$static" >> config.mak
echo "BUILDSUF=$BUILDSUF" >> config.mak
echo "LIBPREF=$LIBPREF" >> config.mak
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
-if test "$lstatic" = "yes" ; then
+if enabled static; then
echo "LIB=$LIB" >> config.mak
else # Some Make complain if this variable does not exist.
echo "LIB=" >> config.mak
@@ -1820,7 +1918,6 @@ fi
echo "SLIBPREF=$SLIBPREF" >> config.mak
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
-echo "TARGET_OS=$targetos" >> config.mak
ucarch=`toupper $arch`
echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
@@ -1836,9 +1933,6 @@ case "$arch" in
if test "$POWERPCMODE" = "64bits"; then
echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
fi
- if test "$powerpc_perf" = "yes"; then
- echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
- fi
;;
sparc64)
echo "TARGET_ARCH_SPARC=yes" >> config.mak
@@ -1846,46 +1940,19 @@ case "$arch" in
;;
esac
-if test "$bigendian" = "yes" ; then
+if enabled bigendian; then
echo "WORDS_BIGENDIAN=yes" >> config.mak
echo "#define WORDS_BIGENDIAN 1" >> $TMPH
fi
-if test "$mmx" = "yes" ; then
- echo "TARGET_MMX=yes" >> config.mak
- echo "#define HAVE_MMX 1" >> $TMPH
+if enabled mmx; then
echo "#define __CPU__ 586" >> $TMPH
fi
-if test "$cmov" = "yes" ; then
- echo "TARGET_CMOV=yes" >> config.mak
- echo "#define HAVE_CMOV 1" >> $TMPH
-fi
-if test "$cmov_is_fast" = "yes" ; then
- echo "TARGET_CMOV_IS_FAST=yes" >> config.mak
- echo "#define CMOV_IS_FAST 1" >> $TMPH
-fi
-if test "$armv5te" = "yes" ; then
- echo "TARGET_ARMV5TE=yes" >> config.mak
- echo "#define HAVE_ARMV5TE 1" >> $TMPH
-fi
-if test "$iwmmxt" = "yes" ; then
- echo "TARGET_IWMMXT=yes" >> config.mak
- echo "#define HAVE_IWMMXT 1" >> $TMPH
-fi
-if test "$mmi" = "yes" ; then
- echo "TARGET_MMI=yes" >> config.mak
- echo "#define HAVE_MMI 1" >> $TMPH
-fi
-
-if test "$altivec" = "yes" ; then
- echo "TARGET_ALTIVEC=yes" >> config.mak
- echo "#define HAVE_ALTIVEC 1" >> $TMPH
-fi
-if test "$sdl" = "yes" ; then
+if enabled sdl; then
echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
fi
-if test "$texi2html" = "yes"; then
+if enabled texi2html; then
echo "BUILD_DOC=yes" >> config.mak
fi
@@ -1897,12 +1964,11 @@ lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h
-if test "$lshared" = "yes" ; then
- echo "#define BUILD_SHARED_AV 1" >> $TMPH
+if enabled shared; then
echo "BUILD_SHARED=yes" >> config.mak
echo "PIC=-fPIC -DPIC" >> config.mak
- echo "SPPMAJOR=${lavc_version%%.*}" >> config.mak
- echo "SPPVERSION=$lavc_version" >> config.mak
+ echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
+ echo "SPPVERSION=$pp_version" >> config.mak
echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
echo "LAVCVERSION=$lavc_version" >> config.mak
echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
@@ -1915,21 +1981,16 @@ if test "$lshared" = "yes" ; then
echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
+ echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
fi
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
echo "EXTRALIBS=$extralibs" >> config.mak
-enabled_any $ENCODER_LIST && enable encoders
-enabled_any $DECODER_LIST && enable decoders
-enabled_any $MUXER_LIST && enable muxers
-enabled_any $DEMUXER_LIST && enable demuxers
-
-enabled_any pthreads beosthreads os2threads w32threads && enable threads
-
print_config HAVE_ $TMPH config.mak $HAVE_LIST
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
+print_config TARGET_ $TMPH config.mak $TARGET_LIST
-if test "$targetos" = "Darwin"; then
+if test "$targetos" = darwin; then
echo "#define CONFIG_DARWIN 1" >> $TMPH
fi
@@ -1944,12 +2005,12 @@ echo "SRC_PATH=\"$source_path\"" >> config.mak
echo "SRC_PATH_BARE=$source_path" >> config.mak
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
-if test "$amr_if2" = "yes" ; then
+if enabled amr_if2; then
echo "AMR_CFLAGS=-DIF2=1" >> config.mak
fi
# Apparently it's not possible to portably echo a backslash.
-if test "$asmalign_pot" = "yes" ; then
+if enabled asmalign_pot; then
printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
else
printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
@@ -1979,7 +2040,7 @@ fi
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
# build tree in object directory if source path is different from current one
-if test "$source_path_used" = "yes" ; then
+if enabled source_path_used; then
DIRS="\
doc \
libavformat \
@@ -1991,7 +2052,9 @@ if test "$source_path_used" = "yes" ; then
libavcodec/sparc \
libavcodec/mlib \
libavcodec/ppc \
- libavcodec/liba52 \
+ libavcodec/amr \
+ libavcodec/amr_float \
+ libavcodec/amrwb_float \
libpostproc \
libavutil \
libswscale \
@@ -2019,168 +2082,76 @@ if test "$source_path_used" = "yes" ; then
done
fi
-# build pkg-config files libav*.pc and libpostproc.pc
-# libavutil.pc
-cat <<EOF >libavutil.pc
-prefix=$PREFIX
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libavutil
-Description: FFmpeg utility library
-Version: $lavu_version
-Requires:
-Conflicts:
-Libs: -L\${libdir} -lavutil
-Cflags: -I\${includedir} -I\${includedir}/ffmpeg
-EOF
-cat <<EOF >libavutil-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libavutil
-includedir=\${pcfiledir}/libavutil
-
-Name: libavutil
-Description: FFmpeg utility library
-Version: $lavu_version
-Requires:
-Conflicts:
-Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
-Cflags: -I\${includedir}
-EOF
+# build pkg-config files
+# FIXME: libdir and includedir are hardcoded and may differ from the real path.
-# libavcodec.pc
-cat <<EOF >libavcodec.pc
+pkgconfig_generate(){
+name=$1
+comment=$2
+version=$3
+libs=$4
+requires=$5
+include=$6
+cat <<EOF >$name.pc
prefix=$PREFIX
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
-Name: libavcodec
-Description: FFmpeg codec library
-Version: $lavc_version
-Requires: $pkg_requires libavutil = $lavu_version
+Name: $name
+Description: $comment
+Version: $version
+Requires: $requires
Conflicts:
-Libs: -L\${libdir} -lavcodec $extralibs
-Cflags: -I\${includedir} -I\${includedir}/ffmpeg
-EOF
-
-cat <<EOF >libavcodec-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libavcodec
-includedir=\${pcfiledir}/libavcodec
-
-Name: libavcodec
-Description: FFmpeg codec library
-Version: $lavc_version
-Requires: $pkg_requires libavutil = $lavu_version
-Conflicts:
-Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
-Cflags: -I\${includedir}
-EOF
-
-# libavformat.pc
-cat <<EOF >libavformat.pc
-prefix=$PREFIX
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libavformat
-Description: FFmpeg container format library
-Version: $lavf_version
-Requires: $pkg_requires libavcodec = $lavc_version
-Conflicts:
-Libs: -L\${libdir} -lavformat $extralibs
-Cflags: -I\${includedir} -I\${includedir}/ffmpeg
+Libs: -L\${libdir} $libs
+Cflags: -I\${includedir} -I\${includedir}/$include
EOF
+}
-cat <<EOF >libavformat-uninstalled.pc
+pkgconfig_generate_uninstalled(){
+name=$1
+shortname=${name#lib}
+comment=$2
+version=$3
+libs=$4
+requires=$5
+cat <<EOF >$name-uninstalled.pc
prefix=
exec_prefix=
-libdir=\${pcfiledir}/libavformat
-includedir=\${pcfiledir}/libavformat
+libdir=\${pcfiledir}/$name
+includedir=\${pcfiledir}/$name
-Name: libavformat
-Description: FFmpeg container format library
-Version: $lavf_version
-Requires: $pkg_requires libavcodec = $lavc_version
+Name: $name
+Description: $comment
+Version: $version
+Requires: $requires
Conflicts:
-Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
+Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
Cflags: -I\${includedir}
EOF
+}
+pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
+pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
-# libpostproc.pc
-cat <<EOF >libpostproc.pc
-prefix=$PREFIX
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libpostproc
-Description: FFmpeg post processing library
-Version: $lavc_version
-Requires:
-Conflicts:
-Libs: -L\${libdir} -lpostproc
-Cflags: -I\${includedir} -I\${includedir}/postproc
-EOF
+pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
+pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
-cat <<EOF >libpostproc-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libpostproc
-includedir=\${pcfiledir}/libpostproc
+pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
+pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
-Name: libpostproc
-Description: FFmpeg post processing library
-Version: $lavc_version
-Requires:
-Conflicts:
-Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
-Cflags: -I\${includedir}
-EOF
+if enabled pp; then
+ pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
+ pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
+fi
-if test "$swscaler" != "no"; then
- sws_pc_libs="-L\${libdir} -lswscale"
- sws_pc_uninstalled_libs="\${libdir}/${LIBPREF}swscale${LIBSUF}"
- sws_pc_requires="$pkg_requires libavutil = $lavu_version"
+if enabled swscaler; then
+ pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
+ pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
else
- sws_pc_libs=""
- sws_pc_uninstalled_libs=""
- sws_pc_requires="$pkg_requires libavcodec = $lavc_version"
+ pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
+ pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
+ apply libswscale.pc sed s/^Libs:.*$/Libs:/
+ apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
fi
-# libswscale.pc
-cat <<EOF >libswscale.pc
-prefix=$PREFIX
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libswscale
-Description: FFmpeg image rescaling library
-Version: $sws_version
-Requires: $sws_pc_requires
-Conflicts:
-Libs: $sws_pc_libs
-Cflags: -I\${includedir} -I\${includedir}/swscale
-EOF
-
-cat <<EOF >libswscale-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libswscale
-includedir=\${pcfiledir}/libswscale
-
-Name: libswscale
-Description: FFmpeg image rescaling library
-Version: $sws_version
-Requires: $sws_pc_requires
-Conflicts:
-Libs: $sws_pc_uninstalled_libs
-Cflags: -I\${includedir}
-EOF
diff --git a/contrib/ffmpeg/doc/TODO b/contrib/ffmpeg/doc/TODO
index 8271659d2..996ce3177 100644
--- a/contrib/ffmpeg/doc/TODO
+++ b/contrib/ffmpeg/doc/TODO
@@ -5,7 +5,6 @@ Fabrice's TODO list: (unordered)
-------------------
Short term:
-- seeking API and example in ffplay
- use AVFMTCTX_DISCARD_PKT in ffplay so that DV has a chance to work
- add RTSP regression test (both client and server)
- make ffserver allocate AVFormatContext
@@ -35,7 +34,6 @@ Francois' TODO list: (unordered, without any timeframe)
- test MACE decoder against the openquicktime one as suggested by A'rpi
- BeOS audio input grabbing backend
- BeOS video input grabbing backend
-- have a REAL BeOS errno fix (return MKERROR(EXXX);), not a hack
- publish my BeOS libposix on BeBits so I can officially support ffserver :)
- check the whole code for thread-safety (global and init stuff)
@@ -49,6 +47,13 @@ Philip'a TODO list: (alphabetically ordered) (please help)
- Make ffm files more resilient to changes in the codec structures so that you
can play old ffm files.
+Baptiste's TODO list:
+-----------------
+- mov edit list support (AVEditList)
+- YUV 10 bit per component support "2vuy"
+- mxf muxer
+- mpeg2 non linear quantizer
+
unassigned TODO: (unordered)
---------------
- use AVFrame for audio codecs too
@@ -68,7 +73,7 @@ unassigned TODO: (unordered)
- JPEG2000 decoder & encoder
- MPEG4 GMC encoding support
- macroblock based pixel format (better cache locality, somewhat complex, one paper claimed it faster for high res)
-- finish NUT implementation
+- NUT muxer
- seeking regression test
- regression tests for codecs which dont have an encoder (I+P frame bitstream in svn)
- add support for using mplayers video filters to ffmpeg
@@ -80,3 +85,7 @@ unassigned TODO: (unordered)
- write a script which iteratively changes all functions between always_inline and noinline and benchmarks the result to find the best set of inlined functions
- set up roundup bugtracker somewhere with (newBug, reproduced, analyzed, fixed, worksForMe, duplicate, wontFix, invalid, needMoreInfo, newPatch, ok, applied, rejected, needChanges, newRequest, implemented, wontImplement, invalidReq) states and a checked integer
- convert all the non SIMD asm into small asm vs. C testcases and submit them to the gcc devels so they can improve gcc
+- generic audio mixing API
+- extract PES packetizer from PS muxer and use it for new TS muxer
+- implement automatic AVBistreamFilter activation
+- port libavformat/sgi.c (now removed) to new image format API
diff --git a/contrib/ffmpeg/doc/avutil.txt b/contrib/ffmpeg/doc/avutil.txt
new file mode 100644
index 000000000..a81e74118
--- /dev/null
+++ b/contrib/ffmpeg/doc/avutil.txt
@@ -0,0 +1,37 @@
+AVUtil
+======
+libavutil is a small lightweight library of generally useful functions.
+It is not a library for code needed by both libavcodec and libavformat.
+
+
+Overview:
+=========
+adler32.c adler32 checksum
+aes.c AES encryption and decryption
+fifo.c resizeable first in first out buffer
+intfloat_readwrite.c portable reading and writing of floating point values
+log.c "printf" with context and level
+md5.c MD5 Message-Digest Algorithm
+rational.c code to perform exact calculations with rational numbers
+tree.c generic AVL tree
+crc.c generic CRC checksumming code
+integer.c 128bit integer math
+lls.c
+mathematics.c greatest common divisor, integer sqrt, integer log2, ...
+mem.c memory allocation routines with guaranteed alignment
+softfloat.c
+
+Headers:
+bswap.h big/little/native-endian conversion code
+x86_cpu.h a few useful macros for unifying x86-64 and x86-32 code
+avutil.h
+common.h
+intreadwrite.h reading and writing of unaligned big/little/native-endian integers
+
+
+Goals:
+======
+* Modular (few interdependencies and the possibility of disabling individual parts during ./configure)
+* Small (source and object)
+* Efficient (low CPU and memory usage)
+* Useful (avoid useless features almost noone needs)
diff --git a/contrib/ffmpeg/doc/faq.texi b/contrib/ffmpeg/doc/faq.texi
index 9f1e8ec2d..9c41679ae 100644
--- a/contrib/ffmpeg/doc/faq.texi
+++ b/contrib/ffmpeg/doc/faq.texi
@@ -80,7 +80,7 @@ Use @file{-} as filename.
The audio is AC3 (a.k.a. A/52). AC3 decoding is an optional component in ffmpeg
as the component that handles AC3 decoding (liba52) is currently released under
the GPL. If you have liba52 installed on your system, enable AC3 decoding
-with @code{./configure --enable-a52}. Take care: by
+with @code{./configure --enable-liba52 --enable-gpl}. Take care: by
enabling AC3, you automatically change the license of libavcodec from
LGPL to GPL.
@@ -121,14 +121,14 @@ if some MP3 codec like LAME is installed
@section Why does the chrominance data seem to be sampled at a different time from the luminance data on bt8x8 captures on Linux?
This is a well-known bug in the bt8x8 driver. For 2.4.26 there is a patch at
-(@url{http://mplayerhq.hu/~michael/bttv-420-2.4.26.patch}). This may also
+(@url{http://svn.mplayerhq.hu/michael/trunk/patches/bttv-420-2.4.26.patch?view=co}). This may also
apply cleanly to other 2.4-series kernels.
@section How do I avoid the ugly aliasing artifacts in bt8x8 captures on Linux?
Pass 'combfilter=1 lumafilter=1' to the bttv driver. Note though that 'combfilter=1'
-will cause somewhat too strong filtering. A fix is to apply (@url{http://mplayerhq.hu/~michael/bttv-comb-2.4.26.patch})
-or (@url{http://mplayerhq.hu/~michael/bttv-comb-2.6.6.patch})
+will cause somewhat too strong filtering. A fix is to apply (@url{http://svn.mplayerhq.hu/michael/trunk/patches/bttv-comb-2.4.26.patch?view=co})
+or (@url{http://svn.mplayerhq.hu/michael/trunk/patches/bttv-comb-2.6.6.patch?view=co})
and pass 'combfilter=2'.
@section I have a problem with an old version of ffmpeg; where should I report it?
@@ -148,7 +148,7 @@ Choose a different codec with the -vcodec command line option.
@section ffmpeg does not work; What is wrong?
-Try a 'make distclean' in the ffmpeg source directory. If this does not help see
+Try a 'make distclean' in the ffmpeg source directory before the build. If this does not help see
(@url{http://ffmpeg.org/bugreports.php}).
@section How do I encode XviD or DivX video with ffmpeg?
@@ -171,7 +171,7 @@ default.
@item non-working stuff
B-frames
@item example command line
-ffmpeg -i input -acodec aac -ab 128 -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X output.mp4
+ffmpeg -i input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X output.mp4
@end table
@section How do I encode videos which play on the PSP?
@@ -184,7 +184,7 @@ ffmpeg -i input -acodec aac -ab 128 -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+t
@item non-working stuff
B-frames
@item example command line
-ffmpeg -i input -acodec aac -ab 128 -vcodec mpeg4 -b 1200kb -ar 24000 -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -title X -f psp output.mp4
+ffmpeg -i input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -ar 24000 -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -title X -f psp output.mp4
@item needed stuff for H.264
-acodec aac -vcodec h264 width*height<=76800 width%16=0? height%16=0? -ar 48000 -coder 1 -r 30000/1001 or 15000/1001 -f psp
@item working stuff for H.264
@@ -192,9 +192,25 @@ title, loop filter
@item non-working stuff for H.264
CAVLC
@item example command line
-ffmpeg -i input -acodec aac -ab 128 -vcodec h264 -b 1200kb -ar 48000 -mbd 2 -coder 1 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -title X -f psp -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 output.mp4
+ffmpeg -i input -acodec aac -ab 128kb -vcodec h264 -b 1200kb -ar 48000 -mbd 2 -coder 1 -cmp 2 -subcmp 2 -s 368x192 -r 30000/1001 -title X -f psp -flags loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 output.mp4
@end table
+@section Which are good parameters for encoding high quality MPEG-4?
+
+'-mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g 300 -pass 1/2',
+things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd'.
+
+@section Which are good parameters for encoding high quality MPEG-1/MPEG-2?
+
+'-mbd rd -flags +trell -cmp 2 -subcmp 2 -g 100 -pass 1/2'
+but beware the '-g 100' might cause problems with some decoders.
+Things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd.
+
+@section Interlaced video looks very bad when encoded with ffmpeg, whats wrong?
+
+You should use '-flags +ilme+ildct' and maybe '-flags +alt' for interlaced
+material, and try '-top 0/1' if the result looks really messed-up.
+
@section How can I read DirectShow files?
If you have built FFmpeg with @code{./configure --enable-avisynth}
@@ -214,6 +230,24 @@ Just create an "input.avs" text file with this single line ...
For ANY other help on Avisynth, please visit @url{http://www.avisynth.org/}.
+@section My bugreport/mail to ffmpeg-devel/user has not received any replies.
+
+Likely reasons
+@itemize
+@item We are busy and haven't had time yet to read your report or
+investigate the issue.
+@item You didn't follow bugreports.html.
+@item You didn't use Subversion HEAD.
+@item You reported a segmentation fault without gdb output.
+@item You describe a problem but not how to reproduce it.
+@item It's unclear if you use ffmpeg as command line tool or use
+libav* from another application.
+@item You speak about a video having problems on playback but
+not what you use to play it.
+@item We have no faint clue what you are talking about besides
+that it is related to FFmpeg.
+@end itemize
+
@chapter Development
@section When will the next FFmpeg version be released? / Why are FFmpeg releases so few and far between?
@@ -241,9 +275,24 @@ already incorporate ffmpeg at (@url{projects.php}).
@section Can you support my C compiler XXX ?
-No. Only GCC is supported. GCC is ported to most systems available and there
-is no need to pollute the source code with @code{#ifdef}s
-related to the compiler.
+It depends. If your compiler is C99-compliant, then patches to support
+it are likely to be welcome if they do not pollute the source code
+with @code{#ifdef}s related to the compiler.
+
+@section Visual C++ produces many errors.
+
+Visual C++ is not compliant to the C standard and does not support
+the inline assembly used in FFmpeg.
+If you wish - for whatever weird reason - to use Visual C++ for your
+project then you can link the Visual C++ code with libav* as long as
+you compile the latter with a working C compiler. For more information, see
+the @emph{Visual C++ compatibility} section in the FFmpeg documentation.
+
+There have been efforts to make FFmpeg compatible with Visual C++ in the
+past. However, they have all been rejected as too intrusive, especially
+since MinGW does the job perfectly adequately. None of the core developers
+work with Visual C++ and thus this item is low priority. Should you find
+the silver bullet that solves this problem, feel free to shoot it at us.
@section Can I use FFmpeg or libavcodec under Windows ?
@@ -252,18 +301,20 @@ can link the resulting DLLs with any other Windows program. Read the
@emph{Native Windows Compilation} and @emph{Visual C++ compatibility}
sections in the FFmpeg documentation to find more information.
+To get help and instructions for using FFmpeg under Windows, check out
+the FFmpeg Windows Help Forum at
+@url{http://arrozcru.no-ip.org/ffmpeg/}.
+
@section Can you add automake, libtool or autoconf support ?
-No. These tools are too bloated and they complicate the build. Moreover,
-since only @samp{gcc} is supported they would add little advantages in
-terms of portability.
+No. These tools are too bloated and they complicate the build.
@section Why not rewrite ffmpeg in object-oriented C++ ?
ffmpeg is already organized in a highly modular manner and does not need to
be rewritten in a formal object language. Further, many of the developers
favor straight C; it works for them. For more arguments on this matter,
-read "Programming Religion" at (@url{http://lkml.org/faq/lkmlfaq-15.html}).
+read "Programming Religion" at (@url{http://www.tux.org/lkml/#s15}).
@section Why are the ffmpeg programs devoid of debugging symbols ?
@@ -285,21 +336,6 @@ the whole libav*. If you wish, disable some parts with configure switches.
You can also try to hack it and remove more, but if you had problems fixing
the compilation failure then you are probably not qualified for this.
-@section Visual C++ produces many errors.
-
-Visual C++ is not compliant to the C standard and does not support
-the inline assembly used in FFmpeg.
-If you wish - for whatever weird reason - to use Visual C++ for your
-project then you can link the Visual C++ code with libav* as long as
-you compile the latter with a working C compiler. For more information, see
-the @emph{Visual C++ compatibility} section in the FFmpeg documentation.
-
-There have been efforts to make FFmpeg compatible with Visual C++ in the
-past. However, they have all been rejected as too intrusive, especially
-since MinGW does the job perfectly adequately. None of the core developers
-work with Visual C++ and thus this item is low priority. Should you find
-the silver bullet that solves this problem, feel free to shoot it at us.
-
@section I have a file in memory / a API different from *open/*read/ libc how do i use it with libavformat ?
You have to implement a URLProtocol, see libavformat/file.c in FFmpeg
@@ -309,4 +345,19 @@ and libmpdemux/demux_lavf.c in MPlayer sources.
The standard MSys bash (2.04) is broken. You need to install 2.05 or later.
+@section I tried to pass RTP packets into a decoder, but it doesn't work.
+
+Of course not, you MUST strip ALL RTP headers and assemble valid packets
+first, an MP3 decoder decodes MP3 packets not bastardized MP3 packets
+encapsulated in RTP. The same applies to all decoders, this is not specific
+to ffmpeg or libavcodec.
+
+@section where can i find libav* headers for pascal/delphi
+
+see @url{http://www.iversenit.dk/dev/ffmpeg-headers/}
+
+@section where are the docs about ffv1, msmpeg4, asv1, 4xm?
+
+see @url{http://svn.mplayerhq.hu/michael/trunk/docs/}
+
@bye
diff --git a/contrib/ffmpeg/doc/ffmpeg-doc.texi b/contrib/ffmpeg/doc/ffmpeg-doc.texi
index 2d814c0fb..e4e6430fd 100644
--- a/contrib/ffmpeg/doc/ffmpeg-doc.texi
+++ b/contrib/ffmpeg/doc/ffmpeg-doc.texi
@@ -26,11 +26,11 @@ video on the fly with a high quality polyphase filter.
@c man begin EXAMPLES
@section Video and Audio grabbing
-FFmpeg can use a video4linux compatible video source and any Open Sound
-System audio source:
+FFmpeg can grab video and audio from devices given that you specify the input
+format and device.
@example
-ffmpeg /tmp/out.mpg
+ffmpeg -f audio_device -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
@end example
Note that you must activate the right video source and channel before
@@ -39,6 +39,24 @@ launching FFmpeg with any TV viewer such as xawtv
have to set the audio recording levels correctly with a
standard mixer.
+@section X11 grabbing
+
+FFmpeg can grab the X11 display.
+
+@example
+ffmpeg -f x11grab -i :0.0 /tmp/out.mpg
+@end example
+
+0.0 is display.screen number of your X11 server, same as
+the DISPLAY environment variable.
+
+@example
+ffmpeg -f x11grab -i :0.0+10,20 /tmp/out.mpg
+@end example
+
+0.0 is display.screen number of your X11 server, same as the DISPLAY environment
+variable. 10 is the x-offset and 20 the y-offset for the grabbing.
+
@section Video and Audio file format conversion
* FFmpeg can use any supported file format and protocol as input:
@@ -99,7 +117,7 @@ Converts a.wav to MPEG audio at 22050Hz sample rate.
mapping from input stream to output streams:
@example
-ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
+ffmpeg -i /tmp/a.wav -ab 64k /tmp/a.mp2 -ab 128k /tmp/b.mp2 -map 0:0 -map 0:0
@end example
Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
@@ -109,7 +127,7 @@ stream, in the order of the definition of output streams.
* You can transcode decrypted VOBs
@example
-ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
+ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec mp3 -ab 128k snatch.avi
@end example
This is a typical DVD ripping example; the input is a VOB file, the
@@ -136,8 +154,6 @@ ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{
@c man end
@end example
@c man begin DESCRIPTION
-If no input file is given, audio/video grabbing is done.
-
As a general rule, options are applied to the next specified
file. Therefore, order is important, and you can have the same
option on the command line multiple times. Each occurrence is
@@ -281,7 +297,7 @@ Set the number of video frames to record.
@item -r fps
Set frame rate (Hz value, fraction or abbreviation), (default = 25).
@item -s size
-Set frame size. The format is @samp{wxh} (default = 160x128).
+Set frame size. The format is @samp{wxh} (ffserver default = 160x128, ffmpeg default = same as source).
The following abbreviations are recognized:
@table @samp
@item sqcif
@@ -544,7 +560,7 @@ Set the number of audio frames to record.
@item -ar freq
Set the audio sampling frequency (default = 44100 Hz).
@item -ab bitrate
-Set the audio bitrate in kbit/s (default = 64).
+Set the audio bitrate in bit/s (default = 64k).
@item -ac channels
Set the number of audio channels (default = 1).
@item -an
@@ -562,7 +578,7 @@ can override the mapping using @code{-map} as usual.
Example:
@example
-ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384 test.mpg -acodec mp2 -ab 192 -newaudio
+ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384k test.mpg -acodec mp2 -ab 192k -newaudio
@end example
@item -alang code
Set the ISO 639 language code (3 letters) of the current audio stream.
@@ -591,20 +607,12 @@ Set the ISO 639 language code (3 letters) of the current subtitle stream.
@section Audio/Video grab options
@table @option
-@item -vd device
-sEt video grab device (e.g. @file{/dev/video0}).
@item -vc channel
Set video grab channel (DV1394 only).
@item -tvstd standard
Set television standard (NTSC, PAL (SECAM)).
-@item -dv1394
-Set DV1394 grab.
-@item -ad device
-Set audio device (e.g. @file{/dev/dsp}).
-@item -grab format
-Request grabbing using.
-@item -gd device
-Set grab device.
+@item -isync
+Synchronize read on input.
@end table
@section Advanced options
@@ -890,6 +898,11 @@ library:
@tab Material eXchange Format SMPTE 377M, used by D-Cinema, broadcast industry.
@item SEQ @tab @tab X
@tab Tiertex .seq files used in the DOS CDROM version of the game Flashback.
+@item DXA @tab @tab X
+@tab This format is used in non-Windows version of Feeble Files game and
+different game cutscenes repacked for use with ScummVM.
+@item THP @tab @tab X
+@tab Used on the Nintendo GameCube (video only)
@end multitable
@code{X} means that encoding (resp. decoding) is supported.
@@ -950,11 +963,11 @@ following image formats are supported:
@item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
@item On2 VP3 @tab @tab X @tab still experimental
@item On2 VP5 @tab @tab X @tab fourcc: VP50
-@item On2 VP6 @tab @tab X @tab fourcc: VP62
-@item Theora @tab @tab X @tab still experimental
+@item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62
+@item Theora @tab X @tab X @tab still experimental
@item Intel Indeo 3 @tab @tab X
@item FLV @tab X @tab X @tab Sorenson H.263 used in Flash
-@item Flash Screen Video @tab @tab X @tab fourcc: FSV1
+@item Flash Screen Video @tab X @tab X @tab fourcc: FSV1
@item ATI VCR1 @tab @tab X @tab fourcc: VCR1
@item ATI VCR2 @tab @tab X @tab fourcc: VCR2
@item Cirrus Logic AccuPak @tab @tab X @tab fourcc: CLJR
@@ -989,7 +1002,7 @@ following image formats are supported:
@item Fraps FPS1 @tab @tab X @tab
@item CamStudio @tab @tab X @tab fourcc: CSCD
@item American Laser Games Video @tab @tab X @tab Used in games like Mad Dog McCree
-@item ZMBV @tab @tab X @tab
+@item ZMBV @tab X @tab X @tab Encoder works only on PAL8
@item AVS Video @tab @tab X @tab Video encoding used by the Creature Shock game.
@item Smacker Video @tab @tab X @tab Video encoding used in Smacker.
@item RTjpeg @tab @tab X @tab Video encoding used in NuppelVideo files.
@@ -997,6 +1010,8 @@ following image formats are supported:
@item VMware Video @tab @tab X @tab Codec used in videos captured by VMware.
@item Cin Video @tab @tab X @tab Codec used in Delphine Software games.
@item Tiertex Seq Video @tab @tab X @tab Codec used in DOS CDROM FlashBack game.
+@item DXA Video @tab @tab X @tab Codec originally used in Feeble Files game.
+@item AVID DNxHD @tab @tab X @tab aka SMPTE VC3
@end multitable
@code{X} means that encoding (resp. decoding) is supported.
@@ -1011,7 +1026,7 @@ following image formats are supported:
@item AC3 @tab IX @tab IX
@tab liba52 is used internally for decoding.
@item Vorbis @tab X @tab X
-@item WMA V1/V2 @tab @tab X
+@item WMA V1/V2 @tab X @tab X
@item AAC @tab X @tab X
@tab Supported through the external library libfaac/libfaad.
@item Microsoft ADPCM @tab X @tab X
@@ -1072,6 +1087,9 @@ following image formats are supported:
@item Cin Audio @tab @tab X
@tab Codec used in Delphine Software games.
@item Intel Music Coder @tab @tab X
+@item Musepack @tab @tab X
+@tab Only SV7 is supported
+@item DT$ Coherent Audio @tab @tab X
@end multitable
@code{X} means that encoding (resp. decoding) is supported.
@@ -1081,12 +1099,6 @@ performance on systems without hardware floating point support).
@chapter Platform Specific information
-@section Linux
-
-FFmpeg should be compiled with at least GCC 2.95.3. GCC 3.2 is the
-preferred compiler now for FFmpeg. All future optimizations will depend on
-features only found in GCC 3.2.
-
@section BSD
BSD make will not build FFmpeg, you need to install and use GNU Make
@@ -1094,6 +1106,10 @@ BSD make will not build FFmpeg, you need to install and use GNU Make
@section Windows
+To get help and instructions for using FFmpeg under Windows, check out
+the FFmpeg Windows Help Forum at
+@url{http://arrozcru.no-ip.org/ffmpeg/}.
+
@subsection Native Windows compilation
@itemize
@@ -1101,6 +1117,9 @@ BSD make will not build FFmpeg, you need to install and use GNU Make
@url{http://www.mingw.org/}. You can find detailed installation
instructions in the download section and the FAQ.
+NOTE: Use at least bash 3.1. Older versions are known to be failing on the
+configure script.
+
@item If you want to test the FFplay, also download
the MinGW development library of SDL 1.2.x
(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
@@ -1120,7 +1139,7 @@ suffices. If you have problems using SDL, verify that
@file{sdl-config} can be launched from the MSYS command line.
@item You can install FFmpeg in @file{Program Files/FFmpeg} by typing
-@file{make install}. Don't forget to copy @file{SDL.dll} to the place
+@file{make install}. Do not forget to copy @file{SDL.dll} to the place
you launch @file{ffplay} from.
@end itemize
@@ -1166,7 +1185,7 @@ so they can be used with Visual C++:
@enumerate
-@item Install Visual C++ (if you haven't done so already).
+@item Install Visual C++ (if you have not done so already).
@item Install MinGW and MSYS as described above.
@@ -1190,7 +1209,7 @@ create Visual-C++-compatible import libraries.
@item Type the command
@code{./configure --enable-shared --disable-static --enable-memalign-hack}
-to configure and, if that didn't produce any errors,
+to configure and, if that did not produce any errors,
type @code{make} to build FFmpeg.
@item The subdirectories @file{libavformat}, @file{libavcodec}, and
@@ -1212,8 +1231,8 @@ Application Wizard, uncheck the "Precompiled headers" option.
@item Write the source code for your application, or, for testing, just
copy the code from an existing sample application into the source file
that Visual C++ has already created for you. (Note that your source
-filehas to have a @code{.cpp} extension; otherwise, Visual C++ won't
-compile the FFmpeg headers correctly because in C mode, it doesn't
+filehas to have a @code{.cpp} extension; otherwise, Visual C++ will not
+compile the FFmpeg headers correctly because in C mode, it does not
recognize the @code{inline} keyword.) For example, you can copy
@file{output_example.c} from the FFmpeg distribution (but you will
have to make minor modifications so the code will compile under
@@ -1246,7 +1265,7 @@ set to "Multi-threaded DLL".
the application. Hopefully, it should compile and run cleanly. If you
used @file{output_example.c} as your sample application, you will get a
few compiler errors, but they are easy to fix. The first type of error
-occurs because Visual C++ doesn't allow an @code{int} to be converted to
+occurs because Visual C++ does not allow an @code{int} to be converted to
an @code{enum} without a cast. To solve the problem, insert the required
casts (this error occurs once for a @code{CodecID} and once for a
@code{CodecType}). The second type of error occurs because C++ requires
@@ -1269,7 +1288,7 @@ You must use the MinGW cross compilation tools available at
Then configure FFmpeg with the following options:
@example
-./configure --enable-mingw32 --cross-prefix=i386-mingw32msvc-
+./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
@end example
(you can change the cross-prefix according to the prefix chosen for the
MinGW tools).
@@ -1311,7 +1330,7 @@ and/or SDL, xvid, faac, faad2 packages from Cygwin Ports,
@subsection Crosscompilation for Windows under Cygwin
-With Cygwin you can create Windows binaries that don't need the cygwin1.dll.
+With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
Just install your Cygwin as explained before, plus these additional
"Devel" packages:
@@ -1323,12 +1342,12 @@ and add some special flags to your configure invocation.
For a static build run
@example
-./configure --enable-mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
+./configure --target-os=mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
@end example
and for a build with shared libraries
@example
-./configure --enable-mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
+./configure --target-os=mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
@end example
@section BeOS
@@ -1342,7 +1361,7 @@ Old stuff:
François Revol - revol at free dot fr - April 2002
The configure script should guess the configuration itself,
-however I still didn't test building on the net_server version of BeOS.
+however I still did not test building on the net_server version of BeOS.
FFserver is broken (needs poll() implementation).
@@ -1392,14 +1411,14 @@ designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
compound literals (@samp{x = (struct s) @{ 17, 23 @};})
@end itemize
-These features are supported by all compilers we care about, so we won't
-accept patches to remove their use unless they absolutely don't impair
+These features are supported by all compilers we care about, so we will not
+accept patches to remove their use unless they absolutely do not impair
clarity and performance.
All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also
compiles with several other compilers, such as the Compaq ccc compiler
or Sun Studio 9, and we would like to keep it that way unless it would
-be exceedingly involved. To ensure compatibility, please don't use any
+be exceedingly involved. To ensure compatibility, please do not use any
additional C99 features or GCC extensions. Especially watch out for:
@itemize @bullet
@item
@@ -1424,7 +1443,7 @@ bugs).
Comments: Use the JavaDoc/Doxygen
format (see examples below) so that code documentation
can be generated automatically. All nontrivial functions should have a comment
-above them explaining what the function does, even if it's just one sentence.
+above them explaining what the function does, even if it is just one sentence.
All structures and their member variables should be documented, too.
@example
/**
@@ -1470,13 +1489,19 @@ please use av_log() instead.
(#ifdef etc) by default so it does not interfere with other developers'
work.
@item
- You don't have to over-test things. If it works for you, and you think it
+ You do not have to over-test things. If it works for you, and you think it
should work for others, then commit. If your code has problems
(portability, triggers compiler bugs, unusual environment etc) they will be
reported and eventually fixed.
@item
Do not commit unrelated changes together, split them into self-contained
- pieces.
+ pieces. Also do not forget that if part B depends on part A, but A does not
+ depend on B, then A can and should be committed first and separate from B.
+ Keeping changes well split into self-contained parts makes reviewing and
+ understanding them on the commit log mailing list easier. This also helps
+ in case of debugging later on.
+ Also if you have doubts about splitting or not splitting, do not hesitate to
+ ask/disscuss it on the developer mailing list.
@item
Do not change behavior of the program (renaming options etc) without
first discussing it on the ffmpeg-devel mailing list. Do not remove
@@ -1497,12 +1522,12 @@ please use av_log() instead.
developer has his own indentation style, you should not change it. Of course
if you (re)write something, you can use your own style, even though we would
prefer if the indentation throughout FFmpeg was consistent (Many projects
- force a given indentation style - we don't.). If you really need to make
+ force a given indentation style - we do not.). If you really need to make
indentation changes (try to avoid this), separate them strictly from real
changes.
NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
- then either do NOT change the indentation of the inner part within (don't
+ then either do NOT change the indentation of the inner part within (do not
move it to the right)! or do so in a separate commit
@item
Always fill out the commit log message. Describe in a few lines what you
@@ -1518,7 +1543,7 @@ please use av_log() instead.
Do NOT commit to code actively maintained by others without permission.
Send a patch to ffmpeg-devel instead. If noone answers within a reasonable
timeframe (12h for build failures and security fixes, 3 days small changes,
- 1 week for big patches) then commit your patch if you think it's OK.
+ 1 week for big patches) then commit your patch if you think it is OK.
Also note, the maintainer can simply ask for more time to review!
@item
Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
@@ -1530,6 +1555,9 @@ please use av_log() instead.
unsure how best to do this, send a patch to ffmpeg-devel, the documentation
maintainer(s) will review and commit your stuff.
@item
+ Try to keep important discussions and requests (also) on the public
+ developer mailing list, so that all developers can benefit from them.
+@item
Never write to unallocated memory, never write over the end of arrays,
always check values read from some untrusted source before using them
as array index or other risky things.
@@ -1549,6 +1577,9 @@ please use av_log() instead.
component of the @file{libavcodec} version number appropriately. If
it has a fourcc, add it to @file{libavformat/avienc.c}, even if it
is only a decoder.
+@item
+ Do not change code to hide warnings without ensuring that the underlying
+ logic is correct and thus the warning was inappropriate.
@end enumerate
We think our rules are not too hard. If you have comments, contact us.
@@ -1557,7 +1588,7 @@ Note, these rules are mostly borrowed from the MPlayer project.
@section Submitting patches
-First, (@pxref{Coding Rules}) above if you didn't yet.
+First, (@pxref{Coding Rules}) above if you did not yet.
When you submit your patch, try to send a unified diff (diff '-up'
option). I cannot read other diffs :-)
@@ -1570,7 +1601,7 @@ Run the regression tests before submitting a patch so that you can
verify that there are no big problems.
Patches should be posted as base64 encoded attachments (or any other
-encoding which ensures that the patch won't be trashed during
+encoding which ensures that the patch will not be trashed during
transmission) to the ffmpeg-devel mailing list, see
@url{http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
@@ -1578,8 +1609,26 @@ It also helps quite a bit if you tell us what the patch does (for example
'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
and has no lrint()')
-We reply to all submitted patches and either apply or reject with some
-explanation why, but sometimes we are quite busy so it can take a week or two.
+@section Patch review process
+
+All patches posted to ffmpeg-devel will be reviewed, unless they contain a
+clear note that the patch is not for SVN.
+Reviews and comments will be posted as replies to the patch on the
+mailing list. The patch submitter then has to take care of every comment,
+that can be by resubmitting a changed patch or by disscussion. Resubmitted
+patches will themselves be reviewed like any other patch. If at some point
+a patch passes review with no comments then it is approved, that can for
+simple and small patches happen immediately while large patches will generally
+have to be changed and reviewed many times before they are approved.
+After a patch is approved it will be committed to the repository.
+
+We will review all submitted patches, but sometimes we are quite busy so
+especially for large patches this can take several weeks.
+
+When resubmitting patches, please do not make any significant changes
+not related to the comments received during review. Such patches will
+be rejected. Instead, submit significant changes or new features as
+separate patches.
@section Regression tests
diff --git a/contrib/ffmpeg/doc/ffplay-doc.texi b/contrib/ffmpeg/doc/ffplay-doc.texi
index db08eb38f..1ac315662 100644
--- a/contrib/ffmpeg/doc/ffplay-doc.texi
+++ b/contrib/ffmpeg/doc/ffplay-doc.texi
@@ -35,10 +35,17 @@ show help
force displayed width
@item -y height
force displayed height
+@item -s size
+Set frame size (WxH or abbreviation), needed for videos which don't
+contain a header with the framesize like raw YUV.
@item -an
disable audio
@item -vn
disable video
+@item -ss pos
+seek to a given position in seconds
+@item -bytes
+seek by bytes
@item -nodisp
disable graphical display
@item -f fmt
@@ -47,9 +54,21 @@ force format
@section Advanced options
@table @option
+@item -pix_fmt format
+set pixel format
@item -stats
Show the stream duration, the codec parameters, the current position in
the stream and the audio/video synchronisation drift.
+@item -debug
+print specific debug info
+@item -bug
+work around bugs
+@item -vismv
+visualize motion vectors
+@item -fast
+non-spec-compliant optimizations
+@item -genpts
+generate pts
@item -rtp_tcp
Force RTP/TCP protocol usage instead of RTP/UDP. It is only meaningful
if you are streaming with the RTSP protocol.
@@ -60,6 +79,8 @@ master clock is used to control audio-video synchronization. Most media
players use audio as master clock, but in some cases (streaming or high
quality broadcast) it is necessary to change that. This option is mainly
used for debugging purposes.
+@item -threads count
+thread count
@end table
@section While playing
@@ -82,6 +103,16 @@ cycle video channel
@item w
show audio waves
+
+@item left/right
+seek backward/forward 10 seconds
+
+@item down/up
+seek backward/forward 1 minute
+
+@item mouse click
+seek to percentage in file corresponding to fraction of width
+
@end table
@c man end
diff --git a/contrib/ffmpeg/doc/hooks.texi b/contrib/ffmpeg/doc/hooks.texi
index 15013547c..49504509f 100644
--- a/contrib/ffmpeg/doc/hooks.texi
+++ b/contrib/ffmpeg/doc/hooks.texi
@@ -17,13 +17,18 @@ the video to be modified or examined between the decoder and the encoder.
Any number of hook modules can be placed inline, and they are run in the
order that they were specified on the ffmpeg command line.
-Three modules are provided and are described below. They are all intended to
-be used as a base for your own modules.
+The video hook modules are provided for use as a base for your own modules,
+and are described below.
Modules are loaded using the -vhook option to ffmpeg. The value of this parameter
is a space separated list of arguments. The first is the module name, and the rest
are passed as arguments to the Configure function of the module.
+The modules are dynamic libraries: They have different suffixes (.so, .dll, .dylib)
+depending on your platform. And your platform dictates if they need to be
+somewhere in your PATH, or in your LD_LIBRARY_PATH. Otherwise you will need to
+specify the full path of the vhook file that you are using.
+
@section null.c
This does nothing. Actually it converts the input image to RGB24 and then converts
@@ -43,14 +48,24 @@ colors than would an RGB cuboid.
This module implements a text overlay for a video image. Currently it
supports a fixed overlay or reading the text from a file. The string
-is passed through strftime so that it is easy to imprint the date and
+is passed through strftime() so that it is easy to imprint the date and
time onto the image.
+This module depends on the external library imlib2, available on
+Sourceforge, among other places, if it is not already installed on
+your system.
+
You may also overlay an image (even semi-transparent) like TV stations do.
You may move either the text or the image around your video to create
scrolling credits, for example.
-Text fonts are being looked for in a FONTPATH environment variable.
+The font file used is looked for in a FONTPATH environment variable, and
+prepended to the point size as a command line option and can be specified
+with the full path to the font file, as in:
+@example
+-F /usr/X11R6/lib/X11/fonts/TTF/VeraBd.ttf/20
+@end example
+where 20 is the point size.
Options:
@multitable @columnfractions .2 .8
@@ -58,8 +73,8 @@ Options:
@item @option{-F <fontname>} @tab The font face and size
@item @option{-t <text>} @tab The text
@item @option{-f <filename>} @tab The filename to read text from
-@item @option{-x <expresion>} @tab X coordinate of text or image
-@item @option{-y <expresion>} @tab Y coordinate of text or image
+@item @option{-x <expresion>} @tab x coordinate of text or image
+@item @option{-y <expresion>} @tab y coordinate of text or image
@item @option{-i <filename>} @tab The filename to read a image from
@end multitable
@@ -96,13 +111,53 @@ Usage examples:
ffmpeg -i input.avi -vhook \
'vhook/imlib2.dll -c red -F Vera.ttf/20 -x 150+0.5*N -y 70+0.25*N -t Hello' \
-acodec copy -sameq output.avi
+
+ # Date and time stamp, security-camera style:
+ ffmpeg -r 29.97 -s 320x256 -f video4linux -i /dev/video0 \
+ -vhook 'vhook/imlib2.so -x 0 -y 0 -i black-260x20.png' \
+ -vhook 'vhook/imlib2.so -c white -F VeraBd.ttf/12 -x 0 -y 0 -t %A-%D-%T' \
+ output.avi
+
+ In this example the video is captured from the first video capture card as a
+ 320x256 AVI, and a black 260 by 20 pixel PNG image is placed in the upper
+ left corner, with the day, date and time overlaid on it in Vera Bold 12
+ point font. A simple black PNG file 260 pixels wide and 20 pixels tall
+ was created in the GIMP for this purpose.
+
+ # Scrolling credits from a text file
+ ffmpeg -i input.avi -vhook \
+ 'vhook/imlib2.so -c white -F VeraBd.ttf/16 -x 100 -y -1.0*N -f credits.txt' \
+ -sameq output.avi
+
+ In this example, the text is stored in a file, and is positioned 100
+ pixels from the left hand edge of the video. The text is scrolled from the
+ bottom up. Making the y factor positive will scroll from the top down.
+ Increasing the magnitude of the y factor makes the text scroll faster,
+ decreasing it makes it scroll slower. Hint: Blank lines containing only
+ a newline are treated as end-of-file. To create blank lines, use lines
+ that consist of space characters only.
+
+ # scrolling credits from a graphics file
+ ffmpeg -sameq -i input.avi \
+ -vhook 'vhook/imlib2.so -x 0 -y -1.0*N -i credits.png' output.avi
+
+ In this example, a transparent PNG file the same width as the video
+ (e.g. 320 pixels), but very long, (e.g. 3000 pixels), was created, and
+ text, graphics, brushstrokes, etc, were added to the image. The image
+ is then scrolled up, from the bottom of the frame.
+
@end example
@section ppm.c
It's basically a launch point for a PPM pipe, so you can use any
executable (or script) which consumes a PPM on stdin and produces a PPM
-on stdout (and flushes each frame).
+on stdout (and flushes each frame). The Netpbm utilities are a series of
+such programs.
+
+A list of them is here:
+
+@url{http://netpbm.sourceforge.net/doc/directory.html}
Usage example:
@@ -110,4 +165,96 @@ Usage example:
ffmpeg -i input -vhook "/path/to/ppm.so some-ppm-filter args" output
@end example
+@section drawtext.c
+
+This module implements a text overlay for a video image. Currently it
+supports a fixed overlay or reading the text from a file. The string
+is passed through strftime() so that it is easy to imprint the date and
+time onto the image.
+
+Features:
+@itemize @minus
+@item TrueType, Type1 and others via the FreeType2 library
+@item Font kerning (better output)
+@item Line Wrap (put the text that doesn't fit one line on the next line)
+@item Background box (currently in development)
+@item Outline
+@end itemize
+
+Options:
+@multitable @columnfractions .2 .8
+@item @option{-c <color>} @tab Foreground color of the text ('internet' way) <#RRGGBB> [default #FFFFFF]
+@item @option{-C <color>} @tab Background color of the text ('internet' way) <#RRGGBB> [default #000000]
+@item @option{-f <font-filename>} @tab font file to use
+@item @option{-t <text>} @tab text to display
+@item @option{-T <filename>} @tab file to read text from
+@item @option{-x <pos>} @tab x coordinate of the start of the text
+@item @option{-y <pos>} @tab y coordinate of the start of the text
+@end multitable
+
+Text fonts are being looked for in a FONTPATH environment variable.
+If the FONTPATH environment variable is not available, or is not checked by
+your target (i.e. Cygwin), then specify the full path to the font file as in:
+@example
+-f /usr/X11R6/lib/X11/fonts/TTF/VeraBd.ttf
+@end example
+
+Usage Example:
+@example
+ # Remember to set the path to your fonts
+ FONTPATH="/cygdrive/c/WINDOWS/Fonts/"
+ FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/"
+ FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/"
+ export FONTPATH
+
+ # Time and date display
+ ffmpeg -f video4linux2 -i /dev/video0 \
+ -vhook 'vhook/drawtext.so -f VeraBd.ttf -t %A-%D-%T' movie.mpg
+
+ This example grabs video from the first capture card and outputs it to an
+ MPEG video, and places "Weekday-dd/mm/yy-hh:mm:ss" at the top left of the
+ frame, updated every second, using the Vera Bold TrueType Font, which
+ should exist in: /usr/X11R6/lib/X11/fonts/TTF/
+@end example
+
+Check the man page for strftime() for all the various ways you can format
+the date and time.
+
+@section watermark.c
+
+Command Line options:
+@multitable @columnfractions .2 .8
+@item @option{-m [0|1]} @tab Mode (default: 0, see below)
+@item @option{-t 000000 - FFFFFF} @tab Threshold, six digit hex number
+@item @option{-f <filename>} @tab Watermark image filename, must be specified!
+@end multitable
+
+MODE 0:
+ The watermark picture works like this (assuming color intensities 0..0xFF):
+ Per color do this:
+ If mask color is 0x80, no change to the original frame.
+ If mask color is < 0x80 the absolute difference is subtracted from the
+ frame. If result < 0, result = 0.
+ If mask color is > 0x80 the absolute difference is added to the
+ frame. If result > 0xFF, result = 0xFF.
+
+ You can override the 0x80 level with the -t flag. E.g. if threshold is
+ 000000 the color value of watermark is added to the destination.
+
+ This way a mask that is visible both in light and dark pictures can be made
+ (e.g. by using a picture generated by the Gimp and the bump map tool).
+
+ An example watermark file is at:
+ @url{http://engene.se/ffmpeg_watermark.gif}
+
+MODE 1:
+ Per color do this:
+ If mask color > threshold color then the watermark pixel is used.
+
+Example usage:
+@example
+ ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif' -an out.mov
+ ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif -m 1 -t 222222' -an out.mov
+@end example
+
@bye
diff --git a/contrib/ffmpeg/doc/optimization.txt b/contrib/ffmpeg/doc/optimization.txt
index 26c5ae64c..f66c69bcf 100644
--- a/contrib/ffmpeg/doc/optimization.txt
+++ b/contrib/ffmpeg/doc/optimization.txt
@@ -150,6 +150,15 @@ http://www.agner.org/assem/
AMD Athlon Processor x86 Code Optimization Guide:
http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/22007.pdf
+
+ARM-specific:
+ARM Architecture Reference Manual:
+http://www.arm.com/community/academy/resources.html
+
+Instructions timings and optimization guide for ARM9E:
+http://www.arm.com/pdfs/DDI0222B_9EJS_r1p2.pdf
+
+
GCC asm links:
official doc but quite ugly
http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
diff --git a/contrib/ffmpeg/doc/snow.txt b/contrib/ffmpeg/doc/snow.txt
new file mode 100644
index 000000000..4b8fab75a
--- /dev/null
+++ b/contrib/ffmpeg/doc/snow.txt
@@ -0,0 +1,259 @@
+=============================================
+SNOW Video Codec Specification Draft 20070103
+=============================================
+
+
+Definitions:
+============
+
+MUST the specific part must be done to conform to this standard
+SHOULD it is recommended to be done that way, but not strictly required
+
+ilog2(x) is the rounded down logarithm of x with basis 2
+ilog2(0) = 0
+
+Type definitions:
+=================
+
+b 1-bit range coded
+u unsigned scalar value range coded
+s signed scalar value range coded
+
+
+Bitstream syntax:
+=================
+
+frame:
+ header
+ prediction
+ residual
+
+header:
+ keyframe b MID_STATE
+ if(keyframe || always_reset)
+ reset_contexts
+ if(keyframe){
+ version u header_state
+ always_reset b header_state
+ temporal_decomposition_type u header_state
+ temporal_decomposition_count u header_state
+ spatial_decomposition_count u header_state
+ colorspace_type u header_state
+ chroma_h_shift u header_state
+ chroma_v_shift u header_state
+ spatial_scalability b header_state
+ max_ref_frames-1 u header_state
+ qlogs
+ }
+
+ spatial_decomposition_type s header_state
+ qlog s header_state
+ mv_scale s header_state
+ qbias s header_state
+ block_max_depth s header_state
+
+qlogs:
+ for(plane=0; plane<2; plane++){
+ quant_table[plane][0][0] s header_state
+ for(level=0; level < spatial_decomposition_count; level++){
+ quant_table[plane][level][1]s header_state
+ quant_table[plane][level][3]s header_state
+ }
+ }
+
+reset_contexts
+ *_state[*]= MID_STATE
+
+prediction:
+ for(y=0; y<block_count_vertical; y++)
+ for(x=0; x<block_count_horizontal; x++)
+ block(0)
+
+block(level):
+ if(keyframe){
+ intra=1
+ y_diff=cb_diff=cr_diff=0
+ }else{
+ if(level!=max_block_depth){
+ s_context= 2*left->level + 2*top->level + topleft->level + topright->level
+ leaf b block_state[4 + s_context]
+ }
+ if(level==max_block_depth || leaf){
+ intra b block_state[1 + left->intra + top->intra]
+ if(intra){
+ y_diff s block_state[32]
+ cb_diff s block_state[64]
+ cr_diff s block_state[96]
+ }else{
+ ref_context= ilog2(2*left->ref) + ilog2(2*top->ref)
+ if(ref_frames > 1)
+ ref u block_state[128 + 1024 + 32*ref_context]
+ mx_context= ilog2(2*abs(left->mx - top->mx))
+ my_context= ilog2(2*abs(left->my - top->my))
+ mvx_diff s block_state[128 + 32*(mx_context + 16*!!ref)]
+ mvy_diff s block_state[128 + 32*(my_context + 16*!!ref)]
+ }
+ }else{
+ block(level+1)
+ block(level+1)
+ block(level+1)
+ block(level+1)
+ }
+ }
+
+
+residual:
+ FIXME
+
+
+
+Tag description:
+----------------
+
+version
+ 0
+ this MUST NOT change within a bitstream
+
+always_reset
+ if 1 then the range coder contexts will be reset after each frame
+
+temporal_decomposition_type
+ 0
+
+temporal_decomposition_count
+ 0
+
+spatial_decomposition_count
+ FIXME
+
+colorspace_type
+ 0
+ this MUST NOT change within a bitstream
+
+chroma_h_shift
+ log2(luma.width / chroma.width)
+ this MUST NOT change within a bitstream
+
+chroma_v_shift
+ log2(luma.height / chroma.height)
+ this MUST NOT change within a bitstream
+
+spatial_scalability
+ 0
+
+max_ref_frames
+ maximum number of reference frames
+ this MUST NOT change within a bitstream
+
+ref_frames
+ minimum of the number of available reference frames and max_ref_frames
+ for example the first frame after a key frame always has ref_frames=1
+
+spatial_decomposition_type
+ wavelet type
+ 0 is a 9/7 symmetric compact integer wavelet
+ 1 is a 5/3 symmetric compact integer wavelet
+ others are reserved
+ stored as delta from last, last is reset to 0 if always_reset || keyframe
+
+qlog
+ quality (logarthmic quantizer scale)
+ stored as delta from last, last is reset to 0 if always_reset || keyframe
+
+mv_scale
+ stored as delta from last, last is reset to 0 if always_reset || keyframe
+ FIXME check that everything works fine if this changes between frames
+
+qbias
+ dequantization bias
+ stored as delta from last, last is reset to 0 if always_reset || keyframe
+
+block_max_depth
+ maximum depth of the block tree
+ stored as delta from last, last is reset to 0 if always_reset || keyframe
+
+quant_table
+ quantiztation table
+
+Range Coder:
+============
+FIXME
+
+Neighboring Blocks:
+===================
+left and top are set to the respective blocks unless they are outside of
+the image in which case they are set to the Null block
+
+top-left is set to the top left block unless its outside of the image in
+which case it is set to the left block
+
+if this block has no larger parent block or its at the left side of its
+parent block and the top right block is not outside of the image then the
+top right block is used for top-right else the top-left block is used
+
+Null block
+y,cb,cr are 128
+level, ref, mx and my are 0
+
+
+Motion Vector Prediction:
+=========================
+1. the motion vectors of all the neighboring blocks are scaled to
+compensate for the difference of reference frames
+
+scaled_mv= (mv * (256 * (current_reference+1) / (mv.reference+1)) + 128)>>8
+
+2. the median of the scaled left, top and top-right vectors is used as
+motion vector prediction
+
+3. the used motion vector is the sum of the predictor and
+ (mvx_diff, mvy_diff)*mv_scale
+
+
+Intra DC Predicton:
+======================
+the luma and chroma values of the left block are used as predictors
+
+the used luma and chroma is the sum of the predictor and y_diff, cb_diff, cr_diff
+
+
+Motion Compensation:
+====================
+FIXME
+
+LL band prediction:
+===================
+FIXME
+
+Dequantizaton:
+==============
+FIXME
+
+Wavelet Transform:
+==================
+FIXME
+
+TODO:
+=====
+Important:
+finetune initial contexts
+spatial_decomposition_count per frame?
+flip wavelet?
+try to use the wavelet transformed predicted image (motion compensated image) as context for coding the residual coefficients
+try the MV length as context for coding the residual coefficients
+use extradata for stuff which is in the keyframes now?
+the MV median predictor is patented IIRC
+
+Not Important:
+spatial_scalability b vs u (!= 0 breaks syntax anyway so we can add a u later)
+
+
+Credits:
+========
+Michael Niedermayer
+Loren Merritt
+
+
+Copyright:
+==========
+GPL + GFDL + whatever is needed to make this a RFC
diff --git a/contrib/ffmpeg/ffmpeg.c b/contrib/ffmpeg/ffmpeg.c
index ab0b689a6..c9bac5de6 100644
--- a/contrib/ffmpeg/ffmpeg.c
+++ b/contrib/ffmpeg/ffmpeg.c
@@ -24,7 +24,6 @@
#include "avformat.h"
#include "swscale.h"
#include "framehook.h"
-#include "dsputil.h"
#include "opt.h"
#include "fifo.h"
@@ -56,6 +55,8 @@
#define INFINITY HUGE_VAL
#endif
+#undef exit
+
/* select an input stream for an output stream */
typedef struct AVStreamMap {
int file_index;
@@ -127,7 +128,6 @@ static int video_codec_id = CODEC_ID_NONE;
static int video_codec_tag = 0;
static int same_quality = 0;
static int do_deinterlace = 0;
-static int packet_size = 0;
static int strict = 0;
static int top_field_first = -1;
static int me_threshold = 0;
@@ -138,7 +138,6 @@ static int qp_hist = 0;
static int intra_only = 0;
static int audio_sample_rate = 44100;
-static int audio_bit_rate = 64000;
#define QSCALE_NONE -99999
static float audio_qscale = QSCALE_NONE;
static int audio_disable = 0;
@@ -181,22 +180,9 @@ static int video_global_header = 0;
static int rate_emu = 0;
-#ifdef CONFIG_BKTR
-static const char *video_grab_format = "bktr";
-#else
-#ifdef CONFIG_VIDEO4LINUX2
-static const char *video_grab_format = "video4linux2";
-#else
-static const char *video_grab_format = "video4linux";
-#endif
-#endif
-static char *video_device = NULL;
-static char *grab_device = NULL;
static int video_channel = 0;
static char *video_standard = "ntsc";
-static const char *audio_grab_format = "audio_device";
-static char *audio_device = NULL;
static int audio_volume = 256;
static int using_stdin = 0;
@@ -210,7 +196,7 @@ static int64_t extra_size = 0;
static int nb_frames_dup = 0;
static int nb_frames_drop = 0;
static int input_sync;
-static int limit_filesize = 0; //
+static uint64_t limit_filesize = 0; //
static int pgmyuv_compatibility_hack=0;
static int dts_delta_threshold = 10;
@@ -219,8 +205,9 @@ static int sws_flags = SWS_BICUBIC;
const char **opt_names=NULL;
int opt_name_count=0;
-AVCodecContext *avctx_opts;
+AVCodecContext *avctx_opts[CODEC_TYPE_NB];
AVFormatContext *avformat_opts;
+static int64_t timer_start = 0;
static AVBitStreamFilterContext *video_bitstream_filters=NULL;
static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
@@ -285,8 +272,6 @@ typedef struct AVInputFile {
int eof_reached; /* true if eof reached */
int ist_index; /* index of first stream in ist_table */
int buffer_size; /* current total buffer size */
- int buffer_size_max; /* buffer size at which we consider we can stop
- buffering */
int nb_streams; /* nb streams we are aware of */
} AVInputFile;
@@ -488,7 +473,7 @@ static void do_audio_out(AVFormatContext *s,
fprintf(stderr, "adding %d audio samples of silence\n", (int)delta);
}
}else if(audio_sync_method>1){
- int comp= clip(delta, -audio_sync_method, audio_sync_method);
+ int comp= av_clip(delta, -audio_sync_method, audio_sync_method);
assert(ost->audio_resample);
if(verbose > 2)
fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate);
@@ -610,13 +595,14 @@ static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void
picture2 = picture;
}
} else {
- img_copy(picture2, picture, dec->pix_fmt, dec->width, dec->height);
+ av_picture_copy(picture2, picture, dec->pix_fmt, dec->width, dec->height);
}
} else {
picture2 = picture;
}
- frame_hook_process(picture2, dec->pix_fmt, dec->width, dec->height);
+ frame_hook_process(picture2, dec->pix_fmt, dec->width, dec->height,
+ 1000000 * ist->pts / AV_TIME_BASE);
if (picture != picture2)
*picture = *picture2;
@@ -690,7 +676,6 @@ static void do_video_out(AVFormatContext *s,
int nb_frames, i, ret;
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
- uint8_t *buf = NULL, *buf1 = NULL;
AVCodecContext *enc, *dec;
avcodec_get_frame_defaults(&picture_crop_temp);
@@ -730,9 +715,9 @@ static void do_video_out(AVFormatContext *s,
return;
if (ost->video_crop) {
- if (img_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
+ if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
- goto the_end;
+ return;
}
formatted_picture = &picture_crop_temp;
} else {
@@ -745,9 +730,9 @@ static void do_video_out(AVFormatContext *s,
if (ost->video_pad) {
final_picture = &ost->pict_tmp;
if (ost->video_resample) {
- if (img_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
+ if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
av_log(NULL, AV_LOG_ERROR, "error padding picture\n");
- goto the_end;
+ return;
}
resampling_dst = &picture_pad_temp;
}
@@ -761,7 +746,7 @@ static void do_video_out(AVFormatContext *s,
}
if (ost->video_pad) {
- img_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
+ av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
enc->height, enc->width, enc->pix_fmt,
ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
}
@@ -794,7 +779,7 @@ static void do_video_out(AVFormatContext *s,
/* better than nothing: use input picture interlaced
settings */
big_picture.interlaced_frame = in_picture->interlaced_frame;
- if(avctx_opts->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
+ if(avctx_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){
if(top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
@@ -846,9 +831,6 @@ static void do_video_out(AVFormatContext *s,
ost->sync_opts++;
ost->frame_number++;
}
- the_end:
- av_free(buf);
- av_free(buf1);
}
static double psnr(double d){
@@ -881,7 +863,7 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
}
}
- ti = MAXINT64;
+ ti = INT64_MAX;
enc = ost->st->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO) {
frame_number = ost->frame_number;
@@ -947,9 +929,12 @@ static void print_report(AVFormatContext **output_files,
enc->coded_frame->quality/(float)FF_QP2LAMBDA);
}
if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
+ float t = (av_gettime()-timer_start) / 1000000.0;
+
frame_number = ost->frame_number;
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d q=%3.1f ",
- frame_number, enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
+ frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
+ enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist && enc->coded_frame){
@@ -1065,10 +1050,11 @@ static int output_packet(AVInputStream *ist, int ist_index,
switch(ist->st->codec->codec_type) {
case CODEC_TYPE_AUDIO:{
if(pkt)
- samples= av_fast_realloc(samples, &samples_size, FFMAX(pkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE));
+ samples= av_fast_realloc(samples, &samples_size, FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE));
+ data_size= samples_size;
/* XXX: could avoid copy if PCM 16 bits with same
endianness as CPU */
- ret = avcodec_decode_audio(ist->st->codec, samples, &data_size,
+ ret = avcodec_decode_audio2(ist->st->codec, samples, &data_size,
ptr, len);
if (ret < 0)
goto fail_decode;
@@ -1120,165 +1106,165 @@ static int output_packet(AVInputStream *ist, int ist_index,
goto fail_decode;
}
} else {
- switch(ist->st->codec->codec_type) {
- case CODEC_TYPE_AUDIO:
- ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
- (ist->st->codec->sample_rate * ist->st->codec->channels);
- break;
- case CODEC_TYPE_VIDEO:
- if (ist->st->codec->time_base.num != 0) {
- ist->next_pts += ((int64_t)AV_TIME_BASE *
- ist->st->codec->time_base.num) /
- ist->st->codec->time_base.den;
- }
- break;
+ switch(ist->st->codec->codec_type) {
+ case CODEC_TYPE_AUDIO:
+ ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
+ (ist->st->codec->sample_rate * ist->st->codec->channels);
+ break;
+ case CODEC_TYPE_VIDEO:
+ if (ist->st->codec->time_base.num != 0) {
+ ist->next_pts += ((int64_t)AV_TIME_BASE *
+ ist->st->codec->time_base.num) /
+ ist->st->codec->time_base.den;
}
- data_buf = ptr;
- data_size = len;
- ret = len;
- len = 0;
- }
-
- buffer_to_free = NULL;
- if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
- pre_process_video_frame(ist, (AVPicture *)&picture,
- &buffer_to_free);
+ break;
}
-
- // preprocess audio (volume)
- if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) {
- if (audio_volume != 256) {
- short *volp;
- volp = samples;
- for(i=0;i<(data_size / sizeof(short));i++) {
- int v = ((*volp) * audio_volume + 128) >> 8;
- if (v < -32768) v = -32768;
- if (v > 32767) v = 32767;
- *volp++ = v;
- }
+ data_buf = ptr;
+ data_size = len;
+ ret = len;
+ len = 0;
+ }
+
+ buffer_to_free = NULL;
+ if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
+ pre_process_video_frame(ist, (AVPicture *)&picture,
+ &buffer_to_free);
+ }
+
+ // preprocess audio (volume)
+ if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) {
+ if (audio_volume != 256) {
+ short *volp;
+ volp = samples;
+ for(i=0;i<(data_size / sizeof(short));i++) {
+ int v = ((*volp) * audio_volume + 128) >> 8;
+ if (v < -32768) v = -32768;
+ if (v > 32767) v = 32767;
+ *volp++ = v;
}
}
+ }
- /* frame rate emulation */
- if (ist->st->codec->rate_emu) {
- int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den);
- int64_t now = av_gettime() - ist->start;
- if (pts > now)
- usleep(pts - now);
+ /* frame rate emulation */
+ if (ist->st->codec->rate_emu) {
+ int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den);
+ int64_t now = av_gettime() - ist->start;
+ if (pts > now)
+ usleep(pts - now);
- ist->frame++;
- }
+ ist->frame++;
+ }
#if 0
- /* mpeg PTS deordering : if it is a P or I frame, the PTS
- is the one of the next displayed one */
- /* XXX: add mpeg4 too ? */
- if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
- if (ist->st->codec->pict_type != B_TYPE) {
- int64_t tmp;
- tmp = ist->last_ip_pts;
- ist->last_ip_pts = ist->frac_pts.val;
- ist->frac_pts.val = tmp;
- }
+ /* mpeg PTS deordering : if it is a P or I frame, the PTS
+ is the one of the next displayed one */
+ /* XXX: add mpeg4 too ? */
+ if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
+ if (ist->st->codec->pict_type != B_TYPE) {
+ int64_t tmp;
+ tmp = ist->last_ip_pts;
+ ist->last_ip_pts = ist->frac_pts.val;
+ ist->frac_pts.val = tmp;
}
+ }
#endif
- /* if output time reached then transcode raw format,
- encode packets and output them */
- if (start_time == 0 || ist->pts >= start_time)
- for(i=0;i<nb_ostreams;i++) {
- int frame_size;
+ /* if output time reached then transcode raw format,
+ encode packets and output them */
+ if (start_time == 0 || ist->pts >= start_time)
+ for(i=0;i<nb_ostreams;i++) {
+ int frame_size;
- ost = ost_table[i];
- if (ost->source_index == ist_index) {
- os = output_files[ost->file_index];
+ ost = ost_table[i];
+ if (ost->source_index == ist_index) {
+ os = output_files[ost->file_index];
#if 0
- printf("%d: got pts=%0.3f %0.3f\n", i,
- (double)pkt->pts / AV_TIME_BASE,
- ((double)ist->pts / AV_TIME_BASE) -
- ((double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den));
+ printf("%d: got pts=%0.3f %0.3f\n", i,
+ (double)pkt->pts / AV_TIME_BASE,
+ ((double)ist->pts / AV_TIME_BASE) -
+ ((double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den));
#endif
- /* set the input output pts pairs */
- //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
-
- if (ost->encoding_needed) {
- switch(ost->st->codec->codec_type) {
- case CODEC_TYPE_AUDIO:
- do_audio_out(os, ost, ist, data_buf, data_size);
- break;
- case CODEC_TYPE_VIDEO:
- do_video_out(os, ost, ist, &picture, &frame_size);
- video_size += frame_size;
- if (do_vstats && frame_size)
- do_video_stats(os, ost, frame_size);
- break;
- case CODEC_TYPE_SUBTITLE:
- do_subtitle_out(os, ost, ist, &subtitle,
- pkt->pts);
- break;
- default:
- av_abort();
- }
- } else {
- AVFrame avframe; //FIXME/XXX remove this
- AVPacket opkt;
- av_init_packet(&opkt);
-
- /* no reencoding needed : output the packet directly */
- /* force the input stream PTS */
-
- avcodec_get_frame_defaults(&avframe);
- ost->st->codec->coded_frame= &avframe;
- avframe.key_frame = pkt->flags & PKT_FLAG_KEY;
-
- if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO)
- audio_size += data_size;
- else if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO) {
- video_size += data_size;
- ost->sync_opts++;
- }
+ /* set the input output pts pairs */
+ //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
- opkt.stream_index= ost->index;
- if(pkt->pts != AV_NOPTS_VALUE)
- opkt.pts= av_rescale_q(av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q) + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
- else
- opkt.pts= AV_NOPTS_VALUE;
-
- {
- int64_t dts;
- if (pkt->dts == AV_NOPTS_VALUE)
- dts = ist->next_pts;
- else
- dts= av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
- opkt.dts= av_rescale_q(dts + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
- }
- opkt.flags= pkt->flags;
+ if (ost->encoding_needed) {
+ switch(ost->st->codec->codec_type) {
+ case CODEC_TYPE_AUDIO:
+ do_audio_out(os, ost, ist, data_buf, data_size);
+ break;
+ case CODEC_TYPE_VIDEO:
+ do_video_out(os, ost, ist, &picture, &frame_size);
+ video_size += frame_size;
+ if (do_vstats && frame_size)
+ do_video_stats(os, ost, frame_size);
+ break;
+ case CODEC_TYPE_SUBTITLE:
+ do_subtitle_out(os, ost, ist, &subtitle,
+ pkt->pts);
+ break;
+ default:
+ av_abort();
+ }
+ } else {
+ AVFrame avframe; //FIXME/XXX remove this
+ AVPacket opkt;
+ av_init_packet(&opkt);
+
+ /* no reencoding needed : output the packet directly */
+ /* force the input stream PTS */
+
+ avcodec_get_frame_defaults(&avframe);
+ ost->st->codec->coded_frame= &avframe;
+ avframe.key_frame = pkt->flags & PKT_FLAG_KEY;
+
+ if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO)
+ audio_size += data_size;
+ else if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO) {
+ video_size += data_size;
+ ost->sync_opts++;
+ }
- //FIXME remove the following 2 lines they shall be replaced by the bitstream filters
- if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY))
- opkt.destruct= av_destruct_packet;
+ opkt.stream_index= ost->index;
+ if(pkt->pts != AV_NOPTS_VALUE)
+ opkt.pts= av_rescale_q(av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q) + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
+ else
+ opkt.pts= AV_NOPTS_VALUE;
- write_frame(os, &opkt, ost->st->codec, bitstream_filters[ost->file_index][pkt->stream_index]);
- ost->st->codec->frame_number++;
- ost->frame_number++;
- av_free_packet(&opkt);
+ {
+ int64_t dts;
+ if (pkt->dts == AV_NOPTS_VALUE)
+ dts = ist->next_pts;
+ else
+ dts= av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
+ opkt.dts= av_rescale_q(dts + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
}
+ opkt.flags= pkt->flags;
+
+ //FIXME remove the following 2 lines they shall be replaced by the bitstream filters
+ if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY))
+ opkt.destruct= av_destruct_packet;
+
+ write_frame(os, &opkt, ost->st->codec, bitstream_filters[ost->file_index][pkt->stream_index]);
+ ost->st->codec->frame_number++;
+ ost->frame_number++;
+ av_free_packet(&opkt);
}
}
- av_free(buffer_to_free);
- /* XXX: allocate the subtitles in the codec ? */
- if (subtitle_to_free) {
- if (subtitle_to_free->rects != NULL) {
- for (i = 0; i < subtitle_to_free->num_rects; i++) {
- av_free(subtitle_to_free->rects[i].bitmap);
- av_free(subtitle_to_free->rects[i].rgba_palette);
- }
- av_freep(&subtitle_to_free->rects);
+ }
+ av_free(buffer_to_free);
+ /* XXX: allocate the subtitles in the codec ? */
+ if (subtitle_to_free) {
+ if (subtitle_to_free->rects != NULL) {
+ for (i = 0; i < subtitle_to_free->num_rects; i++) {
+ av_free(subtitle_to_free->rects[i].bitmap);
+ av_free(subtitle_to_free->rects[i].rgba_palette);
}
- subtitle_to_free->num_rects = 0;
- subtitle_to_free = NULL;
+ av_freep(&subtitle_to_free->rects);
}
+ subtitle_to_free->num_rects = 0;
+ subtitle_to_free = NULL;
}
+ }
discard_packet:
if (pkt == NULL) {
/* EOF handling */
@@ -1367,7 +1353,6 @@ static int av_encode(AVFormatContext **output_files,
AVOutputStream *ost, **ost_table = NULL;
AVInputStream *ist, **ist_table = NULL;
AVInputFile *file_table;
- AVFormatContext *stream_no_data;
int key;
file_table= (AVInputFile*) av_mallocz(nb_input_files * sizeof(AVInputFile));
@@ -1542,6 +1527,10 @@ static int av_encode(AVFormatContext **output_files,
codec->block_align= icodec->block_align;
break;
case CODEC_TYPE_VIDEO:
+ if(using_vhook) {
+ fprintf(stderr,"-vcodec copy and -vhook are incompatible (frames are not decoded)\n");
+ exit(1);
+ }
codec->pix_fmt = icodec->pix_fmt;
codec->width = icodec->width;
codec->height = icodec->height;
@@ -1621,9 +1610,10 @@ static int av_encode(AVFormatContext **output_files,
if (ost->video_resample) {
avcodec_get_frame_defaults(&ost->pict_tmp);
if( avpicture_alloc( (AVPicture*)&ost->pict_tmp, codec->pix_fmt,
- codec->width, codec->height ) )
- goto fail;
-
+ codec->width, codec->height ) ) {
+ fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n");
+ exit(1);
+ }
ost->img_resample_ctx = sws_getContext(
icodec->width - (frame_leftBand + frame_rightBand),
icodec->height - (frame_topBand + frame_bottomBand),
@@ -1778,11 +1768,6 @@ static int av_encode(AVFormatContext **output_files,
ist->is_start = 1;
}
- /* compute buffer size max (should use a complete heuristic) */
- for(i=0;i<nb_input_files;i++) {
- file_table[i].buffer_size_max = 2048;
- }
-
/* set meta data information from input file if required */
for (i=0;i<nb_meta_data_maps;i++) {
AVFormatContext *out_file;
@@ -1792,12 +1777,12 @@ static int av_encode(AVFormatContext **output_files,
int in_file_index = meta_data_maps[i].in_file;
if ( out_file_index < 0 || out_file_index >= nb_output_files ) {
fprintf(stderr, "Invalid output file index %d map_meta_data(%d,%d)\n", out_file_index, out_file_index, in_file_index);
- ret = -EINVAL;
+ ret = AVERROR(EINVAL);
goto fail;
}
if ( in_file_index < 0 || in_file_index >= nb_input_files ) {
fprintf(stderr, "Invalid input file index %d map_meta_data(%d,%d)\n", in_file_index, out_file_index, in_file_index);
- ret = -EINVAL;
+ ret = AVERROR(EINVAL);
goto fail;
}
@@ -1819,7 +1804,7 @@ static int av_encode(AVFormatContext **output_files,
os = output_files[i];
if (av_write_header(os) < 0) {
fprintf(stderr, "Could not write header for output file #%d (incorrect codec parameters ?)\n", i);
- ret = -EINVAL;
+ ret = AVERROR(EINVAL);
goto fail;
}
}
@@ -1830,8 +1815,8 @@ static int av_encode(AVFormatContext **output_files,
}
term_init();
- stream_no_data = 0;
key = -1;
+ timer_start = av_gettime();
for(; received_sigterm == 0;) {
int file_index, ist_index;
@@ -1890,7 +1875,7 @@ static int av_encode(AVFormatContext **output_files,
break;
/* finish if limit size exhausted */
- if (limit_filesize != 0 && (limit_filesize * 1024) < url_ftell(&output_files[0]->pb))
+ if (limit_filesize != 0 && limit_filesize < url_ftell(&output_files[0]->pb))
break;
/* read a frame from it and output it in the fifo */
@@ -1900,13 +1885,8 @@ static int av_encode(AVFormatContext **output_files,
if (opt_shortest) break; else continue; //
}
- if (!pkt.size) {
- stream_no_data = is;
- } else {
- stream_no_data = 0;
- }
if (do_pkt_dump) {
- av_pkt_dump(stdout, &pkt, do_hex_dump);
+ av_pkt_dump_log(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump);
}
/* the following test is needed in case new streams appear
dynamically in stream : we ignore them */
@@ -2022,7 +2002,7 @@ static int av_encode(AVFormatContext **output_files,
}
return ret;
fail:
- ret = -ENOMEM;
+ ret = AVERROR(ENOMEM);
goto fail1;
}
@@ -2055,6 +2035,7 @@ static void opt_format(const char *arg)
pgmyuv_compatibility_hack=1;
// opt_image_format(arg);
arg = "image2";
+ fprintf(stderr, "pgmyuv format is deprecated, use image2\n");
}
file_iformat = av_find_input_format(arg);
@@ -2083,7 +2064,7 @@ static void opt_me_threshold(const char *arg)
static void opt_verbose(const char *arg)
{
verbose = atoi(arg);
- av_log_set_level(atoi(arg));
+ av_log_level = atoi(arg);
}
static void opt_frame_rate(const char *arg)
@@ -2313,11 +2294,6 @@ static void opt_qdiff(const char *arg)
}
}
-static void opt_packet_size(const char *arg)
-{
- packet_size= atoi(arg);
-}
-
static void opt_strict(const char *arg)
{
strict= atoi(arg);
@@ -2337,11 +2313,6 @@ static void opt_thread_count(const char *arg)
#endif
}
-static void opt_audio_bitrate(const char *arg)
-{
- audio_bit_rate = atoi(arg) * 1000;
-}
-
static void opt_audio_rate(const char *arg)
{
audio_sample_rate = atoi(arg);
@@ -2352,16 +2323,6 @@ static void opt_audio_channels(const char *arg)
audio_channels = atoi(arg);
}
-static void opt_video_device(const char *arg)
-{
- video_device = av_strdup(arg);
-}
-
-static void opt_grab_device(const char *arg)
-{
- grab_device = av_strdup(arg);
-}
-
static void opt_video_channel(const char *arg)
{
video_channel = strtol(arg, NULL, 0);
@@ -2372,11 +2333,6 @@ static void opt_video_standard(const char *arg)
video_standard = av_strdup(arg);
}
-static void opt_audio_device(const char *arg)
-{
- audio_device = av_strdup(arg);
-}
-
static void opt_codec(int *pstream_copy, int *pcodec_id,
int codec_type, const char *arg)
{
@@ -2568,7 +2524,6 @@ static void opt_input_file(const char *filename)
ap->width = frame_width + frame_padleft + frame_padright;
ap->height = frame_height + frame_padtop + frame_padbottom;
ap->pix_fmt = frame_pix_fmt;
- ap->device = grab_device;
ap->channel = video_channel;
ap->standard = video_standard;
ap->video_codec_id = video_codec_id;
@@ -2577,7 +2532,7 @@ static void opt_input_file(const char *filename)
ap->video_codec_id= CODEC_ID_PGMYUV;
for(i=0; i<opt_name_count; i++){
- AVOption *opt;
+ const AVOption *opt;
double d= av_get_double(avformat_opts, opt_names[i], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_DECODING_PARAM))
av_set_double(ic, opt_names[i], d);
@@ -2619,16 +2574,14 @@ static void opt_input_file(const char *filename)
for(i=0;i<ic->nb_streams;i++) {
int j;
AVCodecContext *enc = ic->streams[i]->codec;
-#if defined(HAVE_THREADS)
if(thread_count>1)
avcodec_thread_init(enc, thread_count);
-#endif
enc->thread_count= thread_count;
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
for(j=0; j<opt_name_count; j++){
- AVOption *opt;
- double d= av_get_double(avctx_opts, opt_names[j], &opt);
+ const AVOption *opt;
+ double d= av_get_double(avctx_opts[CODEC_TYPE_AUDIO], opt_names[j], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_AUDIO_PARAM) && (opt->flags&AV_OPT_FLAG_DECODING_PARAM))
av_set_double(enc, opt_names[j], d);
}
@@ -2640,8 +2593,8 @@ static void opt_input_file(const char *filename)
break;
case CODEC_TYPE_VIDEO:
for(j=0; j<opt_name_count; j++){
- AVOption *opt;
- double d= av_get_double(avctx_opts, opt_names[j], &opt);
+ const AVOption *opt;
+ double d= av_get_double(avctx_opts[CODEC_TYPE_VIDEO], opt_names[j], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_VIDEO_PARAM) && (opt->flags&AV_OPT_FLAG_DECODING_PARAM))
av_set_double(enc, opt_names[j], d);
}
@@ -2658,7 +2611,7 @@ static void opt_input_file(const char *filename)
if (enc->time_base.den != rfps || enc->time_base.num != rfps_base) {
if (verbose >= 0)
- fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
+ fprintf(stderr,"\nSeems stream %d codec frame rate differs from container frame rate: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",
i, (float)enc->time_base.den / enc->time_base.num, enc->time_base.den, enc->time_base.num,
(float)rfps / rfps_base, rfps, rfps_base);
@@ -2694,18 +2647,11 @@ static void opt_input_file(const char *filename)
file_iformat = NULL;
file_oformat = NULL;
- grab_device = NULL;
video_channel = 0;
rate_emu = 0;
}
-static void opt_grab(const char *arg)
-{
- file_iformat = av_find_input_format(arg);
- opt_input_file("");
-}
-
static void check_audio_video_inputs(int *has_video_ptr, int *has_audio_ptr)
{
int has_video, has_audio, i, j;
@@ -2748,13 +2694,12 @@ static void new_video_stream(AVFormatContext *oc)
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
+ avcodec_get_context_defaults2(st->codec, CODEC_TYPE_VIDEO);
bitstream_filters[nb_output_files][oc->nb_streams - 1]= video_bitstream_filters;
video_bitstream_filters= NULL;
-#if defined(HAVE_THREADS)
if(thread_count>1)
avcodec_thread_init(st->codec, thread_count);
-#endif
video_enc = st->codec;
@@ -2764,11 +2709,11 @@ static void new_video_stream(AVFormatContext *oc)
if( (video_global_header&1)
|| (video_global_header==0 && (oc->oformat->flags & AVFMT_GLOBALHEADER))){
video_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
- avctx_opts->flags|= CODEC_FLAG_GLOBAL_HEADER;
+ avctx_opts[CODEC_TYPE_VIDEO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
}
if(video_global_header&2){
video_enc->flags2 |= CODEC_FLAG2_LOCAL_HEADER;
- avctx_opts->flags2|= CODEC_FLAG2_LOCAL_HEADER;
+ avctx_opts[CODEC_TYPE_VIDEO]->flags2|= CODEC_FLAG2_LOCAL_HEADER;
}
if (video_stream_copy) {
@@ -2787,8 +2732,8 @@ static void new_video_stream(AVFormatContext *oc)
codec = avcodec_find_encoder(codec_id);
for(i=0; i<opt_name_count; i++){
- AVOption *opt;
- double d= av_get_double(avctx_opts, opt_names[i], &opt);
+ const AVOption *opt;
+ double d= av_get_double(avctx_opts[CODEC_TYPE_VIDEO], opt_names[i], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_VIDEO_PARAM) && (opt->flags&AV_OPT_FLAG_ENCODING_PARAM))
av_set_double(video_enc, opt_names[i], d);
}
@@ -2868,16 +2813,12 @@ static void new_video_stream(AVFormatContext *oc)
if(p) p++;
}
video_enc->rc_override_count=i;
- video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4;
+ if (!video_enc->rc_initial_buffer_occupancy)
+ video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size*3/4;
video_enc->me_threshold= me_threshold;
video_enc->intra_dc_precision= intra_dc_precision - 8;
video_enc->strict_std_compliance = strict;
- if(packet_size){
- video_enc->rtp_mode= 1;
- video_enc->rtp_payload_size= packet_size;
- }
-
if (do_psnr)
video_enc->flags|= CODEC_FLAG_PSNR;
@@ -2910,14 +2851,13 @@ static void new_audio_stream(AVFormatContext *oc)
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
+ avcodec_get_context_defaults2(st->codec, CODEC_TYPE_AUDIO);
bitstream_filters[nb_output_files][oc->nb_streams - 1]= audio_bitstream_filters;
audio_bitstream_filters= NULL;
-#if defined(HAVE_THREADS)
if(thread_count>1)
avcodec_thread_init(st->codec, thread_count);
-#endif
audio_enc = st->codec;
audio_enc->codec_type = CODEC_TYPE_AUDIO;
@@ -2928,7 +2868,7 @@ static void new_audio_stream(AVFormatContext *oc)
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
- avctx_opts->flags|= CODEC_FLAG_GLOBAL_HEADER;
+ avctx_opts[CODEC_TYPE_AUDIO]->flags|= CODEC_FLAG_GLOBAL_HEADER;
}
if (audio_stream_copy) {
st->stream_copy = 1;
@@ -2937,8 +2877,8 @@ static void new_audio_stream(AVFormatContext *oc)
codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, CODEC_TYPE_AUDIO);
for(i=0; i<opt_name_count; i++){
- AVOption *opt;
- double d= av_get_double(avctx_opts, opt_names[i], &opt);
+ const AVOption *opt;
+ double d= av_get_double(avctx_opts[CODEC_TYPE_AUDIO], opt_names[i], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_AUDIO_PARAM) && (opt->flags&AV_OPT_FLAG_ENCODING_PARAM))
av_set_double(audio_enc, opt_names[i], d);
}
@@ -2947,19 +2887,12 @@ static void new_audio_stream(AVFormatContext *oc)
codec_id = audio_codec_id;
audio_enc->codec_id = codec_id;
- audio_enc->bit_rate = audio_bit_rate;
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
}
audio_enc->thread_count = thread_count;
- /* For audio codecs other than AC3 or DTS we limit */
- /* the number of coded channels to stereo */
- if (audio_channels > 2 && codec_id != CODEC_ID_AC3
- && codec_id != CODEC_ID_DTS) {
- audio_enc->channels = 2;
- } else
- audio_enc->channels = audio_channels;
+ audio_enc->channels = audio_channels;
}
audio_enc->sample_rate = audio_sample_rate;
audio_enc->time_base= (AVRational){1, audio_sample_rate};
@@ -2993,6 +2926,7 @@ static void opt_new_subtitle_stream(void)
fprintf(stderr, "Could not alloc stream\n");
exit(1);
}
+ avcodec_get_context_defaults2(st->codec, CODEC_TYPE_SUBTITLE);
subtitle_enc = st->codec;
subtitle_enc->codec_type = CODEC_TYPE_SUBTITLE;
@@ -3000,8 +2934,8 @@ static void opt_new_subtitle_stream(void)
st->stream_copy = 1;
} else {
for(i=0; i<opt_name_count; i++){
- AVOption *opt;
- double d= av_get_double(avctx_opts, opt_names[i], &opt);
+ const AVOption *opt;
+ double d= av_get_double(avctx_opts[CODEC_TYPE_SUBTITLE], opt_names[i], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_SUBTITLE_PARAM) && (opt->flags&AV_OPT_FLAG_ENCODING_PARAM))
av_set_double(subtitle_enc, opt_names[i], d);
}
@@ -3168,7 +3102,7 @@ static void opt_output_file(const char *filename)
oc->loop_output = loop_output;
for(i=0; i<opt_name_count; i++){
- AVOption *opt;
+ const AVOption *opt;
double d = av_get_double(avformat_opts, opt_names[i], &opt);
if(d==d && (opt->flags&AV_OPT_FLAG_ENCODING_PARAM))
av_set_double(oc, opt_names[i], d);
@@ -3179,103 +3113,6 @@ static void opt_output_file(const char *filename)
file_iformat = NULL;
}
-/* prepare dummy protocols for grab */
-static void prepare_grab(void)
-{
- int has_video, has_audio, i, j;
- AVFormatContext *oc;
- AVFormatContext *ic;
- AVFormatParameters vp1, *vp = &vp1;
- AVFormatParameters ap1, *ap = &ap1;
-
- /* see if audio/video inputs are needed */
- has_video = 0;
- has_audio = 0;
- memset(ap, 0, sizeof(*ap));
- memset(vp, 0, sizeof(*vp));
- vp->time_base.num= 1;
- for(j=0;j<nb_output_files;j++) {
- oc = output_files[j];
- for(i=0;i<oc->nb_streams;i++) {
- AVCodecContext *enc = oc->streams[i]->codec;
- switch(enc->codec_type) {
- case CODEC_TYPE_AUDIO:
- if (enc->sample_rate > ap->sample_rate)
- ap->sample_rate = enc->sample_rate;
- if (enc->channels > ap->channels)
- ap->channels = enc->channels;
- has_audio = 1;
- break;
- case CODEC_TYPE_VIDEO:
- if (enc->width > vp->width)
- vp->width = enc->width;
- if (enc->height > vp->height)
- vp->height = enc->height;
-
- if (vp->time_base.num*(int64_t)enc->time_base.den > enc->time_base.num*(int64_t)vp->time_base.den){
- vp->time_base = enc->time_base;
- vp->width += frame_leftBand + frame_rightBand;
- vp->width -= (frame_padleft + frame_padright);
- vp->height += frame_topBand + frame_bottomBand;
- vp->height -= (frame_padtop + frame_padbottom);
- }
- has_video = 1;
- break;
- default:
- av_abort();
- }
- }
- }
-
- if (has_video == 0 && has_audio == 0) {
- fprintf(stderr, "Output file must have at least one audio or video stream\n");
- exit(1);
- }
-
- if (has_video) {
- AVInputFormat *fmt1;
- fmt1 = av_find_input_format(video_grab_format);
- vp->device = video_device;
- vp->channel = video_channel;
- vp->standard = video_standard;
- vp->pix_fmt = frame_pix_fmt;
- if (av_open_input_file(&ic, "", fmt1, 0, vp) < 0) {
- fprintf(stderr, "Could not find video grab device\n");
- exit(1);
- }
- /* If not enough info to get the stream parameters, we decode the
- first frames to get it. */
- if ((ic->ctx_flags & AVFMTCTX_NOHEADER) && av_find_stream_info(ic) < 0) {
- fprintf(stderr, "Could not find video grab parameters\n");
- exit(1);
- }
- /* by now video grab has one stream */
- ic->streams[0]->r_frame_rate.num = vp->time_base.den;
- ic->streams[0]->r_frame_rate.den = vp->time_base.num;
- input_files[nb_input_files] = ic;
-
- if (verbose >= 0)
- dump_format(ic, nb_input_files, "", 0);
-
- nb_input_files++;
- }
- if (has_audio && audio_grab_format) {
- AVInputFormat *fmt1;
- fmt1 = av_find_input_format(audio_grab_format);
- ap->device = audio_device;
- if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) {
- fprintf(stderr, "Could not find audio grab device\n");
- exit(1);
- }
- input_files[nb_input_files] = ic;
-
- if (verbose >= 0)
- dump_format(ic, nb_input_files, "", 0);
-
- nb_input_files++;
- }
-}
-
/* same option as mencoder */
static void opt_pass(const char *pass_str)
{
@@ -3536,8 +3373,9 @@ static void opt_target(const char *arg)
opt_default("minrate", "1150000");
opt_default("bufsize", "327680"); // 40*1024*8;
- audio_bit_rate = 224000;
+ opt_default("ab", "224000");
audio_sample_rate = 44100;
+ audio_channels = 2;
opt_default("packetsize", "2324");
opt_default("muxrate", "1411200"); // 2352 * 75 * 8;
@@ -3565,7 +3403,7 @@ static void opt_target(const char *arg)
opt_default("flags", "+SCAN_OFFSET");
- audio_bit_rate = 224000;
+ opt_default("ab", "224000");
audio_sample_rate = 44100;
opt_default("packetsize", "2324");
@@ -3588,7 +3426,7 @@ static void opt_target(const char *arg)
opt_default("packetsize", "2048"); // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
opt_default("muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8
- audio_bit_rate = 448000;
+ opt_default("ab", "448000");
audio_sample_rate = 48000;
} else if(!strncmp(arg, "dv", 2)) {
@@ -3615,7 +3453,7 @@ static void opt_video_bsf(const char *arg)
AVBitStreamFilterContext **bsfp;
if(!bsfc){
- fprintf(stderr, "Unkown bitstream filter %s\n", arg);
+ fprintf(stderr, "Unknown bitstream filter %s\n", arg);
exit(1);
}
@@ -3633,7 +3471,7 @@ static void opt_audio_bsf(const char *arg)
AVBitStreamFilterContext **bsfp;
if(!bsfc){
- fprintf(stderr, "Unkown bitstream filter %s\n", arg);
+ fprintf(stderr, "Unknown bitstream filter %s\n", arg);
exit(1);
}
@@ -3656,9 +3494,25 @@ static void show_version(void)
}
static int opt_default(const char *opt, const char *arg){
- AVOption *o= av_set_string(avctx_opts, opt, arg);
+ int type;
+ const AVOption *o= NULL;
+ int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
+
+ for(type=0; type<CODEC_TYPE_NB; type++){
+ const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
+ if(o2)
+ o = av_set_string(avctx_opts[type], opt, arg);
+ }
if(!o)
o = av_set_string(avformat_opts, opt, arg);
+ if(!o){
+ if(opt[0] == 'a')
+ o = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg);
+ else if(opt[0] == 'v')
+ o = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg);
+ else if(opt[0] == 's')
+ o = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg);
+ }
if(!o)
return -1;
@@ -3670,12 +3524,12 @@ static int opt_default(const char *opt, const char *arg){
#if defined(CONFIG_FFM_DEMUXER) || defined(CONFIG_FFM_MUXER)
/* disable generate of real time pts in ffm (need to be supressed anyway) */
- if(avctx_opts->flags & CODEC_FLAG_BITEXACT)
+ if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
ffm_nopts = 1;
#endif
- if(avctx_opts->debug)
- av_log_set_level(AV_LOG_DEBUG);
+ if(avctx_opts[0]->debug)
+ av_log_level = AV_LOG_DEBUG;
return 0;
}
@@ -3691,7 +3545,7 @@ const OptionDef options[] = {
{ "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file:stream[:syncfile:syncstream]" },
{ "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "set meta data information of outfile from infile", "outfile:infile" },
{ "t", HAS_ARG, {(void*)opt_recording_time}, "set the recording time", "duration" },
- { "fs", HAS_ARG | OPT_INT, {(void*)&limit_filesize}, "set the limit file size", "limit_size" }, //
+ { "fs", HAS_ARG | OPT_INT64, {(void*)&limit_filesize}, "set the limit file size in bytes", "limit_size" }, //
{ "ss", HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" },
{ "itsoffset", HAS_ARG, {(void*)opt_input_ts_offset}, "set the input ts offset", "time_off" },
{ "title", HAS_ARG | OPT_STRING, {(void*)&str_title}, "set the title", "string" },
@@ -3721,7 +3575,6 @@ const OptionDef options[] = {
/* video options */
{ "vframes", OPT_INT | HAS_ARG | OPT_VIDEO, {(void*)&max_frames[CODEC_TYPE_VIDEO]}, "set the number of video frames to record", "number" },
- { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[CODEC_TYPE_AUDIO]}, "set the number of audio frames to record", "number" },
{ "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[CODEC_TYPE_DATA]}, "set the number of data frames to record", "number" },
{ "r", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_rate}, "set frame rate (Hz value, fraction or abbreviation)", "rate" },
{ "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
@@ -3747,7 +3600,6 @@ const OptionDef options[] = {
{ "me", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_motion_estimation}, "set motion estimation method",
"method" },
{ "me_threshold", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_me_threshold}, "motion estimaton threshold", "" },
- { "ps", HAS_ARG | OPT_EXPERT, {(void*)opt_packet_size}, "set packet size in bits", "size" },
{ "strict", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_strict}, "how strictly to follow the standards", "strictness" },
{ "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality},
"use same video quality as source (implies VBR)" },
@@ -3767,7 +3619,7 @@ const OptionDef options[] = {
{ "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" },
/* audio options */
- { "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_bitrate}, "set audio bitrate (in kbit/s)", "bitrate", },
+ { "aframes", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&max_frames[CODEC_TYPE_AUDIO]}, "set the number of audio frames to record", "number" },
{ "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set audio quality (codec-specific)", "quality", },
{ "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling rate (in Hz)", "rate" },
{ "ac", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of audio channels", "channels" },
@@ -3784,14 +3636,9 @@ const OptionDef options[] = {
{ "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language}, "set the ISO 639 language code (3 letters) of the current subtitle stream" , "code" },
/* grab options */
- { "vd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_device}, "set video grab device", "device" },
{ "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" },
{ "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_standard}, "set television standard (NTSC, PAL (SECAM))", "standard" },
- { "ad", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_GRAB, {(void*)opt_audio_device}, "set audio device", "device" },
-
- /* G.2 grab options */
- { "grab", HAS_ARG | OPT_EXPERT | OPT_GRAB, {(void*)opt_grab}, "request grabbing using", "format" },
- { "gd", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_grab_device}, "set grab device", "device" },
+ { "isync", OPT_BOOL | OPT_EXPERT | OPT_GRAB, {(void*)&input_sync}, "sync read on input", "" },
/* muxer options */
{ "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "set the maximum demux-decode delay", "seconds" },
@@ -3806,7 +3653,7 @@ const OptionDef options[] = {
static void show_banner(void)
{
- fprintf(stderr, "FFmpeg version " FFMPEG_VERSION ", Copyright (c) 2000-2006 Fabrice Bellard, et al.\n");
+ fprintf(stderr, "FFmpeg version " FFMPEG_VERSION ", Copyright (c) 2000-2007 Fabrice Bellard, et al.\n");
fprintf(stderr, " configuration: " FFMPEG_CONFIGURATION "\n");
fprintf(stderr, " libavutil version: " AV_STRINGIFY(LIBAVUTIL_VERSION) "\n");
fprintf(stderr, " libavcodec version: " AV_STRINGIFY(LIBAVCODEC_VERSION) "\n");
@@ -3887,7 +3734,7 @@ static void show_help(void)
show_help_options(options, "\nAdvanced options:\n",
OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
OPT_EXPERT);
- av_opt_show(avctx_opts, NULL);
+ av_opt_show(avctx_opts[0], NULL);
av_opt_show(avformat_opts, NULL);
exit(1);
@@ -3905,7 +3752,9 @@ int main(int argc, char **argv)
av_register_all();
- avctx_opts= avcodec_alloc_context();
+ for(i=0; i<CODEC_TYPE_NB; i++){
+ avctx_opts[i]= avcodec_alloc_context2(i);
+ }
avformat_opts = av_alloc_format_context();
if (argc <= 1)
@@ -3923,8 +3772,8 @@ int main(int argc, char **argv)
}
if (nb_input_files == 0) {
- input_sync = 1;
- prepare_grab();
+ fprintf(stderr, "Must supply at least one input file\n");
+ exit(1);
}
ti = getutime();
@@ -3942,8 +3791,10 @@ int main(int argc, char **argv)
int j;
if (!(s->oformat->flags & AVFMT_NOFILE))
url_fclose(&s->pb);
- for(j=0;j<s->nb_streams;j++)
+ for(j=0;j<s->nb_streams;j++) {
+ av_free(s->streams[j]->codec);
av_free(s->streams[j]);
+ }
av_free(s);
}
for(i=0;i<nb_input_files;i++)
@@ -3951,15 +3802,14 @@ int main(int argc, char **argv)
av_free_static();
- if(intra_matrix)
- av_free(intra_matrix);
- if(inter_matrix)
- av_free(inter_matrix);
+ av_free(intra_matrix);
+ av_free(inter_matrix);
+ av_free(opt_names);
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
extern void powerpc_display_perf_report(void);
powerpc_display_perf_report();
-#endif /* POWERPC_PERFORMANCE_REPORT */
+#endif /* CONFIG_POWERPC_PERF */
if (received_sigterm) {
fprintf(stderr,
diff --git a/contrib/ffmpeg/ffplay.c b/contrib/ffmpeg/ffplay.c
index f80a43548..ebe31cd9b 100644
--- a/contrib/ffmpeg/ffplay.c
+++ b/contrib/ffmpeg/ffplay.c
@@ -49,6 +49,8 @@
}
#endif
+#undef exit
+
//#define DEBUG_SYNC
#define MAX_VIDEOQ_SIZE (5 * 256 * 1024)
@@ -184,10 +186,14 @@ static AVInputFormat *file_iformat;
static const char *input_filename;
static int fs_screen_width;
static int fs_screen_height;
-static int screen_width = 640;
-static int screen_height = 480;
+static int screen_width = 0;
+static int screen_height = 0;
+static int frame_width = 0;
+static int frame_height = 0;
+static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
static int audio_disable;
static int video_disable;
+static int wanted_audio_stream= 0;
static int seek_by_bytes;
static int display_disable;
static int show_status;
@@ -207,6 +213,7 @@ static enum AVDiscard skip_idct= AVDISCARD_DEFAULT;
static enum AVDiscard skip_loop_filter= AVDISCARD_DEFAULT;
static int error_resilience = FF_ER_CAREFUL;
static int error_concealment = 3;
+static int decoder_reorder_pts= 0;
/* current context */
static int is_full_screen;
@@ -735,7 +742,7 @@ static void video_image_display(VideoState *is)
is->no_background = 0;
}
rect.x = is->xleft + x;
- rect.y = is->xleft + y;
+ rect.y = is->ytop + y;
rect.w = width;
rect.h = height;
SDL_DisplayYUVOverlay(vp->bmp, &rect);
@@ -781,7 +788,23 @@ static void video_audio_display(VideoState *s)
delay -= s->width / 2;
if (delay < s->width)
delay = s->width;
- i_start = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
+
+ i_start= x = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
+
+ h= INT_MIN;
+ for(i=0; i<1000; i+=channels){
+ int idx= (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
+ int a= s->sample_array[idx];
+ int b= s->sample_array[(idx + 4*channels)%SAMPLE_ARRAY_SIZE];
+ int c= s->sample_array[(idx + 5*channels)%SAMPLE_ARRAY_SIZE];
+ int d= s->sample_array[(idx + 9*channels)%SAMPLE_ARRAY_SIZE];
+ int score= a-d;
+ if(h<score && (b^c)<0){
+ h= score;
+ i_start= idx;
+ }
+ }
+
s->last_i_start = i_start;
} else {
i_start = s->last_i_start;
@@ -829,9 +852,49 @@ static void video_audio_display(VideoState *s)
SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height);
}
+static int video_open(VideoState *is){
+ int flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
+ int w,h;
+
+ if(is_full_screen) flags |= SDL_FULLSCREEN;
+ else flags |= SDL_RESIZABLE;
+
+ if (is_full_screen && fs_screen_width) {
+ w = fs_screen_width;
+ h = fs_screen_height;
+ } else if(!is_full_screen && screen_width){
+ w = screen_width;
+ h = screen_height;
+ }else if (is->video_st && is->video_st->codec->width){
+ w = is->video_st->codec->width;
+ h = is->video_st->codec->height;
+ } else {
+ w = 640;
+ h = 480;
+ }
+#ifndef CONFIG_DARWIN
+ screen = SDL_SetVideoMode(w, h, 0, flags);
+#else
+ /* setting bits_per_pixel = 0 or 32 causes blank video on OS X */
+ screen = SDL_SetVideoMode(w, h, 24, flags);
+#endif
+ if (!screen) {
+ fprintf(stderr, "SDL: could not set video mode - exiting\n");
+ return -1;
+ }
+ SDL_WM_SetCaption("FFplay", "FFplay");
+
+ is->width = screen->w;
+ is->height = screen->h;
+
+ return 0;
+}
+
/* display the current picture, if any */
static void video_display(VideoState *is)
{
+ if(!screen)
+ video_open(cur_stream);
if (is->audio_st && is->show_audio)
video_audio_display(is);
else if (is->video_st)
@@ -927,8 +990,9 @@ static void stream_seek(VideoState *is, int64_t pos, int rel)
static void stream_pause(VideoState *is)
{
is->paused = !is->paused;
- if (is->paused) {
+ if (!is->paused) {
is->video_current_pts = get_video_clock(is);
+ is->frame_timer += (av_gettime() - is->video_current_pts_time) / 1000000.0;
}
}
@@ -1116,7 +1180,7 @@ static void alloc_picture(void *opaque)
case PIX_FMT_YUV420P:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV444P:
- case PIX_FMT_YUV422:
+ case PIX_FMT_YUYV422:
case PIX_FMT_YUV410P:
case PIX_FMT_YUV411P:
is_yuv = 1;
@@ -1267,6 +1331,21 @@ static int output_picture2(VideoState *is, AVFrame *src_frame, double pts1)
return queue_picture(is, src_frame, pts);
}
+static uint64_t global_video_pkt_pts= AV_NOPTS_VALUE;
+
+static int my_get_buffer(struct AVCodecContext *c, AVFrame *pic){
+ int ret= avcodec_default_get_buffer(c, pic);
+ uint64_t *pts= av_malloc(sizeof(uint64_t));
+ *pts= global_video_pkt_pts;
+ pic->opaque= pts;
+ return ret;
+}
+
+static void my_release_buffer(struct AVCodecContext *c, AVFrame *pic){
+ if(pic) av_freep(&pic->opaque);
+ avcodec_default_release_buffer(c, pic);
+}
+
static int video_thread(void *arg)
{
VideoState *is = arg;
@@ -1289,19 +1368,26 @@ static int video_thread(void *arg)
/* NOTE: ipts is the PTS of the _first_ picture beginning in
this packet, if any */
- pts = 0;
- if (pkt->dts != AV_NOPTS_VALUE)
- pts = av_q2d(is->video_st->time_base)*pkt->dts;
+ global_video_pkt_pts= pkt->pts;
+ len1 = avcodec_decode_video(is->video_st->codec,
+ frame, &got_picture,
+ pkt->data, pkt->size);
+
+ if( (decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE)
+ && frame->opaque && *(uint64_t*)frame->opaque != AV_NOPTS_VALUE)
+ pts= *(uint64_t*)frame->opaque;
+ else if(pkt->dts != AV_NOPTS_VALUE)
+ pts= pkt->dts;
+ else
+ pts= 0;
+ pts *= av_q2d(is->video_st->time_base);
- len1 = avcodec_decode_video(is->video_st->codec,
- frame, &got_picture,
- pkt->data, pkt->size);
// if (len1 < 0)
// break;
- if (got_picture) {
- if (output_picture2(is, frame, pts) < 0)
- goto the_end;
- }
+ if (got_picture) {
+ if (output_picture2(is, frame, pts) < 0)
+ goto the_end;
+ }
av_free_packet(pkt);
if (step)
if (cur_stream)
@@ -1486,7 +1572,7 @@ static int synchronize_audio(VideoState *is, short *samples,
}
/* decode one audio frame and returns its uncompressed size */
-static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_ptr)
+static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, int buf_size, double *pts_ptr)
{
AVPacket *pkt = &is->audio_pkt;
int n, len1, data_size;
@@ -1495,7 +1581,8 @@ static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_pt
for(;;) {
/* NOTE: the audio packet can contain several frames */
while (is->audio_pkt_size > 0) {
- len1 = avcodec_decode_audio(is->audio_st->codec,
+ data_size = buf_size;
+ len1 = avcodec_decode_audio2(is->audio_st->codec,
(int16_t *)audio_buf, &data_size,
is->audio_pkt_data, is->audio_pkt_size);
if (len1 < 0) {
@@ -1556,7 +1643,7 @@ static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_pt
cannot have a precise information */
static int audio_write_get_buf_size(VideoState *is)
{
- return is->audio_hw_buf_size - is->audio_buf_index;
+ return is->audio_buf_size - is->audio_buf_index;
}
@@ -1571,7 +1658,7 @@ void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
while (len > 0) {
if (is->audio_buf_index >= is->audio_buf_size) {
- audio_size = audio_decode_frame(is, is->audio_buf, &pts);
+ audio_size = audio_decode_frame(is, is->audio_buf, sizeof(is->audio_buf), &pts);
if (audio_size < 0) {
/* if error, just output silence */
is->audio_buf_size = 1024;
@@ -1595,7 +1682,6 @@ void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
}
}
-
/* open a given stream. Return 0 if OK */
static int stream_component_open(VideoState *is, int stream_index)
{
@@ -1643,10 +1729,8 @@ static int stream_component_open(VideoState *is, int stream_index)
if (!codec ||
avcodec_open(enc, codec) < 0)
return -1;
-#if defined(HAVE_THREADS)
if(thread_count>1)
avcodec_thread_init(enc, thread_count);
-#endif
enc->thread_count= thread_count;
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
@@ -1676,6 +1760,9 @@ static int stream_component_open(VideoState *is, int stream_index)
packet_queue_init(&is->videoq);
is->video_tid = SDL_CreateThread(video_thread, is);
+
+ enc-> get_buffer= my_get_buffer;
+ enc->release_buffer= my_release_buffer;
break;
case CODEC_TYPE_SUBTITLE:
is->subtitle_stream = stream_index;
@@ -1809,6 +1896,11 @@ static int decode_thread(void *arg)
ap->initial_pause = 1; /* we force a pause when starting an RTSP
stream */
+ ap->width = frame_width;
+ ap->height= frame_height;
+ ap->time_base= (AVRational){1, 25};
+ ap->pix_fmt = frame_pix_fmt;
+
err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
if (err < 0) {
print_error(is->filename, err);
@@ -1866,7 +1958,7 @@ static int decode_thread(void *arg)
AVCodecContext *enc = ic->streams[i]->codec;
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
- if (audio_index < 0 && !audio_disable)
+ if ((audio_index < 0 || wanted_audio_stream-- > 0) && !audio_disable)
audio_index = i;
break;
case CODEC_TYPE_VIDEO:
@@ -1919,7 +2011,18 @@ static int decode_thread(void *arg)
}
#endif
if (is->seek_req) {
- ret = av_seek_frame(is->ic, -1, is->seek_pos, is->seek_flags);
+ int stream_index= -1;
+ int64_t seek_target= is->seek_pos;
+
+ if (is-> video_stream >= 0) stream_index= is-> video_stream;
+ else if(is-> audio_stream >= 0) stream_index= is-> audio_stream;
+ else if(is->subtitle_stream >= 0) stream_index= is->subtitle_stream;
+
+ if(stream_index>=0){
+ seek_target= av_rescale_q(seek_target, AV_TIME_BASE_Q, ic->streams[stream_index]->time_base);
+ }
+
+ ret = av_seek_frame(is->ic, stream_index, seek_target, is->seek_flags);
if (ret < 0) {
fprintf(stderr, "%s: error while seeking\n", is->ic->filename);
}else{
@@ -2008,10 +2111,6 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
return NULL;
pstrcpy(is->filename, sizeof(is->filename), filename);
is->iformat = iformat;
- if (screen) {
- is->width = screen->w;
- is->height = screen->h;
- }
is->ytop = 0;
is->xleft = 0;
@@ -2108,27 +2207,12 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
static void toggle_full_screen(void)
{
- int w, h, flags;
is_full_screen = !is_full_screen;
if (!fs_screen_width) {
/* use default SDL method */
- SDL_WM_ToggleFullScreen(screen);
- } else {
- /* use the recorded resolution */
- flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
- if (is_full_screen) {
- w = fs_screen_width;
- h = fs_screen_height;
- flags |= SDL_FULLSCREEN;
- } else {
- w = screen_width;
- h = screen_height;
- flags |= SDL_RESIZABLE;
- }
- screen = SDL_SetVideoMode(w, h, 0, flags);
- cur_stream->width = w;
- cur_stream->height = h;
+// SDL_WM_ToggleFullScreen(screen);
}
+ video_open(cur_stream);
}
static void toggle_pause(void)
@@ -2261,8 +2345,8 @@ static void event_loop(void)
if (cur_stream) {
screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);
- cur_stream->width = event.resize.w;
- cur_stream->height = event.resize.h;
+ screen_width = cur_stream->width = event.resize.w;
+ screen_height= cur_stream->height= event.resize.h;
}
break;
case SDL_QUIT:
@@ -2270,6 +2354,7 @@ static void event_loop(void)
do_exit();
break;
case FF_ALLOC_EVENT:
+ video_open(event.user.data1);
alloc_picture(event.user.data1);
break;
case FF_REFRESH_EVENT:
@@ -2281,14 +2366,34 @@ static void event_loop(void)
}
}
+static void opt_frame_size(const char *arg)
+{
+ if (parse_image_size(&frame_width, &frame_height, arg) < 0) {
+ fprintf(stderr, "Incorrect frame size\n");
+ exit(1);
+ }
+ if ((frame_width % 2) != 0 || (frame_height % 2) != 0) {
+ fprintf(stderr, "Frame size must be a multiple of 2\n");
+ exit(1);
+ }
+}
+
void opt_width(const char *arg)
{
screen_width = atoi(arg);
+ if(screen_width<=0){
+ fprintf(stderr, "invalid width\n");
+ exit(1);
+ }
}
void opt_height(const char *arg)
{
screen_height = atoi(arg);
+ if(screen_height<=0){
+ fprintf(stderr, "invalid height\n");
+ exit(1);
+ }
}
static void opt_format(const char *arg)
@@ -2300,6 +2405,11 @@ static void opt_format(const char *arg)
}
}
+static void opt_frame_pix_fmt(const char *arg)
+{
+ frame_pix_fmt = avcodec_get_pix_fmt(arg);
+}
+
#ifdef CONFIG_NETWORK
void opt_rtp_tcp(void)
{
@@ -2327,7 +2437,7 @@ void opt_seek(const char *arg)
static void opt_debug(const char *arg)
{
- av_log_set_level(99);
+ av_log_level = 99;
debug = atoi(arg);
}
@@ -2348,19 +2458,23 @@ const OptionDef options[] = {
{ "h", 0, {(void*)show_help}, "show help" },
{ "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
{ "y", HAS_ARG, {(void*)opt_height}, "force displayed height", "height" },
+ { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
{ "fs", OPT_BOOL, {(void*)&is_full_screen}, "force full screen" },
{ "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
{ "vn", OPT_BOOL, {(void*)&video_disable}, "disable video" },
+ { "ast", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&wanted_audio_stream}, "", "" },
{ "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
{ "bytes", OPT_BOOL, {(void*)&seek_by_bytes}, "seek by bytes" },
{ "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
+ { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format", "format" },
{ "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
{ "debug", HAS_ARG | OPT_EXPERT, {(void*)opt_debug}, "print specific debug info", "" },
{ "bug", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&workaround_bugs}, "workaround bugs", "" },
{ "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
{ "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
{ "genpts", OPT_BOOL | OPT_EXPERT, {(void*)&genpts}, "generate pts", "" },
+ { "drp", OPT_BOOL |OPT_EXPERT, {(void*)&decoder_reorder_pts}, "let decoder reorder pts", ""},
{ "lowres", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&lowres}, "", "" },
{ "skiploop", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&skip_loop_filter}, "", "" },
{ "skipframe", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&skip_frame}, "", "" },
@@ -2411,7 +2525,7 @@ void parse_arg_file(const char *filename)
/* Called from the main */
int main(int argc, char **argv)
{
- int flags, w, h;
+ int flags;
/* register all codecs, demux and protocols */
av_register_all();
@@ -2447,27 +2561,6 @@ int main(int argc, char **argv)
fs_screen_width = vi->current_w;
fs_screen_height = vi->current_h;
#endif
- flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
- if (is_full_screen && fs_screen_width) {
- w = fs_screen_width;
- h = fs_screen_height;
- flags |= SDL_FULLSCREEN;
- } else {
- w = screen_width;
- h = screen_height;
- flags |= SDL_RESIZABLE;
- }
-#ifndef CONFIG_DARWIN
- screen = SDL_SetVideoMode(w, h, 0, flags);
-#else
- /* setting bits_per_pixel = 0 or 32 causes blank video on OS X */
- screen = SDL_SetVideoMode(w, h, 24, flags);
-#endif
- if (!screen) {
- fprintf(stderr, "SDL: could not set video mode - exiting\n");
- exit(1);
- }
- SDL_WM_SetCaption("FFplay", "FFplay");
}
SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
diff --git a/contrib/ffmpeg/ffserver.c b/contrib/ffmpeg/ffserver.c
index 138e607ed..063ac5a02 100644
--- a/contrib/ffmpeg/ffserver.c
+++ b/contrib/ffmpeg/ffserver.c
@@ -25,7 +25,9 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#ifdef HAVE_SYS_POLL_H
#include <sys/poll.h>
+#endif
#include <errno.h>
#include <sys/time.h>
#undef time //needed because HAVE_AV_CONFIG_H is defined on top
@@ -43,6 +45,9 @@
#include "version.h"
#include "ffserver.h"
+#include "random.h"
+
+#undef exit
/* maximum number of simultaneous HTTP connections */
#define HTTP_MAX_CONNECTIONS 2000
@@ -80,9 +85,6 @@ const char *http_state[] = {
#define IOBUFFER_INIT_SIZE 8192
-/* coef for exponential mean for bitrate estimation in statistics */
-#define AVG_COEF 0.9
-
/* timeouts are in ms */
#define HTTP_REQUEST_TIMEOUT (15 * 1000)
#define RTSP_REQUEST_TIMEOUT (3600 * 24 * 1000)
@@ -91,7 +93,7 @@ const char *http_state[] = {
typedef struct {
int64_t count1, count2;
- long time1, time2;
+ int64_t time1, time2;
} DataRateData;
/* context associated with one connection */
@@ -100,7 +102,7 @@ typedef struct HTTPContext {
int fd; /* socket file descriptor */
struct sockaddr_in from_addr; /* origin */
struct pollfd *poll_entry; /* used when polling */
- long timeout;
+ int64_t timeout;
uint8_t *buffer_ptr, *buffer_end;
int http_error;
int post;
@@ -111,7 +113,7 @@ typedef struct HTTPContext {
int feed_fd;
/* input format handling */
AVFormatContext *fmt_in;
- long start_time; /* In milliseconds - this wraps fairly often */
+ int64_t start_time; /* In milliseconds - this wraps fairly often */
int64_t first_pts; /* initial pts value */
int64_t cur_pts; /* current pts value from the stream in us */
int64_t cur_frame_duration; /* duration of the current frame in us */
@@ -191,7 +193,7 @@ typedef struct FFStream {
IPAddressACL *acl;
int nb_streams;
int prebuffer; /* Number of millseconds early to start */
- long max_time; /* Number of milliseconds to run */
+ int64_t max_time; /* Number of milliseconds to run */
int send_on_key;
AVStream *streams[MAX_STREAMS];
int feed_streams[MAX_STREAMS]; /* index of streams in the feed */
@@ -287,15 +289,9 @@ static int nb_connections;
static int max_bandwidth;
static int current_bandwidth;
-static long cur_time; // Making this global saves on passing it around everywhere
-
-static long gettime_ms(void)
-{
- struct timeval tv;
+static int64_t cur_time; // Making this global saves on passing it around everywhere
- gettimeofday(&tv,NULL);
- return (long long)tv.tv_sec * 1000 + (tv.tv_usec / 1000);
-}
+static AVRandomState random_state;
static FILE *logfile = NULL;
@@ -439,13 +435,13 @@ static int socket_open_listen(struct sockaddr_in *my_addr)
char bindmsg[32];
snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));
perror (bindmsg);
- close(server_fd);
+ closesocket(server_fd);
return -1;
}
if (listen (server_fd, 5) < 0) {
perror ("listen");
- close(server_fd);
+ closesocket(server_fd);
return -1;
}
fcntl(server_fd, F_SETFL, O_NONBLOCK);
@@ -466,8 +462,8 @@ static void start_multicast(void)
for(stream = first_stream; stream != NULL; stream = stream->next) {
if (stream->is_multicast) {
/* open the RTP connection */
- snprintf(session_id, sizeof(session_id),
- "%08x%08x", (int)random(), (int)random());
+ snprintf(session_id, sizeof(session_id), "%08x%08x",
+ av_random(&random_state), av_random(&random_state));
/* choose a port if none given */
if (stream->multicast_port == 0) {
@@ -600,7 +596,7 @@ static int http_server(void)
return -1;
} while (ret <= 0);
- cur_time = gettime_ms();
+ cur_time = av_gettime() / 1000;
if (need_to_start_children) {
need_to_start_children = 0;
@@ -689,7 +685,7 @@ static void new_connection(int server_fd, int is_rtsp)
av_free(c->buffer);
av_free(c);
}
- close(fd);
+ closesocket(fd);
}
static void close_connection(HTTPContext *c)
@@ -719,7 +715,7 @@ static void close_connection(HTTPContext *c)
/* remove connection associated resources */
if (c->fd >= 0)
- close(c->fd);
+ closesocket(c->fd);
if (c->fmt_in) {
/* close each frame parser */
for(i=0;i<c->fmt_in->nb_streams;i++) {
@@ -765,6 +761,13 @@ static void close_connection(HTTPContext *c)
if (c->stream && !c->post && c->stream->stream_type == STREAM_TYPE_LIVE)
current_bandwidth -= c->stream->bandwidth;
+
+ /* signal that there is no feed if we are the feeder socket */
+ if (c->state == HTTPSTATE_RECEIVE_DATA && c->stream) {
+ c->stream->feed_opened = 0;
+ close(c->feed_fd);
+ }
+
av_freep(&c->pb_buffer);
av_freep(&c->packet_buffer);
av_free(c->buffer);
@@ -790,7 +793,7 @@ static int handle_connection(HTTPContext *c)
return 0;
/* read the data */
read_loop:
- len = read(c->fd, c->buffer_ptr, 1);
+ len = recv(c->fd, c->buffer_ptr, 1, 0);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR)
return -1;
@@ -825,7 +828,7 @@ static int handle_connection(HTTPContext *c)
/* no need to write if no events */
if (!(c->poll_entry->revents & POLLOUT))
return 0;
- len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
+ len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
/* error : close connection */
@@ -866,6 +869,9 @@ static int handle_connection(HTTPContext *c)
}
if (http_send_data(c) < 0)
return -1;
+ /* close connection if trailer sent */
+ if (c->state == HTTPSTATE_SEND_DATA_TRAILER)
+ return -1;
break;
case HTTPSTATE_RECEIVE_DATA:
/* no need to read if no events */
@@ -892,7 +898,7 @@ static int handle_connection(HTTPContext *c)
/* no need to write if no events */
if (!(c->poll_entry->revents & POLLOUT))
return 0;
- len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
+ len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
/* error : close connection */
@@ -917,8 +923,8 @@ static int handle_connection(HTTPContext *c)
/* no need to write if no events */
if (!(c->poll_entry->revents & POLLOUT))
return 0;
- len = write(c->fd, c->packet_buffer_ptr,
- c->packet_buffer_end - c->packet_buffer_ptr);
+ len = send(c->fd, c->packet_buffer_ptr,
+ c->packet_buffer_end - c->packet_buffer_ptr, 0);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
/* error : close connection */
@@ -1168,7 +1174,7 @@ static int http_parse_request(HTTPContext *c)
char *p;
enum RedirType redir_type;
char cmd[32];
- char info[1024], *filename;
+ char info[1024], filename[1024];
char url[1024], *q;
char protocol[32];
char msg[1024];
@@ -1202,11 +1208,7 @@ static int http_parse_request(HTTPContext *c)
http_log("New connection: %s %s\n", cmd, url);
/* find the filename and the optional info string in the request */
- p = url;
- if (*p == '/')
- p++;
- filename = p;
- p = strchr(p, '?');
+ p = strchr(url, '?');
if (p) {
pstrcpy(info, sizeof(info), p);
*p = '\0';
@@ -1214,6 +1216,8 @@ static int http_parse_request(HTTPContext *c)
info[0] = '\0';
}
+ pstrcpy(filename, sizeof(filename)-1, url + ((*url == '/') ? 1 : 0));
+
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (strncasecmp(p, "User-Agent:", 11) == 0) {
useragent = p + 11;
@@ -1241,12 +1245,16 @@ static int http_parse_request(HTTPContext *c)
strcpy(filename + strlen(filename)-2, "m");
} else if (match_ext(filename, "rtsp")) {
redir_type = REDIR_RTSP;
- compute_real_filename(filename, sizeof(url) - 1);
+ compute_real_filename(filename, sizeof(filename) - 1);
} else if (match_ext(filename, "sdp")) {
redir_type = REDIR_SDP;
- compute_real_filename(filename, sizeof(url) - 1);
+ compute_real_filename(filename, sizeof(filename) - 1);
}
+ // "redirect" / request to index.html
+ if (!strlen(filename))
+ pstrcpy(filename, sizeof(filename) - 1, "index.html");
+
stream = first_stream;
while (stream != NULL) {
if (!strcmp(stream->filename, filename) && validate_acl(stream, c))
@@ -1290,6 +1298,12 @@ static int http_parse_request(HTTPContext *c)
}
}
+ /* If already streaming this feed, dont let start an another feeder */
+ if (stream->feed_opened) {
+ snprintf(msg, sizeof(msg), "This feed is already being received.");
+ goto send_error;
+ }
+
if (c->post == 0 && stream->stream_type == STREAM_TYPE_LIVE) {
current_bandwidth += stream->bandwidth;
}
@@ -1527,14 +1541,14 @@ static int http_parse_request(HTTPContext *c)
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 OK\r\n");
mime_type = c->stream->fmt->mime_type;
if (!mime_type)
- mime_type = "application/x-octet_stream";
+ mime_type = "application/x-octet-stream";
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Pragma: no-cache\r\n");
/* for asf, we need extra headers */
if (!strcmp(c->stream->fmt->name,"asf_stream")) {
/* Need to allocate a client id */
- c->wmp_client_id = random() & 0x7fffffff;
+ c->wmp_client_id = av_random(&random_state) & 0x7fffffff;
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id);
}
@@ -1751,6 +1765,7 @@ static void compute_stats(HTTPContext *c)
switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
type = "audio";
+ snprintf(parameters, sizeof(parameters), "%d channel(s), %d Hz", st->codec->channels, st->codec->sample_rate);
break;
case CODEC_TYPE_VIDEO:
type = "video";
@@ -1953,7 +1968,7 @@ static int open_input_stream(HTTPContext *c, const char *info)
static int64_t get_server_clock(HTTPContext *c)
{
/* compute current pts value from system time */
- return (int64_t)(cur_time - c->start_time) * 1000LL;
+ return (cur_time - c->start_time) * 1000;
}
/* return the estimated time at which the current packet must be sent
@@ -2026,7 +2041,8 @@ static int http_prepare_data(HTTPContext *c)
c->fmt_ctx.pb.is_streamed = 1;
av_set_parameters(&c->fmt_ctx, NULL);
- av_write_header(&c->fmt_ctx);
+ if (av_write_header(&c->fmt_ctx) < 0)
+ return -1;
len = url_close_dyn_buf(&c->fmt_ctx.pb, &c->pb_buffer);
c->buffer_ptr = c->pb_buffer;
@@ -2167,6 +2183,14 @@ static int http_prepare_data(HTTPContext *c)
/* XXX: potential leak */
return -1;
}
+ if (pkt.dts != AV_NOPTS_VALUE)
+ pkt.dts = av_rescale_q(pkt.dts,
+ c->fmt_in->streams[pkt.stream_index]->time_base,
+ ctx->streams[pkt.stream_index]->time_base);
+ if (pkt.pts != AV_NOPTS_VALUE)
+ pkt.pts = av_rescale_q(pkt.pts,
+ c->fmt_in->streams[pkt.stream_index]->time_base,
+ ctx->streams[pkt.stream_index]->time_base);
if (av_write_frame(ctx, &pkt)) {
c->state = HTTPSTATE_SEND_DATA_TRAILER;
}
@@ -2207,9 +2231,6 @@ static int http_prepare_data(HTTPContext *c)
return 0;
}
-/* in bit/s */
-#define SHORT_TERM_BANDWIDTH 8000000
-
/* should convert the format at the same time */
/* send data starting at c->buffer_ptr to the output connection
(either UDP or TCP connection) */
@@ -2289,8 +2310,8 @@ static int http_send_data(HTTPContext *c)
c->buffer_ptr += len;
/* send everything we can NOW */
- len = write(rtsp_c->fd, rtsp_c->packet_buffer_ptr,
- rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr);
+ len = send(rtsp_c->fd, rtsp_c->packet_buffer_ptr,
+ rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr, 0);
if (len > 0) {
rtsp_c->packet_buffer_ptr += len;
}
@@ -2314,7 +2335,7 @@ static int http_send_data(HTTPContext *c)
}
} else {
/* TCP data output */
- len = write(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
+ len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
/* error : close connection */
@@ -2371,7 +2392,7 @@ static int http_receive_data(HTTPContext *c)
if (c->buffer_end > c->buffer_ptr) {
int len;
- len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
+ len = recv(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
/* error : close connection */
@@ -2824,8 +2845,8 @@ static void rtsp_cmd_setup(HTTPContext *c, const char *url,
/* generate session id if needed */
if (h->session_id[0] == '\0') {
- snprintf(h->session_id, sizeof(h->session_id),
- "%08x%08x", (int)random(), (int)random());
+ snprintf(h->session_id, sizeof(h->session_id), "%08x%08x",
+ av_random(&random_state), av_random(&random_state));
}
/* find rtp session, and create it if none found */
@@ -3322,7 +3343,7 @@ static void extract_mpeg4_header(AVFormatContext *infile)
if (p[0] == 0x00 && p[1] == 0x00 &&
p[2] == 0x01 && p[3] == 0xb6) {
size = p - pkt.data;
- // av_hex_dump(pkt.data, size);
+ // av_hex_dump_log(infile, AV_LOG_DEBUG, pkt.data, size);
st->codec->extradata = av_malloc(size);
st->codec->extradata_size = size;
memcpy(st->codec->extradata, pkt.data, size);
@@ -3518,7 +3539,10 @@ static void build_feed_streams(void)
s->streams[i] = st;
}
av_set_parameters(s, NULL);
- av_write_header(s);
+ if (av_write_header(s) < 0) {
+ fprintf(stderr, "Container doesn't supports the required parameters\n");
+ exit(1);
+ }
/* XXX: need better api */
av_freep(&s->priv_data);
url_fclose(&s->pb);
@@ -4149,6 +4173,11 @@ static int parse_ffconfig(const char *filename)
video_enc.mb_decision = FF_MB_DECISION_BITS; //FIXME remove
video_enc.flags |= CODEC_FLAG_4MV;
}
+ } else if (!strcasecmp(cmd, "VideoTag")) {
+ get_arg(arg, sizeof(arg), &p);
+ if ((strlen(arg) == 4) && stream) {
+ video_enc.codec_tag = ff_get_fourcc(arg);
+ }
} else if (!strcasecmp(cmd, "BitExact")) {
if (stream) {
video_enc.flags |= CODEC_FLAG_BITEXACT;
@@ -4267,8 +4296,8 @@ static int parse_ffconfig(const char *filename)
IPAddressACL *nacl = (IPAddressACL *) av_mallocz(sizeof(*nacl));
IPAddressACL **naclp = 0;
+ acl.next = 0;
*nacl = acl;
- nacl->next = 0;
if (stream) {
naclp = &stream->acl;
@@ -4291,11 +4320,7 @@ static int parse_ffconfig(const char *filename)
get_arg(arg, sizeof(arg), &p);
if (stream) {
av_freep(&stream->rtsp_option);
- /* XXX: av_strdup ? */
- stream->rtsp_option = av_malloc(strlen(arg) + 1);
- if (stream->rtsp_option) {
- strcpy(stream->rtsp_option, arg);
- }
+ stream->rtsp_option = av_strdup(arg);
}
} else if (!strcasecmp(cmd, "MulticastAddress")) {
get_arg(arg, sizeof(arg), &p);
@@ -4398,25 +4423,6 @@ static int parse_ffconfig(const char *filename)
return 0;
}
-
-#if 0
-static void write_packet(FFCodec *ffenc,
- uint8_t *buf, int size)
-{
- PacketHeader hdr;
- AVCodecContext *enc = &ffenc->enc;
- uint8_t *wptr;
- mk_header(&hdr, enc, size);
- wptr = http_fifo.wptr;
- fifo_write(&http_fifo, (uint8_t *)&hdr, sizeof(hdr), &wptr);
- fifo_write(&http_fifo, buf, size, &wptr);
- /* atomic modification of wptr */
- http_fifo.wptr = wptr;
- ffenc->data_count += size;
- ffenc->avg_frame_size = ffenc->avg_frame_size * AVG_COEF + size * (1.0 - AVG_COEF);
-}
-#endif
-
static void show_banner(void)
{
printf("ffserver version " FFMPEG_VERSION ", Copyright (c) 2000-2006 Fabrice Bellard, et al.\n");
@@ -4523,7 +4529,7 @@ int main(int argc, char **argv)
putenv("http_proxy"); /* Kill the http_proxy */
- srandom(gettime_ms() + (getpid() << 16));
+ av_init_random(av_gettime() + (getpid() << 16), &random_state);
/* address on which the server will handle HTTP connections */
my_http_addr.sin_family = AF_INET;
diff --git a/contrib/ffmpeg/ffserver.h b/contrib/ffmpeg/ffserver.h
index 868e4cd9b..a1b95e84a 100644
--- a/contrib/ffmpeg/ffserver.h
+++ b/contrib/ffmpeg/ffserver.h
@@ -1,3 +1,23 @@
+/*
+ * Multiple format streaming server
+ * copyright (c) 2002 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#ifndef FFSERVER_H
#define FFSERVER_H
diff --git a/contrib/ffmpeg/libavcodec/4xm.c b/contrib/ffmpeg/libavcodec/4xm.c
index ea60e9bf2..6889dbc4b 100644
--- a/contrib/ffmpeg/libavcodec/4xm.c
+++ b/contrib/ffmpeg/libavcodec/4xm.c
@@ -491,7 +491,6 @@ static uint8_t *read_huffman_tables(FourXContext *f, uint8_t * const buf){
for(i=start; i<=end; i++){
frequency[i]= *ptr++;
-// printf("%d %d %d\n", start, end, frequency[i]);
}
start= *ptr++;
if(start==0) break;
@@ -502,9 +501,6 @@ static uint8_t *read_huffman_tables(FourXContext *f, uint8_t * const buf){
while((ptr - buf)&3) ptr++; // 4byte align
-// for(j=0; j<16; j++)
-// printf("%2X", ptr[j]);
-
for(j=257; j<512; j++){
int min_freq[2]= {256*256, 256*256};
int smallest[2]= {0, 0};
@@ -693,12 +689,6 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "ignoring unknown chunk length:%d\n", buf_size);
}
-#if 0
-for(i=0; i<20; i++){
- printf("%2X %c ", buf[i], clip(buf[i],16,126));
-}
-#endif
-
p->key_frame= p->pict_type == I_TYPE;
*picture= *p;
diff --git a/contrib/ffmpeg/libavcodec/8bps.c b/contrib/ffmpeg/libavcodec/8bps.c
index 297465043..3d4eb05b3 100644
--- a/contrib/ffmpeg/libavcodec/8bps.c
+++ b/contrib/ffmpeg/libavcodec/8bps.c
@@ -27,8 +27,8 @@
* http://www.pcisys.net/~melanson/codecs/
*
* Supports: PAL8 (RGB 8bpp, paletted)
- * : BGR24 (RGB 24bpp) (can also output it as RGBA32)
- * : RGBA32 (RGB 32bpp, 4th plane is probably alpha and it's ignored)
+ * : BGR24 (RGB 24bpp) (can also output it as RGB32)
+ * : RGB32 (RGB 32bpp, 4th plane is probably alpha and it's ignored)
*
*/
@@ -39,7 +39,7 @@
#include "avcodec.h"
-static const enum PixelFormat pixfmt_rgb24[] = {PIX_FMT_BGR24, PIX_FMT_RGBA32, -1};
+static const enum PixelFormat pixfmt_rgb24[] = {PIX_FMT_BGR24, PIX_FMT_RGB32, -1};
/*
* Decoder context
@@ -89,7 +89,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
if (planes == 4)
planes--;
- px_inc = planes + (avctx->pix_fmt == PIX_FMT_RGBA32);
+ px_inc = planes + (avctx->pix_fmt == PIX_FMT_RGB32);
for (p = 0; p < planes; p++) {
/* Lines length pointer for this plane */
@@ -181,7 +181,7 @@ static int decode_init(AVCodecContext *avctx)
c->planemap[2] = 0; // 3rd plane is blue
break;
case 32:
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
c->planes = 4;
#ifdef WORDS_BIGENDIAN
c->planemap[0] = 1; // 1st plane is red
diff --git a/contrib/ffmpeg/libavcodec/Makefile b/contrib/ffmpeg/libavcodec/Makefile
index 03c1ae43d..9ec6b96f1 100644
--- a/contrib/ffmpeg/libavcodec/Makefile
+++ b/contrib/ffmpeg/libavcodec/Makefile
@@ -47,7 +47,7 @@ OBJS= bitstream.o \
HEADERS = avcodec.h opt.h
OBJS-$(CONFIG_AASC_DECODER) += aasc.o
-OBJS-$(CONFIG_AC3_ENCODER) += ac3enc.o
+OBJS-$(CONFIG_AC3_ENCODER) += ac3enc.o ac3.o
OBJS-$(CONFIG_ALAC_DECODER) += alac.o
OBJS-$(CONFIG_ASV1_DECODER) += asv1.o
OBJS-$(CONFIG_ASV1_ENCODER) += asv1.o
@@ -55,13 +55,16 @@ OBJS-$(CONFIG_ASV2_DECODER) += asv1.o
OBJS-$(CONFIG_ASV2_ENCODER) += asv1.o
OBJS-$(CONFIG_AVS_DECODER) += avs.o
OBJS-$(CONFIG_BMP_DECODER) += bmp.o
+OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o
OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdsp.o
OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
OBJS-$(CONFIG_CLJR_DECODER) += cljr.o
OBJS-$(CONFIG_CLJR_ENCODER) += cljr.o
OBJS-$(CONFIG_COOK_DECODER) += cook.o
-OBJS-$(CONFIG_CSCD_DECODER) += cscd.o lzo.o
+OBJS-$(CONFIG_CSCD_DECODER) += cscd.o
OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
+OBJS-$(CONFIG_DCA_DECODER) += dca.o
+OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o
OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinav.o
OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinav.o
OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o
@@ -70,6 +73,7 @@ OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o
OBJS-$(CONFIG_DVDSUB_ENCODER) += dvdsubenc.o
OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o
OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o
+OBJS-$(CONFIG_DXA_DECODER) += dxa.o
OBJS-$(CONFIG_EIGHTBPS_DECODER) += 8bps.o
OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o
OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o
@@ -78,6 +82,7 @@ OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o
OBJS-$(CONFIG_FLAC_DECODER) += flac.o
OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o
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
@@ -86,6 +91,7 @@ OBJS-$(CONFIG_GIF_ENCODER) += gif.o
OBJS-$(CONFIG_H261_DECODER) += h261.o
OBJS-$(CONFIG_H261_ENCODER) += h261.o
OBJS-$(CONFIG_H264_DECODER) += h264.o
+OBJS-$(CONFIG_H264_ENCODER) += h264enc.o h264dsp.o
OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o
OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o
OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o
@@ -100,10 +106,11 @@ OBJS-$(CONFIG_MACE3_DECODER) += mace.o
OBJS-$(CONFIG_MACE6_DECODER) += mace.o
OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
OBJS-$(CONFIG_MP2_ENCODER) += mpegaudio.o
+OBJS-$(CONFIG_MPC7_DECODER) += mpc.o
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o
OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
OBJS-$(CONFIG_MSZH_DECODER) += lcl.o
-OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o lzo.o
+OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
OBJS-$(CONFIG_PNG_DECODER) += png.o
OBJS-$(CONFIG_PNG_ENCODER) += png.o
OBJS-$(CONFIG_QDM2_DECODER) += qdm2.o
@@ -133,7 +140,8 @@ OBJS-$(CONFIG_SVQ1_DECODER) += svq1.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1.o
OBJS-$(CONFIG_SVQ3_DECODER) += h264.o
OBJS-$(CONFIG_TARGA_DECODER) += targa.o
-OBJS-$(CONFIG_THEORA_DECODER) += vp3.o
+OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o
+OBJS-$(CONFIG_THEORA_DECODER) += vp3.o xiph.o
OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o
OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o
@@ -148,15 +156,17 @@ OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o
OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdav.o
OBJS-$(CONFIG_VMNC_DECODER) += vmnc.o
-OBJS-$(CONFIG_VORBIS_DECODER) += vorbis.o vorbis_data.o
+OBJS-$(CONFIG_VORBIS_DECODER) += vorbis.o vorbis_data.o xiph.o
OBJS-$(CONFIG_VORBIS_ENCODER) += vorbis_enc.o vorbis.o vorbis_data.o
OBJS-$(CONFIG_VP3_DECODER) += vp3.o
OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o
OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o
OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o
-OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o
-OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o
+OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o
+OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o
+OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o
+OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o
OBJS-$(CONFIG_WMV3_DECODER) += vc1.o vc1dsp.o
OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o
@@ -167,6 +177,7 @@ OBJS-$(CONFIG_XL_DECODER) += xl.o
OBJS-$(CONFIG_ZLIB_DECODER) += lcl.o
OBJS-$(CONFIG_ZLIB_ENCODER) += lcl.o
OBJS-$(CONFIG_ZMBV_DECODER) += zmbv.o
+OBJS-$(CONFIG_ZMBV_ENCODER) += zmbvenc.o
OBJS-$(CONFIG_PCM_S32LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S32LE_ENCODER) += pcm.o
@@ -219,8 +230,8 @@ OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_IMA_DK4_ENCODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER) += adpcm.o
-OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER)+= adpcm.o
-OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_ENCODER)+= adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER) += adpcm.o
+OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_ENCODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_IMA_WAV_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_IMA_WS_DECODER) += adpcm.o
@@ -240,28 +251,17 @@ OBJS-$(CONFIG_ADPCM_XA_ENCODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o
OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcm.o
-OBJS-$(CONFIG_FAAD) += faad.o
-OBJS-$(CONFIG_FAAC) += faac.o
-OBJS-$(CONFIG_XVID) += xvidff.o xvid_rc.o
-OBJS-$(CONFIG_X264) += x264.o
-OBJS-$(CONFIG_MP3LAME) += mp3lameaudio.o
-OBJS-$(CONFIG_LIBVORBIS) += oggvorbis.o
+# external codec libraries
+OBJS-$(CONFIG_LIBA52) += a52dec.o
+OBJS-$(CONFIG_LIBDTS) += dtsdec.o
+OBJS-$(CONFIG_LIBFAAC) += faac.o
+OBJS-$(CONFIG_LIBFAAD) += faad.o
OBJS-$(CONFIG_LIBGSM) += libgsm.o
-
-# currently using liba52 for ac3 decoding
-OBJS-$(CONFIG_A52) += a52dec.o
-
-# using builtin liba52 or runtime linked liba52.so.0
-OBJS-$(CONFIG_A52)$(CONFIG_A52BIN) += liba52/bit_allocate.o \
- liba52/bitstream.o \
- liba52/downmix.o \
- liba52/imdct.o \
- liba52/parse.o \
- liba52/crc.o \
- liba52/resample.o
-
-# currently using libdts for dts decoding
-OBJS-$(CONFIG_DTS) += dtsdec.o
+OBJS-$(CONFIG_LIBMP3LAME) += mp3lameaudio.o
+OBJS-$(CONFIG_LIBTHEORA) += libtheoraenc.o
+OBJS-$(CONFIG_LIBVORBIS) += oggvorbis.o
+OBJS-$(CONFIG_X264) += x264.o
+OBJS-$(CONFIG_XVID) += xvidff.o xvid_rc.o
OBJS-$(CONFIG_AMR) += amr.o
OBJS-$(CONFIG_AMR_NB) += amr_float/sp_dec.o \
@@ -293,7 +293,7 @@ OBJS-$(CONFIG_AMR_WB) += amrwb_float/dec_acelp.o \
amrwb_float/if_rom.o
OBJS-$(CONFIG_AAC_PARSER) += parser.o
-OBJS-$(CONFIG_AC3_PARSER) += parser.o
+OBJS-$(CONFIG_AC3_PARSER) += parser.o ac3.o
OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs.o parser.o
OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsubdec.o
OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsubdec.o
@@ -317,7 +317,7 @@ ifneq ($(CONFIG_SWSCALER),yes)
OBJS += imgresample.o
endif
-# i386 mmx specific stuff
+# processor-specific code
ifeq ($(TARGET_MMX),yes)
OBJS += i386/fdct_mmx.o \
i386/cputest.o \
@@ -331,17 +331,12 @@ OBJS += i386/fdct_mmx.o \
i386/vp3dsp_sse2.o \
i386/fft_3dn.o \
i386/fft_3dn2.o \
- i386/snowdsp_mmx.o \
-ifeq ($(CONFIG_GPL),yes)
-OBJS += i386/idct_mmx.o
-endif
-ifeq ($(CONFIG_CAVS_DECODER),yes)
-OBJS += i386/cavsdsp_mmx.o
-endif
+OBJS-$(CONFIG_GPL) += i386/idct_mmx.o
+OBJS-$(CONFIG_CAVS_DECODER) += i386/cavsdsp_mmx.o
+OBJS-$(CONFIG_SNOW_DECODER) += i386/snowdsp_mmx.o
endif
-# armv4l specific stuff
ASM_OBJS-$(TARGET_ARCH_ARMV4L) += armv4l/jrevdct_arm.o \
armv4l/simple_idct_arm.o \
armv4l/dsputil_arm_s.o \
@@ -353,16 +348,16 @@ OBJS-$(TARGET_IWMMXT) += armv4l/dsputil_iwmmxt.o \
armv4l/mpegvideo_iwmmxt.o \
ASM_OBJS-$(TARGET_ARMV5TE) += armv4l/simple_idct_armv5te.o \
+ armv4l/mpegvideo_armv5te.o \
+
+ASM_OBJS-$(HAVE_ARMV6) += armv4l/simple_idct_armv6.o
-# sun sparc
OBJS-$(TARGET_ARCH_SPARC) += sparc/dsputil_vis.o \
sparc/dsputil_vis.o: CFLAGS += -mcpu=ultrasparc -mtune=ultrasparc
-# sun mediaLib specific stuff
OBJS-$(HAVE_MLIB) += mlib/dsputil_mlib.o \
-# alpha specific stuff
OBJS-$(TARGET_ARCH_ALPHA) += alpha/dsputil_alpha.o \
alpha/mpegvideo_alpha.o \
alpha/simple_idct_alpha.o \
@@ -399,21 +394,19 @@ endif
OBJS-$(TARGET_ARCH_BFIN) += bfin/dsputil_bfin.o \
-CFLAGS += $(CFLAGS-yes)
-OBJS += $(OBJS-yes)
-ASM_OBJS += $(ASM_OBJS-yes)
+ASM_OBJS-$(TARGET_ARCH_BFIN) += bfin/pixels_bfin.o \
+ bfin/idct_bfin.o \
+ bfin/fdct_bfin.o \
EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
NAME=avcodec
-ifeq ($(BUILD_SHARED),yes)
LIBVERSION=$(LAVCVERSION)
LIBMAJOR=$(LAVCMAJOR)
-endif
-TESTS= imgresample-test fft-test
+TESTS= imgresample-test fft-test dct-test
ifeq ($(TARGET_ARCH_X86),yes)
-TESTS+= cpuid_test dct-test motion-test
+TESTS+= cpuid_test motion-test
endif
include ../common.mak
@@ -433,7 +426,6 @@ clean::
ps2/*.o ps2/*~ \
sh4/*.o sh4/*~ \
sparc/*.o sparc/*~ \
- liba52/*.o liba52/*~ \
amr_float/*.o \
apiexample $(TESTS)
-$(MAKE) -C amr clean
diff --git a/contrib/ffmpeg/libavcodec/a52dec.c b/contrib/ffmpeg/libavcodec/a52dec.c
index dec25138e..c2da2283d 100644
--- a/contrib/ffmpeg/libavcodec/a52dec.c
+++ b/contrib/ffmpeg/libavcodec/a52dec.c
@@ -1,5 +1,5 @@
/*
- * A52 decoder
+ * A52 decoder using liba52
* Copyright (c) 2001 Fabrice Bellard.
*
* This file is part of FFmpeg.
@@ -21,13 +21,13 @@
/**
* @file a52dec.c
- * A52 decoder.
+ * A52 decoder using liba52
*/
#include "avcodec.h"
-#include "liba52/a52.h"
+#include <a52dec/a52.h>
-#ifdef CONFIG_A52BIN
+#ifdef CONFIG_LIBA52BIN
#include <dlfcn.h>
static const char* liba52name = "liba52.so.0";
#endif
@@ -70,7 +70,7 @@ typedef struct AC3DecodeState {
} AC3DecodeState;
-#ifdef CONFIG_A52BIN
+#ifdef CONFIG_LIBA52BIN
static void* dlsymm(void* handle, const char* symbol)
{
void* f = dlsym(handle, symbol);
@@ -84,7 +84,7 @@ static int a52_decode_init(AVCodecContext *avctx)
{
AC3DecodeState *s = avctx->priv_data;
-#ifdef CONFIG_A52BIN
+#ifdef CONFIG_LIBA52BIN
s->handle = dlopen(liba52name, RTLD_LAZY);
if (!s->handle)
{
@@ -104,7 +104,6 @@ static int a52_decode_init(AVCodecContext *avctx)
return -1;
}
#else
- /* static linked version */
s->handle = 0;
s->a52_init = a52_init;
s->a52_samples = a52_samples;
@@ -162,6 +161,8 @@ static int a52_decode_frame(AVCodecContext *avctx,
2, 1, 2, 3, 3, 4, 4, 5
};
+ *data_size= 0;
+
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
@@ -217,6 +218,7 @@ static int a52_decode_frame(AVCodecContext *avctx,
level = 1;
if (s->a52_frame(s->state, s->inbuf, &flags, &level, 384)) {
fail:
+ av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n");
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
continue;
@@ -239,13 +241,13 @@ static int a52_decode_end(AVCodecContext *avctx)
{
AC3DecodeState *s = avctx->priv_data;
s->a52_free(s->state);
-#ifdef CONFIG_A52BIN
+#ifdef CONFIG_LIBA52BIN
dlclose(s->handle);
#endif
return 0;
}
-AVCodec ac3_decoder = {
+AVCodec liba52_decoder = {
"ac3",
CODEC_TYPE_AUDIO,
CODEC_ID_AC3,
diff --git a/contrib/ffmpeg/libavcodec/aasc.c b/contrib/ffmpeg/libavcodec/aasc.c
index 6c8e3166e..8f26fae87 100644
--- a/contrib/ffmpeg/libavcodec/aasc.c
+++ b/contrib/ffmpeg/libavcodec/aasc.c
@@ -52,7 +52,6 @@ static int aasc_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
avctx->pix_fmt = PIX_FMT_BGR24;
- avctx->has_b_frames = 0;
s->frame.data[0] = NULL;
return 0;
diff --git a/contrib/ffmpeg/libavcodec/ac3.c b/contrib/ffmpeg/libavcodec/ac3.c
new file mode 100644
index 000000000..3749d02f0
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/ac3.c
@@ -0,0 +1,287 @@
+/*
+ * Common code between AC3 encoder and decoder
+ * Copyright (c) 2000 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
+ */
+
+/**
+ * @file ac3.c
+ * Common code between AC3 encoder and decoder.
+ */
+
+#include "avcodec.h"
+#include "ac3.h"
+#include "ac3tab.h"
+#include "bitstream.h"
+
+static inline int calc_lowcomp1(int a, int b0, int b1, int c)
+{
+ if ((b0 + 256) == b1) {
+ a = c;
+ } else if (b0 > b1) {
+ a = FFMAX(a - 64, 0);
+ }
+ return a;
+}
+
+static inline int calc_lowcomp(int a, int b0, int b1, int bin)
+{
+ if (bin < 7) {
+ return calc_lowcomp1(a, b0, b1, 384);
+ } else if (bin < 20) {
+ return calc_lowcomp1(a, b0, b1, 320);
+ } else {
+ return FFMAX(a - 128, 0);
+ }
+}
+
+void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
+ int16_t *bndpsd)
+{
+ int bin, i, j, k, end1, v;
+
+ /* exponent mapping to PSD */
+ for(bin=start;bin<end;bin++) {
+ psd[bin]=(3072 - (exp[bin] << 7));
+ }
+
+ /* PSD integration */
+ j=start;
+ k=masktab[start];
+ do {
+ v=psd[j];
+ j++;
+ end1 = FFMIN(bndtab[k+1], end);
+ for(i=j;i<end1;i++) {
+ /* logadd */
+ int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255);
+ v = FFMAX(v, psd[j]) + latab[adr];
+ j++;
+ }
+ bndpsd[k]=v;
+ k++;
+ } while (end > bndtab[k]);
+}
+
+void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
+ int start, int end, int fgain, int is_lfe,
+ int deltbae, int deltnseg, uint8_t *deltoffst,
+ uint8_t *deltlen, uint8_t *deltba,
+ int16_t *mask)
+{
+ int16_t excite[50]; /* excitation */
+ int bin, k;
+ int bndstrt, bndend, begin, end1, tmp;
+ int lowcomp, fastleak, slowleak;
+
+ /* excitation function */
+ bndstrt = masktab[start];
+ bndend = masktab[end-1] + 1;
+
+ if (bndstrt == 0) {
+ lowcomp = 0;
+ lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1], 384);
+ excite[0] = bndpsd[0] - fgain - lowcomp;
+ lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2], 384);
+ excite[1] = bndpsd[1] - fgain - lowcomp;
+ begin = 7;
+ for (bin = 2; bin < 7; bin++) {
+ if (!(is_lfe && bin == 6))
+ lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1], 384);
+ fastleak = bndpsd[bin] - fgain;
+ slowleak = bndpsd[bin] - s->sgain;
+ excite[bin] = fastleak - lowcomp;
+ if (!(is_lfe && bin == 6)) {
+ if (bndpsd[bin] <= bndpsd[bin+1]) {
+ begin = bin + 1;
+ break;
+ }
+ }
+ }
+
+ end1=bndend;
+ if (end1 > 22) end1=22;
+
+ for (bin = begin; bin < end1; bin++) {
+ if (!(is_lfe && bin == 6))
+ lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
+
+ fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
+ slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
+ excite[bin] = FFMAX(fastleak - lowcomp, slowleak);
+ }
+ begin = 22;
+ } else {
+ /* coupling channel */
+ begin = bndstrt;
+
+ fastleak = (s->cplfleak << 8) + 768;
+ slowleak = (s->cplsleak << 8) + 768;
+ }
+
+ for (bin = begin; bin < bndend; bin++) {
+ fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain);
+ slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain);
+ excite[bin] = FFMAX(fastleak, slowleak);
+ }
+
+ /* compute masking curve */
+
+ for (bin = bndstrt; bin < bndend; bin++) {
+ tmp = s->dbknee - bndpsd[bin];
+ if (tmp > 0) {
+ excite[bin] += tmp >> 2;
+ }
+ mask[bin] = FFMAX(hth[bin >> s->halfratecod][s->fscod], excite[bin]);
+ }
+
+ /* delta bit allocation */
+
+ if (deltbae == 0 || deltbae == 1) {
+ int band, seg, delta;
+ band = 0;
+ for (seg = 0; seg < deltnseg; seg++) {
+ band += deltoffst[seg];
+ if (deltba[seg] >= 4) {
+ delta = (deltba[seg] - 3) << 7;
+ } else {
+ delta = (deltba[seg] - 4) << 7;
+ }
+ for (k = 0; k < deltlen[seg]; k++) {
+ mask[band] += delta;
+ band++;
+ }
+ }
+ }
+}
+
+void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
+ int snroffset, int floor, uint8_t *bap)
+{
+ int i, j, k, end1, v, address;
+
+ /* special case, if snroffset is -960, set all bap's to zero */
+ if(snroffset == -960) {
+ memset(bap, 0, 256);
+ return;
+ }
+
+ i = start;
+ j = masktab[start];
+ do {
+ v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor;
+ end1 = FFMIN(bndtab[j] + bndsz[j], end);
+ for (k = i; k < end1; k++) {
+ address = av_clip((psd[i] - v) >> 5, 0, 63);
+ bap[i] = baptab[address];
+ i++;
+ }
+ } while (end > bndtab[j++]);
+}
+
+/* AC3 bit allocation. The algorithm is the one described in the AC3
+ spec. */
+void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
+ int8_t *exp, int start, int end,
+ int snroffset, int fgain, int is_lfe,
+ int deltbae,int deltnseg,
+ uint8_t *deltoffst, uint8_t *deltlen,
+ uint8_t *deltba)
+{
+ int16_t psd[256]; /* scaled exponents */
+ int16_t bndpsd[50]; /* interpolated exponents */
+ int16_t mask[50]; /* masking value */
+
+ ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, bndpsd);
+
+ ff_ac3_bit_alloc_calc_mask(s, bndpsd, start, end, fgain, is_lfe,
+ deltbae, deltnseg, deltoffst, deltlen, deltba,
+ mask);
+
+ ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snroffset, s->floor, bap);
+}
+
+/**
+ * Initializes some tables.
+ * note: This function must remain thread safe because it is called by the
+ * AVParser init code.
+ */
+void ac3_common_init(void)
+{
+ int i, j, k, l, v;
+ /* compute bndtab and masktab from bandsz */
+ k = 0;
+ l = 0;
+ for(i=0;i<50;i++) {
+ bndtab[i] = l;
+ v = bndsz[i];
+ for(j=0;j<v;j++) masktab[k++]=i;
+ l += v;
+ }
+ bndtab[50] = l;
+}
+
+int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
+{
+ GetBitContext gbc;
+
+ memset(hdr, 0, sizeof(*hdr));
+
+ init_get_bits(&gbc, buf, 54);
+
+ hdr->sync_word = get_bits(&gbc, 16);
+ if(hdr->sync_word != 0x0B77)
+ return -1;
+
+ /* read ahead to bsid to make sure this is AC-3, not E-AC-3 */
+ hdr->bsid = show_bits_long(&gbc, 29) & 0x1F;
+ if(hdr->bsid > 10)
+ return -2;
+
+ hdr->crc1 = get_bits(&gbc, 16);
+ hdr->fscod = get_bits(&gbc, 2);
+ if(hdr->fscod == 3)
+ return -3;
+
+ hdr->frmsizecod = get_bits(&gbc, 6);
+ if(hdr->frmsizecod > 37)
+ return -4;
+
+ skip_bits(&gbc, 5); // skip bsid, already got it
+
+ hdr->bsmod = get_bits(&gbc, 3);
+ hdr->acmod = get_bits(&gbc, 3);
+ if((hdr->acmod & 1) && hdr->acmod != 1) {
+ hdr->cmixlev = get_bits(&gbc, 2);
+ }
+ if(hdr->acmod & 4) {
+ hdr->surmixlev = get_bits(&gbc, 2);
+ }
+ if(hdr->acmod == 2) {
+ hdr->dsurmod = get_bits(&gbc, 2);
+ }
+ hdr->lfeon = get_bits1(&gbc);
+
+ hdr->halfratecod = FFMAX(hdr->bsid, 8) - 8;
+ hdr->sample_rate = ff_ac3_freqs[hdr->fscod] >> hdr->halfratecod;
+ hdr->bit_rate = (ff_ac3_bitratetab[hdr->frmsizecod>>1] * 1000) >> hdr->halfratecod;
+ hdr->channels = ff_ac3_channels[hdr->acmod] + hdr->lfeon;
+ hdr->frame_size = ff_ac3_frame_sizes[hdr->frmsizecod][hdr->fscod] * 2;
+
+ return 0;
+}
diff --git a/contrib/ffmpeg/libavcodec/ac3.h b/contrib/ffmpeg/libavcodec/ac3.h
index 5daa9750f..ae53a80c3 100644
--- a/contrib/ffmpeg/libavcodec/ac3.h
+++ b/contrib/ffmpeg/libavcodec/ac3.h
@@ -45,19 +45,125 @@ typedef struct AC3BitAllocParameters {
int cplfleak, cplsleak;
} AC3BitAllocParameters;
-#if 0
-extern const uint16_t ac3_freqs[3];
-extern const uint16_t ac3_bitratetab[19];
-extern const int16_t ac3_window[256];
-extern const uint8_t sdecaytab[4];
-extern const uint8_t fdecaytab[4];
-extern const uint16_t sgaintab[4];
-extern const uint16_t dbkneetab[4];
-extern const uint16_t floortab[8];
-extern const uint16_t fgaintab[8];
-#endif
+/**
+ * @struct AC3HeaderInfo
+ * Coded AC-3 header values up to the lfeon element, plus derived values.
+ */
+typedef struct {
+ /** @defgroup coded Coded elements
+ * @{
+ */
+ uint16_t sync_word;
+ uint16_t crc1;
+ uint8_t fscod;
+ uint8_t frmsizecod;
+ uint8_t bsid;
+ uint8_t bsmod;
+ uint8_t acmod;
+ uint8_t cmixlev;
+ uint8_t surmixlev;
+ uint8_t dsurmod;
+ uint8_t lfeon;
+ /** @} */
+
+ /** @defgroup derived Derived values
+ * @{
+ */
+ uint8_t halfratecod;
+ uint16_t sample_rate;
+ uint32_t bit_rate;
+ uint8_t channels;
+ uint16_t frame_size;
+ /** @} */
+} AC3HeaderInfo;
+
+/**
+ * Parses AC-3 frame header.
+ * Parses the header up to the lfeon element, which is the first 52 or 54 bits
+ * depending on the audio coding mode.
+ * @param buf[in] Array containing the first 7 bytes of the frame.
+ * @param hdr[out] 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(const uint8_t buf[7], AC3HeaderInfo *hdr);
+
+extern const uint16_t ff_ac3_frame_sizes[38][3];
+extern const uint8_t ff_ac3_channels[8];
+extern const uint16_t ff_ac3_freqs[3];
+extern const uint16_t ff_ac3_bitratetab[19];
+extern const int16_t ff_ac3_window[256];
+extern const uint8_t ff_sdecaytab[4];
+extern const uint8_t ff_fdecaytab[4];
+extern const uint16_t ff_sgaintab[4];
+extern const uint16_t ff_dbkneetab[4];
+extern const int16_t ff_floortab[8];
+extern const uint16_t ff_fgaintab[8];
void ac3_common_init(void);
+
+/**
+ * Calculates the log power-spectral density of the input signal.
+ * This gives a rough estimate of signal power in the frequency domain by using
+ * the spectral envelope (exponents). The psd is also separately grouped
+ * into critical bands for use in the calculating the masking curve.
+ * 128 units in psd = -6 dB. The dbknee parameter in AC3BitAllocParameters
+ * determines the reference level.
+ *
+ * @param[in] exp frequency coefficient exponents
+ * @param[in] start starting bin location
+ * @param[in] end ending bin location
+ * @param[out] psd signal power for each frequency bin
+ * @param[out] bndpsd signal power for each critical band
+ */
+void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
+ int16_t *bndpsd);
+
+/**
+ * Calculates the masking curve.
+ * First, the excitation is calculated using parameters in \p s and the signal
+ * power in each critical band. The excitation is compared with a predefined
+ * hearing threshold table to produce the masking curve. If delta bit
+ * allocation information is provided, it is used for adjusting the masking
+ * curve, usually to give a closer match to a better psychoacoustic model.
+ *
+ * @param[in] s adjustable bit allocation parameters
+ * @param[in] bndpsd signal power for each critical band
+ * @param[in] start starting bin location
+ * @param[in] end ending bin location
+ * @param[in] fgain fast gain (estimated signal-to-mask ratio)
+ * @param[in] is_lfe whether or not the channel being processed is the LFE
+ * @param[in] deltbae delta bit allocation exists (none, reuse, or new)
+ * @param[in] deltnseg number of delta segments
+ * @param[in] deltoffst location offsets for each segment
+ * @param[in] deltlen length of each segment
+ * @param[in] deltba delta bit allocation for each segment
+ * @param[out] mask calculated masking curve
+ */
+void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
+ int start, int end, int fgain, int is_lfe,
+ int deltbae, int deltnseg, uint8_t *deltoffst,
+ uint8_t *deltlen, uint8_t *deltba,
+ int16_t *mask);
+
+/**
+ * Calculates bit allocation pointers.
+ * The SNR is the difference between the masking curve and the signal. AC-3
+ * uses this value for each frequency bin to allocate bits. The \p snroffset
+ * parameter is a global adjustment to the SNR for all bins.
+ *
+ * @param[in] mask masking curve
+ * @param[in] psd signal power for each frequency bin
+ * @param[in] start starting bin location
+ * @param[in] end ending bin location
+ * @param[in] snroffset SNR adjustment
+ * @param[in] floor noise floor
+ * @param[out] bap bit allocation pointers
+ */
+void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
+ int snroffset, int floor, uint8_t *bap);
+
void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
int8_t *exp, int start, int end,
int snroffset, int fgain, int is_lfe,
diff --git a/contrib/ffmpeg/libavcodec/ac3dec.c b/contrib/ffmpeg/libavcodec/ac3dec.c
deleted file mode 100644
index b6bebfb59..000000000
--- a/contrib/ffmpeg/libavcodec/ac3dec.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * AC3 decoder
- * Copyright (c) 2001 Fabrice Bellard.
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file ac3dec.c
- * AC3 decoder.
- */
-
-//#define DEBUG
-
-#include "avcodec.h"
-#include "libac3/ac3.h"
-
-/* currently, I use libac3 which is Copyright (C) Aaron Holtzman and
- released under the GPL license. I may reimplement it someday... */
-typedef struct AC3DecodeState {
- uint8_t inbuf[4096]; /* input buffer */
- uint8_t *inbuf_ptr;
- int frame_size;
- int flags;
- int channels;
- ac3_state_t state;
-} AC3DecodeState;
-
-static int ac3_decode_init(AVCodecContext *avctx)
-{
- AC3DecodeState *s = avctx->priv_data;
-
- ac3_init ();
- s->inbuf_ptr = s->inbuf;
- s->frame_size = 0;
- return 0;
-}
-
-stream_samples_t samples;
-
-/**** the following two functions comes from ac3dec */
-static inline int blah (int32_t i)
-{
- if (i > 0x43c07fff)
- return 32767;
- else if (i < 0x43bf8000)
- return -32768;
- else
- return i - 0x43c00000;
-}
-
-static inline void float_to_int (float * _f, int16_t * s16, int nchannels)
-{
- int i, j, c;
- int32_t * f = (int32_t *) _f; // XXX assumes IEEE float format
-
- j = 0;
- nchannels *= 256;
- for (i = 0; i < 256; i++) {
- for (c = 0; c < nchannels; c += 256)
- s16[j++] = blah (f[i + c]);
- }
-}
-
-/**** end */
-
-#define HEADER_SIZE 7
-
-static int ac3_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- uint8_t *buf, int buf_size)
-{
- AC3DecodeState *s = avctx->priv_data;
- uint8_t *buf_ptr;
- int flags, i, len;
- int sample_rate, bit_rate;
- short *out_samples = data;
- float level;
- static const int ac3_channels[8] = {
- 2, 1, 2, 3, 3, 4, 4, 5
- };
-
- buf_ptr = buf;
- while (buf_size > 0) {
- len = s->inbuf_ptr - s->inbuf;
- if (s->frame_size == 0) {
- /* no header seen : find one. We need at least 7 bytes to parse it */
- len = HEADER_SIZE - len;
- if (len > buf_size)
- len = buf_size;
- memcpy(s->inbuf_ptr, buf_ptr, len);
- buf_ptr += len;
- s->inbuf_ptr += len;
- buf_size -= len;
- if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) {
- len = ac3_syncinfo (s->inbuf, &s->flags, &sample_rate, &bit_rate);
- if (len == 0) {
- /* no sync found : move by one byte (inefficient, but simple!) */
- memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1);
- s->inbuf_ptr--;
- } else {
- s->frame_size = len;
- /* update codec info */
- avctx->sample_rate = sample_rate;
- s->channels = ac3_channels[s->flags & 7];
- if (s->flags & AC3_LFE)
- s->channels++;
- if (avctx->channels == 0)
- /* No specific number of channel requested */
- avctx->channels = s->channels;
- else if (s->channels < avctx->channels) {
- av_log( avctx, AV_LOG_INFO, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len);
- avctx->channels = s->channels;
- }
- avctx->bit_rate = bit_rate;
- }
- }
- } else if (len < s->frame_size) {
- len = s->frame_size - len;
- if (len > buf_size)
- len = buf_size;
-
- memcpy(s->inbuf_ptr, buf_ptr, len);
- buf_ptr += len;
- s->inbuf_ptr += len;
- buf_size -= len;
- } else {
- flags = s->flags;
- if (avctx->channels == 1)
- flags = AC3_MONO;
- else if (avctx->channels == 2)
- flags = AC3_STEREO;
- else
- flags |= AC3_ADJUST_LEVEL;
- level = 1;
- if (ac3_frame (&s->state, s->inbuf, &flags, &level, 384)) {
- fail:
- s->inbuf_ptr = s->inbuf;
- s->frame_size = 0;
- continue;
- }
- for (i = 0; i < 6; i++) {
- if (ac3_block (&s->state))
- goto fail;
- float_to_int (*samples, out_samples + i * 256 * avctx->channels, avctx->channels);
- }
- s->inbuf_ptr = s->inbuf;
- s->frame_size = 0;
- *data_size = 6 * avctx->channels * 256 * sizeof(int16_t);
- break;
- }
- }
- return buf_ptr - buf;
-}
-
-static int ac3_decode_end(AVCodecContext *s)
-{
- return 0;
-}
-
-AVCodec ac3_decoder = {
- "ac3",
- CODEC_TYPE_AUDIO,
- CODEC_ID_AC3,
- sizeof(AC3DecodeState),
- ac3_decode_init,
- NULL,
- ac3_decode_end,
- ac3_decode_frame,
-};
diff --git a/contrib/ffmpeg/libavcodec/ac3enc.c b/contrib/ffmpeg/libavcodec/ac3enc.c
index c8c8920ed..5161b61e4 100644
--- a/contrib/ffmpeg/libavcodec/ac3enc.c
+++ b/contrib/ffmpeg/libavcodec/ac3enc.c
@@ -62,7 +62,11 @@ typedef struct AC3EncodeContext {
int mant1_cnt, mant2_cnt, mant4_cnt;
} AC3EncodeContext;
-#include "ac3tab.h"
+static int16_t costab[64];
+static int16_t sintab[64];
+static int16_t fft_rev[512];
+static int16_t xcos1[128];
+static int16_t xsin1[128];
#define MDCT_NBITS 9
#define N (1 << MDCT_NBITS)
@@ -83,212 +87,6 @@ static inline int16_t fix15(float a)
return v;
}
-static inline int calc_lowcomp1(int a, int b0, int b1)
-{
- if ((b0 + 256) == b1) {
- a = 384 ;
- } else if (b0 > b1) {
- a = a - 64;
- if (a < 0) a=0;
- }
- return a;
-}
-
-static inline int calc_lowcomp(int a, int b0, int b1, int bin)
-{
- if (bin < 7) {
- if ((b0 + 256) == b1) {
- a = 384 ;
- } else if (b0 > b1) {
- a = a - 64;
- if (a < 0) a=0;
- }
- } else if (bin < 20) {
- if ((b0 + 256) == b1) {
- a = 320 ;
- } else if (b0 > b1) {
- a= a - 64;
- if (a < 0) a=0;
- }
- } else {
- a = a - 128;
- if (a < 0) a=0;
- }
- return a;
-}
-
-/* AC3 bit allocation. The algorithm is the one described in the AC3
- spec. */
-void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
- int8_t *exp, int start, int end,
- int snroffset, int fgain, int is_lfe,
- int deltbae,int deltnseg,
- uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba)
-{
- int bin,i,j,k,end1,v,v1,bndstrt,bndend,lowcomp,begin;
- int fastleak,slowleak,address,tmp;
- int16_t psd[256]; /* scaled exponents */
- int16_t bndpsd[50]; /* interpolated exponents */
- int16_t excite[50]; /* excitation */
- int16_t mask[50]; /* masking value */
-
- /* exponent mapping to PSD */
- for(bin=start;bin<end;bin++) {
- psd[bin]=(3072 - (exp[bin] << 7));
- }
-
- /* PSD integration */
- j=start;
- k=masktab[start];
- do {
- v=psd[j];
- j++;
- end1=bndtab[k+1];
- if (end1 > end) end1=end;
- for(i=j;i<end1;i++) {
- int c,adr;
- /* logadd */
- v1=psd[j];
- c=v-v1;
- if (c >= 0) {
- adr=c >> 1;
- if (adr > 255) adr=255;
- v=v + latab[adr];
- } else {
- adr=(-c) >> 1;
- if (adr > 255) adr=255;
- v=v1 + latab[adr];
- }
- j++;
- }
- bndpsd[k]=v;
- k++;
- } while (end > bndtab[k]);
-
- /* excitation function */
- bndstrt = masktab[start];
- bndend = masktab[end-1] + 1;
-
- if (bndstrt == 0) {
- lowcomp = 0;
- lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1]) ;
- excite[0] = bndpsd[0] - fgain - lowcomp ;
- lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2]) ;
- excite[1] = bndpsd[1] - fgain - lowcomp ;
- begin = 7 ;
- for (bin = 2; bin < 7; bin++) {
- if (!(is_lfe && bin == 6))
- lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1]) ;
- fastleak = bndpsd[bin] - fgain ;
- slowleak = bndpsd[bin] - s->sgain ;
- excite[bin] = fastleak - lowcomp ;
- if (!(is_lfe && bin == 6)) {
- if (bndpsd[bin] <= bndpsd[bin+1]) {
- begin = bin + 1 ;
- break ;
- }
- }
- }
-
- end1=bndend;
- if (end1 > 22) end1=22;
-
- for (bin = begin; bin < end1; bin++) {
- if (!(is_lfe && bin == 6))
- lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin) ;
-
- fastleak -= s->fdecay ;
- v = bndpsd[bin] - fgain;
- if (fastleak < v) fastleak = v;
-
- slowleak -= s->sdecay ;
- v = bndpsd[bin] - s->sgain;
- if (slowleak < v) slowleak = v;
-
- v=fastleak - lowcomp;
- if (slowleak > v) v=slowleak;
-
- excite[bin] = v;
- }
- begin = 22;
- } else {
- /* coupling channel */
- begin = bndstrt;
-
- fastleak = (s->cplfleak << 8) + 768;
- slowleak = (s->cplsleak << 8) + 768;
- }
-
- for (bin = begin; bin < bndend; bin++) {
- fastleak -= s->fdecay ;
- v = bndpsd[bin] - fgain;
- if (fastleak < v) fastleak = v;
- slowleak -= s->sdecay ;
- v = bndpsd[bin] - s->sgain;
- if (slowleak < v) slowleak = v;
-
- v=fastleak;
- if (slowleak > v) v = slowleak;
- excite[bin] = v;
- }
-
- /* compute masking curve */
-
- for (bin = bndstrt; bin < bndend; bin++) {
- v1 = excite[bin];
- tmp = s->dbknee - bndpsd[bin];
- if (tmp > 0) {
- v1 += tmp >> 2;
- }
- v=hth[bin >> s->halfratecod][s->fscod];
- if (v1 > v) v=v1;
- mask[bin] = v;
- }
-
- /* delta bit allocation */
-
- if (deltbae == 0 || deltbae == 1) {
- int band, seg, delta;
- band = 0 ;
- for (seg = 0; seg < deltnseg; seg++) {
- band += deltoffst[seg] ;
- if (deltba[seg] >= 4) {
- delta = (deltba[seg] - 3) << 7;
- } else {
- delta = (deltba[seg] - 4) << 7;
- }
- for (k = 0; k < deltlen[seg]; k++) {
- mask[band] += delta ;
- band++ ;
- }
- }
- }
-
- /* compute bit allocation */
-
- i = start ;
- j = masktab[start] ;
- do {
- v=mask[j];
- v -= snroffset ;
- v -= s->floor ;
- if (v < 0) v = 0;
- v &= 0x1fe0 ;
- v += s->floor ;
-
- end1=bndtab[j] + bndsz[j];
- if (end1 > end) end1=end;
-
- for (k = i; k < end1; k++) {
- address = (psd[i] - v) >> 5 ;
- if (address < 0) address=0;
- else if (address > 63) address=63;
- bap[i] = baptab[address];
- i++;
- }
- } while (end > bndtab[j++]) ;
-}
-
typedef struct IComplex {
short re,im;
} IComplex;
@@ -633,13 +431,45 @@ static int compute_mantissa_size(AC3EncodeContext *s, uint8_t *m, int nb_coefs)
}
+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])
+{
+ int blk, ch;
+ int16_t bndpsd[NB_BLOCKS][AC3_MAX_CHANNELS][50];
+
+ 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], bndpsd[blk][ch]);
+ ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, bndpsd[blk][ch],
+ 0, s->nb_coefs[ch],
+ ff_fgaintab[s->fgaincod[ch]],
+ ch == s->lfe_channel,
+ 2, 0, NULL, NULL, NULL,
+ mask[blk][ch]);
+ }
+ }
+ }
+}
+
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],
- uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
- uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
int frame_bits, int csnroffst, int fsnroffst)
{
int i, ch;
+ int snroffset;
+
+ snroffset = (((csnroffst - 15) << 4) + fsnroffst) << 2;
/* compute size */
for(i=0;i<NB_BLOCKS;i++) {
@@ -647,14 +477,9 @@ static int bit_alloc(AC3EncodeContext *s,
s->mant2_cnt = 0;
s->mant4_cnt = 0;
for(ch=0;ch<s->nb_all_channels;ch++) {
- ac3_parametric_bit_allocation(&s->bit_alloc,
- bap[i][ch], (int8_t *)encoded_exp[i][ch],
- 0, s->nb_coefs[ch],
- (((csnroffst-15) << 4) +
- fsnroffst) << 2,
- fgaintab[s->fgaincod[ch]],
- ch == s->lfe_channel,
- 2, 0, NULL, NULL, NULL);
+ ff_ac3_bit_alloc_calc_bap(mask[i][ch], psd[i][ch], 0,
+ s->nb_coefs[ch], snroffset,
+ s->bit_alloc.floor, bap[i][ch]);
frame_bits += compute_mantissa_size(s, bap[i][ch],
s->nb_coefs[ch]);
}
@@ -678,6 +503,8 @@ static int compute_bit_allocation(AC3EncodeContext *s,
int i, ch;
int csnroffst, fsnroffst;
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 int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };
/* init default parameters */
@@ -692,11 +519,11 @@ static int compute_bit_allocation(AC3EncodeContext *s,
/* compute real values */
s->bit_alloc.fscod = s->fscod;
s->bit_alloc.halfratecod = s->halfratecod;
- s->bit_alloc.sdecay = sdecaytab[s->sdecaycod] >> s->halfratecod;
- s->bit_alloc.fdecay = fdecaytab[s->fdecaycod] >> s->halfratecod;
- s->bit_alloc.sgain = sgaintab[s->sgaincod];
- s->bit_alloc.dbknee = dbkneetab[s->dbkneecod];
- s->bit_alloc.floor = floortab[s->floorcod];
+ s->bit_alloc.sdecay = ff_sdecaytab[s->sdecaycod] >> s->halfratecod;
+ s->bit_alloc.fdecay = ff_fdecaytab[s->fdecaycod] >> s->halfratecod;
+ s->bit_alloc.sgain = ff_sgaintab[s->sgaincod];
+ s->bit_alloc.dbknee = ff_dbkneetab[s->dbkneecod];
+ s->bit_alloc.floor = ff_floortab[s->floorcod];
/* header size */
frame_bits += 65;
@@ -735,38 +562,41 @@ 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);
+
/* now the big work begins : do the bit allocation. Modify the snr
offset until we can pack everything in the requested frame size */
csnroffst = s->csnroffst;
while (csnroffst >= 0 &&
- bit_alloc(s, bap, encoded_exp, exp_strategy, frame_bits, csnroffst, 0) < 0)
+ bit_alloc(s, mask, psd, bap, frame_bits, csnroffst, 0) < 0)
csnroffst -= SNR_INC1;
if (csnroffst < 0) {
av_log(NULL, AV_LOG_ERROR, "Bit allocation failed, try increasing the bitrate, -ab 384 for example!\n");
return -1;
}
while ((csnroffst + SNR_INC1) <= 63 &&
- bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits,
+ bit_alloc(s, mask, psd, bap1, frame_bits,
csnroffst + SNR_INC1, 0) >= 0) {
csnroffst += SNR_INC1;
memcpy(bap, bap1, sizeof(bap1));
}
while ((csnroffst + 1) <= 63 &&
- bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, csnroffst + 1, 0) >= 0) {
+ bit_alloc(s, mask, psd, bap1, frame_bits, csnroffst + 1, 0) >= 0) {
csnroffst++;
memcpy(bap, bap1, sizeof(bap1));
}
fsnroffst = 0;
while ((fsnroffst + SNR_INC1) <= 15 &&
- bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits,
+ bit_alloc(s, mask, psd, bap1, frame_bits,
csnroffst, fsnroffst + SNR_INC1) >= 0) {
fsnroffst += SNR_INC1;
memcpy(bap, bap1, sizeof(bap1));
}
while ((fsnroffst + 1) <= 15 &&
- bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits,
+ bit_alloc(s, mask, psd, bap1, frame_bits,
csnroffst, fsnroffst + 1) >= 0) {
fsnroffst++;
memcpy(bap, bap1, sizeof(bap1));
@@ -794,22 +624,6 @@ static int compute_bit_allocation(AC3EncodeContext *s,
return 0;
}
-void ac3_common_init(void)
-{
- int i, j, k, l, v;
- /* compute bndtab and masktab from bandsz */
- k = 0;
- l = 0;
- for(i=0;i<50;i++) {
- bndtab[i] = l;
- v = bndsz[i];
- for(j=0;j<v;j++) masktab[k++]=i;
- l += v;
- }
- bndtab[50] = l;
-}
-
-
static int AC3_encode_init(AVCodecContext *avctx)
{
int freq = avctx->sample_rate;
@@ -829,6 +643,8 @@ static int AC3_encode_init(AVCodecContext *avctx)
avctx->frame_size = AC3_FRAME_SIZE;
+ ac3_common_init();
+
/* number of channels */
if (channels < 1 || channels > 6)
return -1;
@@ -841,7 +657,7 @@ static int AC3_encode_init(AVCodecContext *avctx)
/* frequency */
for(i=0;i<3;i++) {
for(j=0;j<3;j++)
- if ((ac3_freqs[j] >> i) == freq)
+ if ((ff_ac3_freqs[j] >> i) == freq)
goto found;
}
return -1;
@@ -855,14 +671,14 @@ static int AC3_encode_init(AVCodecContext *avctx)
/* bitrate & frame size */
bitrate /= 1000;
for(i=0;i<19;i++) {
- if ((ac3_bitratetab[i] >> s->halfratecod) == bitrate)
+ if ((ff_ac3_bitratetab[i] >> s->halfratecod) == bitrate)
break;
}
if (i == 19)
return -1;
s->bit_rate = bitrate;
s->frmsizecod = i << 1;
- s->frame_size_min = (bitrate * 1000 * AC3_FRAME_SIZE) / (freq * 16);
+ s->frame_size_min = ff_ac3_frame_sizes[s->frmsizecod][s->fscod];
s->bits_written = 0;
s->samples_written = 0;
s->frame_size = s->frame_size_min;
@@ -881,8 +697,6 @@ static int AC3_encode_init(AVCodecContext *avctx)
/* initial snr offset */
s->csnroffst = 40;
- ac3_common_init();
-
/* mdct init */
fft_init(MDCT_NBITS - 2);
for(i=0;i<N/4;i++) {
@@ -1369,9 +1183,9 @@ static int AC3_encode_frame(AVCodecContext *avctx,
/* apply the MDCT window */
for(j=0;j<N/2;j++) {
input_samples[j] = MUL16(input_samples[j],
- ac3_window[j]) >> 15;
+ ff_ac3_window[j]) >> 15;
input_samples[N-j-1] = MUL16(input_samples[N-j-1],
- ac3_window[j]) >> 15;
+ ff_ac3_window[j]) >> 15;
}
/* Normalize the samples to use the maximum available
@@ -1379,7 +1193,7 @@ static int AC3_encode_frame(AVCodecContext *avctx,
v = 14 - log2_tab(input_samples, N);
if (v < 0)
v = 0;
- exp_samples[i][ch] = v - 10;
+ exp_samples[i][ch] = v - 9;
lshift_tab(input_samples, N, v);
/* do the MDCT */
diff --git a/contrib/ffmpeg/libavcodec/ac3tab.h b/contrib/ffmpeg/libavcodec/ac3tab.h
index 9f90ae95c..b549c5ba9 100644
--- a/contrib/ffmpeg/libavcodec/ac3tab.h
+++ b/contrib/ffmpeg/libavcodec/ac3tab.h
@@ -24,11 +24,64 @@
* tables taken directly from AC3 spec.
*/
+/**
+ * Possible frame sizes.
+ * from ATSC A/52 Table 5.18 Frame Size Code Table.
+ */
+const uint16_t ff_ac3_frame_sizes[38][3] = {
+ { 64, 69, 96 },
+ { 64, 70, 96 },
+ { 80, 87, 120 },
+ { 80, 88, 120 },
+ { 96, 104, 144 },
+ { 96, 105, 144 },
+ { 112, 121, 168 },
+ { 112, 122, 168 },
+ { 128, 139, 192 },
+ { 128, 140, 192 },
+ { 160, 174, 240 },
+ { 160, 175, 240 },
+ { 192, 208, 288 },
+ { 192, 209, 288 },
+ { 224, 243, 336 },
+ { 224, 244, 336 },
+ { 256, 278, 384 },
+ { 256, 279, 384 },
+ { 320, 348, 480 },
+ { 320, 349, 480 },
+ { 384, 417, 576 },
+ { 384, 418, 576 },
+ { 448, 487, 672 },
+ { 448, 488, 672 },
+ { 512, 557, 768 },
+ { 512, 558, 768 },
+ { 640, 696, 960 },
+ { 640, 697, 960 },
+ { 768, 835, 1152 },
+ { 768, 836, 1152 },
+ { 896, 975, 1344 },
+ { 896, 976, 1344 },
+ { 1024, 1114, 1536 },
+ { 1024, 1115, 1536 },
+ { 1152, 1253, 1728 },
+ { 1152, 1254, 1728 },
+ { 1280, 1393, 1920 },
+ { 1280, 1394, 1920 },
+};
+
+/**
+ * Maps audio coding mode (acmod) to number of full-bandwidth channels.
+ * from ATSC A/52 Table 5.8 Audio Coding Mode
+ */
+const uint8_t ff_ac3_channels[8] = {
+ 2, 1, 2, 3, 3, 4, 4, 5
+};
+
/* possible frequencies */
-static const uint16_t ac3_freqs[3] = { 48000, 44100, 32000 };
+const uint16_t ff_ac3_freqs[3] = { 48000, 44100, 32000 };
/* possible bitrates */
-static const uint16_t ac3_bitratetab[19] = {
+const uint16_t ff_ac3_bitratetab[19] = {
32, 40, 48, 56, 64, 80, 96, 112, 128,
160, 192, 224, 256, 320, 384, 448, 512, 576, 640
};
@@ -36,7 +89,7 @@ static const uint16_t ac3_bitratetab[19] = {
/* AC3 MDCT window */
/* MDCT window */
-static const int16_t ac3_window[256] = {
+const int16_t ff_ac3_window[256] = {
4, 7, 12, 16, 21, 28, 34, 42,
51, 61, 72, 84, 97, 111, 127, 145,
164, 184, 207, 231, 257, 285, 315, 347,
@@ -165,27 +218,27 @@ static const uint8_t baptab[64]= {
15, 15, 15, 15,
};
-static const uint8_t sdecaytab[4]={
+const uint8_t ff_sdecaytab[4]={
0x0f, 0x11, 0x13, 0x15,
};
-static const uint8_t fdecaytab[4]={
+const uint8_t ff_fdecaytab[4]={
0x3f, 0x53, 0x67, 0x7b,
};
-static const uint16_t sgaintab[4]= {
+const uint16_t ff_sgaintab[4]= {
0x540, 0x4d8, 0x478, 0x410,
};
-static const uint16_t dbkneetab[4]= {
+const uint16_t ff_dbkneetab[4]= {
0x000, 0x700, 0x900, 0xb00,
};
-static const int16_t floortab[8]= {
+const int16_t ff_floortab[8]= {
0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800,
};
-static const uint16_t fgaintab[8]= {
+const uint16_t ff_fgaintab[8]= {
0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
};
@@ -196,10 +249,3 @@ static const uint8_t bndsz[50]={
};
static uint8_t bndtab[51];
-
-/* fft & mdct sin cos tables */
-static int16_t costab[64];
-static int16_t sintab[64];
-static int16_t fft_rev[512];
-static int16_t xcos1[128];
-static int16_t xsin1[128];
diff --git a/contrib/ffmpeg/libavcodec/adpcm.c b/contrib/ffmpeg/libavcodec/adpcm.c
index ec3fe6f6e..8800c3a20 100644
--- a/contrib/ffmpeg/libavcodec/adpcm.c
+++ b/contrib/ffmpeg/libavcodec/adpcm.c
@@ -150,10 +150,6 @@ typedef struct ADPCMContext {
int channel; /* for stereo MOVs, decode left, then decode right, then tell it's decoded */
ADPCMChannelStatus status[2];
short sample_buffer[32]; /* hold left samples while waiting for right samples */
-
- /* SWF only */
- int nb_bits;
- int nb_samples;
} ADPCMContext;
/* XXX: implement encoding */
@@ -209,7 +205,7 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho
int nibble = FFMIN(7, abs(delta)*4/step_table[c->step_index]) + (delta<0)*8;
c->prev_sample = c->prev_sample + ((step_table[c->step_index] * yamaha_difflookup[nibble]) / 8);
CLAMP_TO_SHORT(c->prev_sample);
- c->step_index = clip(c->step_index + index_table[nibble], 0, 88);
+ c->step_index = av_clip(c->step_index + index_table[nibble], 0, 88);
return nibble;
}
@@ -224,7 +220,7 @@ static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, shor
else bias=-c->idelta/2;
nibble= (nibble + bias) / c->idelta;
- nibble= clip(nibble, -8, 7)&0x0F;
+ nibble= av_clip(nibble, -8, 7)&0x0F;
predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
CLAMP_TO_SHORT(predictor);
@@ -254,7 +250,7 @@ static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c,
c->predictor = c->predictor + ((c->step * yamaha_difflookup[nibble]) / 8);
CLAMP_TO_SHORT(c->predictor);
c->step = (c->step * yamaha_indexscale[nibble]) >> 8;
- c->step = clip(c->step, 127, 24567);
+ c->step = av_clip(c->step, 127, 24567);
return nibble;
}
@@ -324,8 +320,8 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
if(version == CODEC_ID_ADPCM_MS) {
const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 256;
const int div = (sample - predictor) / step;
- const int nmin = clip(div-range, -8, 6);
- const int nmax = clip(div+range, -7, 7);
+ const int nmin = av_clip(div-range, -8, 6);
+ const int nmax = av_clip(div+range, -7, 7);
for(nidx=nmin; nidx<=nmax; nidx++) {
const int nibble = nidx & 0xf;
int dec_sample = predictor + nidx * step;
@@ -372,8 +368,8 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\
const int predictor = nodes[j]->sample1;\
const int div = (sample - predictor) * 4 / STEP_TABLE;\
- int nmin = clip(div-range, -7, 6);\
- int nmax = clip(div+range, -6, 7);\
+ int nmin = av_clip(div-range, -7, 6);\
+ int nmax = av_clip(div+range, -6, 7);\
if(nmin<=0) nmin--; /* distinguish -0 from +0 */\
if(nmax<0) nmax--;\
for(nidx=nmin; nidx<=nmax; nidx++) {\
@@ -381,9 +377,9 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
int dec_sample = predictor + (STEP_TABLE * yamaha_difflookup[nibble]) / 8;\
STORE_NODE(NAME, STEP_INDEX);\
}
- LOOP_NODES(ima, step_table[step], clip(step + index_table[nibble], 0, 88));
+ LOOP_NODES(ima, step_table[step], av_clip(step + index_table[nibble], 0, 88));
} else { //CODEC_ID_ADPCM_YAMAHA
- LOOP_NODES(yamaha, step, clip((step * yamaha_indexscale[nibble]) >> 8, 127, 24567));
+ LOOP_NODES(yamaha, step, av_clip((step * yamaha_indexscale[nibble]) >> 8, 127, 24567));
#undef LOOP_NODES
#undef STORE_NODE
}
@@ -602,6 +598,10 @@ static int adpcm_decode_init(AVCodecContext * avctx)
{
ADPCMContext *c = avctx->priv_data;
+ if(avctx->channels > 2U){
+ return -1;
+ }
+
c->channel = 0;
c->status[0].predictor = c->status[1].predictor = 0;
c->status[0].step_index = c->status[1].step_index = 0;
@@ -730,7 +730,7 @@ static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned c
c->predictor += (c->step * yamaha_difflookup[nibble]) / 8;
CLAMP_TO_SHORT(c->predictor);
c->step = (c->step * yamaha_indexscale[nibble]) >> 8;
- c->step = clip(c->step, 127, 24567);
+ c->step = av_clip(c->step, 127, 24567);
return c->predictor;
}
@@ -826,6 +826,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
int n, m, channel, i;
int block_predictor[2];
short *samples;
+ short *samples_end;
uint8_t *src;
int st; /* stereo */
@@ -847,7 +848,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
if (!buf_size)
return 0;
+ //should protect all 4bit ADPCM variants
+ //8 is needed for CODEC_ID_ADPCM_IMA_WAV with 2 channels
+ //
+ if(*data_size/4 < buf_size + 8)
+ return -1;
+
samples = data;
+ samples_end= samples + *data_size/2;
+ *data_size= 0;
src = buf;
st = avctx->channels == 2 ? 1 : 0;
@@ -961,10 +970,10 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
n = buf_size - 7 * avctx->channels;
if (n < 0)
return -1;
- block_predictor[0] = clip(*src++, 0, 7);
+ block_predictor[0] = av_clip(*src++, 0, 7);
block_predictor[1] = 0;
if (st)
- block_predictor[1] = clip(*src++, 0, 7);
+ block_predictor[1] = av_clip(*src++, 0, 7);
c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
src+=2;
if (st){
@@ -1031,6 +1040,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
if (avctx->block_align != 0 && buf_size > avctx->block_align)
buf_size = avctx->block_align;
+ if(buf_size + 16 > (samples_end - samples)*3/8)
+ return -1;
+
c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8));
c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8));
c->status[0].step_index = src[14];
@@ -1100,19 +1112,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
}
break;
case CODEC_ID_ADPCM_EA:
- samples_in_chunk = LE_32(src);
+ samples_in_chunk = AV_RL32(src);
if (samples_in_chunk >= ((buf_size - 12) * 2)) {
src += buf_size;
break;
}
src += 4;
- current_left_sample = (int16_t)LE_16(src);
+ current_left_sample = (int16_t)AV_RL16(src);
src += 2;
- previous_left_sample = (int16_t)LE_16(src);
+ previous_left_sample = (int16_t)AV_RL16(src);
src += 2;
- current_right_sample = (int16_t)LE_16(src);
+ current_right_sample = (int16_t)AV_RL16(src);
src += 2;
- previous_right_sample = (int16_t)LE_16(src);
+ previous_right_sample = (int16_t)AV_RL16(src);
src += 2;
for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
@@ -1197,7 +1209,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
src++;
}
} else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) {
- while (src < buf + buf_size) {
+ while (src < buf + buf_size && samples + 2 < samples_end) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 5) & 0x07, 3, 0);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
@@ -1207,7 +1219,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
src++;
}
} else {
- while (src < buf + buf_size) {
+ while (src < buf + buf_size && samples + 3 < samples_end) {
*samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
(src[0] >> 6) & 0x03, 2, 2);
*samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
@@ -1224,41 +1236,30 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
{
GetBitContext gb;
const int *table;
- int k0, signmask;
+ int k0, signmask, nb_bits;
int size = buf_size*8;
init_get_bits(&gb, buf, size);
- // first frame, read bits & inital values
- if (!c->nb_bits)
- {
- c->nb_bits = get_bits(&gb, 2)+2;
-// av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", c->nb_bits);
- }
+ //read bits & inital values
+ nb_bits = get_bits(&gb, 2)+2;
+ //av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits);
+ table = swf_index_tables[nb_bits-2];
+ k0 = 1 << (nb_bits-2);
+ signmask = 1 << (nb_bits-1);
- table = swf_index_tables[c->nb_bits-2];
- k0 = 1 << (c->nb_bits-2);
- signmask = 1 << (c->nb_bits-1);
+ for (i = 0; i < avctx->channels; i++) {
+ *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
+ c->status[i].step_index = get_bits(&gb, 6);
+ }
- while (get_bits_count(&gb) <= size)
+ while (get_bits_count(&gb) < size)
{
int i;
- c->nb_samples++;
- // wrap around at every 4096 samples...
- if ((c->nb_samples & 0xfff) == 1)
- {
- for (i = 0; i <= st; i++)
- {
- *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
- c->status[i].step_index = get_bits(&gb, 6);
- }
- }
-
- // similar to IMA adpcm
- for (i = 0; i <= st; i++)
- {
- int delta = get_bits(&gb, c->nb_bits);
+ for (i = 0; i < avctx->channels; i++) {
+ // similar to IMA adpcm
+ int delta = get_bits(&gb, nb_bits);
int step = step_table[c->status[i].step_index];
long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
int k = k0;
@@ -1278,16 +1279,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
c->status[i].step_index += table[delta & (~signmask)];
- c->status[i].step_index = clip(c->status[i].step_index, 0, 88);
- c->status[i].predictor = clip(c->status[i].predictor, -32768, 32767);
+ c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
+ c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767);
*samples++ = c->status[i].predictor;
+ if (samples >= samples_end) {
+ av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n");
+ return -1;
+ }
}
}
-
-// src += get_bits_count(&gb)*8;
- src += size;
-
+ src += buf_size;
break;
}
case CODEC_ID_ADPCM_YAMAHA:
diff --git a/contrib/ffmpeg/libavcodec/alac.c b/contrib/ffmpeg/libavcodec/alac.c
index 793f71a11..cc87c81e5 100644
--- a/contrib/ffmpeg/libavcodec/alac.c
+++ b/contrib/ffmpeg/libavcodec/alac.c
@@ -110,11 +110,11 @@ static int alac_set_info(ALACContext *alac)
ptr += 4; /* alac */
ptr += 4; /* 0 ? */
- if(BE_32(ptr) >= UINT_MAX/4){
+ if(AV_RB32(ptr) >= UINT_MAX/4){
av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
return -1;
}
- alac->setinfo_max_samples_per_frame = BE_32(ptr); /* buffer size / 2 ? */
+ alac->setinfo_max_samples_per_frame = AV_RB32(ptr); /* buffer size / 2 ? */
ptr += 4;
alac->setinfo_7a = *ptr++;
alac->setinfo_sample_size = *ptr++;
@@ -122,13 +122,13 @@ static int alac_set_info(ALACContext *alac)
alac->setinfo_rice_initialhistory = *ptr++;
alac->setinfo_rice_kmodifier = *ptr++;
alac->setinfo_7f = *ptr++; // channels?
- alac->setinfo_80 = BE_16(ptr);
+ alac->setinfo_80 = AV_RB16(ptr);
ptr += 2;
- alac->setinfo_82 = BE_32(ptr); // max coded frame size
+ alac->setinfo_82 = AV_RB32(ptr); // max coded frame size
ptr += 4;
- alac->setinfo_86 = BE_32(ptr); // bitrate ?
+ alac->setinfo_86 = AV_RB32(ptr); // bitrate ?
ptr += 4;
- alac->setinfo_8a_rate = BE_32(ptr); // samplerate
+ alac->setinfo_8a_rate = AV_RB32(ptr); // samplerate
ptr += 4;
allocate_buffers(alac);
diff --git a/contrib/ffmpeg/libavcodec/allcodecs.c b/contrib/ffmpeg/libavcodec/allcodecs.c
index 9678f6bee..b247cbe34 100644
--- a/contrib/ffmpeg/libavcodec/allcodecs.c
+++ b/contrib/ffmpeg/libavcodec/allcodecs.c
@@ -1,5 +1,5 @@
/*
- * Utils for libavcodec
+ * Provides registration of all codecs, parsers and bitstream filters for libavcodec.
* Copyright (c) 2002 Fabrice Bellard.
*
* This file is part of FFmpeg.
@@ -21,7 +21,7 @@
/**
* @file allcodecs.c
- * Utils for libavcodec.
+ * Provides registration of all codecs, parsers and bitstream filters for libavcodec.
*/
#include "avcodec.h"
@@ -35,11 +35,15 @@
#define REGISTER_PARSER(X,x) \
if(ENABLE_##X##_PARSER) av_register_codec_parser(&x##_parser)
-/* If you do not call this function, then you can select exactly which
- formats you want to support */
-
/**
- * simple call to register all the codecs.
+ * Register all the codecs, parsers and bitstream filters which were enabled at
+ * configuration time. If you do not call this function you can select exactly
+ * which formats you want to support, by using the individual registration
+ * functions.
+ *
+ * @see register_avcodec
+ * @see av_register_codec_parser
+ * @see av_register_bitstream_filter
*/
void avcodec_register_all(void)
{
@@ -54,18 +58,21 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (ASV1, asv1);
REGISTER_ENCDEC (ASV2, asv2);
REGISTER_DECODER(AVS, avs);
- REGISTER_DECODER(BMP, bmp);
+ REGISTER_ENCDEC (BMP, bmp);
REGISTER_DECODER(CAVS, cavs);
REGISTER_DECODER(CINEPAK, cinepak);
REGISTER_DECODER(CLJR, cljr);
REGISTER_DECODER(CSCD, cscd);
REGISTER_DECODER(CYUV, cyuv);
+ REGISTER_DECODER(DCA, dca);
+ REGISTER_DECODER(DNXHD, dnxhd);
REGISTER_DECODER(DSICINVIDEO, dsicinvideo);
REGISTER_ENCDEC (DVVIDEO, dvvideo);
+ REGISTER_DECODER(DXA, dxa);
REGISTER_DECODER(EIGHTBPS, eightbps);
REGISTER_ENCDEC (FFV1, ffv1);
REGISTER_ENCDEC (FFVHUFF, ffvhuff);
- REGISTER_DECODER(FLASHSV, flashsv);
+ REGISTER_ENCDEC (FLASHSV, flashsv);
REGISTER_DECODER(FLIC, flic);
REGISTER_ENCDEC (FLV, flv);
REGISTER_DECODER(FOURXM, fourxm);
@@ -89,9 +96,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (MJPEG, mjpeg);
REGISTER_DECODER(MJPEGB, mjpegb);
REGISTER_DECODER(MMVIDEO, mmvideo);
-#ifdef HAVE_XVMC
REGISTER_DECODER(MPEG_XVMC, mpeg_xvmc);
-#endif
REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video);
REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);
REGISTER_ENCDEC (MPEG4, mpeg4);
@@ -107,9 +112,7 @@ void avcodec_register_all(void)
REGISTER_ENCODER(PBM, pbm);
REGISTER_ENCODER(PGM, pgm);
REGISTER_ENCODER(PGMYUV, pgmyuv);
-#ifdef CONFIG_ZLIB
REGISTER_ENCDEC (PNG, png);
-#endif
REGISTER_ENCODER(PPM, ppm);
REGISTER_DECODER(QDRAW, qdraw);
REGISTER_DECODER(QPEG, qpeg);
@@ -125,8 +128,9 @@ void avcodec_register_all(void)
REGISTER_DECODER(SP5X, sp5x);
REGISTER_ENCDEC (SVQ1, svq1);
REGISTER_DECODER(SVQ3, svq3);
- REGISTER_DECODER(TARGA, targa);
+ REGISTER_ENCDEC (TARGA, targa);
REGISTER_DECODER(THEORA, theora);
+ REGISTER_DECODER(THP, thp);
REGISTER_DECODER(TIERTEXSEQVIDEO, tiertexseqvideo);
REGISTER_DECODER(TIFF, tiff);
REGISTER_DECODER(TRUEMOTION1, truemotion1);
@@ -146,59 +150,40 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (WMV2, wmv2);
REGISTER_DECODER(WMV3, wmv3);
REGISTER_DECODER(WNV1, wnv1);
-#ifdef CONFIG_X264
REGISTER_ENCODER(X264, x264);
-#endif
REGISTER_DECODER(XAN_WC3, xan_wc3);
REGISTER_DECODER(XL, xl);
-#ifdef CONFIG_XVID
REGISTER_ENCODER(XVID, xvid);
-#endif
REGISTER_ENCDEC (ZLIB, zlib);
- REGISTER_DECODER(ZMBV, zmbv);
+ REGISTER_ENCDEC (ZMBV, zmbv);
/* audio codecs */
-#ifdef CONFIG_FAAD
REGISTER_DECODER(AAC, aac);
REGISTER_DECODER(MPEG4AAC, mpeg4aac);
-#endif
-#ifdef CONFIG_A52
- REGISTER_DECODER(AC3, ac3);
-#endif
REGISTER_ENCODER(AC3, ac3);
REGISTER_DECODER(ALAC, alac);
-#if defined(CONFIG_AMR_NB) || defined(CONFIG_AMR_NB_FIXED)
REGISTER_ENCDEC (AMR_NB, amr_nb);
-#endif
-#ifdef CONFIG_AMR_WB
REGISTER_ENCDEC (AMR_WB, amr_wb);
-#endif
REGISTER_DECODER(COOK, cook);
REGISTER_DECODER(DSICINAUDIO, dsicinaudio);
-#ifdef CONFIG_DTS
REGISTER_DECODER(DTS, dts);
-#endif
-#ifdef CONFIG_FAAC
REGISTER_ENCODER(FAAC, faac);
-#endif
REGISTER_ENCDEC (FLAC, flac);
REGISTER_DECODER(IMC, imc);
-#ifdef CONFIG_LIBGSM
+ REGISTER_DECODER(LIBA52, liba52);
REGISTER_ENCDEC (LIBGSM, libgsm);
-#endif
+ REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms);
+ REGISTER_ENCODER(LIBTHEORA, libtheora);
REGISTER_DECODER(MACE3, mace3);
REGISTER_DECODER(MACE6, mace6);
REGISTER_ENCDEC (MP2, mp2);
REGISTER_DECODER(MP3, mp3);
REGISTER_DECODER(MP3ADU, mp3adu);
-#ifdef CONFIG_MP3LAME
REGISTER_ENCODER(MP3LAME, mp3lame);
-#endif
REGISTER_DECODER(MP3ON4, mp3on4);
-#ifdef CONFIG_LIBVORBIS
+ REGISTER_DECODER(MPC7, mpc7);
if (!ENABLE_VORBIS_ENCODER) REGISTER_ENCODER(OGGVORBIS, oggvorbis);
if (!ENABLE_VORBIS_DECODER) REGISTER_DECODER(OGGVORBIS, oggvorbis);
-#endif
REGISTER_DECODER(QDM2, qdm2);
REGISTER_DECODER(RA_144, ra_144);
REGISTER_DECODER(RA_288, ra_288);
@@ -211,8 +196,8 @@ void avcodec_register_all(void)
REGISTER_DECODER(VMDAUDIO, vmdaudio);
REGISTER_ENCDEC (VORBIS, vorbis);
REGISTER_DECODER(WAVPACK, wavpack);
- REGISTER_DECODER(WMAV1, wmav1);
- REGISTER_DECODER(WMAV2, wmav2);
+ REGISTER_ENCDEC(WMAV1, wmav1);
+ REGISTER_ENCDEC(WMAV2, wmav2);
REGISTER_DECODER(WS_SND1, ws_snd1);
/* pcm codecs */
@@ -268,6 +253,7 @@ void avcodec_register_all(void)
REGISTER_PARSER (AAC, aac);
REGISTER_PARSER (AC3, ac3);
REGISTER_PARSER (CAVSVIDEO, cavsvideo);
+ REGISTER_PARSER (DCA, dca);
REGISTER_PARSER (DVBSUB, dvbsub);
REGISTER_PARSER (DVDSUB, dvdsub);
REGISTER_PARSER (H261, h261);
@@ -278,6 +264,7 @@ void avcodec_register_all(void)
REGISTER_PARSER (MPEGAUDIO, mpegaudio);
REGISTER_PARSER (MPEGVIDEO, mpegvideo);
REGISTER_PARSER (PNM, pnm);
+ REGISTER_PARSER (VC1, vc1);
av_register_bitstream_filter(&dump_extradata_bsf);
av_register_bitstream_filter(&remove_extradata_bsf);
@@ -285,5 +272,6 @@ void avcodec_register_all(void)
av_register_bitstream_filter(&mp3_header_compress_bsf);
av_register_bitstream_filter(&mp3_header_decompress_bsf);
av_register_bitstream_filter(&mjpega_dump_header_bsf);
+ av_register_bitstream_filter(&imx_dump_header_bsf);
}
diff --git a/contrib/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S b/contrib/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S
index 367f2d743..dbdf279ba 100644
--- a/contrib/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S
+++ b/contrib/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S
@@ -53,7 +53,7 @@ put_pixels_axp_asm:
.frame sp, 0, ra
.prologue 0
-#ifdef HAVE_GPROF
+#ifdef CONFIG_GPROF
lda AT, _mcount
jsr AT, (AT), _mcount
#endif
@@ -150,7 +150,7 @@ put_pixels_clamped_mvi_asm:
.frame sp, 0, ra
.prologue 0
-#ifdef HAVE_GPROF
+#ifdef CONFIG_GPROF
lda AT, _mcount
jsr AT, (AT), _mcount
#endif
@@ -205,7 +205,7 @@ add_pixels_clamped_mvi_asm:
.frame sp, 0, ra
.prologue 0
-#ifdef HAVE_GPROF
+#ifdef CONFIG_GPROF
lda AT, _mcount
jsr AT, (AT), _mcount
#endif
diff --git a/contrib/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S b/contrib/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S
index 6015a7824..cdf40b1f3 100644
--- a/contrib/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S
+++ b/contrib/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S
@@ -55,7 +55,7 @@ pix_abs16x16_mvi_asm:
.frame sp, 0, ra, 0
.prologue 0
-#ifdef HAVE_GPROF
+#ifdef CONFIG_GPROF
lda AT, _mcount
jsr AT, (AT), _mcount
#endif
diff --git a/contrib/ffmpeg/libavcodec/amr.c b/contrib/ffmpeg/libavcodec/amr.c
index 2d1877b22..6a8193f0b 100644
--- a/contrib/ffmpeg/libavcodec/amr.c
+++ b/contrib/ffmpeg/libavcodec/amr.c
@@ -18,41 +18,53 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
- /*
- This code implements amr-nb and amr-wb audio encoder/decoder through external reference
- code from www.3gpp.org. The licence of the code from 3gpp is unclear so you
- have to download the code separately. Two versions exists: One fixed-point
- and one with floats. For some reason the float-encoder is significant faster
- atleast on a P4 1.5GHz (0.9s instead of 9.9s on a 30s audio clip at MR102).
- Both float and fixed point is supported for amr-nb, but only float for
- amr-wb.
-
- --AMR-NB--
- The fixed-point (TS26.073) can be downloaded from:
- http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip
- Extract the soure into ffmpeg/libavcodec/amr
- To use the fixed version run "./configure" with "--enable-amr_nb-fixed"
-
- The float version (default) can be downloaded from:
- http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip
- Extract the soure into ffmpeg/libavcodec/amr_float
-
- The specification for amr-nb can be found in TS 26.071
- (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other
- info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm
-
- --AMR-WB--
- The reference code can be downloaded from:
- http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip
- It should be extracted to "libavcodec/amrwb_float". Enable it with
- "--enable-amr_wb".
-
- The specification for amr-wb can be downloaded from:
- http://www.3gpp.org/ftp/Specs/archive/26_series/26.171/26171-500.zip
-
- If someone want to use the fixed point version it can be downloaded
- from: http://www.3gpp.org/ftp/Specs/archive/26_series/26.173/26173-571.zip
+ /** @file
+ * Adaptive Multi-Rate (AMR) Audio decoder stub.
+ *
+ * This code implements both an AMR-NarrowBand (AMR-NB) and an AMR-WideBand
+ * (AMR-WB) audio encoder/decoder through external reference code from
+ * http://www.3gpp.org/. The license of the code from 3gpp is unclear so you
+ * have to download the code separately. Two versions exists: One fixed-point
+ * and one with floats. For some reason the float-encoder is significant faster
+ * at least on a P4 1.5GHz (0.9s instead of 9.9s on a 30s audio clip at MR102).
+ * Both float and fixed point are supported for AMR-NB, but only float for
+ * AMR-WB.
+ *
+ * \section AMR-NB
+ *
+ * \subsection Float
+ * The float version (default) can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-610.zip
+ * Extract the source into \c "ffmpeg/libavcodec/amr_float".
+ *
+ * \subsection Fixed-point
+ * The fixed-point (TS26.073) can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip.
+ * Extract the source into \c "ffmpeg/libavcodec/amr".
+ * To use the fixed version run \c "./configure" with \c "--enable-amr_nb-fixed".
+ *
+ * \subsection Specification
+ * The specification for AMR-NB can be found in TS 26.071
+ * (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other
+ * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm.
+ *
+ * \section AMR-WB
+ * \subsection Float
+ * The reference code can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-600.zip
+ * It should be extracted to \c "ffmpeg/libavcodec/amrwb_float". Enable it with
+ * \c "--enable-amr_wb".
+ *
+ * \subsection Fixed-point
+ * If someone wants to use the fixed point version it can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.173/26173-571.zip.
+ *
+ * \subsection Specification
+ * The specification for AMR-WB can be found in TS 26.171
+ * (http://www.3gpp.org/ftp/Specs/html-info/26171.htm) and some other
+ * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm.
+ *
*/
#include "avcodec.h"
@@ -76,37 +88,34 @@
/* Common code for fixed and float version*/
typedef struct AMR_bitrates
{
- int startrate;
- int stoprate;
+ int rate;
enum Mode mode;
-
} AMR_bitrates;
-/* Match desired bitrate with closest one*/
-static enum Mode getBitrateMode(int bitrate)
+/* Match desired bitrate */
+static int getBitrateMode(int bitrate)
{
- /* Adjusted so that all bitrates can be used from commandline where
- only a multiple of 1000 can be specified*/
- AMR_bitrates rates[]={ {0,4999,MR475}, //4
- {5000,5899,MR515},//5
- {5900,6699,MR59},//6
- {6700,7000,MR67},//7
- {7001,7949,MR74},//8
- {7950,9999,MR795},//9
- {10000,11999,MR102},//10
- {12000,64000,MR122},//12
-
+ /* make the correspondance between bitrate and mode */
+ AMR_bitrates rates[]={ {4750,MR475},
+ {5150,MR515},
+ {5900,MR59},
+ {6700,MR67},
+ {7400,MR74},
+ {7950,MR795},
+ {10200,MR102},
+ {12200,MR122},
};
int i;
+
for(i=0;i<8;i++)
{
- if(rates[i].startrate<=bitrate && rates[i].stoprate>=bitrate)
+ if(rates[i].rate==bitrate)
{
return(rates[i].mode);
}
}
- /*Return highest possible*/
- return(MR122);
+ /* no bitrate matching, return an error */
+ return -1;
}
static void amr_decode_fix_avctx(AVCodecContext * avctx)
@@ -139,17 +148,16 @@ typedef struct AMRContext {
Word16 reset_flag;
Word16 reset_flag_old;
- enum Mode enc_bitrate;
+ int enc_bitrate;
Speech_Encode_FrameState *enstate;
sid_syncState *sidstate;
enum TXFrameType tx_frametype;
-
-
} AMRContext;
static int amr_nb_decode_init(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
s->frameCount=0;
s->speech_decoder_state=NULL;
s->rx_type = (enum RXFrameType)0;
@@ -177,6 +185,7 @@ static int amr_nb_decode_init(AVCodecContext * avctx)
static int amr_nb_encode_init(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
s->frameCount=0;
s->speech_decoder_state=NULL;
s->rx_type = (enum RXFrameType)0;
@@ -186,19 +195,13 @@ static int amr_nb_encode_init(AVCodecContext * avctx)
if(avctx->sample_rate!=8000)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Only 8000Hz sample rate supported\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return -1;
}
if(avctx->channels!=1)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Only mono supported\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return -1;
}
@@ -207,14 +210,15 @@ static int amr_nb_encode_init(AVCodecContext * avctx)
if(Speech_Encode_Frame_init(&s->enstate, 0, "encoder") || sid_sync_init (&s->sidstate))
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Speech_Encode_Frame_init error\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Speech_Encode_Frame_init error\n");
return -1;
}
- s->enc_bitrate=getBitrateMode(avctx->bit_rate);
+ if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
+ {
+ av_log(avctx, AV_LOG_ERROR, "bitrate not supported\n");
+ return -1;
+ }
return 0;
}
@@ -222,6 +226,7 @@ static int amr_nb_encode_init(AVCodecContext * avctx)
static int amr_nb_encode_close(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
Speech_Encode_Frame_exit(&s->enstate);
sid_sync_exit (&s->sidstate);
av_freep(&avctx->coded_frame);
@@ -231,6 +236,7 @@ static int amr_nb_encode_close(AVCodecContext * avctx)
static int amr_nb_decode_close(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
Speech_Decode_Frame_exit(&s->speech_decoder_state);
return 0;
}
@@ -240,16 +246,12 @@ static int amr_nb_decode_frame(AVCodecContext * avctx,
uint8_t * buf, int buf_size)
{
AMRContext *s = avctx->priv_data;
-
uint8_t*amrData=buf;
int offset=0;
-
UWord8 toc, q, ft;
-
Word16 serial[SERIAL_FRAMESIZE]; /* coded bits */
Word16 *synth;
UWord8 *packed_bits;
-
static Word16 packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
int i;
@@ -332,7 +334,6 @@ static int amr_nb_encode_frame(AVCodecContext *avctx,
unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
{
short serial_data[250] = {0};
-
AMRContext *s = avctx->priv_data;
int written;
@@ -360,12 +361,13 @@ typedef struct AMRContext {
int frameCount;
void * decState;
int *enstate;
- enum Mode enc_bitrate;
+ int enc_bitrate;
} AMRContext;
static int amr_nb_decode_init(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
s->frameCount=0;
s->decState=Decoder_Interface_init();
if(!s->decState)
@@ -388,23 +390,18 @@ static int amr_nb_decode_init(AVCodecContext * avctx)
static int amr_nb_encode_init(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
s->frameCount=0;
if(avctx->sample_rate!=8000)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Only 8000Hz sample rate supported\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
return -1;
}
if(avctx->channels!=1)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Only mono supported\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
return -1;
}
@@ -414,14 +411,15 @@ static int amr_nb_encode_init(AVCodecContext * avctx)
s->enstate=Encoder_Interface_init(0);
if(!s->enstate)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Encoder_Interface_init error\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
return -1;
}
- s->enc_bitrate=getBitrateMode(avctx->bit_rate);
+ if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
+ {
+ av_log(avctx, AV_LOG_ERROR, "bitrate not supported\n");
+ return -1;
+ }
return 0;
}
@@ -429,6 +427,7 @@ static int amr_nb_encode_init(AVCodecContext * avctx)
static int amr_nb_decode_close(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
Decoder_Interface_exit(s->decState);
return 0;
}
@@ -436,6 +435,7 @@ static int amr_nb_decode_close(AVCodecContext * avctx)
static int amr_nb_encode_close(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
+
Encoder_Interface_exit(s->enstate);
av_freep(&avctx->coded_frame);
return 0;
@@ -445,8 +445,7 @@ static int amr_nb_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
uint8_t * buf, int buf_size)
{
- AMRContext *s = (AMRContext*)avctx->priv_data;
-
+ AMRContext *s = avctx->priv_data;
uint8_t*amrData=buf;
static short block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
enum Mode dec_mode;
@@ -454,11 +453,6 @@ static int amr_nb_decode_frame(AVCodecContext * avctx,
/* av_log(NULL,AV_LOG_DEBUG,"amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",buf,buf_size,s->frameCount); */
- if(buf_size==0) {
- /* nothing to do */
- return 0;
- }
-
dec_mode = (buf[0] >> 3) & 0x000F;
packet_size = block_size[dec_mode]+1;
@@ -479,10 +473,14 @@ static int amr_nb_decode_frame(AVCodecContext * avctx,
static int amr_nb_encode_frame(AVCodecContext *avctx,
unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
{
- AMRContext *s = (AMRContext*)avctx->priv_data;
+ AMRContext *s = avctx->priv_data;
int written;
- s->enc_bitrate=getBitrateMode(avctx->bit_rate);
+ if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
+ {
+ av_log(avctx, AV_LOG_ERROR, "bitrate not supported\n");
+ return -1;
+ }
written = Encoder_Interface_Encode(s->enstate,
s->enc_bitrate,
@@ -538,38 +536,34 @@ AVCodec amr_nb_encoder =
/* Common code for fixed and float version*/
typedef struct AMRWB_bitrates
{
- int startrate;
- int stoprate;
+ int rate;
int mode;
-
} AMRWB_bitrates;
static int getWBBitrateMode(int bitrate)
{
- /* Adjusted so that all bitrates can be used from commandline where
- only a multiple of 1000 can be specified*/
- AMRWB_bitrates rates[]={ {0,7999,0}, //6.6kHz
- {8000,9999,1},//8.85
- {10000,13000,2},//12.65
- {13001,14999,3},//14.25
- {15000,17000,4},//15.85
- {17001,18000,5},//18.25
- {18001,22000,6},//19.85
- {22001,23000,7},//23.05
- {23001,24000,8},//23.85
-
+ /* make the correspondance between bitrate and mode */
+ AMRWB_bitrates rates[]={ {6600,0},
+ {8850,1},
+ {12650,2},
+ {14250,3},
+ {15850,4},
+ {18250,5},
+ {19850,6},
+ {23050,7},
+ {23850,8},
};
int i;
for(i=0;i<9;i++)
{
- if(rates[i].startrate<=bitrate && rates[i].stoprate>=bitrate)
+ if(rates[i].rate==bitrate)
{
return(rates[i].mode);
}
}
- /*Return highest possible*/
- return(8);
+ /* no bitrate matching, return an error */
+ return -1;
}
@@ -582,24 +576,25 @@ typedef struct AMRWBContext {
static int amr_wb_encode_init(AVCodecContext * avctx)
{
- AMRWBContext *s = (AMRWBContext*)avctx->priv_data;
+ AMRWBContext *s = avctx->priv_data;
+
s->frameCount=0;
if(avctx->sample_rate!=16000)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Only 16000Hz sample rate supported\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
return -1;
}
if(avctx->channels!=1)
{
- if(avctx->debug)
- {
- av_log(avctx, AV_LOG_DEBUG, "Only mono supported\n");
- }
+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
+ return -1;
+ }
+
+ if((s->mode=getWBBitrateMode(avctx->bit_rate))<0)
+ {
+ av_log(avctx, AV_LOG_ERROR, "bitrate not supported\n");
return -1;
}
@@ -607,7 +602,6 @@ static int amr_wb_encode_init(AVCodecContext * avctx)
avctx->coded_frame= avcodec_alloc_frame();
s->state = E_IF_init();
- s->mode=getWBBitrateMode(avctx->bit_rate);
s->allow_dtx=0;
return 0;
@@ -615,7 +609,8 @@ static int amr_wb_encode_init(AVCodecContext * avctx)
static int amr_wb_encode_close(AVCodecContext * avctx)
{
- AMRWBContext *s = (AMRWBContext*) avctx->priv_data;
+ AMRWBContext *s = avctx->priv_data;
+
E_IF_exit(s->state);
av_freep(&avctx->coded_frame);
s->frameCount++;
@@ -625,17 +620,22 @@ static int amr_wb_encode_close(AVCodecContext * avctx)
static int amr_wb_encode_frame(AVCodecContext *avctx,
unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
{
- AMRWBContext *s;
+ AMRWBContext *s = avctx->priv_data;
int size;
- s = (AMRWBContext*) avctx->priv_data;
- s->mode=getWBBitrateMode(avctx->bit_rate);
+
+ if((s->mode=getWBBitrateMode(avctx->bit_rate))<0)
+ {
+ av_log(avctx, AV_LOG_ERROR, "bitrate not supported\n");
+ return -1;
+ }
size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
return size;
}
static int amr_wb_decode_init(AVCodecContext * avctx)
{
- AMRWBContext *s = (AMRWBContext *)avctx->priv_data;
+ AMRWBContext *s = avctx->priv_data;
+
s->frameCount=0;
s->state = D_IF_init();
@@ -656,8 +656,7 @@ static int amr_wb_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
uint8_t * buf, int buf_size)
{
- AMRWBContext *s = (AMRWBContext*)avctx->priv_data;
-
+ AMRWBContext *s = avctx->priv_data;
uint8_t*amrData=buf;
int mode;
int packet_size;
@@ -683,7 +682,8 @@ static int amr_wb_decode_frame(AVCodecContext * avctx,
static int amr_wb_decode_close(AVCodecContext * avctx)
{
- AMRWBContext *s = (AMRWBContext *)avctx->priv_data;
+ AMRWBContext *s = avctx->priv_data;
+
D_IF_exit(s->state);
return 0;
}
diff --git a/contrib/ffmpeg/libavcodec/apiexample.c b/contrib/ffmpeg/libavcodec/apiexample.c
index 484c77876..151637bd2 100644
--- a/contrib/ffmpeg/libavcodec/apiexample.c
+++ b/contrib/ffmpeg/libavcodec/apiexample.c
@@ -32,6 +32,8 @@
#include <string.h>
#include <math.h>
+#define PI 3.14159265358979323846
+
#ifdef HAVE_AV_CONFIG_H
#undef HAVE_AV_CONFIG_H
#endif
@@ -89,7 +91,7 @@ void audio_encode_example(const char *filename)
/* encode a single tone sound */
t = 0;
- tincr = 2 * M_PI * 440.0 / c->sample_rate;
+ tincr = 2 * PI * 440.0 / c->sample_rate;
for(i=0;i<200;i++) {
for(j=0;j<frame_size;j++) {
samples[2*j] = (int)(sin(t) * 10000);
@@ -122,9 +124,6 @@ void audio_decode_example(const char *outfilename, const char *filename)
printf("Audio decoding\n");
- /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
- memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
/* find the mpeg audio decoder */
codec = avcodec_find_decoder(CODEC_ID_MP2);
if (!codec) {
@@ -226,8 +225,6 @@ void video_encode_example(const char *filename)
exit(1);
}
- /* the codec gives us the frame size, in samples */
-
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "could not open %s\n", filename);
diff --git a/contrib/ffmpeg/libavcodec/armv4l/dsputil_arm.c b/contrib/ffmpeg/libavcodec/armv4l/dsputil_arm.c
index 9f0bfa2af..61b5fdacc 100644
--- a/contrib/ffmpeg/libavcodec/armv4l/dsputil_arm.c
+++ b/contrib/ffmpeg/libavcodec/armv4l/dsputil_arm.c
@@ -35,6 +35,12 @@ extern void simple_idct_put_armv5te(uint8_t *dest, int line_size,
extern void simple_idct_add_armv5te(uint8_t *dest, int line_size,
DCTELEM *data);
+extern void ff_simple_idct_armv6(DCTELEM *data);
+extern void ff_simple_idct_put_armv6(uint8_t *dest, int line_size,
+ DCTELEM *data);
+extern void ff_simple_idct_add_armv6(uint8_t *dest, int line_size,
+ DCTELEM *data);
+
/* XXX: local hack */
static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
@@ -206,6 +212,8 @@ void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx)
if(idct_algo == FF_IDCT_AUTO){
#if defined(HAVE_IPP)
idct_algo = FF_IDCT_IPP;
+#elif defined(HAVE_ARMV6)
+ idct_algo = FF_IDCT_SIMPLEARMV6;
#elif defined(HAVE_ARMV5TE)
idct_algo = FF_IDCT_SIMPLEARMV5TE;
#else
@@ -223,6 +231,13 @@ void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx)
c->idct_add= simple_idct_ARM_add;
c->idct = simple_idct_ARM;
c->idct_permutation_type= FF_NO_IDCT_PERM;
+#ifdef HAVE_ARMV6
+ } else if (idct_algo==FF_IDCT_SIMPLEARMV6){
+ c->idct_put= ff_simple_idct_put_armv6;
+ c->idct_add= ff_simple_idct_add_armv6;
+ c->idct = ff_simple_idct_armv6;
+ c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
+#endif
#ifdef HAVE_ARMV5TE
} else if (idct_algo==FF_IDCT_SIMPLEARMV5TE){
c->idct_put= simple_idct_put_armv5te;
diff --git a/contrib/ffmpeg/libavcodec/armv4l/dsputil_iwmmxt.c b/contrib/ffmpeg/libavcodec/armv4l/dsputil_iwmmxt.c
index d7401e760..7536100ee 100644
--- a/contrib/ffmpeg/libavcodec/armv4l/dsputil_iwmmxt.c
+++ b/contrib/ffmpeg/libavcodec/armv4l/dsputil_iwmmxt.c
@@ -128,17 +128,13 @@ static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h)
return;
}
-int mm_flags; /* multimedia extension flags */
-
-int mm_support(void)
-{
- return 0; /* TODO, implement proper detection */
-}
+/* A run time test is not simple. If this file is compiled in
+ * then we should install the functions
+ */
+int mm_flags = MM_IWMMXT; /* multimedia extension flags */
void dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)
{
- mm_flags = mm_support();
-
if (avctx->dsp_mask) {
if (avctx->dsp_mask & FF_MM_FORCE)
mm_flags |= (avctx->dsp_mask & 0xffff);
diff --git a/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_arm.c b/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_arm.c
index 10a005cd3..22d40d8bc 100644
--- a/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_arm.c
+++ b/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_arm.c
@@ -24,9 +24,17 @@
#include "../avcodec.h"
extern void MPV_common_init_iwmmxt(MpegEncContext *s);
+extern void MPV_common_init_armv5te(MpegEncContext *s);
void MPV_common_init_armv4l(MpegEncContext *s)
{
+ /* IWMMXT support is a superset of armv5te, so
+ * allow optimised functions for armv5te unless
+ * a better iwmmxt function exists
+ */
+#ifdef HAVE_ARMV5TE
+ MPV_common_init_armv5te(s);
+#endif
#ifdef HAVE_IWMMXT
MPV_common_init_iwmmxt(s);
#endif
diff --git a/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_armv5te.c b/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_armv5te.c
new file mode 100644
index 000000000..5e83c8a43
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/armv4l/mpegvideo_armv5te.c
@@ -0,0 +1,213 @@
+/*
+ * Optimization of some functions from mpegvideo.c for armv5te
+ * Copyright (c) 2007 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
+ */
+
+/*
+ * Some useful links for those who may be interested in optimizing code for ARM.
+ * ARM Architecture Reference Manual: http://www.arm.com/community/academy/resources.html
+ * Instructions timings and optimization guide for ARM9E: http://www.arm.com/pdfs/DDI0222B_9EJS_r1p2.pdf
+ */
+
+#include "../dsputil.h"
+#include "../mpegvideo.h"
+#include "../avcodec.h"
+
+
+#ifdef ENABLE_ARM_TESTS
+/**
+ * h263 dequantizer supplementary function, it is performance critical and needs to
+ * have optimized implementations for each architecture. Is also used as a reference
+ * implementation in regression tests
+ */
+static inline void dct_unquantize_h263_helper_c(DCTELEM *block, int qmul, int qadd, int count)
+{
+ int i, level;
+ for (i = 0; i < count; i++) {
+ level = block[i];
+ if (level) {
+ if (level < 0) {
+ level = level * qmul - qadd;
+ } else {
+ level = level * qmul + qadd;
+ }
+ block[i] = level;
+ }
+ }
+}
+#endif
+
+/* GCC 3.1 or higher is required to support symbolic names in assembly code */
+#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
+
+/**
+ * Special optimized version of dct_unquantize_h263_helper_c, it requires the block
+ * to be at least 8 bytes aligned, and may process more elements than requested.
+ * But it is guaranteed to never process more than 64 elements provided that
+ * xxcount argument is <= 64, so it is safe. This macro is optimized for a common
+ * distribution of values for nCoeffs (they are mostly multiple of 8 plus one or
+ * two extra elements). So this macro processes data as 8 elements per loop iteration
+ * and contains optional 2 elements processing in the end.
+ *
+ * Inner loop should take 6 cycles per element on arm926ej-s (Nokia 770)
+ */
+#define dct_unquantize_h263_special_helper_armv5te(xxblock, xxqmul, xxqadd, xxcount) \
+({ DCTELEM *xblock = xxblock; \
+ int xqmul = xxqmul, xqadd = xxqadd, xcount = xxcount, xtmp; \
+ int xdata1, xdata2; \
+__asm__ __volatile__( \
+ "subs %[count], %[count], #2 \n\t" \
+ "ble 2f \n\t" \
+ "ldrd r4, [%[block], #0] \n\t" \
+ "1: \n\t" \
+ "ldrd r6, [%[block], #8] \n\t" \
+\
+ "rsbs %[data1], %[zero], r4, asr #16 \n\t" \
+ "addgt %[data1], %[qadd], #0 \n\t" \
+ "rsblt %[data1], %[qadd], #0 \n\t" \
+ "smlatbne %[data1], r4, %[qmul], %[data1] \n\t" \
+\
+ "rsbs %[data2], %[zero], r5, asr #16 \n\t" \
+ "addgt %[data2], %[qadd], #0 \n\t" \
+ "rsblt %[data2], %[qadd], #0 \n\t" \
+ "smlatbne %[data2], r5, %[qmul], %[data2] \n\t" \
+\
+ "rsbs %[tmp], %[zero], r4, asl #16 \n\t" \
+ "addgt %[tmp], %[qadd], #0 \n\t" \
+ "rsblt %[tmp], %[qadd], #0 \n\t" \
+ "smlabbne r4, r4, %[qmul], %[tmp] \n\t" \
+\
+ "rsbs %[tmp], %[zero], r5, asl #16 \n\t" \
+ "addgt %[tmp], %[qadd], #0 \n\t" \
+ "rsblt %[tmp], %[qadd], #0 \n\t" \
+ "smlabbne r5, r5, %[qmul], %[tmp] \n\t" \
+\
+ "strh r4, [%[block]], #2 \n\t" \
+ "strh %[data1], [%[block]], #2 \n\t" \
+ "strh r5, [%[block]], #2 \n\t" \
+ "strh %[data2], [%[block]], #2 \n\t" \
+\
+ "rsbs %[data1], %[zero], r6, asr #16 \n\t" \
+ "addgt %[data1], %[qadd], #0 \n\t" \
+ "rsblt %[data1], %[qadd], #0 \n\t" \
+ "smlatbne %[data1], r6, %[qmul], %[data1] \n\t" \
+\
+ "rsbs %[data2], %[zero], r7, asr #16 \n\t" \
+ "addgt %[data2], %[qadd], #0 \n\t" \
+ "rsblt %[data2], %[qadd], #0 \n\t" \
+ "smlatbne %[data2], r7, %[qmul], %[data2] \n\t" \
+\
+ "rsbs %[tmp], %[zero], r6, asl #16 \n\t" \
+ "addgt %[tmp], %[qadd], #0 \n\t" \
+ "rsblt %[tmp], %[qadd], #0 \n\t" \
+ "smlabbne r6, r6, %[qmul], %[tmp] \n\t" \
+\
+ "rsbs %[tmp], %[zero], r7, asl #16 \n\t" \
+ "addgt %[tmp], %[qadd], #0 \n\t" \
+ "rsblt %[tmp], %[qadd], #0 \n\t" \
+ "smlabbne r7, r7, %[qmul], %[tmp] \n\t" \
+\
+ "strh r6, [%[block]], #2 \n\t" \
+ "strh %[data1], [%[block]], #2 \n\t" \
+ "strh r7, [%[block]], #2 \n\t" \
+ "strh %[data2], [%[block]], #2 \n\t" \
+\
+ "subs %[count], %[count], #8 \n\t" \
+ "ldrgtd r4, [%[block], #0] \n\t" /* load data early to avoid load/use pipeline stall */ \
+ "bgt 1b \n\t" \
+\
+ "adds %[count], %[count], #2 \n\t" \
+ "ble 3f \n\t" \
+ "2: \n\t" \
+ "ldrsh %[data1], [%[block], #0] \n\t" \
+ "ldrsh %[data2], [%[block], #2] \n\t" \
+ "mov %[tmp], %[qadd] \n\t" \
+ "cmp %[data1], #0 \n\t" \
+ "rsblt %[tmp], %[qadd], #0 \n\t" \
+ "smlabbne %[data1], %[data1], %[qmul], %[tmp] \n\t" \
+ "mov %[tmp], %[qadd] \n\t" \
+ "cmp %[data2], #0 \n\t" \
+ "rsblt %[tmp], %[qadd], #0 \n\t" \
+ "smlabbne %[data2], %[data2], %[qmul], %[tmp] \n\t" \
+ "strh %[data1], [%[block]], #2 \n\t" \
+ "strh %[data2], [%[block]], #2 \n\t" \
+ "3: \n\t" \
+ : [block] "+&r" (xblock), [count] "+&r" (xcount), [tmp] "=&r" (xtmp), \
+ [data1] "=&r" (xdata1), [data2] "=&r" (xdata2) \
+ : [qmul] "r" (xqmul), [qadd] "r" (xqadd), [zero] "r" (0) \
+ : "r4", "r5", "r6", "r7", "cc", "memory" \
+); \
+})
+
+static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s,
+ DCTELEM *block, int n, int qscale)
+{
+ int i, level, qmul, qadd;
+ int nCoeffs;
+
+ assert(s->block_last_index[n]>=0);
+
+ qmul = qscale << 1;
+
+ if (!s->h263_aic) {
+ if (n < 4)
+ level = block[0] * s->y_dc_scale;
+ else
+ level = block[0] * s->c_dc_scale;
+ qadd = (qscale - 1) | 1;
+ }else{
+ qadd = 0;
+ level = block[0];
+ }
+ if(s->ac_pred)
+ nCoeffs=63;
+ else
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+
+ dct_unquantize_h263_special_helper_armv5te(block, qmul, qadd, nCoeffs + 1);
+ block[0] = level;
+}
+
+static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s,
+ DCTELEM *block, int n, int qscale)
+{
+ int i, level, qmul, qadd;
+ int nCoeffs;
+
+ assert(s->block_last_index[n]>=0);
+
+ qadd = (qscale - 1) | 1;
+ qmul = qscale << 1;
+
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+
+ dct_unquantize_h263_special_helper_armv5te(block, qmul, qadd, nCoeffs + 1);
+}
+
+#define HAVE_DCT_UNQUANTIZE_H263_ARMV5TE_OPTIMIZED
+
+#endif
+
+void MPV_common_init_armv5te(MpegEncContext *s)
+{
+#ifdef HAVE_DCT_UNQUANTIZE_H263_ARMV5TE_OPTIMIZED
+ s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te;
+ s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te;
+#endif
+}
diff --git a/contrib/ffmpeg/libavcodec/armv4l/simple_idct_armv6.S b/contrib/ffmpeg/libavcodec/armv4l/simple_idct_armv6.S
new file mode 100644
index 000000000..401e1910d
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/armv4l/simple_idct_armv6.S
@@ -0,0 +1,448 @@
+/*
+ * Simple IDCT
+ *
+ * Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at>
+ * Copyright (c) 2007 Mans Rullgard <mru@inprovide.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
+ */
+
+#define W1 22725 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define W2 21407 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define W3 19266 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define W4 16383 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define W5 12873 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define W6 8867 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define W7 4520 /* cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 */
+#define ROW_SHIFT 11
+#define COL_SHIFT 20
+
+#define W13 (W1 | (W3 << 16))
+#define W26 (W2 | (W6 << 16))
+#define W42 (W4 | (W2 << 16))
+#define W42n (-W4&0xffff | (-W2 << 16))
+#define W46 (W4 | (W6 << 16))
+#define W57 (W5 | (W7 << 16))
+
+ .text
+ .align
+w13: .long W13
+w26: .long W26
+w42: .long W42
+w42n: .long W42n
+w46: .long W46
+w57: .long W57
+
+/*
+ Compute partial IDCT of single row.
+ shift = left-shift amount
+ a1 = source address
+ a3 = row[2,0] <= 2 cycles
+ a4 = row[3,1]
+ ip = w42 <= 2 cycles
+
+ Output in registers v1--v8
+*/
+ .macro idct_row shift
+ ldr lr, [pc, #(w46-.-8)] /* lr = W4 | (W6 << 16) */
+ mov a2, #(1<<(\shift-1))
+ smlad v1, a3, ip, a2
+ smlsd v4, a3, ip, a2
+ ldr ip, [pc, #(w13-.-8)] /* ip = W1 | (W3 << 16) */
+ ldr v7, [pc, #(w57-.-8)] /* v7 = W5 | (W7 << 16) */
+ smlad v2, a3, lr, a2
+ smlsd v3, a3, lr, a2
+
+ smuad v5, a4, ip /* v5 = B0 = W1*row[1] + W3*row[3] */
+ smusdx fp, a4, v7 /* fp = B3 = W7*row[1] - W5*row[3] */
+ ldr lr, [a1, #12] /* lr = row[7,5] */
+ pkhtb a3, ip, v7, asr #16 /* a4 = W7 | (W3 << 16) */
+ pkhbt a2, ip, v7, lsl #16 /* a2 = W1 | (W5 << 16) */
+ smusdx v6, a3, a4 /* v6 = -B1 = W7*row[3] - W3*row[1] */
+ smlad v5, lr, v7, v5 /* B0 += W5*row[5] + W7*row[7] */
+ smusdx v7, a4, a2 /* v7 = B2 = W5*row[1] - W1*row[3] */
+
+ ldr a4, [pc, #(w42n-.-8)] /* a4 = -W4 | (-W2 << 16) */
+ smlad v7, lr, a3, v7 /* B2 += W7*row[5] + W3*row[7] */
+ ldr a3, [a1, #4] /* a3 = row[6,4] */
+ smlsdx fp, lr, ip, fp /* B3 += W3*row[5] - W1*row[7] */
+ ldr ip, [pc, #(w46-.-8)] /* ip = W4 | (W6 << 16) */
+ smlad v6, lr, a2, v6 /* B1 -= W1*row[5] + W5*row[7] */
+
+ smlad v2, a3, a4, v2 /* A1 += -W4*row[4] - W2*row[6] */
+ smlsd v3, a3, a4, v3 /* A2 += -W4*row[4] + W2*row[6] */
+ smlad v1, a3, ip, v1 /* A0 += W4*row[4] + W6*row[6] */
+ smlsd v4, a3, ip, v4 /* A3 += W4*row[4] - W6*row[6] */
+ .endm
+
+/*
+ Compute partial IDCT of half row.
+ shift = left-shift amount
+ a3 = row[2,0]
+ a4 = row[3,1]
+ ip = w42
+
+ Output in registers v1--v8
+*/
+ .macro idct_row4 shift
+ ldr lr, [pc, #(w46-.-8)] /* lr = W4 | (W6 << 16) */
+ ldr v7, [pc, #(w57-.-8)] /* v7 = W5 | (W7 << 16) */
+ mov a2, #(1<<(\shift-1))
+ smlad v1, a3, ip, a2
+ smlsd v4, a3, ip, a2
+ ldr ip, [pc, #(w13-.-8)] /* ip = W1 | (W3 << 16) */
+ smlad v2, a3, lr, a2
+ smlsd v3, a3, lr, a2
+ smusdx fp, a4, v7 /* fp = B3 = W7*row[1] - W5*row[3] */
+ smuad v5, a4, ip /* v5 = B0 = W1*row[1] + W3*row[3] */
+ pkhtb a3, ip, v7, asr #16 /* a4 = W7 | (W3 << 16) */
+ pkhbt a2, ip, v7, lsl #16 /* a2 = W1 | (W5 << 16) */
+ smusdx v6, a3, a4 /* v6 = -B1 = W7*row[3] - W3*row[1] */
+ smusdx v7, a4, a2 /* v7 = B2 = W5*row[1] - W1*row[3] */
+ .endm
+
+/*
+ Compute final part of IDCT single row without shift.
+ Input in registers v1--v8
+ Output in registers ip, v1--v3, lr, v5--v7
+*/
+ .macro idct_finish
+ add ip, v1, v5 /* a2 = A0 + B0 */
+ sub lr, v1, v5 /* a3 = A0 - B0 */
+ sub v1, v2, v6 /* a3 = A1 + B1 */
+ add v5, v2, v6 /* a3 = A1 - B1 */
+ add v2, v3, v7 /* a2 = A2 + B2 */
+ sub v6, v3, v7 /* a2 = A2 - B2 */
+ add v3, v4, fp /* a3 = A3 + B3 */
+ sub v7, v4, fp /* a3 = A3 - B3 */
+ .endm
+
+/*
+ Compute final part of IDCT single row.
+ shift = right-shift amount
+ Input/output in registers v1--v8
+*/
+ .macro idct_finish_shift shift
+ add a4, v1, v5 /* a4 = A0 + B0 */
+ sub a3, v1, v5 /* a3 = A0 - B0 */
+ mov v1, a4, asr #\shift
+ mov v5, a3, asr #\shift
+
+ sub a4, v2, v6 /* a4 = A1 + B1 */
+ add a3, v2, v6 /* a3 = A1 - B1 */
+ mov v2, a4, asr #\shift
+ mov v6, a3, asr #\shift
+
+ add a4, v3, v7 /* a4 = A2 + B2 */
+ sub a3, v3, v7 /* a3 = A2 - B2 */
+ mov v3, a4, asr #\shift
+ mov v7, a3, asr #\shift
+
+ add a4, v4, fp /* a4 = A3 + B3 */
+ sub a3, v4, fp /* a3 = A3 - B3 */
+ mov v4, a4, asr #\shift
+ mov fp, a3, asr #\shift
+ .endm
+
+/*
+ Compute final part of IDCT single row, saturating results at 8 bits.
+ shift = right-shift amount
+ Input/output in registers v1--v8
+*/
+ .macro idct_finish_shift_sat shift
+ add a4, v1, v5 /* a4 = A0 + B0 */
+ sub ip, v1, v5 /* ip = A0 - B0 */
+ usat v1, #8, a4, asr #\shift
+ usat v5, #8, ip, asr #\shift
+
+ sub a4, v2, v6 /* a4 = A1 + B1 */
+ add ip, v2, v6 /* ip = A1 - B1 */
+ usat v2, #8, a4, asr #\shift
+ usat v6, #8, ip, asr #\shift
+
+ add a4, v3, v7 /* a4 = A2 + B2 */
+ sub ip, v3, v7 /* ip = A2 - B2 */
+ usat v3, #8, a4, asr #\shift
+ usat v7, #8, ip, asr #\shift
+
+ add a4, v4, fp /* a4 = A3 + B3 */
+ sub ip, v4, fp /* ip = A3 - B3 */
+ usat v4, #8, a4, asr #\shift
+ usat fp, #8, ip, asr #\shift
+ .endm
+
+/*
+ Compute IDCT of single row, storing as column.
+ a1 = source
+ a2 = dest
+*/
+ .align
+ .func idct_row_armv6
+idct_row_armv6:
+ str lr, [sp, #-4]!
+
+ ldr lr, [a1, #12] /* lr = row[7,5] */
+ ldr ip, [a1, #4] /* ip = row[6,4] */
+ ldr a4, [a1, #8] /* a4 = row[3,1] */
+ ldr a3, [a1] /* a3 = row[2,0] */
+ orrs lr, lr, ip
+ cmpeq lr, a4
+ cmpeq lr, a3, lsr #16
+ beq 1f
+ str a2, [sp, #-4]!
+ ldr ip, [pc, #(w42-.-8)] /* ip = W4 | (W2 << 16) */
+ cmp lr, #0
+ beq 2f
+
+ idct_row ROW_SHIFT
+ b 3f
+
+2: idct_row4 ROW_SHIFT
+
+3: ldr a2, [sp], #4
+ idct_finish_shift ROW_SHIFT
+
+ strh v1, [a2]
+ strh v2, [a2, #(16*2)]
+ strh v3, [a2, #(16*4)]
+ strh v4, [a2, #(16*6)]
+ strh fp, [a2, #(16*1)]
+ strh v7, [a2, #(16*3)]
+ strh v6, [a2, #(16*5)]
+ strh v5, [a2, #(16*7)]
+
+ ldr pc, [sp], #4
+
+1: mov a3, a3, lsl #3
+ strh a3, [a2]
+ strh a3, [a2, #(16*2)]
+ strh a3, [a2, #(16*4)]
+ strh a3, [a2, #(16*6)]
+ strh a3, [a2, #(16*1)]
+ strh a3, [a2, #(16*3)]
+ strh a3, [a2, #(16*5)]
+ strh a3, [a2, #(16*7)]
+ ldr pc, [sp], #4
+ .endfunc
+
+/*
+ Compute IDCT of single column, read as row.
+ a1 = source
+ a2 = dest
+*/
+ .align
+ .func idct_col_armv6
+idct_col_armv6:
+ stmfd sp!, {a2, lr}
+
+ ldr a3, [a1] /* a3 = row[2,0] */
+ ldr ip, [pc, #(w42-.-8)] /* ip = W4 | (W2 << 16) */
+ ldr a4, [a1, #8] /* a4 = row[3,1] */
+ idct_row COL_SHIFT
+ ldr a2, [sp], #4
+ idct_finish_shift COL_SHIFT
+
+ strh v1, [a2]
+ strh v2, [a2, #(16*1)]
+ strh v3, [a2, #(16*2)]
+ strh v4, [a2, #(16*3)]
+ strh fp, [a2, #(16*4)]
+ strh v7, [a2, #(16*5)]
+ strh v6, [a2, #(16*6)]
+ strh v5, [a2, #(16*7)]
+
+ ldr pc, [sp], #4
+ .endfunc
+
+/*
+ Compute IDCT of single column, read as row, store saturated 8-bit.
+ a1 = source
+ a2 = dest
+ a3 = line size
+*/
+ .align
+ .func idct_col_put_armv6
+idct_col_put_armv6:
+ stmfd sp!, {a2, a3, lr}
+
+ ldr a3, [a1] /* a3 = row[2,0] */
+ ldr ip, [pc, #(w42-.-8)] /* ip = W4 | (W2 << 16) */
+ ldr a4, [a1, #8] /* a4 = row[3,1] */
+ idct_row COL_SHIFT
+ ldmfd sp!, {a2, a3}
+ idct_finish_shift_sat COL_SHIFT
+
+ strb v1, [a2], a3
+ strb v2, [a2], a3
+ strb v3, [a2], a3
+ strb v4, [a2], a3
+ strb fp, [a2], a3
+ strb v7, [a2], a3
+ strb v6, [a2], a3
+ strb v5, [a2], a3
+
+ sub a2, a2, a3, lsl #3
+
+ ldr pc, [sp], #4
+ .endfunc
+
+/*
+ Compute IDCT of single column, read as row, add/store saturated 8-bit.
+ a1 = source
+ a2 = dest
+ a3 = line size
+*/
+ .align
+ .func idct_col_add_armv6
+idct_col_add_armv6:
+ stmfd sp!, {a2, a3, lr}
+
+ ldr a3, [a1] /* a3 = row[2,0] */
+ ldr ip, [pc, #(w42-.-8)] /* ip = W4 | (W2 << 16) */
+ ldr a4, [a1, #8] /* a4 = row[3,1] */
+ idct_row COL_SHIFT
+ ldmfd sp!, {a2, a3}
+ idct_finish
+
+ ldrb a4, [a2]
+ ldrb v4, [a2, a3]
+ ldrb fp, [a2, a3, lsl #2]
+ add ip, a4, ip, asr #COL_SHIFT
+ usat ip, #8, ip
+ add v1, v4, v1, asr #COL_SHIFT
+ strb ip, [a2], a3
+ ldrb ip, [a2, a3]
+ usat v1, #8, v1
+ ldrb fp, [a2, a3, lsl #2]
+ add v2, ip, v2, asr #COL_SHIFT
+ usat v2, #8, v2
+ strb v1, [a2], a3
+ ldrb a4, [a2, a3]
+ ldrb ip, [a2, a3, lsl #2]
+ strb v2, [a2], a3
+ ldrb v4, [a2, a3]
+ ldrb v1, [a2, a3, lsl #2]
+ add v3, a4, v3, asr #COL_SHIFT
+ usat v3, #8, v3
+ add v7, v4, v7, asr #COL_SHIFT
+ usat v7, #8, v7
+ add v6, fp, v6, asr #COL_SHIFT
+ usat v6, #8, v6
+ add v5, ip, v5, asr #COL_SHIFT
+ usat v5, #8, v5
+ add lr, v1, lr, asr #COL_SHIFT
+ usat lr, #8, lr
+ strb v3, [a2], a3
+ strb v7, [a2], a3
+ strb v6, [a2], a3
+ strb v5, [a2], a3
+ strb lr, [a2], a3
+
+ sub a2, a2, a3, lsl #3
+
+ ldr pc, [sp], #4
+ .endfunc
+
+/*
+ Compute 8 IDCT row transforms.
+ func = IDCT row->col function
+ width = width of columns in bytes
+*/
+ .macro idct_rows func width
+ bl \func
+ add a1, a1, #(16*2)
+ add a2, a2, #\width
+ bl \func
+ add a1, a1, #(16*2)
+ add a2, a2, #\width
+ bl \func
+ add a1, a1, #(16*2)
+ add a2, a2, #\width
+ bl \func
+ sub a1, a1, #(16*5)
+ add a2, a2, #\width
+ bl \func
+ add a1, a1, #(16*2)
+ add a2, a2, #\width
+ bl \func
+ add a1, a1, #(16*2)
+ add a2, a2, #\width
+ bl \func
+ add a1, a1, #(16*2)
+ add a2, a2, #\width
+ bl \func
+
+ sub a1, a1, #(16*7)
+ .endm
+
+ .align
+ .global ff_simple_idct_armv6
+ .func ff_simple_idct_armv6
+/* void ff_simple_idct_armv6(DCTELEM *data); */
+ff_simple_idct_armv6:
+ stmfd sp!, {v1, v2, v3, v4, v5, v6, v7, fp, lr}
+ sub sp, sp, #128
+
+ mov a2, sp
+ idct_rows idct_row_armv6, 2
+ mov a2, a1
+ mov a1, sp
+ idct_rows idct_col_armv6, 2
+
+ add sp, sp, #128
+ ldmfd sp!, {v1, v2, v3, v4, v5, v6, v7, fp, pc}
+ .endfunc
+
+ .align
+ .global ff_simple_idct_add_armv6
+ .func ff_simple_idct_add_armv6
+/* ff_simple_idct_add_armv6(uint8_t *dest, int line_size, DCTELEM *data); */
+ff_simple_idct_add_armv6:
+ stmfd sp!, {a1, a2, v1, v2, v3, v4, v5, v6, v7, fp, lr}
+ sub sp, sp, #128
+
+ mov a1, a3
+ mov a2, sp
+ idct_rows idct_row_armv6, 2
+ mov a1, sp
+ ldr a2, [sp, #128]
+ ldr a3, [sp, #(128+4)]
+ idct_rows idct_col_add_armv6, 1
+
+ add sp, sp, #(128+8)
+ ldmfd sp!, {v1, v2, v3, v4, v5, v6, v7, fp, pc}
+ .endfunc
+
+ .align
+ .global ff_simple_idct_put_armv6
+ .func ff_simple_idct_put_armv6
+/* ff_simple_idct_put_armv6(uint8_t *dest, int line_size, DCTELEM *data); */
+ff_simple_idct_put_armv6:
+ stmfd sp!, {a1, a2, v1, v2, v3, v4, v5, v6, v7, fp, lr}
+ sub sp, sp, #128
+
+ mov a1, a3
+ mov a2, sp
+ idct_rows idct_row_armv6, 2
+ mov a1, sp
+ ldr a2, [sp, #128]
+ ldr a3, [sp, #(128+4)]
+ idct_rows idct_col_put_armv6, 1
+
+ add sp, sp, #(128+8)
+ ldmfd sp!, {v1, v2, v3, v4, v5, v6, v7, fp, pc}
+ .endfunc
diff --git a/contrib/ffmpeg/libavcodec/avcodec.h b/contrib/ffmpeg/libavcodec/avcodec.h
index da063b562..1d8427a9d 100644
--- a/contrib/ffmpeg/libavcodec/avcodec.h
+++ b/contrib/ffmpeg/libavcodec/avcodec.h
@@ -37,16 +37,22 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVCODEC_VERSION_INT ((51<<16)+(25<<8)+0)
-#define LIBAVCODEC_VERSION 51.25.0
+#define LIBAVCODEC_VERSION_INT ((51<<16)+(40<<8)+2)
+#define LIBAVCODEC_VERSION 51.40.2
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
-#define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
+#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
#define AV_TIME_BASE 1000000
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
+/**
+ *
+ * if you add a codec id to this list add it so that
+ * 1. no value of a existing codec id changes (that would break ABI)
+ * 2. closest to similar codecs
+ */
enum CodecID {
CODEC_ID_NONE,
CODEC_ID_MPEG1VIDEO,
@@ -149,6 +155,10 @@ enum CodecID {
CODEC_ID_TIERTEXSEQVIDEO,
CODEC_ID_TIFF,
CODEC_ID_GIF,
+ CODEC_ID_FFH264,
+ CODEC_ID_DXA,
+ CODEC_ID_DNXHD,
+ CODEC_ID_THP,
/* various pcm "codecs" */
CODEC_ID_PCM_S16LE= 0x10000,
@@ -226,7 +236,7 @@ enum CodecID {
CODEC_ID_SHORTEN,
CODEC_ID_ALAC,
CODEC_ID_WESTWOOD_SND1,
- CODEC_ID_GSM,
+ CODEC_ID_GSM, /* As in Berlin toast format */
CODEC_ID_QDM2,
CODEC_ID_COOK,
CODEC_ID_TRUESPEECH,
@@ -236,6 +246,9 @@ enum CodecID {
CODEC_ID_WAVPACK,
CODEC_ID_DSICINAUDIO,
CODEC_ID_IMC,
+ CODEC_ID_MUSEPACK7,
+ CODEC_ID_MLP,
+ CODEC_ID_GSM_MS, /* As found in WAV */
/* subtitle codecs */
CODEC_ID_DVD_SUBTITLE= 0x17000,
@@ -245,8 +258,11 @@ enum CodecID {
stream (only used by libavformat) */
};
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
/* CODEC_ID_MP3LAME is absolete */
#define CODEC_ID_MP3LAME CODEC_ID_MP3
+#define CODEC_ID_MPEG4AAC CODEC_ID_AAC
+#endif
enum CodecType {
CODEC_TYPE_UNKNOWN = -1,
@@ -254,6 +270,7 @@ enum CodecType {
CODEC_TYPE_AUDIO,
CODEC_TYPE_DATA,
CODEC_TYPE_SUBTITLE,
+ CODEC_TYPE_NB
};
/* currently unused, may be used if 24/32 bits samples ever supported */
@@ -328,7 +345,7 @@ typedef struct RcOverride{
#define CODEC_FLAG_GMC 0x0020 ///< use GMC
#define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
#define CODEC_FLAG_PART 0x0080 ///< use data partitioning
-/* parent program gurantees that the input for b-frame containing streams is not written to
+/* parent program guarantees that the input for b-frame containing streams is not written to
for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
#define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
@@ -347,7 +364,9 @@ typedef struct RcOverride{
#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
/* Fx : Flag for h263+ extra options */
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
#define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
+#endif
#define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
#define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
@@ -365,7 +384,7 @@ typedef struct RcOverride{
#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< place global headers at every keyframe instead of in extradata
#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow b-frames to be used as references
#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for b-frames
-#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 multiple references per partition
+#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
@@ -373,11 +392,14 @@ typedef struct RcOverride{
#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table
#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< only do ME/MC (I frames -> ref, P frame -> ME+MC)
#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format
+#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skiping
+#define CODEC_FLAG2_CHUNKS 0x00008000 ///< input bitstream might be truncated at a packet boundaries instead of only at frame boundaries
+#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< use MPEG-2 non linear quantizer
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
* Reference Picture Selection
- * Independant Segment Decoding */
+ * Independent Segment Decoding */
/* /Fx */
/* codec capabilities */
@@ -395,7 +417,7 @@ typedef struct RcOverride{
#define CODEC_CAP_HWACCEL 0x0010
/**
* codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
- * if this is not set, the codec is guranteed to never be feeded with NULL data
+ * if this is not set, the codec is guaranteed to never be feeded with NULL data
*/
#define CODEC_CAP_DELAY 0x0020
/**
@@ -728,7 +750,10 @@ typedef struct AVCodecContext {
/**
* some codecs needs additionnal format info. It is stored here
- * - encoding: set by user.
+ * if any muxer uses this then ALL demuxers/parsers AND encoders for the specific codec MUST set it correctly
+ * too otherwise stream copy breaks
+ * in general use of this field by muxers is not recommanded
+ * - encoding: set by lavc.
* - decoding: set by lavc. (FIXME is this ok?)
*/
int sub_id;
@@ -862,7 +887,7 @@ typedef struct AVCodecContext {
int qmax;
/**
- * maximum quantizer difference etween frames.
+ * maximum quantizer difference between frames.
* - encoding: set by user.
* - decoding: unused
*/
@@ -891,9 +916,9 @@ typedef struct AVCodecContext {
/**
* hurry up amount.
- * deprecated in favor of skip_idct and skip_frame
* - encoding: unused
* - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
+ * @deprecated Deprecated in favor of skip_idct and skip_frame.
*/
int hurry_up;
@@ -901,8 +926,10 @@ typedef struct AVCodecContext {
void *priv_data;
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
/* unused, FIXME remove*/
int rtp_mode;
+#endif
int rtp_payload_size; /* The size of the RTP payload: the coder will */
/* do it's best to deliver a chunk with size */
@@ -951,6 +978,13 @@ typedef struct AVCodecContext {
/**
* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
* this is used to workaround some encoder bugs
+ * a demuxer should set this to what is stored in the field used to identify the codec
+ * if there are mutiple such fields in a container then the demuxer should choose the one
+ * which maximizes the information about the used codec
+ * if the codec tag field in a container is larger then 32bit then the demxuer should
+ * remap the longer id to 32bit with a table or other structure alternatively a new
+ * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
+ * first
* - encoding: set by user, if not then the default based on codec_id will be used
* - decoding: set by user, will be converted to upper case by lavc during init
*/
@@ -1231,6 +1265,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_XVIDMMX 14
#define FF_IDCT_CAVS 15
#define FF_IDCT_SIMPLEARMV5TE 16
+#define FF_IDCT_SIMPLEARMV6 17
/**
* slice count.
@@ -1698,14 +1733,14 @@ typedef struct AVCodecContext {
/**
* Thread count.
- * is used to decide how many independant tasks should be passed to execute()
+ * is used to decide how many independent tasks should be passed to execute()
* - encoding: set by user
* - decoding: set by user
*/
int thread_count;
/**
- * the codec may call this to execute several independant things. it will return only after
+ * the codec may call this to execute several independent things. it will return only after
* finishing all tasks, the user may replace this with some multithreaded implementation, the
* default implementation will execute the parts serially
* @param count the number of things to execute
@@ -2083,9 +2118,6 @@ typedef struct AVCodec {
int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
uint8_t *buf, int buf_size);
int capabilities;
-#if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0)
- void *dummy; // FIXME remove next time we break binary compatibility
-#endif
struct AVCodec *next;
void (*flush)(AVCodecContext *);
const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
@@ -2143,240 +2175,254 @@ typedef struct AVSubtitle {
} AVSubtitle;
extern AVCodec ac3_encoder;
-extern AVCodec mp2_encoder;
-extern AVCodec mp3lame_encoder;
-extern AVCodec oggvorbis_encoder;
+extern AVCodec amr_nb_encoder;
+extern AVCodec amr_wb_encoder;
+extern AVCodec asv1_encoder;
+extern AVCodec asv2_encoder;
+extern AVCodec bmp_encoder;
+extern AVCodec dvvideo_encoder;
extern AVCodec faac_encoder;
+extern AVCodec ffv1_encoder;
+extern AVCodec ffvhuff_encoder;
extern AVCodec flac_encoder;
+extern AVCodec flashsv_encoder;
+extern AVCodec flv_encoder;
extern AVCodec gif_encoder;
-extern AVCodec xvid_encoder;
-extern AVCodec mpeg1video_encoder;
-extern AVCodec mpeg2video_encoder;
extern AVCodec h261_encoder;
extern AVCodec h263_encoder;
extern AVCodec h263p_encoder;
-extern AVCodec flv_encoder;
-extern AVCodec rv10_encoder;
-extern AVCodec rv20_encoder;
-extern AVCodec dvvideo_encoder;
-extern AVCodec mjpeg_encoder;
-extern AVCodec ljpeg_encoder;
+extern AVCodec h264_encoder;
+extern AVCodec huffyuv_encoder;
extern AVCodec jpegls_encoder;
-extern AVCodec png_encoder;
-extern AVCodec ppm_encoder;
-extern AVCodec pgm_encoder;
-extern AVCodec pgmyuv_encoder;
-extern AVCodec pbm_encoder;
-extern AVCodec pam_encoder;
+extern AVCodec libgsm_encoder;
+extern AVCodec libgsm_ms_encoder;
+extern AVCodec libtheora_encoder;
+extern AVCodec ljpeg_encoder;
+extern AVCodec mdec_encoder;
+extern AVCodec mjpeg_encoder;
+extern AVCodec mp2_encoder;
+extern AVCodec mp3lame_encoder;
+extern AVCodec mpeg1video_encoder;
+extern AVCodec mpeg2video_encoder;
extern AVCodec mpeg4_encoder;
extern AVCodec msmpeg4v1_encoder;
extern AVCodec msmpeg4v2_encoder;
extern AVCodec msmpeg4v3_encoder;
-extern AVCodec wmv1_encoder;
-extern AVCodec wmv2_encoder;
-extern AVCodec huffyuv_encoder;
-extern AVCodec ffvhuff_encoder;
-extern AVCodec h264_encoder;
-extern AVCodec asv1_encoder;
-extern AVCodec asv2_encoder;
-extern AVCodec vcr1_encoder;
-extern AVCodec ffv1_encoder;
+extern AVCodec oggvorbis_encoder;
+extern AVCodec pam_encoder;
+extern AVCodec pbm_encoder;
+extern AVCodec pgm_encoder;
+extern AVCodec pgmyuv_encoder;
+extern AVCodec png_encoder;
+extern AVCodec ppm_encoder;
+extern AVCodec rv10_encoder;
+extern AVCodec rv20_encoder;
extern AVCodec snow_encoder;
-extern AVCodec vorbis_encoder;
-extern AVCodec mdec_encoder;
-extern AVCodec zlib_encoder;
extern AVCodec sonic_encoder;
extern AVCodec sonic_ls_encoder;
extern AVCodec svq1_encoder;
+extern AVCodec targa_encoder;
+extern AVCodec vcr1_encoder;
+extern AVCodec vorbis_encoder;
+extern AVCodec wmav1_encoder;
+extern AVCodec wmav2_encoder;
+extern AVCodec wmv1_encoder;
+extern AVCodec wmv2_encoder;
extern AVCodec x264_encoder;
+extern AVCodec xvid_encoder;
+extern AVCodec zlib_encoder;
+extern AVCodec zmbv_encoder;
+extern AVCodec aac_decoder;
+extern AVCodec aasc_decoder;
+extern AVCodec alac_decoder;
+extern AVCodec amr_nb_decoder;
+extern AVCodec amr_wb_decoder;
+extern AVCodec asv1_decoder;
+extern AVCodec asv2_decoder;
+extern AVCodec avs_decoder;
+extern AVCodec bmp_decoder;
+extern AVCodec cavs_decoder;
+extern AVCodec cinepak_decoder;
+extern AVCodec cljr_decoder;
+extern AVCodec cook_decoder;
+extern AVCodec cscd_decoder;
+extern AVCodec cyuv_decoder;
+extern AVCodec dca_decoder;
+extern AVCodec dnxhd_decoder;
+extern AVCodec dsicinaudio_decoder;
+extern AVCodec dsicinvideo_decoder;
+extern AVCodec dvvideo_decoder;
+extern AVCodec dxa_decoder;
+extern AVCodec eightbps_decoder;
+extern AVCodec ffv1_decoder;
+extern AVCodec ffvhuff_decoder;
+extern AVCodec flac_decoder;
+extern AVCodec flashsv_decoder;
+extern AVCodec flic_decoder;
+extern AVCodec flv_decoder;
+extern AVCodec fourxm_decoder;
+extern AVCodec fraps_decoder;
extern AVCodec gif_decoder;
-extern AVCodec h263_decoder;
extern AVCodec h261_decoder;
-extern AVCodec mpeg4_decoder;
-extern AVCodec msmpeg4v1_decoder;
-extern AVCodec msmpeg4v2_decoder;
-extern AVCodec msmpeg4v3_decoder;
-extern AVCodec wmv1_decoder;
-extern AVCodec wmv2_decoder;
-extern AVCodec vc1_decoder;
-extern AVCodec wmv3_decoder;
-extern AVCodec mpeg1video_decoder;
-extern AVCodec mpeg2video_decoder;
-extern AVCodec mpegvideo_decoder;
-extern AVCodec mpeg_xvmc_decoder;
+extern AVCodec h263_decoder;
extern AVCodec h263i_decoder;
-extern AVCodec flv_decoder;
-extern AVCodec rv10_decoder;
-extern AVCodec rv20_decoder;
-extern AVCodec rv30_decoder;
-extern AVCodec rv40_decoder;
-extern AVCodec svq1_decoder;
-extern AVCodec svq3_decoder;
-extern AVCodec dvvideo_decoder;
-extern AVCodec wmav1_decoder;
-extern AVCodec wmav2_decoder;
+extern AVCodec h264_decoder;
+extern AVCodec huffyuv_decoder;
+extern AVCodec idcin_decoder;
+extern AVCodec imc_decoder;
+extern AVCodec indeo2_decoder;
+extern AVCodec indeo3_decoder;
+extern AVCodec interplay_dpcm_decoder;
+extern AVCodec interplay_video_decoder;
+extern AVCodec kmvc_decoder;
+extern AVCodec libgsm_decoder;
+extern AVCodec libgsm_ms_decoder;
+extern AVCodec loco_decoder;
+extern AVCodec mace3_decoder;
+extern AVCodec mace6_decoder;
+extern AVCodec mdec_decoder;
extern AVCodec mjpeg_decoder;
extern AVCodec mjpegb_decoder;
-extern AVCodec sp5x_decoder;
-extern AVCodec png_decoder;
+extern AVCodec mmvideo_decoder;
extern AVCodec mp2_decoder;
extern AVCodec mp3_decoder;
extern AVCodec mp3adu_decoder;
extern AVCodec mp3on4_decoder;
-extern AVCodec qdm2_decoder;
-extern AVCodec cook_decoder;
-extern AVCodec truespeech_decoder;
-extern AVCodec tta_decoder;
-extern AVCodec mace3_decoder;
-extern AVCodec mace6_decoder;
-extern AVCodec huffyuv_decoder;
-extern AVCodec ffvhuff_decoder;
-extern AVCodec oggvorbis_decoder;
-extern AVCodec cyuv_decoder;
-extern AVCodec h264_decoder;
-extern AVCodec indeo3_decoder;
-extern AVCodec vp3_decoder;
-extern AVCodec theora_decoder;
-extern AVCodec vp5_decoder;
-extern AVCodec vp6_decoder;
-extern AVCodec vp6f_decoder;
-extern AVCodec amr_nb_decoder;
-extern AVCodec amr_nb_encoder;
-extern AVCodec amr_wb_encoder;
-extern AVCodec amr_wb_decoder;
-extern AVCodec aac_decoder;
+extern AVCodec mpc7_decoder;
+extern AVCodec mpeg1video_decoder;
+extern AVCodec mpeg2video_decoder;
+extern AVCodec mpeg4_decoder;
extern AVCodec mpeg4aac_decoder;
-extern AVCodec asv1_decoder;
-extern AVCodec asv2_decoder;
-extern AVCodec vcr1_decoder;
-extern AVCodec cljr_decoder;
-extern AVCodec ffv1_decoder;
-extern AVCodec snow_decoder;
-extern AVCodec fourxm_decoder;
-extern AVCodec mdec_decoder;
-extern AVCodec roq_decoder;
-extern AVCodec interplay_video_decoder;
-extern AVCodec xan_wc3_decoder;
-extern AVCodec rpza_decoder;
-extern AVCodec cinepak_decoder;
+extern AVCodec mpeg_xvmc_decoder;
+extern AVCodec mpegvideo_decoder;
+extern AVCodec msmpeg4v1_decoder;
+extern AVCodec msmpeg4v2_decoder;
+extern AVCodec msmpeg4v3_decoder;
extern AVCodec msrle_decoder;
extern AVCodec msvideo1_decoder;
-extern AVCodec vqa_decoder;
-extern AVCodec idcin_decoder;
-extern AVCodec eightbps_decoder;
-extern AVCodec smc_decoder;
-extern AVCodec flic_decoder;
-extern AVCodec vmdvideo_decoder;
-extern AVCodec vmdaudio_decoder;
-extern AVCodec truemotion1_decoder;
-extern AVCodec truemotion2_decoder;
extern AVCodec mszh_decoder;
-extern AVCodec zlib_decoder;
+extern AVCodec nuv_decoder;
+extern AVCodec oggvorbis_decoder;
+extern AVCodec png_decoder;
+extern AVCodec qdm2_decoder;
+extern AVCodec qdraw_decoder;
+extern AVCodec qpeg_decoder;
+extern AVCodec qtrle_decoder;
extern AVCodec ra_144_decoder;
extern AVCodec ra_288_decoder;
+extern AVCodec roq_decoder;
extern AVCodec roq_dpcm_decoder;
-extern AVCodec interplay_dpcm_decoder;
-extern AVCodec xan_dpcm_decoder;
+extern AVCodec rpza_decoder;
+extern AVCodec rv10_decoder;
+extern AVCodec rv20_decoder;
+extern AVCodec rv30_decoder;
+extern AVCodec rv40_decoder;
+extern AVCodec shorten_decoder;
+extern AVCodec smackaud_decoder;
+extern AVCodec smacker_decoder;
+extern AVCodec smc_decoder;
+extern AVCodec snow_decoder;
extern AVCodec sol_dpcm_decoder;
extern AVCodec sonic_decoder;
-extern AVCodec qtrle_decoder;
-extern AVCodec flac_decoder;
+extern AVCodec sp5x_decoder;
+extern AVCodec svq1_decoder;
+extern AVCodec svq3_decoder;
+extern AVCodec targa_decoder;
+extern AVCodec theora_decoder;
+extern AVCodec thp_decoder;
+extern AVCodec tiertexseqvideo_decoder;
+extern AVCodec tiff_decoder;
+extern AVCodec truemotion1_decoder;
+extern AVCodec truemotion2_decoder;
+extern AVCodec truespeech_decoder;
extern AVCodec tscc_decoder;
-extern AVCodec cscd_decoder;
-extern AVCodec nuv_decoder;
+extern AVCodec tta_decoder;
extern AVCodec ulti_decoder;
-extern AVCodec qdraw_decoder;
-extern AVCodec xl_decoder;
-extern AVCodec qpeg_decoder;
-extern AVCodec shorten_decoder;
-extern AVCodec loco_decoder;
+extern AVCodec vc1_decoder;
+extern AVCodec vcr1_decoder;
+extern AVCodec vmdaudio_decoder;
+extern AVCodec vmdvideo_decoder;
+extern AVCodec vmnc_decoder;
+extern AVCodec vorbis_decoder;
+extern AVCodec vp3_decoder;
+extern AVCodec vp5_decoder;
+extern AVCodec vp6_decoder;
+extern AVCodec vp6f_decoder;
+extern AVCodec vqa_decoder;
+extern AVCodec wavpack_decoder;
+extern AVCodec wmav1_decoder;
+extern AVCodec wmav2_decoder;
+extern AVCodec wmv1_decoder;
+extern AVCodec wmv2_decoder;
+extern AVCodec wmv3_decoder;
extern AVCodec wnv1_decoder;
-extern AVCodec aasc_decoder;
-extern AVCodec alac_decoder;
extern AVCodec ws_snd1_decoder;
-extern AVCodec indeo2_decoder;
-extern AVCodec vorbis_decoder;
-extern AVCodec fraps_decoder;
-extern AVCodec libgsm_encoder;
-extern AVCodec libgsm_decoder;
-extern AVCodec bmp_decoder;
-extern AVCodec mmvideo_decoder;
+extern AVCodec xan_dpcm_decoder;
+extern AVCodec xan_wc3_decoder;
+extern AVCodec xl_decoder;
+extern AVCodec zlib_decoder;
extern AVCodec zmbv_decoder;
-extern AVCodec avs_decoder;
-extern AVCodec smacker_decoder;
-extern AVCodec smackaud_decoder;
-extern AVCodec kmvc_decoder;
-extern AVCodec flashsv_decoder;
-extern AVCodec cavs_decoder;
-extern AVCodec vmnc_decoder;
-extern AVCodec wavpack_decoder;
-extern AVCodec targa_decoder;
-extern AVCodec dsicinvideo_decoder;
-extern AVCodec dsicinaudio_decoder;
-extern AVCodec tiertexseqvideo_decoder;
-extern AVCodec tiff_decoder;
-extern AVCodec imc_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
extern AVCodec name ## _decoder; \
extern AVCodec name ## _encoder
-PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
-PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
-PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
-PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
-PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
-PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
-PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
-PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
+PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
+PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
+PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
+PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
+PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
+PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
-PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
-PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
-PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
-PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
-PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
-PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
-PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
-PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
+PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
+PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
+PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
+PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
+PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
+PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
+PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
+PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
+PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
+PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
/* adpcm codecs */
-PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
+PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
+PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
+PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
+PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
+PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
-PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
-PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
-PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
-PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
-PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
-PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
-PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
-PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
-PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
-PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
-PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
-PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
+PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
PCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2);
+PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
+PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
+PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
+PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
+PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
+PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
#undef PCM_CODEC
/* dummy raw video codec */
-extern AVCodec rawvideo_encoder;
extern AVCodec rawvideo_decoder;
+extern AVCodec rawvideo_encoder;
/* the following codecs use external GPL libs */
-extern AVCodec ac3_decoder;
extern AVCodec dts_decoder;
+extern AVCodec liba52_decoder;
/* subtitles */
-extern AVCodec dvdsub_encoder;
-extern AVCodec dvdsub_decoder;
-extern AVCodec dvbsub_encoder;
extern AVCodec dvbsub_decoder;
+extern AVCodec dvbsub_encoder;
+extern AVCodec dvdsub_decoder;
+extern AVCodec dvdsub_encoder;
/* resample.c */
@@ -2395,16 +2441,17 @@ int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consum
void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
void av_resample_close(struct AVResampleContext *c);
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
/* YUV420 format is assumed ! */
-struct ImgReSampleContext;
+struct ImgReSampleContext attribute_deprecated;
-typedef struct ImgReSampleContext ImgReSampleContext;
+typedef struct ImgReSampleContext ImgReSampleContext attribute_deprecated;
-ImgReSampleContext *img_resample_init(int output_width, int output_height,
+attribute_deprecated ImgReSampleContext *img_resample_init(int output_width, int output_height,
int input_width, int input_height);
-ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
+attribute_deprecated ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int iwidth, int iheight,
int topBand, int bottomBand,
int leftBand, int rightBand,
@@ -2412,10 +2459,12 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int padleft, int padright);
-void img_resample(ImgReSampleContext *s,
+attribute_deprecated void img_resample(ImgReSampleContext *s,
AVPicture *output, const AVPicture *input);
-void img_resample_close(ImgReSampleContext *s);
+attribute_deprecated void img_resample_close(ImgReSampleContext *s);
+
+#endif
/**
* Allocate memory for a picture. Call avpicture_free to free it.
@@ -2424,17 +2473,47 @@ void img_resample_close(ImgReSampleContext *s);
* @param pix_fmt the format of the picture.
* @param width the width of the picture.
* @param height the height of the picture.
- * @return 0 if successful, -1 if not.
+ * @return Zero if successful, a negative value if not.
*/
int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
-/* Free a picture previously allocated by avpicture_alloc. */
+/**
+ * Free a picture previously allocated by avpicture_alloc().
+ *
+ * @param picture The AVPicture to be freed.
+ */
void avpicture_free(AVPicture *picture);
+/**
+ * Fill in AVPicture's fields.
+ * The fields of the given AVPicture are filled in by using the 'ptr' address
+ * which points to the image data buffer. Depending on the specified picture
+ * format, one or multiple image data pointers and line sizes will be set.
+ * If a planar format is specified, several pointers will be set pointing to
+ * the different picture planes and the line sizes of the different planes
+ * will be stored in the lines_sizes array.
+ *
+ * @param picture AVPicture who's fields are to be filled in
+ * @param ptr Buffer which will contain or contains the actual image data
+ * @param pix_fmt The format in which the picture data is stored
+ * @param width The width of the image in pixels
+ * @param height The height of the image in pixels
+ * @return Size of the image data in bytes.
+ */
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height);
int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
unsigned char *dest, int dest_size);
+
+/**
+ * Calculate the size in bytes that a picture of the given width and height
+ * would occupy if stored in the given picture format.
+ *
+ * @param pix_fmt The given picture format
+ * @param width The width of the image
+ * @param height The height of the image
+ * @return Image data size in bytes
+ */
int avpicture_get_size(int pix_fmt, int width, int height);
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
const char *avcodec_get_pix_fmt_name(int pix_fmt);
@@ -2442,29 +2521,77 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
enum PixelFormat avcodec_get_pix_fmt(const char* name);
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
-#define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
-#define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
-#define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
-#define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
-#define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
-#define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
+#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
+#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
+#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
+#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
+#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
+#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
+/**
+ * Computes what kind of losses will occur when converting from one specific
+ * pixel format to another.
+ * When converting from one pixel format to another, information loss may occur.
+ * For example, when converting from RGB24 to GRAY, the color information will
+ * be lost. Similarly, other losses occur when converting from some formats to
+ * other formats. These losses can involve loss of chroma, but also loss of
+ * resolution, loss of color depth, loss due to the color space conversion, loss
+ * of the alpha bits or loss due to color quantization.
+ * avcodec_get_fix_fmt_loss() informs you on the various types of losses which
+ * will occur when converting from one pixel format to another.
+ *
+ * @param[in] dst_pix_fmt Destination pixel format.
+ * @param[in] src_pix_fmt Source pixel format.
+ * @param[in] has_alpha Whether the source pixel format alpha channel is used.
+ * @return Combination of flags informing you what kind of losses will occur.
+ */
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
int has_alpha);
+
+/**
+ * Finds the best pixel format to convert to given a certain source pixel
+ * format. When converting from one pixel format to another, information loss
+ * may occur. For example, when converting from RGB24 to GRAY, the color
+ * information will be lost. Similarly, other losses occur when converting from
+ * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
+ * the given pixel formats should be used to undergo the least amount of losses.
+ * The pixel formats from which it choses one, are determined by the
+ * \p pix_fmt_mask parameter.
+ *
+ * @code
+ * src_pix_fmt = PIX_FMT_YUV420P;
+ * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
+ * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
+ * @endcode
+ *
+ * @param[in] pix_fmt_mask Bitmask determining which pixel format to choose from.
+ * @param[in] src_pix_fmt Source pixel format.
+ * @param[in] has_alpha Whether the source pixel format alpha channel is used.
+ * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
+ * @return The best pixel format to convert to or -1 if none was found.
+ */
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
int has_alpha, int *loss_ptr);
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
+
+/**
+ * Tell if an image really has transparent alpha values.
+ * @return ored mask of FF_ALPHA_xxx constants
+ */
int img_get_alpha_info(const AVPicture *src,
int pix_fmt, int width, int height);
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
/* convert among pixel formats */
-int img_convert(AVPicture *dst, int dst_pix_fmt,
+attribute_deprecated int img_convert(AVPicture *dst, int dst_pix_fmt,
const AVPicture *src, int pix_fmt,
int width, int height);
+#endif
/* deinterlace a picture */
+/* deinterlace - if not supported return -1 */
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height);
@@ -2476,24 +2603,103 @@ extern AVCodec *first_avcodec;
unsigned avcodec_version(void);
/* returns LIBAVCODEC_BUILD constant */
unsigned avcodec_build(void);
+
+/**
+ * Initializes libavcodec.
+ *
+ * @warning This function \e must be called before any other libavcodec
+ * function.
+ */
void avcodec_init(void);
void register_avcodec(AVCodec *format);
+
+/**
+ * Finds an encoder with a matching codec ID.
+ *
+ * @param id CodecID of the requested encoder.
+ * @return An encoder if one was found, NULL otherwise.
+ */
AVCodec *avcodec_find_encoder(enum CodecID id);
+
+/**
+ * Finds an encoder with the specified name.
+ *
+ * @param name Name of the requested encoder.
+ * @return An encoder if one was found, NULL otherwise.
+ */
AVCodec *avcodec_find_encoder_by_name(const char *name);
+
+/**
+ * Finds a decoder with a matching codec ID.
+ *
+ * @param id CodecID of the requested decoder.
+ * @return A decoder if one was found, NULL otherwise.
+ */
AVCodec *avcodec_find_decoder(enum CodecID id);
+
+/**
+ * Finds an decoder with the specified name.
+ *
+ * @param name Name of the requested decoder.
+ * @return A decoder if one was found, NULL otherwise.
+ */
AVCodec *avcodec_find_decoder_by_name(const char *name);
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
+/**
+ * Sets the fields of the given AVCodecContext to default values.
+ *
+ * @param s The AVCodecContext of which the fields should be set to default values.
+ */
void avcodec_get_context_defaults(AVCodecContext *s);
+
+/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
+ * we WILL change its arguments and name a few times! */
+void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
+
+/**
+ * Allocates an AVCodecContext and sets its fields to default values. The
+ * resulting struct can be deallocated by simply calling av_free().
+ *
+ * @return An AVCodecContext filled with default values or NULL on failure.
+ * @see avcodec_get_context_defaults
+ */
AVCodecContext *avcodec_alloc_context(void);
+
+/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
+ * we WILL change its arguments and name a few times! */
+AVCodecContext *avcodec_alloc_context2(enum CodecType);
+
+/**
+ * Sets the fields of the given AVFrame to default values.
+ *
+ * @param pic The AVFrame of which the fields should be set to default values.
+ */
void avcodec_get_frame_defaults(AVFrame *pic);
+
+/**
+ * Allocates an AVFrame and sets its fields to default values. The resulting
+ * struct can be deallocated by simply calling av_free().
+ *
+ * @return An AVFrame filled with default values or NULL on failure.
+ * @see avcodec_get_frame_defaults
+ */
AVFrame *avcodec_alloc_frame(void);
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
+
+/**
+ * Checks 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.
+ */
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
@@ -2504,36 +2710,159 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v
//FIXME func typedef
/**
- * opens / inits the AVCodecContext.
- * not thread save!
+ * Initializes the AVCodecContext to use the given AVCodec. Prior to using this
+ * function the context has to be allocated.
+ *
+ * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
+ * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
+ * retrieving a codec.
+ *
+ * @warning This function is not thread save!
+ *
+ * @code
+ * codec = avcodec_find_decoder(CODEC_ID_H264);
+ * if (!codec)
+ * exit(1);
+ *
+ * context = avcodec_alloc_context();
+ *
+ * if (avcodec_open(context, codec) < 0)
+ * exit(1);
+ * @endcode
+ *
+ * @param avctx The context which will be setup to use the given codec.
+ * @param codec The codec to use within the context.
+ * @return Zero on success, a negative value on error.
+ * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
*/
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
/**
- * Decode an audio frame.
- *
- * @param avctx the codec context.
- * @param samples output buffer, 16 byte aligned
- * @param frame_size_ptr the output buffer size in bytes, zero if no frame could be compressed
- * @param buf input buffer, 16 byte aligned
- * @param buf_size the input buffer size
- * @return 0 if successful, -1 if not.
+ * @deprecated Use avcodec_decode_audio2() instead.
*/
+attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+ int *frame_size_ptr,
+ uint8_t *buf, int buf_size);
-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+/**
+ * Decodes an audio frame from \p buf into \p samples.
+ * The avcodec_decode_audio2() function decodes a frame of audio from the input
+ * buffer \p buf of size \p buf_size. To decode it, it makes use of the
+ * audiocodec which was coupled with \p avctx using avcodec_open(). The
+ * resulting decoded frame is stored in output buffer \p samples. If no frame
+ * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the
+ * decompressed frame size in \e bytes.
+ *
+ * @warning You \e must set \p frame_size_ptr to the allocated size of the
+ * output buffer before calling avcodec_decode_audio2().
+ *
+ * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
+ * the actual read bytes because some optimized bitstream readers read 32 or 64
+ * bits at once and could read over the end.
+ *
+ * @warning The end of the input buffer \p buf should be set to 0 to ensure that
+ * no overreading happens for damaged MPEG streams.
+ *
+ * @note You might have to align the input buffer \p buf and output buffer \p
+ * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
+ * necessary at all, on others it won't work at all if not aligned and on others
+ * it will work but it will have an impact on performance. In practice, the
+ * bitstream should have 4 byte alignment at minimum and all sample data should
+ * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
+ * the linesize is not a multiple of 16 then there's no sense in aligning the
+ * start of the buffer to 16.
+ *
+ * @param avctx The codec context.
+ * @param[out] samples The output buffer.
+ * @param[in,out] frame_size_ptr The output buffer size in bytes.
+ * @param[in] buf The input buffer.
+ * @param[in] buf_size The input buffer size in bytes.
+ * @return On error a negative value is returned, otherwise the number of bytes
+ * used or zero if no frame could be decompressed.
+ */
+int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size);
+
+/**
+ * Decodes a video frame from \p buf into \p picture.
+ * The avcodec_decode_video() function decodes a frame of video from the input
+ * buffer \p buf of size \p buf_size. To decode it, it makes use of the
+ * videocodec which was coupled with \p avctx using avcodec_open(). The
+ * resulting decoded frame is stored in \p picture.
+ *
+ * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
+ * the actual read bytes because some optimized bitstream readers read 32 or 64
+ * bits at once and could read over the end.
+ *
+ * @warning The end of the input buffer \p buf should be set to 0 to ensure that
+ * no overreading happens for damaged MPEG streams.
+ *
+ * @note You might have to align the input buffer \p buf and output buffer \p
+ * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
+ * necessary at all, on others it won't work at all if not aligned and on others
+ * it will work but it will have an impact on performance. In practice, the
+ * bitstream should have 4 byte alignment at minimum and all sample data should
+ * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
+ * the linesize is not a multiple of 16 then there's no sense in aligning the
+ * start of the buffer to 16.
+ *
+ * @param avctx The codec context.
+ * @param[out] picture The AVFrame in which the decoded video frame will be stored.
+ * @param[in] buf The input buffer.
+ * @param[in] buf_size The size of the input buffer in bytes.
+ * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is non zero.
+ * @return On error a negative value is returned, otherwise the number of bytes
+ * used or zero if no frame could be decompressed.
+ */
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
uint8_t *buf, int buf_size);
+
+/* decode a subtitle message. return -1 if error, otherwise return the
+ *number of bytes used. If no subtitle could be decompressed,
+ *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
const uint8_t *buf, int buf_size);
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
int *data_size_ptr,
uint8_t *buf, int buf_size);
+
+/**
+ * Encodes an audio frame from \p samples into \p buf.
+ * The avcodec_encode_audio() function encodes a frame of audio from the input
+ * buffer \p samples. To encode it, it makes use of the audiocodec which was
+ * coupled with \p avctx using avcodec_open(). The resulting encoded frame is
+ * stored in output buffer \p buf.
+ *
+ * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large.
+ *
+ * @param avctx The codec context.
+ * @param[out] buf The output buffer.
+ * @param[in] buf_size The output buffer size.
+ * @param[in] samples The input buffer containing the samples.
+ * @return On error a negative value is returned, on succes zero or the number
+ * of bytes used from the input buffer.
+ */
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const short *samples);
+
+/**
+ * Encodes a video frame from \p pict into \p buf.
+ * The avcodec_encode_video() function encodes a frame of video from the input
+ * \p pict. To encode it, it makes use of the videocodec which was coupled with
+ * \p avctx using avcodec_open(). The resulting encoded bytes representing the
+ * frame are stored in the output buffer \p buf. The input picture should be
+ * stored using a specific format, namely \c avctx.pix_fmt.
+ *
+ * @param avctx The codec context.
+ * @param[out] buf The output buffer for the bitstream of encoded frame.
+ * @param[in] buf_size The size of the outputbuffer in bytes.
+ * @param[in] pict The input picture to encode.
+ * @return On error a negative value is returned, on success zero or the number
+ * of bytes used from the input buffer.
+ */
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict);
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
@@ -2543,19 +2872,28 @@ int avcodec_close(AVCodecContext *avctx);
void avcodec_register_all(void);
+/**
+ * Flush buffers, should be called when seeking or when switching to a different stream.
+ */
void avcodec_flush_buffers(AVCodecContext *avctx);
void avcodec_default_free_buffers(AVCodecContext *s);
-/* misc usefull functions */
+/* misc useful functions */
/**
- * returns a single letter to describe the picture type
+ * Returns a single letter to describe the given picture type \p pict_type.
+ *
+ * @param[in] pict_type The picture type.
+ * @return A single character representing the picture type.
*/
char av_get_pict_type_char(int pict_type);
/**
- * returns codec bits per sample
+ * Returns codec bits per sample.
+ *
+ * @param[in] codec_id The codec.
+ * @return Number of bits per sample or zero if unknown for the given codec.
*/
int av_get_bits_per_sample(enum CodecID codec_id);
@@ -2616,19 +2954,21 @@ int av_parser_change(AVCodecParserContext *s,
const uint8_t *buf, int buf_size, int keyframe);
void av_parser_close(AVCodecParserContext *s);
-extern AVCodecParser mpegvideo_parser;
-extern AVCodecParser mpeg4video_parser;
+extern AVCodecParser aac_parser;
+extern AVCodecParser ac3_parser;
extern AVCodecParser cavsvideo_parser;
+extern AVCodecParser dca_parser;
+extern AVCodecParser dvbsub_parser;
+extern AVCodecParser dvdsub_parser;
extern AVCodecParser h261_parser;
extern AVCodecParser h263_parser;
extern AVCodecParser h264_parser;
extern AVCodecParser mjpeg_parser;
-extern AVCodecParser pnm_parser;
+extern AVCodecParser mpeg4video_parser;
extern AVCodecParser mpegaudio_parser;
-extern AVCodecParser ac3_parser;
-extern AVCodecParser dvdsub_parser;
-extern AVCodecParser dvbsub_parser;
-extern AVCodecParser aac_parser;
+extern AVCodecParser mpegvideo_parser;
+extern AVCodecParser pnm_parser;
+extern AVCodecParser vc1_parser;
typedef struct AVBitStreamFilterContext {
@@ -2665,41 +3005,85 @@ extern AVBitStreamFilter noise_bsf;
extern AVBitStreamFilter mp3_header_compress_bsf;
extern AVBitStreamFilter mp3_header_decompress_bsf;
extern AVBitStreamFilter mjpega_dump_header_bsf;
+extern AVBitStreamFilter imx_dump_header_bsf;
/* memory */
+
+/**
+ * Reallocates the given block if it is not large enough, otherwise it
+ * does nothing.
+ *
+ * @see av_realloc
+ */
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
+
/* for static data only */
-/* call av_free_static to release all staticaly allocated tables */
-void av_free_static(void);
-void *av_mallocz_static(unsigned int size);
-void *av_realloc_static(void *ptr, unsigned int size);
-void img_copy(AVPicture *dst, const AVPicture *src,
+/**
+ * Frees all static arrays and reset their pointers to 0.
+ * Call this function to release all statically allocated tables.
+ */
+attribute_deprecated void av_free_static(void);
+
+/**
+ * Allocation of static arrays.
+ *
+ * @warning Do not use for normal allocation.
+ *
+ * @param[in] size The amount of memory you need in bytes.
+ * @return Block of memory of the requested size.
+ */
+attribute_deprecated void *av_mallocz_static(unsigned int size);
+
+/**
+ * Copy image 'src' to 'dst'.
+ */
+void av_picture_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height);
-int img_crop(AVPicture *dst, const AVPicture *src,
+/**
+ * Crop image top and left side
+ */
+int av_picture_crop(AVPicture *dst, const AVPicture *src,
int pix_fmt, int top_band, int left_band);
-int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
+/**
+ * Pad image
+ */
+int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
int padtop, int padbottom, int padleft, int padright, int *color);
-/* endian macros */
-#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
-#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
- (((uint8_t*)(x))[1] << 16) | \
- (((uint8_t*)(x))[2] << 8) | \
- ((uint8_t*)(x))[3])
-#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
-#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
- (((uint8_t*)(x))[2] << 16) | \
- (((uint8_t*)(x))[1] << 8) | \
- ((uint8_t*)(x))[0])
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+attribute_deprecated void img_copy(AVPicture *dst, const AVPicture *src,
+ int pix_fmt, int width, int height);
+
+attribute_deprecated int img_crop(AVPicture *dst, const AVPicture *src,
+ int pix_fmt, int top_band, int left_band);
+
+attribute_deprecated int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
+ int padtop, int padbottom, int padleft, int padright, int *color);
#endif
extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
+/* error handling */
+#if EINVAL > 0
+#define AVERROR(e) (-(e)) /**< returns a negative error code from a POSIX error code, to return from library functions. */
+#define AVUNERROR(e) (-(e)) /**< returns a POSIX error code from a library function error return value. */
+#else
+/* some platforms have E* and errno already negated. */
+#define AVERROR(e) (e)
+#define AVUNERROR(e) (e)
+#endif
+#define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */
+#define AVERROR_IO AVERROR(EIO) /**< i/o error */
+#define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< number syntax expected in filename */
+#define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */
+#define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */
+#define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */
+#define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< operation not supported */
+
#ifdef __cplusplus
}
#endif
diff --git a/contrib/ffmpeg/libavcodec/avs.c b/contrib/ffmpeg/libavcodec/avs.c
index 953aea1be..ebfa8adb7 100644
--- a/contrib/ffmpeg/libavcodec/avs.c
+++ b/contrib/ffmpeg/libavcodec/avs.c
@@ -74,8 +74,8 @@ avs_decode_frame(AVCodecContext * avctx,
int first, last;
uint32_t *pal = (uint32_t *) avs->picture.data[1];
- first = LE_16(buf);
- last = first + LE_16(buf + 2);
+ first = AV_RL16(buf);
+ last = first + AV_RL16(buf + 2);
buf += 4;
for (i=first; i<last; i++, buf+=3)
pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2);
diff --git a/contrib/ffmpeg/libavcodec/bfin/config_bfin.h b/contrib/ffmpeg/libavcodec/bfin/config_bfin.h
new file mode 100644
index 000000000..1f5080900
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/bfin/config_bfin.h
@@ -0,0 +1,46 @@
+/*
+ * config_bfin.h
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.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
+ */
+/*
+ low level assembler interface wrapper
+
+DEFUN(put_pixels_clamped,mL1,
+ (DCTELEM *block, uint8_t *dest, int line_size)):
+
+ body
+
+ rts;
+*/
+#ifndef DEFUN
+
+#ifndef mL1
+#define mL1 .l1.text
+#endif
+#define mL3 .text
+
+#define DEFUN(fname,where,interface) \
+ .section where; \
+ .global _ff_bfin_ ## fname ; \
+ .align 8; \
+ _ff_bfin_ ## fname
+
+#endif
+
diff --git a/contrib/ffmpeg/libavcodec/bfin/dsputil_bfin.c b/contrib/ffmpeg/libavcodec/bfin/dsputil_bfin.c
index 196ef6fea..b4d549fb7 100644
--- a/contrib/ffmpeg/libavcodec/bfin/dsputil_bfin.c
+++ b/contrib/ffmpeg/libavcodec/bfin/dsputil_bfin.c
@@ -1,5 +1,8 @@
/*
- * Copyright (c) 2006 Michael Benjamin
+ * BlackFin DSPUTILS
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
+ * Copyright (c) 2006 Michael Benjamin <michael.benjamin@analog.com>
*
* This file is part of FFmpeg.
*
@@ -18,38 +21,290 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <unistd.h>
+#include <bits/bfin_sram.h>
#include "../avcodec.h"
#include "../dsputil.h"
-static int sad8x8_bfin( void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h )
-{
- int sum;
- __asm__ __volatile__ (
- "P0 = %1;" // blk1
- "P1 = %2;" // blk2
- "P2 = %3;\n" // h
- "I0 = P0;"
- "I1 = P1;\n"
- "A0 = 0;"
- "A1 = 0;\n"
- "M0 = P2;\n"
- "P3 = 32;\n"
- "LSETUP (sad8x8LoopBegin, sad8x8LoopEnd) LC0=P3;\n"
- "sad8x8LoopBegin:\n"
- " DISALGNEXCPT || R0 = [I0] || R2 = [I1];\n"
- " DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];\n"
- "sad8x8LoopEnd:\n"
- " SAA ( R1:0 , R3:2 );\n"
- "R3 = A1.L + A1.H, R2 = A0.L + A0.H;\n"
- "%0 = R2 + R3 (S);\n"
- : "=&d" (sum)
- : "m"(blk1), "m"(blk2), "m"(h)
- : "P0","P1","P2","I0","I1","A0","A1","R0","R1","R2","R3");
- return sum;
+#define USE_L1CODE
+
+#ifdef USE_L1CODE
+#define L1CODE __attribute__ ((l1_text))
+#else
+#define L1CODE
+#endif
+int off;
+
+
+extern void ff_bfin_idct (DCTELEM *block) L1CODE;
+extern void ff_bfin_fdct (DCTELEM *block) L1CODE;
+extern void ff_bfin_add_pixels_clamped (DCTELEM *block, uint8_t *dest, int line_size) L1CODE;
+extern void ff_bfin_put_pixels_clamped (DCTELEM *block, uint8_t *dest, int line_size) L1CODE;
+extern void ff_bfin_diff_pixels (DCTELEM *block, uint8_t *s1, uint8_t *s2, int stride) L1CODE;
+extern void ff_bfin_get_pixels (DCTELEM *restrict block, const uint8_t *pixels, int line_size) L1CODE;
+extern int ff_bfin_pix_norm1 (uint8_t * pix, int line_size) L1CODE;
+extern int ff_bfin_z_sad8x8 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h) L1CODE;
+extern int ff_bfin_z_sad16x16 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h) L1CODE;
+
+extern void ff_bfin_z_put_pixels16_xy2 (uint8_t *block, const uint8_t *s0, int dest_size, int line_size, int h) L1CODE;
+extern void ff_bfin_z_put_pixels8_xy2 (uint8_t *block, const uint8_t *s0, int dest_size, int line_size, int h) L1CODE;
+extern void ff_bfin_put_pixels16_xy2_nornd (uint8_t *block, const uint8_t *s0, int line_size, int h) L1CODE;
+extern void ff_bfin_put_pixels8_xy2_nornd (uint8_t *block, const uint8_t *s0, int line_size, int h) L1CODE;
+
+
+extern int ff_bfin_pix_sum (uint8_t *p, int stride) L1CODE;
+
+extern void ff_bfin_put_pixels8uc (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int dest_size, int line_size, int h) L1CODE;
+extern void ff_bfin_put_pixels16uc (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int dest_size, int line_size, int h) L1CODE;
+extern void ff_bfin_put_pixels8uc_nornd (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int line_size, int h) L1CODE;
+extern void ff_bfin_put_pixels16uc_nornd (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int line_size, int h) L1CODE;
+
+extern int ff_bfin_sse4 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) L1CODE;
+extern int ff_bfin_sse8 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) L1CODE;
+extern int ff_bfin_sse16 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) L1CODE;
+
+
+#if 0
+void pblk (uint8_t *p, int w, int h, int s)
+{
+ int i,j;
+ av_log (0,0,"0x%08x:\n", p);
+ for (i = 0;i<h;i++) {
+ for (j=0;j<w;j++)
+ av_log (0,0,"%3d ", p[j]);
+ p+=s;
+ av_log (0,0,"\n");
+ }
+ av_log (0,0,"\n");
+}
+#endif
+
+static void bfin_idct_add (uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_bfin_idct (block);
+ ff_bfin_add_pixels_clamped (block, dest, line_size);
+}
+
+static void bfin_idct_put (uint8_t *dest, int line_size, DCTELEM *block)
+{
+ ff_bfin_idct (block);
+ ff_bfin_put_pixels_clamped (block, dest, line_size);
+}
+
+
+static void bfin_clear_blocks (DCTELEM *blocks)
+{
+ // This is just a simple memset.
+ //
+ asm("P0=192; "
+ "I0=%0; "
+ "R0=0; "
+ "LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
+ "clear_blocks_blkfn_lab:"
+ "[I0++]=R0;"
+ ::"a" (blocks):"P0","I0","R0");
+}
+
+
+
+static void bfin_put_pixels8 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc (block, pixels, pixels, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc (block, pixels, pixels+1, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_y2 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc (block, pixels, pixels+line_size, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_xy2 (uint8_t *block, const uint8_t *s0, int line_size, int h)
+{
+ ff_bfin_z_put_pixels8_xy2 (block,s0,line_size, line_size, h);
+}
+
+static void bfin_put_pixels16 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc (block, pixels, pixels, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_x2 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc (block, pixels, pixels+1, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_y2 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc (block, pixels, pixels+line_size, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_xy2 (uint8_t *block, const uint8_t *s0, int line_size, int h)
+{
+ ff_bfin_z_put_pixels16_xy2 (block,s0,line_size, line_size, h);
+}
+
+void bfin_put_pixels8_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc_nornd (block, pixels, pixels, line_size, h);
+}
+
+static void bfin_put_pixels8_x2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+1, line_size, h);
+}
+
+static void bfin_put_pixels8_y2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+line_size, line_size, h);
}
+
+void bfin_put_pixels16_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc_nornd (block, pixels, pixels, line_size, h);
+}
+
+static void bfin_put_pixels16_x2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+1, line_size, h);
+}
+
+static void bfin_put_pixels16_y2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+line_size, line_size, h);
+}
+
+static int bfin_pix_abs16 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ return ff_bfin_z_sad16x16 (blk1,blk2,line_size,line_size,h);
+}
+
+static uint8_t vtmp_blk[256] __attribute__((l1_data_B));
+
+static int bfin_pix_abs16_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+1, 16, line_size, h);
+ return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs16_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+line_size, 16, line_size, h);
+ return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs16_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ ff_bfin_z_put_pixels16_xy2 (vtmp_blk, blk2, 16, line_size, h);
+ return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs8 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ return ff_bfin_z_sad8x8 (blk1,blk2,line_size,line_size, h);
+}
+
+static int bfin_pix_abs8_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+1, 8, line_size, h);
+ return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
+}
+
+static int bfin_pix_abs8_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+line_size, 8, line_size, h);
+ return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
+}
+
+static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
+{
+ ff_bfin_z_put_pixels8_xy2 (vtmp_blk, blk2, 8, line_size, h);
+ return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
+}
+
+
+/*
+ decoder optimization
+ start on 2/11 100 frames of 352x240@25 compiled with no optimization -g debugging
+ 9.824s ~ 2.44x off
+ 6.360s ~ 1.58x off with -O2
+ 5.740s ~ 1.43x off with idcts
+
+ 2.64s 2/20 same sman.mp4 decode only
+
+*/
+
void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
{
- c->pix_abs[1][0] = sad8x8_bfin;
- c->sad[1] = sad8x8_bfin;
+ c->get_pixels = ff_bfin_get_pixels;
+ c->diff_pixels = ff_bfin_diff_pixels;
+ c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
+ c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
+
+ c->clear_blocks = bfin_clear_blocks;
+ c->pix_sum = ff_bfin_pix_sum;
+ c->pix_norm1 = ff_bfin_pix_norm1;
+
+ c->sad[0] = bfin_pix_abs16;
+ c->sad[1] = bfin_pix_abs8;
+
+ /* TODO [0] 16 [1] 8 */
+ c->pix_abs[0][0] = bfin_pix_abs16;
+ c->pix_abs[0][1] = bfin_pix_abs16_x2;
+ c->pix_abs[0][2] = bfin_pix_abs16_y2;
+ c->pix_abs[0][3] = bfin_pix_abs16_xy2;
+
+ c->pix_abs[1][0] = bfin_pix_abs8;
+ c->pix_abs[1][1] = bfin_pix_abs8_x2;
+ c->pix_abs[1][2] = bfin_pix_abs8_y2;
+ c->pix_abs[1][3] = bfin_pix_abs8_xy2;
+
+
+ c->sse[0] = ff_bfin_sse16;
+ c->sse[1] = ff_bfin_sse8;
+ c->sse[2] = ff_bfin_sse4;
+
+
+ /**
+ * Halfpel motion compensation with rounding (a+b+1)>>1.
+ * This is an array[4][4] of motion compensation functions for 4
+ * horizontal blocksizes (8,16) and the 4 halfpel positions
+ * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
+ * @param block destination where the result is stored
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
+
+ c->put_pixels_tab[0][0] = bfin_put_pixels16;
+ c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
+ c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
+ c->put_pixels_tab[0][3] = bfin_put_pixels16_xy2;
+
+ c->put_pixels_tab[1][0] = bfin_put_pixels8;
+ c->put_pixels_tab[1][1] = bfin_put_pixels8_x2;
+ c->put_pixels_tab[1][2] = bfin_put_pixels8_y2;
+ c->put_pixels_tab[1][3] = bfin_put_pixels8_xy2;
+
+ c->put_no_rnd_pixels_tab[1][0] = bfin_put_pixels8_nornd;
+ c->put_no_rnd_pixels_tab[1][1] = bfin_put_pixels8_x2_nornd;
+ c->put_no_rnd_pixels_tab[1][2] = bfin_put_pixels8_y2_nornd;
+ c->put_no_rnd_pixels_tab[1][3] = ff_bfin_put_pixels8_xy2_nornd;
+
+ c->put_no_rnd_pixels_tab[0][0] = bfin_put_pixels16_nornd;
+ c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_nornd;
+ c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_nornd;
+ c->put_no_rnd_pixels_tab[0][3] = ff_bfin_put_pixels16_xy2_nornd;
+
+ c->fdct = ff_bfin_fdct;
+ c->idct = ff_bfin_idct;
+ c->idct_add = bfin_idct_add;
+ c->idct_put = bfin_idct_put;
}
+
+
+
diff --git a/contrib/ffmpeg/libavcodec/bfin/fdct_bfin.S b/contrib/ffmpeg/libavcodec/bfin/fdct_bfin.S
new file mode 100644
index 000000000..8230673e8
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/bfin/fdct_bfin.S
@@ -0,0 +1,324 @@
+/*
+ * fdct BlackFin
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.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
+ */
+/*
+ void ff_bfin_fdct (DCTELEM *buf);
+
+ This implementation works only for 8x8 input. The range of input
+ must be -256 to 255 i.e. 8bit input represented in a 16bit data
+ word. The original data must be sign extended into the 16bit data
+ words.
+
+
+ Chen factorization of
+
+ 8
+ X(m) = sum (x(n) * cos ((2n+1)*m*pi/16))
+ n=0
+
+ C4
+ 0 --*-------------*0+7---*-----*0+3-------*-*-------------------> 0
+ \ / \ / X S4,S4
+ 1 --*-\---------/-*1+6---*-\-/-*1+2-------*-*-------------------> 4
+ \ / \ -C4 C3
+ 2 --*---\-----/---*2+5---*-/-\-*1-2---------------*-*-----------> 2
+ \ / / \ X S3,-S3
+ 3 --*-----\-/-----*3+4---*-----*0-3---------------*-*-----------> 6
+ / C7 C3
+ 4 --*-----/-\-----*3-4------------*-*4+5--*-----*---------------> 1
+ / \ -C4 X \ /S7 C3
+ 5 --*---/-----\---*2-5---*-*------*=*4-5----\-/------*-*--------> 5
+ / \ X S4,S4 / X S3,-S3
+ 6 --*-/---------\-*1-6---*-*------*=*7-6----/-\------*-*--------> 3
+ / \ C4 X / \-S7 C3
+ --*-------------*0-7------------*-*7+6--*-----*---------------> 7
+ C7
+
+Notation
+ Cn = cos(n*pi/8) used throughout the code.
+
+
+ Registers used:
+ R0, R1, R2, R3, R4, R5, R6,R7, P0, P1, P2, P3, P4, P5, A0, A1.
+ Other registers used:
+ I0, I1, I2, I3, B0, B2, B3, M0, M1, L3 registers and LC0.
+
+ Input - r0 - pointer to start of DCTELEM *block
+
+ Output - The DCT output coefficients in the DCTELEM *block
+
+ Register constraint:
+ This code is called from jpeg_encode.
+ R6, R5, R4 if modified should be stored and restored.
+
+
+ Performance: (Timer version 0.6.33)
+ Code Size : 240 Bytes.
+ Memory Required :
+ Input Matrix : 8 * 8 * 2 Bytes.
+ Coefficients : 16 Bytes
+ Temporary matrix: 8 * 8 * 2 Bytes.
+ Cycle Count :26+{18+8*(14+2S)}*2 where S -> Stalls
+ (7.45 c/pel)
+ -----------------------------------------
+ | Size | Forward DCT | Inverse DCT |
+ -----------------------------------------
+ | 8x8 | 284 Cycles | 311 Cycles |
+ -----------------------------------------
+
+Ck = int16(cos(k/16*pi)*32767+.5)/2
+#define C4 23170
+#define C3 13623
+#define C6 6270
+#define C7 3196
+
+Sk = int16(sin(k/16*pi)*32767+.5)/2
+#define S4 11585
+#define S3 9102
+#define S6 15137
+#define S7 16069
+
+the coefficients are ordered as follows:
+short dct_coef[]
+ C4,S4,
+ C6,S6,
+ C7,S7,
+ S3,C3,
+
+-----------------------------------------------------------
+FFMPEG conformance testing results
+-----------------------------------------------------------
+dct-test: modified with the following
+ dct_error("BFINfdct", 0, ff_bfin_fdct, fdct, test);
+produces the following output:
+
+root:/u/ffmpeg/bhead/libavcodec> ./dct-test
+ffmpeg DCT/IDCT test
+
+ 2 -131 -6 -48 -36 33 -83 24
+ 34 52 -24 -15 5 92 57 143
+ -67 -43 -1 74 -16 5 -71 32
+ -78 106 92 -34 -38 81 20 -18
+ 7 -62 40 2 -15 90 -62 -83
+ -83 1 -104 -13 43 -19 7 11
+ -63 31 12 -29 83 72 21 10
+ -17 -63 -15 73 50 -91 159 -14
+DCT BFINfdct: err_inf=2 err2=0.16425938 syserr=0.00795000 maxout=2098 blockSumErr=27
+DCT BFINfdct: 92.1 kdct/s
+root:/u/ffmpeg/bhead/libavcodec>
+
+*/
+
+#include "config_bfin.h"
+
+.section .l1.data.B,"aw",@progbits
+.align 4;
+dct_coeff:
+.short 0x5a82, 0x2d41, 0x187e, 0x3b21, 0x0c7c, 0x3ec5, 0x238e, 0x3537;
+
+.section .l1.data.A,"aw",@progbits
+.align 4
+vtmp: .space 128
+
+DEFUN(fdct,mL1,
+ (DCTELEM *block)):
+ [--SP] = (R7:4, P5:3); // Push the registers onto the stack.
+
+ b0 = r0;
+ r0 = [P3+dct_coeff@GOT17M4];
+ b3 = r0;
+ r0 = [P3+vtmp@GOT17M4];
+ b2 = r0;
+
+ L3 = 16; // L3 is set to 16 to make the coefficient
+ // array Circular.
+
+
+//----------------------------------------------------------------------------
+
+/*
+ * I0, I1, and I2 registers are used to read the input data. I3 register is used
+ * to read the coefficients. P0 and P1 registers are used for writing the output
+ * data.
+ */
+ M0 = 12 (X); // All these initializations are used in the
+ M1 = 16 (X); // modification of address offsets.
+
+ M2 = 128 (X);
+
+ P2 = 16;
+ P3 = 32 (X);
+ P4 = -110 (X);
+ P5 = -62 (X);
+ P0 = 2(X);
+
+
+ // Prescale the input to get the correct precision.
+ i0=b0;
+ i1=b0;
+
+ lsetup (.0, .1) LC0 = P3;
+ r0=[i0++];
+.0: r1=r0<<3 (v) || r0=[i0++] ;
+.1: [i1++]=r1;
+
+ /*
+ * B0 points to the "in" buffer.
+ * B2 points to "temp" buffer in the first iteration.
+ */
+
+ lsetup (.2, .3) LC0 = P0;
+.2:
+ I0 = B0; // I0 points to Input Element (0, 0).
+ I1 = B0; // Element 1 and 0 is read in R0.
+ I1 += M0 || R0 = [I0++]; // I1 points to Input Element (0, 6).
+ I2 = I1; // Element 6 is read into R3.H.
+ I2 -= 4 || R3.H = W[I1++]; // I2 points to Input Element (0, 4).
+
+ I3 = B3; // I3 points to Coefficients.
+ P0 = B2; // P0 points to temporary array Element
+ // (0, 0).
+ P1 = B2; // P1 points to temporary array.
+ R7 = [P1++P2] || R2 = [I2++]; // P1 points to temporary array
+ // Element (1, 0).
+ // R7 is a dummy read. X4,X5
+ // are read into R2.
+ R3.L = W[I1--]; // X7 is read into R3.L.
+ R1.H = W[I0++]; // X2 is read into R1.H.
+
+
+ /*
+ * X0 = (X0 + X7) / 2.
+ * X1 = (X1 + X6) / 2.
+ * X6 = (X1 - X6) / 2.
+ * X7 = (X0 - X7) / 2.
+ * It reads the data 3 in R1.L.
+ */
+
+ R0 = R0 +|+ R3, R3 = R0 -|- R3 || R1.L = W[I0++] || NOP;
+
+ /*
+ * X2 = (X2 + X5) / 2.
+ * X3 = (X3 + X4) / 2.
+ * X4 = (X3 - X4) / 2.
+ * X5 = (X2 - X5) / 2.
+ * R7 = C4 = cos(4*pi/16)
+ */
+
+ R1 = R1 +|+ R2, R2 = R1 -|- R2 (CO) || NOP || R7 = [I3++];
+
+ /*
+ * At the end of stage 1 R0 has (1,0), R1 has (2,3), R2 has (4, 5) and
+ * R3 has (6,7).
+ * Where the notation (x, y) represents uper/lower half pairs.
+ */
+
+ /*
+ * X0 = X0 + X3.
+ * X1 = X1 + X2.
+ * X2 = X1 - X2.
+ * X3 = X0 - X3.
+ */
+ R0 = R0 +|+ R1, R1 = R0 -|- R1;
+
+ lsetup (.row0, .row1) LC1 = P2 >> 1; // 1d dct, loops 8x
+.row0:
+
+ /*
+ * This is part 2 computation continued.....
+ * A1 = X6 * cos(pi/4)
+ * A0 = X6 * cos(pi/4)
+ * A1 = A1 - X5 * cos(pi/4)
+ * A0 = A0 + X5 * cos(pi/4).
+ * The instruction W[I0] = R3.L is used for packing it to R2.L.
+ */
+
+ A1=R3.H*R7.l, A0=R3.H*R7.l || I1+=M1 || W[I0] = R3.L;
+ R4.H=(A1-=R2.L*R7.l), R4.L=(A0+=R2.L*R7.l) || I2+=M0 || NOP;
+
+ /* R0 = (X1,X0) R1 = (X2,X3) R4 = (X5, X6). */
+
+ /*
+ * A1 = X0 * cos(pi/4)
+ * A0 = X0 * cos(pi/4)
+ * A1 = A1 - X1 * cos(pi/4)
+ * A0 = A0 + X1 * cos(pi/4)
+ * R7 = (C2,C6)
+ */
+ A1=R0.L*R7.h, A0=R0.L*R7.h || NOP || R3.H=W[I1++];
+ R5.H=(A1-=R0.H*R7.h),R5.L=(A0+=R0.H*R7.h) || R7=[I3++] || NOP;
+
+ /*
+ * A1 = X2 * cos(3pi/8)
+ * A0 = X3 * cos(3pi/8)
+ * A1 = A1 + X3 * cos(pi/8)
+ * A0 = A0 - X2 * cos(pi/8)
+ * R3 = cos(pi/4)
+ * R7 = (cos(7pi/8),cos(pi/8))
+ * X4 = X4 + X5.
+ * X5 = X4 - X5.
+ * X6 = X7 - X6.
+ * X7 = X7 + X6.
+ */
+ A1=R1.H*R7.L, A0=R1.L*R7.L || W[P0++P3]=R5.L || R2.L=W[I0];
+ R2=R2+|+R4, R4=R2-|-R4 || I0+=4 || R3.L=W[I1--];
+ R6.H=(A1+=R1.L*R7.H),R6.L=(A0 -= R1.H * R7.H) || I0+=4 || R7=[I3++];
+
+ /* R2 = (X4, X7) R4 = (X5,X6) R5 = (X1, X0) R6 = (X2,X3). */
+
+ /*
+ * A1 = X4 * cos(7pi/16)
+ * A0 = X7 * cos(7pi/16)
+ * A1 = A1 + X7 * cos(pi/16)
+ * A0 = A0 - X4 * cos(pi/16)
+ */
+
+ A1=R2.H*R7.L, A0=R2.L*R7.L || W[P0++P3]=R6.H || R0=[I0++];
+ R2.H=(A1+=R2.L*R7.H),R2.L=(A0-=R2.H*R7.H) || W[P0++P3]=R5.H || R7=[I3++];
+
+ /*
+ * A1 = X5 * cos(3pi/16)
+ * A0 = X6 * cos(3pi/16)
+ * A1 = A1 + X6 * cos(5pi/16)
+ * A0 = A0 - X5 * cos(5pi/16)
+ * The output values are written.
+ */
+
+ A1=R4.H*R7.H, A0=R4.L*R7.H || W[P0++P2]=R6.L || R1.H=W[I0++];
+ R4.H=(A1+=R4.L*R7.L),R4.L=(A0-=R4.H*R7.L) || W[P0++P4]=R2.L || R1.L=W[I0++];
+
+
+ /* Beginning of next stage, **pipelined** + drain and store the
+ rest of the column store. */
+
+ R0=R0+|+R3,R3=R0-|-R3 || W[P1++P3]=R2.H || R2=[I2++];
+ R1=R1+|+R2,R2=R1-|-R2 (CO) || W[P1++P3]=R4.L || R7=[I3++];
+.row1: R0=R0+|+R1,R1=R0-|-R1 || W[P1++P5]=R4.H || NOP;
+
+ // Exchange input with output.
+ B1 = B0;
+ B0 = B2;
+.3: B2 = B1;
+
+ L3=0;
+ (r7:4,p5:3) = [sp++];
+ RTS;
+
diff --git a/contrib/ffmpeg/libavcodec/bfin/idct_bfin.S b/contrib/ffmpeg/libavcodec/bfin/idct_bfin.S
new file mode 100644
index 000000000..f6904c189
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/bfin/idct_bfin.S
@@ -0,0 +1,297 @@
+/*
+ * idct BlackFin
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.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
+ */
+/*
+ This blackfin DSP code implements an 8x8 inverse type II DCT.
+
+Prototype : void ff_bfin_idct(DCTELEM *in)
+
+Registers Used : A0, A1, R0-R7, I0-I3, B0, B2, B3, M0-M2, L0-L3, P0-P5, LC0.
+
+Performance :
+ Code Size : 498 Bytes.
+ Cycle Count : 417 Cycles
+
+
+-----------------------------------------------------------
+FFMPEG conformance testing results
+-----------------------------------------------------------
+
+dct-test: modified with the following
+ dct_error("BFINidct", 1, ff_bfin_idct, idct, test);
+produces the following output
+
+root:/u/ffmpeg/bhead/libavcodec> ./dct-test -i
+ffmpeg DCT/IDCT test
+
+ 8 15 -2 21 24 17 0 10
+ 2 -10 -5 -5 -3 7 -14 -3
+ 2 -13 -10 -19 18 -6 6 -2
+ 9 4 16 -3 9 12 10 15
+ 15 -9 -2 10 1 16 0 -15
+ -15 5 7 3 13 0 13 20
+ -6 -15 24 9 -18 1 9 -22
+ -8 25 23 2 -7 0 30 13
+IDCT BFINidct: err_inf=1 err2=0.01002344 syserr=0.00150000 maxout=266 blockSumErr=64
+IDCT BFINidct: 88.3 kdct/s
+
+*/
+
+#include "config_bfin.h"
+
+.section .l1.data.B,"aw",@progbits
+
+.align 4;
+coefs:
+.short 0x5a82; // C4
+.short 0x5a82; // C4
+.short 0x30FC; //cos(3pi/8) C6
+.short 0x7642; //cos(pi/8) C2
+.short 0x18F9; //cos(7pi/16)
+.short 0x7D8A; //cos(pi/16)
+.short 0x471D; //cos(5pi/16)
+.short 0x6A6E; //cos(3pi/16)
+.short 0x18F9; //cos(7pi/16)
+.short 0x7D8A; //cos(pi/16)
+
+.section .l1.data.A
+
+vtmp: .space 256
+
+#define TMP0 FP-8
+#define TMP1 FP-12
+#define TMP2 FP-16
+
+
+DEFUN(idct,mL1,
+ (DCTELEM *block)):
+
+/********************** Function Prologue *********************************/
+ link 16;
+ [--SP] = (R7:4, P5:3); // Push the registers onto the stack.
+ B0 = R0; // Pointer to Input matrix
+ R1 = [P3+coefs@GOT17M4]; // Pointer to Coefficients
+ R2 = [P3+vtmp@GOT17M4]; // Pointer to Temporary matrix
+ B3 = R1;
+ B2 = R2;
+ L3 = 20; // L3 is used for making the coefficient array
+ // circular.
+ // MUST BE RESTORED TO ZERO at function exit.
+ M1 = 16 (X); // All these registers are initialized for
+ M3 = 8(X); // modifying address offsets.
+
+ I0 = B0; // I0 points to Input Element (0, 0).
+ I2 = B0; // I2 points to Input Element (0, 0).
+ I2 += M3 || R0.H = W[I0];
+ // Element 0 is read into R0.H
+ I1 = I2; // I1 points to input Element (0, 6).
+ I1 += 4 || R0.L = W[I2++];
+ // I2 points to input Element (0, 4).
+ // Element 4 is read into R0.L.
+ P2 = 8 (X);
+ P3 = 32 (X);
+ P4 = -32 (X);
+ P5 = 98 (X);
+ R7 = 0x8000(Z);
+ I3 = B3; // I3 points to Coefficients
+ P0 = B2; // P0 points to array Element (0, 0) of temp
+ P1 = B2;
+ R7 = [I3++] || [TMP2]=R7; // Coefficient C4 is read into R7.H and R7.L.
+ MNOP;
+ NOP;
+
+ /*
+ * A1 = Y0 * cos(pi/4)
+ * A0 = Y0 * cos(pi/4)
+ * A1 = A1 + Y4 * cos(pi/4)
+ * A0 = A0 - Y4 * cos(pi/4)
+ * load:
+ * R1=(Y2,Y6)
+ * R7=(C2,C6)
+ * res:
+ * R3=Y0, R2=Y4
+ */
+ A1=R7.H*R0.H, A0=R7.H*R0.H (IS) || I0+= 4 || R1.L=W[I1++];
+ R3=(A1+=R7.H*R0.L), R2=(A0-=R7.H*R0.L) (IS) || R1.H=W[I0--] || R7=[I3++];
+
+ LSETUP (.0, .1) LC0 = P2; // perform 8 1d idcts
+
+ P2 = 112 (X);
+ P1 = P1 + P2; // P1 points to element (7, 0) of temp buffer.
+ P2 = -94(X);
+
+.0:
+ /*
+ * A1 = Y2 * cos(3pi/8)
+ * A0 = Y2 * cos(pi/8)
+ * A1 = A1 - Y6 * cos(pi/8)
+ * A0 = A0 + Y6 * cos(3pi/8)
+ * R5 = (Y1,Y7)
+ * R7 = (C1,C7)
+ * res:
+ * R1=Y2, R0=Y6
+ */
+ A1=R7.L*R1.H, A0=R7.H*R1.H (IS) || I0+=4 || R5.H=W[I0];
+ R1=(A1-=R7.H*R1.L), R0=(A0+=R7.L*R1.L) (IS) || R5.L=W[I1--] || R7=[I3++];
+ /*
+ * Y0 = Y0 + Y6.
+ * Y4 = Y4 + Y2.
+ * Y2 = Y4 - Y2.
+ * Y6 = Y0 - Y6.
+ * R3 is saved
+ * R6.l=Y3
+ * note: R3: Y0, R2: Y4, R1: Y2, R0: Y6
+ */
+ R3=R3+R0, R0=R3-R0;
+ R2=R2+R1, R1=R2-R1 || [TMP0]=R3 || R6.L=W[I0--];
+ /*
+ * Compute the odd portion (1,3,5,7) even is done.
+ *
+ * Y1 = C7 * Y1 - C1 * Y7 + C3 * Y5 - C5 * Y3.
+ * Y7 = C1 * Y1 + C7 * Y7 + C5 * Y5 + C3 * Y3.
+ * Y5 = C5 * Y1 + C3 * Y7 + C7 * Y5 - C1 * Y3.
+ * Y3 = C3 * Y1 - C5 * Y7 - C1 * Y5 - C7 * Y3.
+ */
+ // R5=(Y1,Y7) R6=(Y5,Y3) // R7=(C1,C7)
+ A1 =R7.L*R5.H, A0 =R7.H*R5.H (IS) || [TMP1]=R2 || R6.H=W[I2--];
+ A1-=R7.H*R5.L, A0+=R7.L*R5.L (IS) || I0-=4 || R7=[I3++];
+ A1+=R7.H*R6.H, A0+=R7.L*R6.H (IS) || I0+=M1; // R7=(C3,C5)
+ R3 =(A1-=R7.L*R6.L), R2 =(A0+=R7.H*R6.L) (IS);
+ A1 =R7.L*R5.H, A0 =R7.H*R5.H (IS) || R4=[TMP0];
+ A1+=R7.H*R5.L, A0-=R7.L*R5.L (IS) || I1+=M1 || R7=[I3++]; // R7=(C1,C7)
+ A1+=R7.L*R6.H, A0-=R7.H*R6.H (IS);
+ R7 =(A1-=R7.H*R6.L), R6 =(A0-=R7.L*R6.L) (IS) || I2+=M1;
+ // R3=Y1, R2=Y7, R7=Y5, R6=Y3
+
+ /* Transpose write column. */
+ R5.H=R4+R2 (RND12); // Y0=Y0+Y7
+ R5.L=R4-R2 (RND12) || R4 = [TMP1]; // Y7=Y7-Y0
+ R2.H=R1+R7 (RND12) || W[P0++P3]=R5.H; // Y2=Y2+Y5 st Y0
+ R2.L=R1-R7 (RND12) || W[P1++P4]=R5.L || R7=[I3++]; // Y5=Y2-Y5 st Y7
+ R5.H=R0-R3 (RND12) || W[P0++P3]=R2.H || R1.L=W[I1++]; // Y1=Y6-Y1 st Y2
+ R5.L=R0+R3 (RND12) || W[P1++P4]=R2.L || R0.H=W[I0++]; // Y6=Y6+Y1 st Y5
+ R3.H=R4-R6 (RND12) || W[P0++P3]=R5.H || R0.L=W[I2++]; // Y3=Y3-Y4 st Y1
+ R3.L=R4+R6 (RND12) || W[P1++P4]=R5.L || R1.H=W[I0++]; // Y4=Y3+Y4 st Y6
+
+ /* pipeline loop start, + drain Y3, Y4 */
+ A1=R7.H*R0.H, A0=R7.H*R0.H (IS) || W[P0++P2]= R3.H || R1.H = W[I0--];
+.1: R3=(A1+=R7.H*R0.L), R2=(A0-=R7.H*R0.L) (IS) || W[P1++P5]= R3.L || R7 = [I3++];
+
+
+
+ I0 = B2; // I0 points to Input Element (0, 0)
+ I2 = B2; // I2 points to Input Element (0, 0)
+ I2 += M3 || R0.H = W[I0];
+ // Y0 is read in R0.H
+ I1 = I2; // I1 points to input Element (0, 6)
+ I1 += 4 || R0.L = W[I2++];
+ // I2 points to input Element (0, 4)
+ // Y4 is read in R0.L
+ P2 = 8 (X);
+ I3 = B3; // I3 points to Coefficients
+ P0 = B0; // P0 points to array Element (0, 0) for writing
+ // output
+ P1 = B0;
+ R7 = [I3++]; // R7.H = C4 and R7.L = C4
+ NOP;
+
+ /*
+ * A1 = Y0 * cos(pi/4)
+ * A0 = Y0 * cos(pi/4)
+ * A1 = A1 + Y4 * cos(pi/4)
+ * A0 = A0 - Y4 * cos(pi/4)
+ * load:
+ * R1=(Y2,Y6)
+ * R7=(C2,C6)
+ * res:
+ * R3=Y0, R2=Y4
+ */
+ A1=R7.H*R0.H, A0=R7.H*R0.H (IS) || I0+=4 || R1.L=W[I1++];
+ R3=(A1+=R7.H*R0.L), R2=(A0-=R7.H*R0.L) (IS) || R1.H=W[I0--] || R7=[I3++];
+
+ LSETUP (.2, .3) LC0 = P2; // peform 8 1d idcts
+ P2 = 112 (X);
+ P1 = P1 + P2;
+ P2 = -94(X);
+
+.2:
+ /*
+ * A1 = Y2 * cos(3pi/8)
+ * A0 = Y2 * cos(pi/8)
+ * A1 = A1 - Y6 * cos(pi/8)
+ * A0 = A0 + Y6 * cos(3pi/8)
+ * R5 = (Y1,Y7)
+ * R7 = (C1,C7)
+ * res:
+ * R1=Y2, R0=Y6
+ */
+ A1=R7.L*R1.H, A0=R7.H*R1.H (IS) || I0+=4 || R5.H=W[I0];
+ R1=(A1-=R7.H*R1.L), R0=(A0+=R7.L*R1.L) (IS) || R5.L=W[I1--] || R7=[I3++];
+ /*
+ * Y0 = Y0 + Y6.
+ * Y4 = Y4 + Y2.
+ * Y2 = Y4 - Y2.
+ * Y6 = Y0 - Y6.
+ * R3 is saved
+ * R6.l=Y3
+ * note: R3: Y0, R2: Y4, R1: Y2, R0: Y6
+ */
+ R3=R3+R0, R0=R3-R0;
+ R2=R2+R1, R1=R2-R1 || [TMP0]=R3 || R6.L=W[I0--];
+ /*
+ * Compute the odd portion (1,3,5,7) even is done.
+ *
+ * Y1 = C7 * Y1 - C1 * Y7 + C3 * Y5 - C5 * Y3.
+ * Y7 = C1 * Y1 + C7 * Y7 + C5 * Y5 + C3 * Y3.
+ * Y5 = C5 * Y1 + C3 * Y7 + C7 * Y5 - C1 * Y3.
+ * Y3 = C3 * Y1 - C5 * Y7 - C1 * Y5 - C7 * Y3.
+ */
+ // R5=(Y1,Y7) R6=(Y5,Y3) // R7=(C1,C7)
+ A1 =R7.L*R5.H, A0 =R7.H*R5.H (IS) || [TMP1]=R2 || R6.H=W[I2--];
+ A1-=R7.H*R5.L, A0+=R7.L*R5.L (IS) || I0-=4 || R7=[I3++];
+ A1+=R7.H*R6.H, A0+=R7.L*R6.H (IS) || I0+=M1; // R7=(C3,C5)
+ R3 =(A1-=R7.L*R6.L), R2 =(A0+=R7.H*R6.L) (IS);
+ A1 =R7.L*R5.H, A0 =R7.H*R5.H (IS) || R4=[TMP0];
+ A1+=R7.H*R5.L, A0-=R7.L*R5.L (IS) || I1+=M1 || R7=[I3++]; // R7=(C1,C7)
+ A1+=R7.L*R6.H, A0-=R7.H*R6.H (IS);
+ R7 =(A1-=R7.H*R6.L), R6 =(A0-=R7.L*R6.L) (IS) || I2+=M1;
+ // R3=Y1, R2=Y7, R7=Y5, R6=Y3
+
+ /* Transpose write column. */
+ R5.H=R4+R2 (RND20); // Y0=Y0+Y7
+ R5.L=R4-R2 (RND20) || R4 = [TMP1]; // Y7=Y7-Y0
+ R2.H=R1+R7 (RND20) || W[P0++P3]=R5.H; // Y2=Y2+Y5 st Y0
+ R2.L=R1-R7 (RND20) || W[P1++P4]=R5.L || R7=[I3++]; // Y5=Y2-Y5 st Y7
+ R5.H=R0-R3 (RND20) || W[P0++P3]=R2.H || R1.L=W[I1++]; // Y1=Y6-Y1 st Y2
+ R5.L=R0+R3 (RND20) || W[P1++P4]=R2.L || R0.H=W[I0++]; // Y6=Y6+Y1 st Y5
+ R3.H=R4-R6 (RND20) || W[P0++P3]=R5.H || R0.L=W[I2++]; // Y3=Y3-Y4 st Y1
+ R3.L=R4+R6 (RND20) || W[P1++P4]=R5.L || R1.H=W[I0++]; // Y4=Y3+Y4 st Y6
+
+ /* pipeline loop start, + drain Y3, Y4 */
+ A1=R7.H*R0.H, A0=R7.H*R0.H (IS) || W[P0++P2]= R3.H || R1.H = W[I0--];
+.3: R3=(A1+=R7.H*R0.L), R2=(A0-=R7.H*R0.L) (IS) || W[P1++P5]= R3.L || R7 = [I3++];
+
+ L3 = 0;
+ (R7:4,P5:3)=[SP++];
+ unlink;
+ RTS;
+
+
diff --git a/contrib/ffmpeg/libavcodec/bfin/pixels_bfin.S b/contrib/ffmpeg/libavcodec/bfin/pixels_bfin.S
new file mode 100644
index 000000000..2968fcff6
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/bfin/pixels_bfin.S
@@ -0,0 +1,723 @@
+/*
+ * Blackfin Pixel Operations
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.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_bfin.h"
+
+DEFUN(put_pixels_clamped,mL1,
+ (DCTELEM *block, uint8_t *dest, int line_size)):
+ [--SP] = (R7:4);
+ R4 = 0;
+ R5.l = 0x00ff;
+ R5.h = 0x00ff;
+ I0 = R0; // block
+ I1 = R1; // dest
+ R2 += -4; // line_size
+ M1 = R2;
+ P0 = 8;
+ R0 = [I0++];
+ R1 = [I0++];
+ R2 = MAX(R0, R4) (V);
+ LSETUP (ppc$0,ppc$1) LC0=P0;
+ppc$0: R2 = MIN(R2, R5) (V);
+ R3 = MAX(R1, R4) (V);
+ R3 = MIN(R3, R5) (V) || R0 = [I0++];
+ R6 = BYTEPACK (R2,R3) || R1 = [I0++];
+ R2 = MAX(R0, R4) (V) || [I1++] = R6;
+ R2 = MIN(R2, R5) (V);
+ R3 = MAX(R1, R4) (V);
+ R3 = MIN(R3, R5) (V) || R0 = [I0++];
+ R6 = BYTEPACK (R2,R3) || R1 = [I0++];
+ppc$1: R2 = Max(R0, R4) (V) || [I1++M1] = R6;
+
+ (R7:4) = [SP++];
+ RTS;
+
+DEFUN(add_pixels_clamped,mL1,
+ (DCTELEM *block, uint8_t *dest, int line_size)):
+ [-- SP] = (R7:4);
+ R4 = 0;
+ I0 = 0;
+ R2 += -4; // line_size
+ M0 = R2;
+ I1 = R1; // dest
+ I3 = R0; // block
+ I2 = R1; // dest
+ P0 = 8;
+ M3 = 2;
+ R0 = [I3++] || R2 = [I1];
+ R2 = R2 << 8 || R0.H = W[I3--] || R3 = [I1++];
+ R3 = R3 >> 8 || R1.L = W[I3] || I3 += 4;
+ R6 = BYTEOP3P(R1:0, R3:2) (LO) || R1.H = W[I3++] || R2 = [I1];
+
+ LSETUP(apc$2,apc$3) LC1 = P0;
+apc$2: R7 = BYTEOP3P(R1:0, R3:2) (HI, R) || R0 = [I3++] || R3 = [I1++M0];
+ R2 = R2 << 8 || R0.H = W[I3--];
+ R3 = R3 >> 8 || R1.L = W[I3] || I3 += 4;
+ R6 = R6 + R7 (S) || R1.H = W[I3];
+ R6 = BYTEOP3P(R1:0, R3:2) (LO) || I3+=M3 || [I2++]=R6;
+ R7 = BYTEOP3P(R1:0, R3:2) (HI, R) || R0 = [I3++] || R2 = [I1];
+ R2 = R2 << 8 || R0.H = W[I3--] || R3 = [I1++];
+ R3 = R3 >> 8 || R1.L = W[I3] || I3 += 4;
+ R6 = R6 + R7 (S) || R1.H = W[I3++];
+apc$3: R6 = BYTEOP3P(R1:0, R3:2) (LO) || [I2++M0] = R6 || R2 = [I1];
+
+ (R7:4) = [SP++];
+ RTS;
+
+
+/*
+ motion compensation
+ primitives
+
+ * Halfpel motion compensation with rounding (a+b+1)>>1.
+ * This is an array[4][4] of motion compensation funcions for 4
+ * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
+ * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
+ * @param block destination where the result is stored
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+
+*/
+
+DEFUN(put_pixels8uc,mL1,
+ (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+ int dest_size, int line_size, int h)):
+ i3=r0; // dest
+ i0=r1; // src0
+ i1=r2; // src1
+ r0=[sp+12]; // dest_size
+ r2=[sp+16]; // line_size
+ p0=[sp+20]; // h
+ [--sp] = (r7:6);
+ r0+=-4;
+ m3=r0;
+ r2+=-8;
+ m0=r2;
+ LSETUP(pp8$0,pp8$1) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+pp8$0: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R6 = BYTEOP1P(R1:0,R3:2) || R0 = [I0++M0]|| R2 =[I1++M0];
+ R7 = BYTEOP1P(R1:0,R3:2)(R) || R0 = [I0++] || [I3++] = R6 ;
+pp8$1: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
+
+ (r7:6) = [sp++];
+ RTS;
+
+DEFUN(put_pixels16uc,mL1,
+ (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+ int dest_size, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:6);
+ i3=r0; // dest
+ i0=r1; // src0
+ i1=r2; // src1
+ r0=[fp+20]; // dest_size
+ r2=[fp+24]; // line_size
+ p0=[fp+28]; // h
+
+
+ r0+=-12;
+ m3=r0; // line_size
+ r2+=-16;
+ m0=r2;
+
+ LSETUP(pp16$0,pp16$1) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+pp16$0: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R6 = BYTEOP1P(R1:0,R3:2) || R0 = [I0++] || R2 =[I1++];
+ R7 = BYTEOP1P(R1:0,R3:2)(R) || R1 = [I0++] || R3 =[I1++];
+ [I3++] = R6;
+ R6 = BYTEOP1P(R1:0,R3:2) || R0 = [I0++M0] || R2 =[I1++M0];
+ R7 = BYTEOP1P(R1:0,R3:2)(R) || R0 = [I0++] || [I3++] = R7 ;
+ [I3++] = R6;
+pp16$1: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
+
+ (r7:6) = [sp++];
+ unlink;
+ RTS;
+
+
+
+
+
+
+DEFUN(put_pixels8uc_nornd,mL1,
+ (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+ int line_size, int h)):
+ i3=r0; // dest
+ i0=r1; // src0
+ i1=r2; // src1
+ r2=[sp+12]; // line_size
+ p0=[sp+16]; // h
+ [--sp] = (r7:6);
+ r2+=-4;
+ m3=r2;
+ r2+=-4;
+ m0=r2;
+ LSETUP(pp8$2,pp8$3) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+pp8$2: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++M0]|| R2 =[I1++M0];
+ R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++] || [I3++] = R6 ;
+pp8$3: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
+
+ (r7:6) = [sp++];
+ RTS;
+
+DEFUN(put_pixels16uc_nornd,mL1,
+ (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+ int line_size, int h)):
+ i3=r0; // dest
+ i0=r1; // src0
+ i1=r2; // src1
+ r2=[sp+12]; // line_size
+ p0=[sp+16]; // h
+
+ [--sp] = (r7:6);
+ r2+=-12;
+ m3=r2; // line_size
+ r2+=-4;
+ m0=r2;
+
+ LSETUP(pp16$2,pp16$3) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+pp16$2:
+ DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++] || R2 =[I1++];
+ R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R1 = [I0++] || R3 =[I1++];
+ [I3++] = R6;
+
+ R6 = BYTEOP1P(R1:0,R3:2)(T) || R0 = [I0++M0] || R2 =[I1++M0];
+ R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++] || [I3++] = R7 ;
+ [I3++] = R6;
+pp16$3: DISALGNEXCPT || R2 = [I1++] || [I3++M3] = R7;
+
+ (r7:6) = [sp++];
+
+ RTS;
+
+DEFUN(z_put_pixels16_xy2,mL1,
+ (uint8_t *block, const uint8_t *s0,
+ int dest_size, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:4);
+ i3=r0; // dest
+ i0=r1; // src0--> pixels
+ i1=r1; // src1--> pixels + line_size
+ r2+=-12;
+ m2=r2; // m2=dest_width-4
+ r2=[fp+20];
+ m3=r2; // line_size
+ p0=[fp+24]; // h
+ r2+=-16;
+ i1+=m3; /* src1 + line_size */
+ m0=r2; /* line-size - 20 */
+
+ B0 = I0;
+ B1 = I1;
+ B3 = I3;
+
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+ LSETUP(LS$16E,LE$16E) LC0=P0;
+LS$16E: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (RNDL) || R0 = [I0++] || R2 =[I1++];
+ R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R1 = [I0++] || [I3++] = R4 ;
+ DISALGNEXCPT || R3 = [I1++] || [I3++] = R5;
+ R4 = BYTEOP2P (R3:2,R1:0) (RNDL) || R0 = [I0++M0]|| R2 = [I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R0 = [I0++] || [I3++] = R4 ;
+LE$16E: DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
+
+ M1 = 1;
+ I3 = B3;
+ I1 = B1;
+ I0 = B0;
+
+ I0 += M1;
+ I1 += M1;
+
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+ LSETUP(LS$16O,LE$16O) LC0=P0;
+LS$16O: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (RNDH) || R0 = [I0++] || R2 =[I1++];
+ R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R1 = [I0++] || R6 =[I3++];
+ R4 = R4 +|+ R6 || R7 = [I3--];
+ R5 = R5 +|+ R7 || [I3++] = R4;
+ DISALGNEXCPT || R3 =[I1++] || [I3++] = R5;
+ R4 = BYTEOP2P (R3:2,R1:0) (RNDH) || R0 = [I0++M0]|| R2 = [I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R0 = [I0++] || R6 = [I3++];
+ R4 = R4 +|+ R6 || R7 = [I3--];
+ R5 = R5 +|+ R7 || [I3++] = R4;
+LE$16O: DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
+
+ (r7:4) = [sp++];
+ unlink;
+ rts;
+
+DEFUN(put_pixels16_xy2_nornd,mL1,
+ (uint8_t *block, const uint8_t *s0,
+ int line_size, int h)):
+ link 0;
+ [--sp] = (r7:4);
+ i3=r0; // dest
+ i0=r1; // src0--> pixels
+ i1=r1; // src1--> pixels + line_size
+ m3=r2;
+ r2+=-12;
+ m2=r2;
+ r2+=-4;
+ i1+=m3; /* src1 + line_size */
+ m0=r2; /* line-size - 20 */
+ p0=[fp+20]; // h
+
+ B0=I0;
+ B1=I1;
+ B3=I3;
+
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+ LSETUP(LS$16ET,LE$16ET) LC0=P0;
+LS$16ET:DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (TL) || R0 = [I0++] || R2 =[I1++];
+ R5 = BYTEOP2P (R3:2,R1:0) (TL,R) || R1 = [I0++] || [I3++] = R4 ;
+ DISALGNEXCPT || R3 = [I1++] || [I3++] = R5;
+ R4 = BYTEOP2P (R3:2,R1:0) (TL) || R0 = [I0++M0]|| R2 = [I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (TL,R) || R0 = [I0++] || [I3++] = R4 ;
+LE$16ET:DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
+
+ M1 = 1;
+ I3=B3;
+ I1=B1;
+ I0=B0;
+
+ I0 += M1;
+ I1 += M1;
+
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+ LSETUP(LS$16OT,LE$16OT) LC0=P0;
+LS$16OT:DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (TH) || R0 = [I0++] || R2 =[I1++];
+ R5 = BYTEOP2P (R3:2,R1:0) (TH,R) || R1 = [I0++] || R6 =[I3++];
+ R4 = R4 +|+ R6 || R7 = [I3--];
+ R5 = R5 +|+ R7 || [I3++] = R4;
+ DISALGNEXCPT || R3 =[I1++] || [I3++] = R5;
+ R4 = BYTEOP2P (R3:2,R1:0) (TH) || R0 = [I0++M0]|| R2 = [I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (TH,R) || R0 = [I0++] || R6 = [I3++];
+ R4 = R4 +|+ R6 || R7 = [I3--];
+ R5 = R5 +|+ R7 || [I3++] = R4;
+LE$16OT:DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
+
+ (r7:4) = [sp++];
+ unlink;
+ rts;
+
+DEFUN(z_put_pixels8_xy2,mL1,
+ (uint8_t *block, const uint8_t *s0,
+ int dest_size, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:4);
+ i3=r0; // dest
+ i0=r1; // src0--> pixels
+ i1=r1; // src1--> pixels + line_size
+ r2+=-4;
+ m2=r2; // m2=dest_width-4
+ r2=[fp+20];
+ m3=r2; // line_size
+ p0=[fp+24]; // h
+ r2+=-8;
+ i1+=m3; /* src1 + line_size */
+ m0=r2; /* line-size - 20 */
+
+ b0 = I0;
+ b1 = I1;
+ b3 = I3;
+
+ LSETUP(LS$8E,LE$8E) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+LS$8E: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (RNDL) || R0 = [I0++M0] || R2 =[I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (RNDL,R) || R0 = [I0++] || [I3++] = R4 ;
+LE$8E: DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
+
+ M1 = 1;
+ I3 = b3;
+ I1 = b1;
+ I0 = b0;
+
+ I0 += M1;
+ I1 += M1;
+
+ LSETUP(LS$8O,LE$8O) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+LS$8O: DISALGNEXCPT || R1 = [I0++] || R3 =[I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (RNDH) || R0 = [I0++M0] || R2 =[I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (RNDH,R) || R0 = [I0++] || R6 =[I3++];
+ R4 = R4 +|+ R6 || R7 = [I3--];
+ R5 = R5 +|+ R7 || [I3++] = R4;
+LE$8O: DISALGNEXCPT || R2 =[I1++] || [I3++M2] = R5;
+
+ (r7:4) = [sp++];
+ unlink;
+ rts;
+
+DEFUN(put_pixels8_xy2_nornd,mL1,
+ (uint8_t *block, const uint8_t *s0, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:4);
+ i3=r0; // dest
+ i0=r1; // src0--> pixels
+ i1=r1; // src1--> pixels + line_size
+ m3=r2;
+ r2+=-4;
+ m2=r2;
+ r2+=-4;
+ i1+=m3; /* src1 + line_size */
+ m0=r2; /* line-size - 20 */
+ p0=[fp+20]; // h
+
+
+ b0 = I0;
+ b1 = I1;
+ b3 = I3;
+
+ LSETUP(LS$8ET,LE$8ET) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+LS$8ET: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (TL) || R0 = [I0++M0] || R2 = [I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (TL,R) || R0 = [I0++] || [I3++] = R4 ;
+LE$8ET: DISALGNEXCPT || R2 = [I1++] || [I3++M2] = R5;
+
+ M1 = 1;
+ I3 = b3;
+ I1 = b1;
+ I0 = b0;
+
+ I0 += M1;
+ I1 += M1;
+
+ LSETUP(LS$8OT,LE$8OT) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 = [I1++];
+
+LS$8OT: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ R4 = BYTEOP2P (R3:2,R1:0) (TH) || R0 = [I0++M0] || R2 = [I1++M0];
+ R5 = BYTEOP2P (R3:2,R1:0) (TH,R) || R0 = [I0++] || R6 = [I3++];
+ R4 = R4 +|+ R6 || R7 = [I3--];
+ R5 = R5 +|+ R7 || [I3++] = R4;
+LE$8OT: DISALGNEXCPT || R2 =[I1++] || [I3++M2] = R5;
+
+ (r7:4) = [sp++];
+ unlink;
+ rts;
+
+DEFUN(diff_pixels,mL1,
+ (DCTELEM *block, uint8_t *s1, uint8_t *s2, int stride)):
+ link 0;
+ [--sp] = (r7:4);
+ p0=8;
+ i3=r0; // block
+ i0=r1; // s1
+ i1=r2; // s2
+ r2=[fp+20]; // stride
+ r2+=-8;
+ m0=r2;
+
+
+ LSETUP(.LS0,.LE0) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+.LS0: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ (R5,R4) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M0];
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R0 = [I0++] || [I3++] = R4;
+ DISALGNEXCPT || R2 = [I1++] || [I3++] = R5;
+ [i3++]=r6;
+.LE0: [i3++]=r7;
+
+ (r7:4) = [sp++];
+ unlink;
+ rts;
+
+/*
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ sum += pix[j];
+ }
+ pix += line_size;
+ }
+*/
+DEFUN(pix_sum,mL1,
+ (uint8_t *p, int stride)):
+ link 0;
+ [--sp] = (r7:4);
+ p0=8;
+ i0=r0; // s1
+ i1=r0;
+ m1=r1;
+ r1=r1+r1;
+ r1+=-16; // stride
+ m0=r1;
+ i1+=m1;
+
+ r6=0;
+
+ LSETUP(LS$PS,LE$PS) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+LS$PS: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ (R5,R4) = BYTEOP16P (R3:2,R1:0) || R0 = [I0++] || R2 = [I1++];
+ r6=r6+|+r5;
+ r6=r6+|+r4;
+ (R5,R4) = BYTEOP16P (R3:2,R1:0) (R)|| R1 = [I0++] || R3 = [I1++];
+ r6=r6+|+r5;
+ r6=r6+|+r4;
+ (R5,R4) = BYTEOP16P (R3:2,R1:0) || R0 = [I0++m0] || R2 = [I1++m0];
+ r6=r6+|+r5;
+ r6=r6+|+r4;
+ (R5,R4) = BYTEOP16P (R3:2,R1:0) (R)|| R0 = [I0++] || R2 = [I1++];
+ r6=r6+|+r5;
+LE$PS: r6=r6+|+r4;
+ r0.l=r6.l+r6.h;
+ r0.h=0;
+
+ (r7:4) = [sp++];
+ unlink;
+ rts;
+
+
+DEFUN(get_pixels,mL1,
+ (DCTELEM *restrict block, const uint8_t *pixels, int line_size)):
+ [--sp] = (r7:4);
+ i3=r0; // dest
+ i0=r1; // src0
+ p0=8;
+ r2+=-8;
+ m0=r2;
+ LSETUP(gp8$0,gp8$1) LC0=P0;
+
+ DISALGNEXCPT || R0 = [I0++];
+ DISALGNEXCPT || R1 = [I0++];
+
+gp8$0: (R7,R6) = byteunpack R1:0 || R0 = [I0++M0];
+ (R5,R4) = byteunpack R1:0 (R) || R0 = [I0++] || [I3++]=R6;
+ DISALGNEXCPT || R1 = [I0++] || [I3++]=R7;
+ [I3++]=R4;
+gp8$1: [I3++]=R5
+
+
+ (r7:4) = [sp++];
+ RTS;
+
+
+/* sad = sad16x16 (ubyte *mb, ubyte *refwin, srcwidth, refwinwidth, h) */
+/* 91 cycles */
+DEFUN(z_sad16x16,mL1,
+ (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h)):
+ link 0;
+ I0 = R0;
+ I1 = R1;
+
+ A1 = A0 = 0;
+ R0 = [sp+20]; // rwidth
+ P2 = [sp+24]; // height
+ R3 = 16;
+ R0 = R0 - R3;
+ R3 = R2 - R3;
+ M1 = R0;
+ M0 = R3;
+
+ DISALGNEXCPT || R0 = [I0++] || R2 = [I1++];
+ LSETUP (s$16, e$16) LC0=P2;
+s$16: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ SAA (R1:0,R3:2) || R0 = [I0++] || R2 = [I1++];
+ SAA (R1:0,R3:2) (R) || R1 = [I0++] || R3 = [I1++];
+ SAA (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M1];
+e$16: SAA (R1:0,R3:2) (R) || R0 = [I0++] || R2 = [I1++];
+
+ R3=A1.L+A1.H, R2=A0.L+A0.H ;
+ R0 = R2 + R3 ;
+ unlink;
+ RTS;
+
+/* sad = sad8x8 (ubyte *mb, ubyte *refwin, int srcwidth, int refwinwidth, int h) */
+/* 36 cycles */
+DEFUN(z_sad8x8,mL1,
+ (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h)):
+ I0 = R0;
+ I1 = R1;
+
+ A1 = A0 = 0;
+ r0 = [sp+12]; // rwidth
+ P2 = [sp+16]; //height
+ R3 = 8;
+ R0 = R0 - R3;
+ R3 = R2 - R3;
+ M0 = R3;
+ M1 = R0;
+
+ LSETUP (s$8, e$8) LC0=P2;
+ DISALGNEXCPT || R0 = [I0++] || R2 = [I1++];
+ DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+s$8: SAA (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M1];
+ SAA (R1:0,R3:2) (R) || R0 = [I0++] || R2 = [I1++];
+e$8: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+
+ R3=A1.L+A1.H, R2=A0.L+A0.H ;
+ R0 = R2 + R3 ;
+ RTS;
+
+DEFUN(pix_norm1,mL1,
+ (uint8_t * pix, int line_size)):
+ [--SP]=(R7:4,P5:3);
+
+ // Fetch the input arguments.
+ P1 = R0; // pix
+ P0 = R1; // line_size
+ P5 = 16; // loop ctr.
+ P0 -= P5;
+ M0 = P0; // M0 = line_size-16;
+ // Now for the real work.
+ A1 = A0 = 0;
+ lsetup(_pix_norm1_blkfn_loopStart, _pix_norm1_blkfn_loopEnd) LC1 = P5;
+ I0 = P1;
+ DISALGNEXCPT || r0 = [i0++];
+
+_pix_norm1_blkfn_loopStart:
+ // following unpacks pix1[0..15] pix1+line_size[0..15]
+ DISALGNEXCPT || r1 = [i0++];
+
+ (r5, r4) = byteunpack r1:0 || r0 = [i0++];
+ a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
+ a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
+ (r5, r4) = byteunpack r1:0(r) || r1 = [i0++];
+ a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
+ a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
+ (r5, r4) = byteunpack r1:0 || r0 = [i0++M0];
+ a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
+ a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
+ (r5, r4) = byteunpack r1:0(r) || r0 = [i0++];
+ a1 += r5.h * r5.h, a0 += r5.l * r5.l (is);
+_pix_norm1_blkfn_loopEnd:
+ a1 += r4.h * r4.h, a0 += r4.l * r4.l (is);
+
+
+// Clean up at the end:
+ R2 = A0, R3 = A1;
+ R0 = R2 + R3 (S);
+
+ (R7:4,P5:3)=[SP++];
+
+ RTS;
+
+DEFUN(sse4,mL1,
+ (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:6);
+ p0=[fp+24]; // h
+ i0=r1; // pix1
+ i1=r2; // pix2
+ r2=[fp+20]; // line_size
+ r2+=-4;
+ m0=r2;
+
+ a0=a1=0;
+ LSETUP(.S40,.E40) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+.S40: DISALGNEXCPT || R1 = [I0++M0] || R3 = [I1++M0];
+ (R7,R6) = BYTEOP16M (R1:0,R3:2);
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+.E40: a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ a0 += a1;
+ r0 = a0;
+
+ (r7:6) = [sp++];
+ unlink;
+ rts;
+
+DEFUN(sse8,mL1,
+ (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:6);
+ p0=[fp+24]; // h
+ i0=r1; // pix1
+ i1=r2; // pix2
+ r2=[fp+20]; // line_size
+ r2+=-8;
+ m0=r2;
+
+ a0=a1=0;
+ LSETUP(.S80,.E80) LC0=P0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+
+.S80: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M0];
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+ a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R0 = [I0++] || R2 = [I1++];
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+.E80: a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ a0 += a1;
+ r0 = a0;
+
+ (r7:6) = [sp++];
+ unlink;
+ rts;
+
+DEFUN(sse16,mL1,
+ (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)):
+ link 0;
+ [--sp] = (r7:6);
+ p0=[fp+24]; // h
+ i0=r1; // pix1
+ i1=r2; // pix2
+ r2=[fp+20]; // line_size
+ r2+=-16;
+ m0=r2;
+
+ a0=a1=0;
+ DISALGNEXCPT || R0 = [I0++] || R2 =[I1++];
+ LSETUP(.S160,.E160) LC0=P0;
+
+.S160: DISALGNEXCPT || R1 = [I0++] || R3 = [I1++];
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++] || R2 = [I1++];
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+ a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R1 = [I0++] || R3 = [I1++];
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+ a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) || R0 = [I0++M0] || R2 = [I1++M0];
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+ a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ (R7,R6) = BYTEOP16M (R1:0,R3:2) (R)|| R0 = [I0++] || R2 = [I1++];
+ a0 += r7.l * r7.l, a1 += r7.h * r7.h (is);
+.E160: a0 += r6.l * r6.l, a1 += r6.h * r6.h (is);
+ a0 += a1;
+ r0 = a0;
+
+ (r7:6) = [sp++];
+ unlink;
+ rts;
+
+
diff --git a/contrib/ffmpeg/libavcodec/bitstream.c b/contrib/ffmpeg/libavcodec/bitstream.c
index 22d256df5..a0c239798 100644
--- a/contrib/ffmpeg/libavcodec/bitstream.c
+++ b/contrib/ffmpeg/libavcodec/bitstream.c
@@ -30,6 +30,15 @@
#include "avcodec.h"
#include "bitstream.h"
+/**
+ * Same as av_mallocz_static(), but does a realloc.
+ *
+ * @param[in] ptr The block of memory to reallocate.
+ * @param[in] size The requested size.
+ * @return Block of memory of requested size.
+ */
+attribute_deprecated void *ff_realloc_static(void *ptr, unsigned int size);
+
void align_put_bits(PutBitContext *s)
{
#ifdef ALT_BITSTREAM_WRITER
@@ -78,7 +87,7 @@ static int alloc_table(VLC *vlc, int size, int use_static)
if (vlc->table_size > vlc->table_allocated) {
vlc->table_allocated += (1 << vlc->bits);
if(use_static)
- vlc->table = av_realloc_static(vlc->table,
+ vlc->table = ff_realloc_static(vlc->table,
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
else
vlc->table = av_realloc(vlc->table,
@@ -218,10 +227,10 @@ static int build_table(VLC *vlc, int table_nb_bits,
int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
- int use_static)
+ int flags)
{
vlc->bits = nb_bits;
- if(!use_static) {
+ if(!(flags & INIT_VLC_USE_STATIC)) {
vlc->table = NULL;
vlc->table_allocated = 0;
vlc->table_size = 0;
@@ -239,7 +248,7 @@ int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
if (build_table(vlc, nb_bits, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
- 0, 0, use_static) < 0) {
+ 0, 0, flags) < 0) {
av_free(vlc->table);
return -1;
}
diff --git a/contrib/ffmpeg/libavcodec/bitstream.h b/contrib/ffmpeg/libavcodec/bitstream.h
index af25b6dcf..18842702c 100644
--- a/contrib/ffmpeg/libavcodec/bitstream.h
+++ b/contrib/ffmpeg/libavcodec/bitstream.h
@@ -187,12 +187,12 @@ static inline uint##x##_t unaligned##x(const void *v) { \
}
# elif defined(__DECC)
# define unaligned(x) \
-static inline uint##x##_t unaligned##x##(const void *v) { \
+static inline uint##x##_t unaligned##x(const void *v) { \
return *(const __unaligned uint##x##_t *) v; \
}
# else
# define unaligned(x) \
-static inline uint##x##_t unaligned##x##(const void *v) { \
+static inline uint##x##_t unaligned##x(const void *v) { \
return *(const uint##x##_t *) v; \
}
# endif
@@ -662,7 +662,7 @@ static inline int get_sbits(GetBitContext *s, int n){
}
/**
- * reads 0-17 bits.
+ * reads 1-17 bits.
* Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
*/
static inline unsigned int get_bits(GetBitContext *s, int n){
@@ -676,7 +676,7 @@ static inline unsigned int get_bits(GetBitContext *s, int n){
}
/**
- * shows 0-17 bits.
+ * shows 1-17 bits.
* Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
*/
static inline unsigned int show_bits(GetBitContext *s, int n){
@@ -877,7 +877,7 @@ void free_vlc(VLC *vlc);
* read the longest vlc code
* = (max_vlc_length + bits - 1) / bits
*/
-static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
+static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
int bits, int max_depth)
{
int code;
@@ -938,10 +938,10 @@ static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const cha
#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__)
+#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
#else //TRACE
-#define tprintf(...) {}
+#define tprintf(p, ...) {}
#endif
static inline int decode012(GetBitContext *gb){
diff --git a/contrib/ffmpeg/libavcodec/bitstream_filter.c b/contrib/ffmpeg/libavcodec/bitstream_filter.c
index b52acf60a..89fc4e175 100644
--- a/contrib/ffmpeg/libavcodec/bitstream_filter.c
+++ b/contrib/ffmpeg/libavcodec/bitstream_filter.c
@@ -138,7 +138,7 @@ static int mp3_header_compress(AVBitStreamFilterContext *bsfc, AVCodecContext *a
return -1;
}
- header = BE_32(buf);
+ header = AV_RB32(buf);
mode_extension= (header>>4)&3;
if(ff_mpa_check_header(header) < 0 || (header&0x60000) != 0x20000){
@@ -160,7 +160,7 @@ output_unchanged:
av_log(avctx, AV_LOG_ERROR, "Extradata invalid\n");
return -1;
}
- extraheader = BE_32(avctx->extradata+11);
+ extraheader = AV_RB32(avctx->extradata+11);
if((extraheader&MP3_MASK) != (header&MP3_MASK))
goto output_unchanged;
@@ -192,7 +192,7 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext
int sample_rate_index=0;
int lsf, mpeg25, bitrate_index, frame_size;
- header = BE_32(buf);
+ header = AV_RB32(buf);
if(ff_mpa_check_header(header) >= 0){
*poutbuf= (uint8_t *) buf;
*poutbuf_size= buf_size;
@@ -205,7 +205,7 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext
return -1;
}
- header= BE_32(avctx->extradata+11) & MP3_MASK;
+ header= AV_RB32(avctx->extradata+11) & MP3_MASK;
lsf = sample_rate < (24000+32000)/2;
mpeg25 = sample_rate < (12000+16000)/2;
diff --git a/contrib/ffmpeg/libavcodec/bmp.c b/contrib/ffmpeg/libavcodec/bmp.c
index 2a4d83393..d1cfdce6d 100644
--- a/contrib/ffmpeg/libavcodec/bmp.c
+++ b/contrib/ffmpeg/libavcodec/bmp.c
@@ -1,5 +1,5 @@
/*
- * BMP image format
+ * BMP image format decoder
* Copyright (c) 2005 Mans Rullgard
*
* This file is part of FFmpeg.
@@ -20,20 +20,8 @@
*/
#include "avcodec.h"
-#include "bitstream.h"
-#include "bswap.h"
-
-typedef struct BMPContext {
- AVFrame picture;
-} BMPContext;
-
-#define BMP_RGB 0
-#define BMP_RLE8 1
-#define BMP_RLE4 2
-#define BMP_BITFIELDS 3
-
-#define read16(bits) bswap_16(get_bits(bits, 16))
-#define read32(bits) bswap_32(get_bits_long(bits, 32))
+#include "bytestream.h"
+#include "bmp.h"
static int bmp_decode_init(AVCodecContext *avctx){
BMPContext *s = avctx->priv_data;
@@ -51,64 +39,63 @@ static int bmp_decode_frame(AVCodecContext *avctx,
BMPContext *s = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p = &s->picture;
- GetBitContext bits;
unsigned int fsize, hsize;
int width, height;
unsigned int depth;
- unsigned int comp;
+ BiCompression comp;
unsigned int ihsize;
int i, j, n, linesize;
uint32_t rgb[3];
uint8_t *ptr;
int dsize;
+ uint8_t *buf0 = buf;
if(buf_size < 14){
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
return -1;
}
- init_get_bits(&bits, buf, buf_size);
-
- if(get_bits(&bits, 16) != 0x424d){ /* 'BM' */
+ if(bytestream_get_byte(&buf) != 'B' ||
+ bytestream_get_byte(&buf) != 'M') {
av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
return -1;
}
- fsize = read32(&bits);
+ fsize = bytestream_get_le32(&buf);
if(buf_size < fsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
buf_size, fsize);
return -1;
}
- skip_bits(&bits, 16); /* reserved1 */
- skip_bits(&bits, 16); /* reserved2 */
+ buf += 2; /* reserved1 */
+ buf += 2; /* reserved2 */
- hsize = read32(&bits); /* header size */
+ hsize = bytestream_get_le32(&buf); /* header size */
if(fsize <= hsize){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
fsize, hsize);
return -1;
}
- ihsize = read32(&bits); /* more header size */
+ ihsize = bytestream_get_le32(&buf); /* more header size */
if(ihsize + 14 > hsize){
av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
return -1;
}
- width = read32(&bits);
- height = read32(&bits);
+ width = bytestream_get_le32(&buf);
+ height = bytestream_get_le32(&buf);
- if(read16(&bits) != 1){ /* planes */
+ if(bytestream_get_le16(&buf) != 1){ /* planes */
av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
return -1;
}
- depth = read16(&bits);
+ depth = bytestream_get_le16(&buf);
if(ihsize > 16)
- comp = read32(&bits);
+ comp = bytestream_get_le32(&buf);
else
comp = BMP_RGB;
@@ -118,10 +105,10 @@ static int bmp_decode_frame(AVCodecContext *avctx,
}
if(comp == BMP_BITFIELDS){
- skip_bits(&bits, 20 * 8);
- rgb[0] = read32(&bits);
- rgb[1] = read32(&bits);
- rgb[2] = read32(&bits);
+ buf += 20;
+ rgb[0] = bytestream_get_le32(&buf);
+ rgb[1] = bytestream_get_le32(&buf);
+ rgb[2] = bytestream_get_le32(&buf);
}
avctx->codec_id = CODEC_ID_BMP;
@@ -166,6 +153,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
return -1;
}
+ if(p->data[0])
+ avctx->release_buffer(avctx, p);
+
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
@@ -174,7 +164,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
- buf += hsize;
+ buf = buf0 + hsize;
dsize = buf_size - hsize;
/* Line size in file multiple of 4 */
@@ -197,7 +187,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
switch(depth){
case 24:
for(i = 0; i < avctx->height; i++){
- memcpy(ptr, buf, n);
+ memcpy(ptr, buf, avctx->width*(depth>>3));
buf += n;
ptr += linesize;
}
@@ -242,6 +232,16 @@ static int bmp_decode_frame(AVCodecContext *avctx,
return buf_size;
}
+static int bmp_decode_end(AVCodecContext *avctx)
+{
+ BMPContext* c = avctx->priv_data;
+
+ if (c->picture.data[0])
+ avctx->release_buffer(avctx, &c->picture);
+
+ return 0;
+}
+
AVCodec bmp_decoder = {
"bmp",
CODEC_TYPE_VIDEO,
@@ -249,6 +249,6 @@ AVCodec bmp_decoder = {
sizeof(BMPContext),
bmp_decode_init,
NULL,
- NULL,
+ bmp_decode_end,
bmp_decode_frame
};
diff --git a/contrib/ffmpeg/libavcodec/bmp.h b/contrib/ffmpeg/libavcodec/bmp.h
new file mode 100644
index 000000000..cf6ace845
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/bmp.h
@@ -0,0 +1,31 @@
+/*
+ * internals for BMP codecs
+ * Copyright (c) 2005 Mans Rullgard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+typedef struct BMPContext {
+ AVFrame picture;
+} BMPContext;
+
+typedef enum {
+ BMP_RGB =0,
+ BMP_RLE8 =1,
+ BMP_RLE4 =2,
+ BMP_BITFIELDS =3,
+} BiCompression;
diff --git a/contrib/ffmpeg/libavcodec/bmpenc.c b/contrib/ffmpeg/libavcodec/bmpenc.c
new file mode 100644
index 000000000..351038504
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/bmpenc.c
@@ -0,0 +1,98 @@
+/*
+ * BMP image format encoder
+ * Copyright (c) 2006, 2007 Michel Bardiaux
+ *
+ * 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 "bytestream.h"
+#include "bmp.h"
+
+static int bmp_encode_init(AVCodecContext *avctx){
+ BMPContext *s = avctx->priv_data;
+
+ avcodec_get_frame_defaults((AVFrame*)&s->picture);
+ avctx->coded_frame = (AVFrame*)&s->picture;
+
+ return 0;
+}
+
+static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
+ BMPContext *s = avctx->priv_data;
+ AVFrame *pict = data;
+ AVFrame * const p= (AVFrame*)&s->picture;
+ int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize;
+ uint8_t *ptr;
+ unsigned char* buf0 = buf;
+ *p = *pict;
+ p->pict_type= FF_I_TYPE;
+ p->key_frame= 1;
+ n_bytes_per_row = (avctx->width*3 + 3) & ~3;
+ n_bytes_image = avctx->height*n_bytes_per_row;
+
+ // STRUCTURE.field refer to the MSVC documentation for BITMAPFILEHEADER
+ // and related pages.
+#define SIZE_BITMAPFILEHEADER 14
+#define SIZE_BITMAPINFOHEADER 40
+ hsize = SIZE_BITMAPFILEHEADER + SIZE_BITMAPINFOHEADER;
+ n_bytes = n_bytes_image + hsize;
+ if(n_bytes>buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "buf size too small (need %d, got %d)\n", n_bytes, buf_size);
+ return -1;
+ }
+ bytestream_put_byte(&buf, 'B'); // BITMAPFILEHEADER.bfType
+ bytestream_put_byte(&buf, 'M'); // do.
+ bytestream_put_le32(&buf, n_bytes); // BITMAPFILEHEADER.bfSize
+ bytestream_put_le16(&buf, 0); // BITMAPFILEHEADER.bfReserved1
+ bytestream_put_le16(&buf, 0); // BITMAPFILEHEADER.bfReserved2
+ bytestream_put_le32(&buf, hsize); // BITMAPFILEHEADER.bfOffBits
+ bytestream_put_le32(&buf, SIZE_BITMAPINFOHEADER); // BITMAPINFOHEADER.biSize
+ bytestream_put_le32(&buf, avctx->width); // BITMAPINFOHEADER.biWidth
+ bytestream_put_le32(&buf, avctx->height); // BITMAPINFOHEADER.biHeight
+ bytestream_put_le16(&buf, 1); // BITMAPINFOHEADER.biPlanes
+ bytestream_put_le16(&buf, 24); // BITMAPINFOHEADER.biBitCount
+ bytestream_put_le32(&buf, BMP_RGB); // BITMAPINFOHEADER.biCompression
+ bytestream_put_le32(&buf, n_bytes_image); // BITMAPINFOHEADER.biSizeImage
+ bytestream_put_le32(&buf, 0); // BITMAPINFOHEADER.biXPelsPerMeter
+ bytestream_put_le32(&buf, 0); // BITMAPINFOHEADER.biYPelsPerMeter
+ bytestream_put_le32(&buf, 0); // BITMAPINFOHEADER.biClrUsed
+ bytestream_put_le32(&buf, 0); // BITMAPINFOHEADER.biClrImportant
+ // BMP files are bottom-to-top so we start from the end...
+ ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
+ buf = buf0 + hsize;
+ for(i = 0; i < avctx->height; i++) {
+ n = 3*avctx->width;
+ memcpy(buf, ptr, n);
+ buf += n;
+ memset(buf, 0, n_bytes_per_row-n);
+ buf += n_bytes_per_row-n;
+ ptr -= p->linesize[0]; // ... and go back
+ }
+ return n_bytes;
+}
+
+AVCodec bmp_encoder = {
+ "bmp",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_BMP,
+ sizeof(BMPContext),
+ bmp_encode_init,
+ bmp_encode_frame,
+ NULL, //encode_end,
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_BGR24, -1},
+};
diff --git a/contrib/ffmpeg/libavcodec/bytestream.h b/contrib/ffmpeg/libavcodec/bytestream.h
index 25c457fe4..d1e9f82ed 100644
--- a/contrib/ffmpeg/libavcodec/bytestream.h
+++ b/contrib/ffmpeg/libavcodec/bytestream.h
@@ -22,65 +22,34 @@
#ifndef FFMPEG_BYTESTREAM_H
#define FFMPEG_BYTESTREAM_H
-static always_inline unsigned int bytestream_get_le32(uint8_t **b)
-{
- (*b) += 4;
- return LE_32(*b - 4);
-}
+#define DEF(name, bytes, read, write)\
+static av_always_inline unsigned int bytestream_get_ ## name(uint8_t **b){\
+ (*b) += bytes;\
+ return read(*b - bytes);\
+}\
+static av_always_inline void bytestream_put_ ##name(uint8_t **b, const unsigned int value){\
+ write(*b, value);\
+ (*b) += bytes;\
+};
-static always_inline unsigned int bytestream_get_le16(uint8_t **b)
-{
- (*b) += 2;
- return LE_16(*b - 2);
-}
+DEF(le32, 4, AV_RL32, AV_WL32)
+DEF(le24, 3, AV_RL24, AV_WL24)
+DEF(le16, 2, AV_RL16, AV_WL16)
+DEF(be32, 4, AV_RB32, AV_WB32)
+DEF(be24, 3, AV_RB24, AV_WB24)
+DEF(be16, 2, AV_RB16, AV_WB16)
+DEF(byte, 1, AV_RB8 , AV_WB8 )
-static always_inline unsigned int bytestream_get_byte(uint8_t **b)
-{
- (*b)++;
- return (*b)[-1];
-}
+#undef DEF
-static always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size)
+static av_always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size)
{
memcpy(dst, *b, size);
(*b) += size;
return size;
}
-static always_inline void bytestream_put_be32(uint8_t **b, const unsigned int value)
-{
- *(*b)++ = value >> 24;
- *(*b)++ = value >> 16;
- *(*b)++ = value >> 8;
- *(*b)++ = value;
-};
-
-static always_inline void bytestream_put_be16(uint8_t **b, const unsigned int value)
-{
- *(*b)++ = value >> 8;
- *(*b)++ = value;
-}
-
-static always_inline void bytestream_put_le32(uint8_t **b, const unsigned int value)
-{
- *(*b)++ = value;
- *(*b)++ = value >> 8;
- *(*b)++ = value >> 16;
- *(*b)++ = value >> 24;
-}
-
-static always_inline void bytestream_put_le16(uint8_t **b, const unsigned int value)
-{
- *(*b)++ = value;
- *(*b)++ = value >> 8;
-}
-
-static always_inline void bytestream_put_byte(uint8_t **b, const unsigned int value)
-{
- *(*b)++ = value;
-}
-
-static always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
+static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
{
memcpy(*b, src, size);
(*b) += size;
diff --git a/contrib/ffmpeg/libavcodec/cabac.h b/contrib/ffmpeg/libavcodec/cabac.h
index 43fe78e3b..c96eb0b96 100644
--- a/contrib/ffmpeg/libavcodec/cabac.h
+++ b/contrib/ffmpeg/libavcodec/cabac.h
@@ -363,7 +363,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
refill(c);
}
-static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state){
+static int av_always_inline get_cabac_inline(CABACContext *c, uint8_t * const state){
//FIXME gcc generates duplicate load/stores for c->low and c->range
#define LOW "0"
#define RANGE "4"
@@ -376,7 +376,7 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state
#define BYTE "16"
#define BYTEEND "20"
#endif
-#if defined(ARCH_X86) && !(defined(PIC) && defined(__GNUC__))
+#if defined(ARCH_X86) && defined(CONFIG_7REGS) && defined(CONFIG_EBX_AVAILABLE)
int bit;
#ifndef BRANCHLESS_CABAC_DECODER
@@ -462,7 +462,7 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state
#else /* BRANCHLESS_CABAC_DECODER */
-#if defined CMOV_IS_FAST
+#if defined HAVE_FAST_CMOV
#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
@@ -472,7 +472,7 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state
"and %%ecx , "tmp" \n\t"\
"sub "tmp" , "low" \n\t"\
"xor %%ecx , "ret" \n\t"
-#else /* CMOV_IS_FAST */
+#else /* HAVE_FAST_CMOV */
#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
@@ -485,7 +485,7 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state
"and "tmp" , %%ecx \n\t"\
"sub %%ecx , "low" \n\t"\
"xor "tmp" , "ret" \n\t"
-#endif /* CMOV_IS_FAST */
+#endif /* HAVE_FAST_CMOV */
#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
@@ -539,26 +539,26 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state
c->range -= RangeLPS;
#ifndef BRANCHLESS_CABAC_DECODER
- if(c->low < (c->range<<17)){
+ if(c->low < (c->range<<(CABAC_BITS+1))){
bit= s&1;
*state= ff_h264_mps_state[s];
renorm_cabac_decoder_once(c);
}else{
bit= ff_h264_norm_shift[RangeLPS];
- c->low -= (c->range<<17);
+ c->low -= (c->range<<(CABAC_BITS+1));
*state= ff_h264_lps_state[s];
c->range = RangeLPS<<bit;
c->low <<= bit;
bit= (s&1)^1;
- if(!(c->low & 0xFFFF)){
+ if(!(c->low & CABAC_MASK)){
refill2(c);
}
}
#else /* BRANCHLESS_CABAC_DECODER */
- lps_mask= ((c->range<<17) - c->low)>>31;
+ lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31;
- c->low -= (c->range<<17) & lps_mask;
+ c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask;
c->range += (RangeLPS - c->range) & lps_mask;
s^=lps_mask;
@@ -575,7 +575,7 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state
return bit;
}
-static int __attribute((noinline)) get_cabac_noinline(CABACContext *c, uint8_t * const state){
+static int av_noinline get_cabac_noinline(CABACContext *c, uint8_t * const state){
return get_cabac_inline(c,state);
}
@@ -620,7 +620,7 @@ static int get_cabac_bypass(CABACContext *c){
if(!(c->low & CABAC_MASK))
refill(c);
- range= c->range<<17;
+ range= c->range<<(CABAC_BITS+1);
if(c->low < range){
return 0;
}else{
@@ -631,7 +631,7 @@ static int get_cabac_bypass(CABACContext *c){
}
-static always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
+static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
#if defined(ARCH_X86) && !(defined(PIC) && defined(__GNUC__))
asm volatile(
"movl "RANGE "(%1), %%ebx \n\t"
@@ -669,7 +669,7 @@ static always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
if(!(c->low & CABAC_MASK))
refill(c);
- range= c->range<<17;
+ range= c->range<<(CABAC_BITS+1);
c->low -= range;
mask= c->low >> 31;
range &= mask;
@@ -680,7 +680,7 @@ static always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
//FIXME the x86 code from this file should be moved into i386/h264 or cabac something.c/h (note ill kill you if you move my code away from under my fingers before iam finished with it!)
//FIXME use some macros to avoid duplicatin get_cabac (cant be done yet as that would make optimization work hard)
-#if defined(ARCH_X86) && !(defined(PIC) && defined(__GNUC__))
+#if defined(ARCH_X86) && defined(CONFIG_7REGS) && defined(CONFIG_EBX_AVAILABLE)
static int decode_significance_x86(CABACContext *c, int max_coeff, uint8_t *significant_coeff_ctx_base, int *index){
void *end= significant_coeff_ctx_base + max_coeff - 1;
int minusstart= -(int)significant_coeff_ctx_base;
@@ -794,7 +794,7 @@ static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coe
*/
static int get_cabac_terminate(CABACContext *c){
c->range -= 2;
- if(c->low < c->range<<17){
+ if(c->low < c->range<<(CABAC_BITS+1)){
renorm_cabac_decoder_once(c);
return 0;
}else{
diff --git a/contrib/ffmpeg/libavcodec/cavs.c b/contrib/ffmpeg/libavcodec/cavs.c
index ee862bbc7..4672635d7 100644
--- a/contrib/ffmpeg/libavcodec/cavs.c
+++ b/contrib/ffmpeg/libavcodec/cavs.c
@@ -128,9 +128,9 @@ static inline int get_bs(vector_t *mvP, vector_t *mvQ, int b) {
}
#define SET_PARAMS \
- alpha = alpha_tab[clip(qp_avg + h->alpha_offset,0,63)]; \
- beta = beta_tab[clip(qp_avg + h->beta_offset, 0,63)]; \
- tc = tc_tab[clip(qp_avg + h->alpha_offset,0,63)];
+ alpha = alpha_tab[av_clip(qp_avg + h->alpha_offset,0,63)]; \
+ beta = beta_tab[av_clip(qp_avg + h->beta_offset, 0,63)]; \
+ tc = tc_tab[av_clip(qp_avg + h->alpha_offset,0,63)];
/**
* in-loop deblocking filter for a single macroblock
diff --git a/contrib/ffmpeg/libavcodec/cavsdsp.c b/contrib/ffmpeg/libavcodec/cavsdsp.c
index 220dec1b8..55ecaae0a 100644
--- a/contrib/ffmpeg/libavcodec/cavsdsp.c
+++ b/contrib/ffmpeg/libavcodec/cavsdsp.c
@@ -63,16 +63,16 @@ static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta
int q0 = Q0;
if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
- int delta = clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
- P0 = clip_uint8(p0+delta);
- Q0 = clip_uint8(q0-delta);
+ int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
+ P0 = av_clip_uint8(p0+delta);
+ Q0 = av_clip_uint8(q0-delta);
if(abs(P2-p0)<beta) {
- delta = clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
- P1 = clip_uint8(P1+delta);
+ delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
+ P1 = av_clip_uint8(P1+delta);
}
if(abs(Q2-q0)<beta) {
- delta = clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
- Q1 = clip_uint8(Q1-delta);
+ delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
+ Q1 = av_clip_uint8(Q1-delta);
}
}
}
@@ -98,9 +98,9 @@ static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta)
static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta,
int tc) {
if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) {
- int delta = clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
- P0 = clip_uint8(P0+delta);
- Q0 = clip_uint8(Q0-delta);
+ int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
+ P0 = av_clip_uint8(P0+delta);
+ Q0 = av_clip_uint8(Q0-delta);
}
}
diff --git a/contrib/ffmpeg/libavcodec/cinepak.c b/contrib/ffmpeg/libavcodec/cinepak.c
index e137377e5..db0519b5d 100644
--- a/contrib/ffmpeg/libavcodec/cinepak.c
+++ b/contrib/ffmpeg/libavcodec/cinepak.c
@@ -26,6 +26,8 @@
* by Ewald Snel <ewald@rambo.its.tudelft.nl>
* For more information on the Cinepak algorithm, visit:
* http://www.csse.monash.edu.au/~timf/
+ * For more information on the quirky data inside Sega FILM/CPK files, visit:
+ * http://wiki.multimedia.cx/index.php?title=Sega_FILM
*/
#include <stdio.h>
@@ -67,6 +69,8 @@ typedef struct CinepakContext {
int palette_video;
cvid_strip_t strips[MAX_STRIPS];
+ int sega_film_skip_bytes;
+
} CinepakContext;
static void cinepak_decode_codebook (cvid_codebook_t *codebook,
@@ -86,7 +90,7 @@ static void cinepak_decode_codebook (cvid_codebook_t *codebook,
if ((data + 4) > eod)
break;
- flag = BE_32 (data);
+ flag = AV_RB32 (data);
data += 4;
mask = 0x80000000;
}
@@ -148,7 +152,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
if ((data + 4) > eod)
return -1;
- flag = BE_32 (data);
+ flag = AV_RB32 (data);
data += 4;
mask = 0x80000000;
}
@@ -158,7 +162,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
if ((data + 4) > eod)
return -1;
- flag = BE_32 (data);
+ flag = AV_RB32 (data);
data += 4;
mask = 0x80000000;
}
@@ -274,8 +278,8 @@ static int cinepak_decode_strip (CinepakContext *s,
return -1;
while ((data + 4) <= eod) {
- chunk_id = BE_16 (&data[0]);
- chunk_size = BE_16 (&data[2]) - 4;
+ chunk_id = AV_RB16 (&data[0]);
+ chunk_size = AV_RB16 (&data[2]) - 4;
if(chunk_size < 0)
return -1;
@@ -319,21 +323,36 @@ static int cinepak_decode (CinepakContext *s)
int i, result, strip_size, frame_flags, num_strips;
int y0 = 0;
int encoded_buf_size;
- /* if true, Cinepak data is from a Sega FILM/CPK file */
- int sega_film_data = 0;
if (s->size < 10)
return -1;
frame_flags = s->data[0];
- num_strips = BE_16 (&s->data[8]);
- encoded_buf_size = ((s->data[1] << 16) | BE_16 (&s->data[2]));
- if (encoded_buf_size != s->size)
- sega_film_data = 1;
- if (sega_film_data)
- s->data += 12;
- else
- s->data += 10;
+ num_strips = AV_RB16 (&s->data[8]);
+ encoded_buf_size = ((s->data[1] << 16) | AV_RB16 (&s->data[2]));
+
+ /* if this is the first frame, check for deviant Sega FILM data */
+ if (s->sega_film_skip_bytes == -1) {
+ if (encoded_buf_size != s->size) {
+ /* If the encoded frame size differs from the frame size as indicated
+ * by the container file, this data likely comes from a Sega FILM/CPK file.
+ * If the frame header is followed by the bytes FE 00 00 06 00 00 then
+ * this is probably one of the two known files that have 6 extra bytes
+ * after the frame header. Else, assume 2 extra bytes. */
+ if ((s->data[10] == 0xFE) &&
+ (s->data[11] == 0x00) &&
+ (s->data[12] == 0x00) &&
+ (s->data[13] == 0x06) &&
+ (s->data[14] == 0x00) &&
+ (s->data[15] == 0x00))
+ s->sega_film_skip_bytes = 6;
+ else
+ s->sega_film_skip_bytes = 2;
+ } else
+ s->sega_film_skip_bytes = 0;
+ }
+
+ s->data += 10 + s->sega_film_skip_bytes;
if (num_strips > MAX_STRIPS)
num_strips = MAX_STRIPS;
@@ -342,13 +361,13 @@ static int cinepak_decode (CinepakContext *s)
if ((s->data + 12) > eod)
return -1;
- s->strips[i].id = BE_16 (s->data);
+ s->strips[i].id = AV_RB16 (s->data);
s->strips[i].y1 = y0;
s->strips[i].x1 = 0;
- s->strips[i].y2 = y0 + BE_16 (&s->data[8]);
+ s->strips[i].y2 = y0 + AV_RB16 (&s->data[8]);
s->strips[i].x2 = s->avctx->width;
- strip_size = BE_16 (&s->data[2]) - 12;
+ strip_size = AV_RB16 (&s->data[2]) - 12;
s->data += 12;
strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
@@ -377,6 +396,7 @@ static int cinepak_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->width = (avctx->width + 3) & ~3;
s->height = (avctx->height + 3) & ~3;
+ s->sega_film_skip_bytes = -1; /* uninitialized state */
// check for paletted data
if ((avctx->palctrl == NULL) || (avctx->bits_per_sample == 40)) {
diff --git a/contrib/ffmpeg/libavcodec/cook.c b/contrib/ffmpeg/libavcodec/cook.c
index 47d9ce2c3..32b1081cc 100644
--- a/contrib/ffmpeg/libavcodec/cook.c
+++ b/contrib/ffmpeg/libavcodec/cook.c
@@ -50,12 +50,15 @@
#include "avcodec.h"
#include "bitstream.h"
#include "dsputil.h"
+#include "common.h"
+#include "bytestream.h"
+#include "random.h"
#include "cookdata.h"
/* the different Cook versions */
-#define MONO_COOK1 0x1000001
-#define MONO_COOK2 0x1000002
+#define MONO 0x1000001
+#define STEREO 0x1000002
#define JOINT_STEREO 0x1000003
#define MC_COOK 0x2000000 //multichannel Cook, not supported
@@ -63,23 +66,9 @@
//#define COOKDEBUG
typedef struct {
- int size;
- int qidx_table1[8];
- int qidx_table2[8];
-} COOKgain;
-
-typedef struct __attribute__((__packed__)){
- /* codec data start */
- uint32_t cookversion; //in network order, bigendian
- uint16_t samples_per_frame; //amount of samples per frame per channel, bigendian
- uint16_t subbands; //amount of bands used in the frequency domain, bigendian
- /* Mono extradata ends here. */
- uint32_t unused;
- uint16_t js_subband_start; //bigendian
- uint16_t js_vlc_bits; //bigendian
- /* Stereo extradata ends here. */
-} COOKextradata;
-
+ int *now;
+ int *previous;
+} cook_gains;
typedef struct {
GetBitContext gb;
@@ -97,28 +86,22 @@ typedef struct {
int total_subbands;
int num_vectors;
int bits_per_subpacket;
+ int cookversion;
/* states */
- int random_state;
+ AVRandomState random_state;
/* transform data */
- FFTContext fft_ctx;
- FFTSample mlt_tmp[1024] __attribute__((aligned(16))); /* temporary storage for imlt */
+ MDCTContext mdct_ctx;
+ DECLARE_ALIGNED_16(FFTSample, mdct_tmp[1024]); /* temporary storage for imlt */
float* mlt_window;
- float* mlt_precos;
- float* mlt_presin;
- float* mlt_postcos;
- int fft_size;
- int fft_order;
- int mlt_size; //modulated lapped transform size
/* gain buffers */
- COOKgain* gain_now_ptr;
- COOKgain* gain_previous_ptr;
- COOKgain gain_current;
- COOKgain gain_now;
- COOKgain gain_previous;
- COOKgain gain_channel1[2];
- COOKgain gain_channel2[2];
+ cook_gains gains1;
+ cook_gains gains2;
+ int gain_1[9];
+ int gain_2[9];
+ int gain_3[9];
+ int gain_4[9];
/* VLC data */
int js_vlc_bits;
@@ -135,16 +118,11 @@ typedef struct {
/* data buffers */
uint8_t* decoded_bytes_buffer;
- float mono_mdct_output[2048] __attribute__((aligned(16)));
- float* previous_buffer_ptr[2];
+ DECLARE_ALIGNED_16(float,mono_mdct_output[2048]);
float mono_previous_buffer1[1024];
float mono_previous_buffer2[1024];
- float* decode_buf_ptr[4];
- float* decode_buf_ptr2[2];
float decode_buffer_1[1024];
float decode_buffer_2[1024];
- float decode_buffer_3[1024];
- float decode_buffer_4[1024];
} COOKContext;
/* debug functions */
@@ -242,34 +220,25 @@ static int init_cook_vlc_tables(COOKContext *q) {
static int init_cook_mlt(COOKContext *q) {
int j;
float alpha;
+ int mlt_size = q->samples_per_channel;
- /* Allocate the buffers, could be replaced with a static [512]
- array if needed. */
- q->mlt_size = q->samples_per_channel;
- q->mlt_window = av_malloc(sizeof(float)*q->mlt_size);
- q->mlt_precos = av_malloc(sizeof(float)*q->mlt_size/2);
- q->mlt_presin = av_malloc(sizeof(float)*q->mlt_size/2);
- q->mlt_postcos = av_malloc(sizeof(float)*q->mlt_size/2);
+ if ((q->mlt_window = av_malloc(sizeof(float)*mlt_size)) == 0)
+ return -1;
/* Initialize the MLT window: simple sine window. */
- alpha = M_PI / (2.0 * (float)q->mlt_size);
- for(j=0 ; j<q->mlt_size ; j++) {
- q->mlt_window[j] = sin((j + 512.0/(float)q->mlt_size) * alpha);
- }
-
- /* pre/post twiddle factors */
- for (j=0 ; j<q->mlt_size/2 ; j++){
- q->mlt_precos[j] = cos( ((j+0.25)*M_PI)/q->mlt_size);
- q->mlt_presin[j] = sin( ((j+0.25)*M_PI)/q->mlt_size);
- q->mlt_postcos[j] = (float)sqrt(2.0/(float)q->mlt_size)*cos( ((float)j*M_PI) /q->mlt_size); //sqrt(2/MLT_size) = scalefactor
+ alpha = M_PI / (2.0 * (float)mlt_size);
+ for(j=0 ; j<mlt_size ; j++)
+ q->mlt_window[j] = sin((j + 0.5) * alpha) * sqrt(2.0 / q->samples_per_channel);
+
+ /* Initialize the MDCT. */
+ if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1)) {
+ av_free(q->mlt_window);
+ return -1;
}
+ av_log(NULL,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n",
+ av_log2(mlt_size)+1);
- /* Initialize the FFT. */
- ff_fft_init(&q->fft_ctx, av_log2(q->mlt_size)-1, 0);
- av_log(NULL,AV_LOG_DEBUG,"FFT initialized, order = %d.\n",
- av_log2(q->samples_per_channel)-1);
-
- return (int)(q->mlt_window && q->mlt_precos && q->mlt_presin && q->mlt_postcos);
+ return 0;
}
/*************** init functions end ***********/
@@ -277,16 +246,30 @@ static int init_cook_mlt(COOKContext *q) {
/**
* Cook indata decoding, every 32 bits are XORed with 0x37c511f2.
* Why? No idea, some checksum/error detection method maybe.
+ *
+ * Out buffer size: extra bytes are needed to cope with
+ * padding/missalignment.
+ * Subpackets passed to the decoder can contain two, consecutive
+ * half-subpackets, of identical but arbitrary size.
+ * 1234 1234 1234 1234 extraA extraB
+ * Case 1: AAAA BBBB 0 0
+ * Case 2: AAAA ABBB BB-- 3 3
+ * Case 3: AAAA AABB BBBB 2 2
+ * Case 4: AAAA AAAB BBBB BB-- 1 5
+ *
* Nice way to waste CPU cycles.
*
- * @param in pointer to 32bit array of indata
- * @param bits amount of bits
- * @param out pointer to 32bit array of outdata
+ * @param inbuffer pointer to byte array of indata
+ * @param out pointer to byte array of outdata
+ * @param bytes number of bytes
*/
+#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4)
+#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes)))
-static inline void decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
- int i;
- uint32_t* buf = (uint32_t*) inbuffer;
+static inline int decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
+ int i, off;
+ uint32_t c;
+ uint32_t* buf;
uint32_t* obuf = (uint32_t*) out;
/* FIXME: 64 bit platforms would be able to do 64 bits at a time.
* I'm too lazy though, should be something like
@@ -294,14 +277,14 @@ static inline void decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
* (int64_t)out[i] = 0x37c511f237c511f2^be2me_64(int64_t)in[i]);
* Buffer alignment needs to be checked. */
+ off = (int)((long)inbuffer & 3);
+ buf = (uint32_t*) (inbuffer - off);
+ c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8))));
+ bytes += 3 + off;
+ for (i = 0; i < bytes/4; i++)
+ obuf[i] = c ^ buf[i];
- for(i=0 ; i<bytes/4 ; i++){
-#ifdef WORDS_BIGENDIAN
- obuf[i] = 0x37c511f2^buf[i];
-#else
- obuf[i] = 0xf211c537^buf[i];
-#endif
- }
+ return off;
}
/**
@@ -312,17 +295,14 @@ static int cook_decode_close(AVCodecContext *avctx)
{
int i;
COOKContext *q = avctx->priv_data;
- av_log(NULL,AV_LOG_DEBUG, "Deallocating memory.\n");
+ av_log(avctx,AV_LOG_DEBUG, "Deallocating memory.\n");
/* Free allocated memory buffers. */
av_free(q->mlt_window);
- av_free(q->mlt_precos);
- av_free(q->mlt_presin);
- av_free(q->mlt_postcos);
av_free(q->decoded_bytes_buffer);
/* Free the transform. */
- ff_fft_end(&q->fft_ctx);
+ ff_mdct_end(&q->mdct_ctx);
/* Free the VLC tables. */
for (i=0 ; i<13 ; i++) {
@@ -341,29 +321,27 @@ static int cook_decode_close(AVCodecContext *avctx)
}
/**
- * Fill the COOKgain structure for the timedomain quantization.
+ * Fill the gain array for the timedomain quantization.
*
* @param q pointer to the COOKContext
- * @param gaininfo pointer to the COOKgain
+ * @param gaininfo[9] array of gain indices
*/
-static void decode_gain_info(GetBitContext *gb, COOKgain* gaininfo) {
- int i;
+static void decode_gain_info(GetBitContext *gb, int *gaininfo)
+{
+ int i, n;
while (get_bits1(gb)) {}
+ n = get_bits_count(gb) - 1; //amount of elements*2 to update
- gaininfo->size = get_bits_count(gb) - 1; //amount of elements*2 to update
-
- if (get_bits_count(gb) - 1 <= 0) return;
+ i = 0;
+ while (n--) {
+ int index = get_bits(gb, 3);
+ int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1;
- for (i=0 ; i<gaininfo->size ; i++){
- gaininfo->qidx_table1[i] = get_bits(gb,3);
- if (get_bits1(gb)) {
- gaininfo->qidx_table2[i] = get_bits(gb,4) - 7; //convert to signed
- } else {
- gaininfo->qidx_table2[i] = -1;
- }
+ while (i <= index) gaininfo[i++] = gain;
}
+ while (i <= 8) gaininfo[i++] = 0;
}
/**
@@ -397,22 +375,6 @@ static void decode_envelope(COOKContext *q, int* quant_index_table) {
}
/**
- * Create the quant value table.
- *
- * @param q pointer to the COOKContext
- * @param quant_value_table pointer to the array
- */
-
-static void inline dequant_envelope(COOKContext *q, int* quant_index_table,
- float* quant_value_table){
-
- int i;
- for(i=0 ; i < q->total_subbands ; i++){
- quant_value_table[i] = q->rootpow2tab[quant_index_table[i]+63];
- }
-}
-
-/**
* Calculate the category and category_index vector.
*
* @param q pointer to the COOKContext
@@ -559,46 +521,41 @@ static void inline expand_category(COOKContext *q, int* category,
*
* @param q pointer to the COOKContext
* @param index index
- * @param band current subband
- * @param quant_value_table pointer to the array
+ * @param quant_index quantisation index
* @param subband_coef_index array of indexes to quant_centroid_tab
- * @param subband_coef_noise use random noise instead of predetermined value
- * @param mlt_buffer pointer to the mlt buffer
+ * @param subband_coef_sign signs of coefficients
+ * @param mlt_p pointer into the mlt buffer
*/
-
-static void scalar_dequant(COOKContext *q, int index, int band,
- float* quant_value_table, int* subband_coef_index,
- int* subband_coef_noise, float* mlt_buffer){
+static void scalar_dequant(COOKContext *q, int index, int quant_index,
+ int* subband_coef_index, int* subband_coef_sign,
+ float* mlt_p){
int i;
float f1;
for(i=0 ; i<SUBBAND_SIZE ; i++) {
if (subband_coef_index[i]) {
- if (subband_coef_noise[i]) {
- f1 = -quant_centroid_tab[index][subband_coef_index[i]];
- } else {
- f1 = quant_centroid_tab[index][subband_coef_index[i]];
- }
+ f1 = quant_centroid_tab[index][subband_coef_index[i]];
+ if (subband_coef_sign[i]) f1 = -f1;
} else {
- /* noise coding if subband_coef_noise[i] == 0 */
- q->random_state = q->random_state * 214013 + 2531011; //typical RNG numbers
- f1 = randsign[(q->random_state/0x1000000)&1] * dither_tab[index]; //>>31
+ /* noise coding if subband_coef_index[i] == 0 */
+ f1 = dither_tab[index];
+ if (av_random(&q->random_state) < 0x80000000) f1 = -f1;
}
- mlt_buffer[band*20+ i] = f1 * quant_value_table[band];
+ mlt_p[i] = f1 * q->rootpow2tab[quant_index+63];
}
}
/**
- * Unpack the subband_coef_index and subband_coef_noise vectors.
+ * Unpack the subband_coef_index and subband_coef_sign vectors.
*
* @param q pointer to the COOKContext
* @param category pointer to the category array
* @param subband_coef_index array of indexes to quant_centroid_tab
- * @param subband_coef_noise use random noise instead of predetermined value
+ * @param subband_coef_sign signs of coefficients
*/
static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index,
- int* subband_coef_noise) {
+ int* subband_coef_sign) {
int i,j;
int vlc, vd ,tmp, result;
int ub;
@@ -622,13 +579,13 @@ static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index,
for(j=0 ; j<vd ; j++){
if (subband_coef_index[i*vd + j]) {
if(get_bits_count(&q->gb) < q->bits_per_subpacket){
- subband_coef_noise[i*vd+j] = get_bits1(&q->gb);
+ subband_coef_sign[i*vd+j] = get_bits1(&q->gb);
} else {
result=1;
- subband_coef_noise[i*vd+j]=0;
+ subband_coef_sign[i*vd+j]=0;
}
} else {
- subband_coef_noise[i*vd+j]=0;
+ subband_coef_sign[i*vd+j]=0;
}
}
}
@@ -641,41 +598,42 @@ static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index,
*
* @param q pointer to the COOKContext
* @param category pointer to the category array
- * @param quant_value_table pointer to the array
+ * @param quant_index_table pointer to the array
* @param mlt_buffer pointer to mlt coefficients
*/
static void decode_vectors(COOKContext* q, int* category,
- float* quant_value_table, float* mlt_buffer){
+ int *quant_index_table, float* mlt_buffer){
/* A zero in this table means that the subband coefficient is
random noise coded. */
- int subband_coef_noise[SUBBAND_SIZE];
+ int subband_coef_index[SUBBAND_SIZE];
/* A zero in this table means that the subband coefficient is a
positive multiplicator. */
- int subband_coef_index[SUBBAND_SIZE];
+ int subband_coef_sign[SUBBAND_SIZE];
int band, j;
int index=0;
for(band=0 ; band<q->total_subbands ; band++){
index = category[band];
if(category[band] < 7){
- if(unpack_SQVH(q, category[band], subband_coef_index, subband_coef_noise)){
+ if(unpack_SQVH(q, category[band], subband_coef_index, subband_coef_sign)){
index=7;
for(j=0 ; j<q->total_subbands ; j++) category[band+j]=7;
}
}
if(index==7) {
memset(subband_coef_index, 0, sizeof(subband_coef_index));
- memset(subband_coef_noise, 0, sizeof(subband_coef_noise));
+ memset(subband_coef_sign, 0, sizeof(subband_coef_sign));
}
- scalar_dequant(q, index, band, quant_value_table, subband_coef_index,
- subband_coef_noise, mlt_buffer);
+ scalar_dequant(q, index, quant_index_table[band],
+ subband_coef_index, subband_coef_sign,
+ &mlt_buffer[band * 20]);
}
if(q->total_subbands*SUBBAND_SIZE >= q->samples_per_channel){
return;
- }
+ } /* FIXME: should this be removed, or moved into loop above? */
}
@@ -690,69 +648,17 @@ static void decode_vectors(COOKContext* q, int* category,
static void mono_decode(COOKContext *q, float* mlt_buffer) {
int category_index[128];
- float quant_value_table[102];
int quant_index_table[102];
int category[128];
memset(&category, 0, 128*sizeof(int));
- memset(&quant_value_table, 0, 102*sizeof(int));
memset(&category_index, 0, 128*sizeof(int));
decode_envelope(q, quant_index_table);
q->num_vectors = get_bits(&q->gb,q->log2_numvector_size);
- dequant_envelope(q, quant_index_table, quant_value_table);
categorize(q, quant_index_table, category, category_index);
expand_category(q, category, category_index);
- decode_vectors(q, category, quant_value_table, mlt_buffer);
-}
-
-
-/**
- * The modulated lapped transform, this takes transform coefficients
- * and transforms them into timedomain samples. This is done through
- * an FFT-based algorithm with pre- and postrotation steps.
- * A window and reorder step is also included.
- *
- * @param q pointer to the COOKContext
- * @param inbuffer pointer to the mltcoefficients
- * @param outbuffer pointer to the timedomain buffer
- * @param mlt_tmp pointer to temporary storage space
- */
-
-static void cook_imlt(COOKContext *q, float* inbuffer, float* outbuffer,
- float* mlt_tmp){
- int i;
-
- /* prerotation */
- for(i=0 ; i<q->mlt_size ; i+=2){
- outbuffer[i] = (q->mlt_presin[i/2] * inbuffer[q->mlt_size-1-i]) +
- (q->mlt_precos[i/2] * inbuffer[i]);
- outbuffer[i+1] = (q->mlt_precos[i/2] * inbuffer[q->mlt_size-1-i]) -
- (q->mlt_presin[i/2] * inbuffer[i]);
- }
-
- /* FFT */
- ff_fft_permute(&q->fft_ctx, (FFTComplex *) outbuffer);
- ff_fft_calc (&q->fft_ctx, (FFTComplex *) outbuffer);
-
- /* postrotation */
- for(i=0 ; i<q->mlt_size ; i+=2){
- mlt_tmp[i] = (q->mlt_postcos[(q->mlt_size-1-i)/2] * outbuffer[i+1]) +
- (q->mlt_postcos[i/2] * outbuffer[i]);
- mlt_tmp[q->mlt_size-1-i] = (q->mlt_postcos[(q->mlt_size-1-i)/2] * outbuffer[i]) -
- (q->mlt_postcos[i/2] * outbuffer[i+1]);
- }
-
- /* window and reorder */
- for(i=0 ; i<q->mlt_size/2 ; i++){
- outbuffer[i] = mlt_tmp[q->mlt_size/2-1-i] * q->mlt_window[i];
- outbuffer[q->mlt_size-1-i]= mlt_tmp[q->mlt_size/2-1-i] *
- q->mlt_window[q->mlt_size-1-i];
- outbuffer[q->mlt_size+i]= mlt_tmp[q->mlt_size/2+i] *
- q->mlt_window[q->mlt_size-1-i];
- outbuffer[2*q->mlt_size-1-i]= -(mlt_tmp[q->mlt_size/2+i] *
- q->mlt_window[i]);
- }
+ decode_vectors(q, category, quant_index_table, mlt_buffer);
}
@@ -786,81 +692,52 @@ static void interpolate(COOKContext *q, float* buffer,
}
}
-/**
- * timedomain requantization of the timedomain samples
- *
- * @param q pointer to the COOKContext
- * @param buffer pointer to the timedomain buffer
- * @param gain_now current gain structure
- * @param gain_previous previous gain structure
- */
-
-static void gain_window(COOKContext *q, float* buffer, COOKgain* gain_now,
- COOKgain* gain_previous){
- int i, index;
- int gain_index[9];
- int tmp_gain_index;
-
- gain_index[8]=0;
- index = gain_previous->size;
- for (i=7 ; i>=0 ; i--) {
- if(index && gain_previous->qidx_table1[index-1]==i) {
- gain_index[i] = gain_previous->qidx_table2[index-1];
- index--;
- } else {
- gain_index[i]=gain_index[i+1];
- }
- }
- /* This is applied to the to be previous data buffer. */
- for(i=0;i<8;i++){
- interpolate(q, &buffer[q->samples_per_channel+q->gain_size_factor*i],
- gain_index[i], gain_index[i+1]);
- }
-
- tmp_gain_index = gain_index[0];
- index = gain_now->size;
- for (i=7 ; i>=0 ; i--) {
- if(index && gain_now->qidx_table1[index-1]==i) {
- gain_index[i]= gain_now->qidx_table2[index-1];
- index--;
- } else {
- gain_index[i]=gain_index[i+1];
- }
- }
-
- /* This is applied to the to be current block. */
- for(i=0;i<8;i++){
- interpolate(q, &buffer[i*q->gain_size_factor],
- tmp_gain_index+gain_index[i],
- tmp_gain_index+gain_index[i+1]);
- }
-}
-
/**
- * mlt overlapping and buffer management
+ * The modulated lapped transform, this takes transform coefficients
+ * and transforms them into timedomain samples.
+ * Apply transform window, overlap buffers, apply gain profile
+ * and buffer management.
*
* @param q pointer to the COOKContext
- * @param buffer pointer to the timedomain buffer
- * @param gain_now current gain structure
- * @param gain_previous previous gain structure
+ * @param inbuffer pointer to the mltcoefficients
+ * @param gains_ptr current and previous gains
* @param previous_buffer pointer to the previous buffer to be used for overlapping
- *
*/
-static void gain_compensate(COOKContext *q, float* buffer, COOKgain* gain_now,
- COOKgain* gain_previous, float* previous_buffer) {
+static void imlt_gain(COOKContext *q, float *inbuffer,
+ cook_gains *gains_ptr, float* previous_buffer)
+{
+ const float fc = q->pow2tab[gains_ptr->previous[0] + 63];
+ float *buffer0 = q->mono_mdct_output;
+ float *buffer1 = q->mono_mdct_output + q->samples_per_channel;
int i;
- if((gain_now->size || gain_previous->size)) {
- gain_window(q, buffer, gain_now, gain_previous);
+
+ /* Inverse modified discrete cosine transform */
+ q->mdct_ctx.fft.imdct_calc(&q->mdct_ctx, q->mono_mdct_output,
+ inbuffer, q->mdct_tmp);
+
+ /* The weird thing here, is that the two halves of the time domain
+ * buffer are swapped. Also, the newest data, that we save away for
+ * next frame, has the wrong sign. Hence the subtraction below.
+ * Almost sounds like a complex conjugate/reverse data/FFT effect.
+ */
+
+ /* Apply window and overlap */
+ for(i = 0; i < q->samples_per_channel; i++){
+ buffer1[i] = buffer1[i] * fc * q->mlt_window[i] -
+ previous_buffer[i] * q->mlt_window[q->samples_per_channel - 1 - i];
}
- /* Overlap with the previous block. */
- for(i=0 ; i<q->samples_per_channel ; i++) buffer[i]+=previous_buffer[i];
+ /* Apply gain profile */
+ for (i = 0; i < 8; i++) {
+ if (gains_ptr->now[i] || gains_ptr->now[i + 1])
+ interpolate(q, &buffer1[q->gain_size_factor * i],
+ gains_ptr->now[i], gains_ptr->now[i + 1]);
+ }
/* Save away the current to be previous block. */
- memcpy(previous_buffer, buffer+q->samples_per_channel,
- sizeof(float)*q->samples_per_channel);
+ memcpy(previous_buffer, buffer0, sizeof(float)*q->samples_per_channel);
}
@@ -948,6 +825,63 @@ static void joint_decode(COOKContext *q, float* mlt_buffer1,
}
/**
+ * First part of subpacket decoding:
+ * decode raw stream bytes and read gain info.
+ *
+ * @param q pointer to the COOKContext
+ * @param inbuffer pointer to raw stream data
+ * @param gain_ptr array of current/prev gain pointers
+ */
+
+static inline void
+decode_bytes_and_gain(COOKContext *q, uint8_t *inbuffer,
+ cook_gains *gains_ptr)
+{
+ int offset;
+
+ offset = decode_bytes(inbuffer, q->decoded_bytes_buffer,
+ q->bits_per_subpacket/8);
+ init_get_bits(&q->gb, q->decoded_bytes_buffer + offset,
+ q->bits_per_subpacket);
+ decode_gain_info(&q->gb, gains_ptr->now);
+
+ /* Swap current and previous gains */
+ FFSWAP(int *, gains_ptr->now, gains_ptr->previous);
+}
+
+/**
+ * Final part of subpacket decoding:
+ * Apply modulated lapped transform, gain compensation,
+ * clip and convert to integer.
+ *
+ * @param q pointer to the COOKContext
+ * @param decode_buffer pointer to the mlt coefficients
+ * @param gain_ptr array of current/prev gain pointers
+ * @param previous_buffer pointer to the previous buffer to be used for overlapping
+ * @param out pointer to the output buffer
+ * @param chan 0: left or single channel, 1: right channel
+ */
+
+static inline void
+mlt_compensate_output(COOKContext *q, float *decode_buffer,
+ cook_gains *gains, float *previous_buffer,
+ int16_t *out, int chan)
+{
+ float *output = q->mono_mdct_output + q->samples_per_channel;
+ int j;
+
+ imlt_gain(q, decode_buffer, gains, previous_buffer);
+
+ /* Clip and convert floats to 16 bits.
+ */
+ for (j = 0; j < q->samples_per_channel; j++) {
+ out[chan + q->nb_channels * j] =
+ av_clip(lrintf(output[j]), -32768, 32767);
+ }
+}
+
+
+/**
* Cook subpacket decoding. This function returns one decoded subpacket,
* usually 1024 samples per channel.
*
@@ -960,142 +894,36 @@ static void joint_decode(COOKContext *q, float* mlt_buffer1,
static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,
int sub_packet_size, int16_t *outbuffer) {
- int i,j;
- int value;
- float* tmp_ptr;
-
/* packet dump */
// for (i=0 ; i<sub_packet_size ; i++) {
// av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]);
// }
// av_log(NULL, AV_LOG_ERROR, "\n");
- decode_bytes(inbuffer, q->decoded_bytes_buffer, sub_packet_size);
- init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8);
- decode_gain_info(&q->gb, &q->gain_current);
-
- if(q->nb_channels==2 && q->joint_stereo==1){
- joint_decode(q, q->decode_buf_ptr[0], q->decode_buf_ptr[2]);
-
- /* Swap buffer pointers. */
- tmp_ptr = q->decode_buf_ptr[1];
- q->decode_buf_ptr[1] = q->decode_buf_ptr[0];
- q->decode_buf_ptr[0] = tmp_ptr;
- tmp_ptr = q->decode_buf_ptr[3];
- q->decode_buf_ptr[3] = q->decode_buf_ptr[2];
- q->decode_buf_ptr[2] = tmp_ptr;
-
- /* FIXME: Rethink the gainbuffer handling, maybe a rename?
- now/previous swap */
- q->gain_now_ptr = &q->gain_now;
- q->gain_previous_ptr = &q->gain_previous;
- for (i=0 ; i<q->nb_channels ; i++){
-
- cook_imlt(q, q->decode_buf_ptr[i*2], q->mono_mdct_output, q->mlt_tmp);
- gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,
- q->gain_previous_ptr, q->previous_buffer_ptr[0]);
-
- /* Swap out the previous buffer. */
- tmp_ptr = q->previous_buffer_ptr[0];
- q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];
- q->previous_buffer_ptr[1] = tmp_ptr;
-
- /* Clip and convert the floats to 16 bits. */
- for (j=0 ; j<q->samples_per_frame ; j++){
- value = lrintf(q->mono_mdct_output[j]);
- if(value < -32768) value = -32768;
- else if(value > 32767) value = 32767;
- outbuffer[2*j+i] = value;
- }
- }
-
- memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));
- memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));
-
- } else if (q->nb_channels==2 && q->joint_stereo==0) {
- /* channel 0 */
- mono_decode(q, q->decode_buf_ptr2[0]);
-
- tmp_ptr = q->decode_buf_ptr2[0];
- q->decode_buf_ptr2[0] = q->decode_buf_ptr2[1];
- q->decode_buf_ptr2[1] = tmp_ptr;
-
- memcpy(&q->gain_channel1[0], &q->gain_current ,sizeof(COOKgain));
- q->gain_now_ptr = &q->gain_channel1[0];
- q->gain_previous_ptr = &q->gain_channel1[1];
-
- cook_imlt(q, q->decode_buf_ptr2[0], q->mono_mdct_output,q->mlt_tmp);
- gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,
- q->gain_previous_ptr, q->mono_previous_buffer1);
-
- memcpy(&q->gain_channel1[1], &q->gain_channel1[0],sizeof(COOKgain));
-
-
- for (j=0 ; j<q->samples_per_frame ; j++){
- value = lrintf(q->mono_mdct_output[j]);
- if(value < -32768) value = -32768;
- else if(value > 32767) value = 32767;
- outbuffer[2*j+1] = value;
- }
-
- /* channel 1 */
- //av_log(NULL,AV_LOG_ERROR,"bits = %d\n",get_bits_count(&q->gb));
- init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8+q->bits_per_subpacket);
-
- q->gain_now_ptr = &q->gain_channel2[0];
- q->gain_previous_ptr = &q->gain_channel2[1];
+ decode_bytes_and_gain(q, inbuffer, &q->gains1);
- decode_gain_info(&q->gb, &q->gain_channel2[0]);
- mono_decode(q, q->decode_buf_ptr[0]);
-
- tmp_ptr = q->decode_buf_ptr[0];
- q->decode_buf_ptr[0] = q->decode_buf_ptr[1];
- q->decode_buf_ptr[1] = tmp_ptr;
-
- cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);
- gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,
- q->gain_previous_ptr, q->mono_previous_buffer2);
-
- /* Swap out the previous buffer. */
- tmp_ptr = q->previous_buffer_ptr[0];
- q->previous_buffer_ptr[0] = q->previous_buffer_ptr[1];
- q->previous_buffer_ptr[1] = tmp_ptr;
+ if (q->joint_stereo) {
+ joint_decode(q, q->decode_buffer_1, q->decode_buffer_2);
+ } else {
+ mono_decode(q, q->decode_buffer_1);
- memcpy(&q->gain_channel2[1], &q->gain_channel2[0] ,sizeof(COOKgain));
+ if (q->nb_channels == 2) {
+ decode_bytes_and_gain(q, inbuffer + sub_packet_size/2, &q->gains2);
+ mono_decode(q, q->decode_buffer_2);
+ }
+ }
- for (j=0 ; j<q->samples_per_frame ; j++){
- value = lrintf(q->mono_mdct_output[j]);
- if(value < -32768) value = -32768;
- else if(value > 32767) value = 32767;
- outbuffer[2*j] = value;
- }
+ mlt_compensate_output(q, q->decode_buffer_1, &q->gains1,
+ q->mono_previous_buffer1, outbuffer, 0);
- } else {
- mono_decode(q, q->decode_buf_ptr[0]);
-
- /* Swap buffer pointers. */
- tmp_ptr = q->decode_buf_ptr[1];
- q->decode_buf_ptr[1] = q->decode_buf_ptr[0];
- q->decode_buf_ptr[0] = tmp_ptr;
-
- /* FIXME: Rethink the gainbuffer handling, maybe a rename?
- now/previous swap */
- q->gain_now_ptr = &q->gain_now;
- q->gain_previous_ptr = &q->gain_previous;
-
- cook_imlt(q, q->decode_buf_ptr[0], q->mono_mdct_output,q->mlt_tmp);
- gain_compensate(q, q->mono_mdct_output, q->gain_now_ptr,
- q->gain_previous_ptr, q->mono_previous_buffer1);
-
- /* Clip and convert the floats to 16 bits */
- for (j=0 ; j<q->samples_per_frame ; j++){
- value = lrintf(q->mono_mdct_output[j]);
- if(value < -32768) value = -32768;
- else if(value > 32767) value = 32767;
- outbuffer[j] = value;
+ if (q->nb_channels == 2) {
+ if (q->joint_stereo) {
+ mlt_compensate_output(q, q->decode_buffer_2, &q->gains1,
+ q->mono_previous_buffer2, outbuffer, 1);
+ } else {
+ mlt_compensate_output(q, q->decode_buffer_2, &q->gains2,
+ q->mono_previous_buffer2, outbuffer, 1);
}
- memcpy(&q->gain_now, &q->gain_previous, sizeof(COOKgain));
- memcpy(&q->gain_previous, &q->gain_current, sizeof(COOKgain));
}
return q->samples_per_frame * sizeof(int16_t);
}
@@ -1117,19 +945,22 @@ static int cook_decode_frame(AVCodecContext *avctx,
*data_size = decode_subpacket(q, buf, avctx->block_align, data);
+ /* Discard the first two frames: no valid audio. */
+ if (avctx->frame_number < 2) *data_size = 0;
+
return avctx->block_align;
}
#ifdef COOKDEBUG
-static void dump_cook_context(COOKContext *q, COOKextradata *e)
+static void dump_cook_context(COOKContext *q)
{
//int i=0;
#define PRINT(a,b) av_log(NULL,AV_LOG_ERROR," %s = %d\n", a, b);
av_log(NULL,AV_LOG_ERROR,"COOKextradata\n");
- av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",e->cookversion);
- if (e->cookversion > MONO_COOK2) {
- PRINT("js_subband_start",e->js_subband_start);
- PRINT("js_vlc_bits",e->js_vlc_bits);
+ av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion);
+ if (q->cookversion > STEREO) {
+ PRINT("js_subband_start",q->js_subband_start);
+ PRINT("js_vlc_bits",q->js_vlc_bits);
}
av_log(NULL,AV_LOG_ERROR,"COOKContext\n");
PRINT("nb_channels",q->nb_channels);
@@ -1139,7 +970,6 @@ static void dump_cook_context(COOKContext *q, COOKextradata *e)
PRINT("samples_per_frame",q->samples_per_frame);
PRINT("subbands",q->subbands);
PRINT("random_state",q->random_state);
- PRINT("mlt_size",q->mlt_size);
PRINT("js_subband_start",q->js_subband_start);
PRINT("log2_numvector_size",q->log2_numvector_size);
PRINT("numvector_size",q->numvector_size);
@@ -1155,25 +985,26 @@ static void dump_cook_context(COOKContext *q, COOKextradata *e)
static int cook_decode_init(AVCodecContext *avctx)
{
- COOKextradata *e = avctx->extradata;
COOKContext *q = avctx->priv_data;
+ uint8_t *edata_ptr = avctx->extradata;
/* Take care of the codec specific extradata. */
if (avctx->extradata_size <= 0) {
- av_log(NULL,AV_LOG_ERROR,"Necessary extradata missing!\n");
+ av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n");
return -1;
} else {
/* 8 for mono, 16 for stereo, ? for multichannel
Swap to right endianness so we don't need to care later on. */
- av_log(NULL,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size);
+ av_log(avctx,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size);
if (avctx->extradata_size >= 8){
- e->cookversion = be2me_32(e->cookversion);
- e->samples_per_frame = be2me_16(e->samples_per_frame);
- e->subbands = be2me_16(e->subbands);
+ q->cookversion = bytestream_get_be32(&edata_ptr);
+ q->samples_per_frame = bytestream_get_be16(&edata_ptr);
+ q->subbands = bytestream_get_be16(&edata_ptr);
}
if (avctx->extradata_size >= 16){
- e->js_subband_start = be2me_16(e->js_subband_start);
- e->js_vlc_bits = be2me_16(e->js_vlc_bits);
+ bytestream_get_be32(&edata_ptr); //Unknown unused
+ q->js_subband_start = bytestream_get_be16(&edata_ptr);
+ q->js_vlc_bits = bytestream_get_be16(&edata_ptr);
}
}
@@ -1182,48 +1013,43 @@ static int cook_decode_init(AVCodecContext *avctx)
q->nb_channels = avctx->channels;
q->bit_rate = avctx->bit_rate;
- /* Initialize state. */
- q->random_state = 1;
+ /* Initialize RNG. */
+ av_init_random(1, &q->random_state);
/* Initialize extradata related variables. */
- q->samples_per_channel = e->samples_per_frame / q->nb_channels;
- q->samples_per_frame = e->samples_per_frame;
- q->subbands = e->subbands;
+ q->samples_per_channel = q->samples_per_frame / q->nb_channels;
q->bits_per_subpacket = avctx->block_align * 8;
/* Initialize default data states. */
- q->js_subband_start = 0;
q->log2_numvector_size = 5;
q->total_subbands = q->subbands;
/* Initialize version-dependent variables */
- av_log(NULL,AV_LOG_DEBUG,"e->cookversion=%x\n",e->cookversion);
- switch (e->cookversion) {
- case MONO_COOK1:
+ av_log(NULL,AV_LOG_DEBUG,"q->cookversion=%x\n",q->cookversion);
+ q->joint_stereo = 0;
+ switch (q->cookversion) {
+ case MONO:
if (q->nb_channels != 1) {
- av_log(NULL,AV_LOG_ERROR,"Container channels != 1, report sample!\n");
+ av_log(avctx,AV_LOG_ERROR,"Container channels != 1, report sample!\n");
return -1;
}
- av_log(NULL,AV_LOG_DEBUG,"MONO_COOK1\n");
+ av_log(avctx,AV_LOG_DEBUG,"MONO\n");
break;
- case MONO_COOK2:
+ case STEREO:
if (q->nb_channels != 1) {
- q->joint_stereo = 0;
q->bits_per_subpacket = q->bits_per_subpacket/2;
}
- av_log(NULL,AV_LOG_DEBUG,"MONO_COOK2\n");
+ av_log(avctx,AV_LOG_DEBUG,"STEREO\n");
break;
case JOINT_STEREO:
if (q->nb_channels != 2) {
- av_log(NULL,AV_LOG_ERROR,"Container channels != 2, report sample!\n");
+ av_log(avctx,AV_LOG_ERROR,"Container channels != 2, report sample!\n");
return -1;
}
- av_log(NULL,AV_LOG_DEBUG,"JOINT_STEREO\n");
+ av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n");
if (avctx->extradata_size >= 16){
- q->total_subbands = q->subbands + e->js_subband_start;
- q->js_subband_start = e->js_subband_start;
+ q->total_subbands = q->subbands + q->js_subband_start;
q->joint_stereo = 1;
- q->js_vlc_bits = e->js_vlc_bits;
}
if (q->samples_per_channel > 256) {
q->log2_numvector_size = 6;
@@ -1233,17 +1059,16 @@ static int cook_decode_init(AVCodecContext *avctx)
}
break;
case MC_COOK:
- av_log(NULL,AV_LOG_ERROR,"MC_COOK not supported!\n");
+ av_log(avctx,AV_LOG_ERROR,"MC_COOK not supported!\n");
return -1;
break;
default:
- av_log(NULL,AV_LOG_ERROR,"Unknown Cook version, report sample!\n");
+ av_log(avctx,AV_LOG_ERROR,"Unknown Cook version, report sample!\n");
return -1;
break;
}
/* Initialize variable relations */
- q->mlt_size = q->samples_per_channel;
q->numvector_size = (1 << q->log2_numvector_size);
/* Generate tables */
@@ -1258,43 +1083,53 @@ static int cook_decode_init(AVCodecContext *avctx)
if(avctx->block_align >= UINT_MAX/2)
return -1;
- /* Pad the databuffer with FF_INPUT_BUFFER_PADDING_SIZE,
- this is for the bitstreamreader. */
- if ((q->decoded_bytes_buffer = av_mallocz((avctx->block_align+(4-avctx->block_align%4) + FF_INPUT_BUFFER_PADDING_SIZE)*sizeof(uint8_t))) == NULL)
+ /* Pad the databuffer with:
+ DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(),
+ FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */
+ if (q->nb_channels==2 && q->joint_stereo==0) {
+ q->decoded_bytes_buffer =
+ av_mallocz(avctx->block_align/2
+ + DECODE_BYTES_PAD2(avctx->block_align/2)
+ + FF_INPUT_BUFFER_PADDING_SIZE);
+ } else {
+ q->decoded_bytes_buffer =
+ av_mallocz(avctx->block_align
+ + DECODE_BYTES_PAD1(avctx->block_align)
+ + FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+ if (q->decoded_bytes_buffer == NULL)
return -1;
- q->decode_buf_ptr[0] = q->decode_buffer_1;
- q->decode_buf_ptr[1] = q->decode_buffer_2;
- q->decode_buf_ptr[2] = q->decode_buffer_3;
- q->decode_buf_ptr[3] = q->decode_buffer_4;
-
- q->decode_buf_ptr2[0] = q->decode_buffer_3;
- q->decode_buf_ptr2[1] = q->decode_buffer_4;
-
- q->previous_buffer_ptr[0] = q->mono_previous_buffer1;
- q->previous_buffer_ptr[1] = q->mono_previous_buffer2;
+ q->gains1.now = q->gain_1;
+ q->gains1.previous = q->gain_2;
+ q->gains2.now = q->gain_3;
+ q->gains2.previous = q->gain_4;
/* Initialize transform. */
- if ( init_cook_mlt(q) == 0 )
+ if ( init_cook_mlt(q) != 0 )
return -1;
/* Try to catch some obviously faulty streams, othervise it might be exploitable */
if (q->total_subbands > 53) {
- av_log(NULL,AV_LOG_ERROR,"total_subbands > 53, report sample!\n");
+ av_log(avctx,AV_LOG_ERROR,"total_subbands > 53, report sample!\n");
return -1;
}
if (q->subbands > 50) {
- av_log(NULL,AV_LOG_ERROR,"subbands > 50, report sample!\n");
+ av_log(avctx,AV_LOG_ERROR,"subbands > 50, report sample!\n");
return -1;
}
if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) {
} else {
- av_log(NULL,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel);
+ av_log(avctx,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel);
+ return -1;
+ }
+ if ((q->js_vlc_bits > 6) || (q->js_vlc_bits < 0)) {
+ av_log(avctx,AV_LOG_ERROR,"q->js_vlc_bits = %d, only >= 0 and <= 6 allowed!\n",q->js_vlc_bits);
return -1;
}
#ifdef COOKDEBUG
- dump_cook_context(q,e);
+ dump_cook_context(q);
#endif
return 0;
}
diff --git a/contrib/ffmpeg/libavcodec/cscd.c b/contrib/ffmpeg/libavcodec/cscd.c
index e4257f4c0..2e7d05c40 100644
--- a/contrib/ffmpeg/libavcodec/cscd.c
+++ b/contrib/ffmpeg/libavcodec/cscd.c
@@ -220,12 +220,12 @@ static int decode_init(AVCodecContext *avctx) {
}
avctx->has_b_frames = 0;
switch (avctx->bits_per_sample) {
- case 16: avctx->pix_fmt = PIX_FMT_RGB565; break;
+ case 16: avctx->pix_fmt = PIX_FMT_RGB555; break;
case 24: avctx->pix_fmt = PIX_FMT_BGR24; break;
- case 32: avctx->pix_fmt = PIX_FMT_RGBA32; break;
+ case 32: avctx->pix_fmt = PIX_FMT_RGB32; break;
default:
av_log(avctx, AV_LOG_ERROR,
- "CamStudio codec error: unvalid depth %i bpp\n",
+ "CamStudio codec error: invalid depth %i bpp\n",
avctx->bits_per_sample);
return 1;
}
diff --git a/contrib/ffmpeg/libavcodec/dca.c b/contrib/ffmpeg/libavcodec/dca.c
new file mode 100644
index 000000000..a57dcdc44
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/dca.c
@@ -0,0 +1,1322 @@
+/*
+ * DCA compatible decoder
+ * Copyright (C) 2004 Gildas Bazin
+ * Copyright (C) 2004 Benjamin Zores
+ * Copyright (C) 2006 Benjamin Larsson
+ * Copyright (C) 2007 Konstantin Shishkov
+ *
+ * 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 dca.c
+ */
+
+#include <math.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include "avcodec.h"
+#include "dsputil.h"
+#include "bitstream.h"
+#include "dcadata.h"
+#include "dcahuff.h"
+#include "parser.h"
+
+/** DCA syncwords, also used for bitstream type detection */
+//@{
+#define DCA_MARKER_RAW_BE 0x7FFE8001
+#define DCA_MARKER_RAW_LE 0xFE7F0180
+#define DCA_MARKER_14B_BE 0x1FFFE800
+#define DCA_MARKER_14B_LE 0xFF1F00E8
+//@}
+
+//#define TRACE
+
+#define DCA_PRIM_CHANNELS_MAX (5)
+#define DCA_SUBBANDS (32)
+#define DCA_ABITS_MAX (32) /* Should be 28 */
+#define DCA_SUBSUBFAMES_MAX (4)
+#define DCA_LFE_MAX (3)
+
+enum DCAMode {
+ DCA_MONO = 0,
+ DCA_CHANNEL,
+ DCA_STEREO,
+ DCA_STEREO_SUMDIFF,
+ DCA_STEREO_TOTAL,
+ DCA_3F,
+ DCA_2F1R,
+ DCA_3F1R,
+ DCA_2F2R,
+ DCA_3F2R,
+ DCA_4F2R
+};
+
+#define DCA_DOLBY 101 /* FIXME */
+
+#define DCA_CHANNEL_BITS 6
+#define DCA_CHANNEL_MASK 0x3F
+
+#define DCA_LFE 0x80
+
+#define HEADER_SIZE 14
+#define CONVERT_BIAS 384
+
+#define DCA_MAX_FRAME_SIZE 16383
+
+/** Bit allocation */
+typedef struct {
+ int offset; ///< code values offset
+ int maxbits[8]; ///< max bits in VLC
+ int wrap; ///< wrap for get_vlc2()
+ VLC vlc[8]; ///< actual codes
+} BitAlloc;
+
+static BitAlloc dca_bitalloc_index; ///< indexes for samples VLC select
+static BitAlloc dca_tmode; ///< transition mode VLCs
+static BitAlloc dca_scalefactor; ///< scalefactor VLCs
+static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs
+
+/** Pre-calculated cosine modulation coefs for the QMF */
+static float cos_mod[544];
+
+static int av_always_inline get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx)
+{
+ return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + ba->offset;
+}
+
+typedef struct {
+ AVCodecContext *avctx;
+ /* Frame header */
+ int frame_type; ///< type of the current frame
+ int samples_deficit; ///< deficit sample count
+ int crc_present; ///< crc is present in the bitstream
+ int sample_blocks; ///< number of PCM sample blocks
+ int frame_size; ///< primary frame byte size
+ int amode; ///< audio channels arrangement
+ int sample_rate; ///< audio sampling rate
+ int bit_rate; ///< transmission bit rate
+
+ int downmix; ///< embedded downmix enabled
+ int dynrange; ///< embedded dynamic range flag
+ int timestamp; ///< embedded time stamp flag
+ int aux_data; ///< auxiliary data flag
+ int hdcd; ///< source material is mastered in HDCD
+ int ext_descr; ///< extension audio descriptor flag
+ int ext_coding; ///< extended coding flag
+ int aspf; ///< audio sync word insertion flag
+ int lfe; ///< low frequency effects flag
+ int predictor_history; ///< predictor history flag
+ int header_crc; ///< header crc check bytes
+ int multirate_inter; ///< multirate interpolator switch
+ int version; ///< encoder software revision
+ int copy_history; ///< copy history
+ int source_pcm_res; ///< source pcm resolution
+ int front_sum; ///< front sum/difference flag
+ int surround_sum; ///< surround sum/difference flag
+ int dialog_norm; ///< dialog normalisation parameter
+
+ /* Primary audio coding header */
+ int subframes; ///< number of subframes
+ int prim_channels; ///< number of primary audio channels
+ int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count
+ int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband
+ int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index
+ int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book
+ int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book
+ int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select
+ int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select
+ float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment
+
+ /* Primary audio coding side information */
+ int subsubframes; ///< number of subsubframes
+ int partial_samples; ///< partial subsubframe samples count
+ int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not)
+ int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs
+ int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index
+ int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< transition mode (transients)
+ int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]; ///< scale factors (2 if transient)
+ int joint_huff[DCA_PRIM_CHANNELS_MAX]; ///< joint subband scale factors codebook
+ int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< joint subband scale factors
+ int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]; ///< stereo downmix coefficients
+ int dynrange_coef; ///< dynamic range coefficient
+
+ int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands
+
+ float lfe_data[2 * DCA_SUBSUBFAMES_MAX * DCA_LFE_MAX *
+ 2 /*history */ ]; ///< Low frequency effect data
+ int lfe_scale_factor;
+
+ /* Subband samples history (for ADPCM) */
+ float subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4];
+ float subband_fir_hist[DCA_PRIM_CHANNELS_MAX][512];
+ float subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][64];
+
+ int output; ///< type of output
+ int bias; ///< output bias
+
+ DECLARE_ALIGNED_16(float, samples[1536]); /* 6 * 256 = 1536, might only need 5 */
+ DECLARE_ALIGNED_16(int16_t, tsamples[1536]);
+
+ uint8_t dca_buffer[DCA_MAX_FRAME_SIZE];
+ int dca_buffer_size; ///< how much data is in the dca_buffer
+
+ GetBitContext gb;
+ /* Current position in DCA frame */
+ int current_subframe;
+ int current_subsubframe;
+
+ int debug_flag; ///< used for suppressing repeated error messages output
+ DSPContext dsp;
+} DCAContext;
+
+static void dca_init_vlcs()
+{
+ static int vlcs_inited = 0;
+ int i, j;
+
+ if (vlcs_inited)
+ return;
+
+ dca_bitalloc_index.offset = 1;
+ dca_bitalloc_index.wrap = 1;
+ for (i = 0; i < 5; i++)
+ init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12,
+ bitalloc_12_bits[i], 1, 1,
+ bitalloc_12_codes[i], 2, 2, 1);
+ dca_scalefactor.offset = -64;
+ dca_scalefactor.wrap = 2;
+ for (i = 0; i < 5; i++)
+ init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129,
+ scales_bits[i], 1, 1,
+ scales_codes[i], 2, 2, 1);
+ dca_tmode.offset = 0;
+ dca_tmode.wrap = 1;
+ for (i = 0; i < 4; i++)
+ init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4,
+ tmode_bits[i], 1, 1,
+ tmode_codes[i], 2, 2, 1);
+
+ for(i = 0; i < 10; i++)
+ for(j = 0; j < 7; j++){
+ if(!bitalloc_codes[i][j]) break;
+ dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i];
+ dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4);
+ init_vlc(&dca_smpl_bitalloc[i+1].vlc[j], bitalloc_maxbits[i][j],
+ bitalloc_sizes[i],
+ bitalloc_bits[i][j], 1, 1,
+ bitalloc_codes[i][j], 2, 2, 1);
+ }
+ vlcs_inited = 1;
+}
+
+static inline void get_array(GetBitContext *gb, int *dst, int len, int bits)
+{
+ while(len--)
+ *dst++ = get_bits(gb, bits);
+}
+
+static int dca_parse_frame_header(DCAContext * s)
+{
+ int i, j;
+ static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
+ static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
+ static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
+
+ s->bias = CONVERT_BIAS;
+
+ init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
+
+ /* Sync code */
+ get_bits(&s->gb, 32);
+
+ /* Frame header */
+ s->frame_type = get_bits(&s->gb, 1);
+ s->samples_deficit = get_bits(&s->gb, 5) + 1;
+ s->crc_present = get_bits(&s->gb, 1);
+ s->sample_blocks = get_bits(&s->gb, 7) + 1;
+ s->frame_size = get_bits(&s->gb, 14) + 1;
+ if (s->frame_size < 95)
+ return -1;
+ s->amode = get_bits(&s->gb, 6);
+ s->sample_rate = dca_sample_rates[get_bits(&s->gb, 4)];
+ if (!s->sample_rate)
+ return -1;
+ s->bit_rate = dca_bit_rates[get_bits(&s->gb, 5)];
+ if (!s->bit_rate)
+ return -1;
+
+ s->downmix = get_bits(&s->gb, 1);
+ s->dynrange = get_bits(&s->gb, 1);
+ s->timestamp = get_bits(&s->gb, 1);
+ s->aux_data = get_bits(&s->gb, 1);
+ s->hdcd = get_bits(&s->gb, 1);
+ s->ext_descr = get_bits(&s->gb, 3);
+ s->ext_coding = get_bits(&s->gb, 1);
+ s->aspf = get_bits(&s->gb, 1);
+ s->lfe = get_bits(&s->gb, 2);
+ s->predictor_history = get_bits(&s->gb, 1);
+
+ /* TODO: check CRC */
+ if (s->crc_present)
+ s->header_crc = get_bits(&s->gb, 16);
+
+ s->multirate_inter = get_bits(&s->gb, 1);
+ s->version = get_bits(&s->gb, 4);
+ s->copy_history = get_bits(&s->gb, 2);
+ s->source_pcm_res = get_bits(&s->gb, 3);
+ s->front_sum = get_bits(&s->gb, 1);
+ s->surround_sum = get_bits(&s->gb, 1);
+ s->dialog_norm = get_bits(&s->gb, 4);
+
+ /* FIXME: channels mixing levels */
+ s->output = DCA_STEREO;
+
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type);
+ av_log(s->avctx, AV_LOG_DEBUG, "samples deficit: %i\n", s->samples_deficit);
+ av_log(s->avctx, AV_LOG_DEBUG, "crc present: %i\n", s->crc_present);
+ av_log(s->avctx, AV_LOG_DEBUG, "sample blocks: %i (%i samples)\n",
+ s->sample_blocks, s->sample_blocks * 32);
+ av_log(s->avctx, AV_LOG_DEBUG, "frame size: %i bytes\n", s->frame_size);
+ av_log(s->avctx, AV_LOG_DEBUG, "amode: %i (%i channels)\n",
+ s->amode, dca_channels[s->amode]);
+ av_log(s->avctx, AV_LOG_DEBUG, "sample rate: %i (%i Hz)\n",
+ s->sample_rate, dca_sample_rates[s->sample_rate]);
+ av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i (%i bits/s)\n",
+ s->bit_rate, dca_bit_rates[s->bit_rate]);
+ av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix);
+ av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange);
+ av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp);
+ av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data);
+ av_log(s->avctx, AV_LOG_DEBUG, "hdcd: %i\n", s->hdcd);
+ av_log(s->avctx, AV_LOG_DEBUG, "ext descr: %i\n", s->ext_descr);
+ av_log(s->avctx, AV_LOG_DEBUG, "ext coding: %i\n", s->ext_coding);
+ av_log(s->avctx, AV_LOG_DEBUG, "aspf: %i\n", s->aspf);
+ av_log(s->avctx, AV_LOG_DEBUG, "lfe: %i\n", s->lfe);
+ av_log(s->avctx, AV_LOG_DEBUG, "predictor history: %i\n",
+ s->predictor_history);
+ av_log(s->avctx, AV_LOG_DEBUG, "header crc: %i\n", s->header_crc);
+ av_log(s->avctx, AV_LOG_DEBUG, "multirate inter: %i\n",
+ s->multirate_inter);
+ av_log(s->avctx, AV_LOG_DEBUG, "version number: %i\n", s->version);
+ av_log(s->avctx, AV_LOG_DEBUG, "copy history: %i\n", s->copy_history);
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "source pcm resolution: %i (%i bits/sample)\n",
+ s->source_pcm_res, dca_bits_per_sample[s->source_pcm_res]);
+ av_log(s->avctx, AV_LOG_DEBUG, "front sum: %i\n", s->front_sum);
+ av_log(s->avctx, AV_LOG_DEBUG, "surround sum: %i\n", s->surround_sum);
+ av_log(s->avctx, AV_LOG_DEBUG, "dialog norm: %i\n", s->dialog_norm);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+#endif
+
+ /* Primary audio coding header */
+ s->subframes = get_bits(&s->gb, 4) + 1;
+ s->prim_channels = get_bits(&s->gb, 3) + 1;
+
+
+ for (i = 0; i < s->prim_channels; i++) {
+ s->subband_activity[i] = get_bits(&s->gb, 5) + 2;
+ if (s->subband_activity[i] > DCA_SUBBANDS)
+ s->subband_activity[i] = DCA_SUBBANDS;
+ }
+ for (i = 0; i < s->prim_channels; i++) {
+ s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1;
+ if (s->vq_start_subband[i] > DCA_SUBBANDS)
+ s->vq_start_subband[i] = DCA_SUBBANDS;
+ }
+ get_array(&s->gb, s->joint_intensity, s->prim_channels, 3);
+ get_array(&s->gb, s->transient_huffman, s->prim_channels, 2);
+ get_array(&s->gb, s->scalefactor_huffman, s->prim_channels, 3);
+ get_array(&s->gb, s->bitalloc_huffman, s->prim_channels, 3);
+
+ /* Get codebooks quantization indexes */
+ memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman));
+ for (j = 1; j < 11; j++)
+ for (i = 0; i < s->prim_channels; i++)
+ s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]);
+
+ /* Get scale factor adjustment */
+ for (j = 0; j < 11; j++)
+ for (i = 0; i < s->prim_channels; i++)
+ s->scalefactor_adj[i][j] = 1;
+
+ for (j = 1; j < 11; j++)
+ for (i = 0; i < s->prim_channels; i++)
+ if (s->quant_index_huffman[i][j] < thr[j])
+ s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)];
+
+ if (s->crc_present) {
+ /* Audio header CRC check */
+ get_bits(&s->gb, 16);
+ }
+
+ s->current_subframe = 0;
+ s->current_subsubframe = 0;
+
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes);
+ av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels);
+ for(i = 0; i < s->prim_channels; i++){
+ av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");
+ for (j = 0; j < 11; j++)
+ av_log(s->avctx, AV_LOG_DEBUG, " %i",
+ s->quant_index_huffman[i][j]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");
+ for (j = 0; j < 11; j++)
+ av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+#endif
+
+ return 0;
+}
+
+
+static inline int get_scale(GetBitContext *gb, int level, int index, int value)
+{
+ if (level < 5) {
+ /* huffman encoded */
+ value += get_bitalloc(gb, &dca_scalefactor, index);
+ } else if(level < 8)
+ value = get_bits(gb, level + 1);
+ return value;
+}
+
+static int dca_subframe_header(DCAContext * s)
+{
+ /* Primary audio coding side information */
+ int j, k;
+
+ s->subsubframes = get_bits(&s->gb, 2) + 1;
+ s->partial_samples = get_bits(&s->gb, 3);
+ for (j = 0; j < s->prim_channels; j++) {
+ for (k = 0; k < s->subband_activity[j]; k++)
+ s->prediction_mode[j][k] = get_bits(&s->gb, 1);
+ }
+
+ /* Get prediction codebook */
+ for (j = 0; j < s->prim_channels; j++) {
+ for (k = 0; k < s->subband_activity[j]; k++) {
+ if (s->prediction_mode[j][k] > 0) {
+ /* (Prediction coefficient VQ address) */
+ s->prediction_vq[j][k] = get_bits(&s->gb, 12);
+ }
+ }
+ }
+
+ /* Bit allocation index */
+ for (j = 0; j < s->prim_channels; j++) {
+ for (k = 0; k < s->vq_start_subband[j]; k++) {
+ if (s->bitalloc_huffman[j] == 6)
+ s->bitalloc[j][k] = get_bits(&s->gb, 5);
+ else if (s->bitalloc_huffman[j] == 5)
+ s->bitalloc[j][k] = get_bits(&s->gb, 4);
+ else {
+ s->bitalloc[j][k] =
+ get_bitalloc(&s->gb, &dca_bitalloc_index, j);
+ }
+
+ if (s->bitalloc[j][k] > 26) {
+// av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n",
+// j, k, s->bitalloc[j][k]);
+ return -1;
+ }
+ }
+ }
+
+ /* Transition mode */
+ for (j = 0; j < s->prim_channels; j++) {
+ for (k = 0; k < s->subband_activity[j]; k++) {
+ s->transition_mode[j][k] = 0;
+ if (s->subsubframes > 1 &&
+ k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {
+ s->transition_mode[j][k] =
+ get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);
+ }
+ }
+ }
+
+ for (j = 0; j < s->prim_channels; j++) {
+ uint32_t *scale_table;
+ int scale_sum;
+
+ memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
+
+ if (s->scalefactor_huffman[j] == 6)
+ scale_table = (uint32_t *) scale_factor_quant7;
+ else
+ scale_table = (uint32_t *) scale_factor_quant6;
+
+ /* When huffman coded, only the difference is encoded */
+ scale_sum = 0;
+
+ for (k = 0; k < s->subband_activity[j]; k++) {
+ if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {
+ scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], j, scale_sum);
+ s->scale_factor[j][k][0] = scale_table[scale_sum];
+ }
+
+ if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {
+ /* Get second scale factor */
+ scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], j, scale_sum);
+ s->scale_factor[j][k][1] = scale_table[scale_sum];
+ }
+ }
+ }
+
+ /* Joint subband scale factor codebook select */
+ for (j = 0; j < s->prim_channels; j++) {
+ /* Transmitted only if joint subband coding enabled */
+ if (s->joint_intensity[j] > 0)
+ s->joint_huff[j] = get_bits(&s->gb, 3);
+ }
+
+ /* Scale factors for joint subband coding */
+ for (j = 0; j < s->prim_channels; j++) {
+ int source_channel;
+
+ /* Transmitted only if joint subband coding enabled */
+ if (s->joint_intensity[j] > 0) {
+ int scale = 0;
+ source_channel = s->joint_intensity[j] - 1;
+
+ /* When huffman coded, only the difference is encoded
+ * (is this valid as well for joint scales ???) */
+
+ for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
+ scale = get_scale(&s->gb, s->joint_huff[j], j, 0);
+ scale += 64; /* bias */
+ s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */
+ }
+
+ if (!s->debug_flag & 0x02) {
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "Joint stereo coding not supported\n");
+ s->debug_flag |= 0x02;
+ }
+ }
+ }
+
+ /* Stereo downmix coefficients */
+ if (s->prim_channels > 2 && s->downmix) {
+ for (j = 0; j < s->prim_channels; j++) {
+ s->downmix_coef[j][0] = get_bits(&s->gb, 7);
+ s->downmix_coef[j][1] = get_bits(&s->gb, 7);
+ }
+ }
+
+ /* Dynamic range coefficient */
+ if (s->dynrange)
+ s->dynrange_coef = get_bits(&s->gb, 8);
+
+ /* Side information CRC check word */
+ if (s->crc_present) {
+ get_bits(&s->gb, 16);
+ }
+
+ /*
+ * Primary audio data arrays
+ */
+
+ /* VQ encoded high frequency subbands */
+ for (j = 0; j < s->prim_channels; j++)
+ for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
+ /* 1 vector -> 32 samples */
+ s->high_freq_vq[j][k] = get_bits(&s->gb, 10);
+
+ /* Low frequency effect data */
+ if (s->lfe) {
+ /* LFE samples */
+ int lfe_samples = 2 * s->lfe * s->subsubframes;
+ float lfe_scale;
+
+ for (j = lfe_samples; j < lfe_samples * 2; j++) {
+ /* Signed 8 bits int */
+ s->lfe_data[j] = get_sbits(&s->gb, 8);
+ }
+
+ /* Scale factor index */
+ s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)];
+
+ /* Quantization step size * scale factor */
+ lfe_scale = 0.035 * s->lfe_scale_factor;
+
+ for (j = lfe_samples; j < lfe_samples * 2; j++)
+ s->lfe_data[j] *= lfe_scale;
+ }
+
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes);
+ av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
+ s->partial_samples);
+ for (j = 0; j < s->prim_channels; j++) {
+ av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
+ for (k = 0; k < s->subband_activity[j]; k++)
+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+ for (j = 0; j < s->prim_channels; j++) {
+ for (k = 0; k < s->subband_activity[j]; k++)
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "prediction coefs: %f, %f, %f, %f\n",
+ (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
+ (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
+ (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
+ (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
+ }
+ for (j = 0; j < s->prim_channels; j++) {
+ av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");
+ for (k = 0; k < s->vq_start_subband[j]; k++)
+ av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+ for (j = 0; j < s->prim_channels; j++) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");
+ for (k = 0; k < s->subband_activity[j]; k++)
+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+ for (j = 0; j < s->prim_channels; j++) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");
+ for (k = 0; k < s->subband_activity[j]; k++) {
+ if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)
+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);
+ if (k < s->vq_start_subband[j] && s->transition_mode[j][k])
+ av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);
+ }
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+ for (j = 0; j < s->prim_channels; j++) {
+ if (s->joint_intensity[j] > 0) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
+ for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)
+ av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+ }
+ if (s->prim_channels > 2 && s->downmix) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
+ for (j = 0; j < s->prim_channels; j++) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]);
+ av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]);
+ }
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+ for (j = 0; j < s->prim_channels; j++)
+ for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
+ av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]);
+ if(s->lfe){
+ av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n");
+ for (j = lfe_samples; j < lfe_samples * 2; j++)
+ av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);
+ av_log(s->avctx, AV_LOG_DEBUG, "\n");
+ }
+#endif
+
+ return 0;
+}
+
+static void qmf_32_subbands(DCAContext * s, int chans,
+ float samples_in[32][8], float *samples_out,
+ float scale, float bias)
+{
+ float *prCoeff;
+ int i, j, k;
+ float praXin[33], *raXin = &praXin[1];
+
+ float *subband_fir_hist = s->subband_fir_hist[chans];
+ float *subband_fir_hist2 = s->subband_fir_noidea[chans];
+
+ int chindex = 0, subindex;
+
+ praXin[0] = 0.0;
+
+ /* Select filter */
+ if (!s->multirate_inter) /* Non-perfect reconstruction */
+ prCoeff = (float *) fir_32bands_nonperfect;
+ else /* Perfect reconstruction */
+ prCoeff = (float *) fir_32bands_perfect;
+
+ /* Reconstructed channel sample index */
+ for (subindex = 0; subindex < 8; subindex++) {
+ float t1, t2, sum[16], diff[16];
+
+ /* Load in one sample from each subband and clear inactive subbands */
+ for (i = 0; i < s->subband_activity[chans]; i++)
+ raXin[i] = samples_in[i][subindex];
+ for (; i < 32; i++)
+ raXin[i] = 0.0;
+
+ /* Multiply by cosine modulation coefficients and
+ * create temporary arrays SUM and DIFF */
+ for (j = 0, k = 0; k < 16; k++) {
+ t1 = 0.0;
+ t2 = 0.0;
+ for (i = 0; i < 16; i++, j++){
+ t1 += (raXin[2 * i] + raXin[2 * i + 1]) * cos_mod[j];
+ t2 += (raXin[2 * i] + raXin[2 * i - 1]) * cos_mod[j + 256];
+ }
+ sum[k] = t1 + t2;
+ diff[k] = t1 - t2;
+ }
+
+ j = 512;
+ /* Store history */
+ for (k = 0; k < 16; k++)
+ subband_fir_hist[k] = cos_mod[j++] * sum[k];
+ for (k = 0; k < 16; k++)
+ subband_fir_hist[32-k-1] = cos_mod[j++] * diff[k];
+
+ /* Multiply by filter coefficients */
+ for (k = 31, i = 0; i < 32; i++, k--)
+ for (j = 0; j < 512; j += 64){
+ subband_fir_hist2[i] += prCoeff[i+j] * ( subband_fir_hist[i+j] - subband_fir_hist[j+k]);
+ subband_fir_hist2[i+32] += prCoeff[i+j+32]*(-subband_fir_hist[i+j] - subband_fir_hist[j+k]);
+ }
+
+ /* Create 32 PCM output samples */
+ for (i = 0; i < 32; i++)
+ samples_out[chindex++] = subband_fir_hist2[i] * scale + bias;
+
+ /* Update working arrays */
+ memmove(&subband_fir_hist[32], &subband_fir_hist[0], (512 - 32) * sizeof(float));
+ memmove(&subband_fir_hist2[0], &subband_fir_hist2[32], 32 * sizeof(float));
+ memset(&subband_fir_hist2[32], 0, 32 * sizeof(float));
+ }
+}
+
+static void lfe_interpolation_fir(int decimation_select,
+ int num_deci_sample, float *samples_in,
+ float *samples_out, float scale,
+ float bias)
+{
+ /* samples_in: An array holding decimated samples.
+ * Samples in current subframe starts from samples_in[0],
+ * while samples_in[-1], samples_in[-2], ..., stores samples
+ * from last subframe as history.
+ *
+ * samples_out: An array holding interpolated samples
+ */
+
+ int decifactor, k, j;
+ const float *prCoeff;
+
+ int interp_index = 0; /* Index to the interpolated samples */
+ int deciindex;
+
+ /* Select decimation filter */
+ if (decimation_select == 1) {
+ decifactor = 128;
+ prCoeff = lfe_fir_128;
+ } else {
+ decifactor = 64;
+ prCoeff = lfe_fir_64;
+ }
+ /* Interpolation */
+ for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
+ /* One decimated sample generates decifactor interpolated ones */
+ for (k = 0; k < decifactor; k++) {
+ float rTmp = 0.0;
+ //FIXME the coeffs are symetric, fix that
+ for (j = 0; j < 512 / decifactor; j++)
+ rTmp += samples_in[deciindex - j] * prCoeff[k + j * decifactor];
+ samples_out[interp_index++] = rTmp / scale + bias;
+ }
+ }
+}
+
+/* downmixing routines */
+#define MIX_REAR1(samples, si1) \
+ samples[i] += samples[si1]; \
+ samples[i+256] += samples[si1];
+
+#define MIX_REAR2(samples, si1, si2) \
+ samples[i] += samples[si1]; \
+ samples[i+256] += samples[si2];
+
+#define MIX_FRONT3(samples) \
+ t = samples[i]; \
+ samples[i] += samples[i+256]; \
+ samples[i+256] = samples[i+512] + t;
+
+#define DOWNMIX_TO_STEREO(op1, op2) \
+ for(i = 0; i < 256; i++){ \
+ op1 \
+ op2 \
+ }
+
+static void dca_downmix(float *samples, int srcfmt)
+{
+ int i;
+ float t;
+
+ switch (srcfmt) {
+ case DCA_MONO:
+ case DCA_CHANNEL:
+ case DCA_STEREO_TOTAL:
+ case DCA_STEREO_SUMDIFF:
+ case DCA_4F2R:
+ av_log(NULL, 0, "Not implemented!\n");
+ break;
+ case DCA_STEREO:
+ break;
+ case DCA_3F:
+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples),);
+ break;
+ case DCA_2F1R:
+ DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + 512),);
+ break;
+ case DCA_3F1R:
+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples),
+ MIX_REAR1(samples, i + 768));
+ break;
+ case DCA_2F2R:
+ DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + 512, i + 768),);
+ break;
+ case DCA_3F2R:
+ DOWNMIX_TO_STEREO(MIX_FRONT3(samples),
+ MIX_REAR2(samples, i + 768, i + 1024));
+ break;
+ }
+}
+
+
+/* Very compact version of the block code decoder that does not use table
+ * look-up but is slightly slower */
+static int decode_blockcode(int code, int levels, int *values)
+{
+ int i;
+ int offset = (levels - 1) >> 1;
+
+ for (i = 0; i < 4; i++) {
+ values[i] = (code % levels) - offset;
+ code /= levels;
+ }
+
+ if (code == 0)
+ return 0;
+ else {
+ av_log(NULL, AV_LOG_ERROR, "ERROR: block code look-up failed\n");
+ return -1;
+ }
+}
+
+static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 };
+static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 };
+
+static int dca_subsubframe(DCAContext * s)
+{
+ int k, l;
+ int subsubframe = s->current_subsubframe;
+
+ float *quant_step_table;
+
+ /* FIXME */
+ float subband_samples[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
+
+ /*
+ * Audio data
+ */
+
+ /* Select quantization step size table */
+ if (s->bit_rate == 0x1f)
+ quant_step_table = (float *) lossless_quant_d;
+ else
+ quant_step_table = (float *) lossy_quant_d;
+
+ for (k = 0; k < s->prim_channels; k++) {
+ for (l = 0; l < s->vq_start_subband[k]; l++) {
+ int m;
+
+ /* Select the mid-tread linear quantizer */
+ int abits = s->bitalloc[k][l];
+
+ float quant_step_size = quant_step_table[abits];
+ float rscale;
+
+ /*
+ * Determine quantization index code book and its type
+ */
+
+ /* Select quantization index code book */
+ int sel = s->quant_index_huffman[k][abits];
+
+ /*
+ * Extract bits from the bit stream
+ */
+ if(!abits){
+ memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0]));
+ }else if(abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){
+ if(abits <= 7){
+ /* Block code */
+ int block_code1, block_code2, size, levels;
+ int block[8];
+
+ size = abits_sizes[abits-1];
+ levels = abits_levels[abits-1];
+
+ block_code1 = get_bits(&s->gb, size);
+ /* FIXME Should test return value */
+ decode_blockcode(block_code1, levels, block);
+ block_code2 = get_bits(&s->gb, size);
+ decode_blockcode(block_code2, levels, &block[4]);
+ for (m = 0; m < 8; m++)
+ subband_samples[k][l][m] = block[m];
+ }else{
+ /* no coding */
+ for (m = 0; m < 8; m++)
+ subband_samples[k][l][m] = get_sbits(&s->gb, abits - 3);
+ }
+ }else{
+ /* Huffman coded */
+ for (m = 0; m < 8; m++)
+ subband_samples[k][l][m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
+ }
+
+ /* Deal with transients */
+ if (s->transition_mode[k][l] &&
+ subsubframe >= s->transition_mode[k][l])
+ rscale = quant_step_size * s->scale_factor[k][l][1];
+ else
+ rscale = quant_step_size * s->scale_factor[k][l][0];
+
+ rscale *= s->scalefactor_adj[k][sel];
+
+ for (m = 0; m < 8; m++)
+ subband_samples[k][l][m] *= rscale;
+
+ /*
+ * Inverse ADPCM if in prediction mode
+ */
+ if (s->prediction_mode[k][l]) {
+ int n;
+ for (m = 0; m < 8; m++) {
+ for (n = 1; n <= 4; n++)
+ if (m >= n)
+ subband_samples[k][l][m] +=
+ (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+ subband_samples[k][l][m - n] / 8192);
+ else if (s->predictor_history)
+ subband_samples[k][l][m] +=
+ (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+ s->subband_samples_hist[k][l][m - n +
+ 4] / 8192);
+ }
+ }
+ }
+
+ /*
+ * Decode VQ encoded high frequencies
+ */
+ for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) {
+ /* 1 vector -> 32 samples but we only need the 8 samples
+ * for this subsubframe. */
+ int m;
+
+ if (!s->debug_flag & 0x01) {
+ av_log(s->avctx, AV_LOG_DEBUG, "Stream with high frequencies VQ coding\n");
+ s->debug_flag |= 0x01;
+ }
+
+ for (m = 0; m < 8; m++) {
+ subband_samples[k][l][m] =
+ high_freq_vq[s->high_freq_vq[k][l]][subsubframe * 8 +
+ m]
+ * (float) s->scale_factor[k][l][0] / 16.0;
+ }
+ }
+ }
+
+ /* Check for DSYNC after subsubframe */
+ if (s->aspf || subsubframe == s->subsubframes - 1) {
+ if (0xFFFF == get_bits(&s->gb, 16)) { /* 0xFFFF */
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n");
+#endif
+ } else {
+ av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
+ }
+ }
+
+ /* Backup predictor history for adpcm */
+ for (k = 0; k < s->prim_channels; k++)
+ for (l = 0; l < s->vq_start_subband[k]; l++)
+ memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4],
+ 4 * sizeof(subband_samples[0][0][0]));
+
+ /* 32 subbands QMF */
+ for (k = 0; k < s->prim_channels; k++) {
+/* 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 * k],
+ 2.0 / 3 /*pcm_to_double[s->source_pcm_res] */ ,
+ 0 /*s->bias */ );
+ }
+
+ /* Down mixing */
+
+ if (s->prim_channels > dca_channels[s->output & DCA_CHANNEL_MASK]) {
+ dca_downmix(s->samples, s->amode);
+ }
+
+ /* Generate LFE samples for this subsubframe FIXME!!! */
+ if (s->output & DCA_LFE) {
+ int lfe_samples = 2 * s->lfe * s->subsubframes;
+ int i_channels = dca_channels[s->output & DCA_CHANNEL_MASK];
+
+ lfe_interpolation_fir(s->lfe, 2 * s->lfe,
+ s->lfe_data + lfe_samples +
+ 2 * s->lfe * subsubframe,
+ &s->samples[256 * i_channels],
+ 8388608.0, s->bias);
+ /* Outputs 20bits pcm samples */
+ }
+
+ return 0;
+}
+
+
+static int dca_subframe_footer(DCAContext * s)
+{
+ int aux_data_count = 0, i;
+ int lfe_samples;
+
+ /*
+ * Unpack optional information
+ */
+
+ if (s->timestamp)
+ get_bits(&s->gb, 32);
+
+ if (s->aux_data)
+ aux_data_count = get_bits(&s->gb, 6);
+
+ for (i = 0; i < aux_data_count; i++)
+ get_bits(&s->gb, 8);
+
+ if (s->crc_present && (s->downmix || s->dynrange))
+ get_bits(&s->gb, 16);
+
+ lfe_samples = 2 * s->lfe * s->subsubframes;
+ for (i = 0; i < lfe_samples; i++) {
+ s->lfe_data[i] = s->lfe_data[i + lfe_samples];
+ }
+
+ return 0;
+}
+
+/**
+ * Decode a dca frame block
+ *
+ * @param s pointer to the DCAContext
+ */
+
+static int dca_decode_block(DCAContext * s)
+{
+
+ /* Sanity check */
+ if (s->current_subframe >= s->subframes) {
+ av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i",
+ s->current_subframe, s->subframes);
+ return -1;
+ }
+
+ if (!s->current_subsubframe) {
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n");
+#endif
+ /* Read subframe header */
+ if (dca_subframe_header(s))
+ return -1;
+ }
+
+ /* Read subsubframe */
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n");
+#endif
+ if (dca_subsubframe(s))
+ return -1;
+
+ /* Update state */
+ s->current_subsubframe++;
+ if (s->current_subsubframe >= s->subsubframes) {
+ s->current_subsubframe = 0;
+ s->current_subframe++;
+ }
+ if (s->current_subframe >= s->subframes) {
+#ifdef TRACE
+ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n");
+#endif
+ /* Read subframe footer */
+ if (dca_subframe_footer(s))
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * Convert bitstream to one representation based on sync marker
+ */
+static int dca_convert_bitstream(uint8_t * src, int src_size, uint8_t * dst,
+ int max_size)
+{
+ uint32_t mrk;
+ int i, tmp;
+ uint16_t *ssrc = (uint16_t *) src, *sdst = (uint16_t *) dst;
+ PutBitContext pb;
+
+ mrk = AV_RB32(src);
+ switch (mrk) {
+ case DCA_MARKER_RAW_BE:
+ memcpy(dst, src, FFMIN(src_size, max_size));
+ return FFMIN(src_size, max_size);
+ case DCA_MARKER_RAW_LE:
+ for (i = 0; i < (FFMIN(src_size, max_size) + 1) >> 1; i++)
+ *sdst++ = bswap_16(*ssrc++);
+ return FFMIN(src_size, max_size);
+ case DCA_MARKER_14B_BE:
+ case DCA_MARKER_14B_LE:
+ init_put_bits(&pb, dst, max_size);
+ for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
+ tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
+ put_bits(&pb, 14, tmp);
+ }
+ flush_put_bits(&pb);
+ return (put_bits_count(&pb) + 7) >> 3;
+ default:
+ return -1;
+ }
+}
+
+/**
+ * Main frame decoding function
+ * FIXME add arguments
+ */
+static int dca_decode_frame(AVCodecContext * avctx,
+ void *data, int *data_size,
+ uint8_t * buf, int buf_size)
+{
+
+ int i, j, k;
+ int16_t *samples = data;
+ DCAContext *s = avctx->priv_data;
+ int channels;
+
+
+ s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);
+ if (s->dca_buffer_size == -1) {
+ av_log(avctx, AV_LOG_ERROR, "Not a DCA frame\n");
+ return -1;
+ }
+
+ init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
+ if (dca_parse_frame_header(s) < 0) {
+ //seems like the frame is corrupt, try with the next one
+ return buf_size;
+ }
+ //set AVCodec values with parsed data
+ avctx->sample_rate = s->sample_rate;
+ avctx->channels = 2; //FIXME
+ avctx->bit_rate = s->bit_rate;
+
+ channels = dca_channels[s->output];
+ if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
+ return -1;
+ *data_size = 0;
+ for (i = 0; i < (s->sample_blocks / 8); i++) {
+ dca_decode_block(s);
+ s->dsp.float_to_int16(s->tsamples, s->samples, 256 * channels);
+ /* interleave samples */
+ for (j = 0; j < 256; j++) {
+ for (k = 0; k < channels; k++)
+ samples[k] = s->tsamples[j + k * 256];
+ samples += channels;
+ }
+ *data_size += 256 * sizeof(int16_t) * channels;
+ }
+
+ return buf_size;
+}
+
+
+
+/**
+ * Build the cosine modulation tables for the QMF
+ *
+ * @param s pointer to the DCAContext
+ */
+
+static void pre_calc_cosmod(DCAContext * s)
+{
+ int i, j, k;
+ static int cosmod_inited = 0;
+
+ if(cosmod_inited) return;
+ for (j = 0, k = 0; k < 16; k++)
+ for (i = 0; i < 16; i++)
+ cos_mod[j++] = cos((2 * i + 1) * (2 * k + 1) * M_PI / 64);
+
+ for (k = 0; k < 16; k++)
+ for (i = 0; i < 16; i++)
+ cos_mod[j++] = cos((i) * (2 * k + 1) * M_PI / 32);
+
+ for (k = 0; k < 16; k++)
+ cos_mod[j++] = 0.25 / (2 * cos((2 * k + 1) * M_PI / 128));
+
+ for (k = 0; k < 16; k++)
+ cos_mod[j++] = -0.25 / (2.0 * sin((2 * k + 1) * M_PI / 128));
+
+ cosmod_inited = 1;
+}
+
+
+/**
+ * DCA initialization
+ *
+ * @param avctx pointer to the AVCodecContext
+ */
+
+static int dca_decode_init(AVCodecContext * avctx)
+{
+ DCAContext *s = avctx->priv_data;
+
+ s->avctx = avctx;
+ dca_init_vlcs();
+ pre_calc_cosmod(s);
+
+ dsputil_init(&s->dsp, avctx);
+ return 0;
+}
+
+
+AVCodec dca_decoder = {
+ .name = "dca",
+ .type = CODEC_TYPE_AUDIO,
+ .id = CODEC_ID_DTS,
+ .priv_data_size = sizeof(DCAContext),
+ .init = dca_decode_init,
+ .decode = dca_decode_frame,
+};
+
+#ifdef CONFIG_DCA_PARSER
+
+typedef struct DCAParseContext {
+ ParseContext pc;
+ uint32_t lastmarker;
+} DCAParseContext;
+
+#define IS_MARKER(state, i, buf, buf_size) \
+ ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \
+ || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \
+ || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)
+
+/**
+ * finds the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or -1
+ */
+static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
+ int buf_size)
+{
+ int start_found, i;
+ uint32_t state;
+ ParseContext *pc = &pc1->pc;
+
+ start_found = pc->frame_start_found;
+ state = pc->state;
+
+ i = 0;
+ if (!start_found) {
+ for (i = 0; i < buf_size; i++) {
+ state = (state << 8) | buf[i];
+ if (IS_MARKER(state, i, buf, buf_size)) {
+ if (pc1->lastmarker && state == pc1->lastmarker) {
+ start_found = 1;
+ break;
+ } else if (!pc1->lastmarker) {
+ start_found = 1;
+ pc1->lastmarker = state;
+ break;
+ }
+ }
+ }
+ }
+ if (start_found) {
+ for (; i < buf_size; i++) {
+ state = (state << 8) | buf[i];
+ if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) {
+ pc->frame_start_found = 0;
+ pc->state = -1;
+ return i - 3;
+ }
+ }
+ }
+ pc->frame_start_found = start_found;
+ pc->state = state;
+ return END_NOT_FOUND;
+}
+
+static int dca_parse_init(AVCodecParserContext * s)
+{
+ DCAParseContext *pc1 = s->priv_data;
+
+ pc1->lastmarker = 0;
+ return 0;
+}
+
+static int dca_parse(AVCodecParserContext * s,
+ AVCodecContext * avctx,
+ uint8_t ** poutbuf, int *poutbuf_size,
+ const uint8_t * buf, int buf_size)
+{
+ DCAParseContext *pc1 = s->priv_data;
+ ParseContext *pc = &pc1->pc;
+ int next;
+
+ if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+ next = buf_size;
+ } else {
+ next = dca_find_frame_end(pc1, buf, buf_size);
+
+ if (ff_combine_frame(pc, next, (uint8_t **) & buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
+ }
+ *poutbuf = (uint8_t *) buf;
+ *poutbuf_size = buf_size;
+ return next;
+}
+
+AVCodecParser dca_parser = {
+ {CODEC_ID_DTS},
+ sizeof(DCAParseContext),
+ dca_parse_init,
+ dca_parse,
+ ff_parse_close,
+};
+#endif /* CONFIG_DCA_PARSER */
diff --git a/contrib/ffmpeg/libavcodec/dcadata.h b/contrib/ffmpeg/libavcodec/dcadata.h
new file mode 100644
index 000000000..c9f2ca747
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/dcadata.h
@@ -0,0 +1,8454 @@
+/*
+ * DCA compatible decoder data
+ * Copyright (C) 2004 Gildas Bazin
+ * Copyright (c) 2006 Benjamin Larsson
+ *
+ * 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 dcadata.c
+ */
+
+/* Generic tables */
+
+static const uint32_t dca_sample_rates[16] =
+{
+ 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
+ 12000, 24000, 48000, 96000, 192000
+};
+
+static const uint32_t dca_bit_rates[32] =
+{
+ 32000, 56000, 64000, 96000, 112000, 128000,
+ 192000, 224000, 256000, 320000, 384000,
+ 448000, 512000, 576000, 640000, 768000,
+ 896000, 1024000, 1152000, 1280000, 1344000,
+ 1408000, 1411200, 1472000, 1536000, 1920000,
+ 2048000, 3072000, 3840000, 1/*open*/, 2/*variable*/, 3/*lossless*/
+};
+
+static const uint8_t dca_channels[16] =
+{
+ 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8
+};
+
+static const uint8_t dca_bits_per_sample[7] =
+{
+ 16, 16, 20, 20, 0, 24, 24
+};
+
+
+/* Adpcm data */
+
+/* 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 }
+};
+
+/* quantization tables */
+
+static const uint32_t scale_factor_quant6[64] = {
+ 1, 2, 2, 3, 3, 4, 6, 7,
+ 10, 12, 16, 20, 26, 34, 44, 56,
+ 72, 93, 120, 155, 200, 257, 331, 427,
+ 550, 708, 912, 1175, 1514, 1950, 2512, 3236,
+ 4169, 5370, 6918, 8913, 11482, 14791, 19055, 24547,
+ 31623, 40738, 52481, 67608, 87096, 112202, 144544, 186209,
+ 239883, 309030, 398107, 512861, 660693, 851138, 1096478, 1412538,
+ 1819701, 2344229, 3019952, 3890451, 5011872, 6456542, 8317638, 0
+};
+
+static const uint32_t scale_factor_quant7[128] = {
+ 1, 1, 2, 2, 2, 2, 3, 3,
+ 3, 4, 4, 5, 6, 7, 7, 8,
+ 10, 11, 12, 14, 16, 18, 20, 23,
+ 26, 30, 34, 38, 44, 50, 56, 64,
+ 72, 82, 93, 106, 120, 136, 155, 176,
+ 200, 226, 257, 292, 331, 376, 427, 484,
+ 550, 624, 708, 804, 912, 1035, 1175, 1334,
+ 1514, 1718, 1950, 2213, 2512, 2851, 3236, 3673,
+ 4169, 4732, 5370, 6095, 6918, 7852, 8913, 10116,
+ 11482, 13032, 14791, 16788, 19055, 21627, 24547, 27861,
+ 31623, 35892, 40738, 46238, 52481, 59566, 67608, 76736,
+ 87096, 98855, 112202, 127350, 144544, 164059, 186209, 211349,
+ 239883, 272270, 309030, 350752, 398107, 451856, 512861, 582103,
+ 660693, 749894, 851138, 966051, 1096478, 1244515, 1412538, 1603245,
+ 1819701, 2065380, 2344229, 2660725, 3019952, 3427678, 3890451, 4415704,
+ 5011872, 5688529, 6456542, 7328245, 8317638, 0, 0, 0
+};
+
+/* 20bits unsigned fractional binary codes */
+static const uint32_t lossy_quant[32] = {
+ 0, 6710886, 4194304, 3355443, 2474639, 2097152, 1761608, 1426063,
+ 796918, 461373, 251658, 146801, 79692, 46137, 27263, 16777,
+ 10486, 5872, 3355, 1887, 1258, 713, 336, 168,
+ 84, 42, 21, 0, 0, 0, 0, 0
+};
+
+static const float lossy_quant_d[32] = {
+ 0, 1.6, 1.0, 0.8, 0.59, 0.50, 0.42, 0.34,
+ 0.19, 0.11, 0.06, 0.035, 0.019, 0.011, 0.0065, 0.0040,
+ 0.0025, 0.0014, 0.0008, 0.00045, 0.00030, 0.00017, 0.00008, 0.00004,
+ 0.00002, 0.00001, 0.000005, 0, 0, 0, 0, 0
+};
+
+/* 20bits unsigned fractional binary codes */
+static const uint32_t lossless_quant[32] = {
+ 0, 4194304, 2097152, 1384120, 1048576, 696254, 524288, 348127,
+ 262144, 131072, 65431, 33026, 16450, 8208, 4100, 2049,
+ 1024, 512, 256, 128, 64, 32, 16, 8,
+ 4, 2, 1, 0, 0, 0, 0, 0
+};
+
+static const float lossless_quant_d[32] = {
+ 0, 1.0, 0.5, 0.33, 0.25, 0.166, 0.125,
+ 0.083, 0.0625, 0.03125, 0.0156, 7.874E-3, 3.922E-3, 1.957E-3,
+ 9.775E-4, 4.885E-4, 2.442E-4, 1.221E-4, 6.104E-5, 3.052E-5, 1.526E-5,
+ 7.629E-6, 3.815E-6, 1.907E-6, 9.537E-7, 4.768E-7, 2.384E-7, 0,
+ 0, 0, 0, 0
+};
+
+
+/* Vector quantization tables */
+
+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 }
+};
+
+
+/* FIR filter coefficients, they can be cut on half and maybe use float instead of double*/
+
+static const float fir_32bands_perfect[] =
+{
++1.135985195E-010,
+-6.022448247E-007,
++9.742954035E-007,
++7.018770981E-011,
+-6.628192182E-007,
++1.085227950E-006,
+-1.608403011E-008,
+-6.982898526E-007,
++1.162929266E-006,
+-5.083275667E-008,
+-7.020648809E-007,
++1.194632091E-006,
+-1.543309907E-007,
+-6.767839409E-007,
++1.179182050E-006,
+-3.961981463E-007,
+-6.262345096E-007,
++1.033426656E-006,
+-7.342250683E-007,
+-5.564140224E-007,
++9.451737242E-007,
+-3.970030775E-007,
++7.003467317E-007,
++1.975324267E-006,
+-4.741137047E-007,
++8.419976893E-007,
++1.190443072E-006,
++5.234479659E-007,
++6.402664354E-008,
+-1.470520488E-006,
++2.014677420E-007,
+-3.246264413E-008,
+-1.853591357E-006,
++7.834767501E-008,
+-3.809887872E-008,
++7.198007665E-007,
++8.434094667E-008,
++3.086857760E-006,
+-6.702406963E-010,
++6.437721822E-008,
++6.084746474E-006,
+-1.613285505E-009,
++1.189317118E-006,
++9.561075785E-006,
+-2.682709610E-009,
++2.497214155E-006,
++1.309637537E-005,
+-3.399493131E-009,
++3.617151151E-006,
++2.263354872E-005,
++1.314406006E-008,
++3.157242645E-006,
++2.847247197E-005,
++7.506701927E-009,
++2.319611212E-006,
++3.415624451E-005,
++2.788728892E-008,
++7.869333785E-006,
++3.946387005E-005,
++1.444918922E-007,
++9.826449968E-006,
++4.425736552E-005,
++3.132386439E-007,
++1.177108606E-005,
++4.839275425E-005,
++1.399798180E-006,
++1.379448349E-005,
++5.176846025E-005,
++2.032118118E-006,
++1.571428584E-005,
++5.429694284E-005,
++2.715013807E-006,
++1.743183020E-005,
++5.595519906E-005,
++3.453840463E-006,
++1.884208177E-005,
++4.916387297E-006,
++4.195037945E-006,
++1.987093310E-005,
++9.299508747E-006,
++4.896494374E-006,
++2.042970118E-005,
++1.356193479E-005,
++5.516381407E-006,
+-3.144468428E-005,
++1.751866148E-005,
++6.015239251E-006,
+-3.334947178E-005,
++2.093936746E-005,
++6.361419310E-006,
+-3.460439257E-005,
++2.362549276E-005,
++8.006985809E-006,
+-3.515914432E-005,
++2.537086584E-005,
++8.087732567E-006,
+-3.495384954E-005,
++2.618136386E-005,
++7.941360309E-006,
+-3.397853652E-005,
++2.554462844E-005,
++7.568834008E-006,
+-3.225446198E-005,
++3.018750249E-005,
++6.986399967E-006,
+-2.978993689E-005,
++2.570833203E-005,
++6.225028756E-006,
+-2.677291741E-005,
++1.985177369E-005,
++5.315936960E-006,
+-1.806914770E-005,
++1.191342653E-005,
++4.429412002E-006,
+-1.776598037E-005,
++2.525620175E-006,
++3.332600045E-006,
+-1.661818715E-005,
+-1.521241393E-005,
++8.427224429E-007,
+-1.207003334E-005,
+-1.617751332E-005,
++4.341498823E-007,
+-6.993315310E-006,
++1.992636317E-005,
++9.458596395E-008,
+-5.633860383E-007,
++1.774702469E-005,
++2.975164826E-008,
+-9.984935332E-007,
++4.624524081E-005,
++5.610509834E-005,
+-5.729619297E-004,
++4.244441516E-004,
++6.568001118E-005,
+-6.358824321E-004,
++2.206075296E-004,
++7.513730816E-005,
+-7.021900383E-004,
+-2.719412748E-007,
++8.413690375E-005,
+-7.698345580E-004,
+-2.382978710E-004,
++8.757545584E-005,
+-8.385353722E-004,
+-4.935106263E-004,
++9.517164290E-005,
+-9.078957955E-004,
+-7.658848190E-004,
++1.020687996E-004,
+-9.775133803E-004,
+-1.055365428E-003,
++1.084438481E-004,
+-1.046945457E-003,
+-1.361547387E-003,
++1.140582463E-004,
+-1.115717343E-003,
+-1.684492454E-003,
++1.187910311E-004,
+-1.183370827E-003,
+-2.023874084E-003,
++1.224978914E-004,
+-1.252829796E-003,
+-2.379294252E-003,
++1.250260248E-004,
+-1.316190348E-003,
+-2.750317100E-003,
++1.262027217E-004,
+-1.376571832E-003,
+-3.136433195E-003,
++1.226499153E-004,
+-1.433344092E-003,
+-3.537061159E-003,
++1.213575742E-004,
+-1.485876855E-003,
+-3.951539751E-003,
++1.180980107E-004,
+-1.533520175E-003,
+-4.379155114E-003,
++1.126275165E-004,
+-1.575609902E-003,
+-4.819062538E-003,
++1.047207043E-004,
+-1.611457788E-003,
+-5.270531867E-003,
++9.417100227E-005,
+-1.640390139E-003,
+-5.732392892E-003,
++8.078388782E-005,
+-1.661288203E-003,
+-6.203945260E-003,
++6.447290798E-005,
+-1.674512983E-003,
+-6.683901884E-003,
++4.491530854E-005,
+-1.678415807E-003,
+-7.170005701E-003,
++2.470704203E-005,
+-1.672798418E-003,
+-7.664063945E-003,
+-1.714242217E-006,
+-1.656501088E-003,
+-8.162760176E-003,
+-3.193307566E-005,
+-1.633993932E-003,
+-8.665001951E-003,
+-6.541742187E-005,
+-1.593449386E-003,
+-9.170533158E-003,
+-1.024175072E-004,
++1.542080659E-003,
+-9.676489048E-003,
+-1.312203676E-004,
++1.479332102E-003,
+-1.018219907E-002,
+-1.774113771E-004,
++1.395521569E-003,
+-1.068630442E-002,
+-2.233728592E-004,
++1.303116791E-003,
+-1.118756086E-002,
+-2.682086197E-004,
++1.196175464E-003,
+-1.168460958E-002,
+-3.347633174E-004,
++1.073757303E-003,
+-1.217562053E-002,
+-3.906481725E-004,
++9.358961834E-004,
+-1.265939046E-002,
+-4.490280990E-004,
++7.817269652E-004,
+-1.313448418E-002,
+-5.099929986E-004,
++6.114174030E-004,
+-1.359948888E-002,
+-1.405300573E-002,
++1.572482102E-002,
++4.935106263E-004,
+-1.449365262E-002,
++1.533095632E-002,
++2.382978710E-004,
+-1.492007636E-002,
++1.492007636E-002,
++2.719412748E-007,
+-1.533095632E-002,
++1.449365262E-002,
+-2.206075296E-004,
+-1.572482102E-002,
++1.405300573E-002,
+-4.244441516E-004,
+-1.610082202E-002,
++1.359948888E-002,
+-6.114174030E-004,
+-1.645756140E-002,
++1.313448418E-002,
+-7.817269652E-004,
+-1.679391414E-002,
++1.265939046E-002,
+-9.358961834E-004,
+-1.710879989E-002,
++1.217562053E-002,
+-1.073757303E-003,
+-1.740120351E-002,
++1.168460958E-002,
+-1.196175464E-003,
+-1.767017506E-002,
++1.118756086E-002,
+-1.303116791E-003,
+-1.791484281E-002,
++1.068630442E-002,
+-1.395521569E-003,
+-1.813439466E-002,
++1.018219907E-002,
+-1.479332102E-003,
+-1.832821220E-002,
++9.676489048E-003,
+-1.542080659E-003,
+-1.849545911E-002,
++9.170533158E-003,
++1.593449386E-003,
+-1.863567345E-002,
++8.665001951E-003,
++1.633993932E-003,
+-1.874836907E-002,
++8.162760176E-003,
++1.656501088E-003,
+-1.883326657E-002,
++7.664063945E-003,
++1.672798418E-003,
+-1.889026538E-002,
++7.170005701E-003,
++1.678415807E-003,
+-1.891860925E-002,
++6.683901884E-003,
++1.674512983E-003,
++1.891860925E-002,
++6.203945260E-003,
++1.661288203E-003,
++1.889026538E-002,
++5.732392892E-003,
++1.640390139E-003,
++1.883326657E-002,
++5.270531867E-003,
++1.611457788E-003,
++1.874836907E-002,
++4.819062538E-003,
++1.575609902E-003,
++1.863567345E-002,
++4.379155114E-003,
++1.533520175E-003,
++1.849545911E-002,
++3.951539751E-003,
++1.485876855E-003,
++1.832821220E-002,
++3.537061159E-003,
++1.433344092E-003,
++1.813439466E-002,
++3.136433195E-003,
++1.376571832E-003,
++1.791484281E-002,
++2.750317100E-003,
++1.316190348E-003,
++1.767017506E-002,
++2.379294252E-003,
++1.252829796E-003,
++1.740120351E-002,
++2.023874084E-003,
++1.183370827E-003,
++1.710879989E-002,
++1.684492454E-003,
++1.115717343E-003,
++1.679391414E-002,
++1.361547387E-003,
++1.046945457E-003,
++1.645756140E-002,
++1.055365428E-003,
++9.775133803E-004,
++1.610082202E-002,
++7.658848190E-004,
++9.078957955E-004,
++8.385353722E-004,
+-8.757545584E-005,
+-6.084746474E-006,
++7.698345580E-004,
+-8.413690375E-005,
+-3.086857760E-006,
++7.021900383E-004,
+-7.513730816E-005,
+-7.198007665E-007,
++6.358824321E-004,
+-6.568001118E-005,
++1.853591357E-006,
++5.729619297E-004,
+-5.610509834E-005,
++1.470520488E-006,
++5.099929986E-004,
+-4.624524081E-005,
++9.984935332E-007,
++4.490280990E-004,
+-1.774702469E-005,
++5.633860383E-007,
++3.906481725E-004,
+-1.992636317E-005,
++6.993315310E-006,
++3.347633174E-004,
++1.617751332E-005,
++1.207003334E-005,
++2.682086197E-004,
++1.521241393E-005,
++1.661818715E-005,
++2.233728592E-004,
+-2.525620175E-006,
++1.776598037E-005,
++1.774113771E-004,
+-1.191342653E-005,
++1.806914770E-005,
++1.312203676E-004,
+-1.985177369E-005,
++2.677291741E-005,
++1.024175072E-004,
+-2.570833203E-005,
++2.978993689E-005,
++6.541742187E-005,
+-3.018750249E-005,
++3.225446198E-005,
++3.193307566E-005,
+-2.554462844E-005,
++3.397853652E-005,
++1.714242217E-006,
+-2.618136386E-005,
++3.495384954E-005,
+-2.470704203E-005,
+-2.537086584E-005,
++3.515914432E-005,
+-4.491530854E-005,
+-2.362549276E-005,
++3.460439257E-005,
+-6.447290798E-005,
+-2.093936746E-005,
++3.334947178E-005,
+-8.078388782E-005,
+-1.751866148E-005,
++3.144468428E-005,
+-9.417100227E-005,
+-1.356193479E-005,
+-2.042970118E-005,
+-1.047207043E-004,
+-9.299508747E-006,
+-1.987093310E-005,
+-1.126275165E-004,
+-4.916387297E-006,
+-1.884208177E-005,
+-1.180980107E-004,
+-5.595519906E-005,
+-1.743183020E-005,
+-1.213575742E-004,
+-5.429694284E-005,
+-1.571428584E-005,
+-1.226499153E-004,
+-5.176846025E-005,
+-1.379448349E-005,
+-1.262027217E-004,
+-4.839275425E-005,
+-1.177108606E-005,
+-1.250260248E-004,
+-4.425736552E-005,
+-9.826449968E-006,
+-1.224978914E-004,
+-3.946387005E-005,
+-7.869333785E-006,
+-1.187910311E-004,
+-3.415624451E-005,
+-2.319611212E-006,
+-1.140582463E-004,
+-2.847247197E-005,
+-3.157242645E-006,
+-1.084438481E-004,
+-2.263354872E-005,
+-3.617151151E-006,
+-1.020687996E-004,
+-1.309637537E-005,
+-2.497214155E-006,
+-9.517164290E-005,
+-9.561075785E-006,
+-1.189317118E-006,
+-6.437721822E-008,
+-4.195037945E-006,
+-1.194632091E-006,
+-8.434094667E-008,
+-3.453840463E-006,
+-1.162929266E-006,
++3.809887872E-008,
+-2.715013807E-006,
+-1.085227950E-006,
++3.246264413E-008,
+-2.032118118E-006,
+-9.742954035E-007,
+-6.402664354E-008,
+-1.399798180E-006,
+-8.419976893E-007,
+-2.975164826E-008,
+-3.132386439E-007,
+-7.003467317E-007,
+-9.458596395E-008,
+-1.444918922E-007,
++5.564140224E-007,
+-4.341498823E-007,
+-2.788728892E-008,
++6.262345096E-007,
+-8.427224429E-007,
+-7.506701927E-009,
++6.767839409E-007,
+-3.332600045E-006,
+-1.314406006E-008,
++7.020648809E-007,
+-4.429412002E-006,
++3.399493131E-009,
++6.982898526E-007,
+-5.315936960E-006,
++2.682709610E-009,
++6.628192182E-007,
+-6.225028756E-006,
++1.613285505E-009,
++6.022448247E-007,
+-6.986399967E-006,
++6.702406963E-010,
++4.741137047E-007,
+-7.568834008E-006,
+-7.834767501E-008,
++3.970030775E-007,
+-7.941360309E-006,
+-2.014677420E-007,
++7.342250683E-007,
+-8.087732567E-006,
+-5.234479659E-007,
++3.961981463E-007,
+-8.006985809E-006,
+-1.190443072E-006,
++1.543309907E-007,
+-6.361419310E-006,
+-1.975324267E-006,
++5.083275667E-008,
+-6.015239251E-006,
+-9.451737242E-007,
++1.608403011E-008,
+-5.516381407E-006,
+-1.033426656E-006,
+-7.018770981E-011,
+-4.896494374E-006,
+-1.179182050E-006,
+-1.135985195E-010
+};
+
+static const float fir_32bands_nonperfect[] =
+{
+-1.390191784E-007,
+-1.693738625E-007,
+-2.030677564E-007,
+-2.404238444E-007,
+-2.818143514E-007,
+-3.276689142E-007,
+-3.784752209E-007,
+-4.347855338E-007,
+-4.972276315E-007,
+-5.665120852E-007,
+-6.434325428E-007,
+-7.288739425E-007,
+-8.238164355E-007,
+-9.293416952E-007,
+-1.046637067E-006,
+-1.176999604E-006,
+-1.321840614E-006,
+-1.482681114E-006,
+-1.661159786E-006,
+-1.859034001E-006,
+-2.078171747E-006,
+-2.320550948E-006,
+-2.588257530E-006,
+-2.883470643E-006,
+-3.208459020E-006,
+-3.565570978E-006,
+-3.957220997E-006,
+-4.385879038E-006,
+-4.854050530E-006,
+-5.364252502E-006,
+-5.918994248E-006,
+-6.520755960E-006,
+-7.171964626E-006,
+-7.874960829E-006,
+-8.631964192E-006,
+-9.445050637E-006,
+-1.031611009E-005,
+-1.124680875E-005,
+-1.223855270E-005,
+-1.329243969E-005,
+-1.440921824E-005,
+-1.558924305E-005,
+-1.683242772E-005,
+-1.813820381E-005,
+-1.950545993E-005,
+-2.093250441E-005,
+-2.241701623E-005,
+-2.395598858E-005,
+-2.554569073E-005,
+-2.718161704E-005,
+-2.885844333E-005,
+-3.056998685E-005,
+-3.230916263E-005,
+-3.406793985E-005,
+-3.583733633E-005,
+-3.760734762E-005,
+-3.936696885E-005,
+-4.110412556E-005,
+-4.280570283E-005,
+-4.445751256E-005,
+-4.604430433E-005,
+-4.754976908E-005,
+-4.895655002E-005,
+-5.024627535E-005,
++5.139957648E-005,
++5.239612074E-005,
++5.321469871E-005,
++5.383323878E-005,
++5.422891263E-005,
++5.437819709E-005,
++5.425697600E-005,
++5.384063843E-005,
++5.310418419E-005,
++5.202236207E-005,
++5.056979353E-005,
++4.872112549E-005,
++4.645117951E-005,
++4.373511547E-005,
++4.054862075E-005,
++3.686808850E-005,
++3.267079956E-005,
++2.793515523E-005,
++2.264085742E-005,
++1.676913780E-005,
++1.030297699E-005,
++3.227306706E-006,
+-4.470633485E-006,
+-1.280130618E-005,
+-2.177240640E-005,
+-3.138873581E-005,
+-4.165195787E-005,
+-5.256036457E-005,
+-6.410864444E-005,
+-7.628766616E-005,
+-8.908427117E-005,
+-1.024810626E-004,
+-1.164562127E-004,
+-1.309833024E-004,
+-1.460311323E-004,
+-1.615635992E-004,
+-1.775395358E-004,
+-1.939126523E-004,
+-2.106313768E-004,
+-2.276388550E-004,
+-2.448728774E-004,
+-2.622658503E-004,
+-2.797449124E-004,
+-2.972317743E-004,
+-3.146430245E-004,
+-3.318900708E-004,
+-3.488793736E-004,
+-3.655125911E-004,
+-3.816867538E-004,
+-3.972945851E-004,
+-4.122247046E-004,
+-4.263620067E-004,
+-4.395879805E-004,
+-4.517810594E-004,
+-4.628172028E-004,
+-4.725702747E-004,
+-4.809123348E-004,
+-4.877146275E-004,
+-4.928477574E-004,
+-4.961824161E-004,
+-4.975944757E-004,
+-4.969481961E-004,
+-4.941228544E-004,
+-4.889960401E-004,
++4.814492422E-004,
++4.713678791E-004,
++4.586426076E-004,
++4.431701091E-004,
++4.248536134E-004,
++4.036037717E-004,
++3.793396754E-004,
++3.519894381E-004,
++3.214911267E-004,
++2.877934603E-004,
++2.508567995E-004,
++2.106537577E-004,
++1.671699720E-004,
++1.204049113E-004,
++7.037253090E-005,
++1.710198012E-005,
+-3.936182839E-005,
+-9.895755647E-005,
+-1.616069785E-004,
+-2.272142592E-004,
+-2.956659591E-004,
+-3.668301215E-004,
+-4.405563814E-004,
+-5.166754709E-004,
+-5.949990009E-004,
+-6.753197522E-004,
+-7.574109477E-004,
+-8.410271257E-004,
+-9.259034996E-004,
+-1.011756598E-003,
+-1.098284614E-003,
+-1.185167348E-003,
+-1.272067428E-003,
+-1.358630019E-003,
+-1.444484224E-003,
+-1.529243193E-003,
+-1.612505526E-003,
+-1.693855622E-003,
+-1.772865304E-003,
+-1.849094522E-003,
+-1.922092517E-003,
+-1.991399564E-003,
+-2.056547208E-003,
+-2.117061289E-003,
+-2.172462177E-003,
+-2.222266514E-003,
+-2.265989315E-003,
+-2.303145360E-003,
+-2.333251061E-003,
+-2.355825622E-003,
+-2.370394068E-003,
+-2.376487479E-003,
+-2.373647178E-003,
+-2.361423569E-003,
+-2.339380793E-003,
+-2.307097195E-003,
+-2.264167881E-003,
+-2.210205887E-003,
+-2.144844970E-003,
+-2.067740774E-003,
+-1.978572691E-003,
+-1.877046190E-003,
+-1.762894331E-003,
+-1.635878929E-003,
++1.495792647E-003,
++1.342460280E-003,
++1.175740734E-003,
++9.955273708E-004,
++8.017504588E-004,
++5.943773431E-004,
++3.734139318E-004,
++1.389056415E-004,
+-1.090620208E-004,
+-3.703625989E-004,
+-6.448282511E-004,
+-9.322494152E-004,
+-1.232374110E-003,
+-1.544908970E-003,
+-1.869517611E-003,
+-2.205822384E-003,
+-2.553403843E-003,
+-2.911801683E-003,
+-3.280514618E-003,
+-3.659002949E-003,
+-4.046686925E-003,
+-4.442950245E-003,
+-4.847140983E-003,
+-5.258570891E-003,
+-5.676518660E-003,
+-6.100233644E-003,
+-6.528933067E-003,
+-6.961807609E-003,
+-7.398022339E-003,
+-7.836719044E-003,
+-8.277016692E-003,
+-8.718019351E-003,
+-9.158811532E-003,
+-9.598465636E-003,
+-1.003604382E-002,
+-1.047059800E-002,
+-1.090117730E-002,
+-1.132682897E-002,
+-1.174659748E-002,
+-1.215953380E-002,
+-1.256469358E-002,
+-1.296114177E-002,
+-1.334795821E-002,
+-1.372423489E-002,
+-1.408908330E-002,
+-1.444163360E-002,
+-1.478104480E-002,
+-1.510649733E-002,
+-1.541720331E-002,
+-1.571240649E-002,
+-1.599138230E-002,
+-1.625344716E-002,
+-1.649795473E-002,
+-1.672429405E-002,
+-1.693190821E-002,
+-1.712027565E-002,
+-1.728892699E-002,
+-1.743743755E-002,
+-1.756543480E-002,
+-1.767260395E-002,
+-1.775865816E-002,
+-1.782339066E-002,
+-1.786663756E-002,
+-1.788828894E-002,
++1.788828894E-002,
++1.786663756E-002,
++1.782339066E-002,
++1.775865816E-002,
++1.767260395E-002,
++1.756543480E-002,
++1.743743755E-002,
++1.728892699E-002,
++1.712027565E-002,
++1.693190821E-002,
++1.672429405E-002,
++1.649795473E-002,
++1.625344716E-002,
++1.599138230E-002,
++1.571240649E-002,
++1.541720331E-002,
++1.510649733E-002,
++1.478104480E-002,
++1.444163360E-002,
++1.408908330E-002,
++1.372423489E-002,
++1.334795821E-002,
++1.296114177E-002,
++1.256469358E-002,
++1.215953380E-002,
++1.174659748E-002,
++1.132682897E-002,
++1.090117730E-002,
++1.047059800E-002,
++1.003604382E-002,
++9.598465636E-003,
++9.158811532E-003,
++8.718019351E-003,
++8.277016692E-003,
++7.836719044E-003,
++7.398022339E-003,
++6.961807609E-003,
++6.528933067E-003,
++6.100233644E-003,
++5.676518660E-003,
++5.258570891E-003,
++4.847140983E-003,
++4.442950245E-003,
++4.046686925E-003,
++3.659002949E-003,
++3.280514618E-003,
++2.911801683E-003,
++2.553403843E-003,
++2.205822384E-003,
++1.869517611E-003,
++1.544908970E-003,
++1.232374110E-003,
++9.322494152E-004,
++6.448282511E-004,
++3.703625989E-004,
++1.090620208E-004,
+-1.389056415E-004,
+-3.734139318E-004,
+-5.943773431E-004,
+-8.017504588E-004,
+-9.955273708E-004,
+-1.175740734E-003,
+-1.342460280E-003,
+-1.495792647E-003,
++1.635878929E-003,
++1.762894331E-003,
++1.877046190E-003,
++1.978572691E-003,
++2.067740774E-003,
++2.144844970E-003,
++2.210205887E-003,
++2.264167881E-003,
++2.307097195E-003,
++2.339380793E-003,
++2.361423569E-003,
++2.373647178E-003,
++2.376487479E-003,
++2.370394068E-003,
++2.355825622E-003,
++2.333251061E-003,
++2.303145360E-003,
++2.265989315E-003,
++2.222266514E-003,
++2.172462177E-003,
++2.117061289E-003,
++2.056547208E-003,
++1.991399564E-003,
++1.922092517E-003,
++1.849094522E-003,
++1.772865304E-003,
++1.693855622E-003,
++1.612505526E-003,
++1.529243193E-003,
++1.444484224E-003,
++1.358630019E-003,
++1.272067428E-003,
++1.185167348E-003,
++1.098284614E-003,
++1.011756598E-003,
++9.259034996E-004,
++8.410271257E-004,
++7.574109477E-004,
++6.753197522E-004,
++5.949990009E-004,
++5.166754709E-004,
++4.405563814E-004,
++3.668301215E-004,
++2.956659591E-004,
++2.272142592E-004,
++1.616069785E-004,
++9.895755647E-005,
++3.936182839E-005,
+-1.710198012E-005,
+-7.037253090E-005,
+-1.204049113E-004,
+-1.671699720E-004,
+-2.106537577E-004,
+-2.508567995E-004,
+-2.877934603E-004,
+-3.214911267E-004,
+-3.519894381E-004,
+-3.793396754E-004,
+-4.036037717E-004,
+-4.248536134E-004,
+-4.431701091E-004,
+-4.586426076E-004,
+-4.713678791E-004,
+-4.814492422E-004,
++4.889960401E-004,
++4.941228544E-004,
++4.969481961E-004,
++4.975944757E-004,
++4.961824161E-004,
++4.928477574E-004,
++4.877146275E-004,
++4.809123348E-004,
++4.725702747E-004,
++4.628172028E-004,
++4.517810594E-004,
++4.395879805E-004,
++4.263620067E-004,
++4.122247046E-004,
++3.972945851E-004,
++3.816867538E-004,
++3.655125911E-004,
++3.488793736E-004,
++3.318900708E-004,
++3.146430245E-004,
++2.972317743E-004,
++2.797449124E-004,
++2.622658503E-004,
++2.448728774E-004,
++2.276388550E-004,
++2.106313768E-004,
++1.939126523E-004,
++1.775395358E-004,
++1.615635992E-004,
++1.460311323E-004,
++1.309833024E-004,
++1.164562127E-004,
++1.024810626E-004,
++8.908427117E-005,
++7.628766616E-005,
++6.410864444E-005,
++5.256036457E-005,
++4.165195787E-005,
++3.138873581E-005,
++2.177240640E-005,
++1.280130618E-005,
++4.470633485E-006,
+-3.227306706E-006,
+-1.030297699E-005,
+-1.676913780E-005,
+-2.264085742E-005,
+-2.793515523E-005,
+-3.267079956E-005,
+-3.686808850E-005,
+-4.054862075E-005,
+-4.373511547E-005,
+-4.645117951E-005,
+-4.872112549E-005,
+-5.056979353E-005,
+-5.202236207E-005,
+-5.310418419E-005,
+-5.384063843E-005,
+-5.425697600E-005,
+-5.437819709E-005,
+-5.422891263E-005,
+-5.383323878E-005,
+-5.321469871E-005,
+-5.239612074E-005,
+-5.139957648E-005,
++5.024627535E-005,
++4.895655002E-005,
++4.754976908E-005,
++4.604430433E-005,
++4.445751256E-005,
++4.280570283E-005,
++4.110412556E-005,
++3.936696885E-005,
++3.760734762E-005,
++3.583733633E-005,
++3.406793985E-005,
++3.230916263E-005,
++3.056998685E-005,
++2.885844333E-005,
++2.718161704E-005,
++2.554569073E-005,
++2.395598858E-005,
++2.241701623E-005,
++2.093250441E-005,
++1.950545993E-005,
++1.813820381E-005,
++1.683242772E-005,
++1.558924305E-005,
++1.440921824E-005,
++1.329243969E-005,
++1.223855270E-005,
++1.124680875E-005,
++1.031611009E-005,
++9.445050637E-006,
++8.631964192E-006,
++7.874960829E-006,
++7.171964626E-006,
++6.520755960E-006,
++5.918994248E-006,
++5.364252502E-006,
++4.854050530E-006,
++4.385879038E-006,
++3.957220997E-006,
++3.565570978E-006,
++3.208459020E-006,
++2.883470643E-006,
++2.588257530E-006,
++2.320550948E-006,
++2.078171747E-006,
++1.859034001E-006,
++1.661159786E-006,
++1.482681114E-006,
++1.321840614E-006,
++1.176999604E-006,
++1.046637067E-006,
++9.293416952E-007,
++8.238164355E-007,
++7.288739425E-007,
++6.434325428E-007,
++5.665120852E-007,
++4.972276315E-007,
++4.347855338E-007,
++3.784752209E-007,
++3.276689142E-007,
++2.818143514E-007,
++2.404238444E-007,
++2.030677564E-007,
++1.693738625E-007,
++1.390191784E-007
+};
+
+//FIXME the coeffs are symetric
+static const float lfe_fir_64[] =
+{
+2.6584343868307770E-004,
+8.1793652498163280E-005,
+9.4393239123746760E-005,
+1.0821702744578940E-004,
+1.2333714403212070E-004,
+1.3974857574794440E-004,
+1.5759580128360540E-004,
+1.7699223826639360E-004,
+1.9817386055365200E-004,
+2.2118473134469240E-004,
+2.4602311896160240E-004,
+2.7261159266345200E-004,
+3.0138631700538100E-004,
+3.3283955417573450E-004,
+3.6589911906048660E-004,
+4.0182814700528980E-004,
+4.4018754852004350E-004,
+4.8127761692740020E-004,
+5.2524596685543660E-004,
+5.7215924607589840E-004,
+6.2221300322562460E-004,
+6.7555153509601950E-004,
+7.3241489008069040E-004,
+7.9285167157649990E-004,
+8.5701106581836940E-004,
+9.2511920956894760E-004,
+9.9747709464281800E-004,
+1.0739302961155770E-003,
+1.1550235794857140E-003,
+1.2406768510118130E-003,
+1.3312589144334200E-003,
+1.4268938684836030E-003,
+1.5278297942131760E-003,
+1.6342115122824910E-003,
+1.7463274998590350E-003,
+1.8643775256350640E-003,
+1.9886041991412640E-003,
+2.1191518753767010E-003,
+2.2563596721738580E-003,
+2.4004334118217230E-003,
+2.5515670422464610E-003,
+2.7100932784378530E-003,
+2.8761904686689380E-003,
+3.0501529108732940E-003,
+3.2322725746780640E-003,
+3.4227769356220960E-003,
+3.6219672765582800E-003,
+3.8300913292914630E-003,
+4.0474990382790560E-003,
+4.2744171805679800E-003,
+4.5111598446965220E-003,
+4.7580120153725150E-003,
+5.0153112970292570E-003,
+5.2832840010523800E-003,
+5.5623454973101620E-003,
+5.8526843786239620E-003,
+6.1547122895717620E-003,
+6.4686913974583150E-003,
+6.7949919030070300E-003,
+7.1338820271193980E-003,
+7.4857366271317010E-003,
+7.8508658334612850E-003,
+8.2296309992671010E-003,
+8.6223213002085690E-003,
+9.0293306857347480E-003,
+9.4509534537792200E-003,
+9.8875602707266800E-003,
+1.0339494794607160E-002,
+1.0807084850966930E-002,
+1.1290682479739190E-002,
+1.1790650896728040E-002,
+1.2307321652770040E-002,
+1.2841059826314450E-002,
+1.3392185792326930E-002,
+1.3961089774966240E-002,
+1.4548087492585180E-002,
+1.5153550542891020E-002,
+1.5777811408042910E-002,
+1.6421230509877200E-002,
+1.7084129154682160E-002,
+1.7766902223229410E-002,
+1.8469827249646190E-002,
+1.9193304702639580E-002,
+1.9937623292207720E-002,
+2.0703161135315900E-002,
+2.1490212529897690E-002,
+2.2299138829112050E-002,
+2.3130238056182860E-002,
+2.3983856663107870E-002,
+2.4860285222530360E-002,
+2.5759860873222350E-002,
+2.6682861149311060E-002,
+2.7629608288407320E-002,
+2.8600392863154410E-002,
+2.9595496132969860E-002,
+3.0615204945206640E-002,
+3.1659796833992000E-002,
+3.2729536294937140E-002,
+3.3824689686298370E-002,
+3.4945506602525710E-002,
+3.6092240363359450E-002,
+3.7265110760927200E-002,
+3.8464374840259550E-002,
+3.9690230041742320E-002,
+4.0942888706922530E-002,
+4.2222552001476290E-002,
+4.3529424816370010E-002,
+4.4863656163215640E-002,
+4.6225443482398990E-002,
+4.7614917159080510E-002,
+4.9032241106033330E-002,
+5.0477534532547000E-002,
+5.1950931549072270E-002,
+5.3452525287866590E-002,
+5.4982420057058330E-002,
+5.6540694087743760E-002,
+5.8127421885728840E-002,
+5.9742655605077740E-002,
+6.1386436223983760E-002,
+6.3058786094188690E-002,
+6.4759708940982820E-002,
+6.6489234566688540E-002,
+6.8247318267822270E-002,
+7.0033922791481020E-002,
+7.1849010884761810E-002,
+7.3692522943019870E-002,
+7.5564362108707430E-002,
+7.7464438974857330E-002,
+7.9392634332180020E-002,
+8.1348828971385960E-002,
+8.3332858979702000E-002,
+8.5344567894935610E-002,
+8.7383769452571870E-002,
+8.9450262486934660E-002,
+9.1543838381767280E-002,
+9.3664251267910000E-002,
+9.5811240375041960E-002,
+9.7984537482261660E-002,
+1.0018386691808700E-001,
+1.0240890830755230E-001,
+1.0465932637453080E-001,
+1.0693479329347610E-001,
+1.0923493653535840E-001,
+1.1155936866998670E-001,
+1.1390769481658940E-001,
+1.1627949774265290E-001,
+1.1867434531450270E-001,
+1.2109176814556120E-001,
+1.2353130429983140E-001,
+1.2599244713783260E-001,
+1.2847468256950380E-001,
+1.3097748160362240E-001,
+1.3350030779838560E-001,
+1.3604259490966800E-001,
+1.3860376179218290E-001,
+1.4118319749832150E-001,
+1.4378026127815250E-001,
+1.4639437198638920E-001,
+1.4902481436729430E-001,
+1.5167096257209780E-001,
+1.5433208644390100E-001,
+1.5700751543045040E-001,
+1.5969651937484740E-001,
+1.6239835321903230E-001,
+1.6511227190494540E-001,
+1.6783750057220460E-001,
+1.7057323455810550E-001,
+1.7331869900226590E-001,
+1.7607308924198150E-001,
+1.7883554100990300E-001,
+1.8160524964332580E-001,
+1.8438133597373960E-001,
+1.8716295063495640E-001,
+1.8994916975498200E-001,
+1.9273911416530610E-001,
+1.9553191959857940E-001,
+1.9832661747932440E-001,
+2.0112232863903040E-001,
+2.0391805469989780E-001,
+2.0671287178993220E-001,
+2.0950584113597870E-001,
+2.1229594945907590E-001,
+2.1508227288722990E-001,
+2.1786379814147950E-001,
+2.2063951194286350E-001,
+2.2340846061706540E-001,
+2.2616961598396300E-001,
+2.2892196476459500E-001,
+2.3166447877883910E-001,
+2.3439615964889520E-001,
+2.3711597919464110E-001,
+2.3982289433479310E-001,
+2.4251587688922880E-001,
+2.4519388377666480E-001,
+2.4785590171813960E-001,
+2.5050088763237000E-001,
+2.5312781333923340E-001,
+2.5573557615280150E-001,
+2.5832322239875800E-001,
+2.6088967919349670E-001,
+2.6343390345573420E-001,
+2.6595494151115420E-001,
+2.6845166087150580E-001,
+2.7092313766479490E-001,
+2.7336826920509340E-001,
+2.7578607201576240E-001,
+2.7817553281784060E-001,
+2.8053569793701170E-001,
+2.8286558389663700E-001,
+2.8516408801078800E-001,
+2.8743034601211550E-001,
+2.8966337442398070E-001,
+2.9186218976974480E-001,
+2.9402589797973640E-001,
+2.9615348577499390E-001,
+2.9824411869049070E-001,
+3.0029675364494320E-001,
+3.0231067538261420E-001,
+3.0428490042686460E-001,
+3.0621853470802300E-001,
+3.0811080336570740E-001,
+3.0996081233024600E-001,
+3.1176769733428960E-001,
+3.1353080272674560E-001,
+3.1524917483329780E-001,
+3.1692212820053100E-001,
+3.1854888796806340E-001,
+3.2012873888015740E-001,
+3.2166096568107600E-001,
+3.2314485311508180E-001,
+3.2457971572875980E-001,
+3.2596495747566220E-001,
+3.2729989290237420E-001,
+3.2858389616012580E-001,
+3.2981643080711360E-001,
+3.3099696040153500E-001,
+3.3212485909461980E-001,
+3.3319962024688720E-001,
+3.3422079682350160E-001,
+3.3518791198730470E-001,
+3.3610042929649360E-001,
+3.3695802092552180E-001,
+3.3776029944419860E-001,
+3.3850681781768800E-001,
+3.3919724822044380E-001,
+3.3983129262924200E-001,
+3.4040865302085880E-001,
+3.4092903137207030E-001,
+3.4139221906661980E-001,
+3.4179797768592840E-001,
+3.4214612841606140E-001,
+3.4243649244308470E-001,
+3.4266895055770880E-001,
+3.4284341335296630E-001,
+3.4295973181724550E-001,
+3.4301793575286860E-001,
+3.4301793575286860E-001,
+3.4295973181724550E-001,
+3.4284341335296630E-001,
+3.4266895055770880E-001,
+3.4243649244308470E-001,
+3.4214612841606140E-001,
+3.4179797768592840E-001,
+3.4139221906661980E-001,
+3.4092903137207030E-001,
+3.4040865302085880E-001,
+3.3983129262924200E-001,
+3.3919724822044380E-001,
+3.3850681781768800E-001,
+3.3776029944419860E-001,
+3.3695802092552180E-001,
+3.3610042929649360E-001,
+3.3518791198730470E-001,
+3.3422079682350160E-001,
+3.3319962024688720E-001,
+3.3212485909461980E-001,
+3.3099696040153500E-001,
+3.2981643080711360E-001,
+3.2858389616012580E-001,
+3.2729989290237420E-001,
+3.2596495747566220E-001,
+3.2457971572875980E-001,
+3.2314485311508180E-001,
+3.2166096568107600E-001,
+3.2012873888015740E-001,
+3.1854888796806340E-001,
+3.1692212820053100E-001,
+3.1524917483329780E-001,
+3.1353080272674560E-001,
+3.1176769733428960E-001,
+3.0996081233024600E-001,
+3.0811080336570740E-001,
+3.0621853470802300E-001,
+3.0428490042686460E-001,
+3.0231067538261420E-001,
+3.0029675364494320E-001,
+2.9824411869049070E-001,
+2.9615348577499390E-001,
+2.9402589797973640E-001,
+2.9186218976974480E-001,
+2.8966337442398070E-001,
+2.8743034601211550E-001,
+2.8516408801078800E-001,
+2.8286558389663700E-001,
+2.8053569793701170E-001,
+2.7817553281784060E-001,
+2.7578607201576240E-001,
+2.7336826920509340E-001,
+2.7092313766479490E-001,
+2.6845166087150580E-001,
+2.6595494151115420E-001,
+2.6343390345573420E-001,
+2.6088967919349670E-001,
+2.5832322239875800E-001,
+2.5573557615280150E-001,
+2.5312781333923340E-001,
+2.5050088763237000E-001,
+2.4785590171813960E-001,
+2.4519388377666480E-001,
+2.4251587688922880E-001,
+2.3982289433479310E-001,
+2.3711597919464110E-001,
+2.3439615964889520E-001,
+2.3166447877883910E-001,
+2.2892196476459500E-001,
+2.2616961598396300E-001,
+2.2340846061706540E-001,
+2.2063951194286350E-001,
+2.1786379814147950E-001,
+2.1508227288722990E-001,
+2.1229594945907590E-001,
+2.0950584113597870E-001,
+2.0671287178993220E-001,
+2.0391805469989780E-001,
+2.0112232863903040E-001,
+1.9832661747932440E-001,
+1.9553191959857940E-001,
+1.9273911416530610E-001,
+1.8994916975498200E-001,
+1.8716295063495640E-001,
+1.8438133597373960E-001,
+1.8160524964332580E-001,
+1.7883554100990300E-001,
+1.7607308924198150E-001,
+1.7331869900226590E-001,
+1.7057323455810550E-001,
+1.6783750057220460E-001,
+1.6511227190494540E-001,
+1.6239835321903230E-001,
+1.5969651937484740E-001,
+1.5700751543045040E-001,
+1.5433208644390100E-001,
+1.5167096257209780E-001,
+1.4902481436729430E-001,
+1.4639437198638920E-001,
+1.4378026127815250E-001,
+1.4118319749832150E-001,
+1.3860376179218290E-001,
+1.3604259490966800E-001,
+1.3350030779838560E-001,
+1.3097748160362240E-001,
+1.2847468256950380E-001,
+1.2599244713783260E-001,
+1.2353130429983140E-001,
+1.2109176814556120E-001,
+1.1867434531450270E-001,
+1.1627949774265290E-001,
+1.1390769481658940E-001,
+1.1155936866998670E-001,
+1.0923493653535840E-001,
+1.0693479329347610E-001,
+1.0465932637453080E-001,
+1.0240890830755230E-001,
+1.0018386691808700E-001,
+9.7984537482261660E-002,
+9.5811240375041960E-002,
+9.3664251267910000E-002,
+9.1543838381767280E-002,
+8.9450262486934660E-002,
+8.7383769452571870E-002,
+8.5344567894935610E-002,
+8.3332858979702000E-002,
+8.1348828971385960E-002,
+7.9392634332180020E-002,
+7.7464438974857330E-002,
+7.5564362108707430E-002,
+7.3692522943019870E-002,
+7.1849010884761810E-002,
+7.0033922791481020E-002,
+6.8247318267822270E-002,
+6.6489234566688540E-002,
+6.4759708940982820E-002,
+6.3058786094188690E-002,
+6.1386436223983760E-002,
+5.9742655605077740E-002,
+5.8127421885728840E-002,
+5.6540694087743760E-002,
+5.4982420057058330E-002,
+5.3452525287866590E-002,
+5.1950931549072270E-002,
+5.0477534532547000E-002,
+4.9032241106033330E-002,
+4.7614917159080510E-002,
+4.6225443482398990E-002,
+4.4863656163215640E-002,
+4.3529424816370010E-002,
+4.2222552001476290E-002,
+4.0942888706922530E-002,
+3.9690230041742320E-002,
+3.8464374840259550E-002,
+3.7265110760927200E-002,
+3.6092240363359450E-002,
+3.4945506602525710E-002,
+3.3824689686298370E-002,
+3.2729536294937140E-002,
+3.1659796833992000E-002,
+3.0615204945206640E-002,
+2.9595496132969860E-002,
+2.8600392863154410E-002,
+2.7629608288407320E-002,
+2.6682861149311060E-002,
+2.5759860873222350E-002,
+2.4860285222530360E-002,
+2.3983856663107870E-002,
+2.3130238056182860E-002,
+2.2299138829112050E-002,
+2.1490212529897690E-002,
+2.0703161135315900E-002,
+1.9937623292207720E-002,
+1.9193304702639580E-002,
+1.8469827249646190E-002,
+1.7766902223229410E-002,
+1.7084129154682160E-002,
+1.6421230509877200E-002,
+1.5777811408042910E-002,
+1.5153550542891020E-002,
+1.4548087492585180E-002,
+1.3961089774966240E-002,
+1.3392185792326930E-002,
+1.2841059826314450E-002,
+1.2307321652770040E-002,
+1.1790650896728040E-002,
+1.1290682479739190E-002,
+1.0807084850966930E-002,
+1.0339494794607160E-002,
+9.8875602707266800E-003,
+9.4509534537792200E-003,
+9.0293306857347480E-003,
+8.6223213002085690E-003,
+8.2296309992671010E-003,
+7.8508658334612850E-003,
+7.4857366271317010E-003,
+7.1338820271193980E-003,
+6.7949919030070300E-003,
+6.4686913974583150E-003,
+6.1547122895717620E-003,
+5.8526843786239620E-003,
+5.5623454973101620E-003,
+5.2832840010523800E-003,
+5.0153112970292570E-003,
+4.7580120153725150E-003,
+4.5111598446965220E-003,
+4.2744171805679800E-003,
+4.0474990382790560E-003,
+3.8300913292914630E-003,
+3.6219672765582800E-003,
+3.4227769356220960E-003,
+3.2322725746780640E-003,
+3.0501529108732940E-003,
+2.8761904686689380E-003,
+2.7100932784378530E-003,
+2.5515670422464610E-003,
+2.4004334118217230E-003,
+2.2563596721738580E-003,
+2.1191518753767010E-003,
+1.9886041991412640E-003,
+1.8643775256350640E-003,
+1.7463274998590350E-003,
+1.6342115122824910E-003,
+1.5278297942131760E-003,
+1.4268938684836030E-003,
+1.3312589144334200E-003,
+1.2406768510118130E-003,
+1.1550235794857140E-003,
+1.0739302961155770E-003,
+9.9747709464281800E-004,
+9.2511920956894760E-004,
+8.5701106581836940E-004,
+7.9285167157649990E-004,
+7.3241489008069040E-004,
+6.7555153509601950E-004,
+6.2221300322562460E-004,
+5.7215924607589840E-004,
+5.2524596685543660E-004,
+4.8127761692740020E-004,
+4.4018754852004350E-004,
+4.0182814700528980E-004,
+3.6589911906048660E-004,
+3.3283955417573450E-004,
+3.0138631700538100E-004,
+2.7261159266345200E-004,
+2.4602311896160240E-004,
+2.2118473134469240E-004,
+1.9817386055365200E-004,
+1.7699223826639360E-004,
+1.5759580128360540E-004,
+1.3974857574794440E-004,
+1.2333714403212070E-004,
+1.0821702744578940E-004,
+9.4393239123746760E-005,
+8.1793652498163280E-005,
+2.6584343868307770E-004
+};
+
+//FIXME the coeffs are symetric
+
+static const float lfe_fir_128[] =
+{
+0.00053168571,
+0.00016358691,
+0.00018878609,
+0.00021643363,
+0.00024667382,
+0.00027949660,
+0.00031519096,
+0.00035398375,
+0.00039634691,
+0.00044236859,
+0.00049204525,
+0.00054522208,
+0.00060277141,
+0.00066567765,
+0.00073179678,
+0.00080365466,
+0.00088037323,
+0.00096255314,
+0.00105048984,
+0.00114431616,
+0.00124442333,
+0.00135110028,
+0.00146482687,
+0.00158570008,
+0.00171401864,
+0.00185023469,
+0.00199495023,
+0.00214785640,
+0.00231004250,
+0.00248134881,
+0.00266251224,
+0.00285378192,
+0.00305565330,
+0.00326841651,
+0.00349264755,
+0.00372874714,
+0.00397720048,
+0.00423829490,
+0.00451271003,
+0.00480085658,
+0.00510312291,
+0.00542017492,
+0.00575236930,
+0.00610029325,
+0.00646453211,
+0.00684553990,
+0.00724391919,
+0.00766016589,
+0.00809498038,
+0.00854881573,
+0.00902230106,
+0.00951600447,
+0.01003060210,
+0.01056654565,
+0.01112466771,
+0.01170534454,
+0.01230939943,
+0.01293735672,
+0.01358995494,
+0.01426773332,
+0.01497144438,
+0.01570170000,
+0.01645922661,
+0.01724460535,
+0.01805862412,
+0.01890186779,
+0.01977507770,
+0.02067894675,
+0.02161412500,
+0.02258131653,
+0.02358125709,
+0.02461459488,
+0.02568206564,
+0.02678431384,
+0.02792212367,
+0.02909611352,
+0.03030703776,
+0.03155555204,
+0.03284239396,
+0.03416819125,
+0.03553372994,
+0.03693958372,
+0.03838652745,
+0.03987516090,
+0.04140623659,
+0.04298033938,
+0.04459818453,
+0.04626038298,
+0.04796761274,
+0.04972046614,
+0.05151961371,
+0.05336561054,
+0.05525910854,
+0.05720067024,
+0.05919086933,
+0.06123027951,
+0.06331945211,
+0.06545893103,
+0.06764923781,
+0.06989086419,
+0.07218432426,
+0.07453006506,
+0.07692859322,
+0.07938029617,
+0.08188561350,
+0.08444493264,
+0.08705867827,
+0.08972713351,
+0.09245070815,
+0.09522963315,
+0.09806428105,
+0.10095486045,
+0.10390164703,
+0.10690483451,
+0.10996460915,
+0.11308115721,
+0.11625462025,
+0.11948505789,
+0.12277261168,
+0.12611730397,
+0.12951917946,
+0.13297818601,
+0.13649433851,
+0.14006754756,
+0.14369773865,
+0.14738474786,
+0.15112841129,
+0.15492856503,
+0.15878495574,
+0.16269733012,
+0.16666537523,
+0.17068879306,
+0.17476719618,
+0.17890018225,
+0.18308731914,
+0.18732811511,
+0.19162209332,
+0.19596865773,
+0.20036731660,
+0.20481738448,
+0.20931822062,
+0.21386915445,
+0.21846942604,
+0.22311829031,
+0.22781492770,
+0.23255851865,
+0.23734821379,
+0.24218304455,
+0.24706205726,
+0.25198432803,
+0.25694879889,
+0.26195442677,
+0.26700007915,
+0.27208462358,
+0.27720692754,
+0.28236576915,
+0.28755992651,
+0.29278811812,
+0.29804900289,
+0.30334126949,
+0.30866351724,
+0.31401440501,
+0.31939238310,
+0.32479602098,
+0.33022382855,
+0.33567428589,
+0.34114575386,
+0.34663668275,
+0.35214546323,
+0.35767036676,
+0.36320972443,
+0.36876192689,
+0.37432509661,
+0.37989753485,
+0.38547745347,
+0.39106300473,
+0.39665243030,
+0.40224379301,
+0.40783521533,
+0.41342487931,
+0.41901078820,
+0.42459106445,
+0.43016362190,
+0.43572667241,
+0.44127810001,
+0.44681602716,
+0.45233830810,
+0.45784294605,
+0.46332800388,
+0.46879136562,
+0.47423094511,
+0.47964480519,
+0.48503074050,
+0.49038675427,
+0.49571081996,
+0.50100076199,
+0.50625455379,
+0.51147013903,
+0.51664537191,
+0.52177828550,
+0.52686679363,
+0.53190881014,
+0.53690224886,
+0.54184508324,
+0.54673534632,
+0.55157101154,
+0.55634999275,
+0.56107026339,
+0.56572991610,
+0.57032698393,
+0.57485944033,
+0.57932555676,
+0.58372318745,
+0.58805054426,
+0.59230577946,
+0.59648692608,
+0.60059231520,
+0.60462015867,
+0.60856848955,
+0.61243581772,
+0.61622029543,
+0.61992025375,
+0.62353414297,
+0.62706029415,
+0.63049703836,
+0.63384294510,
+0.63709646463,
+0.64025616646,
+0.64332056046,
+0.64628833532,
+0.64915806055,
+0.65192854404,
+0.65459835529,
+0.65716648102,
+0.65963155031,
+0.66199249029,
+0.66424828768,
+0.66639786959,
+0.66844022274,
+0.67037439346,
+0.67219948769,
+0.67391467094,
+0.67551922798,
+0.67701220512,
+0.67839306593,
+0.67966115475,
+0.68081587553,
+0.68185669184,
+0.68278300762,
+0.68359452486,
+0.68429082632,
+0.68487155437,
+0.68533653021,
+0.68568539619,
+0.68591803312,
+0.68603444099,
+0.68603444099,
+0.68591803312,
+0.68568539619,
+0.68533653021,
+0.68487155437,
+0.68429082632,
+0.68359452486,
+0.68278300762,
+0.68185669184,
+0.68081587553,
+0.67966115475,
+0.67839306593,
+0.67701220512,
+0.67551922798,
+0.67391467094,
+0.67219948769,
+0.67037439346,
+0.66844022274,
+0.66639786959,
+0.66424828768,
+0.66199249029,
+0.65963155031,
+0.65716648102,
+0.65459835529,
+0.65192854404,
+0.64915806055,
+0.64628833532,
+0.64332056046,
+0.64025616646,
+0.63709646463,
+0.63384294510,
+0.63049703836,
+0.62706029415,
+0.62353414297,
+0.61992025375,
+0.61622029543,
+0.61243581772,
+0.60856848955,
+0.60462015867,
+0.60059231520,
+0.59648692608,
+0.59230577946,
+0.58805054426,
+0.58372318745,
+0.57932555676,
+0.57485944033,
+0.57032698393,
+0.56572991610,
+0.56107026339,
+0.55634999275,
+0.55157101154,
+0.54673534632,
+0.54184508324,
+0.53690224886,
+0.53190881014,
+0.52686679363,
+0.52177828550,
+0.51664537191,
+0.51147013903,
+0.50625455379,
+0.50100076199,
+0.49571081996,
+0.49038675427,
+0.48503074050,
+0.47964480519,
+0.47423094511,
+0.46879136562,
+0.46332800388,
+0.45784294605,
+0.45233830810,
+0.44681602716,
+0.44127810001,
+0.43572667241,
+0.43016362190,
+0.42459106445,
+0.41901078820,
+0.41342487931,
+0.40783521533,
+0.40224379301,
+0.39665243030,
+0.39106300473,
+0.38547745347,
+0.37989753485,
+0.37432509661,
+0.36876192689,
+0.36320972443,
+0.35767036676,
+0.35214546323,
+0.34663668275,
+0.34114575386,
+0.33567428589,
+0.33022382855,
+0.32479602098,
+0.31939238310,
+0.31401440501,
+0.30866351724,
+0.30334126949,
+0.29804900289,
+0.29278811812,
+0.28755992651,
+0.28236576915,
+0.27720692754,
+0.27208462358,
+0.26700007915,
+0.26195442677,
+0.25694879889,
+0.25198432803,
+0.24706205726,
+0.24218304455,
+0.23734821379,
+0.23255851865,
+0.22781492770,
+0.22311829031,
+0.21846942604,
+0.21386915445,
+0.20931822062,
+0.20481738448,
+0.20036731660,
+0.19596865773,
+0.19162209332,
+0.18732811511,
+0.18308731914,
+0.17890018225,
+0.17476719618,
+0.17068879306,
+0.16666537523,
+0.16269733012,
+0.15878495574,
+0.15492856503,
+0.15112841129,
+0.14738474786,
+0.14369773865,
+0.14006754756,
+0.13649433851,
+0.13297818601,
+0.12951917946,
+0.12611730397,
+0.12277261168,
+0.11948505789,
+0.11625462025,
+0.11308115721,
+0.10996460915,
+0.10690483451,
+0.10390164703,
+0.10095486045,
+0.09806428105,
+0.09522963315,
+0.09245070815,
+0.08972713351,
+0.08705867827,
+0.08444493264,
+0.08188561350,
+0.07938029617,
+0.07692859322,
+0.07453006506,
+0.07218432426,
+0.06989086419,
+0.06764923781,
+0.06545893103,
+0.06331945211,
+0.06123027951,
+0.05919086933,
+0.05720067024,
+0.05525910854,
+0.05336561054,
+0.05151961371,
+0.04972046614,
+0.04796761274,
+0.04626038298,
+0.04459818453,
+0.04298033938,
+0.04140623659,
+0.03987516090,
+0.03838652745,
+0.03693958372,
+0.03553372994,
+0.03416819125,
+0.03284239396,
+0.03155555204,
+0.03030703776,
+0.02909611352,
+0.02792212367,
+0.02678431384,
+0.02568206564,
+0.02461459488,
+0.02358125709,
+0.02258131653,
+0.02161412500,
+0.02067894675,
+0.01977507770,
+0.01890186779,
+0.01805862412,
+0.01724460535,
+0.01645922661,
+0.01570170000,
+0.01497144438,
+0.01426773332,
+0.01358995494,
+0.01293735672,
+0.01230939943,
+0.01170534454,
+0.01112466771,
+0.01056654565,
+0.01003060210,
+0.00951600447,
+0.00902230106,
+0.00854881573,
+0.00809498038,
+0.00766016589,
+0.00724391919,
+0.00684553990,
+0.00646453211,
+0.00610029325,
+0.00575236930,
+0.00542017492,
+0.00510312291,
+0.00480085658,
+0.00451271003,
+0.00423829490,
+0.00397720048,
+0.00372874714,
+0.00349264755,
+0.00326841651,
+0.00305565330,
+0.00285378192,
+0.00266251224,
+0.00248134881,
+0.00231004250,
+0.00214785640,
+0.00199495023,
+0.00185023469,
+0.00171401864,
+0.00158570008,
+0.00146482687,
+0.00135110028,
+0.00124442333,
+0.00114431616,
+0.00105048984,
+0.00096255314,
+0.00088037323,
+0.00080365466,
+0.00073179678,
+0.00066567765,
+0.00060277141,
+0.00054522208,
+0.00049204525,
+0.00044236859,
+0.00039634691,
+0.00035398375,
+0.00031519096,
+0.00027949660,
+0.00024667382,
+0.00021643363,
+0.00018878609,
+0.00016358691,
+0.00053168571
+};
+
+/* 10^-(dB/20), with dB beeing a list of dB values rangeing from 0 to -72 */
+/* do a 20*log10(dca_downmix_coeffs) to reconvert the values */
+
+static const float dca_downmix_coeffs[65] = {
+ 1.000000000000000, 0.988553094656939, 0.971627951577106, 0.944060876285923, 0.917275935389780, 0.891250938133746,
+ 0.865964323360065, 0.841395141645195, 0.817523037943650, 0.794328234724281, 0.771791515585012, 0.749894209332456,
+ 0.728618174513228, 0.707945784384138, 0.687859912308808, 0.668343917568615, 0.649381631576211, 0.630957344480193,
+ 0.613055792149821, 0.595662143529010, 0.578761988349121, 0.562341325190349, 0.546386549881854, 0.530884444230988,
+ 0.515822165072306, 0.501187233627272, 0.446683592150963, 0.398107170553497, 0.354813389233575, 0.316227766016838,
+ 0.281838293126445, 0.251188643150958, 0.223872113856834, 0.199526231496888, 0.177827941003892, 0.158489319246111,
+ 0.141253754462275, 0.125892541179417, 0.112201845430196, 0.100000000000000, 0.089125093813374, 0.079432823472428,
+ 0.070794578438414, 0.063095734448019, 0.053088444423099, 0.044668359215096, 0.037583740428844, 0.031622776601684,
+ 0.026607250597988, 0.022387211385683, 0.018836490894898, 0.015848931924611, 0.013335214321633, 0.011220184543020,
+ 0.009440608762859, 0.007943282347243, 0.005623413251903, 0.003981071705535, 0.002818382931264, 0.001995262314969,
+ 0.001412537544623, 0.001000000000000, 0.000501187233627, 0.000251188643151, 0.000000000000000,
+};
+
+/* downmix coeffs
+
+ TABLE 9
+______________________________________
+Down-mix coefficients for 8-channel source
+audio (5 + 3 format)
+ lt
+ cen- rt lt ctr rt
+lt ter ctr center
+ rt srd srd srd
+______________________________________
+1 0.71 0.74 1.0 0.71 0.71 0.58 0.58 0.58
+2 left 1.0 0.89 0.71 0.46 0.71 0.50
+ rt 0.45 0.71 0.89 1.0 0.50 0.71
+3 lt 1.0 0.89 0.71 0.45
+ rt 0.45 0.71 0.89 1.0
+ srd 0.71 0.71 0.71
+4 lt 1.0 0.89 0.71 0.45
+ rt 0.45 0.71 0.89 1.0
+ lt srd 1.0 0.71
+ rt srd 0.71 0.71
+4 lt 1.0 0.5
+ ctr 0.87 1.0 0.87
+ rt 0.5 1.0
+ srd 0.71 0.71 0.71
+5 lt 1.0 0.5
+ ctr 0.87 1.0 0.87
+ rt 0.5 1.0
+ lt srd 1.0 0.71
+ rt srd 0.71 1.0
+6 lt 1.0 0.5
+ lt ctr 0.87 0.71
+ rt ctr 0.71 0.87
+ rt 0.5 1.0
+ lt srd 1.0 0.71
+ rt srd 0.71 1.0
+6 lt 1.0 0.5
+ ctr 0.86 1.0 0.86
+ rt 0.5 1.0
+ lt srd 1.0
+ ctr srd 1.0
+ rt srd 1.0
+7 lt 1.0
+ lt ctr 1.0
+ ctr 1.0
+ rt ctr 1.0
+ rt 1.0
+ lt srd 1.0 0.71
+ rt srd 0.71 1.0
+7 lt 1.0 0.5
+ lt ctr 0.87 0.71
+ rt ctr 0.71 0.87
+ rt 0.5 1.0
+ lt srd 1.0
+ ctr srd 1.0
+ rt srd 1.0
+8 lt 1.0 0.5
+ lt ctr 0.87 0.71
+ rt ctr 0.71 0.87
+ rt 0.5 1.0
+ lt 1 srd 0.87 0.35
+ lt 2 srd 0.5 0.61
+ rt 2 srd 0.61 0.50
+ rt 2 srd 0.35 0.87
+
+ Generation of Lt Rt
+
+In the case when the playback system has analog or digital surround multi-channel capability, a down matrix from 5, 4, or 3 channel to Lt Rt may be desirable. In the case when the number of decoded audio channels exceeds 5, 4 or 3 respectively a first stage down mix to 5, 4 or 3 chs should be used as described above.
+
+The down matrixing equations for 5-channel source audio to a two-channel Lt Rt playback system are given by:
+
+Left left+0.7*center-0.7*(lt surround+rt surround)
+
+Right=right+0.7*center+0.7*(lt surround+rt surround)
+
+Embedded mixing to 2-channel
+
+One concern arising from the proliferation of multi-channel audio systems is that most home systems presently have only two channel playback capability. To accommodate this a fixed 2-channel down matrix processes is commonly used following the multi-channel decoding stage. However, for music only applications the image quality etc. of the down matrixed signal may not match that of an equivalent stereo recording found on CD.
+
+The concept of embedded mixing is to allow the producer to dynamically specify the matrixing coefficients within the audio frame itself. In this way the stereo down mix at the decoder may be better matched to a 2-channel playback environment.
+
+CHS*2, 7-bit down mix indexes (MCOEFFS) are transmitted along with the multi-channel audio once in every frame. The indexes are converted to attenuation factors using a 7 bit LUT. The 2-ch down mix equations are as follows,
+
+Left Ch=sum (MCOEFF[n]*Ch[n]) for n=1, CHS
+
+Right Ch sum (MCOEFF[n+CHS]*Ch[n]) for n=1, CHS
+
+where Ch(n) represents the subband samples in the (n)th audio channel.
+
+
+*/
diff --git a/contrib/ffmpeg/libavcodec/dcahuff.h b/contrib/ffmpeg/libavcodec/dcahuff.h
new file mode 100644
index 000000000..8a78aee7e
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/dcahuff.h
@@ -0,0 +1,1068 @@
+/*
+ * DCA compatible decoder - huffman tables
+ * Copyright (C) 2004 Gildas Bazin
+ * Copyright (C) 2007 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define TMODE_COUNT 4
+static const uint8_t tmode_vlc_bits[TMODE_COUNT] = { 3, 3, 3, 2 };
+static const uint16_t tmode_codes[TMODE_COUNT][4] = {
+ { 0x0000, 0x0002, 0x0006, 0x0007 },
+ { 0x0002, 0x0006, 0x0007, 0x0000 },
+ { 0x0006, 0x0007, 0x0000, 0x0002 },
+ { 0x0000, 0x0001, 0x0002, 0x0003 }
+};
+static const uint8_t tmode_bits[TMODE_COUNT][4] = {
+ { 1, 2, 3, 3 },
+ { 2, 3, 3, 1 },
+ { 3, 3, 1, 2 },
+ { 2, 2, 2, 2 }
+};
+
+
+#define BITALLOC_12_COUNT 5
+#define BITALLOC_12_VLC_BITS 9
+static const uint8_t bitalloc_12_vlc_bits[BITALLOC_12_COUNT] = {
+ 9, 7, 7, 9, 9
+};
+static const uint16_t bitalloc_12_codes[BITALLOC_12_COUNT][12] = {
+ {
+ 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, 0x00FF, 0x00FE,
+ 0x01FB, 0x01FA, 0x01F9, 0x01F8,
+ },
+ {
+ 0x0001, 0x0000, 0x0002, 0x000F, 0x000C, 0x001D, 0x0039, 0x0038,
+ 0x0037, 0x0036, 0x0035, 0x0034,
+ },
+ {
+ 0x0000, 0x0007, 0x0005, 0x0004, 0x0002, 0x000D, 0x000C, 0x0006,
+ 0x000F, 0x001D, 0x0039, 0x0038,
+ },
+ {
+ 0x0003, 0x0002, 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E,
+ 0x007E, 0x00FE, 0x01FF, 0x01FE,
+ },
+ {
+ 0x0001, 0x0000, 0x0002, 0x0006, 0x000E, 0x003F, 0x003D, 0x007C,
+ 0x0079, 0x0078, 0x00FB, 0x00FA,
+ }
+};
+static const uint8_t bitalloc_12_bits[BITALLOC_12_COUNT][12] = {
+ { 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 9, 9 },
+ { 1, 2, 3, 5, 5, 6, 7, 7, 7, 7, 7, 7 },
+ { 2, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 7 },
+ { 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10 },
+ { 1, 2, 3, 4, 5, 7, 7, 8, 8, 8, 9, 9 }
+};
+
+
+#define SCALES_COUNT 5
+#define SCALES_VLC_BITS 9
+static const uint16_t scales_codes[SCALES_COUNT][129] = {
+ {
+ 0x3AB0, 0x3AB2, 0x3AB4, 0x3AB6, 0x3AB8, 0x3ABA, 0x3ABC, 0x3ABE,
+ 0x3AC0, 0x3AC2, 0x3AC4, 0x3AC6, 0x3AC8, 0x3ACA, 0x3ACC, 0x3ACE,
+ 0x3AD0, 0x3AD2, 0x3AD4, 0x3AD6, 0x3AD8, 0x3ADA, 0x3ADC, 0x3ADE,
+ 0x3AE0, 0x3AE2, 0x3AE4, 0x3AE6, 0x3AE8, 0x3AEA, 0x3AEC, 0x3AEE,
+ 0x3AF0, 0x3AF2, 0x3AF4, 0x3AF6, 0x3AF8, 0x3AFA, 0x3AFC, 0x3AFE,
+ 0x0540, 0x0542, 0x0544, 0x0546, 0x0548, 0x054A, 0x054C, 0x054E,
+ 0x0558, 0x055E, 0x02AD, 0x0154, 0x0754, 0x03A8, 0x0056, 0x0028,
+ 0x00E8, 0x004A, 0x000B, 0x003B, 0x0013, 0x0003, 0x000F, 0x0005,
+ 0x0001, 0x0006, 0x0000, 0x0008, 0x001C, 0x0004, 0x0024, 0x004B,
+ 0x00E9, 0x0029, 0x0057, 0x03A9, 0x0755, 0x0155, 0x02AE, 0x055F,
+ 0x0559, 0x054F, 0x054D, 0x054B, 0x0549, 0x0547, 0x0545, 0x0543,
+ 0x0541, 0x3AFF, 0x3AFD, 0x3AFB, 0x3AF9, 0x3AF7, 0x3AF5, 0x3AF3,
+ 0x3AF1, 0x3AEF, 0x3AED, 0x3AEB, 0x3AE9, 0x3AE7, 0x3AE5, 0x3AE3,
+ 0x3AE1, 0x3ADF, 0x3ADD, 0x3ADB, 0x3AD9, 0x3AD7, 0x3AD5, 0x3AD3,
+ 0x3AD1, 0x3ACF, 0x3ACD, 0x3ACB, 0x3AC9, 0x3AC7, 0x3AC5, 0x3AC3,
+ 0x3AC1, 0x3ABF, 0x3ABD, 0x3ABB, 0x3AB9, 0x3AB7, 0x3AB5, 0x3AB3,
+ 0x3AB1,
+ },
+ {
+ 0x0F60, 0x0F62, 0x0F64, 0x0F66, 0x0F68, 0x0F6A, 0x0F6C, 0x0F6E,
+ 0x0F70, 0x0F72, 0x0F74, 0x0F76, 0x0F78, 0x0F7A, 0x0F7C, 0x0F7E,
+ 0x0F80, 0x0F82, 0x0F84, 0x0F86, 0x0F88, 0x0F8A, 0x0F8C, 0x0F8E,
+ 0x0F90, 0x0F92, 0x0F94, 0x0F96, 0x0F98, 0x0F9A, 0x0F9C, 0x0F9E,
+ 0x0FA0, 0x0FA2, 0x0FA4, 0x0FA6, 0x0FA8, 0x0FAA, 0x0FAC, 0x0FAE,
+ 0x0FB0, 0x0FB2, 0x0FB4, 0x0FB6, 0x0FB8, 0x0FBA, 0x0FBC, 0x0FBE,
+ 0x07A0, 0x07A2, 0x03D2, 0x01EA, 0x00FC, 0x007F, 0x001C, 0x000C,
+ 0x0004, 0x0034, 0x0010, 0x001B, 0x0009, 0x000B, 0x000E, 0x0001,
+ 0x0003, 0x0002, 0x000F, 0x000C, 0x000A, 0x0000, 0x0011, 0x0035,
+ 0x0005, 0x000D, 0x001D, 0x003C, 0x00FD, 0x01EB, 0x03D3, 0x07A3,
+ 0x07A1, 0x0FBF, 0x0FBD, 0x0FBB, 0x0FB9, 0x0FB7, 0x0FB5, 0x0FB3,
+ 0x0FB1, 0x0FAF, 0x0FAD, 0x0FAB, 0x0FA9, 0x0FA7, 0x0FA5, 0x0FA3,
+ 0x0FA1, 0x0F9F, 0x0F9D, 0x0F9B, 0x0F99, 0x0F97, 0x0F95, 0x0F93,
+ 0x0F91, 0x0F8F, 0x0F8D, 0x0F8B, 0x0F89, 0x0F87, 0x0F85, 0x0F83,
+ 0x0F81, 0x0F7F, 0x0F7D, 0x0F7B, 0x0F79, 0x0F77, 0x0F75, 0x0F73,
+ 0x0F71, 0x0F6F, 0x0F6D, 0x0F6B, 0x0F69, 0x0F67, 0x0F65, 0x0F63,
+ 0x0F61,
+ },
+ {
+ 0x51D0, 0x51D2, 0x51D4, 0x51D6, 0x51D8, 0x51DA, 0x51DC, 0x51DE,
+ 0x51E0, 0x51E2, 0x51E4, 0x51E6, 0x51E8, 0x51EA, 0x51EC, 0x51EE,
+ 0x51F0, 0x51F2, 0x51F4, 0x51F6, 0x51F8, 0x51FA, 0x51FC, 0x51FE,
+ 0x70C0, 0x70C2, 0x70C4, 0x70C6, 0x70C8, 0x70CA, 0x70CC, 0x70CE,
+ 0x70EC, 0x10EA, 0x3868, 0x3877, 0x0876, 0x1C35, 0x0434, 0x0A34,
+ 0x0E1B, 0x021B, 0x051B, 0x070F, 0x010F, 0x0380, 0x0080, 0x0140,
+ 0x01C1, 0x0041, 0x00A1, 0x00E2, 0x0022, 0x0052, 0x0072, 0x0012,
+ 0x002A, 0x003A, 0x000A, 0x0016, 0x001E, 0x0006, 0x000C, 0x0000,
+ 0x0004, 0x0001, 0x000D, 0x0007, 0x001F, 0x0017, 0x000B, 0x003B,
+ 0x002B, 0x0013, 0x0073, 0x0053, 0x0023, 0x00E3, 0x00A2, 0x0042,
+ 0x01C2, 0x0141, 0x0081, 0x0381, 0x028C, 0x010C, 0x051C, 0x021C,
+ 0x0E1C, 0x0A35, 0x0435, 0x1C3A, 0x0877, 0x0874, 0x3869, 0x10EB,
+ 0x70ED, 0x70CF, 0x70CD, 0x70CB, 0x70C9, 0x70C7, 0x70C5, 0x70C3,
+ 0x70C1, 0x51FF, 0x51FD, 0x51FB, 0x51F9, 0x51F7, 0x51F5, 0x51F3,
+ 0x51F1, 0x51EF, 0x51ED, 0x51EB, 0x51E9, 0x51E7, 0x51E5, 0x51E3,
+ 0x51E1, 0x51DF, 0x51DD, 0x51DB, 0x51D9, 0x51D7, 0x51D5, 0x51D3,
+ 0x51D1,
+ },
+ {
+ 0x6F64, 0x6F66, 0x6F68, 0x6F6A, 0x6F6C, 0x6F6E, 0x6F70, 0x6F72,
+ 0x6F74, 0x6F76, 0x6F78, 0x6F7A, 0x6F7C, 0x6F7E, 0x6F80, 0x6F82,
+ 0x6F84, 0x6F86, 0x6F88, 0x6F8A, 0x6F8C, 0x6F8E, 0x6F90, 0x6F92,
+ 0x6F94, 0x6F96, 0x6F98, 0x6F9A, 0x6F9C, 0x6F9E, 0x6FA0, 0x6FA2,
+ 0x6FA4, 0x6FA6, 0x6FA8, 0x6FAA, 0x6FAC, 0x6FAE, 0x6FB0, 0x6FB2,
+ 0x6FB4, 0x6FB6, 0x17B4, 0x37DC, 0x0BDB, 0x1BEF, 0x05EE, 0x0DF8,
+ 0x02F8, 0x06FD, 0x017D, 0x037F, 0x00BF, 0x0040, 0x00C0, 0x0021,
+ 0x0061, 0x0011, 0x0031, 0x0009, 0x0019, 0x0006, 0x000E, 0x0004,
+ 0x0000, 0x0005, 0x000F, 0x0007, 0x001A, 0x000A, 0x0036, 0x0016,
+ 0x006E, 0x002E, 0x00C1, 0x0041, 0x01BC, 0x00BC, 0x037A, 0x017A,
+ 0x02F9, 0x0DF9, 0x05EF, 0x05EC, 0x1BD8, 0x37DD, 0x17B5, 0x6FB7,
+ 0x6FB5, 0x6FB3, 0x6FB1, 0x6FAF, 0x6FAD, 0x6FAB, 0x6FA9, 0x6FA7,
+ 0x6FA5, 0x6FA3, 0x6FA1, 0x6F9F, 0x6F9D, 0x6F9B, 0x6F99, 0x6F97,
+ 0x6F95, 0x6F93, 0x6F91, 0x6F8F, 0x6F8D, 0x6F8B, 0x6F89, 0x6F87,
+ 0x6F85, 0x6F83, 0x6F81, 0x6F7F, 0x6F7D, 0x6F7B, 0x6F79, 0x6F77,
+ 0x6F75, 0x6F73, 0x6F71, 0x6F6F, 0x6F6D, 0x6F6B, 0x6F69, 0x6F67,
+ 0x6F65,
+ },
+ {
+ 0xDF54, 0xDF56, 0xDFC8, 0xDFCA, 0xDFCC, 0xDFCE, 0xDFD0, 0xDFD2,
+ 0xDFD4, 0xDFD6, 0xDFD8, 0xDFDA, 0xDFDC, 0xDFDE, 0xDFE0, 0xDFE2,
+ 0x0FE8, 0x2FEA, 0x6FA8, 0x6FF6, 0x07F5, 0x07F7, 0x37D2, 0x37F9,
+ 0x03F8, 0x0BF8, 0x0BFB, 0x1BEB, 0x01FA, 0x05FA, 0x09FA, 0x0DFA,
+ 0x0DFF, 0x00FF, 0x02FF, 0x06FB, 0x007C, 0x017C, 0x027C, 0x027F,
+ 0x003C, 0x00BC, 0x013C, 0x01BC, 0x001C, 0x005C, 0x009C, 0x00DC,
+ 0x000C, 0x002C, 0x004C, 0x006C, 0x0004, 0x0014, 0x0024, 0x0034,
+ 0x0000, 0x0008, 0x0010, 0x0018, 0x001E, 0x0002, 0x0006, 0x000A,
+ 0x000E, 0x000B, 0x0007, 0x0003, 0x001F, 0x0019, 0x0011, 0x0009,
+ 0x0001, 0x0035, 0x0025, 0x0015, 0x0005, 0x006D, 0x004D, 0x002D,
+ 0x000D, 0x00DD, 0x009D, 0x005D, 0x001D, 0x01BD, 0x013D, 0x00BD,
+ 0x003D, 0x037C, 0x027D, 0x017D, 0x007D, 0x06FC, 0x04FC, 0x02FC,
+ 0x00FC, 0x0DFB, 0x09FB, 0x05FB, 0x01FB, 0x1BF8, 0x1BE8, 0x0BF9,
+ 0x03F9, 0x37FA, 0x37D3, 0x17F4, 0x07F6, 0x6FF7, 0x6FA9, 0x2FEB,
+ 0x0FE9, 0xDFE3, 0xDFE1, 0xDFDF, 0xDFDD, 0xDFDB, 0xDFD9, 0xDFD7,
+ 0xDFD5, 0xDFD3, 0xDFD1, 0xDFCF, 0xDFCD, 0xDFCB, 0xDFC9, 0xDF57,
+ 0xDF55,
+ }
+};
+
+static const uint8_t scales_bits[SCALES_COUNT][129] = {
+ {
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 12, 11, 11, 10, 9, 8,
+ 8, 7, 6, 6, 5, 4, 4, 3,
+ 2, 3, 3, 4, 5, 5, 6, 7,
+ 8, 8, 9, 10, 11, 11, 12, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14,
+ 14,
+ },
+ {
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 14, 14, 13, 12, 11, 10, 8, 7,
+ 6, 6, 5, 5, 4, 4, 4, 3,
+ 3, 3, 4, 4, 4, 4, 5, 6,
+ 6, 7, 8, 9, 11, 12, 13, 14,
+ 14, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15,
+ },
+ {
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 14, 14, 14, 13, 13, 12, 12,
+ 12, 11, 11, 11, 10, 10, 9, 9,
+ 9, 8, 8, 8, 7, 7, 7, 6,
+ 6, 6, 5, 5, 5, 4, 4, 3,
+ 3, 3, 4, 4, 5, 5, 5, 6,
+ 6, 6, 7, 7, 7, 8, 8, 8,
+ 9, 9, 9, 10, 10, 10, 11, 11,
+ 12, 12, 12, 13, 13, 13, 14, 14,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15,
+ },
+ {
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 14, 14, 13, 13, 12, 12,
+ 11, 11, 10, 10, 9, 8, 8, 7,
+ 7, 6, 6, 5, 5, 4, 4, 3,
+ 2, 3, 4, 4, 5, 5, 6, 6,
+ 7, 7, 8, 8, 9, 9, 10, 10,
+ 11, 12, 12, 12, 13, 14, 14, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15,
+ 15,
+ },
+ {
+ 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16,
+ 15, 15, 15, 15, 14, 14, 14, 14,
+ 13, 13, 13, 13, 12, 12, 12, 12,
+ 12, 11, 11, 11, 10, 10, 10, 10,
+ 9, 9, 9, 9, 8, 8, 8, 8,
+ 7, 7, 7, 7, 6, 6, 6, 6,
+ 5, 5, 5, 5, 5, 4, 4, 4,
+ 4, 4, 4, 4, 5, 5, 5, 5,
+ 5, 6, 6, 6, 6, 7, 7, 7,
+ 7, 8, 8, 8, 8, 9, 9, 9,
+ 9, 10, 10, 10, 10, 11, 11, 11,
+ 11, 12, 12, 12, 12, 13, 13, 13,
+ 13, 14, 14, 14, 14, 15, 15, 15,
+ 15, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16,
+ 16,
+ }
+};
+
+static const uint16_t bitalloc_3_codes[3] =
+{
+ 0x0003, 0x0000, 0x0002,
+};
+static const uint8_t bitalloc_3_bits[3] =
+{
+ 2, 1, 2,
+};
+
+static const uint16_t bitalloc_5_codes_a[5] =
+{
+ 0x000F, 0x0006, 0x0000, 0x0002, 0x000E,
+};
+static const uint16_t bitalloc_5_codes_b[5] =
+{
+ 0x0007, 0x0001, 0x0002, 0x0000, 0x0006,
+};
+static const uint16_t bitalloc_5_codes_c[5] =
+{
+ 0x0007, 0x0005, 0x0000, 0x0004, 0x0006,
+};
+static const uint8_t bitalloc_5_bits_a[5] =
+{
+ 4, 3, 1, 2, 4,
+};
+static const uint8_t bitalloc_5_bits_b[5] =
+{
+ 3, 2, 2, 2, 3,
+};
+static const uint8_t bitalloc_5_bits_c[5] =
+{
+ 3, 3, 1, 3, 3,
+};
+
+static const uint16_t bitalloc_7_codes_a[7] =
+{
+ 0x001E, 0x000E, 0x0005, 0x0000, 0x0006, 0x0004, 0x001F,
+};
+static const uint16_t bitalloc_7_codes_b[7] =
+{
+ 0x0014, 0x000B, 0x0000, 0x0003, 0x0001, 0x0004, 0x0015,
+};
+static const uint16_t bitalloc_7_codes_c[7] =
+{
+ 0x0000, 0x0002, 0x0001, 0x0003, 0x0002, 0x0003, 0x0001,
+};
+static const uint8_t bitalloc_7_bits_a[7] =
+{
+ 5, 4, 3, 1, 3, 3, 5,
+};
+static const uint8_t bitalloc_7_bits_b[7] =
+{
+ 5, 4, 2, 2, 2, 3, 5,
+};
+static const uint8_t bitalloc_7_bits_c[7] =
+{
+ 4, 4, 2, 2, 2, 4, 4,
+};
+
+static const uint16_t bitalloc_9_codes_a[9] =
+{
+ 0x0030, 0x0019, 0x0009, 0x0005, 0x0000, 0x0007, 0x000D, 0x0008,
+ 0x0031,
+};
+static const uint16_t bitalloc_9_codes_b[9] =
+{
+ 0x0018, 0x001A, 0x0002, 0x0007, 0x0002, 0x0000, 0x0003, 0x001B,
+ 0x0019,
+};
+static const uint16_t bitalloc_9_codes_c[9] =
+{
+ 0x001C, 0x000F, 0x0002, 0x0007, 0x0002, 0x0000, 0x0006, 0x0006,
+ 0x001D,
+};
+static const uint8_t bitalloc_9_bits_a[9] =
+{
+ 6, 5, 4, 3, 1, 3, 4, 4, 6,
+};
+static const uint8_t bitalloc_9_bits_b[9] =
+{
+ 5, 5, 3, 3, 2, 2, 3, 5, 5,
+};
+static const uint8_t bitalloc_9_bits_c[9] =
+{
+ 6, 5, 3, 3, 2, 2, 3, 4, 6,
+};
+
+static const uint16_t bitalloc_13_codes_a[13] =
+{
+ 0x0070, 0x002E, 0x0039, 0x001D, 0x000C, 0x000F, 0x0000, 0x0004,
+ 0x000D, 0x000A, 0x0016, 0x002F, 0x0071,
+};
+static const uint16_t bitalloc_13_codes_b[13] =
+{
+ 0x0038, 0x0010, 0x001D, 0x0007, 0x000F, 0x0005, 0x0000, 0x0006,
+ 0x0002, 0x0009, 0x0006, 0x0011, 0x0039,
+};
+static const uint16_t bitalloc_13_codes_c[13] =
+{
+ 0x0004, 0x001A, 0x0003, 0x000E, 0x0000, 0x0003, 0x0005, 0x0004,
+ 0x0002, 0x000F, 0x000C, 0x001B, 0x0005,
+};
+static const uint8_t bitalloc_13_bits_a[13] =
+{
+ 7, 6, 6, 5, 4, 4, 1, 3, 4, 4, 5, 6, 7,
+};
+static const uint8_t bitalloc_13_bits_b[13] =
+{
+ 6, 5, 5, 4, 4, 3, 2, 3, 3, 4, 4, 5, 6,
+};
+static const uint8_t bitalloc_13_bits_c[13] =
+{
+ 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5,
+};
+
+static const uint16_t bitalloc_17_codes_a[17] =
+{
+ 0x0154, 0x00AB, 0x002B, 0x000B, 0x0003, 0x000A, 0x0001, 0x0006,
+ 0x0001, 0x0007, 0x0004, 0x000B, 0x0000, 0x0004, 0x0014, 0x0054,
+ 0x0155,
+};
+static const uint16_t bitalloc_17_codes_b[17] =
+{
+ 0x007C, 0x003F, 0x0019, 0x000D, 0x001C, 0x0008, 0x000F, 0x0005,
+ 0x0000, 0x0006, 0x0002, 0x0009, 0x001D, 0x000E, 0x001E, 0x0018,
+ 0x007D,
+};
+static const uint16_t bitalloc_17_codes_c[17] =
+{
+ 0x002C, 0x0017, 0x0005, 0x001C, 0x0003, 0x000A, 0x000F, 0x0003,
+ 0x0006, 0x0004, 0x0000, 0x000B, 0x0004, 0x001D, 0x000A, 0x0004,
+ 0x002D,
+};
+static const uint16_t bitalloc_17_codes_d[17] =
+{
+ 0x0100, 0x0102, 0x0082, 0x0042, 0x0022, 0x0012, 0x000A, 0x0006,
+ 0x0000, 0x0007, 0x000B, 0x0013, 0x0023, 0x0043, 0x0083, 0x0103,
+ 0x0101,
+};
+static const uint16_t bitalloc_17_codes_e[17] =
+{
+ 0x00E8, 0x00F6, 0x0075, 0x0034, 0x003B, 0x001B, 0x001F, 0x0004,
+ 0x0000, 0x0005, 0x000C, 0x001C, 0x003C, 0x0035, 0x007A, 0x00F7,
+ 0x00E9,
+};
+static const uint16_t bitalloc_17_codes_f[17] =
+{
+ 0x0004, 0x0003, 0x001E, 0x0001, 0x0001, 0x000E, 0x0001, 0x0004,
+ 0x0006, 0x0005, 0x0002, 0x000F, 0x0006, 0x000E, 0x001F, 0x0000,
+ 0x0005,
+};
+static const uint16_t bitalloc_17_codes_g[17] =
+{
+ 0x0060, 0x007E, 0x0031, 0x0019, 0x000D, 0x0004, 0x0000, 0x0006,
+ 0x0002, 0x0007, 0x0001, 0x0005, 0x000E, 0x001E, 0x003E, 0x007F,
+ 0x0061,
+};
+static const uint8_t bitalloc_17_bits_a[17] =
+{
+ 12, 11, 9, 7, 5, 4, 3, 3, 2, 3, 3, 4, 4, 6, 8, 10,
+ 12,
+};
+static const uint8_t bitalloc_17_bits_b[17] =
+{
+ 8, 7, 6, 5, 5, 4, 4, 3, 2, 3, 3, 4, 5, 5, 6, 6,
+ 8,
+};
+static const uint8_t bitalloc_17_bits_c[17] =
+{
+ 7, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 5, 5, 5,
+ 7,
+};
+static const uint8_t bitalloc_17_bits_d[17] =
+{
+ 9, 9, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, 8, 9,
+ 9,
+};
+static const uint8_t bitalloc_17_bits_e[17] =
+{
+ 8, 8, 7, 6, 6, 5, 5, 3, 1, 3, 4, 5, 6, 6, 7, 8,
+ 8,
+};
+static const uint8_t bitalloc_17_bits_f[17] =
+{
+ 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6,
+ 8,
+};
+static const uint8_t bitalloc_17_bits_g[17] =
+{
+ 8, 8, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4, 5, 6, 7, 8,
+ 8,
+};
+
+static const uint16_t bitalloc_25_codes_a[25] =
+{
+ 0x2854, 0x142B, 0x050B, 0x0143, 0x00A2, 0x0052, 0x002E, 0x0015,
+ 0x0004, 0x000E, 0x0000, 0x0003, 0x0006, 0x0004, 0x0001, 0x000F,
+ 0x0005, 0x0016, 0x002F, 0x0053, 0x00A3, 0x00A0, 0x0284, 0x0A14,
+ 0x2855,
+};
+static const uint16_t bitalloc_25_codes_b[25] =
+{
+ 0x001C, 0x000F, 0x0005, 0x0000, 0x0030, 0x0036, 0x000E, 0x0019,
+ 0x0001, 0x0008, 0x000E, 0x0001, 0x0005, 0x0002, 0x000F, 0x0009,
+ 0x0006, 0x001A, 0x000F, 0x0037, 0x0031, 0x0001, 0x0006, 0x0004,
+ 0x001D,
+};
+static const uint16_t bitalloc_25_codes_c[25] =
+{
+ 0x004C, 0x0027, 0x006D, 0x0028, 0x0037, 0x000E, 0x0015, 0x0000,
+ 0x0005, 0x0008, 0x000B, 0x000E, 0x0001, 0x000F, 0x000C, 0x0009,
+ 0x0006, 0x0001, 0x001A, 0x000F, 0x0008, 0x0029, 0x0012, 0x006C,
+ 0x004D,
+};
+static const uint16_t bitalloc_25_codes_d[25] =
+{
+ 0x0780, 0x0782, 0x03C2, 0x01E2, 0x00FE, 0x0079, 0x003D, 0x001C,
+ 0x000C, 0x0004, 0x0000, 0x0006, 0x0002, 0x0007, 0x0001, 0x0005,
+ 0x000D, 0x001D, 0x003E, 0x007E, 0x00FF, 0x01E3, 0x03C3, 0x0783,
+ 0x0781,
+};
+static const uint16_t bitalloc_25_codes_e[25] =
+{
+ 0x003C, 0x0092, 0x0018, 0x001F, 0x004E, 0x000D, 0x0025, 0x0004,
+ 0x0010, 0x0000, 0x000A, 0x0002, 0x0003, 0x0003, 0x000B, 0x0001,
+ 0x0011, 0x0005, 0x0026, 0x000E, 0x004F, 0x0048, 0x0019, 0x0093,
+ 0x003D,
+};
+static const uint16_t bitalloc_25_codes_f[25] =
+{
+ 0x0324, 0x0193, 0x00CE, 0x0065, 0x0024, 0x000C, 0x0013, 0x0004,
+ 0x0007, 0x000A, 0x000D, 0x000F, 0x0001, 0x0000, 0x000E, 0x000B,
+ 0x0008, 0x0005, 0x0018, 0x000D, 0x0025, 0x0066, 0x00CF, 0x00C8,
+ 0x0325,
+};
+static const uint16_t bitalloc_25_codes_g[25] =
+{
+ 0x03A8, 0x03AE, 0x01D5, 0x0094, 0x0014, 0x004B, 0x000B, 0x003B,
+ 0x0013, 0x0003, 0x000F, 0x0005, 0x0001, 0x0006, 0x0000, 0x0008,
+ 0x001C, 0x0004, 0x0024, 0x0074, 0x0015, 0x0095, 0x01D6, 0x03AF,
+ 0x03A9,
+};
+static const uint8_t bitalloc_25_bits_a[25] =
+{
+ 14, 13, 11, 9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 4,
+ 4, 5, 6, 7, 8, 8, 10, 12, 14,
+};
+static const uint8_t bitalloc_25_bits_b[25] =
+{
+ 9, 8, 7, 6, 6, 6, 5, 5, 4, 4, 4, 3, 3, 3, 4, 4,
+ 4, 5, 5, 6, 6, 6, 7, 7, 9,
+};
+static const uint8_t bitalloc_25_bits_c[25] =
+{
+ 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 4, 4, 3, 4, 4, 4,
+ 4, 4, 5, 5, 5, 6, 6, 7, 8,
+};
+static const uint8_t bitalloc_25_bits_d[25] =
+{
+ 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 12,
+};
+static const uint8_t bitalloc_25_bits_e[25] =
+{
+ 8, 8, 7, 7, 7, 6, 6, 5, 5, 4, 4, 3, 2, 3, 4, 4,
+ 5, 5, 6, 6, 7, 7, 7, 8, 8,
+};
+static const uint8_t bitalloc_25_bits_f[25] =
+{
+ 10, 9, 8, 7, 6, 5, 5, 4, 4, 4, 4, 4, 3, 3, 4, 4,
+ 4, 4, 5, 5, 6, 7, 8, 8, 10,
+};
+static const uint8_t bitalloc_25_bits_g[25] =
+{
+ 10, 10, 9, 8, 7, 7, 6, 6, 5, 4, 4, 3, 2, 3, 3, 4,
+ 5, 5, 6, 7, 7, 8, 9, 10, 10,
+};
+
+static const uint16_t bitalloc_33_codes_a[33] =
+{
+ 0x1580, 0x1582, 0x0AC2, 0x0562, 0x02B2, 0x015E, 0x00AD, 0x0054,
+ 0x001C, 0x003C, 0x000F, 0x001F, 0x0008, 0x000B, 0x000D, 0x0000,
+ 0x0002, 0x0001, 0x000E, 0x000C, 0x0009, 0x0006, 0x0014, 0x003D,
+ 0x001D, 0x0055, 0x00AE, 0x015F, 0x02B3, 0x0563, 0x0AC3, 0x1583,
+ 0x1581,
+};
+static const uint16_t bitalloc_33_codes_b[33] =
+{
+ 0x030C, 0x0187, 0x006D, 0x0028, 0x0037, 0x0066, 0x0015, 0x0031,
+ 0x0000, 0x000B, 0x0012, 0x001A, 0x0001, 0x0007, 0x000A, 0x000E,
+ 0x0001, 0x000F, 0x000B, 0x0008, 0x0004, 0x001B, 0x0013, 0x000C,
+ 0x0001, 0x0032, 0x001A, 0x0067, 0x0060, 0x0029, 0x00C2, 0x006C,
+ 0x030D,
+};
+static const uint16_t bitalloc_33_codes_c[33] =
+{
+ 0x00CC, 0x0067, 0x0005, 0x0070, 0x0003, 0x001A, 0x0039, 0x003F,
+ 0x000A, 0x0012, 0x0018, 0x001D, 0x0001, 0x0003, 0x0007, 0x000A,
+ 0x000D, 0x000B, 0x0008, 0x0004, 0x0002, 0x001E, 0x0019, 0x0013,
+ 0x000B, 0x0000, 0x003E, 0x001B, 0x0018, 0x0071, 0x0032, 0x0004,
+ 0x00CD,
+};
+static const uint16_t bitalloc_33_codes_d[33] =
+{
+ 0x3AF8, 0x3AFA, 0x1D7E, 0x0EBC, 0x075C, 0x03AC, 0x01D4, 0x0094,
+ 0x0014, 0x004B, 0x000B, 0x003B, 0x0013, 0x0003, 0x000F, 0x0005,
+ 0x0001, 0x0006, 0x0000, 0x0008, 0x001C, 0x0004, 0x0024, 0x0074,
+ 0x0015, 0x0095, 0x01D5, 0x03AD, 0x075D, 0x0EBD, 0x1D7F, 0x3AFB,
+ 0x3AF9,
+};
+static const uint16_t bitalloc_33_codes_e[33] =
+{
+ 0x01C8, 0x01E6, 0x0064, 0x00E2, 0x00E5, 0x0030, 0x0033, 0x0073,
+ 0x007A, 0x001A, 0x003A, 0x0002, 0x001A, 0x001F, 0x0007, 0x0001,
+ 0x0002, 0x0002, 0x000C, 0x0000, 0x001B, 0x0003, 0x003B, 0x001B,
+ 0x007B, 0x0078, 0x0070, 0x0031, 0x00F2, 0x00E3, 0x0065, 0x01E7,
+ 0x01C9,
+};
+static const uint16_t bitalloc_33_codes_f[33] =
+{
+ 0x0724, 0x0393, 0x01CE, 0x00E5, 0x002C, 0x0008, 0x0017, 0x003E,
+ 0x0005, 0x0014, 0x001D, 0x0000, 0x0003, 0x0006, 0x0008, 0x000B,
+ 0x000D, 0x000C, 0x0009, 0x0007, 0x0004, 0x0001, 0x001E, 0x0015,
+ 0x000A, 0x003F, 0x0038, 0x0009, 0x002D, 0x00E6, 0x01CF, 0x01C8,
+ 0x0725,
+};
+static const uint16_t bitalloc_33_codes_g[33] =
+{
+ 0x0284, 0x0042, 0x0140, 0x0143, 0x003E, 0x00BE, 0x0011, 0x0051,
+ 0x0009, 0x0029, 0x0005, 0x0015, 0x0000, 0x0008, 0x000E, 0x0002,
+ 0x0006, 0x0003, 0x000F, 0x0009, 0x0001, 0x0016, 0x0006, 0x002E,
+ 0x000E, 0x005E, 0x001E, 0x00BF, 0x003F, 0x0020, 0x0141, 0x0043,
+ 0x0285,
+};
+static const uint8_t bitalloc_33_bits_a[33] =
+{
+ 13, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4, 3,
+ 3, 3, 4, 4, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13,
+ 13,
+};
+static const uint8_t bitalloc_33_bits_b[33] =
+{
+ 10, 9, 8, 7, 7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4,
+ 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8,
+ 10,
+};
+static const uint8_t bitalloc_33_bits_c[33] =
+{
+ 9, 8, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7,
+ 9,
+};
+static const uint8_t bitalloc_33_bits_d[33] =
+{
+ 14, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 5, 4, 4, 3,
+ 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14,
+ 14,
+};
+static const uint8_t bitalloc_33_bits_e[33] =
+{
+ 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 5, 5, 5, 4, 3,
+ 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9,
+ 9,
+};
+static const uint8_t bitalloc_33_bits_f[33] =
+{
+ 11, 10, 9, 8, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9,
+ 11,
+};
+static const uint8_t bitalloc_33_bits_g[33] =
+{
+ 10, 9, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3,
+ 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9,
+ 10,
+};
+
+static const uint16_t bitalloc_65_codes_a[65] =
+{
+ 0x9E5C, 0x9E5E, 0x4F2C, 0x2794, 0x13C4, 0x1E44, 0x09E3, 0x0F23,
+ 0x04F3, 0x0792, 0x027E, 0x03CE, 0x013D, 0x01E5, 0x009C, 0x00CC,
+ 0x0040, 0x0058, 0x0067, 0x001E, 0x0021, 0x002D, 0x003D, 0x0007,
+ 0x0011, 0x0014, 0x0017, 0x001A, 0x001C, 0x001F, 0x0001, 0x0004,
+ 0x0006, 0x0005, 0x0002, 0x0000, 0x001D, 0x001B, 0x0018, 0x0015,
+ 0x0012, 0x000E, 0x0006, 0x0032, 0x0026, 0x001F, 0x0078, 0x0059,
+ 0x0041, 0x00CD, 0x009D, 0x01E6, 0x013E, 0x03CF, 0x027F, 0x0793,
+ 0x0790, 0x04F0, 0x09E4, 0x1E45, 0x13C5, 0x2795, 0x4F2D, 0x9E5F,
+ 0x9E5D,
+};
+static const uint16_t bitalloc_65_codes_b[65] =
+{
+ 0x0A8C, 0x0547, 0x01B5, 0x0008, 0x00DB, 0x0152, 0x0005, 0x000B,
+ 0x008E, 0x00AE, 0x00E4, 0x0003, 0x0037, 0x0039, 0x0055, 0x006C,
+ 0x0073, 0x0003, 0x0015, 0x001D, 0x0028, 0x0030, 0x0037, 0x003E,
+ 0x0006, 0x000B, 0x000F, 0x0012, 0x0016, 0x0019, 0x001D, 0x0001,
+ 0x0004, 0x0002, 0x001E, 0x001A, 0x0017, 0x0013, 0x0010, 0x000C,
+ 0x0007, 0x003F, 0x0038, 0x0031, 0x0029, 0x0022, 0x001A, 0x0014,
+ 0x0000, 0x006D, 0x0056, 0x0046, 0x0038, 0x0004, 0x00E5, 0x00AF,
+ 0x008F, 0x006C, 0x000A, 0x0153, 0x0150, 0x0009, 0x02A2, 0x01B4,
+ 0x0A8D,
+};
+static const uint16_t bitalloc_65_codes_c[65] =
+{
+ 0x045C, 0x022F, 0x03F5, 0x01BC, 0x01FB, 0x0059, 0x00D0, 0x00DF,
+ 0x000A, 0x002D, 0x002F, 0x0052, 0x0069, 0x0078, 0x007F, 0x000A,
+ 0x0010, 0x001C, 0x0023, 0x002A, 0x0035, 0x003A, 0x003D, 0x0000,
+ 0x0003, 0x0006, 0x0009, 0x000C, 0x000F, 0x0012, 0x0016, 0x0018,
+ 0x001C, 0x0019, 0x0017, 0x0013, 0x0010, 0x000D, 0x000A, 0x0007,
+ 0x0004, 0x0001, 0x003E, 0x003B, 0x0036, 0x002B, 0x0028, 0x001D,
+ 0x0011, 0x000B, 0x0004, 0x0079, 0x006E, 0x0053, 0x0044, 0x002E,
+ 0x000B, 0x00FC, 0x00D1, 0x008A, 0x0058, 0x01BD, 0x0116, 0x03F4,
+ 0x045D,
+};
+static const uint16_t bitalloc_65_codes_d[65] =
+{
+ 0x70B0, 0x70B2, 0x70B4, 0x2852, 0x385B, 0x142E, 0x1C2E, 0x0A15,
+ 0x0E14, 0x0214, 0x0704, 0x0104, 0x010B, 0x0383, 0x0083, 0x0143,
+ 0x01C3, 0x0043, 0x00A2, 0x00E2, 0x0022, 0x0052, 0x0072, 0x0012,
+ 0x002A, 0x003A, 0x000A, 0x0016, 0x001E, 0x0006, 0x000C, 0x0000,
+ 0x0004, 0x0001, 0x000D, 0x0007, 0x001F, 0x0017, 0x000B, 0x003B,
+ 0x002B, 0x0013, 0x0073, 0x0053, 0x0023, 0x00E3, 0x00A3, 0x00A0,
+ 0x0040, 0x01C0, 0x0084, 0x0384, 0x0284, 0x0105, 0x0705, 0x0215,
+ 0x0E15, 0x0A16, 0x1C2F, 0x142F, 0x1428, 0x2853, 0x70B5, 0x70B3,
+ 0x70B1,
+};
+static const uint16_t bitalloc_65_codes_e[65] =
+{
+ 0x032C, 0x0332, 0x0378, 0x037E, 0x008C, 0x014A, 0x0188, 0x0197,
+ 0x019E, 0x01BD, 0x0044, 0x0047, 0x00AA, 0x00C5, 0x00CD, 0x00DC,
+ 0x001C, 0x002C, 0x0053, 0x0063, 0x0068, 0x0008, 0x000F, 0x0017,
+ 0x002B, 0x0035, 0x0005, 0x0009, 0x0016, 0x001C, 0x0006, 0x000F,
+ 0x0004, 0x0000, 0x0007, 0x001D, 0x0017, 0x000A, 0x0006, 0x0036,
+ 0x0030, 0x0028, 0x0010, 0x0009, 0x0069, 0x0064, 0x0054, 0x002D,
+ 0x001D, 0x00DD, 0x00CE, 0x00CA, 0x00AB, 0x00A4, 0x0045, 0x01BE,
+ 0x019F, 0x0198, 0x0189, 0x014B, 0x008D, 0x037F, 0x0379, 0x0333,
+ 0x032D,
+};
+static const uint16_t bitalloc_65_codes_f[65] =
+{
+ 0x0FE0, 0x0FE2, 0x0FE8, 0x0FEA, 0x0FEC, 0x0FEE, 0x0FF0, 0x0FF2,
+ 0x0FF4, 0x2FF2, 0x07F2, 0x07FB, 0x03F6, 0x0BFA, 0x0BFD, 0x01FF,
+ 0x05FF, 0x02FC, 0x007C, 0x017C, 0x003C, 0x00BC, 0x001C, 0x005C,
+ 0x000C, 0x002C, 0x0004, 0x0014, 0x0000, 0x0008, 0x000E, 0x0002,
+ 0x0006, 0x0003, 0x000F, 0x0009, 0x0001, 0x0015, 0x0005, 0x002D,
+ 0x000D, 0x005D, 0x001D, 0x00BD, 0x003D, 0x017D, 0x007D, 0x02FD,
+ 0x00FC, 0x05FC, 0x01FA, 0x0BFB, 0x03F7, 0x17F8, 0x07F3, 0x2FF3,
+ 0x0FF5, 0x0FF3, 0x0FF1, 0x0FEF, 0x0FED, 0x0FEB, 0x0FE9, 0x0FE3,
+ 0x0FE1,
+};
+static const uint16_t bitalloc_65_codes_g[65] =
+{
+ 0x010C, 0x038A, 0x0608, 0x0786, 0x0084, 0x0087, 0x0302, 0x0305,
+ 0x0040, 0x00E0, 0x00E3, 0x0183, 0x001E, 0x005E, 0x009E, 0x00DE,
+ 0x00F1, 0x0011, 0x0039, 0x0061, 0x0079, 0x0009, 0x001D, 0x0031,
+ 0x003D, 0x0005, 0x000F, 0x0019, 0x001F, 0x0003, 0x0006, 0x000A,
+ 0x000E, 0x000B, 0x0008, 0x0004, 0x0000, 0x001A, 0x0012, 0x000A,
+ 0x0002, 0x0036, 0x0026, 0x0016, 0x0006, 0x006E, 0x004E, 0x002E,
+ 0x000E, 0x00DF, 0x009F, 0x005F, 0x001F, 0x01E0, 0x0180, 0x00E1,
+ 0x0041, 0x03C2, 0x0303, 0x01C4, 0x0085, 0x0787, 0x0609, 0x038B,
+ 0x010D,
+};
+static const uint8_t bitalloc_65_bits_a[65] =
+{
+ 16, 16, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8,
+ 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4,
+ 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7,
+ 7, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 13, 13, 14, 15, 16,
+ 16,
+};
+static const uint8_t bitalloc_65_bits_b[65] =
+{
+ 12, 11, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7,
+ 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4,
+ 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6,
+ 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 10, 10,
+ 12,
+};
+static const uint8_t bitalloc_65_bits_c[65] =
+{
+ 11, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6,
+ 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 10,
+ 11,
+};
+static const uint8_t bitalloc_65_bits_d[65] =
+{
+ 15, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9,
+ 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 3,
+ 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8,
+ 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 15, 15,
+ 15,
+};
+static const uint8_t bitalloc_65_bits_e[65] =
+{
+ 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8,
+ 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4,
+ 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7,
+ 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10,
+ 10,
+};
+static const uint8_t bitalloc_65_bits_f[65] =
+{
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 12, 12, 12, 11,
+ 11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3,
+ 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
+ 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14,
+};
+static const uint8_t bitalloc_65_bits_g[65] =
+{
+ 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8,
+ 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4,
+ 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7,
+ 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,
+ 11,
+};
+
+static const uint16_t bitalloc_129_codes_a[129] =
+{
+ 0x0660, 0x0666, 0x06EC, 0x0722, 0x0760, 0x076E, 0x004C, 0x004E,
+ 0x00F4, 0x010A, 0x0148, 0x0156, 0x01D4, 0x01F2, 0x0331, 0x0370,
+ 0x0377, 0x0396, 0x03B1, 0x0024, 0x0064, 0x007B, 0x008A, 0x00A5,
+ 0x00D4, 0x00EB, 0x00FA, 0x019A, 0x01B9, 0x01C9, 0x01D9, 0x0010,
+ 0x0030, 0x0033, 0x0043, 0x0053, 0x006B, 0x007A, 0x00CA, 0x00D2,
+ 0x00DE, 0x00E6, 0x00F6, 0x000E, 0x001F, 0x0023, 0x002B, 0x003B,
+ 0x003F, 0x0067, 0x0070, 0x0077, 0x0005, 0x000D, 0x0012, 0x001B,
+ 0x002C, 0x0035, 0x003A, 0x0004, 0x000B, 0x0017, 0x001F, 0x0009,
+ 0x0008, 0x000A, 0x0000, 0x0018, 0x000C, 0x0005, 0x003C, 0x0036,
+ 0x002D, 0x001C, 0x0013, 0x000E, 0x0006, 0x007A, 0x0071, 0x0068,
+ 0x0064, 0x003C, 0x0034, 0x0028, 0x0020, 0x000F, 0x00F7, 0x00E7,
+ 0x00DF, 0x00D3, 0x00CB, 0x007B, 0x0074, 0x0054, 0x0044, 0x003C,
+ 0x0031, 0x0011, 0x01DA, 0x01CA, 0x01BA, 0x019B, 0x00FB, 0x00F8,
+ 0x00D5, 0x00AA, 0x008B, 0x0084, 0x0065, 0x0025, 0x03B6, 0x0397,
+ 0x0390, 0x0371, 0x0332, 0x01F3, 0x01D5, 0x0157, 0x0149, 0x010B,
+ 0x00F5, 0x004F, 0x004D, 0x076F, 0x0761, 0x0723, 0x06ED, 0x0667,
+ 0x0661,
+};
+static const uint16_t bitalloc_129_codes_b[129] =
+{
+ 0x29DC, 0x14EF, 0x0455, 0x0E9C, 0x022B, 0x0489, 0x0740, 0x074F,
+ 0x0172, 0x0245, 0x0247, 0x030A, 0x03A1, 0x001C, 0x008B, 0x00D6,
+ 0x010C, 0x0148, 0x014F, 0x0186, 0x01D1, 0x0008, 0x000F, 0x0046,
+ 0x005D, 0x0078, 0x0087, 0x0096, 0x00A5, 0x00BC, 0x00D8, 0x00DE,
+ 0x00F6, 0x0005, 0x0014, 0x0024, 0x002F, 0x003A, 0x003D, 0x0049,
+ 0x0050, 0x0058, 0x005F, 0x0066, 0x006D, 0x0075, 0x007C, 0x0004,
+ 0x000B, 0x0013, 0x0018, 0x001B, 0x001F, 0x0022, 0x0026, 0x002A,
+ 0x002D, 0x0031, 0x0034, 0x0038, 0x003B, 0x003F, 0x0003, 0x0006,
+ 0x000A, 0x0007, 0x0004, 0x0000, 0x003C, 0x0039, 0x0035, 0x0032,
+ 0x002E, 0x002B, 0x0027, 0x0023, 0x0020, 0x001C, 0x0019, 0x0016,
+ 0x0010, 0x0005, 0x007D, 0x007A, 0x006E, 0x0067, 0x0060, 0x0059,
+ 0x0051, 0x004A, 0x0042, 0x003B, 0x0034, 0x0025, 0x0015, 0x0006,
+ 0x00F7, 0x00DF, 0x00D9, 0x00BD, 0x00A6, 0x0097, 0x0090, 0x0079,
+ 0x006A, 0x0047, 0x0044, 0x0009, 0x01D2, 0x0187, 0x0184, 0x0149,
+ 0x010D, 0x00D7, 0x00B8, 0x001D, 0x03A6, 0x030B, 0x029C, 0x0246,
+ 0x0173, 0x0114, 0x0741, 0x053A, 0x0488, 0x0E9D, 0x0A76, 0x0454,
+ 0x29DD,
+};
+static const uint16_t bitalloc_129_codes_c[129] =
+{
+ 0x0E5C, 0x072F, 0x001D, 0x0724, 0x000F, 0x010D, 0x0324, 0x0393,
+ 0x03E9, 0x0080, 0x0087, 0x00FA, 0x0164, 0x0193, 0x01DE, 0x01F5,
+ 0x0010, 0x002A, 0x0041, 0x0064, 0x0073, 0x008E, 0x00A4, 0x00B3,
+ 0x00D6, 0x00E5, 0x00F4, 0x00FB, 0x0002, 0x0009, 0x0013, 0x001E,
+ 0x0026, 0x002C, 0x0033, 0x003F, 0x0041, 0x004C, 0x0053, 0x005E,
+ 0x0065, 0x0070, 0x0073, 0x0078, 0x007B, 0x007E, 0x0002, 0x0005,
+ 0x0007, 0x000B, 0x000D, 0x0011, 0x0014, 0x0017, 0x001A, 0x001D,
+ 0x0021, 0x0024, 0x0027, 0x002A, 0x002D, 0x0030, 0x0033, 0x0036,
+ 0x003A, 0x0037, 0x0034, 0x0031, 0x002E, 0x002B, 0x0028, 0x0025,
+ 0x0022, 0x001E, 0x001B, 0x0018, 0x0015, 0x0012, 0x000E, 0x000C,
+ 0x0008, 0x0006, 0x0003, 0x007F, 0x007C, 0x0079, 0x0076, 0x0071,
+ 0x006A, 0x005F, 0x0058, 0x004D, 0x0046, 0x0040, 0x0038, 0x002D,
+ 0x0027, 0x001F, 0x0014, 0x0012, 0x0003, 0x0000, 0x00F5, 0x00EE,
+ 0x00D7, 0x00C8, 0x00A5, 0x008F, 0x007C, 0x0065, 0x0042, 0x002B,
+ 0x0011, 0x0002, 0x01DF, 0x01C8, 0x0165, 0x00FB, 0x00E4, 0x0081,
+ 0x0006, 0x03E8, 0x0325, 0x01CA, 0x010C, 0x0725, 0x0396, 0x001C,
+ 0x0E5D,
+};
+static const uint16_t bitalloc_129_codes_d[129] =
+{
+ 0xA598, 0xA59A, 0xA59C, 0xA59E, 0xC598, 0xE586, 0x3ACC, 0x52CA,
+ 0x62CD, 0x0D48, 0x1D67, 0x2978, 0x3167, 0x3966, 0x06A5, 0x0EBC,
+ 0x14BD, 0x1CB1, 0x0350, 0x0353, 0x075F, 0x0A5F, 0x0C5E, 0x0E5E,
+ 0x01AE, 0x03AD, 0x052D, 0x062D, 0x072D, 0x00D5, 0x01D4, 0x0294,
+ 0x0314, 0x0394, 0x0014, 0x0094, 0x0114, 0x0174, 0x01B4, 0x01F4,
+ 0x000B, 0x004B, 0x008B, 0x00BB, 0x00DB, 0x00FB, 0x001B, 0x003B,
+ 0x0053, 0x0063, 0x0073, 0x0003, 0x0013, 0x0023, 0x002F, 0x0037,
+ 0x003F, 0x0007, 0x000F, 0x0015, 0x0019, 0x001D, 0x0001, 0x0005,
+ 0x0009, 0x0006, 0x0002, 0x001E, 0x001A, 0x0016, 0x0010, 0x0008,
+ 0x0000, 0x0038, 0x0030, 0x0028, 0x001C, 0x000C, 0x007C, 0x006C,
+ 0x005C, 0x0044, 0x0024, 0x0004, 0x00E4, 0x00C4, 0x00A4, 0x0074,
+ 0x0034, 0x01F5, 0x01B5, 0x0175, 0x0115, 0x0095, 0x0015, 0x0395,
+ 0x0315, 0x0295, 0x01D5, 0x00D6, 0x072E, 0x062E, 0x052E, 0x03AE,
+ 0x01AF, 0x0E5F, 0x0C5F, 0x0C58, 0x0A58, 0x0758, 0x0351, 0x1CB2,
+ 0x18B2, 0x0EBD, 0x0EB2, 0x3967, 0x3960, 0x2979, 0x2964, 0x0D49,
+ 0x72C2, 0x52CB, 0x3ACD, 0xE587, 0xC599, 0xA59F, 0xA59D, 0xA59B,
+ 0xA599,
+};
+static const uint16_t bitalloc_129_codes_e[129] =
+{
+ 0xA13C, 0xC720, 0xA13F, 0xA13E, 0xA13D, 0xE722, 0x5090, 0x6393,
+ 0x7392, 0x2849, 0x31CE, 0x39CE, 0x1425, 0x18E5, 0x1CE5, 0x0844,
+ 0x0A1C, 0x0C7C, 0x036C, 0x0423, 0x050F, 0x063F, 0x01B7, 0x0216,
+ 0x0285, 0x031D, 0x039D, 0x0109, 0x0140, 0x0180, 0x01C8, 0x01CF,
+ 0x007A, 0x008A, 0x00A2, 0x00C1, 0x00E5, 0x0014, 0x0037, 0x0043,
+ 0x004E, 0x0056, 0x0061, 0x006C, 0x007C, 0x000B, 0x001C, 0x001F,
+ 0x0023, 0x0025, 0x0029, 0x002C, 0x002E, 0x0032, 0x0034, 0x0037,
+ 0x003A, 0x003C, 0x003F, 0x0001, 0x0003, 0x0006, 0x0008, 0x000A,
+ 0x000C, 0x000B, 0x0009, 0x0007, 0x0004, 0x0002, 0x0000, 0x003D,
+ 0x003B, 0x0038, 0x0035, 0x0033, 0x002F, 0x002D, 0x002A, 0x0026,
+ 0x0024, 0x0020, 0x001D, 0x001A, 0x007D, 0x006D, 0x0062, 0x0057,
+ 0x004F, 0x0044, 0x003C, 0x0015, 0x00E6, 0x00C6, 0x00A3, 0x008B,
+ 0x007B, 0x006C, 0x01C9, 0x0181, 0x0141, 0x010A, 0x00DA, 0x031E,
+ 0x0286, 0x0217, 0x0210, 0x0738, 0x0638, 0x0508, 0x036D, 0x0C7D,
+ 0x0A1D, 0x0845, 0x1CE6, 0x18E6, 0x1426, 0x39CF, 0x31CF, 0x284E,
+ 0x7393, 0x7390, 0x5091, 0xE723, 0xC724, 0xC725, 0xC722, 0xC723,
+ 0xC721,
+};
+static const uint16_t bitalloc_129_codes_f[129] =
+{
+ 0x762C, 0x3B17, 0x1555, 0x0608, 0x0AAB, 0x0FF2, 0x0305, 0x0307,
+ 0x0763, 0x0046, 0x010C, 0x01BC, 0x02AB, 0x03B6, 0x03FD, 0x0080,
+ 0x0087, 0x00DF, 0x0156, 0x01D9, 0x01F8, 0x01FF, 0x002A, 0x0041,
+ 0x0061, 0x0094, 0x00D4, 0x00EA, 0x00F2, 0x00FD, 0x0009, 0x000B,
+ 0x001A, 0x0026, 0x0031, 0x0040, 0x004B, 0x006B, 0x0073, 0x0077,
+ 0x007A, 0x007C, 0x0000, 0x0002, 0x0006, 0x0008, 0x000B, 0x000E,
+ 0x0011, 0x0014, 0x0016, 0x0019, 0x001C, 0x001E, 0x0021, 0x0023,
+ 0x0026, 0x0028, 0x002B, 0x002D, 0x002F, 0x0031, 0x0033, 0x0036,
+ 0x0038, 0x0037, 0x0034, 0x0032, 0x0030, 0x002E, 0x002C, 0x0029,
+ 0x0027, 0x0024, 0x0022, 0x001F, 0x001D, 0x001A, 0x0017, 0x0015,
+ 0x0012, 0x000F, 0x000C, 0x0009, 0x0007, 0x0003, 0x0001, 0x007D,
+ 0x007B, 0x0078, 0x0074, 0x0072, 0x0054, 0x0041, 0x0036, 0x0027,
+ 0x001B, 0x0014, 0x000A, 0x00FE, 0x00F3, 0x00EB, 0x00D5, 0x0095,
+ 0x006E, 0x0042, 0x002B, 0x0010, 0x01F9, 0x01DA, 0x0157, 0x0154,
+ 0x00C0, 0x0081, 0x0022, 0x03B7, 0x03B0, 0x01BD, 0x010D, 0x0047,
+ 0x07F8, 0x0554, 0x0306, 0x0FF3, 0x0EC4, 0x0609, 0x1D8A, 0x1554,
+ 0x762D,
+};
+static const uint16_t bitalloc_129_codes_g[129] =
+{
+ 0x1E20, 0x1E5E, 0x031C, 0x051A, 0x0718, 0x0916, 0x0B14, 0x0D12,
+ 0x0F11, 0x0090, 0x018F, 0x028E, 0x038D, 0x048C, 0x058B, 0x068A,
+ 0x0789, 0x0049, 0x00C8, 0x0148, 0x01C7, 0x0247, 0x02C6, 0x0346,
+ 0x03C5, 0x0025, 0x0065, 0x00A5, 0x00E4, 0x0124, 0x0164, 0x01A4,
+ 0x01E3, 0x0013, 0x0033, 0x0053, 0x0073, 0x0093, 0x00B3, 0x00D3,
+ 0x00F3, 0x000A, 0x001A, 0x002A, 0x003A, 0x004A, 0x005A, 0x006A,
+ 0x007A, 0x0006, 0x000E, 0x0016, 0x001E, 0x0026, 0x002E, 0x0036,
+ 0x003E, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C,
+ 0x0000, 0x001D, 0x0019, 0x0015, 0x0011, 0x000D, 0x0009, 0x0005,
+ 0x003F, 0x0037, 0x002F, 0x0027, 0x001F, 0x0017, 0x000F, 0x0007,
+ 0x007B, 0x006B, 0x005B, 0x004B, 0x003B, 0x002B, 0x001B, 0x000B,
+ 0x0008, 0x00F0, 0x00D0, 0x00B0, 0x0090, 0x0070, 0x0050, 0x0030,
+ 0x01E4, 0x01A5, 0x0165, 0x0125, 0x00E5, 0x00E2, 0x00A2, 0x0062,
+ 0x03CA, 0x0347, 0x02C7, 0x02C4, 0x0244, 0x0149, 0x00C9, 0x00C6,
+ 0x0796, 0x068B, 0x0688, 0x048D, 0x048A, 0x028F, 0x028C, 0x0091,
+ 0x0F2E, 0x0D13, 0x0B15, 0x0917, 0x0719, 0x051B, 0x031D, 0x1E5F,
+ 0x1E21,
+};
+static const uint8_t bitalloc_129_bits_a[129] =
+{
+ 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4,
+ 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
+ 11,
+};
+static const uint8_t bitalloc_129_bits_b[129] =
+{
+ 14, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9,
+ 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5,
+ 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
+ 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12,
+ 14,
+};
+static const uint8_t bitalloc_129_bits_c[129] =
+{
+ 13, 12, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,
+ 13,
+};
+static const uint8_t bitalloc_129_bits_d[129] =
+{
+ 16, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13,
+ 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10,
+ 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7,
+ 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4,
+ 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7,
+ 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+ 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13,
+ 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16,
+ 16,
+};
+static const uint8_t bitalloc_129_bits_e[129] =
+{
+ 16, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12,
+ 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9,
+ 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
+ 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
+ 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16,
+ 16,
+};
+static const uint8_t bitalloc_129_bits_f[129] =
+{
+ 15, 14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9,
+ 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
+ 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13,
+ 15,
+};
+static const uint8_t bitalloc_129_bits_g[129] =
+{
+ 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11,
+ 11, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9,
+ 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
+ 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5,
+ 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
+ 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
+ 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13,
+ 13,
+};
+
+static const uint8_t bitalloc_sizes[10] = { 3, 5, 7, 9, 13, 17, 25, 33, 65, 129 };
+
+static const uint8_t bitalloc_offsets[10] =
+ { -1, -2, -3, -4, -6, -8, -12, -16, -32, -64 };
+
+static const uint8_t bitalloc_maxbits[10][7] = {
+ { 2 },
+ { 4, 3, 3 },
+ { 5, 5, 4 },
+ { 6, 5, 6 },
+ { 7, 6, 5 },
+ { 9, 8, 7, 9, 8, 8, 8 },
+ { 9, 9, 8, 9, 8, 9, 9 },
+ { 9, 9, 9, 9, 9, 9, 9 },
+ { 9, 9, 9, 9, 9, 9, 9 },
+ { 9, 9, 9, 9, 9, 9, 9 }
+};
+
+static const uint16_t* bitalloc_codes[10][8] = {
+ { bitalloc_3_codes, NULL },
+ { bitalloc_5_codes_a, bitalloc_5_codes_b, bitalloc_5_codes_c, NULL },
+ { bitalloc_7_codes_a, bitalloc_7_codes_b, bitalloc_7_codes_c, NULL },
+ { bitalloc_9_codes_a, bitalloc_9_codes_b, bitalloc_9_codes_c, NULL },
+ { bitalloc_13_codes_a, bitalloc_13_codes_b, bitalloc_13_codes_c, NULL },
+ { bitalloc_17_codes_a, bitalloc_17_codes_b, bitalloc_17_codes_c, bitalloc_17_codes_d,
+ bitalloc_17_codes_e, bitalloc_17_codes_f, bitalloc_17_codes_g, NULL },
+ { bitalloc_25_codes_a, bitalloc_25_codes_b, bitalloc_25_codes_c, bitalloc_25_codes_d,
+ bitalloc_25_codes_e, bitalloc_25_codes_f, bitalloc_25_codes_g, NULL },
+ { bitalloc_33_codes_a, bitalloc_33_codes_b, bitalloc_33_codes_c, bitalloc_33_codes_d,
+ bitalloc_33_codes_e, bitalloc_33_codes_f, bitalloc_33_codes_g, NULL },
+ { bitalloc_65_codes_a, bitalloc_65_codes_b, bitalloc_65_codes_c, bitalloc_65_codes_d,
+ bitalloc_65_codes_e, bitalloc_65_codes_f, bitalloc_65_codes_g, NULL },
+ { bitalloc_129_codes_a, bitalloc_129_codes_b, bitalloc_129_codes_c, bitalloc_129_codes_d,
+ bitalloc_129_codes_e, bitalloc_129_codes_f, bitalloc_129_codes_g, NULL }
+};
+
+static const uint8_t* bitalloc_bits[10][8] = {
+ { bitalloc_3_bits, NULL },
+ { bitalloc_5_bits_a, bitalloc_5_bits_b, bitalloc_5_bits_c, NULL },
+ { bitalloc_7_bits_a, bitalloc_7_bits_b, bitalloc_7_bits_c, NULL },
+ { bitalloc_9_bits_a, bitalloc_9_bits_b, bitalloc_9_bits_c, NULL },
+ { bitalloc_13_bits_a, bitalloc_13_bits_b, bitalloc_13_bits_c, NULL },
+ { bitalloc_17_bits_a, bitalloc_17_bits_b, bitalloc_17_bits_c, bitalloc_17_bits_d,
+ bitalloc_17_bits_e, bitalloc_17_bits_f, bitalloc_17_bits_g, NULL },
+ { bitalloc_25_bits_a, bitalloc_25_bits_b, bitalloc_25_bits_c, bitalloc_25_bits_d,
+ bitalloc_25_bits_e, bitalloc_25_bits_f, bitalloc_25_bits_g, NULL },
+ { bitalloc_33_bits_a, bitalloc_33_bits_b, bitalloc_33_bits_c, bitalloc_33_bits_d,
+ bitalloc_33_bits_e, bitalloc_33_bits_f, bitalloc_33_bits_g, NULL },
+ { bitalloc_65_bits_a, bitalloc_65_bits_b, bitalloc_65_bits_c, bitalloc_65_bits_d,
+ bitalloc_65_bits_e, bitalloc_65_bits_f, bitalloc_65_bits_g, NULL },
+ { bitalloc_129_bits_a, bitalloc_129_bits_b, bitalloc_129_bits_c, bitalloc_129_bits_d,
+ bitalloc_129_bits_e, bitalloc_129_bits_f, bitalloc_129_bits_g, NULL }
+};
diff --git a/contrib/ffmpeg/libavcodec/dct-test.c b/contrib/ffmpeg/libavcodec/dct-test.c
index 2c16f47e4..7cd866832 100644
--- a/contrib/ffmpeg/libavcodec/dct-test.c
+++ b/contrib/ffmpeg/libavcodec/dct-test.c
@@ -1,5 +1,6 @@
/*
* (c) 2001 Fabrice Bellard
+ * 2007 Marc Hoffman <marc.hoffman@analog.com>
*
* This file is part of FFmpeg.
*
@@ -56,6 +57,64 @@ extern void ff_mmxext_idct(DCTELEM *data);
extern void odivx_idct_c (short *block);
+// BFIN
+extern void ff_bfin_idct (DCTELEM *block) ;
+extern void ff_bfin_fdct (DCTELEM *block) ;
+
+// ALTIVEC
+extern void fdct_altivec (DCTELEM *block);
+//extern void idct_altivec (DCTELEM *block);?? no routine
+
+
+struct algo {
+ char *name;
+ enum { FDCT, IDCT } is_idct;
+ void (* func) (DCTELEM *block);
+ void (* ref) (DCTELEM *block);
+ enum formattag { NO_PERM,MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM } format;
+};
+
+#ifndef FAAN_POSTSCALE
+#define FAAN_SCALE SCALE_PERM
+#else
+#define FAAN_SCALE NO_PERM
+#endif
+
+#define DCT_ERROR(name,is_idct,func,ref,form) {name,is_idct,func,ref,form}
+
+
+struct algo algos[] = {
+ DCT_ERROR( "REF-DBL", 0, fdct, fdct, NO_PERM),
+ DCT_ERROR("IJG-AAN-INT", 0, fdct_ifast, fdct, SCALE_PERM),
+ DCT_ERROR("IJG-LLM-INT", 0, ff_jpeg_fdct_islow, fdct, NO_PERM),
+ DCT_ERROR("REF-DBL", 1, idct, idct, NO_PERM),
+ DCT_ERROR("INT", 1, j_rev_dct, idct, MMX_PERM),
+ DCT_ERROR("SIMPLE-C", 1, simple_idct, idct, NO_PERM),
+
+#ifdef ARCH_X86
+ DCT_ERROR("MMX", 0, ff_fdct_mmx, fdct, NO_PERM),
+ DCT_ERROR("MMX2", 0, ff_fdct_mmx2, fdct, NO_PERM),
+ DCT_ERROR("FAAN", 0, ff_faandct, fdct, FAAN_SCALE),
+
+ DCT_ERROR("LIBMPEG2-MMX", 1, ff_mmx_idct, idct, MMX_PERM),
+ DCT_ERROR("LIBMPEG2-MMXEXT", 1, ff_mmxext_idct, idct, MMX_PERM),
+ DCT_ERROR("SIMPLE-MMX", 1, ff_simple_idct_mmx, idct, MMX_SIMPLE_PERM),
+ DCT_ERROR("XVID-MMX", 1, ff_idct_xvid_mmx, idct, NO_PERM),
+ DCT_ERROR("XVID-MMX2", 1, ff_idct_xvid_mmx2, idct, NO_PERM),
+#endif
+
+#ifdef HAVE_ALTIVEC
+ DCT_ERROR("altivecfdct", 0, fdct_altivec, fdct, NO_PERM),
+#endif
+
+#ifdef ARCH_BFIN
+ DCT_ERROR("BFINfdct", 0, ff_bfin_fdct, fdct, NO_PERM),
+ DCT_ERROR("BFINidct", 1, ff_bfin_idct, idct, NO_PERM),
+#endif
+
+ { 0 }
+};
+
#define AANSCALE_BITS 12
static const unsigned short aanscales[64] = {
/* precomputed values scaled up by 14 bits */
@@ -111,7 +170,7 @@ static DCTELEM block_org[64] __attribute__ ((aligned (8)));
void dct_error(const char *name, int is_idct,
void (*fdct_func)(DCTELEM *block),
- void (*fdct_ref)(DCTELEM *block), int test)
+ void (*fdct_ref)(DCTELEM *block), int form, int test)
{
int it, i, scale;
int err_inf, v;
@@ -162,11 +221,10 @@ void dct_error(const char *name, int is_idct,
for(i=0; i<64; i++)
block_org[i]= block1[i];
- if (fdct_func == ff_mmx_idct ||
- fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) {
+ if (form == MMX_PERM) {
for(i=0;i<64;i++)
block[idct_mmx_perm[i]] = block1[i];
- } else if(fdct_func == ff_simple_idct_mmx ) {
+ } else if (form == MMX_SIMPLE_PERM) {
for(i=0;i<64;i++)
block[idct_simple_mmx_perm[i]] = block1[i];
@@ -184,13 +242,9 @@ void dct_error(const char *name, int is_idct,
#endif
fdct_func(block);
- emms(); /* for ff_mmx_idct */
+ emms_c(); /* for ff_mmx_idct */
- if (fdct_func == fdct_ifast
-#ifndef FAAN_POSTSCALE
- || fdct_func == ff_faandct
-#endif
- ) {
+ if (form == SCALE_PERM) {
for(i=0; i<64; i++) {
scale = 8*(1 << (AANSCALE_BITS + 11)) / aanscales[i];
block[i] = (block[i] * scale /*+ (1<<(AANSCALE_BITS-1))*/) >> AANSCALE_BITS;
@@ -261,11 +315,10 @@ void dct_error(const char *name, int is_idct,
}break;
}
- if (fdct_func == ff_mmx_idct ||
- fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) {
+ if (form == MMX_PERM) {
for(i=0;i<64;i++)
block[idct_mmx_perm[i]] = block1[i];
- } else if(fdct_func == ff_simple_idct_mmx ) {
+ } else if(form == MMX_SIMPLE_PERM) {
for(i=0;i<64;i++)
block[idct_simple_mmx_perm[i]] = block1[i];
} else {
@@ -286,7 +339,7 @@ void dct_error(const char *name, int is_idct,
it1 += NB_ITS_SPEED;
ti1 = gettime() - ti;
} while (ti1 < 1000000);
- emms();
+ emms_c();
printf("%s %s: %0.1f kdct/s\n",
is_idct ? "IDCT" : "DCT",
@@ -446,7 +499,7 @@ void idct248_error(const char *name,
it1 += NB_ITS_SPEED;
ti1 = gettime() - ti;
} while (ti1 < 1000000);
- emms();
+ emms_c();
printf("%s %s: %0.1f kdct/s\n",
1 ? "IDCT248" : "DCT248",
@@ -461,7 +514,6 @@ void help(void)
" 2 -> do 3. test from mpeg4 std\n"
"-i test IDCT implementations\n"
"-4 test IDCT248 implementations\n");
- exit(1);
}
int main(int argc, char **argv)
@@ -493,7 +545,7 @@ int main(int argc, char **argv)
default :
case 'h':
help();
- break;
+ return 0;
}
}
@@ -504,31 +556,9 @@ int main(int argc, char **argv)
if (test_248_dct) {
idct248_error("SIMPLE-C", simple_idct248_put);
} else {
- if (!test_idct) {
- dct_error("REF-DBL", 0, fdct, fdct, test); /* only to verify code ! */
- dct_error("IJG-AAN-INT", 0, fdct_ifast, fdct, test);
- dct_error("IJG-LLM-INT", 0, ff_jpeg_fdct_islow, fdct, test);
- dct_error("MMX", 0, ff_fdct_mmx, fdct, test);
- dct_error("MMX2", 0, ff_fdct_mmx2, fdct, test);
- dct_error("FAAN", 0, ff_faandct, fdct, test);
- } else {
- dct_error("REF-DBL", 1, idct, idct, test);
- dct_error("INT", 1, j_rev_dct, idct, test);
- dct_error("LIBMPEG2-MMX", 1, ff_mmx_idct, idct, test);
- dct_error("LIBMPEG2-MMXEXT", 1, ff_mmxext_idct, idct, test);
- dct_error("SIMPLE-C", 1, simple_idct, idct, test);
- dct_error("SIMPLE-MMX", 1, ff_simple_idct_mmx, idct, test);
- dct_error("XVID-MMX", 1, ff_idct_xvid_mmx, idct, test);
- dct_error("XVID-MMX2", 1, ff_idct_xvid_mmx2, idct, test);
- // dct_error("ODIVX-C", 1, odivx_idct_c, idct);
- //printf(" test against odivx idct\n");
- // dct_error("REF", 1, idct, odivx_idct_c);
- // dct_error("INT", 1, j_rev_dct, odivx_idct_c);
- // dct_error("MMX", 1, ff_mmx_idct, odivx_idct_c);
- // dct_error("MMXEXT", 1, ff_mmxext_idct, odivx_idct_c);
- // dct_error("SIMPLE-C", 1, simple_idct, odivx_idct_c);
- // dct_error("SIMPLE-MMX", 1, ff_simple_idct_mmx, odivx_idct_c);
- // dct_error("ODIVX-C", 1, odivx_idct_c, odivx_idct_c);
+ for (i=0;algos[i].name;i++)
+ if (algos[i].is_idct == test_idct) {
+ dct_error (algos[i].name, algos[i].is_idct, algos[i].func, algos[i].ref, algos[i].format, test);
}
}
return 0;
diff --git a/contrib/ffmpeg/libavcodec/dnxhddata.h b/contrib/ffmpeg/libavcodec/dnxhddata.h
new file mode 100644
index 000000000..5d5aa528b
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/dnxhddata.h
@@ -0,0 +1,106 @@
+/*
+ * VC3/DNxHD decoder.
+ * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot 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
+ */
+
+static const uint8_t dnxhd_1238_luma_weigth[] = {
+ 0, 32, 32, 33, 34, 33, 33, 33,
+ 33, 33, 33, 33, 33, 35, 37, 37,
+ 36, 36, 35, 36, 38, 38, 36, 35,
+ 36, 37, 38, 41, 42, 41, 39, 38,
+ 38, 38, 39, 41, 42, 41, 39, 39,
+ 40, 41, 43, 44, 44, 44, 44, 44,
+ 45, 47, 47, 47, 49, 50, 51, 51,
+ 51, 53, 55, 57, 58, 59, 57, 57,
+};
+
+static const uint8_t dnxhd_1238_chroma_weigth[] = {
+ 0, 32, 35, 35, 35, 34, 34, 35,
+ 39, 43, 45, 45, 41, 39, 40, 41,
+ 42, 44, 48, 55, 59, 63, 65, 59,
+ 53, 52, 52, 55, 61, 62, 58, 58,
+ 63, 66, 66, 65, 70, 74, 70, 66,
+ 65, 68, 75, 77, 74, 74, 77, 76,
+ 73, 73, 73, 73, 76, 80, 89, 90,
+ 82, 77, 80, 86, 84, 82, 82, 82,
+};
+
+/* FIXME permute */
+static const uint8_t dnxhd_1243_luma_weigth[] = {
+ 0,32,35,35,38,40,44,45,
+ 32,33,35,35,39,42,44,45,
+ 33,35,34,37,41,42,45,45,
+ 35,35,37,40,41,44,45,48,
+ 35,37,38,40,43,45,47,48,
+ 36,36,38,40,45,47,48,47,
+ 35,36,38,41,45,46,47,48,
+ 36,37,39,41,44,45,47,47,
+};
+
+/* FIXME permute */
+static const uint8_t dnxhd_1243_chroma_weigth[] = {
+ 0,32,37,39,41,42,45,45,
+ 36,36,39,41,43,45,46,45,
+ 37,41,41,43,45,44,45,46,
+ 43,42,43,46,44,45,46,48,
+ 43,44,47,45,44,46,47,49,
+ 44,46,44,45,45,47,48,47,
+ 44,42,46,44,45,46,47,48,
+ 41,43,45,44,45,46,47,47,
+};
+
+static const uint8_t dnxhd_1238_dc_codes[12] = {
+ 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
+};
+
+static const uint8_t dnxhd_1238_dc_bits[12] = {
+ 3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6,
+};
+
+static const uint16_t dnxhd_1238_ac_codes[257] = {
+ 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 498, 499, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 16314, 16315, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 16338, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535,
+};
+
+static const uint8_t dnxhd_1238_ac_bits[257] = {
+ 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+};
+
+static const uint8_t dnxhd_1238_ac_level[257] = {
+ 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 22, 6, 7, 23, 24, 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 10, 11, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 12, 13, 14, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 15, 16, 17, 18, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 40, 25, 26, 27, 28, 29, 30, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+}; /* 0 is EOB */
+
+static const uint8_t dnxhd_1238_ac_run_flag[257] = {
+ 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+};
+
+static const uint8_t dnxhd_1238_ac_index_flag[257] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+};
+
+static const uint16_t dnxhd_1238_run_codes[62] = {
+ 0, 4, 10, 11, 24, 25, 26, 27, 56, 57, 58, 59, 120, 242, 486, 487, 488, 489, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023,
+};
+
+static const uint8_t dnxhd_1238_run_bits[62] = {
+ 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+};
+
+static const uint8_t dnxhd_1238_run[62] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+};
diff --git a/contrib/ffmpeg/libavcodec/dnxhddec.c b/contrib/ffmpeg/libavcodec/dnxhddec.c
new file mode 100644
index 000000000..224439c47
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/dnxhddec.c
@@ -0,0 +1,368 @@
+/*
+ * VC3/DNxHD decoder.
+ * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot 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
+ */
+
+//#define TRACE
+//#define DEBUG
+
+#include "avcodec.h"
+#include "bitstream.h"
+#include "dnxhddata.h"
+#include "dsputil.h"
+#include "mpegvideo.h"
+
+typedef struct {
+ int cid;
+ unsigned int width, height;
+ int interlaced;
+ unsigned int frame_size;
+ int index_bits;
+ int bit_depth;
+ const uint8_t *luma_weigth, *chroma_weigth;
+ const uint8_t *dc_codes, *dc_bits;
+ const uint16_t *ac_codes;
+ const uint8_t *ac_bits, *ac_level;
+ const uint8_t *ac_run_flag, *ac_index_flag;
+ const uint16_t *run_codes;
+ const uint8_t *run_bits, *run;
+} CIDEntry;
+
+typedef struct {
+ AVCodecContext *avctx;
+ AVFrame picture;
+ GetBitContext gb;
+ int cid; ///< compression id
+ unsigned int width, height;
+ unsigned int mb_width, mb_height;
+ uint32_t mb_scan_index[68]; /* max for 1080p */
+ int cur_field; ///< current interlaced field
+ int index_bits; ///< length of index value
+ VLC ac_vlc, dc_vlc, run_vlc;
+ const uint8_t *ac_level, *run;
+ const uint8_t *ac_run_flag, *ac_index_flag;
+ const uint8_t *luma_weigth, *chroma_weigth;
+ int last_dc[3];
+ DSPContext dsp;
+ DECLARE_ALIGNED_16(DCTELEM, blocks[8][64]);
+ DECLARE_ALIGNED_8(ScanTable, scantable);
+ const CIDEntry *cid_table;
+} DNXHDContext;
+
+static const CIDEntry cid_table[] = {
+ { 1238, 1920, 1080, 0, 917504, 4, 8,
+ dnxhd_1238_luma_weigth, dnxhd_1238_chroma_weigth,
+ dnxhd_1238_dc_codes, dnxhd_1238_dc_bits,
+ dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level,
+ dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag,
+ dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run },
+/* { 1243, 1920, 1080, 1, 917504, 4, 8, */
+/* dnxhd_1243_luma_weigth, dnxhd_1243_chroma_weigth, */
+/* dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, */
+/* dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, */
+/* dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, */
+/* dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run }, */
+};
+
+static int dnxhd_get_cid_table(int cid)
+{
+ int i;
+ for (i = 0; i < sizeof(cid_table)/sizeof(CIDEntry); i++)
+ if (cid_table[i].cid == cid)
+ return i;
+ return -1;
+}
+
+#define DNXHD_VLC_BITS 9
+#define DNXHD_DC_VLC_BITS 6
+
+static int dnxhd_decode_init(AVCodecContext *avctx)
+{
+ DNXHDContext *ctx = avctx->priv_data;
+
+ ctx->avctx = avctx;
+ dsputil_init(&ctx->dsp, avctx);
+ avctx->coded_frame = &ctx->picture;
+ ctx->picture.type = FF_I_TYPE;
+ return 0;
+}
+
+static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
+{
+ if (!ctx->cid_table) {
+ int index;
+
+ if ((index = dnxhd_get_cid_table(cid)) < 0) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
+ return -1;
+ }
+ ctx->cid_table = &cid_table[index];
+ init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
+ cid_table->ac_bits, 1, 1,
+ cid_table->ac_codes, 2, 2, 0);
+ init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, 12,
+ cid_table->dc_bits, 1, 1,
+ cid_table->dc_codes, 1, 1, 0);
+ init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
+ cid_table->run_bits, 1, 1,
+ cid_table->run_codes, 2, 2, 0);
+
+ ctx->run = cid_table->run;
+ ctx->ac_level = cid_table->ac_level;
+ ctx->ac_run_flag = cid_table->ac_run_flag;
+ ctx->ac_index_flag = cid_table->ac_index_flag;
+ ctx->luma_weigth = cid_table->luma_weigth;
+ ctx->chroma_weigth = cid_table->chroma_weigth;
+
+ ctx->index_bits = cid_table->index_bits;
+
+ ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct);
+ }
+ return 0;
+}
+
+static int dnxhd_decode_header(DNXHDContext *ctx, uint8_t *buf, int buf_size)
+{
+ static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
+ int i;
+
+ if (buf_size < 0x280)
+ return -1;
+
+ if (memcmp(buf, header_prefix, 5)) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "error in header\n");
+ return -1;
+ }
+ if (buf[5] & 2) {/* interlaced FIXME top or bottom */
+ ctx->picture.interlaced_frame = 1;
+ av_log(ctx->avctx, AV_LOG_DEBUG, "interlaced %d\n", buf[5] & 3);
+ }
+
+ ctx->height = AV_RB16(buf + 0x18);
+ ctx->width = AV_RB16(buf + 0x1a);
+
+ dprintf(ctx->avctx, "width %d, heigth %d\n", ctx->width, ctx->height);
+
+ if (buf[0x21] & 0x80) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "10 bit per component\n");
+ return -1;
+ }
+
+ ctx->cid = AV_RB32(buf + 0x28);
+ dprintf(ctx->avctx, "compression id %d\n", ctx->cid);
+
+ if (dnxhd_init_vlc(ctx, ctx->cid) < 0)
+ return -1;
+
+ if (buf_size < ctx->cid_table->frame_size) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size\n");
+ return -1;
+ }
+
+ ctx->mb_width = ctx->width>>4;
+ ctx->mb_height = buf[0x16d];
+
+ if (ctx->mb_height > 68) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "mb height too big\n");
+ return -1;
+ }
+
+ dprintf(ctx->avctx, "mb width %d, mb height %d\n", ctx->mb_width, ctx->mb_height);
+ 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]);
+ if (buf_size < ctx->mb_scan_index[i] + 0x280) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "invalid mb scan index\n");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int dnxhd_decode_dc(DNXHDContext *ctx)
+{
+ int len;
+
+ len = get_vlc2(&ctx->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1);
+ return len ? get_xbits(&ctx->gb, len) : 0;
+}
+
+static void dnxhd_decode_dct_block(DNXHDContext *ctx, DCTELEM *block, int n, int qscale)
+{
+ int i, j, index, index2;
+ int level, component, sign;
+ const uint8_t *weigth_matrix;
+
+ if (n&2) {
+ component = 1 + (n&1);
+ weigth_matrix = ctx->chroma_weigth;
+ } else {
+ component = 0;
+ weigth_matrix = ctx->luma_weigth;
+ }
+
+ ctx->last_dc[component] += dnxhd_decode_dc(ctx);
+ block[0] = ctx->last_dc[component];
+ //av_log(ctx->avctx, AV_LOG_DEBUG, "dc %d\n", block[0]);
+ for (i = 1; ; i++) {
+ index = get_vlc2(&ctx->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2);
+ //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index);
+ level = ctx->ac_level[index];
+ if (!level) { /* EOB */
+ //av_log(ctx->avctx, AV_LOG_DEBUG, "EOB\n");
+ return;
+ }
+ sign = get_sbits(&ctx->gb, 1);
+
+ if (ctx->ac_index_flag[index]) {
+ level += get_bits(&ctx->gb, ctx->index_bits)<<6;
+ }
+
+ if (ctx->ac_run_flag[index]) {
+ index2 = get_vlc2(&ctx->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2);
+ i += ctx->run[index2];
+ }
+
+ j = ctx->scantable.permutated[i];
+ //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j);
+ //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]);
+ level = (2*level+1) * qscale * weigth_matrix[i];
+ if (weigth_matrix[i] != 32) // FIXME 10bit
+ level += 32;
+ level >>= 6;
+ level = (level^sign) - sign;
+
+ if (i > 63) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i);
+ return;
+ }
+
+ //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level);
+ block[j] = level;
+ }
+}
+
+static int dnxhd_decode_macroblock(DNXHDContext *ctx, int x, int y)
+{
+ int dct_linesize_luma = ctx->picture.linesize[0];
+ int dct_linesize_chroma = ctx->picture.linesize[1];
+ uint8_t *dest_y, *dest_u, *dest_v;
+ int dct_offset;
+ int qscale, i;
+
+ ctx->dsp.clear_blocks(ctx->blocks[0]);
+ ctx->dsp.clear_blocks(ctx->blocks[2]); // FIXME change clear blocks to take block amount
+
+ qscale = get_bits(&ctx->gb, 11);
+ skip_bits1(&ctx->gb);
+ //av_log(ctx->avctx, AV_LOG_DEBUG, "qscale %d\n", qscale);
+
+ for (i = 0; i < 8; i++) {
+ dnxhd_decode_dct_block(ctx, ctx->blocks[i], i, qscale);
+ }
+ dest_y = ctx->picture.data[0] + ((y * dct_linesize_luma) << 4) + (x << 4);
+ dest_u = ctx->picture.data[1] + ((y * dct_linesize_chroma) << 4) + (x << 3);
+ dest_v = ctx->picture.data[2] + ((y * dct_linesize_chroma) << 4) + (x << 3);
+
+ dct_offset = dct_linesize_luma << 3;
+ ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
+ ctx->dsp.idct_put(dest_y + 8, dct_linesize_luma, ctx->blocks[1]);
+ ctx->dsp.idct_put(dest_y + dct_offset, dct_linesize_luma, ctx->blocks[4]);
+ ctx->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize_luma, ctx->blocks[5]);
+
+ if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
+ dct_offset = dct_linesize_chroma << 3;
+ ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
+ ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);
+ ctx->dsp.idct_put(dest_u + dct_offset, dct_linesize_chroma, ctx->blocks[6]);
+ ctx->dsp.idct_put(dest_v + dct_offset, dct_linesize_chroma, ctx->blocks[7]);
+ }
+
+ return 0;
+}
+
+static int dnxhd_decode_macroblocks(DNXHDContext *ctx, uint8_t *buf, int buf_size)
+{
+ int x, y;
+ for (y = 0; y < ctx->mb_height; y++) {
+ memset(ctx->last_dc, 4, sizeof(ctx->last_dc)); // 4 for levels +128
+ init_get_bits(&ctx->gb, buf + ctx->mb_scan_index[y], (buf_size - ctx->mb_scan_index[y]) << 3);
+ for (x = 0; x < ctx->mb_width; x++) {
+ //START_TIMER;
+ dnxhd_decode_macroblock(ctx, x, y);
+ //STOP_TIMER("decode macroblock");
+ }
+ }
+ return 0;
+}
+
+static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ DNXHDContext *ctx = avctx->priv_data;
+ AVFrame *picture = data;
+
+ dprintf(avctx, "frame size %d\n", buf_size);
+
+ if (dnxhd_decode_header(ctx, buf, buf_size) < 0)
+ return -1;
+
+ avctx->pix_fmt = PIX_FMT_YUV422P;
+ if (avcodec_check_dimensions(avctx, ctx->width, ctx->height))
+ return -1;
+ avcodec_set_dimensions(avctx, ctx->width, ctx->height);
+
+ if (ctx->picture.data[0])
+ avctx->release_buffer(avctx, &ctx->picture);
+ if (avctx->get_buffer(avctx, &ctx->picture) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return -1;
+ }
+
+ dnxhd_decode_macroblocks(ctx, buf + 0x280, buf_size - 0x280);
+
+ *picture = ctx->picture;
+ *data_size = sizeof(AVPicture);
+ return buf_size;
+}
+
+static int dnxhd_decode_close(AVCodecContext *avctx)
+{
+ DNXHDContext *ctx = avctx->priv_data;
+
+ if(ctx->picture.data[0])
+ avctx->release_buffer(avctx, &ctx->picture);
+ free_vlc(&ctx->ac_vlc);
+ free_vlc(&ctx->dc_vlc);
+ free_vlc(&ctx->run_vlc);
+ return 0;
+}
+
+AVCodec dnxhd_decoder = {
+ "dnxhd",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_DNXHD,
+ sizeof(DNXHDContext),
+ dnxhd_decode_init,
+ NULL,
+ dnxhd_decode_close,
+ dnxhd_decode_frame,
+ CODEC_CAP_DR1,
+};
diff --git a/contrib/ffmpeg/libavcodec/dpcm.c b/contrib/ffmpeg/libavcodec/dpcm.c
index 99c0cac64..6243881de 100644
--- a/contrib/ffmpeg/libavcodec/dpcm.c
+++ b/contrib/ffmpeg/libavcodec/dpcm.c
@@ -179,7 +179,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_ROQ_DPCM:
if (s->channels == 1)
- predictor[0] = LE_16(&buf[6]);
+ predictor[0] = AV_RL16(&buf[6]);
else {
predictor[0] = buf[7] << 8;
predictor[1] = buf[6] << 8;
@@ -200,12 +200,12 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_INTERPLAY_DPCM:
in = 6; /* skip over the stream mask and stream length */
- predictor[0] = LE_16(&buf[in]);
+ predictor[0] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[0])
output_samples[out++] = predictor[0];
if (s->channels == 2) {
- predictor[1] = LE_16(&buf[in]);
+ predictor[1] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[1])
output_samples[out++] = predictor[1];
@@ -225,11 +225,11 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_XAN_DPCM:
in = 0;
shift[0] = shift[1] = 4;
- predictor[0] = LE_16(&buf[in]);
+ predictor[0] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[0]);
if (s->channels == 2) {
- predictor[1] = LE_16(&buf[in]);
+ predictor[1] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[1]);
}
diff --git a/contrib/ffmpeg/libavcodec/dsicinav.c b/contrib/ffmpeg/libavcodec/dsicinav.c
index ded53c45a..c7c3f5627 100644
--- a/contrib/ffmpeg/libavcodec/dsicinav.c
+++ b/contrib/ffmpeg/libavcodec/dsicinav.c
@@ -159,7 +159,7 @@ static void cin_decode_lzss(const unsigned char *src, int src_size, unsigned cha
if (code & (1 << i)) {
*dst++ = *src++;
} else {
- cmd = LE_16(src); src += 2;
+ cmd = AV_RL16(src); src += 2;
offset = cmd >> 4;
sz = (cmd & 0xF) + 2;
/* don't use memcpy/memmove here as the decoding routine (ab)uses */
@@ -321,13 +321,13 @@ static int cinaudio_decode_frame(AVCodecContext *avctx,
if (cin->initial_decode_frame) {
cin->initial_decode_frame = 0;
- cin->delta = (int16_t)LE_16(src); src += 2;
+ cin->delta = (int16_t)AV_RL16(src); src += 2;
*samples++ = cin->delta;
buf_size -= 2;
}
while (buf_size > 0) {
cin->delta += cinaudio_delta16_table[*src++];
- cin->delta = clip(cin->delta, -32768, 32767);
+ cin->delta = av_clip(cin->delta, -32768, 32767);
*samples++ = cin->delta;
--buf_size;
}
diff --git a/contrib/ffmpeg/libavcodec/dsputil.c b/contrib/ffmpeg/libavcodec/dsputil.c
index 51eddbc60..3f5e845e7 100644
--- a/contrib/ffmpeg/libavcodec/dsputil.c
+++ b/contrib/ffmpeg/libavcodec/dsputil.c
@@ -1178,19 +1178,19 @@ void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+ src[index+stride+1]* frac_x )* frac_y
+ r)>>(shift*2);
}else{
- index= src_x + clip(src_y, 0, height)*stride;
+ index= src_x + av_clip(src_y, 0, height)*stride;
dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
+ src[index +1]* frac_x )*s
+ r)>>(shift*2);
}
}else{
if((unsigned)src_y < height){
- index= clip(src_x, 0, width) + src_y*stride;
+ index= av_clip(src_x, 0, width) + src_y*stride;
dst[y*stride + x]= ( ( src[index ]*(s-frac_y)
+ src[index+stride ]* frac_y )*s
+ r)>>(shift*2);
}else{
- index= clip(src_x, 0, width) + clip(src_y, 0, height)*stride;
+ index= av_clip(src_x, 0, width) + av_clip(src_y, 0, height)*stride;
dst[y*stride + x]= src[index ];
}
}
@@ -2434,8 +2434,8 @@ H264_MC(avg_, 16)
#undef op2_put
#endif
-#define op_scale1(x) block[x] = clip_uint8( (block[x]*weight + offset) >> log2_denom )
-#define op_scale2(x) dst[x] = clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
+#define op_scale1(x) block[x] = av_clip_uint8( (block[x]*weight + offset) >> log2_denom )
+#define op_scale2(x) dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
#define H264_WEIGHT(W,H) \
static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \
int y; \
@@ -2549,6 +2549,11 @@ void ff_put_vc1_mspel_mc00_c(uint8_t *dst, uint8_t *src, int stride, int rnd) {
}
#endif /* CONFIG_VC1_DECODER||CONFIG_WMV3_DECODER */
+#if defined(CONFIG_H264_ENCODER)
+/* H264 specific */
+void ff_h264dsp_init(DSPContext* c, AVCodecContext *avctx);
+#endif /* CONFIG_H264_ENCODER */
+
static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
@@ -2654,7 +2659,7 @@ static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
ad1= FFABS(d1)>>1;
- d2= clip((p0-p3)/4, -ad1, ad1);
+ d2= av_clip((p0-p3)/4, -ad1, ad1);
src[x-2*stride] = p0 - d2;
src[x+ stride] = p3 + d2;
@@ -2689,7 +2694,7 @@ static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
ad1= FFABS(d1)>>1;
- d2= clip((p0-p3)/4, -ad1, ad1);
+ d2= av_clip((p0-p3)/4, -ad1, ad1);
src[y*stride-2] = p0 - d2;
src[y*stride+1] = p3 + d2;
@@ -2747,17 +2752,17 @@ static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystrid
int i_delta;
if( FFABS( p2 - p0 ) < beta ) {
- pix[-2*xstride] = p1 + clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] );
+ pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] );
tc++;
}
if( FFABS( q2 - q0 ) < beta ) {
- pix[ xstride] = q1 + clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] );
+ pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] );
tc++;
}
- i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
- pix[-xstride] = clip_uint8( p0 + i_delta ); /* p0' */
- pix[0] = clip_uint8( q0 - i_delta ); /* q0' */
+ i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
+ pix[-xstride] = av_clip_uint8( p0 + i_delta ); /* p0' */
+ pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
}
pix += ystride;
}
@@ -2791,10 +2796,10 @@ static inline void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystr
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
- int delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
+ int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
- pix[-xstride] = clip_uint8( p0 + delta ); /* p0' */
- pix[0] = clip_uint8( q0 - delta ); /* q0' */
+ pix[-xstride] = av_clip_uint8( p0 + delta ); /* p0' */
+ pix[0] = av_clip_uint8( q0 - delta ); /* q0' */
}
pix += ystride;
}
@@ -3689,6 +3694,14 @@ static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int st
return score;
}
+static int ssd_int8_vs_int16_c(int8_t *pix1, int16_t *pix2, int size){
+ int score=0;
+ int i;
+ for(i=0; i<size; i++)
+ score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
+ return score;
+}
+
WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
@@ -3801,11 +3814,31 @@ void dsputil_static_init(void)
for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
}
+int ff_check_alignment(void){
+ static int did_fail=0;
+ DECLARE_ALIGNED_16(int, aligned);
+
+ if((int)&aligned & 15){
+ if(!did_fail){
+#if defined(HAVE_MMX) || defined(HAVE_ALTIVEC)
+ av_log(NULL, AV_LOG_ERROR,
+ "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
+ "and may be very slow or crash. This is not a bug in libavcodec,\n"
+ "but in the compiler. Do not report crashes to FFmpeg developers.\n");
+#endif
+ did_fail=1;
+ }
+ return -1;
+ }
+ return 0;
+}
void dsputil_init(DSPContext* c, AVCodecContext *avctx)
{
int i;
+ ff_check_alignment();
+
#ifdef CONFIG_ENCODERS
if(avctx->dct_algo==FF_DCT_FASTINT) {
c->fdct = fdct_ifast;
@@ -4006,6 +4039,9 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
#if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
ff_vc1dsp_init(c,avctx);
#endif
+#if defined(CONFIG_H264_ENCODER)
+ ff_h264dsp_init(c,avctx);
+#endif
c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
@@ -4048,6 +4084,8 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->w97[1]= w97_8_c;
#endif
+ c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
+
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
@@ -4069,7 +4107,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->try_8x8basis= try_8x8basis_c;
c->add_8x8basis= add_8x8basis_c;
-#ifdef CONFIG_SNOW_ENCODER
+#ifdef CONFIG_SNOW_DECODER
c->vertical_compose97i = ff_snow_vertical_compose97i;
c->horizontal_compose97i = ff_snow_horizontal_compose97i;
c->inner_add_yblock = ff_snow_inner_add_yblock;
diff --git a/contrib/ffmpeg/libavcodec/dsputil.h b/contrib/ffmpeg/libavcodec/dsputil.h
index 35deb6aab..800669ea7 100644
--- a/contrib/ffmpeg/libavcodec/dsputil.h
+++ b/contrib/ffmpeg/libavcodec/dsputil.h
@@ -200,9 +200,11 @@ typedef struct DSPContext {
me_cmp_func ildct_cmp[5]; //only width 16 used
me_cmp_func frame_skip_cmp[5]; //only width 8 used
+ int (*ssd_int8_vs_int16)(int8_t *pix1, int16_t *pix2, int size);
+
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[4][4] of motion compensation funcions for 4
+ * this is an array[4][4] of motion compensation functions for 4
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination where the result is stored
@@ -226,7 +228,7 @@ typedef struct DSPContext {
/**
* Halfpel motion compensation with no rounding (a+b)>>1.
- * this is an array[2][4] of motion compensation funcions for 2
+ * this is an array[2][4] of motion compensation functions for 2
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination where the result is stored
@@ -238,7 +240,7 @@ typedef struct DSPContext {
/**
* Halfpel motion compensation with no rounding (a+b)>>1.
- * this is an array[2][4] of motion compensation funcions for 2
+ * this is an array[2][4] of motion compensation functions for 2
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination into which the result is averaged (a+b)>>1
@@ -252,7 +254,8 @@ typedef struct DSPContext {
/**
* Thirdpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[12] of motion compensation funcions for the 9 thirdpel positions<br>
+ * this is an array[12] of motion compensation functions for the 9 thirdpe
+ * positions<br>
* *pixels_tab[ xthirdpel + 4*ythirdpel ]
* @param block destination where the result is stored
* @param pixels source
@@ -269,7 +272,7 @@ typedef struct DSPContext {
qpel_mc_func put_mspel_pixels_tab[8];
/**
- * h264 Chram MC
+ * h264 Chroma MC
*/
h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
/* This is really one func used in VC-1 decoding */
@@ -378,15 +381,17 @@ typedef struct DSPContext {
#define BASIS_SHIFT 16
#define RECON_SHIFT 6
+ /* h264 functions */
void (*h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride);
void (*h264_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
void (*h264_idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
void (*h264_idct8_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
+ void (*h264_dct)(DCTELEM block[4][4]);
/* snow wavelet */
void (*vertical_compose97i)(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width);
void (*horizontal_compose97i)(DWTELEM *b, int width);
- void (*inner_add_yblock)(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
+ void (*inner_add_yblock)(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
void (*prefetch)(void *mem, int stride, int h);
@@ -408,6 +413,8 @@ typedef struct DSPContext {
void dsputil_static_init(void);
void dsputil_init(DSPContext* p, AVCodecContext *avctx);
+int ff_check_alignment(void);
+
/**
* permute block according to permuatation.
* @param last last non zero element in scantable order
@@ -480,6 +487,7 @@ int mm_support(void);
#define MM_SSE2 0x0010 /* PIV SSE2 functions */
#define MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
#define MM_SSE3 0x0040 /* Prescott SSE3 functions */
+#define MM_SSSE3 0x0080 /* Conroe SSSE3 functions */
extern int mm_flags;
@@ -590,30 +598,6 @@ void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
#endif
-#ifdef __GNUC__
-
-struct unaligned_64 { uint64_t l; } __attribute__((packed));
-struct unaligned_32 { uint32_t l; } __attribute__((packed));
-struct unaligned_16 { uint16_t l; } __attribute__((packed));
-
-#define LD16(a) (((const struct unaligned_16 *) (a))->l)
-#define LD32(a) (((const struct unaligned_32 *) (a))->l)
-#define LD64(a) (((const struct unaligned_64 *) (a))->l)
-
-#define ST16(a, b) (((struct unaligned_16 *) (a))->l) = (b)
-#define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
-
-#else /* __GNUC__ */
-
-#define LD16(a) (*((uint16_t*)(a)))
-#define LD32(a) (*((uint32_t*)(a)))
-#define LD64(a) (*((uint64_t*)(a)))
-
-#define ST16(a, b) *((uint16_t*)(a)) = (b)
-#define ST32(a, b) *((uint32_t*)(a)) = (b)
-
-#endif /* !__GNUC__ */
-
/* PSNR */
void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
int orig_linesize[3], int coded_linesize,
diff --git a/contrib/ffmpeg/libavcodec/dtsdec.c b/contrib/ffmpeg/libavcodec/dtsdec.c
index 456f3fdef..6763572dd 100644
--- a/contrib/ffmpeg/libavcodec/dtsdec.c
+++ b/contrib/ffmpeg/libavcodec/dtsdec.c
@@ -16,305 +16,253 @@
*
* You should have received a copy of the GNU General Public License
* along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifdef HAVE_AV_CONFIG_H
-#undef HAVE_AV_CONFIG_H
-#endif
-
#include "avcodec.h"
#include <dts.h>
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
#define BUFFER_SIZE 18726
#define HEADER_SIZE 14
-#ifdef LIBDTS_FIXED
-#define CONVERT_LEVEL (1 << 26)
-#define CONVERT_BIAS 0
-#else
#define CONVERT_LEVEL 1
-#define CONVERT_BIAS 384
-#endif
-
-static inline
-int16_t convert (int32_t i)
-{
-#ifdef LIBDTS_FIXED
- i >>= 15;
-#else
- i -= 0x43c00000;
-#endif
- return (i > 32767) ? 32767 : ((i < -32768) ? -32768 : i);
-}
-
-static void
-convert2s16_2 (sample_t * _f, int16_t * s16)
-{
- int i;
- int32_t * f = (int32_t *) _f;
-
- for (i = 0; i < 256; i++)
- {
- s16[2*i] = convert (f[i]);
- s16[2*i+1] = convert (f[i+256]);
- }
-}
-
-static void
-convert2s16_4 (sample_t * _f, int16_t * s16)
-{
- int i;
- int32_t * f = (int32_t *) _f;
+#define CONVERT_BIAS 0
- for (i = 0; i < 256; i++)
- {
- s16[4*i] = convert (f[i]);
- s16[4*i+1] = convert (f[i+256]);
- s16[4*i+2] = convert (f[i+512]);
- s16[4*i+3] = convert (f[i+768]);
- }
-}
+typedef struct DTSContext {
+ dts_state_t *state;
+ uint8_t buf[BUFFER_SIZE];
+ uint8_t *bufptr;
+ uint8_t *bufpos;
+} DTSContext;
-static void
-convert2s16_5 (sample_t * _f, int16_t * s16)
+static inline int16_t
+convert(sample_t s)
{
- int i;
- int32_t * f = (int32_t *) _f;
-
- for (i = 0; i < 256; i++)
- {
- s16[5*i] = convert (f[i]);
- s16[5*i+1] = convert (f[i+256]);
- s16[5*i+2] = convert (f[i+512]);
- s16[5*i+3] = convert (f[i+768]);
- s16[5*i+4] = convert (f[i+1024]);
- }
+ return s * 0x7fff;
}
static void
-convert2s16_multi (sample_t * _f, int16_t * s16, int flags)
+convert2s16_multi(sample_t *f, int16_t *s16, int flags)
{
- int i;
- int32_t * f = (int32_t *) _f;
+ int i;
- switch (flags)
- {
+ switch(flags & (DTS_CHANNEL_MASK | DTS_LFE)){
case DTS_MONO:
- for (i = 0; i < 256; i++)
- {
- s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
- s16[5*i+4] = convert (f[i]);
+ for(i = 0; i < 256; i++){
+ s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
+ s16[5*i+4] = convert(f[i]);
}
- break;
case DTS_CHANNEL:
case DTS_STEREO:
case DTS_DOLBY:
- convert2s16_2 (_f, s16);
- break;
+ for(i = 0; i < 256; i++){
+ s16[2*i] = convert(f[i]);
+ s16[2*i+1] = convert(f[i+256]);
+ }
case DTS_3F:
- for (i = 0; i < 256; i++)
- {
- s16[5*i] = convert (f[i]);
- s16[5*i+1] = convert (f[i+512]);
- s16[5*i+2] = s16[5*i+3] = 0;
- s16[5*i+4] = convert (f[i+256]);
+ for(i = 0; i < 256; i++){
+ s16[5*i] = convert(f[i+256]);
+ s16[5*i+1] = convert(f[i+512]);
+ s16[5*i+2] = s16[5*i+3] = 0;
+ s16[5*i+4] = convert(f[i]);
}
- break;
case DTS_2F2R:
- convert2s16_4 (_f, s16);
- break;
+ for(i = 0; i < 256; i++){
+ s16[4*i] = convert(f[i]);
+ s16[4*i+1] = convert(f[i+256]);
+ s16[4*i+2] = convert(f[i+512]);
+ s16[4*i+3] = convert(f[i+768]);
+ }
case DTS_3F2R:
- convert2s16_5 (_f, s16);
- break;
+ for(i = 0; i < 256; i++){
+ s16[5*i] = convert(f[i+256]);
+ s16[5*i+1] = convert(f[i+512]);
+ s16[5*i+2] = convert(f[i+768]);
+ s16[5*i+3] = convert(f[i+1024]);
+ s16[5*i+4] = convert(f[i]);
+ }
case DTS_MONO | DTS_LFE:
- for (i = 0; i < 256; i++)
- {
- s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
- s16[6*i+4] = convert (f[i+256]);
- s16[6*i+5] = convert (f[i]);
+ for(i = 0; i < 256; i++){
+ s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
+ s16[6*i+4] = convert(f[i]);
+ s16[6*i+5] = convert(f[i+256]);
}
- break;
case DTS_CHANNEL | DTS_LFE:
case DTS_STEREO | DTS_LFE:
case DTS_DOLBY | DTS_LFE:
- for (i = 0; i < 256; i++)
- {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+512]);
- s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
- s16[6*i+5] = convert (f[i]);
+ for(i = 0; i < 256; i++){
+ s16[6*i] = convert(f[i]);
+ s16[6*i+1] = convert(f[i+256]);
+ s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
+ s16[6*i+5] = convert(f[i+512]);
}
- break;
case DTS_3F | DTS_LFE:
- for (i = 0; i < 256; i++)
- {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+768]);
- s16[6*i+2] = s16[6*i+3] = 0;
- s16[6*i+4] = convert (f[i+512]);
- s16[6*i+5] = convert (f[i]);
+ for(i = 0; i < 256; i++){
+ s16[6*i] = convert(f[i+256]);
+ s16[6*i+1] = convert(f[i+512]);
+ s16[6*i+2] = s16[6*i+3] = 0;
+ s16[6*i+4] = convert(f[i]);
+ s16[6*i+5] = convert(f[i+768]);
}
- break;
case DTS_2F2R | DTS_LFE:
- for (i = 0; i < 256; i++)
- {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+512]);
- s16[6*i+2] = convert (f[i+768]);
- s16[6*i+3] = convert (f[i+1024]);
- s16[6*i+4] = 0;
- s16[6*i+5] = convert (f[i]);
+ for(i = 0; i < 256; i++){
+ s16[6*i] = convert(f[i]);
+ s16[6*i+1] = convert(f[i+256]);
+ s16[6*i+2] = convert(f[i+512]);
+ s16[6*i+3] = convert(f[i+768]);
+ s16[6*i+4] = 0;
+ s16[6*i+5] = convert(f[i+1024]);
}
- break;
case DTS_3F2R | DTS_LFE:
- for (i = 0; i < 256; i++)
- {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+768]);
- s16[6*i+2] = convert (f[i+1024]);
- s16[6*i+3] = convert (f[i+1280]);
- s16[6*i+4] = convert (f[i+512]);
- s16[6*i+5] = convert (f[i]);
+ for(i = 0; i < 256; i++){
+ s16[6*i] = convert(f[i+256]);
+ s16[6*i+1] = convert(f[i+512]);
+ s16[6*i+2] = convert(f[i+768]);
+ s16[6*i+3] = convert(f[i+1024]);
+ s16[6*i+4] = convert(f[i]);
+ s16[6*i+5] = convert(f[i+1280]);
}
- break;
}
}
static int
-channels_multi (int flags)
+channels_multi(int flags)
{
- if (flags & DTS_LFE)
- return 6;
- else if (flags & 1) /* center channel */
- return 5;
- else if ((flags & DTS_CHANNEL_MASK) == DTS_2F2R)
- return 4;
- else
- return 2;
+ switch(flags & (DTS_CHANNEL_MASK | DTS_LFE)){
+ case DTS_CHANNEL:
+ case DTS_STEREO:
+ case DTS_DOLBY:
+ return 2;
+ case DTS_2F2R:
+ return 4;
+ case DTS_MONO:
+ case DTS_3F:
+ case DTS_3F2R:
+ return 5;
+ case DTS_MONO | DTS_LFE:
+ case DTS_CHANNEL | DTS_LFE:
+ case DTS_STEREO | DTS_LFE:
+ case DTS_DOLBY | DTS_LFE:
+ case DTS_3F | DTS_LFE:
+ case DTS_2F2R | DTS_LFE:
+ case DTS_3F2R | DTS_LFE:
+ return 6;
+ }
+
+ return -1;
}
static int
-dts_decode_frame (AVCodecContext *avctx, void *data, int *data_size,
- uint8_t *buff, int buff_size)
+dts_decode_frame(AVCodecContext * avctx, void *data, int *data_size,
+ uint8_t * buff, int buff_size)
{
- uint8_t * start = buff;
- uint8_t * end = buff + buff_size;
- static uint8_t buf[BUFFER_SIZE];
- static uint8_t * bufptr = buf;
- static uint8_t * bufpos = buf + HEADER_SIZE;
+ DTSContext *s = avctx->priv_data;
+ uint8_t *start = buff;
+ uint8_t *end = buff + buff_size;
+ int16_t *out_samples = data;
+ int sample_rate;
+ int frame_length;
+ int flags;
+ int bit_rate;
+ int len;
+ level_t level;
+ sample_t bias;
+ int nblocks;
+ int i;
+
+ *data_size = 0;
- static int sample_rate;
- static int frame_length;
- static int flags;
- int bit_rate;
- int len;
- dts_state_t *state = avctx->priv_data;
+ while(1) {
+ int length;
- *data_size = 0;
+ len = end - start;
+ if(!len)
+ break;
+ if(len > s->bufpos - s->bufptr)
+ len = s->bufpos - s->bufptr;
+ memcpy(s->bufptr, start, len);
+ s->bufptr += len;
+ start += len;
+ if(s->bufptr != s->bufpos)
+ return start - buff;
+ if(s->bufpos != s->buf + HEADER_SIZE)
+ break;
- while (1)
- {
- len = end - start;
- if (!len)
- break;
- if (len > bufpos - bufptr)
- len = bufpos - bufptr;
- memcpy (bufptr, start, len);
- bufptr += len;
- start += len;
- if (bufptr != bufpos)
- return start - buff;
- if (bufpos != buf + HEADER_SIZE)
- break;
+ length = dts_syncinfo(s->state, s->buf, &flags, &sample_rate,
+ &bit_rate, &frame_length);
+ if(!length) {
+ av_log(NULL, AV_LOG_INFO, "skip\n");
+ for(s->bufptr = s->buf; s->bufptr < s->buf + HEADER_SIZE - 1; s->bufptr++)
+ s->bufptr[0] = s->bufptr[1];
+ continue;
+ }
+ s->bufpos = s->buf + length;
+ }
- {
- int length;
+ level = CONVERT_LEVEL;
+ bias = CONVERT_BIAS;
- length = dts_syncinfo (state, buf, &flags, &sample_rate,
- &bit_rate, &frame_length);
- if (!length)
- {
- av_log (NULL, AV_LOG_INFO, "skip\n");
- for (bufptr = buf; bufptr < buf + HEADER_SIZE-1; bufptr++)
- bufptr[0] = bufptr[1];
- continue;
- }
- bufpos = buf + length;
- }
+ flags |= DTS_ADJUST_LEVEL;
+ if(dts_frame(s->state, s->buf, &flags, &level, bias)) {
+ av_log(avctx, AV_LOG_ERROR, "dts_frame() failed\n");
+ goto end;
}
- {
- level_t level;
- sample_t bias;
- int i;
+ avctx->sample_rate = sample_rate;
+ avctx->channels = channels_multi(flags);
+ avctx->bit_rate = bit_rate;
+
+ nblocks = dts_blocks_num(s->state);
- flags = 2; /* ???????????? */
- level = CONVERT_LEVEL;
- bias = CONVERT_BIAS;
+ for(i = 0; i < nblocks; i++) {
+ if(dts_block(s->state)) {
+ av_log(avctx, AV_LOG_ERROR, "dts_block() failed\n");
+ goto end;
+ }
- flags |= DTS_ADJUST_LEVEL;
- if (dts_frame (state, buf, &flags, &level, bias))
- goto error;
- avctx->sample_rate = sample_rate;
- avctx->channels = channels_multi (flags);
- avctx->bit_rate = bit_rate;
- for (i = 0; i < dts_blocks_num (state); i++)
- {
- if (dts_block (state))
- goto error;
- {
- int chans;
- chans = channels_multi (flags);
- convert2s16_multi (dts_samples (state), data,
- flags & (DTS_CHANNEL_MASK | DTS_LFE));
+ convert2s16_multi(dts_samples(s->state), out_samples, flags);
- data += 256 * sizeof (int16_t) * chans;
- *data_size += 256 * sizeof (int16_t) * chans;
- }
- }
- bufptr = buf;
- bufpos = buf + HEADER_SIZE;
- return start-buff;
- error:
- av_log (NULL, AV_LOG_ERROR, "error\n");
- bufptr = buf;
- bufpos = buf + HEADER_SIZE;
- }
+ out_samples += 256 * avctx->channels;
+ *data_size += 256 * sizeof(int16_t) * avctx->channels;
+ }
- return start-buff;
+end:
+ s->bufptr = s->buf;
+ s->bufpos = s->buf + HEADER_SIZE;
+ return start - buff;
}
static int
-dts_decode_init (AVCodecContext *avctx)
+dts_decode_init(AVCodecContext * avctx)
{
- avctx->priv_data = dts_init (0);
- if (avctx->priv_data == NULL)
- return -1;
+ DTSContext *s = avctx->priv_data;
+ s->bufptr = s->buf;
+ s->bufpos = s->buf + HEADER_SIZE;
+ s->state = dts_init(0);
+ if(s->state == NULL)
+ return -1;
- return 0;
+ return 0;
}
static int
-dts_decode_end (AVCodecContext *s)
+dts_decode_end(AVCodecContext * avctx)
{
- return 0;
+ DTSContext *s = avctx->priv_data;
+ dts_free(s->state);
+ return 0;
}
AVCodec dts_decoder = {
- "dts",
- CODEC_TYPE_AUDIO,
- CODEC_ID_DTS,
- sizeof (dts_state_t *),
- dts_decode_init,
- NULL,
- dts_decode_end,
- dts_decode_frame,
+ "dts",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_DTS,
+ sizeof(DTSContext),
+ dts_decode_init,
+ NULL,
+ dts_decode_end,
+ dts_decode_frame,
};
diff --git a/contrib/ffmpeg/libavcodec/dv.c b/contrib/ffmpeg/libavcodec/dv.c
index 76095a481..19615b431 100644
--- a/contrib/ffmpeg/libavcodec/dv.c
+++ b/contrib/ffmpeg/libavcodec/dv.c
@@ -75,12 +75,12 @@ static void* dv_anchor[DV_ANCHOR_SIZE];
#endif
/* XXX: also include quantization */
-static RL_VLC_ELEM *dv_rl_vlc;
+static RL_VLC_ELEM dv_rl_vlc[1184];
/* VLC encoding lookup table */
static struct dv_vlc_pair {
uint32_t vlc;
uint8_t size;
-} (*dv_vlc_map)[DV_VLC_MAP_LEV_SIZE] = NULL;
+} dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
static void dv_build_unquantize_tables(DVVideoContext *s, uint8_t* perm)
{
@@ -123,10 +123,6 @@ static int dvvideo_init(AVCodecContext *avctx)
done = 1;
- dv_vlc_map = av_mallocz_static(DV_VLC_MAP_LEV_SIZE*DV_VLC_MAP_RUN_SIZE*sizeof(struct dv_vlc_pair));
- if (!dv_vlc_map)
- return -ENOMEM;
-
/* dv_anchor lets each thread know its Id */
for (i=0; i<DV_ANCHOR_SIZE; i++)
dv_anchor[i] = (void*)(size_t)i;
@@ -154,10 +150,7 @@ static int dvvideo_init(AVCodecContext *avctx)
to accelerate the parsing of partial codes */
init_vlc(&dv_vlc, TEX_VLC_BITS, j,
new_dv_vlc_len, 1, 1, new_dv_vlc_bits, 2, 2, 0);
-
- dv_rl_vlc = av_mallocz_static(dv_vlc.table_size * sizeof(RL_VLC_ELEM));
- if (!dv_rl_vlc)
- return -ENOMEM;
+ assert(dv_vlc.table_size == 1184);
for(i = 0; i < dv_vlc.table_size; i++){
int code= dv_vlc.table[i][0];
@@ -560,7 +553,7 @@ static inline void dv_decode_video_segment(DVVideoContext *s,
#ifdef DV_CODEC_TINY_TARGET
/* Converts run and level (where level != 0) pair into vlc, returning bit size */
-static always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc)
+static av_always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc)
{
int size;
if (run < DV_VLC_MAP_RUN_SIZE && level < DV_VLC_MAP_LEV_SIZE) {
@@ -585,7 +578,7 @@ static always_inline int dv_rl2vlc(int run, int level, int sign, uint32_t* vlc)
return size;
}
-static always_inline int dv_rl2vlc_size(int run, int level)
+static av_always_inline int dv_rl2vlc_size(int run, int level)
{
int size;
@@ -601,13 +594,13 @@ static always_inline int dv_rl2vlc_size(int run, int level)
return size;
}
#else
-static always_inline int dv_rl2vlc(int run, int l, int sign, uint32_t* vlc)
+static av_always_inline int dv_rl2vlc(int run, int l, int sign, uint32_t* vlc)
{
*vlc = dv_vlc_map[run][l].vlc | sign;
return dv_vlc_map[run][l].size;
}
-static always_inline int dv_rl2vlc_size(int run, int l)
+static av_always_inline int dv_rl2vlc_size(int run, int l)
{
return dv_vlc_map[run][l].size;
}
@@ -627,7 +620,7 @@ typedef struct EncBlockInfo {
uint32_t partial_bit_buffer; /* we can't use uint16_t here */
} EncBlockInfo;
-static always_inline PutBitContext* dv_encode_ac(EncBlockInfo* bi, PutBitContext* pb_pool,
+static av_always_inline PutBitContext* dv_encode_ac(EncBlockInfo* bi, PutBitContext* pb_pool,
PutBitContext* pb_end)
{
int prev;
@@ -670,7 +663,7 @@ static always_inline PutBitContext* dv_encode_ac(EncBlockInfo* bi, PutBitContext
return pb;
}
-static always_inline void dv_set_class_number(DCTELEM* blk, EncBlockInfo* bi,
+static av_always_inline void dv_set_class_number(DCTELEM* blk, EncBlockInfo* bi,
const uint8_t* zigzag_scan, const int *weight, int bias)
{
int i, area;
@@ -742,7 +735,7 @@ static always_inline void dv_set_class_number(DCTELEM* blk, EncBlockInfo* bi,
//FIXME replace this by dsputil
#define SC(x, y) ((s[x] - s[y]) ^ ((s[x] - s[y]) >> 7))
-static always_inline int dv_guess_dct_mode(DCTELEM *blk) {
+static av_always_inline int dv_guess_dct_mode(DCTELEM *blk) {
DCTELEM *s;
int score88 = 0;
int score248 = 0;
@@ -845,7 +838,7 @@ static inline void dv_encode_video_segment(DVVideoContext *s,
uint8_t* data;
uint8_t* ptr;
int do_edge_wrap;
- DECLARE_ALIGNED_8(DCTELEM, block[64]);
+ DECLARE_ALIGNED_16(DCTELEM, block[64]);
EncBlockInfo enc_blks[5*6];
PutBitContext pbs[5*6];
PutBitContext* pb;
@@ -853,7 +846,7 @@ static inline void dv_encode_video_segment(DVVideoContext *s,
int vs_bit_size = 0;
int qnos[5];
- assert((((int)block) & 7) == 0);
+ assert((((int)block) & 15) == 0);
enc_blk = &enc_blks[0];
pb = &pbs[0];
@@ -1229,6 +1222,10 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size,
static int dvvideo_close(AVCodecContext *c)
{
+ DVVideoContext *s = c->priv_data;
+
+ if(s->picture.data[0])
+ c->release_buffer(c, &s->picture);
return 0;
}
@@ -1242,10 +1239,7 @@ AVCodec dvvideo_encoder = {
sizeof(DVVideoContext),
dvvideo_init,
dvvideo_encode_frame,
- dvvideo_close,
- NULL,
- CODEC_CAP_DR1,
- NULL
+ .pix_fmts = (enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, -1},
};
#endif // CONFIG_DVVIDEO_ENCODER
diff --git a/contrib/ffmpeg/libavcodec/dvbsubdec.c b/contrib/ffmpeg/libavcodec/dvbsubdec.c
index ff43ca6b9..08ef6213e 100644
--- a/contrib/ffmpeg/libavcodec/dvbsubdec.c
+++ b/contrib/ffmpeg/libavcodec/dvbsubdec.c
@@ -32,7 +32,7 @@
#define DVBSUB_OBJECT_SEGMENT 0x13
#define DVBSUB_DISPLAY_SEGMENT 0x80
-static unsigned char *cm;
+#define cm (ff_cropTbl + MAX_NEG_CROP)
#ifdef DEBUG_SAVE_IMAGES
#undef fprintf
@@ -344,8 +344,6 @@ static int dvbsub_init_decoder(AVCodecContext *avctx)
int i, r, g, b, a = 0;
DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
- cm = ff_cropTbl + MAX_NEG_CROP;
-
memset(avctx->priv_data, 0, sizeof(DVBSubContext));
ctx->composition_id = avctx->sub_id & 0xffff;
@@ -851,7 +849,7 @@ static void dvbsub_parse_object_segment(AVCodecContext *avctx,
int coding_method, non_modifying_colour;
- object_id = BE_16(buf);
+ object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
@@ -863,9 +861,9 @@ static void dvbsub_parse_object_segment(AVCodecContext *avctx,
non_modifying_colour = ((*buf++) >> 1) & 1;
if (coding_method == 0) {
- top_field_len = BE_16(buf);
+ top_field_len = AV_RB16(buf);
buf += 2;
- bottom_field_len = BE_16(buf);
+ bottom_field_len = AV_RB16(buf);
buf += 2;
if (buf + top_field_len + bottom_field_len > buf_end) {
@@ -1042,9 +1040,9 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
fill = ((*buf++) >> 3) & 1;
- region->width = BE_16(buf);
+ region->width = AV_RB16(buf);
buf += 2;
- region->height = BE_16(buf);
+ region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
@@ -1086,7 +1084,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
- object_id = BE_16(buf);
+ object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
@@ -1106,9 +1104,9 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
display->object_id = object_id;
display->region_id = region_id;
- display->x_pos = BE_16(buf) & 0xfff;
+ display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
- display->y_pos = BE_16(buf) & 0xfff;
+ display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
@@ -1171,9 +1169,9 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
display->region_id = region_id;
- display->x_pos = BE_16(buf);
+ display->x_pos = AV_RB16(buf);
buf += 2;
- display->y_pos = BE_16(buf);
+ display->y_pos = AV_RB16(buf);
buf += 2;
*tmp_ptr = display->next;
@@ -1405,9 +1403,9 @@ static int dvbsub_decode(AVCodecContext *avctx,
{
p += 1;
segment_type = *p++;
- page_id = BE_16(p);
+ page_id = AV_RB16(p);
p += 2;
- segment_length = BE_16(p);
+ segment_length = AV_RB16(p);
p += 2;
if (page_id == ctx->composition_id || page_id == ctx->ancillary_id) {
@@ -1576,7 +1574,7 @@ static int dvbsub_parse(AVCodecParserContext *s,
{
if (p + 6 <= p_end)
{
- len = BE_16(p + 4);
+ len = AV_RB16(p + 4);
if (p + len + 6 <= p_end)
{
diff --git a/contrib/ffmpeg/libavcodec/dvdata.h b/contrib/ffmpeg/libavcodec/dvdata.h
index dce4aba98..e688ffbb0 100644
--- a/contrib/ffmpeg/libavcodec/dvdata.h
+++ b/contrib/ffmpeg/libavcodec/dvdata.h
@@ -49,7 +49,7 @@ typedef struct DVprofile {
/* for 48Khz, 44.1Khz and 32Khz */
int audio_samples_dist[5];/* how many samples are supposed to be */
/* in each frame in a 5 frames window */
- const uint16_t (*audio_shuffle)[9]; /* PCM shuffling table */
+ const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */
} DVprofile;
#define NB_DV_VLC 409
@@ -2504,7 +2504,7 @@ static const int dv_iweight_248[64] = {
22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642,
};
-static const uint16_t dv_audio_shuffle525[10][9] = {
+static const uint8_t dv_audio_shuffle525[10][9] = {
{ 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
{ 6, 36, 66, 26, 56, 86, 16, 46, 76 },
{ 12, 42, 72, 2, 32, 62, 22, 52, 82 },
@@ -2518,7 +2518,7 @@ static const uint16_t dv_audio_shuffle525[10][9] = {
{ 25, 55, 85, 15, 45, 75, 5, 35, 65 },
};
-static const uint16_t dv_audio_shuffle625[12][9] = {
+static const uint8_t dv_audio_shuffle625[12][9] = {
{ 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */
{ 6, 42, 78, 32, 68, 104, 22, 58, 94},
{ 12, 48, 84, 2, 38, 74, 28, 64, 100},
diff --git a/contrib/ffmpeg/libavcodec/dvdsubdec.c b/contrib/ffmpeg/libavcodec/dvdsubdec.c
index 9a0dd7756..3a93a6076 100644
--- a/contrib/ffmpeg/libavcodec/dvdsubdec.c
+++ b/contrib/ffmpeg/libavcodec/dvdsubdec.c
@@ -27,11 +27,6 @@ static int dvdsub_init_decoder(AVCodecContext *avctx)
return 0;
}
-static uint16_t getbe16(const uint8_t *p)
-{
- return (p[0] << 8) | p[1];
-}
-
static int get_nibble(const uint8_t *buf, int nibble_offset)
{
return (buf[nibble_offset >> 1] >> ((1 - (nibble_offset & 1)) << 2)) & 0xf;
@@ -142,10 +137,10 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header,
sub_header->start_display_time = 0;
sub_header->end_display_time = 0;
- cmd_pos = getbe16(buf + 2);
+ cmd_pos = AV_RB16(buf + 2);
while ((cmd_pos + 4) < buf_size) {
- date = getbe16(buf + cmd_pos);
- next_cmd_pos = getbe16(buf + cmd_pos + 2);
+ date = AV_RB16(buf + cmd_pos);
+ next_cmd_pos = AV_RB16(buf + cmd_pos + 2);
#ifdef DEBUG
av_log(NULL, AV_LOG_INFO, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
@@ -211,8 +206,8 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header,
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
- offset1 = getbe16(buf + pos);
- offset2 = getbe16(buf + pos + 2);
+ offset1 = AV_RB16(buf + pos);
+ offset2 = AV_RB16(buf + pos + 2);
#ifdef DEBUG
av_log(NULL, AV_LOG_INFO, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
#endif
@@ -249,7 +244,7 @@ static int decode_dvd_subtitles(AVSubtitle *sub_header,
sub_header->rects = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0].rgba_palette = av_malloc(4 * 4);
- decode_rle(bitmap, w * 2, w, h / 2,
+ decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1 * 2, buf_size);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2 * 2, buf_size);
@@ -438,7 +433,7 @@ static int dvdsub_parse(AVCodecParserContext *s,
if (pc->packet_index == 0) {
if (buf_size < 2)
return 0;
- pc->packet_len = (buf[0] << 8) | buf[1];
+ pc->packet_len = AV_RB16(buf);
av_freep(&pc->packet);
pc->packet = av_malloc(pc->packet_len);
}
diff --git a/contrib/ffmpeg/libavcodec/dxa.c b/contrib/ffmpeg/libavcodec/dxa.c
new file mode 100644
index 000000000..fc201ccb4
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/dxa.c
@@ -0,0 +1,333 @@
+/*
+ * Feeble Files/ScummVM DXA decoder
+ * Copyright (c) 2007 Konstantin Shishkov
+ *
+ * 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 dxa.c
+ * DXA Video decoder
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "common.h"
+#include "avcodec.h"
+
+#include <zlib.h>
+
+/*
+ * Decoder context
+ */
+typedef struct DxaDecContext {
+ AVCodecContext *avctx;
+ AVFrame pic, prev;
+
+ int dsize;
+ uint8_t *decomp_buf;
+ uint32_t pal[256];
+} DxaDecContext;
+
+static const int shift1[6] = { 0, 8, 8, 8, 4, 4 };
+static const int shift2[6] = { 0, 0, 8, 4, 0, 4 };
+
+static int decode_13(AVCodecContext *avctx, DxaDecContext *c, uint8_t* dst, uint8_t *src, uint8_t *ref)
+{
+ uint8_t *code, *data, *mv, *msk, *tmp, *tmp2;
+ int i, j, k;
+ int type, x, y, d, d2;
+ int stride = c->pic.linesize[0];
+ uint32_t mask;
+
+ code = src + 12;
+ data = code + ((avctx->width * avctx->height) >> 4);
+ mv = data + AV_RB32(src + 0);
+ msk = mv + AV_RB32(src + 4);
+
+ for(j = 0; j < avctx->height; j += 4){
+ for(i = 0; i < avctx->width; i += 4){
+ tmp = dst + i;
+ tmp2 = ref + i;
+ type = *code++;
+ switch(type){
+ case 4: // motion compensation
+ x = (*mv) >> 4; if(x & 8) x = 8 - x;
+ y = (*mv++) & 0xF; if(y & 8) y = 8 - y;
+ tmp2 += x + y*stride;
+ case 0: // skip
+ case 5: // skip in method 12
+ for(y = 0; y < 4; y++){
+ memcpy(tmp, tmp2, 4);
+ tmp += stride;
+ tmp2 += stride;
+ }
+ break;
+ case 1: // masked change
+ case 10: // masked change with only half of pixels changed
+ case 11: // cases 10-15 are for method 12 only
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ if(type == 1){
+ mask = AV_RB16(msk);
+ msk += 2;
+ }else{
+ type -= 10;
+ mask = ((msk[0] & 0xF0) << shift1[type]) | ((msk[0] & 0xF) << shift2[type]);
+ msk++;
+ }
+ for(y = 0; y < 4; y++){
+ for(x = 0; x < 4; x++){
+ tmp[x] = (mask & 0x8000) ? *data++ : tmp2[x];
+ mask <<= 1;
+ }
+ tmp += stride;
+ tmp2 += stride;
+ }
+ break;
+ case 2: // fill block
+ for(y = 0; y < 4; y++){
+ memset(tmp, data[0], 4);
+ tmp += stride;
+ }
+ data++;
+ break;
+ case 3: // raw block
+ for(y = 0; y < 4; y++){
+ memcpy(tmp, data, 4);
+ data += 4;
+ tmp += stride;
+ }
+ break;
+ case 8: // subblocks - method 13 only
+ mask = *msk++;
+ for(k = 0; k < 4; k++){
+ d = ((k & 1) << 1) + ((k & 2) * stride);
+ d2 = ((k & 1) << 1) + ((k & 2) * stride);
+ tmp2 = ref + i + d2;
+ switch(mask & 0xC0){
+ case 0x80: // motion compensation
+ x = (*mv) >> 4; if(x & 8) x = 8 - x;
+ y = (*mv++) & 0xF; if(y & 8) y = 8 - y;
+ tmp2 += x + y*stride;
+ case 0x00: // skip
+ tmp[d + 0 ] = tmp2[0];
+ tmp[d + 1 ] = tmp2[1];
+ tmp[d + 0 + stride] = tmp2[0 + stride];
+ tmp[d + 1 + stride] = tmp2[1 + stride];
+ break;
+ case 0x40: // fill
+ tmp[d + 0 ] = data[0];
+ tmp[d + 1 ] = data[0];
+ tmp[d + 0 + stride] = data[0];
+ tmp[d + 1 + stride] = data[0];
+ data++;
+ break;
+ case 0xC0: // raw
+ tmp[d + 0 ] = *data++;
+ tmp[d + 1 ] = *data++;
+ tmp[d + 0 + stride] = *data++;
+ tmp[d + 1 + stride] = *data++;
+ break;
+ }
+ mask <<= 2;
+ }
+ break;
+ case 32: // vector quantization - 2 colors
+ mask = AV_RB16(msk);
+ msk += 2;
+ for(y = 0; y < 4; y++){
+ for(x = 0; x < 4; x++){
+ tmp[x] = data[mask & 1];
+ mask >>= 1;
+ }
+ tmp += stride;
+ tmp2 += stride;
+ }
+ data += 2;
+ break;
+ case 33: // vector quantization - 3 or 4 colors
+ case 34:
+ mask = AV_RB32(msk);
+ msk += 4;
+ for(y = 0; y < 4; y++){
+ for(x = 0; x < 4; x++){
+ tmp[x] = data[mask & 3];
+ mask >>= 2;
+ }
+ tmp += stride;
+ tmp2 += stride;
+ }
+ data += type - 30;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown opcode %d\n", type);
+ return -1;
+ }
+ }
+ dst += stride * 4;
+ ref += stride * 4;
+ }
+ return 0;
+}
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
+{
+ DxaDecContext * const c = (DxaDecContext *)avctx->priv_data;
+ uint8_t *outptr, *srcptr, *tmpptr;
+ unsigned long dsize;
+ int i, j, compr;
+ int stride;
+ int orig_buf_size = buf_size;
+ int pc = 0;
+
+ /* make the palette available on the way out */
+ if(buf[0]=='C' && buf[1]=='M' && buf[2]=='A' && buf[3]=='P'){
+ int r, g, b;
+
+ buf += 4;
+ for(i = 0; i < 256; i++){
+ r = *buf++;
+ g = *buf++;
+ b = *buf++;
+ c->pal[i] = (r << 16) | (g << 8) | b;
+ }
+ pc = 1;
+ buf_size -= 768+4;
+ }
+
+ if(avctx->get_buffer(avctx, &c->pic) < 0){
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return -1;
+ }
+ memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE);
+ c->pic.palette_has_changed = pc;
+
+ outptr = c->pic.data[0];
+ srcptr = c->decomp_buf;
+ tmpptr = c->prev.data[0];
+ stride = c->pic.linesize[0];
+
+ if(buf[0]=='N' && buf[1]=='U' && buf[2]=='L' && buf[3]=='L')
+ compr = -1;
+ else
+ compr = buf[4];
+
+ dsize = c->dsize;
+ if((compr != 4 && compr != -1) && uncompress(c->decomp_buf, &dsize, buf + 9, buf_size - 9) != Z_OK){
+ av_log(avctx, AV_LOG_ERROR, "Uncompress failed!\n");
+ return -1;
+ }
+ switch(compr){
+ case -1:
+ c->pic.key_frame = 0;
+ c->pic.pict_type = FF_P_TYPE;
+ if(c->prev.data[0])
+ memcpy(c->pic.data[0], c->prev.data[0], c->pic.linesize[0] * avctx->height);
+ else{ // Should happen only when first frame is 'NULL'
+ memset(c->pic.data[0], 0, c->pic.linesize[0] * avctx->height);
+ c->pic.key_frame = 1;
+ c->pic.pict_type = FF_I_TYPE;
+ }
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ c->pic.key_frame = !(compr & 1);
+ c->pic.pict_type = (compr & 1) ? FF_P_TYPE : FF_I_TYPE;
+ for(j = 0; j < avctx->height; j++){
+ if(compr & 1){
+ for(i = 0; i < avctx->width; i++)
+ outptr[i] = srcptr[i] ^ tmpptr[i];
+ tmpptr += stride;
+ }else
+ memcpy(outptr, srcptr, avctx->width);
+ outptr += stride;
+ srcptr += avctx->width;
+ }
+ break;
+ case 12: // ScummVM coding
+ case 13:
+ c->pic.key_frame = 0;
+ c->pic.pict_type = FF_P_TYPE;
+ decode_13(avctx, c, c->pic.data[0], srcptr, c->prev.data[0]);
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unknown/unsupported compression type %d\n", buf[4]);
+ return -1;
+ }
+
+ FFSWAP(AVFrame, c->pic, c->prev);
+ if(c->pic.data[0])
+ avctx->release_buffer(avctx, &c->pic);
+
+ *data_size = sizeof(AVFrame);
+ *(AVFrame*)data = c->prev;
+
+ /* always report that the buffer was completely consumed */
+ return orig_buf_size;
+}
+
+static int decode_init(AVCodecContext *avctx)
+{
+ DxaDecContext * const c = (DxaDecContext *)avctx->priv_data;
+
+ c->avctx = avctx;
+ avctx->pix_fmt = PIX_FMT_PAL8;
+
+ if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+ return -1;
+ }
+
+ c->dsize = avctx->width * avctx->height * 2;
+ if((c->decomp_buf = av_malloc(c->dsize)) == NULL) {
+ av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int decode_end(AVCodecContext *avctx)
+{
+ DxaDecContext * const c = (DxaDecContext *)avctx->priv_data;
+
+ av_freep(&c->decomp_buf);
+ if(c->prev.data[0])
+ avctx->release_buffer(avctx, &c->prev);
+ if(c->pic.data[0])
+ avctx->release_buffer(avctx, &c->pic);
+
+ return 0;
+}
+
+AVCodec dxa_decoder = {
+ "dxa",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_DXA,
+ sizeof(DxaDecContext),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame
+};
+
diff --git a/contrib/ffmpeg/libavcodec/error_resilience.c b/contrib/ffmpeg/libavcodec/error_resilience.c
index 0923721ee..175ccf73a 100644
--- a/contrib/ffmpeg/libavcodec/error_resilience.c
+++ b/contrib/ffmpeg/libavcodec/error_resilience.c
@@ -612,12 +612,17 @@ void ff_er_frame_start(MpegEncContext *s){
* error of the same type occured
*/
void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status){
- const int start_i= clip(startx + starty * s->mb_width , 0, s->mb_num-1);
- const int end_i = clip(endx + endy * s->mb_width , 0, s->mb_num);
+ const int start_i= av_clip(startx + starty * s->mb_width , 0, s->mb_num-1);
+ const int end_i = av_clip(endx + endy * s->mb_width , 0, s->mb_num);
const int start_xy= s->mb_index2xy[start_i];
const int end_xy = s->mb_index2xy[end_i];
int mask= -1;
+ if(start_i > end_i || start_xy > end_xy){
+ av_log(s->avctx, AV_LOG_ERROR, "internal error, slice end before start\n");
+ return;
+ }
+
if(!s->error_resilience) return;
mask &= ~VP_START;
diff --git a/contrib/ffmpeg/libavcodec/eval.c b/contrib/ffmpeg/libavcodec/eval.c
index 961c8b5ac..877de3552 100644
--- a/contrib/ffmpeg/libavcodec/eval.c
+++ b/contrib/ffmpeg/libavcodec/eval.c
@@ -110,7 +110,7 @@ static double av_strtod(const char *name, char **tail) {
if(*next=='B') {
d*=8;
- *next++;
+ next++;
}
}
/* if requested, fill in tail with the position after the last parsed
@@ -155,7 +155,7 @@ static double eval_expr(Parser * p, AVEvalExpr * e) {
case e_func2: return e->value * e->a.func2(p->opaque, eval_expr(p, e->param[0]), eval_expr(p, e->param[1]));
case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0])));
case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); }
- case e_ld: return e->value * p->var[clip(eval_expr(p, e->param[0]), 0, VARS-1)];
+ case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)];
case e_while: {
double d = NAN;
while(eval_expr(p, e->param[0]))
@@ -177,7 +177,7 @@ static double eval_expr(Parser * p, AVEvalExpr * e) {
case e_div: return e->value * (d / d2);
case e_add: return e->value * (d + d2);
case e_last:return e->value * d2;
- case e_st : return e->value * (p->var[clip(d, 0, VARS-1)]= d2);
+ case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);
}
}
}
diff --git a/contrib/ffmpeg/libavcodec/faac.c b/contrib/ffmpeg/libavcodec/faac.c
index 06e0b4920..9ff9f5ed0 100644
--- a/contrib/ffmpeg/libavcodec/faac.c
+++ b/contrib/ffmpeg/libavcodec/faac.c
@@ -76,15 +76,19 @@ static int Faac_encode_init(AVCodecContext *avctx)
avctx->extradata_size = 0;
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
- unsigned char *buffer;
+ unsigned char *buffer = NULL;
unsigned long decoder_specific_info_size;
if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer,
&decoder_specific_info_size)) {
- avctx->extradata = buffer;
+ avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = decoder_specific_info_size;
+ memcpy(avctx->extradata, buffer, avctx->extradata_size);
faac_cfg->outputFormat = 0;
}
+#undef free
+ free(buffer);
+#define free please_use_av_free
}
if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
@@ -115,8 +119,7 @@ static int Faac_encode_close(AVCodecContext *avctx)
FaacAudioContext *s = avctx->priv_data;
av_freep(&avctx->coded_frame);
-
- //if (avctx->extradata_size) free(avctx->extradata);
+ av_freep(&avctx->extradata);
faacEncClose(s->faac_handle);
return 0;
diff --git a/contrib/ffmpeg/libavcodec/faad.c b/contrib/ffmpeg/libavcodec/faad.c
index df33ea0b2..01cbd40e7 100644
--- a/contrib/ffmpeg/libavcodec/faad.c
+++ b/contrib/ffmpeg/libavcodec/faad.c
@@ -35,12 +35,12 @@
#endif
/*
- * when CONFIG_FAADBIN is defined the libfaad will be opened at runtime
+ * when CONFIG_LIBFAADBIN is defined the libfaad will be opened at runtime
*/
-//#undef CONFIG_FAADBIN
-//#define CONFIG_FAADBIN
+//#undef CONFIG_LIBFAADBIN
+//#define CONFIG_LIBFAADBIN
-#ifdef CONFIG_FAADBIN
+#ifdef CONFIG_LIBFAADBIN
#include <dlfcn.h>
static const char* libfaadname = "libfaad.so.0";
#else
@@ -196,8 +196,7 @@ static int faac_decode_end(AVCodecContext *avctx)
{
FAACContext *s = (FAACContext *) avctx->priv_data;
- if (s->faacDecClose)
- s->faacDecClose(s->faac_handle);
+ s->faacDecClose(s->faac_handle);
dlclose(s->handle);
return 0;
@@ -208,7 +207,7 @@ static int faac_decode_init(AVCodecContext *avctx)
FAACContext *s = (FAACContext *) avctx->priv_data;
faacDecConfigurationPtr faac_cfg;
-#ifdef CONFIG_FAADBIN
+#ifdef CONFIG_LIBFAADBIN
const char* err = 0;
s->handle = dlopen(libfaadname, RTLD_LAZY);
@@ -222,12 +221,13 @@ static int faac_decode_init(AVCodecContext *avctx)
do { static const char* n = "faacDec" #a; \
if ((s->faacDec ## a = b dlsym( s->handle, n )) == NULL) { err = n; break; } } while(0)
for(;;) {
-#else /* !CONFIG_FAADBIN */
+#else /* !CONFIG_LIBFAADBIN */
#define dfaac(a, b) s->faacDec ## a = faacDec ## a
-#endif /* CONFIG_FAADBIN */
+#endif /* CONFIG_LIBFAADBIN */
// resolve all needed function calls
dfaac(Open, (faacDecHandle FAADAPI (*)(void)));
+ dfaac(Close, (void FAADAPI (*)(faacDecHandle hDecoder)));
dfaac(GetCurrentConfiguration, (faacDecConfigurationPtr
FAADAPI (*)(faacDecHandle)));
#ifndef FAAD2_VERSION
@@ -239,7 +239,6 @@ static int faac_decode_init(AVCodecContext *avctx)
dfaac(Init2, (int FAADAPI (*)(faacDecHandle, unsigned char*,
unsigned long, unsigned long*,
unsigned long*)));
- dfaac(Close, (void FAADAPI (*)(faacDecHandle hDecoder)));
dfaac(Decode, (int FAADAPI (*)(faacDecHandle, unsigned char*,
unsigned long*, short*, unsigned long*)));
#else
@@ -256,7 +255,7 @@ static int faac_decode_init(AVCodecContext *avctx)
#endif
#undef dfacc
-#ifdef CONFIG_FAADBIN
+#ifdef CONFIG_LIBFAADBIN
break;
}
if (err) {
diff --git a/contrib/ffmpeg/libavcodec/faandct.c b/contrib/ffmpeg/libavcodec/faandct.c
index e3c0d84a2..6f73ee5e9 100644
--- a/contrib/ffmpeg/libavcodec/faandct.c
+++ b/contrib/ffmpeg/libavcodec/faandct.c
@@ -70,7 +70,7 @@ B6*B0, B6*B1, B6*B2, B6*B3, B6*B4, B6*B5, B6*B6, B6*B7,
B7*B0, B7*B1, B7*B2, B7*B3, B7*B4, B7*B5, B7*B6, B7*B7,
};
-static always_inline void row_fdct(FLOAT temp[64], DCTELEM * data)
+static av_always_inline void row_fdct(FLOAT temp[64], DCTELEM * data)
{
FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
FLOAT tmp10, tmp11, tmp12, tmp13;
diff --git a/contrib/ffmpeg/libavcodec/fft-test.c b/contrib/ffmpeg/libavcodec/fft-test.c
index e108a6f7b..d2497383d 100644
--- a/contrib/ffmpeg/libavcodec/fft-test.c
+++ b/contrib/ffmpeg/libavcodec/fft-test.c
@@ -28,6 +28,8 @@
#include <unistd.h>
#include <sys/time.h>
+#undef exit
+
int mm_flags;
/* reference fft */
diff --git a/contrib/ffmpeg/libavcodec/ffv1.c b/contrib/ffmpeg/libavcodec/ffv1.c
index 62623e591..45f408c87 100644
--- a/contrib/ffmpeg/libavcodec/ffv1.c
+++ b/contrib/ffmpeg/libavcodec/ffv1.c
@@ -186,7 +186,7 @@ typedef struct FFV1Context{
DSPContext dsp;
}FFV1Context;
-static always_inline int fold(int diff, int bits){
+static av_always_inline int fold(int diff, int bits){
if(bits==8)
diff= (int8_t)diff;
else{
@@ -600,7 +600,7 @@ static int encode_init(AVCodecContext *avctx)
case PIX_FMT_YUV410P:
s->colorspace= 0;
break;
- case PIX_FMT_RGBA32:
+ case PIX_FMT_RGB32:
s->colorspace= 1;
break;
default:
@@ -895,7 +895,7 @@ static int read_header(FFV1Context *f){
av_log(f->avctx, AV_LOG_ERROR, "chroma subsampling not supported in this colorspace\n");
return -1;
}
- f->avctx->pix_fmt= PIX_FMT_RGBA32;
+ f->avctx->pix_fmt= PIX_FMT_RGB32;
}else{
av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n");
return -1;
@@ -1035,6 +1035,6 @@ AVCodec ffv1_encoder = {
encode_init,
encode_frame,
common_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGBA32, -1},
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, -1},
};
#endif
diff --git a/contrib/ffmpeg/libavcodec/flac.c b/contrib/ffmpeg/libavcodec/flac.c
index 6c64ad0a1..1016ed47f 100644
--- a/contrib/ffmpeg/libavcodec/flac.c
+++ b/contrib/ffmpeg/libavcodec/flac.c
@@ -225,6 +225,10 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order)
rice_order = get_bits(&s->gb, 4);
samples= s->blocksize >> rice_order;
+ if (pred_order > samples) {
+ av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", pred_order, samples);
+ return -1;
+ }
sample=
i= pred_order;
@@ -454,7 +458,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
return 0;
}
-static int decode_frame(FLACContext *s)
+static int decode_frame(FLACContext *s, int alloc_data_size)
{
int blocksize_code, sample_rate_code, sample_size_code, assignment, i, crc8;
int decorrelation, bps, blocksize, samplerate;
@@ -516,6 +520,9 @@ static int decode_frame(FLACContext *s)
return -1;
}
+ if(blocksize * s->channels * sizeof(int16_t) > alloc_data_size)
+ return -1;
+
if (sample_rate_code == 0){
samplerate= s->samplerate;
}else if ((sample_rate_code > 3) && (sample_rate_code < 12))
@@ -579,6 +586,9 @@ static int flac_decode_frame(AVCodecContext *avctx,
FLACContext *s = avctx->priv_data;
int tmp = 0, i, j = 0, input_buf_size = 0;
int16_t *samples = data;
+ int alloc_data_size= *data_size;
+
+ *data_size=0;
if(s->max_framesize == 0){
s->max_framesize= 65536; // should hopefully be enough for the first header
@@ -617,7 +627,7 @@ static int flac_decode_frame(AVCodecContext *avctx,
goto end; // we may not have enough bits left to decode a frame, so try next time
}
skip_bits(&s->gb, 16);
- if (decode_frame(s) < 0){
+ if (decode_frame(s, alloc_data_size) < 0){
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
diff --git a/contrib/ffmpeg/libavcodec/flacenc.c b/contrib/ffmpeg/libavcodec/flacenc.c
index b7b7d0d8e..9dd6c7eb8 100644
--- a/contrib/ffmpeg/libavcodec/flacenc.c
+++ b/contrib/ffmpeg/libavcodec/flacenc.c
@@ -244,7 +244,7 @@ static int flac_encode_init(AVCodecContext *avctx)
/* set compression option overrides from AVCodecContext */
if(avctx->use_lpc >= 0) {
- s->options.use_lpc = clip(avctx->use_lpc, 0, 11);
+ s->options.use_lpc = av_clip(avctx->use_lpc, 0, 11);
}
if(s->options.use_lpc == 1)
av_log(avctx, AV_LOG_DEBUG, " use lpc: Levinson-Durbin recursion with Welch window\n");
@@ -712,7 +712,7 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
error=0;
for(i=0; i<order; i++) {
error += lpc_in[i] * (1 << sh);
- lpc_out[i] = clip(lrintf(error), -qmax, qmax);
+ lpc_out[i] = av_clip(lrintf(error), -qmax, qmax);
error -= lpc_out[i];
}
*shift = sh;
diff --git a/contrib/ffmpeg/libavcodec/flashsv.c b/contrib/ffmpeg/libavcodec/flashsv.c
index fea8e2224..9e4aa951a 100644
--- a/contrib/ffmpeg/libavcodec/flashsv.c
+++ b/contrib/ffmpeg/libavcodec/flashsv.c
@@ -54,9 +54,7 @@
#include "avcodec.h"
#include "bitstream.h"
-#ifdef CONFIG_ZLIB
#include <zlib.h>
-#endif
typedef struct FlashSVContext {
AVCodecContext *avctx;
@@ -65,9 +63,7 @@ typedef struct FlashSVContext {
int block_width, block_height;
uint8_t* tmpblock;
int block_size;
-#ifdef CONFIG_ZLIB
z_stream zstream;
-#endif
} FlashSVContext;
@@ -90,7 +86,6 @@ static int flashsv_decode_init(AVCodecContext *avctx)
int zret; // Zlib return code
s->avctx = avctx;
-#ifdef CONFIG_ZLIB
s->zstream.zalloc = Z_NULL;
s->zstream.zfree = Z_NULL;
s->zstream.opaque = Z_NULL;
@@ -99,10 +94,6 @@ static int flashsv_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
return 1;
}
-#else
- av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled. Needed for the decoder.\n");
- return 1;
-#endif
avctx->pix_fmt = PIX_FMT_BGR24;
avctx->has_b_frames = 0;
s->frame.data[0] = NULL;
@@ -145,12 +136,12 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
if(s->block_size < s->block_width*s->block_height) {
if (s->tmpblock != NULL)
av_free(s->tmpblock);
- s->block_size = s->block_width*s->block_height;
- if ((s->tmpblock = av_malloc(3*s->block_size)) == NULL) {
+ if ((s->tmpblock = av_malloc(3*s->block_width*s->block_height)) == NULL) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
return -1;
}
}
+ s->block_size = s->block_width*s->block_height;
/* init the image size once */
if((avctx->width==0) && (avctx->height==0)){
@@ -198,7 +189,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
/* no change, don't do anything */
} else {
/* decompress block */
-#ifdef CONFIG_ZLIB
int ret = inflateReset(&(s->zstream));
if (ret != Z_OK)
{
@@ -222,10 +212,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret);
/* return -1; */
}
-#else
- av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled in.\n");
- return -1;
-#endif
copy_region(s->tmpblock, s->frame.data[0], s->image_height-(hp+hs+1), wp, hs, ws, s->frame.linesize[0]);
skip_bits(&gb, 8*size); /* skip the consumed bits */
}
@@ -247,9 +233,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
static int flashsv_decode_end(AVCodecContext *avctx)
{
FlashSVContext *s = (FlashSVContext *)avctx->priv_data;
-#ifdef CONFIG_ZLIB
inflateEnd(&(s->zstream));
-#endif
/* release the frame if needed */
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
diff --git a/contrib/ffmpeg/libavcodec/flashsvenc.c b/contrib/ffmpeg/libavcodec/flashsvenc.c
new file mode 100644
index 000000000..cbf488328
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/flashsvenc.c
@@ -0,0 +1,346 @@
+/*
+ * Flash Screen Video encoder
+ * Copyright (C) 2004 Alex Beregszaszi
+ * Copyright (C) 2006 Benjamin Larsson
+ *
+ * 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
+ */
+
+/* Encoding development sponsored by http://fh-campuswien.ac.at */
+
+/**
+ * @file flashsvenc.c
+ * Flash Screen Video encoder
+ * @author Alex Beregszaszi
+ * @author Benjamin Larsson
+ */
+
+/* Bitstream description
+ * The picture is divided into blocks that are zlib-compressed.
+ *
+ * The decoder is fed complete frames, the frameheader contains:
+ * 4bits of block width
+ * 12bits of frame width
+ * 4bits of block height
+ * 12bits of frame height
+ *
+ * Directly after the header are the compressed blocks. The blocks
+ * have their compressed size represented with 16bits in the beginig.
+ * If the size = 0 then the block is unchanged from the previous frame.
+ * All blocks are decompressed until the buffer is consumed.
+ *
+ * Encoding ideas, a basic encoder would just use a fixed block size.
+ * Block sizes can be multipels of 16, from 16 to 256. The blocks don't
+ * have to be quadratic. A brute force search with a set of different
+ * block sizes should give a better result than to just use a fixed size.
+ */
+
+/* TODO:
+ * Don't reencode the frame in brute force mode if the frame is a dupe. Speed up.
+ * Make the difference check faster.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <zlib.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "bitstream.h"
+#include "bytestream.h"
+
+
+typedef struct FlashSVContext {
+ AVCodecContext *avctx;
+ uint8_t *previous_frame;
+ AVFrame frame;
+ int image_width, image_height;
+ int block_width, block_height;
+ uint8_t* tmpblock;
+ uint8_t* encbuffer;
+ int block_size;
+ z_stream zstream;
+ int last_key_frame;
+} FlashSVContext;
+
+static int copy_region_enc(uint8_t *sptr, uint8_t *dptr,
+ int dx, int dy, int h, int w, int stride, uint8_t *pfptr) {
+ int i,j;
+ uint8_t *nsptr;
+ uint8_t *npfptr;
+ int diff = 0;
+
+ for (i = dx+h; i > dx; i--) {
+ nsptr = sptr+(i*stride)+dy*3;
+ npfptr = pfptr+(i*stride)+dy*3;
+ for (j=0 ; j<w*3 ; j++) {
+ diff |=npfptr[j]^nsptr[j];
+ dptr[j] = nsptr[j];
+ }
+ dptr += w*3;
+ }
+ if (diff)
+ return 1;
+ return 0;
+}
+
+static int flashsv_encode_init(AVCodecContext *avctx)
+{
+ FlashSVContext *s = (FlashSVContext *)avctx->priv_data;
+
+ s->avctx = avctx;
+
+ if ((avctx->width > 4095) || (avctx->height > 4095)) {
+ av_log(avctx, AV_LOG_ERROR, "Input dimensions too large, input must be max 4096x4096 !\n");
+ return -1;
+ }
+
+ if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+ return -1;
+ }
+
+ // Needed if zlib unused or init aborted before deflateInit
+ memset(&(s->zstream), 0, sizeof(z_stream));
+/*
+ s->zstream.zalloc = NULL; //av_malloc;
+ s->zstream.zfree = NULL; //av_free;
+ s->zstream.opaque = NULL;
+ zret = deflateInit(&(s->zstream), 9);
+ if (zret != Z_OK) {
+ av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
+ return -1;
+ }
+*/
+
+ s->last_key_frame=0;
+
+ s->image_width = avctx->width;
+ s->image_height = avctx->height;
+
+ s->tmpblock = av_mallocz(3*256*256);
+ s->encbuffer = av_mallocz(s->image_width*s->image_height*3);
+
+ if (!s->tmpblock || !s->encbuffer) {
+ av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static int encode_bitstream(FlashSVContext *s, AVFrame *p, uint8_t *buf, int buf_size,
+ int block_width, int block_height, uint8_t *previous_frame, int* I_frame) {
+
+ PutBitContext pb;
+ int h_blocks, v_blocks, h_part, v_part, i, j;
+ int buf_pos, res;
+ int pred_blocks = 0;
+
+ init_put_bits(&pb, buf, buf_size*8);
+
+ put_bits(&pb, 4, (block_width/16)-1);
+ put_bits(&pb, 12, s->image_width);
+ put_bits(&pb, 4, (block_height/16)-1);
+ put_bits(&pb, 12, s->image_height);
+ flush_put_bits(&pb);
+ buf_pos=4;
+
+ h_blocks = s->image_width / block_width;
+ h_part = s->image_width % block_width;
+ v_blocks = s->image_height / block_height;
+ v_part = s->image_height % block_height;
+
+ /* loop over all block columns */
+ for (j = 0; j < v_blocks + (v_part?1:0); j++)
+ {
+
+ int hp = j*block_height; // horiz position in frame
+ int hs = (j<v_blocks)?block_height:v_part; // size of block
+
+ /* loop over all block rows */
+ for (i = 0; i < h_blocks + (h_part?1:0); i++)
+ {
+ int wp = i*block_width; // vert position in frame
+ int ws = (i<h_blocks)?block_width:h_part; // size of block
+ int ret=Z_OK;
+ uint8_t *ptr;
+
+ ptr = buf+buf_pos;
+
+ //copy the block to the temp buffer before compression (if it differs from the previous frame's block)
+ res = copy_region_enc(p->data[0], s->tmpblock, s->image_height-(hp+hs+1), wp, hs, ws, p->linesize[0], previous_frame);
+
+ if (res || *I_frame) {
+ unsigned long zsize;
+ zsize = 3*block_width*block_height;
+ ret = compress2(ptr+2, &zsize, s->tmpblock, 3*ws*hs, 9);
+
+
+ //ret = deflateReset(&(s->zstream));
+ if (ret != Z_OK)
+ av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j);
+ /*
+ s->zstream.next_in = s->tmpblock;
+ s->zstream.avail_in = 3*ws*hs;
+ s->zstream.total_in = 0;
+
+ s->zstream.next_out = ptr+2;
+ s->zstream.avail_out = buf_size-buf_pos-2;
+ s->zstream.total_out = 0;
+
+ ret = deflate(&(s->zstream), Z_FINISH);
+ if ((ret != Z_OK) && (ret != Z_STREAM_END))
+ av_log(s->avctx, AV_LOG_ERROR, "error while compressing block %dx%d\n", i, j);
+
+ size = s->zstream.total_out;
+ //av_log(avctx, AV_LOG_INFO, "compressed blocks: %d\n", size);
+ */
+ bytestream_put_be16(&ptr,(unsigned int)zsize);
+ buf_pos += zsize+2;
+ //av_log(avctx, AV_LOG_ERROR, "buf_pos = %d\n", buf_pos);
+ } else {
+ pred_blocks++;
+ bytestream_put_be16(&ptr,0);
+ buf_pos += 2;
+ }
+ }
+ }
+
+ if (pred_blocks)
+ *I_frame = 0;
+ else
+ *I_frame = 1;
+
+ return buf_pos;
+}
+
+
+static int flashsv_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data)
+{
+ FlashSVContext * const s = (FlashSVContext *)avctx->priv_data;
+ AVFrame *pict = data;
+ AVFrame * const p = &s->frame;
+ int res;
+ int I_frame = 0;
+ int opt_w, opt_h;
+
+ *p = *pict;
+
+ /* First frame needs to be a keyframe */
+ if (avctx->frame_number == 0) {
+ s->previous_frame = av_mallocz(p->linesize[0]*s->image_height);
+ if (!s->previous_frame) {
+ av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
+ return -1;
+ }
+ I_frame = 1;
+ }
+
+ /* Check the placement of keyframes */
+ if (avctx->gop_size > 0) {
+ if (avctx->frame_number >= s->last_key_frame + avctx->gop_size) {
+ I_frame = 1;
+ }
+ }
+
+#if 0
+ int w, h;
+ int optim_sizes[16][16];
+ int smallest_size;
+ //Try all possible combinations and store the encoded frame sizes
+ for (w=1 ; w<17 ; w++) {
+ for (h=1 ; h<17 ; h++) {
+ optim_sizes[w-1][h-1] = encode_bitstream(s, p, s->encbuffer, s->image_width*s->image_height*4, w*16, h*16, s->previous_frame);
+ //av_log(avctx, AV_LOG_ERROR, "[%d][%d]size = %d\n",w,h,optim_sizes[w-1][h-1]);
+ }
+ }
+
+ //Search for the smallest framesize and encode the frame with those parameters
+ smallest_size=optim_sizes[0][0];
+ opt_w = 0;
+ opt_h = 0;
+ for (w=0 ; w<16 ; w++) {
+ for (h=0 ; h<16 ; h++) {
+ if (optim_sizes[w][h] < smallest_size) {
+ smallest_size = optim_sizes[w][h];
+ opt_w = w;
+ opt_h = h;
+ }
+ }
+ }
+ res = encode_bitstream(s, p, buf, buf_size, (opt_w+1)*16, (opt_h+1)*16, s->previous_frame);
+ av_log(avctx, AV_LOG_ERROR, "[%d][%d]optimal size = %d, res = %d|\n", opt_w, opt_h, smallest_size, res);
+
+ if (buf_size < res)
+ av_log(avctx, AV_LOG_ERROR, "buf_size %d < res %d\n", buf_size, res);
+
+#else
+ opt_w=1;
+ opt_h=1;
+
+ if (buf_size < s->image_width*s->image_height*3) {
+ //Conservative upper bound check for compressed data
+ av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->image_width*s->image_height*3);
+ return -1;
+ }
+
+ res = encode_bitstream(s, p, buf, buf_size, opt_w*16, opt_h*16, s->previous_frame, &I_frame);
+#endif
+ //save the current frame
+ memcpy(s->previous_frame, p->data[0], s->image_height*p->linesize[0]);
+
+ //mark the frame type so the muxer can mux it correctly
+ if (I_frame) {
+ p->pict_type = FF_I_TYPE;
+ p->key_frame = 1;
+ s->last_key_frame = avctx->frame_number;
+ av_log(avctx, AV_LOG_DEBUG, "Inserting key frame at frame %d\n",avctx->frame_number);
+ } else {
+ p->pict_type = FF_P_TYPE;
+ p->key_frame = 0;
+ }
+
+ avctx->coded_frame = p;
+
+ return res;
+}
+
+static int flashsv_encode_end(AVCodecContext *avctx)
+{
+ FlashSVContext *s = (FlashSVContext *)avctx->priv_data;
+
+ deflateEnd(&(s->zstream));
+
+ av_free(s->encbuffer);
+ av_free(s->previous_frame);
+ av_free(s->tmpblock);
+
+ return 0;
+}
+
+AVCodec flashsv_encoder = {
+ "flashsv",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_FLASHSV,
+ sizeof(FlashSVContext),
+ flashsv_encode_init,
+ flashsv_encode_frame,
+ flashsv_encode_end,
+ .pix_fmts = (enum PixelFormat[]){PIX_FMT_BGR24, -1},
+};
+
diff --git a/contrib/ffmpeg/libavcodec/flicvideo.c b/contrib/ffmpeg/libavcodec/flicvideo.c
index 95cb26ce4..b60e0b1c2 100644
--- a/contrib/ffmpeg/libavcodec/flicvideo.c
+++ b/contrib/ffmpeg/libavcodec/flicvideo.c
@@ -87,8 +87,8 @@ static int flic_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
avctx->has_b_frames = 0;
- s->fli_type = LE_16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
- depth = LE_16(&fli_header[12]);
+ s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
+ depth = AV_RL16(&fli_header[12]);
if (depth == 0) {
depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
@@ -115,7 +115,7 @@ static int flic_decode_init(AVCodecContext *avctx)
return -1;
break;
default :
- av_log(avctx, AV_LOG_ERROR, "Unkown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
+ av_log(avctx, AV_LOG_ERROR, "Unknown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
return -1;
}
@@ -172,18 +172,18 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
pixels = s->frame.data[0];
pixel_limit = s->avctx->height * s->frame.linesize[0];
- frame_size = LE_32(&buf[stream_ptr]);
+ frame_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 6; /* skip the magic number */
- num_chunks = LE_16(&buf[stream_ptr]);
+ num_chunks = AV_RL16(&buf[stream_ptr]);
stream_ptr += 10; /* skip padding */
frame_size -= 16;
/* iterate through the chunks */
while ((frame_size > 0) && (num_chunks > 0)) {
- chunk_size = LE_32(&buf[stream_ptr]);
+ chunk_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 4;
- chunk_type = LE_16(&buf[stream_ptr]);
+ chunk_type = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
switch (chunk_type) {
@@ -200,7 +200,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
else
color_shift = 2;
/* set up the palette */
- color_packets = LE_16(&buf[stream_ptr]);
+ color_packets = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
palette_ptr = 0;
for (i = 0; i < color_packets; i++) {
@@ -241,10 +241,10 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
case FLI_DELTA:
y_ptr = 0;
- compressed_lines = LE_16(&buf[stream_ptr]);
+ compressed_lines = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
while (compressed_lines > 0) {
- line_packets = LE_16(&buf[stream_ptr]);
+ line_packets = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
if ((line_packets & 0xC000) == 0xC000) {
// line skip opcode
@@ -290,12 +290,12 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
case FLI_LC:
/* line compressed */
- starting_line = LE_16(&buf[stream_ptr]);
+ starting_line = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
y_ptr = 0;
y_ptr += starting_line * s->frame.linesize[0];
- compressed_lines = LE_16(&buf[stream_ptr]);
+ compressed_lines = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
while (compressed_lines > 0) {
pixel_ptr = y_ptr;
@@ -355,8 +355,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
- av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
- pixel_countdown);
+ av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
+ pixel_countdown, lines);
}
} else { /* copy bytes if byte_run < 0 */
byte_run = -byte_run;
@@ -366,8 +366,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
- av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
- pixel_countdown);
+ av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
+ pixel_countdown, lines);
}
}
}
@@ -466,18 +466,18 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixels = s->frame.data[0];
pixel_limit = s->avctx->height * s->frame.linesize[0];
- frame_size = LE_32(&buf[stream_ptr]);
+ frame_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 6; /* skip the magic number */
- num_chunks = LE_16(&buf[stream_ptr]);
+ num_chunks = AV_RL16(&buf[stream_ptr]);
stream_ptr += 10; /* skip padding */
frame_size -= 16;
/* iterate through the chunks */
while ((frame_size > 0) && (num_chunks > 0)) {
- chunk_size = LE_32(&buf[stream_ptr]);
+ chunk_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 4;
- chunk_type = LE_16(&buf[stream_ptr]);
+ chunk_type = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
switch (chunk_type) {
@@ -492,10 +492,10 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
case FLI_DELTA:
case FLI_DTA_LC:
y_ptr = 0;
- compressed_lines = LE_16(&buf[stream_ptr]);
+ compressed_lines = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
while (compressed_lines > 0) {
- line_packets = LE_16(&buf[stream_ptr]);
+ line_packets = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
if (line_packets < 0) {
line_packets = -line_packets;
@@ -512,7 +512,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
byte_run = (signed char)(buf[stream_ptr++]);
if (byte_run < 0) {
byte_run = -byte_run;
- pixel = LE_16(&buf[stream_ptr]);
+ pixel = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
@@ -522,7 +522,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
} else {
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown--) {
- *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]);
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
pixel_ptr += 2;
}
@@ -563,8 +563,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
- av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
- pixel_countdown);
+ av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) (linea%d)\n",
+ pixel_countdown, lines);
}
} else { /* copy bytes if byte_run < 0 */
byte_run = -byte_run;
@@ -574,8 +574,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixels[pixel_ptr++] = palette_idx1;
pixel_countdown--;
if (pixel_countdown < 0)
- av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
- pixel_countdown);
+ av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n",
+ pixel_countdown, lines);
}
}
}
@@ -586,12 +586,12 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
* a second pass over the line here, swapping the bytes.
*/
pixel = 0xFF00;
- if (0xFF00 != LE_16(&pixel)) /* Check if its not an LE Target */
+ if (0xFF00 != AV_RL16(&pixel)) /* Check if its not an LE Target */
{
pixel_ptr = y_ptr;
pixel_countdown = s->avctx->width;
while (pixel_countdown > 0) {
- *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[pixel_ptr]);
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[pixel_ptr]);
pixel_ptr += 2;
}
}
@@ -611,7 +611,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
while (pixel_countdown > 0) {
byte_run = (signed char)(buf[stream_ptr++]);
if (byte_run > 0) {
- pixel = LE_16(&buf[stream_ptr]);
+ pixel = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
@@ -626,7 +626,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
byte_run = -byte_run;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
- *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]);
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
pixel_ptr += 2;
pixel_countdown--;
@@ -656,7 +656,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixel_countdown = s->avctx->width;
pixel_ptr = 0;
while (pixel_countdown > 0) {
- *((signed short*)(&pixels[y_ptr + pixel_ptr])) = LE_16(&buf[stream_ptr+pixel_ptr]);
+ *((signed short*)(&pixels[y_ptr + pixel_ptr])) = AV_RL16(&buf[stream_ptr+pixel_ptr]);
pixel_ptr += 2;
pixel_countdown--;
}
diff --git a/contrib/ffmpeg/libavcodec/fraps.c b/contrib/ffmpeg/libavcodec/fraps.c
index 18d270049..0a4567d05 100644
--- a/contrib/ffmpeg/libavcodec/fraps.c
+++ b/contrib/ffmpeg/libavcodec/fraps.c
@@ -138,7 +138,7 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
for(i = 0; i < 256; i++){
s->nodes[i].sym = i;
- s->nodes[i].count = LE_32(src);
+ s->nodes[i].count = AV_RL32(src);
s->nodes[i].n0 = -2;
if(s->nodes[i].count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Symbol count < 0\n");
@@ -215,7 +215,7 @@ static int decode_frame(AVCodecContext *avctx,
int i, is_chroma, planes;
- header = LE_32(buf);
+ header = AV_RL32(buf);
version = header & 0xff;
header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
@@ -337,12 +337,12 @@ static int decode_frame(AVCodecContext *avctx,
}
f->pict_type = FF_I_TYPE;
f->key_frame = 1;
- if ((LE_32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) {
+ if ((AV_RL32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) {
av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n");
return -1;
}
for(i = 0; i < planes; i++) {
- offs[i] = LE_32(buf + 4 + i * 4);
+ offs[i] = AV_RL32(buf + 4 + i * 4);
if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
av_log(avctx, AV_LOG_ERROR, "Fraps: plane %i offset is out of bounds\n", i);
return -1;
diff --git a/contrib/ffmpeg/libavcodec/g726.c b/contrib/ffmpeg/libavcodec/g726.c
index c509292b6..07af33122 100644
--- a/contrib/ffmpeg/libavcodec/g726.c
+++ b/contrib/ffmpeg/libavcodec/g726.c
@@ -213,12 +213,12 @@ static inline int16_t g726_iterate(G726Context* c, int16_t I)
c->b[i] = 0;
} else {
/* This is a bit crazy, but it really is +255 not +256 */
- fa1 = clip((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255);
+ fa1 = av_clip((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255);
c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7);
- c->a[1] = clip(c->a[1], -12288, 12288);
+ c->a[1] = av_clip(c->a[1], -12288, 12288);
c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8);
- c->a[0] = clip(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]);
+ c->a[0] = av_clip(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]);
for (i=0; i<6; i++)
c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8);
@@ -248,7 +248,7 @@ static inline int16_t g726_iterate(G726Context* c, int16_t I)
c->ap += (0x200 - c->ap) >> 4;
/* Update Yu and Yl */
- c->yu = clip(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120);
+ c->yu = av_clip(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120);
c->yl += c->yu + ((-c->yl)>>6);
/* Next iteration for Y */
@@ -264,7 +264,7 @@ static inline int16_t g726_iterate(G726Context* c, int16_t I)
c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]);
c->se >>= 1;
- return clip(re_signal << 2, -0xffff, 0xffff);
+ return av_clip(re_signal << 2, -0xffff, 0xffff);
}
static int g726_reset(G726Context* c, int bit_rate)
@@ -341,7 +341,7 @@ static int g726_init(AVCodecContext * avctx)
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
return 0;
diff --git a/contrib/ffmpeg/libavcodec/gifdec.c b/contrib/ffmpeg/libavcodec/gifdec.c
index 5a5712299..3e8a3e6bc 100644
--- a/contrib/ffmpeg/libavcodec/gifdec.c
+++ b/contrib/ffmpeg/libavcodec/gifdec.c
@@ -48,11 +48,14 @@ typedef struct GifState {
/* LZW compatible decoder */
uint8_t *bytestream;
+ uint8_t *bytestream_end;
LZWState *lzw;
/* aux buffers */
uint8_t global_palette[256 * 3];
uint8_t local_palette[256 * 3];
+
+ AVCodecContext* avctx;
} GifState;
static const uint8_t gif87a_sig[6] = "GIF87a";
@@ -73,7 +76,7 @@ static int gif_read_image(GifState *s)
has_local_palette = flags & 0x80;
bits_per_pixel = (flags & 0x07) + 1;
#ifdef DEBUG
- dprintf("gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
+ dprintf(s->avctx, "gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
#endif
if (has_local_palette) {
@@ -87,7 +90,7 @@ static int gif_read_image(GifState *s)
/* verify that all the image is inside the screen dimensions */
if (left + width > s->screen_width ||
top + height > s->screen_height)
- return -EINVAL;
+ return AVERROR(EINVAL);
/* build the palette */
n = (1 << bits_per_pixel);
@@ -105,8 +108,8 @@ static int gif_read_image(GifState *s)
/* now get the image data */
code_size = bytestream_get_byte(&s->bytestream);
- //TODO: add proper data size
- ff_lzw_decode_init(s->lzw, code_size, s->bytestream, 0, FF_LZW_GIF);
+ ff_lzw_decode_init(s->lzw, code_size, s->bytestream,
+ s->bytestream_end - s->bytestream, FF_LZW_GIF);
/* read all the image */
linesize = s->picture.linesize[0];
@@ -164,7 +167,7 @@ static int gif_read_extension(GifState *s)
ext_code = bytestream_get_byte(&s->bytestream);
ext_len = bytestream_get_byte(&s->bytestream);
#ifdef DEBUG
- dprintf("gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
+ dprintf(s->avctx, "gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
#endif
switch(ext_code) {
case 0xf9:
@@ -180,7 +183,7 @@ static int gif_read_extension(GifState *s)
s->transparent_color_index = -1;
s->gce_disposal = (gce_flags >> 2) & 0x7;
#ifdef DEBUG
- dprintf("gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n",
+ dprintf(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
@@ -195,7 +198,7 @@ static int gif_read_extension(GifState *s)
bytestream_get_byte(&s->bytestream);
ext_len = bytestream_get_byte(&s->bytestream);
#ifdef DEBUG
- dprintf("gif: ext_len1=%d\n", ext_len);
+ dprintf(s->avctx, "gif: ext_len1=%d\n", ext_len);
#endif
}
return 0;
@@ -207,6 +210,9 @@ static int gif_read_header1(GifState *s)
int v, n;
int has_global_palette;
+ if (s->bytestream_end < s->bytestream + 13)
+ return -1;
+
/* read gif signature */
bytestream_get_buffer(&s->bytestream, sig, 6);
if (memcmp(sig, gif87a_sig, 6) != 0 &&
@@ -230,12 +236,14 @@ static int gif_read_header1(GifState *s)
s->background_color_index = bytestream_get_byte(&s->bytestream);
bytestream_get_byte(&s->bytestream); /* ignored */
#ifdef DEBUG
- dprintf("gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
+ dprintf(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)
+ return -1;
bytestream_get_buffer(&s->bytestream, s->global_palette, n * 3);
}
return 0;
@@ -243,42 +251,37 @@ static int gif_read_header1(GifState *s)
static int gif_parse_next_image(GifState *s)
{
- int ret, code;
-
- for (;;) {
- code = bytestream_get_byte(&s->bytestream);
+ while (s->bytestream < s->bytestream_end) {
+ int code = bytestream_get_byte(&s->bytestream);
#ifdef DEBUG
- dprintf("gif: code=%02x '%c'\n", code, code);
+ dprintf(s->avctx, "gif: code=%02x '%c'\n", code, code);
#endif
switch (code) {
case ',':
if (gif_read_image(s) < 0)
return -1;
- ret = 0;
- goto the_end;
+ return 0;
case ';':
/* end of image */
- ret = -1;
- goto the_end;
+ return -1;
case '!':
if (gif_read_extension(s) < 0)
return -1;
break;
- case EOF:
default:
/* error or errneous EOF */
- ret = -1;
- goto the_end;
+ return -1;
}
}
- the_end:
- return ret;
+ return -1;
}
static int gif_decode_init(AVCodecContext *avctx)
{
GifState *s = avctx->priv_data;
+ s->avctx = avctx;
+
avcodec_get_frame_defaults(&s->picture);
avctx->coded_frame= &s->picture;
s->picture.data[0] = NULL;
@@ -293,6 +296,7 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, u
int ret;
s->bytestream = buf;
+ s->bytestream_end = buf + buf_size;
if (gif_read_header1(s) < 0)
return -1;
@@ -314,7 +318,7 @@ static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, u
*picture = s->picture;
*data_size = sizeof(AVPicture);
- return 0;
+ return s->bytestream - buf;
}
static int gif_decode_close(AVCodecContext *avctx)
diff --git a/contrib/ffmpeg/libavcodec/h261.c b/contrib/ffmpeg/libavcodec/h261.c
index 8d4ca08cd..83f3136e3 100644
--- a/contrib/ffmpeg/libavcodec/h261.c
+++ b/contrib/ffmpeg/libavcodec/h261.c
@@ -58,6 +58,8 @@ typedef struct H261Context{
int gob_start_code_skipped; // 1 if gob start code is already read before gob header is read
}H261Context;
+static uint8_t static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
+
void ff_h261_loop_filter(MpegEncContext *s){
H261Context * h= (H261Context*)s;
const int linesize = s->linesize;
@@ -285,7 +287,7 @@ void ff_h261_encode_init(MpegEncContext *s){
if (!done) {
done = 1;
- init_rl(&h261_rl_tcoeff, 1);
+ init_rl(&h261_rl_tcoeff, static_rl_table_store);
}
s->min_qcoeff= -127;
@@ -392,7 +394,7 @@ static void h261_decode_init_vlc(H261Context *h){
init_vlc(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
&h261_cbp_tab[0][1], 2, 1,
&h261_cbp_tab[0][0], 2, 1, 1);
- init_rl(&h261_rl_tcoeff, 1);
+ init_rl(&h261_rl_tcoeff, static_rl_table_store);
init_vlc_rl(&h261_rl_tcoeff, 1);
}
}
diff --git a/contrib/ffmpeg/libavcodec/h263.c b/contrib/ffmpeg/libavcodec/h263.c
index ba51c245a..4db89e970 100644
--- a/contrib/ffmpeg/libavcodec/h263.c
+++ b/contrib/ffmpeg/libavcodec/h263.c
@@ -87,7 +87,7 @@ static uint8_t uni_DCtab_chrom_len[512];
static uint16_t uni_DCtab_lum_bits[512];
static uint16_t uni_DCtab_chrom_bits[512];
-static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
+static uint8_t mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
static uint8_t fcode_tab[MAX_MV*2+1];
static uint8_t umv_fcode_tab[MAX_MV*2+1];
@@ -112,6 +112,8 @@ max run: 29/41
*/
#endif
+static uint8_t static_rl_table_store[5][2][2*MAX_RUN + MAX_LEVEL + 3];
+
#if 0 //3IV1 is quite rare and it slows things down a tiny bit
#define IS_3IV1 s->codec_tag == ff_get_fourcc("3IV1")
#else
@@ -211,7 +213,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
for(i=0; i<2; i++){
int div, error;
div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den);
- div= clip(1, div, 127);
+ div= av_clip(1, div, 127);
error= FFABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div);
if(error < best_error){
best_error= error;
@@ -487,12 +489,28 @@ static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], i
}
/**
+ * init s->current_picture.qscale_table from s->lambda_table
+ */
+static void ff_init_qscale_tab(MpegEncContext *s){
+ int8_t * const qscale_table= s->current_picture.qscale_table;
+ int i;
+
+ for(i=0; i<s->mb_num; i++){
+ unsigned int lam= s->lambda_table[ s->mb_index2xy[i] ];
+ int qp= (lam*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
+ qscale_table[ s->mb_index2xy[i] ]= av_clip(qp, s->avctx->qmin, s->avctx->qmax);
+ }
+}
+
+/**
* modify qscale so that encoding is acually possible in h263 (limit difference to -2..2)
*/
void ff_clean_h263_qscales(MpegEncContext *s){
int i;
int8_t * const qscale_table= s->current_picture.qscale_table;
+ ff_init_qscale_tab(s);
+
for(i=1; i<s->mb_num; i++){
if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2)
qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2;
@@ -507,7 +525,6 @@ void ff_clean_h263_qscales(MpegEncContext *s){
int mb_xy= s->mb_index2xy[i];
if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){
- s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_INTER4V;
s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER;
}
}
@@ -546,7 +563,6 @@ void ff_clean_mpeg4_qscales(MpegEncContext *s){
for(i=1; i<s->mb_num; i++){
int mb_xy= s->mb_index2xy[i];
if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_DIRECT)){
- s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_DIRECT;
s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_BIDIR;
}
}
@@ -1783,9 +1799,6 @@ static void init_mv_penalty_and_fcode(MpegEncContext *s)
int f_code;
int mv;
- if(mv_penalty==NULL)
- mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
-
for(f_code=1; f_code<=MAX_FCODE; f_code++){
for(mv=-MAX_MV; mv<=MAX_MV; mv++){
int len;
@@ -2019,9 +2032,9 @@ void h263_encode_init(MpegEncContext *s)
init_uni_dc_tab();
- init_rl(&rl_inter, 1);
- init_rl(&rl_intra, 1);
- init_rl(&rl_intra_aic, 1);
+ init_rl(&rl_inter, static_rl_table_store[0]);
+ init_rl(&rl_intra, static_rl_table_store[1]);
+ init_rl(&rl_intra_aic, static_rl_table_store[2]);
init_uni_mpeg4_rl_tab(&rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len);
init_uni_mpeg4_rl_tab(&rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len);
@@ -2505,7 +2518,7 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
#endif //CONFIG_ENCODERS
/**
- * set qscale and update qscale dependant variables.
+ * set qscale and update qscale dependent variables.
*/
void ff_set_qscale(MpegEncContext * s, int qscale)
{
@@ -2980,11 +2993,11 @@ void h263_decode_init_vlc(MpegEncContext *s)
init_vlc(&mv_vlc, MV_VLC_BITS, 33,
&mvtab[0][1], 2, 1,
&mvtab[0][0], 2, 1, 1);
- init_rl(&rl_inter, 1);
- init_rl(&rl_intra, 1);
- init_rl(&rvlc_rl_inter, 1);
- init_rl(&rvlc_rl_intra, 1);
- init_rl(&rl_intra_aic, 1);
+ init_rl(&rl_inter, static_rl_table_store[0]);
+ init_rl(&rl_intra, static_rl_table_store[1]);
+ init_rl(&rvlc_rl_inter, static_rl_table_store[3]);
+ init_rl(&rvlc_rl_intra, static_rl_table_store[4]);
+ init_rl(&rl_intra_aic, static_rl_table_store[2]);
init_vlc_rl(&rl_inter, 1);
init_vlc_rl(&rl_intra, 1);
init_vlc_rl(&rvlc_rl_inter, 1);
@@ -5127,7 +5140,7 @@ int h263_decode_picture_header(MpegEncContext *s)
if (ufep == 1) {
/* OPPTYPE */
format = get_bits(&s->gb, 3);
- dprintf("ufep=1, format: %d\n", format);
+ dprintf(s->avctx, "ufep=1, format: %d\n", format);
s->custom_pcf= get_bits1(&s->gb);
s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
if (get_bits1(&s->gb) != 0) {
@@ -5177,7 +5190,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("aspect: %d\n", s->aspect_ratio_info);
+ dprintf(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
/* aspect ratios:
0 - forbidden
1 - 1:1
@@ -5190,7 +5203,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("\nH.263+ Custom picture: %dx%d\n",width,height);
+ dprintf(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);
@@ -5914,6 +5927,10 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
- ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
s->pb_field_time= ( ROUNDED_DIV(s->time, s->t_frame)
- ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
+ if(!s->progressive_sequence){
+ if(s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1)
+ return FRAME_SKIPPED;
+ }
}
//av_log(s->avctx, AV_LOG_DEBUG, "last nonb %"PRId64" last_base %d time %"PRId64" pp %d pb %d t %d ppf %d pbf %d\n", s->last_non_b_time, s->last_time_base, s->time, s->pp_time, s->pb_time, s->t_frame, s->pp_field_time, s->pb_field_time);
diff --git a/contrib/ffmpeg/libavcodec/h263dec.c b/contrib/ffmpeg/libavcodec/h263dec.c
index 66370c179..b385f84cd 100644
--- a/contrib/ffmpeg/libavcodec/h263dec.c
+++ b/contrib/ffmpeg/libavcodec/h263dec.c
@@ -429,7 +429,8 @@ uint64_t time= rdtsc();
#endif
#ifdef DEBUG
av_log(avctx, AV_LOG_DEBUG, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
- av_log(avctx, AV_LOG_DEBUG, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
+ if(buf_size>0)
+ av_log(avctx, AV_LOG_DEBUG, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
#endif
s->flags= avctx->flags;
s->flags2= avctx->flags2;
@@ -729,7 +730,7 @@ retry:
decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
- if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
+ if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
break;
}else{
if(ff_h263_resync(s)<0)
diff --git a/contrib/ffmpeg/libavcodec/h264.c b/contrib/ffmpeg/libavcodec/h264.c
index ad23ae120..2750173b1 100644
--- a/contrib/ffmpeg/libavcodec/h264.c
+++ b/contrib/ffmpeg/libavcodec/h264.c
@@ -117,12 +117,12 @@ typedef struct SPS{
* Picture parameter set
*/
typedef struct PPS{
- int sps_id;
+ unsigned int sps_id;
int cabac; ///< entropy_coding_mode_flag
int pic_order_present; ///< pic_order_present_flag
int slice_group_count; ///< num_slice_groups_minus1 + 1
int mb_slice_group_map_type;
- int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
+ unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
int weighted_pred; ///< weighted_pred_flag
int weighted_bipred_idc;
int init_qp; ///< pic_init_qp_minus26 + 26
@@ -165,20 +165,6 @@ typedef struct H264Context{
MpegEncContext s;
int nal_ref_idc;
int nal_unit_type;
-#define NAL_SLICE 1
-#define NAL_DPA 2
-#define NAL_DPB 3
-#define NAL_DPC 4
-#define NAL_IDR_SLICE 5
-#define NAL_SEI 6
-#define NAL_SPS 7
-#define NAL_PPS 8
-#define NAL_AUD 9
-#define NAL_END_SEQUENCE 10
-#define NAL_END_STREAM 11
-#define NAL_FILLER_DATA 12
-#define NAL_SPS_EXT 13
-#define NAL_AUXILIARY_SLICE 19
uint8_t *rbsp_buffer;
unsigned int rbsp_buffer_size;
@@ -288,7 +274,7 @@ typedef struct H264Context{
int mb_field_decoding_flag;
int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag
- int sub_mb_type[4];
+ unsigned int sub_mb_type[4];
//POC stuff
int poc_lsb;
@@ -339,12 +325,13 @@ typedef struct H264Context{
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
- int ref_count[2]; ///< counts frames or fields, depending on current mb mode
+ unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
+ unsigned int list_count;
Picture *short_ref[32];
Picture *long_ref[32];
Picture default_ref_list[2][32];
Picture ref_list[2][48]; ///< 0..15: frame refs, 16..47: mbaff field refs
- Picture *delayed_pic[16]; //FIXME size?
+ Picture *delayed_pic[18]; //FIXME size?
Picture *delayed_output_pic;
/**
@@ -363,6 +350,7 @@ typedef struct H264Context{
GetBitContext *inter_gb_ptr;
DECLARE_ALIGNED_8(DCTELEM, mb[16*24]);
+ DCTELEM mb_padding[256]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not to large or ensure that there is some unused stuff after mb
/**
* Cabac
@@ -414,7 +402,7 @@ static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, in
static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize);
-static always_inline uint32_t pack16to32(int a, int b){
+static av_always_inline uint32_t pack16to32(int a, int b){
#ifdef WORDS_BIGENDIAN
return (b&0xFFFF) + (a<<16);
#else
@@ -422,13 +410,22 @@ static always_inline uint32_t pack16to32(int a, int b){
#endif
}
+const uint8_t ff_rem6[52]={
+0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
+};
+
+const uint8_t ff_div6[52]={
+0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
+};
+
+
/**
* fill a rectangle.
* @param h height of the rectangle, should be a constant
* @param w width of the rectangle, should be a constant
* @param size the size of val (1 or 4), should be a constant
*/
-static always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){
+static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){
uint8_t *p= (uint8_t*)vp;
assert(size==1 || size==4);
assert(w<=4);
@@ -547,7 +544,7 @@ static void fill_caches(H264Context *h, int mb_type, int for_deblock){
const int left_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[pair_xy-1]);
const int curr_mb_frame_flag = !IS_INTERLACED(mb_type);
const int bottom = (s->mb_y & 1);
- tprintf("fill_caches: curr_mb_frame_flag:%d, left_mb_frame_flag:%d, topleft_mb_frame_flag:%d, top_mb_frame_flag:%d, topright_mb_frame_flag:%d\n", curr_mb_frame_flag, left_mb_frame_flag, topleft_mb_frame_flag, top_mb_frame_flag, topright_mb_frame_flag);
+ tprintf(s->avctx, "fill_caches: curr_mb_frame_flag:%d, left_mb_frame_flag:%d, topleft_mb_frame_flag:%d, top_mb_frame_flag:%d, topright_mb_frame_flag:%d\n", curr_mb_frame_flag, left_mb_frame_flag, topleft_mb_frame_flag, top_mb_frame_flag, topright_mb_frame_flag);
if (bottom
? !curr_mb_frame_flag // bottom macroblock
: (!curr_mb_frame_flag && !top_mb_frame_flag) // top macroblock
@@ -617,7 +614,7 @@ static void fill_caches(H264Context *h, int mb_type, int for_deblock){
int v = *(uint16_t*)&h->non_zero_count[mb_xy][14];
for(i=0; i<16; i++)
h->non_zero_count_cache[scan8[i]] = (v>>i)&1;
- for(list=0; list<1+(h->slice_type==B_TYPE); list++){
+ for(list=0; list<h->list_count; list++){
if(USES_LIST(mb_type,list)){
uint32_t *src = (uint32_t*)s->current_picture.motion_val[list][h->mb2b_xy[mb_xy]];
uint32_t *dst = (uint32_t*)h->mv_cache[list][scan8[0]];
@@ -785,7 +782,7 @@ static void fill_caches(H264Context *h, int mb_type, int for_deblock){
#if 1
if(IS_INTER(mb_type) || IS_DIRECT(mb_type)){
int list;
- for(list=0; list<1+(h->slice_type==B_TYPE); list++){
+ for(list=0; list<h->list_count; list++){
if(!USES_LIST(mb_type, list) && !IS_DIRECT(mb_type) && !h->deblocking_filter){
/*if(!h->mv_cache_clean[list]){
memset(h->mv_cache [list], 0, 8*5*2*sizeof(int16_t)); //FIXME clean only input? clean at all?
@@ -815,34 +812,21 @@ static void fill_caches(H264Context *h, int mb_type, int for_deblock){
*(uint32_t*)&h->ref_cache[list][scan8[0] + 0 - 1*8]= ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101;
}
- //FIXME unify cleanup or sth
- if(USES_LIST(left_type[0], list)){
- const int b_xy= h->mb2b_xy[left_xy[0]] + 3;
- const int b8_xy= h->mb2b8_xy[left_xy[0]] + 1;
- *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 0*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0]];
- *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1]];
- h->ref_cache[list][scan8[0] - 1 + 0*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0]>>1)];
- h->ref_cache[list][scan8[0] - 1 + 1*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1]>>1)];
- }else{
- *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 0*8]=
- *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 1*8]= 0;
- h->ref_cache[list][scan8[0] - 1 + 0*8]=
- h->ref_cache[list][scan8[0] - 1 + 1*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
- }
-
- if(USES_LIST(left_type[1], list)){
- const int b_xy= h->mb2b_xy[left_xy[1]] + 3;
- const int b8_xy= h->mb2b8_xy[left_xy[1]] + 1;
- *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 2*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[2]];
- *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 3*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[3]];
- h->ref_cache[list][scan8[0] - 1 + 2*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[2]>>1)];
- h->ref_cache[list][scan8[0] - 1 + 3*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[3]>>1)];
- }else{
- *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 2*8]=
- *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 3*8]= 0;
- h->ref_cache[list][scan8[0] - 1 + 2*8]=
- h->ref_cache[list][scan8[0] - 1 + 3*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
- assert((!left_type[0]) == (!left_type[1]));
+ for(i=0; i<2; i++){
+ int cache_idx = scan8[0] - 1 + i*2*8;
+ if(USES_LIST(left_type[i], list)){
+ const int b_xy= h->mb2b_xy[left_xy[i]] + 3;
+ const int b8_xy= h->mb2b8_xy[left_xy[i]] + 1;
+ *(uint32_t*)h->mv_cache[list][cache_idx ]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0+i*2]];
+ *(uint32_t*)h->mv_cache[list][cache_idx+8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1+i*2]];
+ h->ref_cache[list][cache_idx ]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)];
+ h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)];
+ }else{
+ *(uint32_t*)h->mv_cache [list][cache_idx ]=
+ *(uint32_t*)h->mv_cache [list][cache_idx+8]= 0;
+ h->ref_cache[list][cache_idx ]=
+ h->ref_cache[list][cache_idx+8]= left_type[i] ? LIST_NOT_USED : PART_NOT_AVAILABLE;
+ }
}
if((for_deblock || (IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)) && !FRAME_MBAFF)
@@ -1043,7 +1027,7 @@ static inline int check_intra_pred_mode(H264Context *h, int mode){
static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1};
static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8};
- if(mode < 0 || mode > 6) {
+ if(mode > 6U) {
av_log(h->s.avctx, AV_LOG_ERROR, "out of range intra chroma pred mode at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
@@ -1076,7 +1060,7 @@ static inline int pred_intra_mode(H264Context *h, int n){
const int top = h->intra4x4_pred_mode_cache[index8 - 8];
const int min= FFMIN(left, top);
- tprintf("mode:%d %d min:%d\n", left ,top, min);
+ tprintf(h->s.avctx, "mode:%d %d min:%d\n", left ,top, min);
if(min<0) return DC_PRED;
else return min;
@@ -1123,18 +1107,18 @@ static inline int pred_non_zero_count(H264Context *h, int n){
if(i<64) i= (i+1)>>1;
- tprintf("pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31);
+ tprintf(h->s.avctx, "pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31);
return i&31;
}
static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){
const int topright_ref= h->ref_cache[list][ i - 8 + part_width ];
+ MpegEncContext *s = &h->s;
/* there is no consistent mapping of mvs to neighboring locations that will
* make mbaff happy, so we can't move all this logic to fill_caches */
if(FRAME_MBAFF){
- MpegEncContext *s = &h->s;
const uint32_t *mb_types = s->current_picture_ptr->mb_type;
const int16_t *mv;
*(uint32_t*)h->mv_cache[list][scan8[0]-2] = 0;
@@ -1178,7 +1162,7 @@ static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, in
*C= h->mv_cache[list][ i - 8 + part_width ];
return topright_ref;
}else{
- tprintf("topright MV not available\n");
+ tprintf(s->avctx, "topright MV not available\n");
*C= h->mv_cache[list][ i - 8 - 1 ];
return h->ref_cache[list][ i - 8 - 1 ];
@@ -1213,7 +1197,7 @@ static inline void pred_motion(H264Context * const h, int n, int part_width, int
diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width);
match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref);
- tprintf("pred_motion match_count=%d\n", match_count);
+ tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count);
if(match_count > 1){ //most common
*mx= mid_pred(A[0], B[0], C[0]);
*my= mid_pred(A[1], B[1], C[1]);
@@ -1238,7 +1222,7 @@ static inline void pred_motion(H264Context * const h, int n, int part_width, int
}
}
- tprintf("pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list);
+ tprintf(h->s.avctx, "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list);
}
/**
@@ -1252,7 +1236,7 @@ static inline void pred_16x8_motion(H264Context * const h, int n, int list, int
const int top_ref= h->ref_cache[list][ scan8[0] - 8 ];
const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];
- tprintf("pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list);
+ tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list);
if(top_ref == ref){
*mx= B[0];
@@ -1263,7 +1247,7 @@ static inline void pred_16x8_motion(H264Context * const h, int n, int list, int
const int left_ref= h->ref_cache[list][ scan8[8] - 1 ];
const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ];
- tprintf("pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
+ tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
if(left_ref == ref){
*mx= A[0];
@@ -1287,7 +1271,7 @@ static inline void pred_8x16_motion(H264Context * const h, int n, int list, int
const int left_ref= h->ref_cache[list][ scan8[0] - 1 ];
const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ];
- tprintf("pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
+ tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
if(left_ref == ref){
*mx= A[0];
@@ -1300,7 +1284,7 @@ static inline void pred_8x16_motion(H264Context * const h, int n, int list, int
diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2);
- tprintf("pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list);
+ tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list);
if(diagonal_ref == ref){
*mx= C[0];
@@ -1317,7 +1301,7 @@ static inline void pred_pskip_motion(H264Context * const h, int * const mx, int
const int top_ref = h->ref_cache[0][ scan8[0] - 8 ];
const int left_ref= h->ref_cache[0][ scan8[0] - 1 ];
- tprintf("pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);
+ tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", top_ref, left_ref, h->s.mb_x, h->s.mb_y);
if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE
|| (top_ref == 0 && *(uint32_t*)h->mv_cache[0][ scan8[0] - 8 ] == 0)
@@ -1338,13 +1322,13 @@ static inline void direct_dist_scale_factor(H264Context * const h){
int i;
for(i=0; i<h->ref_count[0]; i++){
int poc0 = h->ref_list[0][i].poc;
- int td = clip(poc1 - poc0, -128, 127);
+ int td = av_clip(poc1 - poc0, -128, 127);
if(td == 0 /* FIXME || pic0 is a long-term ref */){
h->dist_scale_factor[i] = 256;
}else{
- int tb = clip(poc - poc0, -128, 127);
+ int tb = av_clip(poc - poc0, -128, 127);
int tx = (16384 + (FFABS(td) >> 1)) / td;
- h->dist_scale_factor[i] = clip((tb*tx + 32) >> 6, -1024, 1023);
+ h->dist_scale_factor[i] = av_clip((tb*tx + 32) >> 6, -1024, 1023);
}
}
if(FRAME_MBAFF){
@@ -1403,7 +1387,7 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
const int8_t *l1ref0 = &h->ref_list[1][0].ref_index[0][b8_xy];
const int8_t *l1ref1 = &h->ref_list[1][0].ref_index[1][b8_xy];
const int is_b8x8 = IS_8X8(*mb_type);
- int sub_mb_type;
+ unsigned int sub_mb_type;
int i8, i4;
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
@@ -1424,7 +1408,7 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
if(MB_FIELD)
*mb_type |= MB_TYPE_INTERLACED;
- tprintf("mb_type = %08x, sub_mb_type = %08x, is_b8x8 = %d, mb_type_col = %08x\n", *mb_type, sub_mb_type, is_b8x8, mb_type_col);
+ tprintf(s->avctx, "mb_type = %08x, sub_mb_type = %08x, is_b8x8 = %d, mb_type_col = %08x\n", *mb_type, sub_mb_type, is_b8x8, mb_type_col);
if(h->direct_spatial_mv_pred){
int ref[2];
@@ -1471,6 +1455,8 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
}
if(IS_16X16(*mb_type)){
+ int a=0, b=0;
+
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
if(!IS_INTRA(mb_type_col)
@@ -1478,17 +1464,15 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
|| (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1
&& (h->x264_build>33 || !h->x264_build)))){
if(ref[0] > 0)
- fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv[0][0],mv[0][1]), 4);
- else
- fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
+ a= pack16to32(mv[0][0],mv[0][1]);
if(ref[1] > 0)
- fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, pack16to32(mv[1][0],mv[1][1]), 4);
- else
- fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
+ b= pack16to32(mv[1][0],mv[1][1]);
}else{
- fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv[0][0],mv[0][1]), 4);
- fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, pack16to32(mv[1][0],mv[1][1]), 4);
+ a= pack16to32(mv[0][0],mv[0][1]);
+ b= pack16to32(mv[1][0],mv[1][1]);
}
+ fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, a, 4);
+ fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, b, 4);
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
@@ -1632,11 +1616,11 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
/* one-to-one mv scaling */
if(IS_16X16(*mb_type)){
+ int ref, mv0, mv1;
+
fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
if(IS_INTRA(mb_type_col)){
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
- fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
- fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
+ ref=mv0=mv1=0;
}else{
const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0]]
: map_col_to_list0[1][l1ref1[0]];
@@ -1645,10 +1629,13 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
int mv_l0[2];
mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref0, 1);
- fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mv_l0[0],mv_l0[1]), 4);
- fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]), 4);
+ ref= ref0;
+ mv0= pack16to32(mv_l0[0],mv_l0[1]);
+ mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
}
+ fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
+ fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
+ fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
}else{
for(i8=0; i8<4; i8++){
const int x8 = i8&1;
@@ -1706,7 +1693,7 @@ static inline void write_back_motion(H264Context *h, int mb_type){
if(!USES_LIST(mb_type, 0))
fill_rectangle(&s->current_picture.ref_index[0][b8_xy], 2, 2, h->b8_stride, (uint8_t)LIST_NOT_USED, 1);
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
int y;
if(!USES_LIST(mb_type, list))
continue;
@@ -1785,6 +1772,10 @@ static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *c
h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length);
dst= h->rbsp_buffer;
+ if (dst == NULL){
+ return NULL;
+ }
+
//printf("decoding esc\n");
si=di=0;
while(si<length){
@@ -1808,90 +1799,15 @@ static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *c
return dst;
}
-#if 0
-/**
- * @param src the data which should be escaped
- * @param dst the target buffer, dst+1 == src is allowed as a special case
- * @param length the length of the src data
- * @param dst_length the length of the dst array
- * @returns length of escaped data in bytes or -1 if an error occured
- */
-static int encode_nal(H264Context *h, uint8_t *dst, uint8_t *src, int length, int dst_length){
- int i, escape_count, si, di;
- uint8_t *temp;
-
- assert(length>=0);
- assert(dst_length>0);
-
- dst[0]= (h->nal_ref_idc<<5) + h->nal_unit_type;
-
- if(length==0) return 1;
-
- escape_count= 0;
- for(i=0; i<length; i+=2){
- if(src[i]) continue;
- if(i>0 && src[i-1]==0)
- i--;
- if(i+2<length && src[i+1]==0 && src[i+2]<=3){
- escape_count++;
- i+=2;
- }
- }
-
- if(escape_count==0){
- if(dst+1 != src)
- memcpy(dst+1, src, length);
- return length + 1;
- }
-
- if(length + escape_count + 1> dst_length)
- return -1;
-
- //this should be damn rare (hopefully)
-
- h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length + escape_count);
- temp= h->rbsp_buffer;
-//printf("encoding esc\n");
-
- si= 0;
- di= 0;
- while(si < length){
- if(si+2<length && src[si]==0 && src[si+1]==0 && src[si+2]<=3){
- temp[di++]= 0; si++;
- temp[di++]= 0; si++;
- temp[di++]= 3;
- temp[di++]= src[si++];
- }
- else
- temp[di++]= src[si++];
- }
- memcpy(dst+1, temp, length+escape_count);
-
- assert(di == length+escape_count);
-
- return di + 1;
-}
-
-/**
- * write 1,10,100,1000,... for alignment, yes its exactly inverse to mpeg4
- */
-static void encode_rbsp_trailing(PutBitContext *pb){
- int length;
- put_bits(pb, 1, 1);
- length= (-put_bits_count(pb))&7;
- if(length) put_bits(pb, length, 0);
-}
-#endif
-
/**
* identifies the exact end of the bitstream
* @return the length of the trailing, or 0 if damaged
*/
-static int decode_rbsp_trailing(uint8_t *src){
+static int decode_rbsp_trailing(H264Context *h, uint8_t *src){
int v= *src;
int r;
- tprintf("rbsp trailing %X\n", v);
+ tprintf(h->s.avctx, "rbsp trailing %X\n", v);
for(r=1; r<9; r++){
if(v&1) return r;
@@ -2032,48 +1948,12 @@ static void chroma_dc_dct_c(DCTELEM *block){
*/
static inline int get_chroma_qp(int chroma_qp_index_offset, int qscale){
- return chroma_qp[clip(qscale + chroma_qp_index_offset, 0, 51)];
+ return chroma_qp[av_clip(qscale + chroma_qp_index_offset, 0, 51)];
}
-
-#if 0
-static void h264_diff_dct_c(DCTELEM *block, uint8_t *src1, uint8_t *src2, int stride){
- int i;
- //FIXME try int temp instead of block
-
- for(i=0; i<4; i++){
- const int d0= src1[0 + i*stride] - src2[0 + i*stride];
- const int d1= src1[1 + i*stride] - src2[1 + i*stride];
- const int d2= src1[2 + i*stride] - src2[2 + i*stride];
- const int d3= src1[3 + i*stride] - src2[3 + i*stride];
- const int z0= d0 + d3;
- const int z3= d0 - d3;
- const int z1= d1 + d2;
- const int z2= d1 - d2;
-
- block[0 + 4*i]= z0 + z1;
- block[1 + 4*i]= 2*z3 + z2;
- block[2 + 4*i]= z0 - z1;
- block[3 + 4*i]= z3 - 2*z2;
- }
-
- for(i=0; i<4; i++){
- const int z0= block[0*4 + i] + block[3*4 + i];
- const int z3= block[0*4 + i] - block[3*4 + i];
- const int z1= block[1*4 + i] + block[2*4 + i];
- const int z2= block[1*4 + i] - block[2*4 + i];
-
- block[0*4 + i]= z0 + z1;
- block[1*4 + i]= 2*z3 + z2;
- block[2*4 + i]= z0 - z1;
- block[3*4 + i]= z3 - 2*z2;
- }
-}
-#endif
-
//FIXME need to check that this doesnt overflow signed 32 bit for low qp, i am not sure, it's very close
-//FIXME check that gcc inlines this (and optimizes intra & seperate_dc stuff away)
-static inline int quantize_c(DCTELEM *block, uint8_t *scantable, int qscale, int intra, int seperate_dc){
+//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;
@@ -2081,7 +1961,7 @@ static inline int quantize_c(DCTELEM *block, uint8_t *scantable, int qscale, int
const unsigned int threshold2= (threshold1<<1);
int last_non_zero;
- if(seperate_dc){
+ if(separate_dc){
if(qscale<=18){
//avoid overflows
const int dc_bias= intra ? (1<<(QUANT_SHIFT-2))/3 : (1<<(QUANT_SHIFT-2))/6;
@@ -2357,7 +2237,7 @@ static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int strid
src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
}
-static void pred16x16_vertical_c(uint8_t *src, int stride){
+void ff_pred16x16_vertical_c(uint8_t *src, int stride){
int i;
const uint32_t a= ((uint32_t*)(src-stride))[0];
const uint32_t b= ((uint32_t*)(src-stride))[1];
@@ -2372,7 +2252,7 @@ static void pred16x16_vertical_c(uint8_t *src, int stride){
}
}
-static void pred16x16_horizontal_c(uint8_t *src, int stride){
+void ff_pred16x16_horizontal_c(uint8_t *src, int stride){
int i;
for(i=0; i<16; i++){
@@ -2383,7 +2263,7 @@ static void pred16x16_horizontal_c(uint8_t *src, int stride){
}
}
-static void pred16x16_dc_c(uint8_t *src, int stride){
+void ff_pred16x16_dc_c(uint8_t *src, int stride){
int i, dc=0;
for(i=0;i<16; i++){
@@ -2437,7 +2317,7 @@ static void pred16x16_top_dc_c(uint8_t *src, int stride){
}
}
-static void pred16x16_128_dc_c(uint8_t *src, int stride){
+void ff_pred16x16_128_dc_c(uint8_t *src, int stride){
int i;
for(i=0; i<16; i++){
@@ -2488,11 +2368,11 @@ static inline void pred16x16_plane_compat_c(uint8_t *src, int stride, const int
}
}
-static void pred16x16_plane_c(uint8_t *src, int stride){
+void ff_pred16x16_plane_c(uint8_t *src, int stride){
pred16x16_plane_compat_c(src, stride, 0);
}
-static void pred8x8_vertical_c(uint8_t *src, int stride){
+void ff_pred8x8_vertical_c(uint8_t *src, int stride){
int i;
const uint32_t a= ((uint32_t*)(src-stride))[0];
const uint32_t b= ((uint32_t*)(src-stride))[1];
@@ -2503,7 +2383,7 @@ static void pred8x8_vertical_c(uint8_t *src, int stride){
}
}
-static void pred8x8_horizontal_c(uint8_t *src, int stride){
+void ff_pred8x8_horizontal_c(uint8_t *src, int stride){
int i;
for(i=0; i<8; i++){
@@ -2512,7 +2392,7 @@ static void pred8x8_horizontal_c(uint8_t *src, int stride){
}
}
-static void pred8x8_128_dc_c(uint8_t *src, int stride){
+void ff_pred8x8_128_dc_c(uint8_t *src, int stride){
int i;
for(i=0; i<8; i++){
@@ -2566,7 +2446,7 @@ static void pred8x8_top_dc_c(uint8_t *src, int stride){
}
-static void pred8x8_dc_c(uint8_t *src, int stride){
+void ff_pred8x8_dc_c(uint8_t *src, int stride){
int i;
int dc0, dc1, dc2, dc3;
@@ -2591,7 +2471,7 @@ static void pred8x8_dc_c(uint8_t *src, int stride){
}
}
-static void pred8x8_plane_c(uint8_t *src, int stride){
+void ff_pred8x8_plane_c(uint8_t *src, int stride){
int j, k;
int a;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
@@ -2884,7 +2764,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
const int pic_width = 16*s->mb_width;
const int pic_height = 16*s->mb_height >> MB_MBAFF;
- if(!pic->data[0])
+ if(!pic->data[0]) //FIXME this is unacceptable, some senseable error concealment must be done for missing reference frames
return;
if(mx&7) extra_width -= 3;
@@ -3220,21 +3100,21 @@ static void init_pred_ptrs(H264Context *h){
h->pred8x8l[TOP_DC_PRED ]= pred8x8l_top_dc_c;
h->pred8x8l[DC_128_PRED ]= pred8x8l_128_dc_c;
- h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_c;
- h->pred8x8[VERT_PRED8x8 ]= pred8x8_vertical_c;
- h->pred8x8[HOR_PRED8x8 ]= pred8x8_horizontal_c;
- h->pred8x8[PLANE_PRED8x8 ]= pred8x8_plane_c;
+ h->pred8x8[DC_PRED8x8 ]= ff_pred8x8_dc_c;
+ h->pred8x8[VERT_PRED8x8 ]= ff_pred8x8_vertical_c;
+ h->pred8x8[HOR_PRED8x8 ]= ff_pred8x8_horizontal_c;
+ h->pred8x8[PLANE_PRED8x8 ]= ff_pred8x8_plane_c;
h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_c;
h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_c;
- h->pred8x8[DC_128_PRED8x8 ]= pred8x8_128_dc_c;
+ h->pred8x8[DC_128_PRED8x8 ]= ff_pred8x8_128_dc_c;
- h->pred16x16[DC_PRED8x8 ]= pred16x16_dc_c;
- h->pred16x16[VERT_PRED8x8 ]= pred16x16_vertical_c;
- h->pred16x16[HOR_PRED8x8 ]= pred16x16_horizontal_c;
- h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c;
+ h->pred16x16[DC_PRED8x8 ]= ff_pred16x16_dc_c;
+ h->pred16x16[VERT_PRED8x8 ]= ff_pred16x16_vertical_c;
+ h->pred16x16[HOR_PRED8x8 ]= ff_pred16x16_horizontal_c;
+ h->pred16x16[PLANE_PRED8x8 ]= ff_pred16x16_plane_c;
h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c;
h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c;
- h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c;
+ h->pred16x16[DC_128_PRED8x8 ]= ff_pred16x16_128_dc_c;
}
static void free_tables(H264Context *h){
@@ -3269,8 +3149,8 @@ static void init_dequant8_coeff_table(H264Context *h){
}
for(q=0; q<52; q++){
- int shift = div6[q];
- int idx = rem6[q];
+ int shift = ff_div6[q];
+ int idx = ff_rem6[q];
for(x=0; x<64; x++)
h->dequant8_coeff[i][q][transpose ? (x>>3)|((x&7)<<3) : x] =
((uint32_t)dequant8_coeff_init[idx][ dequant8_coeff_init_scan[((x>>1)&12) | (x&3)] ] *
@@ -3294,8 +3174,8 @@ static void init_dequant4_coeff_table(H264Context *h){
continue;
for(q=0; q<52; q++){
- int shift = div6[q] + 2;
- int idx = rem6[q];
+ int shift = ff_div6[q] + 2;
+ int idx = ff_rem6[q];
for(x=0; x<16; x++)
h->dequant4_coeff[i][q][transpose ? (x>>2)|((x<<2)&0xF) : x] =
((uint32_t)dequant4_coeff_init[idx][(x&1) + ((x>>2)&1)] *
@@ -3572,7 +3452,7 @@ static inline void xchg_pair_border(H264Context *h, uint8_t *src_y, uint8_t *src
int deblock_left = (s->mb_x > 0);
int deblock_top = (s->mb_y > 1);
- tprintf("xchg_pair_border: src_y:%p src_cb:%p src_cr:%p ls:%d uvls:%d\n", src_y, src_cb, src_cr, linesize, uvlinesize);
+ tprintf(s->avctx, "xchg_pair_border: src_y:%p src_cb:%p src_cr:%p ls:%d uvls:%d\n", src_y, src_cb, src_cr, linesize, uvlinesize);
src_y -= 2 * linesize + 1;
src_cb -= 2 * uvlinesize + 1;
@@ -3617,7 +3497,7 @@ b= t;
}
}
-static void hl_decode_mb(H264Context *h){
+static void av_always_inline hl_decode_mb_internal(H264Context *h, int simple){
MpegEncContext * const s = &h->s;
const int mb_x= s->mb_x;
const int mb_y= s->mb_y;
@@ -3628,13 +3508,10 @@ static void hl_decode_mb(H264Context *h){
int i;
int *block_offset = &h->block_offset[0];
const unsigned int bottom = mb_y & 1;
- const int transform_bypass = (s->qscale == 0 && h->sps.transform_bypass);
+ const int transform_bypass = (s->qscale == 0 && h->sps.transform_bypass), is_h264 = (simple || s->codec_id == CODEC_ID_H264);
void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
- if(!s->decode)
- return;
-
dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16;
dest_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
dest_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
@@ -3642,7 +3519,7 @@ static void hl_decode_mb(H264Context *h){
s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + 64, s->linesize, 4);
s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + 64, dest_cr - dest_cb, 2);
- if (MB_FIELD) {
+ if (!simple && MB_FIELD) {
linesize = h->mb_linesize = s->linesize * 2;
uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;
block_offset = &h->block_offset[24];
@@ -3653,7 +3530,7 @@ static void hl_decode_mb(H264Context *h){
}
if(FRAME_MBAFF) {
int list;
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
if(!USES_LIST(mb_type, list))
continue;
if(IS_16X16(mb_type)){
@@ -3686,7 +3563,7 @@ static void hl_decode_mb(H264Context *h){
idct_add = s->dsp.h264_idct_add;
}
- if(FRAME_MBAFF && h->deblocking_filter && IS_INTRA(mb_type)
+ if(!simple && FRAME_MBAFF && h->deblocking_filter && IS_INTRA(mb_type)
&& (!bottom || !IS_INTRA(s->current_picture.mb_type[mb_xy-s->mb_stride]))){
int mbt_y = mb_y&~1;
uint8_t *top_y = s->current_picture.data[0] + (mbt_y * 16* s->linesize ) + mb_x * 16;
@@ -3695,7 +3572,7 @@ static void hl_decode_mb(H264Context *h){
xchg_pair_border(h, top_y, top_cb, top_cr, s->linesize, s->uvlinesize, 1);
}
- if (IS_INTRA_PCM(mb_type)) {
+ if (!simple && IS_INTRA_PCM(mb_type)) {
unsigned int x, y;
// The pixels are stored in h->mb array in the same order as levels,
@@ -3723,23 +3600,23 @@ static void hl_decode_mb(H264Context *h){
}
} else {
if(IS_INTRA(mb_type)){
- if(h->deblocking_filter && !FRAME_MBAFF)
+ if(h->deblocking_filter && (simple || !FRAME_MBAFF))
xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1);
- if(!(s->flags&CODEC_FLAG_GRAY)){
+ if(simple || !(s->flags&CODEC_FLAG_GRAY)){
h->pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize);
h->pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize);
}
if(IS_INTRA4x4(mb_type)){
- if(!s->encoding){
+ if(simple || !s->encoding){
if(IS_8x8DCT(mb_type)){
for(i=0; i<16; i+=4){
uint8_t * const ptr= dest_y + block_offset[i];
const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
const int nnz = h->non_zero_count_cache[ scan8[i] ];
h->pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
- (h->topright_samples_available<<(i+1))&0x8000, linesize);
+ (h->topright_samples_available<<i)&0x4000, linesize);
if(nnz){
if(nnz == 1 && h->mb[i*16])
idct_dc_add(ptr, h->mb + i*16, linesize);
@@ -3768,7 +3645,7 @@ static void hl_decode_mb(H264Context *h){
h->pred4x4[ dir ](ptr, topright, linesize);
nnz = h->non_zero_count_cache[ scan8[i] ];
if(nnz){
- if(s->codec_id == CODEC_ID_H264){
+ if(is_h264){
if(nnz == 1 && h->mb[i*16])
idct_dc_add(ptr, h->mb + i*16, linesize);
else
@@ -3780,15 +3657,15 @@ static void hl_decode_mb(H264Context *h){
}
}else{
h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
- if(s->codec_id == CODEC_ID_H264){
+ if(is_h264){
if(!transform_bypass)
h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[IS_INTRA(mb_type) ? 0:3][s->qscale][0]);
}else
svq3_luma_dc_dequant_idct_c(h->mb, s->qscale);
}
- if(h->deblocking_filter && !FRAME_MBAFF)
+ if(h->deblocking_filter && (simple || !FRAME_MBAFF))
xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0);
- }else if(s->codec_id == CODEC_ID_H264){
+ }else if(is_h264){
hl_motion(h, dest_y, dest_cb, dest_cr,
s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
@@ -3797,7 +3674,7 @@ static void hl_decode_mb(H264Context *h){
if(!IS_INTRA4x4(mb_type)){
- if(s->codec_id == CODEC_ID_H264){
+ if(is_h264){
if(IS_INTRA16x16(mb_type)){
for(i=0; i<16; i++){
if(h->non_zero_count_cache[ scan8[i] ])
@@ -3827,7 +3704,7 @@ static void hl_decode_mb(H264Context *h){
}
}
- if(!(s->flags&CODEC_FLAG_GRAY)){
+ if(simple || !(s->flags&CODEC_FLAG_GRAY)){
uint8_t *dest[2] = {dest_cb, dest_cr};
if(transform_bypass){
idct_add = idct_dc_add = s->dsp.add_pixels4;
@@ -3837,7 +3714,7 @@ static void hl_decode_mb(H264Context *h){
chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp, h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp][0]);
chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp, h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp][0]);
}
- if(s->codec_id == CODEC_ID_H264){
+ if(is_h264){
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);
@@ -3855,7 +3732,7 @@ static void hl_decode_mb(H264Context *h){
}
}
if(h->deblocking_filter) {
- if (FRAME_MBAFF) {
+ if (!simple && FRAME_MBAFF) {
//FIXME try deblocking one mb at a time?
// the reduction in load/storing mvs and such might outweigh the extra backup/xchg_border
const int mb_y = s->mb_y - 1;
@@ -3875,18 +3752,18 @@ static void hl_decode_mb(H264Context *h){
// deblock a pair
// top
s->mb_y--;
- tprintf("call mbaff filter_mb mb_x:%d mb_y:%d pair_dest_y = %p, dest_y = %p\n", mb_x, mb_y, pair_dest_y, dest_y);
+ tprintf(h->s.avctx, "call mbaff filter_mb mb_x:%d mb_y:%d pair_dest_y = %p, dest_y = %p\n", mb_x, mb_y, pair_dest_y, dest_y);
fill_caches(h, mb_type_top, 1); //FIXME don't fill stuff which isn't used by filter_mb
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->current_picture.qscale_table[mb_xy]);
filter_mb(h, mb_x, mb_y, pair_dest_y, pair_dest_cb, pair_dest_cr, linesize, uvlinesize);
// bottom
s->mb_y++;
- tprintf("call mbaff filter_mb\n");
+ tprintf(h->s.avctx, "call mbaff filter_mb\n");
fill_caches(h, mb_type_bottom, 1); //FIXME don't fill stuff which isn't used by filter_mb
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->current_picture.qscale_table[mb_xy+s->mb_stride]);
filter_mb(h, mb_x, mb_y+1, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
} else {
- tprintf("call filter_mb\n");
+ tprintf(h->s.avctx, "call filter_mb\n");
backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
fill_caches(h, mb_type, 1); //FIXME don't fill stuff which isn't used by filter_mb
filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
@@ -3895,6 +3772,36 @@ static void hl_decode_mb(H264Context *h){
}
/**
+ * Process a macroblock; this case avoids checks for expensive uncommon cases.
+ */
+static void hl_decode_mb_simple(H264Context *h){
+ hl_decode_mb_internal(h, 1);
+}
+
+/**
+ * Process a macroblock; this handles edge cases, such as interlacing.
+ */
+static void av_noinline hl_decode_mb_complex(H264Context *h){
+ hl_decode_mb_internal(h, 0);
+}
+
+static void hl_decode_mb(H264Context *h){
+ MpegEncContext * const s = &h->s;
+ const int mb_x= s->mb_x;
+ const int mb_y= s->mb_y;
+ const int mb_xy= mb_x + mb_y*s->mb_stride;
+ const int mb_type= s->current_picture.mb_type[mb_xy];
+ int is_complex = FRAME_MBAFF || MB_FIELD || IS_INTRA_PCM(mb_type) || s->codec_id != CODEC_ID_H264 || (s->flags&CODEC_FLAG_GRAY) || s->encoding;
+
+ if(!s->decode)
+ return;
+
+ if (is_complex)
+ hl_decode_mb_complex(h);
+ else hl_decode_mb_simple(h);
+}
+
+/**
* fills the default_ref_list.
*/
static int fill_default_ref_list(H264Context *h){
@@ -3924,7 +3831,7 @@ static int fill_default_ref_list(H264Context *h){
limit= best_poc;
sorted_short_ref[out_i]= *h->short_ref[best_i];
- tprintf("sorted poc: %d->%d poc:%d fn:%d\n", best_i, out_i, sorted_short_ref[out_i].poc, sorted_short_ref[out_i].frame_num);
+ tprintf(h->s.avctx, "sorted poc: %d->%d poc:%d fn:%d\n", best_i, out_i, sorted_short_ref[out_i].poc, sorted_short_ref[out_i].frame_num);
if (-1 == smallest_poc_greater_than_current) {
if (h->short_ref[best_i]->poc >= s->current_picture_ptr->poc) {
smallest_poc_greater_than_current = out_i;
@@ -3936,7 +3843,7 @@ static int fill_default_ref_list(H264Context *h){
if(s->picture_structure == PICT_FRAME){
if(h->slice_type==B_TYPE){
int list;
- tprintf("current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current);
+ tprintf(h->s.avctx, "current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current);
// find the largest poc
for(list=0; list<2; list++){
@@ -3999,11 +3906,11 @@ static int fill_default_ref_list(H264Context *h){
}
#ifdef TRACE
for (i=0; i<h->ref_count[0]; i++) {
- tprintf("List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].data[0]);
+ tprintf(h->s.avctx, "List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].data[0]);
}
if(h->slice_type==B_TYPE){
for (i=0; i<h->ref_count[1]; i++) {
- tprintf("List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[0][i].data[0]);
+ tprintf(h->s.avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[0][i].data[0]);
}
}
#endif
@@ -4021,15 +3928,15 @@ static int decode_ref_pic_list_reordering(H264Context *h){
print_long_term(h);
if(h->slice_type==I_TYPE || h->slice_type==SI_TYPE) return 0; //FIXME move before func
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]);
if(get_bits1(&s->gb)){
int pred= h->curr_pic_num;
for(index=0; ; index++){
- int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb);
- int pic_id;
+ unsigned int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb);
+ unsigned int pic_id;
int i;
Picture *ref = NULL;
@@ -4043,7 +3950,7 @@ static int decode_ref_pic_list_reordering(H264Context *h){
if(reordering_of_pic_nums_idc<3){
if(reordering_of_pic_nums_idc<2){
- const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
+ const unsigned int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
if(abs_diff_pic_num >= h->max_pic_num){
av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
@@ -4065,11 +3972,19 @@ static int decode_ref_pic_list_reordering(H264Context *h){
ref->pic_id= ref->frame_num;
}else{
pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx
+ if(pic_id>31){
+ av_log(h->s.avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
+ return -1;
+ }
ref = h->long_ref[pic_id];
- ref->pic_id= pic_id;
- assert(ref->reference == 3);
- assert(ref->long_ref);
- i=0;
+ if(ref){
+ ref->pic_id= pic_id;
+ assert(ref->reference == 3);
+ assert(ref->long_ref);
+ i=0;
+ }else{
+ i=-1;
+ }
}
if (i < 0) {
@@ -4091,15 +4006,12 @@ static int decode_ref_pic_list_reordering(H264Context *h){
}
}
}
-
- if(h->slice_type!=B_TYPE) break;
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
for(index= 0; index < h->ref_count[list]; index++){
if(!h->ref_list[list][index].data[0])
h->ref_list[list][index]= s->current_picture;
}
- if(h->slice_type!=B_TYPE) break;
}
if(h->slice_type==B_TYPE && !h->direct_spatial_mv_pred)
@@ -4110,7 +4022,7 @@ static int decode_ref_pic_list_reordering(H264Context *h){
static void fill_mbaff_ref_list(H264Context *h){
int list, i, j;
- for(list=0; list<2; list++){
+ for(list=0; list<2; list++){ //FIXME try list_count
for(i=0; i<h->ref_count[list]; i++){
Picture *frame = &h->ref_list[list][i];
Picture *field = &h->ref_list[list][16+2*i];
@@ -4210,11 +4122,11 @@ static void implicit_weight_table(H264Context *h){
int poc0 = h->ref_list[0][ref0].poc;
for(ref1=0; ref1 < h->ref_count[1]; ref1++){
int poc1 = h->ref_list[1][ref1].poc;
- int td = clip(poc1 - poc0, -128, 127);
+ int td = av_clip(poc1 - poc0, -128, 127);
if(td){
- int tb = clip(cur_poc - poc0, -128, 127);
+ int tb = av_clip(cur_poc - poc0, -128, 127);
int tx = (16384 + (FFABS(td) >> 1)) / td;
- int dist_scale_factor = clip((tb*tx + 32) >> 6, -1024, 1023) >> 2;
+ int dist_scale_factor = av_clip((tb*tx + 32) >> 6, -1024, 1023) >> 2;
if(dist_scale_factor < -64 || dist_scale_factor > 128)
h->implicit_weight[ref0][ref1] = 32;
else
@@ -4375,8 +4287,10 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
if(pic) unreference_pic(h, pic);
h->long_ref[ mmco[i].long_index ]= remove_short(h, mmco[i].short_frame_num);
- h->long_ref[ mmco[i].long_index ]->long_ref=1;
- h->long_ref_count++;
+ if (h->long_ref[ mmco[i].long_index ]){
+ h->long_ref[ mmco[i].long_index ]->long_ref=1;
+ h->long_ref_count++;
+ }
break;
case MMCO_LONG2UNUSED:
pic= remove_long(h, mmco[i].long_index);
@@ -4406,7 +4320,7 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
case MMCO_RESET:
while(h->short_ref_count){
pic= remove_short(h, h->short_ref[0]->frame_num);
- unreference_pic(h, pic);
+ if(pic) unreference_pic(h, pic);
}
for(j = 0; j < 16; j++) {
pic= remove_long(h, j);
@@ -4464,14 +4378,15 @@ static int decode_ref_pic_marking(H264Context *h){
}*/
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
- h->mmco[i].long_index= get_ue_golomb(&s->gb);
- if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){
+ unsigned int long_index= get_ue_golomb(&s->gb);
+ if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ long_index >= 16){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
+ h->mmco[i].long_index= long_index;
}
- if(opcode > MMCO_LONG){
+ if(opcode > (unsigned)MMCO_LONG){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
@@ -4589,10 +4504,11 @@ static int init_poc(H264Context *h){
*/
static int decode_slice_header(H264Context *h){
MpegEncContext * const s = &h->s;
- int first_mb_in_slice, pps_id;
+ unsigned int first_mb_in_slice;
+ unsigned int pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
- int slice_type;
+ unsigned int slice_type, tmp;
int default_ref_list_done = 0;
s->current_picture.reference= h->nal_ref_idc != 0;
@@ -4600,6 +4516,11 @@ static int decode_slice_header(H264Context *h){
first_mb_in_slice= get_ue_golomb(&s->gb);
+ if((s->flags2 & CODEC_FLAG2_CHUNKS) && first_mb_in_slice == 0){
+ h->slice_num = 0;
+ s->current_picture_ptr= NULL;
+ }
+
slice_type= get_ue_golomb(&s->gb);
if(slice_type > 9){
av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
@@ -4621,7 +4542,7 @@ static int decode_slice_header(H264Context *h){
s->pict_type= h->slice_type; // to make a few old func happy, it's wrong though
pps_id= get_ue_golomb(&s->gb);
- if(pps_id>255){
+ if(pps_id>=MAX_PPS_COUNT){
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1;
}
@@ -4745,12 +4666,15 @@ static int decode_slice_header(H264Context *h){
h->mb_aff_frame = h->sps.mb_aff;
}
}
-
- s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
- s->resync_mb_y = s->mb_y = (first_mb_in_slice / s->mb_width) << h->mb_aff_frame;
- if(s->mb_y >= s->mb_height){
+ assert(s->mb_num == s->mb_width * s->mb_height);
+ if(first_mb_in_slice << h->mb_aff_frame >= s->mb_num ||
+ first_mb_in_slice >= s->mb_num){
+ av_log(h->s.avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return -1;
}
+ s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
+ s->resync_mb_y = s->mb_y = (first_mb_in_slice / s->mb_width) << h->mb_aff_frame;
+ assert(s->mb_y < s->mb_height);
if(s->picture_structure==PICT_FRAME){
h->curr_pic_num= h->frame_num;
@@ -4802,12 +4726,18 @@ static int decode_slice_header(H264Context *h){
if(h->slice_type==B_TYPE)
h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
- if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
+ if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
+ h->ref_count[0]= h->ref_count[1]= 1;
return -1;
}
}
- }
+ if(h->slice_type == B_TYPE)
+ h->list_count= 2;
+ else
+ h->list_count= 1;
+ }else
+ h->list_count= 0;
if(!default_ref_list_done){
fill_default_ref_list(h);
@@ -4830,15 +4760,22 @@ static int decode_slice_header(H264Context *h){
if(FRAME_MBAFF)
fill_mbaff_ref_list(h);
- if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac )
- h->cabac_init_idc = get_ue_golomb(&s->gb);
+ if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac ){
+ tmp = get_ue_golomb(&s->gb);
+ if(tmp > 2){
+ av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n");
+ return -1;
+ }
+ h->cabac_init_idc= tmp;
+ }
h->last_qscale_diff = 0;
- s->qscale = h->pps.init_qp + get_se_golomb(&s->gb);
- if(s->qscale<0 || s->qscale>51){
- av_log(s->avctx, AV_LOG_ERROR, "QP %d out of range\n", s->qscale);
+ tmp = h->pps.init_qp + get_se_golomb(&s->gb);
+ if(tmp>51){
+ av_log(s->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return -1;
}
+ s->qscale= tmp;
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
//FIXME qscale / qp ... stuff
if(h->slice_type == SP_TYPE){
@@ -4852,7 +4789,12 @@ static int decode_slice_header(H264Context *h){
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if( h->pps.deblocking_filter_parameters_present ) {
- h->deblocking_filter= get_ue_golomb(&s->gb);
+ tmp= get_ue_golomb(&s->gb);
+ if(tmp > 2){
+ av_log(s->avctx, AV_LOG_ERROR, "deblocking_filter_idc %u out of range\n", tmp);
+ return -1;
+ }
+ h->deblocking_filter= tmp;
if(h->deblocking_filter < 2)
h->deblocking_filter^= 1; // 1<->0
@@ -4878,7 +4820,7 @@ static int decode_slice_header(H264Context *h){
h->emu_edge_height= FRAME_MBAFF ? 0 : h->emu_edge_width;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
h->slice_num,
(s->picture_structure==PICT_FRAME ? "F" : s->picture_structure==PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
@@ -4972,9 +4914,13 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
if(total_coeff==0)
return 0;
+ if(total_coeff > (unsigned)max_coeff) {
+ av_log(h->s.avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", s->mb_x, s->mb_y, total_coeff);
+ return -1;
+ }
trailing_ones= coeff_token&3;
- tprintf("trailing:%d, total:%d\n", trailing_ones, total_coeff);
+ tprintf(h->s.avctx, "trailing:%d, total:%d\n", trailing_ones, total_coeff);
assert(total_coeff<=16);
for(i=0; i<trailing_ones; i++){
@@ -5145,12 +5091,13 @@ static void decode_mb_skip(H264Context *h){
static int decode_mb_cavlc(H264Context *h){
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
- int mb_type, partition_count, cbp;
+ int partition_count;
+ unsigned int mb_type, cbp;
int dct8x8_allowed= h->pps.transform_8x8_mode;
s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong?
- tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
+ tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
cbp = 0; /* avoid warning. FIXME: find a solution without slowing
down the code */
if(h->slice_type != I_TYPE && h->slice_type != SI_TYPE){
@@ -5221,21 +5168,21 @@ decode_intra_mb:
for(y=0; y<16; y++){
const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
for(x=0; x<16; x++){
- tprintf("LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
+ tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8);
}
}
for(y=0; y<8; y++){
const int index= 256 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
- tprintf("CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
+ tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8);
}
}
for(y=0; y<8; y++){
const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
- tprintf("CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
+ tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8));
h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8);
}
}
@@ -5259,6 +5206,7 @@ decode_intra_mb:
//mb_pred
if(IS_INTRA(mb_type)){
+ int pred_mode;
// init_top_left_availability(h);
if(IS_INTRA4x4(mb_type)){
int i;
@@ -5290,11 +5238,11 @@ decode_intra_mb:
if(h->intra16x16_pred_mode < 0)
return -1;
}
- h->chroma_pred_mode= get_ue_golomb(&s->gb);
- h->chroma_pred_mode= check_intra_pred_mode(h, h->chroma_pred_mode);
- if(h->chroma_pred_mode < 0)
+ pred_mode= check_intra_pred_mode(h, get_ue_golomb(&s->gb));
+ if(pred_mode < 0)
return -1;
+ h->chroma_pred_mode= pred_mode;
}else if(partition_count==4){
int i, j, sub_partition_count[4], list, ref[2][4];
@@ -5302,7 +5250,7 @@ decode_intra_mb:
for(i=0; i<4; i++){
h->sub_mb_type[i]= get_ue_golomb(&s->gb);
if(h->sub_mb_type[i] >=13){
- av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
return -1;
}
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
@@ -5321,7 +5269,7 @@ decode_intra_mb:
for(i=0; i<4; i++){
h->sub_mb_type[i]= get_ue_golomb(&s->gb);
if(h->sub_mb_type[i] >=4){
- av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
return -1;
}
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
@@ -5329,13 +5277,17 @@ decode_intra_mb:
}
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list];
- if(ref_count == 0) continue;
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
- ref[list][i] = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip?
+ unsigned int tmp = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip?
+ if(tmp>=ref_count){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp);
+ return -1;
+ }
+ ref[list][i]= tmp;
}else{
//FIXME
ref[list][i] = -1;
@@ -5346,9 +5298,8 @@ decode_intra_mb:
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
const int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list];
- if(ref_count == 0) continue;
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])) {
@@ -5368,24 +5319,22 @@ decode_intra_mb:
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my);
mx += get_se_golomb(&s->gb);
my += get_se_golomb(&s->gb);
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
- mv_cache[ 0 ][0]= mv_cache[ 1 ][0]=
+ mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
- mv_cache[ 0 ][1]= mv_cache[ 1 ][1]=
+ mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
}else if(IS_SUB_8X4(sub_mb_type)){
- mv_cache[ 0 ][0]= mv_cache[ 1 ][0]= mx;
- mv_cache[ 0 ][1]= mv_cache[ 1 ][1]= my;
+ mv_cache[ 1 ][0]= mx;
+ mv_cache[ 1 ][1]= my;
}else if(IS_SUB_4X8(sub_mb_type)){
- mv_cache[ 0 ][0]= mv_cache[ 8 ][0]= mx;
- mv_cache[ 0 ][1]= mv_cache[ 8 ][1]= my;
- }else{
- assert(IS_SUB_4X4(sub_mb_type));
- mv_cache[ 0 ][0]= mx;
- mv_cache[ 0 ][1]= my;
+ mv_cache[ 8 ][0]= mx;
+ mv_cache[ 8 ][1]= my;
}
+ mv_cache[ 0 ][0]= mx;
+ mv_cache[ 0 ][1]= my;
}
}else{
uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
@@ -5401,76 +5350,91 @@ decode_intra_mb:
int list, mx, my, i;
//FIXME we should set ref_idx_l? to 0 if we use that later ...
if(IS_16X16(mb_type)){
- for(list=0; list<2; list++){
- if(h->ref_count[list]>0){
+ for(list=0; list<h->list_count; list++){
+ unsigned int val;
if(IS_DIR(mb_type, 0, list)){
- const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
- fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
+ val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ if(val >= h->ref_count[list]){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
+ return -1;
+ }
}else
- fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (LIST_NOT_USED&0xFF), 1);
- }
+ val= LIST_NOT_USED&0xFF;
+ fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
+ unsigned int val;
if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my);
mx += get_se_golomb(&s->gb);
my += get_se_golomb(&s->gb);
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
- fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
+ val= pack16to32(mx,my);
}else
- fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
+ val=0;
+ fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, val, 4);
}
}
else if(IS_16X8(mb_type)){
- for(list=0; list<2; list++){
- if(h->ref_count[list]>0){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
+ unsigned int val;
if(IS_DIR(mb_type, i, list)){
- const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
+ val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ if(val >= h->ref_count[list]){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
+ return -1;
+ }
}else
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
+ val= LIST_NOT_USED&0xFF;
+ fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
}
- }
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
+ unsigned int val;
if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my);
mx += get_se_golomb(&s->gb);
my += get_se_golomb(&s->gb);
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
- fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
+ val= pack16to32(mx,my);
}else
- fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
+ val=0;
+ fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4);
}
}
}else{
assert(IS_8X16(mb_type));
- for(list=0; list<2; list++){
- if(h->ref_count[list]>0){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
+ unsigned int val;
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
- const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
+ val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ if(val >= h->ref_count[list]){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
+ return -1;
+ }
}else
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
+ val= LIST_NOT_USED&0xFF;
+ fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
}
- }
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
+ unsigned int val;
if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
mx += get_se_golomb(&s->gb);
my += get_se_golomb(&s->gb);
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
- fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
+ val= pack16to32(mx,my);
}else
- fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
+ val=0;
+ fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4);
}
}
}
@@ -5482,7 +5446,7 @@ decode_intra_mb:
if(!IS_INTRA16x16(mb_type)){
cbp= get_ue_golomb(&s->gb);
if(cbp > 47){
- av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y);
return -1;
}
@@ -5822,7 +5786,7 @@ static int decode_cabac_mb_cbp_luma( H264Context *h) {
if( h->slice_table[h->top_mb_xy] == h->slice_num ) {
cbp_b = h->top_cbp;
- tprintf("cbp_b = top_cbp = %x\n", cbp_b);
+ tprintf(h->s.avctx, "cbp_b = top_cbp = %x\n", cbp_b);
}
for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
@@ -5837,7 +5801,7 @@ static int decode_cabac_mb_cbp_luma( H264Context *h) {
cbp_a = cbp;
else if( h->slice_table[h->left_mb_xy[0]] == h->slice_num ) {
cbp_a = h->left_cbp;
- tprintf("cbp_a = left_cbp = %x\n", cbp_a);
+ tprintf(h->s.avctx, "cbp_a = left_cbp = %x\n", cbp_a);
}
if( y > 0 )
@@ -5964,6 +5928,10 @@ static int decode_cabac_mb_ref( H264Context *h, int list, int n ) {
ctx = 4;
else
ctx = 5;
+ if(ref >= 32 /*h->ref_list[list]*/){
+ av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_ref\n");
+ return 0; //FIXME we should return -1 and check the return everywhere
+ }
}
return ref;
}
@@ -5997,6 +5965,10 @@ static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) {
while( get_cabac_bypass( &h->cabac ) ) {
mvd += 1 << k;
k++;
+ if(k>24){
+ av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_mvd\n");
+ return INT_MIN;
+ }
}
while( k-- ) {
if( get_cabac_bypass( &h->cabac ) )
@@ -6139,7 +6111,7 @@ static int decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n
index[coeff_count++] = last;\
}
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
-#if defined(ARCH_X86) && !(defined(PIC) && defined(__GNUC__))
+#if defined(ARCH_X86) && defined(CONFIG_7REGS) && defined(CONFIG_EBX_AVAILABLE)
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, sig_off);
} else {
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index);
@@ -6253,7 +6225,7 @@ static int decode_mb_cabac(H264Context *h) {
s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong?)
- tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
+ tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) {
int skip;
/* a skipped mb needs the aff flag from the following mb */
@@ -6336,27 +6308,30 @@ decode_intra_mb:
// FIXME The two following lines get the bitstream position in the cabac
// decode, I think it should be done by a function in cabac.h (or cabac.c).
ptr= h->cabac.bytestream;
- if (h->cabac.low&0x1) ptr-=CABAC_BITS/8;
+ if(h->cabac.low&0x1) ptr--;
+ if(CABAC_BITS==16){
+ if(h->cabac.low&0x1FF) ptr--;
+ }
// The pixels are stored in the same order as levels in h->mb array.
for(y=0; y<16; y++){
const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3);
for(x=0; x<16; x++){
- tprintf("LUMA ICPM LEVEL (%3d)\n", *ptr);
+ tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
- tprintf("CHROMA U ICPM LEVEL (%3d)\n", *ptr);
+ tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
for(y=0; y<8; y++){
const int index= 256 + 64 + 4*(y&3) + 32*(y>>2);
for(x=0; x<8; x++){
- tprintf("CHROMA V ICPM LEVEL (%3d)\n", *ptr);
+ tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", *ptr);
h->mb[index + (x&3) + 16*(x>>2)]= *ptr++;
}
}
@@ -6383,7 +6358,7 @@ decode_intra_mb:
fill_caches(h, mb_type, 0);
if( IS_INTRA( mb_type ) ) {
- int i;
+ int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) {
mb_type |= MB_TYPE_8x8DCT;
@@ -6407,10 +6382,11 @@ decode_intra_mb:
if( h->intra16x16_pred_mode < 0 ) return -1;
}
h->chroma_pred_mode_table[mb_xy] =
- h->chroma_pred_mode = decode_cabac_mb_chroma_pre_mode( h );
+ pred_mode = decode_cabac_mb_chroma_pre_mode( h );
- h->chroma_pred_mode= check_intra_pred_mode( h, h->chroma_pred_mode );
- if( h->chroma_pred_mode < 0 ) return -1;
+ pred_mode= check_intra_pred_mode( h, pred_mode );
+ if( pred_mode < 0 ) return -1;
+ h->chroma_pred_mode= pred_mode;
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
@@ -6437,8 +6413,7 @@ decode_intra_mb:
}
}
- for( list = 0; list < 2; list++ ) {
- if( h->ref_count[list] > 0 ) {
+ for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
@@ -6452,13 +6427,12 @@ decode_intra_mb:
h->ref_cache[list][ scan8[4*i]+1 ]=
h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
}
- }
}
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 4);
@@ -6479,38 +6453,36 @@ decode_intra_mb:
mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
- mv_cache[ 0 ][0]= mv_cache[ 1 ][0]=
+ mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
- mv_cache[ 0 ][1]= mv_cache[ 1 ][1]=
+ mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
- mvd_cache[ 0 ][0]= mvd_cache[ 1 ][0]=
+ mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx;
- mvd_cache[ 0 ][1]= mvd_cache[ 1 ][1]=
+ mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy;
}else if(IS_SUB_8X4(sub_mb_type)){
- mv_cache[ 0 ][0]= mv_cache[ 1 ][0]= mx;
- mv_cache[ 0 ][1]= mv_cache[ 1 ][1]= my;
+ mv_cache[ 1 ][0]= mx;
+ mv_cache[ 1 ][1]= my;
- mvd_cache[ 0 ][0]= mvd_cache[ 1 ][0]= mx- mpx;
- mvd_cache[ 0 ][1]= mvd_cache[ 1 ][1]= my - mpy;
+ mvd_cache[ 1 ][0]= mx - mpx;
+ mvd_cache[ 1 ][1]= my - mpy;
}else if(IS_SUB_4X8(sub_mb_type)){
- mv_cache[ 0 ][0]= mv_cache[ 8 ][0]= mx;
- mv_cache[ 0 ][1]= mv_cache[ 8 ][1]= my;
-
- mvd_cache[ 0 ][0]= mvd_cache[ 8 ][0]= mx - mpx;
- mvd_cache[ 0 ][1]= mvd_cache[ 8 ][1]= my - mpy;
- }else{
- assert(IS_SUB_4X4(sub_mb_type));
- mv_cache[ 0 ][0]= mx;
- mv_cache[ 0 ][1]= my;
+ mv_cache[ 8 ][0]= mx;
+ mv_cache[ 8 ][1]= my;
- mvd_cache[ 0 ][0]= mx - mpx;
- mvd_cache[ 0 ][1]= my - mpy;
+ mvd_cache[ 8 ][0]= mx - mpx;
+ mvd_cache[ 8 ][1]= my - mpy;
}
+ mv_cache[ 0 ][0]= mx;
+ mv_cache[ 0 ][1]= my;
+
+ mvd_cache[ 0 ][0]= mx - mpx;
+ mvd_cache[ 0 ][1]= my - mpy;
}
}else{
uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
@@ -6528,22 +6500,20 @@ decode_intra_mb:
} else {
int list, mx, my, i, mpx, mpy;
if(IS_16X16(mb_type)){
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
- if(h->ref_count[list] > 0 ){
const int ref = h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 0 ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
- }
}else
- fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);
+ fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1); //FIXME factorize and the other fill_rect below too
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
@@ -6552,8 +6522,7 @@ decode_intra_mb:
}
}
else if(IS_16X8(mb_type)){
- for(list=0; list<2; list++){
- if(h->ref_count[list]>0){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 8*i ) : 0;
@@ -6561,15 +6530,14 @@ decode_intra_mb:
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
- }
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
@@ -6581,8 +6549,7 @@ decode_intra_mb:
}
}else{
assert(IS_8X16(mb_type));
- for(list=0; list<2; list++){
- if(h->ref_count[list]>0){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
const int ref= h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 4*i ) : 0;
@@ -6590,16 +6557,15 @@ decode_intra_mb:
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
- }
}
- for(list=0; list<2; list++){
+ for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
- tprintf("final mv:%d %d\n", mx, my);
+ tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}else{
@@ -6792,7 +6758,7 @@ static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int16_t b
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[ 0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
- tprintf("filter_mb_edgev i:%d d:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, p2, p1, p0, q0, q1, q2, pix[-2], pix[-1], pix[0], pix[1]);
+ tprintf(h->s.avctx, "filter_mb_edgev i:%d d:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, p2, p1, p0, q0, q1, q2, pix[-2], pix[-1], pix[0], pix[1]);
}
pix += stride;
}
@@ -6853,18 +6819,18 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int
int i_delta;
if( FFABS( p2 - p0 ) < beta ) {
- pix[-2] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 );
+ pix[-2] = p1 + av_clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 );
tc++;
}
if( FFABS( q2 - q0 ) < beta ) {
- pix[1] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 );
+ pix[1] = q1 + av_clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 );
tc++;
}
- i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
- pix[-1] = clip_uint8( p0 + i_delta ); /* p0' */
- pix[0] = clip_uint8( q0 - i_delta ); /* q0' */
- tprintf("filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
+ i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
+ pix[-1] = av_clip_uint8( p0 + i_delta ); /* p0' */
+ pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
+ tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
}
}else{
const int p0 = pix[-1];
@@ -6907,7 +6873,7 @@ static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[ 0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
- tprintf("filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, p2, p1, p0, q0, q1, q2, pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
+ tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, p2, p1, p0, q0, q1, q2, pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
}
}
}
@@ -6941,11 +6907,11 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in
if( FFABS( p0 - q0 ) < alpha &&
FFABS( p1 - p0 ) < beta &&
FFABS( q1 - q0 ) < beta ) {
- const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
+ const int i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
- pix[-1] = clip_uint8( p0 + i_delta ); /* p0' */
- pix[0] = clip_uint8( q0 - i_delta ); /* q0' */
- tprintf("filter_mb_mbaff_edgecv i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
+ pix[-1] = av_clip_uint8( p0 + i_delta ); /* p0' */
+ pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
+ tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
}
}else{
const int p0 = pix[-1];
@@ -6959,7 +6925,7 @@ static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, in
pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
- tprintf("filter_mb_mbaff_edgecv i:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, pix[-3], p1, p0, q0, q1, pix[2], pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
+ tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, pix[-3], p1, p0, q0, q1, pix[2], pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
}
}
}
@@ -7018,7 +6984,7 @@ static void filter_mb_edgeh( H264Context *h, uint8_t *pix, int stride, int16_t b
pix[-1*pix_next] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[ 0*pix_next] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
- tprintf("filter_mb_edgeh i:%d d:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, qp, index_a, alpha, beta, bS[i], p2, p1, p0, q0, q1, q2, pix[-2*pix_next], pix[-pix_next], pix[0], pix[pix_next]);
+ tprintf(h->s.avctx, "filter_mb_edgeh i:%d d:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, qp, index_a, alpha, beta, bS[i], p2, p1, p0, q0, q1, q2, pix[-2*pix_next], pix[-pix_next], pix[0], pix[pix_next]);
}
pix++;
}
@@ -7221,8 +7187,8 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
get_chroma_qp( h->pps.chroma_qp_index_offset, mbn1_qp ) + 1 ) >> 1;
/* Filter edge */
- tprintf("filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize);
- { int i; for (i = 0; i < 8; i++) tprintf(" bS[%d]:%d", i, bS[i]); tprintf("\n"); }
+ tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPc:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], chroma_qp[0], chroma_qp[1], linesize, uvlinesize);
+ { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_mbaff_edgev ( h, &img_y [0], linesize, bS, qp );
filter_mb_mbaff_edgecv( h, &img_cb[0], uvlinesize, bS, chroma_qp );
filter_mb_mbaff_edgecv( h, &img_cr[0], uvlinesize, bS, chroma_qp );
@@ -7284,8 +7250,8 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
// Do not use s->qscale as luma quantizer because it has not the same
// value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
- tprintf("filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
- { int i; for (i = 0; i < 4; i++) tprintf(" bS[%d]:%d", i, bS[i]); tprintf("\n"); }
+ tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
+ { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
filter_mb_edgeh( h, &img_y[j*linesize], tmp_linesize, bS, qp );
chroma_qp = ( h->chroma_qp +
get_chroma_qp( h->pps.chroma_qp_index_offset, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
@@ -7381,9 +7347,9 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
// Do not use s->qscale as luma quantizer because it has not the same
// value in IPCM macroblocks.
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
- //tprintf("filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]);
- tprintf("filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
- { int i; for (i = 0; i < 4; i++) tprintf(" bS[%d]:%d", i, bS[i]); tprintf("\n"); }
+ //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]);
+ tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
+ { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
@@ -7426,9 +7392,9 @@ static int decode_slice(H264Context *h){
for( i= 0; i < 460; i++ ) {
int pre;
if( h->slice_type == I_TYPE )
- pre = clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 );
+ pre = av_clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 );
else
- pre = clip( ((cabac_context_init_PB[h->cabac_init_idc][i][0] * s->qscale) >>4 ) + cabac_context_init_PB[h->cabac_init_idc][i][1], 1, 126 );
+ pre = av_clip( ((cabac_context_init_PB[h->cabac_init_idc][i][0] * s->qscale) >>4 ) + cabac_context_init_PB[h->cabac_init_idc][i][1], 1, 126 );
if( pre <= 63 )
h->cabac_state[i] = 2 * ( 63 - pre ) + 0;
@@ -7470,7 +7436,7 @@ static int decode_slice(H264Context *h){
}
if( eos || s->mb_y >= s->mb_height ) {
- tprintf("slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
+ tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
return 0;
}
@@ -7505,7 +7471,7 @@ static int decode_slice(H264Context *h){
++s->mb_y;
}
if(s->mb_y >= s->mb_height){
- tprintf("slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
+ tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
if(get_bits_count(&s->gb) == s->gb.size_in_bits ) {
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
@@ -7520,7 +7486,7 @@ static int decode_slice(H264Context *h){
}
if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->mb_skip_run<=0){
- tprintf("slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
+ tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
if(get_bits_count(&s->gb) == s->gb.size_in_bits ){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
@@ -7659,7 +7625,8 @@ static inline void decode_hrd_parameters(H264Context *h, SPS *sps){
static inline int decode_vui_parameters(H264Context *h, SPS *sps){
MpegEncContext * const s = &h->s;
- int aspect_ratio_info_present_flag, aspect_ratio_idc;
+ int aspect_ratio_info_present_flag;
+ unsigned int aspect_ratio_idc;
int nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
aspect_ratio_info_present_flag= get_bits1(&s->gb);
@@ -7719,13 +7686,21 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
sps->bitstream_restriction_flag = get_bits1(&s->gb);
if(sps->bitstream_restriction_flag){
+ unsigned int num_reorder_frames;
get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */
get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */
get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */
get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */
get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */
- sps->num_reorder_frames = get_ue_golomb(&s->gb);
- get_ue_golomb(&s->gb); /* max_dec_frame_buffering */
+ num_reorder_frames= get_ue_golomb(&s->gb);
+ get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/
+
+ if(num_reorder_frames > 16 /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", num_reorder_frames);
+ return -1;
+ }
+
+ sps->num_reorder_frames= num_reorder_frames;
}
return 0;
@@ -7781,7 +7756,8 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s
static inline int decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
int profile_idc, level_idc;
- int sps_id, i;
+ unsigned int sps_id, tmp, mb_width, mb_height;
+ int i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
@@ -7793,6 +7769,12 @@ static inline int decode_seq_parameter_set(H264Context *h){
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb(&s->gb);
+ if (sps_id >= MAX_SPS_COUNT){
+ // ok it has gone out of hand, someone is sending us bad stuff.
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal sps_id (%d)\n", sps_id);
+ return -1;
+ }
+
sps= &h->sps_buffer[ sps_id ];
sps->profile_idc= profile_idc;
sps->level_idc= level_idc;
@@ -7816,26 +7798,36 @@ static inline int decode_seq_parameter_set(H264Context *h){
sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
- sps->poc_cycle_length= get_ue_golomb(&s->gb);
+ tmp= get_ue_golomb(&s->gb);
+
+ if(tmp >= sizeof(sps->offset_for_ref_frame) / sizeof(sps->offset_for_ref_frame[0])){
+ av_log(h->s.avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", tmp);
+ return -1;
+ }
+ sps->poc_cycle_length= tmp;
for(i=0; i<sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
- }
- if(sps->poc_type > 2){
+ }else if(sps->poc_type != 2){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
- sps->ref_frame_count= get_ue_golomb(&s->gb);
- if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){
+ tmp= get_ue_golomb(&s->gb);
+ if(tmp > MAX_PICTURE_COUNT-2){
av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
}
+ sps->ref_frame_count= tmp;
sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
- sps->mb_width= get_ue_golomb(&s->gb) + 1;
- sps->mb_height= get_ue_golomb(&s->gb) + 1;
- 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))
+ mb_width= get_ue_golomb(&s->gb) + 1;
+ mb_height= get_ue_golomb(&s->gb) + 1;
+ if(mb_width >= INT_MAX/16 || mb_height >= INT_MAX/16 ||
+ avcodec_check_dimensions(NULL, 16*mb_width, 16*mb_height)){
+ av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
return -1;
+ }
+ sps->mb_width = mb_width;
+ sps->mb_height= mb_height;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
if(!sps->frame_mbs_only_flag)
@@ -7873,7 +7865,7 @@ static inline int decode_seq_parameter_set(H264Context *h){
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
+ 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\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
@@ -7890,10 +7882,22 @@ static inline int decode_seq_parameter_set(H264Context *h){
static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
MpegEncContext * const s = &h->s;
- int pps_id= get_ue_golomb(&s->gb);
- PPS *pps= &h->pps_buffer[pps_id];
+ unsigned int tmp, pps_id= get_ue_golomb(&s->gb);
+ PPS *pps;
+
+ if(pps_id>=MAX_PPS_COUNT){
+ av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
+ return -1;
+ }
+ pps = &h->pps_buffer[pps_id];
+
+ tmp= get_ue_golomb(&s->gb);
+ if(tmp>=MAX_SPS_COUNT){
+ av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n");
+ return -1;
+ }
+ pps->sps_id= tmp;
- pps->sps_id= get_ue_golomb(&s->gb);
pps->cabac= get_bits1(&s->gb);
pps->pic_order_present= get_bits1(&s->gb);
pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
@@ -7936,8 +7940,9 @@ static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
}
pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;
pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
- if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){
+ if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
+ pps->ref_count[0]= pps->ref_count[1]= 1;
return -1;
}
@@ -7962,7 +7967,7 @@ static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
}
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s %s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s %s\n",
pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count,
@@ -7990,36 +7995,45 @@ static int find_frame_end(H264Context *h, const uint8_t *buf, int buf_size){
//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
// mb_addr= pc->mb_addr - 1;
state= pc->state;
- for(i=0; i<=buf_size; i++){
- if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
- tprintf("find_frame_end new startcode = %08x, frame_start_found = %d, pos = %d\n", state, pc->frame_start_found, i);
- if(pc->frame_start_found){
- // If there isn't one more byte in the buffer
- // the test on first_mb_in_slice cannot be done yet
- // do it at next call.
- if (i >= buf_size) break;
- if (buf[i] & 0x80) {
- // first_mb_in_slice is 0, probably the first nal of a new
- // slice
- tprintf("find_frame_end frame_end_found, state = %08x, pos = %d\n", state, i);
- pc->state=-1;
+ if(state>13)
+ state= 7;
+
+ for(i=0; i<buf_size; i++){
+ if(state==7){
+ for(; i<buf_size; i++){
+ if(!buf[i]){
+ state=2;
+ break;
+ }
+ }
+ }else if(state<=2){
+ if(buf[i]==1) state^= 5; //2->7, 1->4, 0->5
+ else if(buf[i]) state = 7;
+ else state>>=1; //2->1, 1->0, 0->0
+ }else if(state<=5){
+ int v= buf[i] & 0x1F;
+ if(v==7 || v==8 || v==9){
+ if(pc->frame_start_found){
+ i++;
+found:
+ pc->state=7;
pc->frame_start_found= 0;
- return i-4;
+ return i-(state&5);
}
+ }else if(v==1 || v==2 || v==5){
+ if(pc->frame_start_found){
+ state+=8;
+ continue;
+ }else
+ pc->frame_start_found = 1;
}
- pc->frame_start_found = 1;
- }
- if((state&0xFFFFFF1F) == 0x107 || (state&0xFFFFFF1F) == 0x108 || (state&0xFFFFFF1F) == 0x109){
- if(pc->frame_start_found){
- pc->state=-1;
- pc->frame_start_found= 0;
- return i-4;
- }
+ state= 7;
+ }else{
+ if(buf[i] & 0x80)
+ goto found;
+ state= 7;
}
- if (i<buf_size)
- state= (state<<8) | buf[i];
}
-
pc->state= state;
return END_NOT_FOUND;
}
@@ -8034,12 +8048,20 @@ static int h264_parse(AVCodecParserContext *s,
ParseContext *pc = &h->s.parse_context;
int next;
- next= find_frame_end(h, buf, buf_size);
+ if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
+ next= buf_size;
+ }else{
+ next= find_frame_end(h, buf, buf_size);
+
+ if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
- if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
+ if(next<0){
+ find_frame_end(h, &pc->buffer[pc->last_index + next], -next); //update state
+ }
}
*poutbuf = (uint8_t *)buf;
@@ -8082,8 +8104,11 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
}
#endif
- h->slice_num = 0;
- s->current_picture_ptr= NULL;
+ if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
+ h->slice_num = 0;
+ s->current_picture_ptr= NULL;
+ }
+
for(;;){
int consumed;
int dst_length;
@@ -8096,7 +8121,7 @@ static int decode_nal_units(H264Context *h, 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){
+ if(nalsize <= 1 || nalsize > buf_size){
if(nalsize == 1){
buf_index++;
continue;
@@ -8119,9 +8144,12 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
}
ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
+ if (ptr==NULL || dst_length <= 0){
+ return -1;
+ }
while(ptr[dst_length - 1] == 0 && dst_length > 1)
dst_length--;
- bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
+ bit_length= 8*dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1);
if(s->avctx->debug&FF_DEBUG_STARTCODE){
av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", h->nal_unit_type, buf_index, buf_size, dst_length);
@@ -8176,6 +8204,7 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
h->inter_gb_ptr= &h->inter_gb;
if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning
+ && s->context_initialized
&& s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
@@ -8215,24 +8244,6 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
}
}
- if(!s->current_picture_ptr) return buf_index; //no frame
-
- s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
- s->current_picture_ptr->pict_type= s->pict_type;
-
- h->prev_frame_num_offset= h->frame_num_offset;
- h->prev_frame_num= h->frame_num;
- if(s->current_picture_ptr->reference){
- h->prev_poc_msb= h->poc_msb;
- h->prev_poc_lsb= h->poc_lsb;
- }
- if(s->current_picture_ptr->reference)
- execute_ref_pic_marking(h, h->mmco, h->mmco_index);
-
- ff_er_frame_end(s);
-
- MPV_frame_end(s);
-
return buf_index;
}
@@ -8267,6 +8278,26 @@ static int decode_frame(AVCodecContext *avctx,
/* no supplementary picture */
if (buf_size == 0) {
+ Picture *out;
+ int i, out_idx;
+
+//FIXME factorize this with the output code below
+ out = h->delayed_pic[0];
+ out_idx = 0;
+ for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame; i++)
+ if(h->delayed_pic[i]->poc < out->poc){
+ out = h->delayed_pic[i];
+ out_idx = i;
+ }
+
+ for(i=out_idx; h->delayed_pic[i]; i++)
+ h->delayed_pic[i] = h->delayed_pic[i+1];
+
+ if(out){
+ *data_size = sizeof(AVFrame);
+ *pict= *(AVFrame*)out;
+ }
+
return 0;
}
@@ -8296,7 +8327,7 @@ static int decode_frame(AVCodecContext *avctx,
cnt = *(p+5) & 0x1f; // Number of sps
p += 6;
for (i = 0; i < cnt; i++) {
- nalsize = BE_16(p) + 2;
+ nalsize = AV_RB16(p) + 2;
if(decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n", i);
return -1;
@@ -8306,7 +8337,7 @@ static int decode_frame(AVCodecContext *avctx,
// Decode pps from avcC
cnt = *(p++); // Number of pps
for (i = 0; i < cnt; i++) {
- nalsize = BE_16(p) + 2;
+ nalsize = AV_RB16(p) + 2;
if(decode_nal_units(h, p, nalsize) != nalsize) {
av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n", i);
return -1;
@@ -8319,7 +8350,7 @@ static int decode_frame(AVCodecContext *avctx,
h->got_avcC = 1;
}
- if(!h->is_avc && s->avctx->extradata_size && s->picture_number==0){
+ if(avctx->frame_number==0 && !h->is_avc && s->avctx->extradata_size){
if(decode_nal_units(h, s->avctx->extradata, s->avctx->extradata_size) < 0)
return -1;
}
@@ -8328,23 +8359,41 @@ static int decode_frame(AVCodecContext *avctx,
if(buf_index < 0)
return -1;
- //FIXME do something with unavailable reference frames
-
-// if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_index, buf_size);
- if(!s->current_picture_ptr){
- av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n");
+ if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
+ av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return -1;
}
- {
+ if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){
Picture *out = s->current_picture_ptr;
+ Picture *cur = s->current_picture_ptr;
+ Picture *prev = h->delayed_output_pic;
+ int i, pics, cross_idr, out_of_order, out_idx;
+
+ s->mb_y= 0;
+
+ s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
+ s->current_picture_ptr->pict_type= s->pict_type;
+
+ h->prev_frame_num_offset= h->frame_num_offset;
+ h->prev_frame_num= h->frame_num;
+ if(s->current_picture_ptr->reference){
+ h->prev_poc_msb= h->poc_msb;
+ h->prev_poc_lsb= h->poc_lsb;
+ }
+ if(s->current_picture_ptr->reference)
+ execute_ref_pic_marking(h, h->mmco, h->mmco_index);
+
+ ff_er_frame_end(s);
+
+ MPV_frame_end(s);
+
+ //FIXME do something with unavailable reference frames
+
#if 0 //decode order
*data_size = sizeof(AVFrame);
#else
/* Sort B-frames into display order */
- Picture *cur = s->current_picture_ptr;
- Picture *prev = h->delayed_output_pic;
- int i, pics, cross_idr, out_of_order, out_idx;
if(h->sps.bitstream_restriction_flag
&& s->avctx->has_b_frames < h->sps.num_reorder_frames){
@@ -8354,6 +8403,9 @@ static int decode_frame(AVCodecContext *avctx,
pics = 0;
while(h->delayed_pic[pics]) pics++;
+
+ assert(pics+1 < sizeof(h->delayed_pic) / sizeof(h->delayed_pic[0]));
+
h->delayed_pic[pics++] = cur;
if(cur->reference == 0)
cur->reference = 1;
diff --git a/contrib/ffmpeg/libavcodec/h264data.h b/contrib/ffmpeg/libavcodec/h264data.h
index 2dea3580f..74e720421 100644
--- a/contrib/ffmpeg/libavcodec/h264data.h
+++ b/contrib/ffmpeg/libavcodec/h264data.h
@@ -53,6 +53,24 @@
#define EXTENDED_SAR 255
+/* NAL unit types */
+enum {
+NAL_SLICE=1,
+NAL_DPA,
+NAL_DPB,
+NAL_DPC,
+NAL_IDR_SLICE,
+NAL_SEI,
+NAL_SPS,
+NAL_PPS,
+NAL_AUD,
+NAL_END_SEQUENCE,
+NAL_END_STREAM,
+NAL_FILLER_DATA,
+NAL_SPS_EXT,
+NAL_AUXILIARY_SLICE=19
+};
+
static const AVRational pixel_aspect[14]={
{0, 1},
{1, 1},
@@ -488,15 +506,6 @@ static const PMbInfo b_sub_mb_type_info[13]={
{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, },
};
-
-static const uint8_t rem6[52]={
-0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
-};
-
-static const uint8_t div6[52]={
-0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
-};
-
static const uint8_t default_scaling4[2][16]={
{ 6,13,20,28,
13,20,28,32,
diff --git a/contrib/ffmpeg/libavcodec/h264dsp.c b/contrib/ffmpeg/libavcodec/h264dsp.c
new file mode 100644
index 000000000..4f18afac4
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/h264dsp.c
@@ -0,0 +1,81 @@
+/*
+ * 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 h264dsp.c
+ * H.264 encoder related DSP utils
+ *
+ */
+
+#include "dsputil.h"
+
+extern const uint8_t ff_div6[52];
+extern const uint8_t ff_rem6[52];
+
+#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);
+}
+
+void ff_h264dsp_init(DSPContext* c, AVCodecContext *avctx)
+{
+ c->h264_dct = h264_dct_c;
+}
+
diff --git a/contrib/ffmpeg/libavcodec/h264enc.c b/contrib/ffmpeg/libavcodec/h264enc.c
new file mode 100644
index 000000000..15e182302
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/h264enc.c
@@ -0,0 +1,107 @@
+/*
+ * H.264 encoder
+ *
+ * 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 "common.h"
+#include "bitstream.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
+ * @returns pointer to current position in the output buffer or NULL if an error occured
+ */
+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;
+}
+
diff --git a/contrib/ffmpeg/libavcodec/h264idct.c b/contrib/ffmpeg/libavcodec/h264idct.c
index 3506418ad..a6a56d33a 100644
--- a/contrib/ffmpeg/libavcodec/h264idct.c
+++ b/contrib/ffmpeg/libavcodec/h264idct.c
@@ -28,7 +28,7 @@
#include "dsputil.h"
-static always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){
+static av_always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
diff --git a/contrib/ffmpeg/libavcodec/huffyuv.c b/contrib/ffmpeg/libavcodec/huffyuv.c
index 0aefd6d72..f68d8e7ef 100644
--- a/contrib/ffmpeg/libavcodec/huffyuv.c
+++ b/contrib/ffmpeg/libavcodec/huffyuv.c
@@ -206,6 +206,29 @@ static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, uint8_t *src
}
}
+static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue){
+ int i;
+ int r,g,b;
+ r= *red;
+ g= *green;
+ b= *blue;
+ for(i=0; i<FFMIN(w,4); i++){
+ const int rt= src[i*4+R];
+ const int gt= src[i*4+G];
+ const int bt= src[i*4+B];
+ dst[i*4+R]= rt - r;
+ dst[i*4+G]= gt - g;
+ dst[i*4+B]= bt - b;
+ r = rt;
+ g = gt;
+ b = bt;
+ }
+ s->dsp.diff_bytes(dst+16, src+16, src+12, w*4-16);
+ *red= src[(w-1)*4+R];
+ *green= src[(w-1)*4+G];
+ *blue= src[(w-1)*4+B];
+}
+
static void read_len_table(uint8_t *dst, GetBitContext *gb){
int i, val, repeat;
@@ -360,7 +383,9 @@ static void alloc_temp(HYuvContext *s){
s->temp[i]= av_malloc(s->width + 16);
}
}else{
- s->temp[0]= av_malloc(4*s->width + 16);
+ for(i=0; i<2; i++){
+ s->temp[i]= av_malloc(4*s->width + 16);
+ }
}
}
@@ -452,7 +477,7 @@ s->bgr32=1;
break;
case 16:
if(s->yuy2){
- avctx->pix_fmt = PIX_FMT_YUV422;
+ avctx->pix_fmt = PIX_FMT_YUYV422;
}else{
avctx->pix_fmt = PIX_FMT_YUV422P;
}
@@ -460,7 +485,7 @@ s->bgr32=1;
case 24:
case 32:
if(s->bgr32){
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
}else{
avctx->pix_fmt = PIX_FMT_BGR24;
}
@@ -521,6 +546,9 @@ static int encode_init(AVCodecContext *avctx)
case PIX_FMT_YUV422P:
s->bitstream_bpp= 16;
break;
+ case PIX_FMT_RGB32:
+ s->bitstream_bpp= 24;
+ break;
default:
av_log(avctx, AV_LOG_ERROR, "format not supported\n");
return -1;
@@ -550,7 +578,12 @@ static int encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_INFO, "using huffyuv 2.2.0 or newer interlacing flag\n");
}
- ((uint8_t*)avctx->extradata)[0]= s->predictor;
+ if(s->bitstream_bpp>=24 && s->predictor==MEDIAN){
+ av_log(avctx, AV_LOG_ERROR, "Error: RGB is incompatible with median predictor\n");
+ return -1;
+ }
+
+ ((uint8_t*)avctx->extradata)[0]= s->predictor | (s->decorrelate << 6);
((uint8_t*)avctx->extradata)[1]= s->bitstream_bpp;
((uint8_t*)avctx->extradata)[2]= s->interlaced ? 0x10 : 0x20;
if(s->context)
@@ -758,6 +791,48 @@ static void decode_bgr_bitstream(HYuvContext *s, int count){
}
}
+static int encode_bgr_bitstream(HYuvContext *s, int count){
+ int i;
+
+ if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 3*4*count){
+ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
+ return -1;
+ }
+
+ if((s->flags&CODEC_FLAG_PASS1) && (s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT)){
+ for(i=0; i<count; i++){
+ int g= s->temp[0][4*i+G];
+ int b= (s->temp[0][4*i+B] - g) & 0xff;
+ int r= (s->temp[0][4*i+R] - g) & 0xff;
+ s->stats[0][b]++;
+ s->stats[1][g]++;
+ s->stats[2][r]++;
+ }
+ }else if(s->context || (s->flags&CODEC_FLAG_PASS1)){
+ for(i=0; i<count; i++){
+ int g= s->temp[0][4*i+G];
+ int b= (s->temp[0][4*i+B] - g) & 0xff;
+ int r= (s->temp[0][4*i+R] - g) & 0xff;
+ s->stats[0][b]++;
+ s->stats[1][g]++;
+ s->stats[2][r]++;
+ put_bits(&s->pb, s->len[1][g], s->bits[1][g]);
+ put_bits(&s->pb, s->len[0][b], s->bits[0][b]);
+ put_bits(&s->pb, s->len[2][r], s->bits[2][r]);
+ }
+ }else{
+ for(i=0; i<count; i++){
+ int g= s->temp[0][4*i+G];
+ int b= (s->temp[0][4*i+B] - g) & 0xff;
+ int r= (s->temp[0][4*i+R] - g) & 0xff;
+ put_bits(&s->pb, s->len[1][g], s->bits[1][g]);
+ put_bits(&s->pb, s->len[0][b], s->bits[0][b]);
+ put_bits(&s->pb, s->len[2][r], s->bits[2][r]);
+ }
+ }
+ return 0;
+}
+
#ifdef CONFIG_DECODERS
static void draw_slice(HYuvContext *s, int y){
int h, cy;
@@ -1189,6 +1264,31 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
encode_422_bitstream(s, width);
}
}
+ }else if(avctx->pix_fmt == PIX_FMT_RGB32){
+ uint8_t *data = p->data[0] + (height-1)*p->linesize[0];
+ const int stride = -p->linesize[0];
+ const int fake_stride = -fake_ystride;
+ int y;
+ int leftr, leftg, leftb;
+
+ put_bits(&s->pb, 8, leftr= data[R]);
+ put_bits(&s->pb, 8, leftg= data[G]);
+ put_bits(&s->pb, 8, leftb= data[B]);
+ put_bits(&s->pb, 8, 0);
+
+ sub_left_prediction_bgr32(s, s->temp[0], data+4, width-1, &leftr, &leftg, &leftb);
+ encode_bgr_bitstream(s, width-1);
+
+ for(y=1; y<s->height; y++){
+ uint8_t *dst = data + y*stride;
+ if(s->predictor == PLANE && s->interlaced < y){
+ s->dsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width*4);
+ sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width, &leftr, &leftg, &leftb);
+ }else{
+ sub_left_prediction_bgr32(s, s->temp[0], dst, width, &leftr, &leftg, &leftb);
+ }
+ encode_bgr_bitstream(s, width);
+ }
}else{
av_log(avctx, AV_LOG_ERROR, "Format not supported!\n");
}
@@ -1273,7 +1373,7 @@ AVCodec huffyuv_encoder = {
encode_init,
encode_frame,
encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV422P, -1},
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB32, -1},
};
AVCodec ffvhuff_encoder = {
@@ -1284,7 +1384,7 @@ AVCodec ffvhuff_encoder = {
encode_init,
encode_frame,
encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, -1},
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB32, -1},
};
#endif //CONFIG_ENCODERS
diff --git a/contrib/ffmpeg/libavcodec/i386/cputest.c b/contrib/ffmpeg/libavcodec/i386/cputest.c
index 262786b71..0705ab3e5 100644
--- a/contrib/ffmpeg/libavcodec/i386/cputest.c
+++ b/contrib/ffmpeg/libavcodec/i386/cputest.c
@@ -87,6 +87,8 @@ int mm_support(void)
rval |= MM_SSE2;
if (ecx & 1)
rval |= MM_SSE3;
+ if (ecx & 0x00000200 )
+ rval |= MM_SSSE3;
}
cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
@@ -104,11 +106,13 @@ int mm_support(void)
}
#if 0
- av_log(NULL, AV_LOG_DEBUG, "%s%s%s%s%s%s\n",
+ av_log(NULL, AV_LOG_DEBUG, "%s%s%s%s%s%s%s%s\n",
(rval&MM_MMX) ? "MMX ":"",
(rval&MM_MMXEXT) ? "MMX2 ":"",
(rval&MM_SSE) ? "SSE ":"",
(rval&MM_SSE2) ? "SSE2 ":"",
+ (rval&MM_SSE3) ? "SSE3 ":"",
+ (rval&MM_SSSE3) ? "SSSE3 ":"",
(rval&MM_3DNOW) ? "3DNow ":"",
(rval&MM_3DNOWEXT) ? "3DNowExt ":"");
#endif
diff --git a/contrib/ffmpeg/libavcodec/i386/dsputil_h264_template_mmx.c b/contrib/ffmpeg/libavcodec/i386/dsputil_h264_template_mmx.c
index e09a1007e..a943a0371 100644
--- a/contrib/ffmpeg/libavcodec/i386/dsputil_h264_template_mmx.c
+++ b/contrib/ffmpeg/libavcodec/i386/dsputil_h264_template_mmx.c
@@ -184,91 +184,78 @@ static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*
static void H264_CHROMA_MC4_TMPL(uint8_t *dst/*align 4*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
{
- DECLARE_ALIGNED_8(uint64_t, AA);
- DECLARE_ALIGNED_8(uint64_t, DD);
- int i;
-
- /* no special case for mv=(0,0) in 4x*, since it's much less common than in 8x*.
- * could still save a few cycles, but maybe not worth the complexity. */
-
- assert(x<8 && y<8 && x>=0 && y>=0);
-
- 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..3], mm1 = src[1..4] */
- "movd %0, %%mm0\n\t"
- "movd %1, %%mm1\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "punpcklbw %%mm7, %%mm1\n\t"
- : : "m" (src[0]), "m" (src[1]));
-
- for(i=0; i<h; i++) {
- asm volatile(
- /* mm2 = A * src[0..3] + B * src[1..4] */
- "movq %%mm0, %%mm2\n\t"
- "pmullw %0, %%mm2\n\t"
- "pmullw %%mm5, %%mm1\n\t"
- "paddw %%mm1, %%mm2\n\t"
- : : "m" (AA));
-
- src += stride;
- asm volatile(
- /* mm0 = src[0..3], mm1 = src[1..4] */
- "movd %0, %%mm0\n\t"
- "movd %1, %%mm1\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "punpcklbw %%mm7, %%mm1\n\t"
- : : "m" (src[0]), "m" (src[1]));
-
- asm volatile(
- /* mm2 += C * src[0..3] + D * src[1..4] */
- "movq %%mm0, %%mm3\n\t"
- "movq %%mm1, %%mm4\n\t"
- "pmullw %%mm6, %%mm3\n\t"
- "pmullw %0, %%mm4\n\t"
- "paddw %%mm3, %%mm2\n\t"
- "paddw %%mm4, %%mm2\n\t"
- : : "m" (DD));
-
- asm volatile(
- /* dst[0..3] = pack((mm2 + 32) >> 6) */
- "paddw %1, %%mm2\n\t"
- "psrlw $6, %%mm2\n\t"
- "packuswb %%mm7, %%mm2\n\t"
- H264_CHROMA_OP4(%0, %%mm2, %%mm3)
- "movd %%mm2, %0\n\t"
- : "=m" (dst[0]) : "m" (ff_pw_32));
- dst += stride;
- }
+ "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"((long)stride), "m"(ff_pw_32), "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)
+static void H264_CHROMA_MC2_TMPL(uint8_t *dst/*align 2*/, uint8_t *src/*align 1*/, long stride, int h, int x, int y)
{
- int CD=((1<<16)-1)*x*y + 8*y;
- int AB=((8<<16)-8)*x + 64 - CD;
- int i;
-
+ 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} */
@@ -277,50 +264,42 @@ static void H264_CHROMA_MC2_TMPL(uint8_t *dst/*align 2*/, uint8_t *src/*align 1*
"punpckldq %%mm5, %%mm5\n\t"
"punpckldq %%mm6, %%mm6\n\t"
"pxor %%mm7, %%mm7\n\t"
- :: "r"(AB), "r"(CD));
+ /* 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 %0, %%mm0\n\t"
+ "movd (%1), %%mm0\n\t"
"punpcklbw %%mm7, %%mm0\n\t"
"pshufw $0x94, %%mm0, %%mm0\n\t"
- :: "m"(src[0]));
+ /* 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"(stride)
+ : "%esi");
- for(i=0; i<h; i++) {
- asm volatile(
- /* mm1 = A * src[0,1] + B * src[1,2] */
- "movq %%mm0, %%mm1\n\t"
- "pmaddwd %%mm5, %%mm1\n\t"
- ::);
-
- src += stride;
- asm volatile(
- /* mm0 = src[0,1,1,2] */
- "movd %0, %%mm0\n\t"
- "punpcklbw %%mm7, %%mm0\n\t"
- "pshufw $0x94, %%mm0, %%mm0\n\t"
- :: "m"(src[0]));
-
- asm volatile(
- /* mm1 += C * src[0,1] + D * src[1,2] */
- "movq %%mm0, %%mm2\n\t"
- "pmaddwd %%mm6, %%mm2\n\t"
- "paddw %%mm2, %%mm1\n\t"
- ::);
-
- asm volatile(
- /* dst[0,1] = pack((mm1 + 32) >> 6) */
- "paddw %1, %%mm1\n\t"
- "psrlw $6, %%mm1\n\t"
- "packssdw %%mm7, %%mm1\n\t"
- "packuswb %%mm7, %%mm1\n\t"
- /* writes garbage to the right of dst.
- * ok because partitions are processed from left to right. */
- H264_CHROMA_OP4(%0, %%mm1, %%mm3)
- "movd %%mm1, %0\n\t"
- : "=m" (dst[0]) : "m" (ff_pw_32));
- dst += stride;
- }
}
#endif
diff --git a/contrib/ffmpeg/libavcodec/i386/dsputil_mmx.c b/contrib/ffmpeg/libavcodec/i386/dsputil_mmx.c
index 5675828a4..23a717acd 100644
--- a/contrib/ffmpeg/libavcodec/i386/dsputil_mmx.c
+++ b/contrib/ffmpeg/libavcodec/i386/dsputil_mmx.c
@@ -1730,6 +1730,38 @@ static int hadamard8_diff_mmx2(void *s, uint8_t *src1, uint8_t *src2, int stride
WARPER8_16_SQ(hadamard8_diff_mmx, hadamard8_diff16_mmx)
WARPER8_16_SQ(hadamard8_diff_mmx2, hadamard8_diff16_mmx2)
+
+static int ssd_int8_vs_int16_mmx(int8_t *pix1, int16_t *pix2, int size){
+ int sum;
+ long i=size;
+ asm volatile(
+ "pxor %%mm4, %%mm4 \n"
+ "1: \n"
+ "sub $8, %0 \n"
+ "movq (%2,%0), %%mm2 \n"
+ "movq (%3,%0,2), %%mm0 \n"
+ "movq 8(%3,%0,2), %%mm1 \n"
+ "punpckhbw %%mm2, %%mm3 \n"
+ "punpcklbw %%mm2, %%mm2 \n"
+ "psraw $8, %%mm3 \n"
+ "psraw $8, %%mm2 \n"
+ "psubw %%mm3, %%mm1 \n"
+ "psubw %%mm2, %%mm0 \n"
+ "pmaddwd %%mm1, %%mm1 \n"
+ "pmaddwd %%mm0, %%mm0 \n"
+ "paddd %%mm1, %%mm4 \n"
+ "paddd %%mm0, %%mm4 \n"
+ "jg 1b \n"
+ "movq %%mm4, %%mm3 \n"
+ "psrlq $32, %%mm3 \n"
+ "paddd %%mm3, %%mm4 \n"
+ "movd %%mm4, %1 \n"
+ :"+r"(i), "=r"(sum)
+ :"r"(pix1), "r"(pix2)
+ );
+ return sum;
+}
+
#endif //CONFIG_ENCODERS
#define put_no_rnd_pixels8_mmx(a,b,c,d) put_pixels8_mmx(a,b,c,d)
@@ -3037,14 +3069,14 @@ static void float_to_int16_sse(int16_t *dst, const float *src, int len){
asm volatile("emms");
}
-#ifdef CONFIG_SNOW_ENCODER
+#ifdef CONFIG_SNOW_DECODER
extern void ff_snow_horizontal_compose97i_sse2(DWTELEM *b, int width);
extern void ff_snow_horizontal_compose97i_mmx(DWTELEM *b, int width);
extern void ff_snow_vertical_compose97i_sse2(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width);
extern void ff_snow_vertical_compose97i_mmx(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width);
-extern void ff_snow_inner_add_yblock_sse2(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
+extern void ff_snow_inner_add_yblock_sse2(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
-extern void ff_snow_inner_add_yblock_mmx(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
+extern void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
#endif
@@ -3215,6 +3247,8 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
}
c->add_8x8basis= add_8x8basis_mmx;
+ c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
+
#endif //CONFIG_ENCODERS
c->h263_v_loop_filter= h263_v_loop_filter_mmx;
@@ -3462,7 +3496,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
}
-#ifdef CONFIG_SNOW_ENCODER
+#ifdef CONFIG_SNOW_DECODER
if(mm_flags & MM_SSE2){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;
c->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
diff --git a/contrib/ffmpeg/libavcodec/i386/fdct_mmx.c b/contrib/ffmpeg/libavcodec/i386/fdct_mmx.c
index 2ffbfecf6..7e2682a4a 100644
--- a/contrib/ffmpeg/libavcodec/i386/fdct_mmx.c
+++ b/contrib/ffmpeg/libavcodec/i386/fdct_mmx.c
@@ -284,7 +284,7 @@ TABLE_SSE2
}};
-static always_inline void fdct_col(const int16_t *in, int16_t *out, int offset)
+static av_always_inline void fdct_col(const int16_t *in, int16_t *out, int offset)
{
movq_m2r(*(in + offset + 1 * 8), mm0);
movq_m2r(*(in + offset + 6 * 8), mm1);
@@ -364,7 +364,7 @@ static always_inline void fdct_col(const int16_t *in, int16_t *out, int offset)
}
-static always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
+static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
{
asm volatile(
#define FDCT_ROW_SSE2_H1(i,t) \
@@ -426,7 +426,7 @@ static always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
);
}
-static always_inline void fdct_row_mmx2(const int16_t *in, int16_t *out, const int16_t *table)
+static av_always_inline void fdct_row_mmx2(const int16_t *in, int16_t *out, const int16_t *table)
{
pshufw_m2r(*(in + 4), mm5, 0x1B);
movq_m2r(*(in + 0), mm0);
@@ -469,7 +469,7 @@ static always_inline void fdct_row_mmx2(const int16_t *in, int16_t *out, const i
movq_r2m(mm7, *(out + 4));
}
-static always_inline void fdct_row_mmx(const int16_t *in, int16_t *out, const int16_t *table)
+static av_always_inline void fdct_row_mmx(const int16_t *in, int16_t *out, const int16_t *table)
{
//FIXME reorder (i dont have a old mmx only cpu here to benchmark ...)
movd_m2r(*(in + 6), mm1);
diff --git a/contrib/ffmpeg/libavcodec/i386/h264dsp_mmx.c b/contrib/ffmpeg/libavcodec/i386/h264dsp_mmx.c
index 40baf199b..56004b674 100644
--- a/contrib/ffmpeg/libavcodec/i386/h264dsp_mmx.c
+++ b/contrib/ffmpeg/libavcodec/i386/h264dsp_mmx.c
@@ -684,7 +684,7 @@ static void h264_loop_filter_strength_mmx2( int16_t bS[2][4][4], uint8_t nnz[40]
"movq %%mm6, "#OF"(%1) \n\t"
#define QPEL_H264(OPNAME, OP, MMX)\
-static void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+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(\
@@ -724,7 +724,7 @@ static void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, i
: "memory"\
);\
}\
-static void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+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"\
@@ -768,7 +768,7 @@ static void OPNAME ## h264_qpel4_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src
);\
}while(--h);\
}\
-static void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+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"\
@@ -797,7 +797,7 @@ static void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, i
: "memory"\
);\
}\
-static void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
+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;\
@@ -861,7 +861,7 @@ static void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp,
);\
}\
\
-static void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+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"\
@@ -918,7 +918,7 @@ static void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, i
);\
}\
\
-static void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+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"\
@@ -981,7 +981,7 @@ static void OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src
}while(--h);\
}\
\
-static inline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int 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;\
\
@@ -1036,7 +1036,7 @@ static inline void OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint
dst += 4-h*dstStride;\
}\
}\
-static inline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
+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){\
int h = size;\
int w = (size+8)>>2;\
src -= 2*srcStride+2;\
@@ -1141,12 +1141,12 @@ static inline void OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int
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 void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
+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){\
+static av_noinline 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;\
@@ -1155,7 +1155,7 @@ static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src,
OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
}\
\
-static void OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
+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;\
@@ -1173,7 +1173,7 @@ static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp,
OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\
}\
\
-static void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
+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 %5, %%mm6 \n\t"\
@@ -1207,7 +1207,7 @@ static void OPNAME ## pixels4_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, ui
:"S"((long)src8Stride), "D"((long)dstStride), "m"(ff_pw_16)\
:"memory");\
}\
-static void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
+static av_noinline void OPNAME ## pixels8_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
{\
asm volatile(\
"movq %0, %%mm6 \n\t"\
@@ -1311,6 +1311,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *
uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\
uint8_t * const halfHV= (uint8_t*)temp;\
int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE/2;\
+ assert((int)temp & 7 == 0);\
put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\
OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\
}\
@@ -1319,6 +1320,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *
uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\
uint8_t * const halfHV= (uint8_t*)temp;\
int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE/2;\
+ assert((int)temp & 7 == 0);\
put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\
OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\
}\
@@ -1327,6 +1329,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *
uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\
int16_t * const halfV= ((int16_t*)temp) + SIZE*SIZE/2;\
uint8_t * const halfHV= ((uint8_t*)temp);\
+ 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);\
}\
@@ -1335,6 +1338,7 @@ static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *
uint64_t temp[SIZE*(SIZE<8?12:24)/4 + SIZE*SIZE/8];\
int16_t * const halfV= ((int16_t*)temp) + SIZE*SIZE/2;\
uint8_t * const halfHV= ((uint8_t*)temp);\
+ 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);\
}\
diff --git a/contrib/ffmpeg/libavcodec/i386/idct_mmx.c b/contrib/ffmpeg/libavcodec/i386/idct_mmx.c
index ba595845a..4c548fdce 100644
--- a/contrib/ffmpeg/libavcodec/i386/idct_mmx.c
+++ b/contrib/ffmpeg/libavcodec/i386/idct_mmx.c
@@ -15,7 +15,7 @@
* 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
+ * along with mpeg2dec; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
diff --git a/contrib/ffmpeg/libavcodec/i386/idct_mmx_xvid.c b/contrib/ffmpeg/libavcodec/i386/idct_mmx_xvid.c
index 43eb329cc..85cfbc9cd 100644
--- a/contrib/ffmpeg/libavcodec/i386/idct_mmx_xvid.c
+++ b/contrib/ffmpeg/libavcodec/i386/idct_mmx_xvid.c
@@ -21,7 +21,7 @@
// * along with FFmpeg; if not, write to the Free Software Foundation,
// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// *
-// * $Id: idct_mmx_xvid.c,v 1.1.2.1 2006/12/02 01:19:55 dgp85 Exp $
+// * $Id: idct_mmx_xvid.c 6577 2006-10-07 15:30:46Z diego $
// *
// ***************************************************************************/
diff --git a/contrib/ffmpeg/libavcodec/i386/snowdsp_mmx.c b/contrib/ffmpeg/libavcodec/i386/snowdsp_mmx.c
index 718202632..8f182303d 100644
--- a/contrib/ffmpeg/libavcodec/i386/snowdsp_mmx.c
+++ b/contrib/ffmpeg/libavcodec/i386/snowdsp_mmx.c
@@ -708,7 +708,7 @@ void ff_snow_vertical_compose97i_mmx(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTE
"dec %2 \n\t"\
snow_inner_add_yblock_sse2_end_common2
-static void inner_add_yblock_bw_8_obmc_16_bh_even_sse2(uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
+static void inner_add_yblock_bw_8_obmc_16_bh_even_sse2(const uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
int src_x, int src_y, long src_stride, slice_buffer * sb, int add, uint8_t * dst8){
snow_inner_add_yblock_sse2_header
snow_inner_add_yblock_sse2_start_8("xmm1", "xmm5", "3", "0")
@@ -756,7 +756,7 @@ snow_inner_add_yblock_sse2_accum_8("0", "136")
snow_inner_add_yblock_sse2_end_8
}
-static void inner_add_yblock_bw_16_obmc_32_sse2(uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
+static void inner_add_yblock_bw_16_obmc_32_sse2(const uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
int src_x, int src_y, long src_stride, slice_buffer * sb, int add, uint8_t * dst8){
snow_inner_add_yblock_sse2_header
snow_inner_add_yblock_sse2_start_16("xmm1", "xmm5", "3", "0")
@@ -868,7 +868,7 @@ snow_inner_add_yblock_sse2_end_16
"rm"((long)(src_x<<2)),"m"(obmc),"a"(block),"m"((long)b_h),"m"((long)src_stride):\
"%"REG_c"","%"REG_S"","%"REG_D"","%"REG_d"");
-static void inner_add_yblock_bw_8_obmc_16_mmx(uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
+static void inner_add_yblock_bw_8_obmc_16_mmx(const uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
int src_x, int src_y, long src_stride, slice_buffer * sb, int add, uint8_t * dst8){
snow_inner_add_yblock_mmx_header
snow_inner_add_yblock_mmx_start("mm1", "mm5", "3", "0", "0")
@@ -879,7 +879,7 @@ snow_inner_add_yblock_mmx_mix("0", "0")
snow_inner_add_yblock_mmx_end("16")
}
-static void inner_add_yblock_bw_16_obmc_32_mmx(uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
+static void inner_add_yblock_bw_16_obmc_32_mmx(const uint8_t *obmc, const long obmc_stride, uint8_t * * block, int b_w, long b_h,
int src_x, int src_y, long src_stride, slice_buffer * sb, int add, uint8_t * dst8){
snow_inner_add_yblock_mmx_header
snow_inner_add_yblock_mmx_start("mm1", "mm5", "3", "0", "0")
@@ -896,7 +896,7 @@ snow_inner_add_yblock_mmx_mix("32", "8")
snow_inner_add_yblock_mmx_end("32")
}
-void ff_snow_inner_add_yblock_sse2(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
+void ff_snow_inner_add_yblock_sse2(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
if (b_w == 16)
@@ -910,7 +910,7 @@ void ff_snow_inner_add_yblock_sse2(uint8_t *obmc, const int obmc_stride, uint8_t
ff_snow_inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
}
-void ff_snow_inner_add_yblock_mmx(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
+void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
if (b_w == 16)
inner_add_yblock_bw_16_obmc_32_mmx(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
diff --git a/contrib/ffmpeg/libavcodec/imc.c b/contrib/ffmpeg/libavcodec/imc.c
index 7360b6409..6140130b1 100644
--- a/contrib/ffmpeg/libavcodec/imc.c
+++ b/contrib/ffmpeg/libavcodec/imc.c
@@ -347,7 +347,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 = clip((int)((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
+ cwlen = av_clip((int)((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
q->bitsBandT[j] = cwlen;
summer += q->bandWidthT[j] * cwlen;
diff --git a/contrib/ffmpeg/libavcodec/imgconvert.c b/contrib/ffmpeg/libavcodec/imgconvert.c
index d5b4cdca0..2971afaa8 100644
--- a/contrib/ffmpeg/libavcodec/imgconvert.c
+++ b/contrib/ffmpeg/libavcodec/imgconvert.c
@@ -44,24 +44,24 @@
#define xglue(x, y) x ## y
#define glue(x, y) xglue(x, y)
-#define FF_COLOR_RGB 0 /* RGB color space */
-#define FF_COLOR_GRAY 1 /* gray color space */
-#define FF_COLOR_YUV 2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
-#define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
+#define FF_COLOR_RGB 0 /**< RGB color space */
+#define FF_COLOR_GRAY 1 /**< gray color space */
+#define FF_COLOR_YUV 2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
+#define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
-#define FF_PIXEL_PLANAR 0 /* each channel has one component in AVPicture */
-#define FF_PIXEL_PACKED 1 /* only one components containing all the channels */
-#define FF_PIXEL_PALETTE 2 /* one components containing indexes for a palette */
+#define FF_PIXEL_PLANAR 0 /**< each channel has one component in AVPicture */
+#define FF_PIXEL_PACKED 1 /**< only one components containing all the channels */
+#define FF_PIXEL_PALETTE 2 /**< one components containing indexes for a palette */
typedef struct PixFmtInfo {
const char *name;
- uint8_t nb_channels; /* number of channels (including alpha) */
- uint8_t color_type; /* color type (see FF_COLOR_xxx constants) */
- uint8_t pixel_type; /* pixel storage type (see FF_PIXEL_xxx constants) */
- uint8_t is_alpha : 1; /* true if alpha can be specified */
- uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */
- uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */
- uint8_t depth; /* bit depth of the color components */
+ uint8_t nb_channels; /**< number of channels (including alpha) */
+ uint8_t color_type; /**< color type (see FF_COLOR_xxx constants) */
+ uint8_t pixel_type; /**< pixel storage type (see FF_PIXEL_xxx constants) */
+ uint8_t is_alpha : 1; /**< true if alpha can be specified */
+ uint8_t x_chroma_shift; /**< X chroma subsampling factor is 2 ^ shift */
+ uint8_t y_chroma_shift; /**< Y chroma subsampling factor is 2 ^ shift */
+ uint8_t depth; /**< bit depth of the color components */
} PixFmtInfo;
/* this table gives more information about formats */
@@ -91,8 +91,8 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.depth = 8,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_YUV422] = {
- .name = "yuv422",
+ [PIX_FMT_YUYV422] = {
+ .name = "yuyv422",
.nb_channels = 1,
.color_type = FF_COLOR_YUV,
.pixel_type = FF_PIXEL_PACKED,
@@ -167,8 +167,8 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
.depth = 8,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_RGBA32] = {
- .name = "rgba32",
+ [PIX_FMT_RGB32] = {
+ .name = "rgb32",
.nb_channels = 4, .is_alpha = 1,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
@@ -243,8 +243,8 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
[PIX_FMT_XVMC_MPEG2_IDCT] = {
.name = "xvmcidct",
},
- [PIX_FMT_UYVY411] = {
- .name = "uyvy411",
+ [PIX_FMT_UYYVYY411] = {
+ .name = "uyyvyy411",
.nb_channels = 1,
.color_type = FF_COLOR_YUV,
.pixel_type = FF_PIXEL_PACKED,
@@ -382,7 +382,6 @@ enum PixelFormat avcodec_get_pix_fmt(const char* name)
return i;
}
-/* Picture field are filled with 'ptr' addresses. Also return size */
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height)
{
@@ -432,7 +431,7 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
picture->data[2] = NULL;
picture->linesize[0] = width * 3;
return size * 3;
- case PIX_FMT_RGBA32:
+ case PIX_FMT_RGB32:
case PIX_FMT_BGR32:
case PIX_FMT_RGB32_1:
case PIX_FMT_BGR32_1:
@@ -447,7 +446,7 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
case PIX_FMT_BGR565:
case PIX_FMT_RGB555:
case PIX_FMT_RGB565:
- case PIX_FMT_YUV422:
+ case PIX_FMT_YUYV422:
picture->data[0] = ptr;
picture->data[1] = NULL;
picture->data[2] = NULL;
@@ -459,7 +458,7 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
picture->data[2] = NULL;
picture->linesize[0] = width * 2;
return size * 2;
- case PIX_FMT_UYVY411:
+ case PIX_FMT_UYYVYY411:
picture->data[0] = ptr;
picture->data[1] = NULL;
picture->data[2] = NULL;
@@ -519,14 +518,14 @@ int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
return -1;
if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
- if (pix_fmt == PIX_FMT_YUV422 ||
+ if (pix_fmt == PIX_FMT_YUYV422 ||
pix_fmt == PIX_FMT_UYVY422 ||
pix_fmt == PIX_FMT_BGR565 ||
pix_fmt == PIX_FMT_BGR555 ||
pix_fmt == PIX_FMT_RGB565 ||
pix_fmt == PIX_FMT_RGB555)
w = width * 2;
- else if (pix_fmt == PIX_FMT_UYVY411)
+ else if (pix_fmt == PIX_FMT_UYYVYY411)
w = width + width/2;
else if (pix_fmt == PIX_FMT_PAL8)
w = width;
@@ -566,9 +565,6 @@ int avpicture_get_size(int pix_fmt, int width, int height)
return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
}
-/**
- * compute the loss when converting from a pixel format to another
- */
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
int has_alpha)
{
@@ -633,7 +629,7 @@ static int avg_bits_per_pixel(int pix_fmt)
switch(pf->pixel_type) {
case FF_PIXEL_PACKED:
switch(pix_fmt) {
- case PIX_FMT_YUV422:
+ case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_RGB565:
case PIX_FMT_RGB555:
@@ -641,7 +637,7 @@ static int avg_bits_per_pixel(int pix_fmt)
case PIX_FMT_BGR555:
bits = 16;
break;
- case PIX_FMT_UYVY411:
+ case PIX_FMT_UYYVYY411:
bits = 12;
break;
default:
@@ -692,9 +688,6 @@ static int avcodec_find_best_pix_fmt1(int pix_fmt_mask,
return dst_pix_fmt;
}
-/**
- * find best pixel format to convert to. Return -1 if none found
- */
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
int has_alpha, int *loss_ptr)
{
@@ -740,10 +733,7 @@ void ff_img_copy_plane(uint8_t *dst, int dst_wrap,
}
}
-/**
- * Copy image 'src' to 'dst'.
- */
-void img_copy(AVPicture *dst, const AVPicture *src,
+void av_picture_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int bwidth, bits, i;
@@ -753,7 +743,7 @@ void img_copy(AVPicture *dst, const AVPicture *src,
switch(pf->pixel_type) {
case FF_PIXEL_PACKED:
switch(pix_fmt) {
- case PIX_FMT_YUV422:
+ case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_RGB565:
case PIX_FMT_RGB555:
@@ -761,7 +751,7 @@ void img_copy(AVPicture *dst, const AVPicture *src,
case PIX_FMT_BGR555:
bits = 16;
break;
- case PIX_FMT_UYVY411:
+ case PIX_FMT_UYYVYY411:
bits = 12;
break;
default:
@@ -802,7 +792,7 @@ void img_copy(AVPicture *dst, const AVPicture *src,
/* XXX: totally non optimized */
-static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
+static void yuyv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@@ -950,7 +940,7 @@ static void uyvy422_to_yuv422p(AVPicture *dst, const AVPicture *src,
}
-static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
+static void yuyv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@@ -983,7 +973,7 @@ static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
}
}
-static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src,
+static void yuv422p_to_yuyv422(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *p, *p1;
@@ -1049,7 +1039,7 @@ static void yuv422p_to_uyvy422(AVPicture *dst, const AVPicture *src,
}
}
-static void uyvy411_to_yuv411p(AVPicture *dst, const AVPicture *src,
+static void uyyvyy411_to_yuv411p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@@ -1085,7 +1075,7 @@ static void uyvy411_to_yuv411p(AVPicture *dst, const AVPicture *src,
}
-static void yuv420p_to_yuv422(AVPicture *dst, const AVPicture *src,
+static void yuv420p_to_yuyv422(AVPicture *dst, const AVPicture *src,
int width, int height)
{
int w, h;
@@ -1709,10 +1699,10 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
#include "imgconvert_template.h"
-/* rgba32 handling */
+/* rgb32 handling */
-#define RGB_NAME rgba32
-#define FMT_RGBA32
+#define RGB_NAME rgb32
+#define FMT_RGB32
#define RGB_IN(r, g, b, s)\
{\
@@ -1931,7 +1921,7 @@ typedef struct ConvertEntry {
- all FF_COLOR_GRAY formats must convert to and from PIX_FMT_GRAY8
- - all FF_COLOR_RGB formats with alpha must convert to and from PIX_FMT_RGBA32
+ - all FF_COLOR_RGB formats with alpha must convert to and from PIX_FMT_RGB32
- PIX_FMT_YUV444P and PIX_FMT_YUVJ444P must convert to and from
PIX_FMT_RGB24.
@@ -1942,8 +1932,8 @@ typedef struct ConvertEntry {
*/
static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_YUV420P] = {
- [PIX_FMT_YUV422] = {
- .convert = yuv420p_to_yuv422,
+ [PIX_FMT_YUYV422] = {
+ .convert = yuv420p_to_yuyv422,
},
[PIX_FMT_RGB555] = {
.convert = yuv420p_to_rgb555
@@ -1957,16 +1947,16 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_RGB24] = {
.convert = yuv420p_to_rgb24
},
- [PIX_FMT_RGBA32] = {
- .convert = yuv420p_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = yuv420p_to_rgb32
},
[PIX_FMT_UYVY422] = {
.convert = yuv420p_to_uyvy422,
},
},
[PIX_FMT_YUV422P] = {
- [PIX_FMT_YUV422] = {
- .convert = yuv422p_to_yuv422,
+ [PIX_FMT_YUYV422] = {
+ .convert = yuv422p_to_yuyv422,
},
[PIX_FMT_UYVY422] = {
.convert = yuv422p_to_uyvy422,
@@ -1990,8 +1980,8 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_RGB24] = {
.convert = yuvj420p_to_rgb24
},
- [PIX_FMT_RGBA32] = {
- .convert = yuvj420p_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = yuvj420p_to_rgb32
},
},
[PIX_FMT_YUVJ444P] = {
@@ -1999,12 +1989,12 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
.convert = yuvj444p_to_rgb24
},
},
- [PIX_FMT_YUV422] = {
+ [PIX_FMT_YUYV422] = {
[PIX_FMT_YUV420P] = {
- .convert = yuv422_to_yuv420p,
+ .convert = yuyv422_to_yuv420p,
},
[PIX_FMT_YUV422P] = {
- .convert = yuv422_to_yuv422p,
+ .convert = yuyv422_to_yuv422p,
},
},
[PIX_FMT_UYVY422] = {
@@ -2025,8 +2015,8 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_RGB555] = {
.convert = rgb24_to_rgb555
},
- [PIX_FMT_RGBA32] = {
- .convert = rgb24_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = rgb24_to_rgb32
},
[PIX_FMT_BGR24] = {
.convert = rgb24_to_bgr24
@@ -2047,32 +2037,32 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
.convert = rgb24_to_yuvj444p
},
},
- [PIX_FMT_RGBA32] = {
+ [PIX_FMT_RGB32] = {
[PIX_FMT_RGB24] = {
- .convert = rgba32_to_rgb24
+ .convert = rgb32_to_rgb24
},
[PIX_FMT_BGR24] = {
- .convert = rgba32_to_bgr24
+ .convert = rgb32_to_bgr24
},
[PIX_FMT_RGB565] = {
- .convert = rgba32_to_rgb565
+ .convert = rgb32_to_rgb565
},
[PIX_FMT_RGB555] = {
- .convert = rgba32_to_rgb555
+ .convert = rgb32_to_rgb555
},
[PIX_FMT_PAL8] = {
- .convert = rgba32_to_pal8
+ .convert = rgb32_to_pal8
},
[PIX_FMT_YUV420P] = {
- .convert = rgba32_to_yuv420p
+ .convert = rgb32_to_yuv420p
},
[PIX_FMT_GRAY8] = {
- .convert = rgba32_to_gray
+ .convert = rgb32_to_gray
},
},
[PIX_FMT_BGR24] = {
- [PIX_FMT_RGBA32] = {
- .convert = bgr24_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = bgr24_to_rgb32
},
[PIX_FMT_RGB24] = {
.convert = bgr24_to_rgb24
@@ -2088,8 +2078,8 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_RGB24] = {
.convert = rgb555_to_rgb24
},
- [PIX_FMT_RGBA32] = {
- .convert = rgb555_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = rgb555_to_rgb32
},
[PIX_FMT_YUV420P] = {
.convert = rgb555_to_yuv420p
@@ -2099,8 +2089,8 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
},
},
[PIX_FMT_RGB565] = {
- [PIX_FMT_RGBA32] = {
- .convert = rgb565_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = rgb565_to_rgb32
},
[PIX_FMT_RGB24] = {
.convert = rgb565_to_rgb24
@@ -2141,8 +2131,8 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_BGR24] = {
.convert = gray_to_bgr24
},
- [PIX_FMT_RGBA32] = {
- .convert = gray_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = gray_to_rgb32
},
[PIX_FMT_MONOWHITE] = {
.convert = gray_to_monowhite
@@ -2180,13 +2170,13 @@ static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_RGB24] = {
.convert = pal8_to_rgb24
},
- [PIX_FMT_RGBA32] = {
- .convert = pal8_to_rgba32
+ [PIX_FMT_RGB32] = {
+ .convert = pal8_to_rgb32
},
},
- [PIX_FMT_UYVY411] = {
+ [PIX_FMT_UYYVYY411] = {
[PIX_FMT_YUV411P] = {
- .convert = uyvy411_to_yuv411p,
+ .convert = uyyvyy411_to_yuv411p,
},
},
@@ -2224,10 +2214,7 @@ static inline int is_yuv_planar(const PixFmtInfo *ps)
ps->pixel_type == FF_PIXEL_PLANAR;
}
-/**
- * Crop image top and left side
- */
-int img_crop(AVPicture *dst, const AVPicture *src,
+int av_picture_crop(AVPicture *dst, const AVPicture *src,
int pix_fmt, int top_band, int left_band)
{
int y_shift;
@@ -2249,56 +2236,87 @@ int img_crop(AVPicture *dst, const AVPicture *src,
return 0;
}
-/**
- * Pad image
- */
-int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
- int padtop, int padbottom, int padleft, int padright, int *color)
+int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
+ int pix_fmt, int padtop, int padbottom, int padleft, int padright,
+ int *color)
{
- uint8_t *optr, *iptr;
+ uint8_t *optr;
int y_shift;
int x_shift;
int yheight;
int i, y;
- if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt]))
- return -1;
+ if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB ||
+ !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1;
for (i = 0; i < 3; i++) {
x_shift = i ? pix_fmt_info[pix_fmt].x_chroma_shift : 0;
y_shift = i ? pix_fmt_info[pix_fmt].y_chroma_shift : 0;
if (padtop || padleft) {
- memset(dst->data[i], color[i], dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
+ memset(dst->data[i], color[i],
+ dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
}
- if (padleft || padright || src) {
- if (src) { /* first line */
- iptr = src->data[i];
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift);
- memcpy(optr, iptr, src->linesize[i]);
- iptr += src->linesize[i];
+ if (padleft || padright) {
+ optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+ (dst->linesize[i] - (padright >> x_shift));
+ yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
+ for (y = 0; y < yheight; y++) {
+ memset(optr, color[i], (padleft + padright) >> x_shift);
+ optr += dst->linesize[i];
}
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (dst->linesize[i] - (padright >> x_shift));
+ }
+
+ if (src) { /* first line */
+ uint8_t *iptr = src->data[i];
+ optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+ (padleft >> x_shift);
+ memcpy(optr, iptr, src->linesize[i]);
+ iptr += src->linesize[i];
+ optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+ (dst->linesize[i] - (padright >> x_shift));
yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
for (y = 0; y < yheight; y++) {
memset(optr, color[i], (padleft + padright) >> x_shift);
- if (src) {
- memcpy(optr + ((padleft + padright) >> x_shift), iptr, src->linesize[i]);
- iptr += src->linesize[i];
- }
+ memcpy(optr + ((padleft + padright) >> x_shift), iptr,
+ src->linesize[i]);
+ iptr += src->linesize[i];
optr += dst->linesize[i];
}
}
if (padbottom || padright) {
- optr = dst->data[i] + dst->linesize[i] * ((height - padbottom) >> y_shift) - (padright >> x_shift);
- memset(optr, color[i], dst->linesize[i] * (padbottom >> y_shift) + (padright >> x_shift));
+ optr = dst->data[i] + dst->linesize[i] *
+ ((height - padbottom) >> y_shift) - (padright >> x_shift);
+ memset(optr, color[i],dst->linesize[i] *
+ (padbottom >> y_shift) + (padright >> x_shift));
}
}
return 0;
}
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+void img_copy(AVPicture *dst, const AVPicture *src,
+ int pix_fmt, int width, int height)
+{
+ av_picture_copy(dst, src, pix_fmt, width, height);
+}
+
+int img_crop(AVPicture *dst, const AVPicture *src,
+ int pix_fmt, int top_band, int left_band)
+{
+ return av_picture_crop(dst, src, pix_fmt, top_band, left_band);
+}
+
+int img_pad(AVPicture *dst, const AVPicture *src, int height, int width,
+ int pix_fmt, int padtop, int padbottom, int padleft, int padright,
+ int *color)
+{
+ return av_picture_pad(dst, src, height, width, pix_fmt, padtop, padbottom, padleft, padright, color);
+}
+#endif
+
#ifndef CONFIG_SWSCALER
/* XXX: always use linesize. Return -1 if not supported */
int img_convert(AVPicture *dst, int dst_pix_fmt,
@@ -2329,7 +2347,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
src_pix = &pix_fmt_info[src_pix_fmt];
if (src_pix_fmt == dst_pix_fmt) {
/* no conversion needed: just copy */
- img_copy(dst, src, dst_pix_fmt, dst_width, dst_height);
+ av_picture_copy(dst, src, dst_pix_fmt, dst_width, dst_height);
return 0;
}
@@ -2486,16 +2504,16 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
no_chroma_filter:
/* try to use an intermediate format */
- if (src_pix_fmt == PIX_FMT_YUV422 ||
- dst_pix_fmt == PIX_FMT_YUV422) {
+ if (src_pix_fmt == PIX_FMT_YUYV422 ||
+ dst_pix_fmt == PIX_FMT_YUYV422) {
/* specific case: convert to YUV422P first */
int_pix_fmt = PIX_FMT_YUV422P;
} else if (src_pix_fmt == PIX_FMT_UYVY422 ||
dst_pix_fmt == PIX_FMT_UYVY422) {
/* specific case: convert to YUV422P first */
int_pix_fmt = PIX_FMT_YUV422P;
- } else if (src_pix_fmt == PIX_FMT_UYVY411 ||
- dst_pix_fmt == PIX_FMT_UYVY411) {
+ } else if (src_pix_fmt == PIX_FMT_UYYVYY411 ||
+ dst_pix_fmt == PIX_FMT_UYYVYY411) {
/* specific case: convert to YUV411P first */
int_pix_fmt = PIX_FMT_YUV411P;
} else if ((src_pix->color_type == FF_COLOR_GRAY &&
@@ -2523,7 +2541,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
} else {
/* the two formats are rgb or gray8 or yuv[j]444p */
if (src_pix->is_alpha && dst_pix->is_alpha)
- int_pix_fmt = PIX_FMT_RGBA32;
+ int_pix_fmt = PIX_FMT_RGB32;
else
int_pix_fmt = PIX_FMT_RGB24;
}
@@ -2569,10 +2587,6 @@ static int get_alpha_info_pal8(const AVPicture *src, int width, int height)
return ret;
}
-/**
- * Tell if an image really has transparent alpha values.
- * @return ored mask of FF_ALPHA_xxx constants
- */
int img_get_alpha_info(const AVPicture *src,
int pix_fmt, int width, int height)
{
@@ -2584,8 +2598,8 @@ int img_get_alpha_info(const AVPicture *src,
if (!pf->is_alpha)
return 0;
switch(pix_fmt) {
- case PIX_FMT_RGBA32:
- ret = get_alpha_info_rgba32(src, width, height);
+ case PIX_FMT_RGB32:
+ ret = get_alpha_info_rgb32(src, width, height);
break;
case PIX_FMT_PAL8:
ret = get_alpha_info_pal8(src, width, height);
@@ -2792,8 +2806,6 @@ static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
av_free(buf);
}
-
-/* deinterlace - if not supported return -1 */
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
diff --git a/contrib/ffmpeg/libavcodec/imgconvert_template.h b/contrib/ffmpeg/libavcodec/imgconvert_template.h
index 4cc898bab..70c090bad 100644
--- a/contrib/ffmpeg/libavcodec/imgconvert_template.h
+++ b/contrib/ffmpeg/libavcodec/imgconvert_template.h
@@ -411,10 +411,10 @@ static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
}
// RGB24 has optimised routines
-#if !defined(FMT_RGBA32) && !defined(FMT_RGB24)
+#if !defined(FMT_RGB32) && !defined(FMT_RGB24)
/* alpha support */
-static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
+static void glue(rgb32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@@ -451,7 +451,7 @@ static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
}
}
-static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
+static void glue(RGB_NAME, _to_rgb32)(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *s;
@@ -485,7 +485,7 @@ static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
}
}
-#endif /* !defined(FMT_RGBA32) */
+#endif /* !defined(FMT_RGB32) */
#ifndef FMT_RGB24
@@ -788,7 +788,7 @@ static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
#endif /* FMT_RGB24 */
-#if defined(FMT_RGB24) || defined(FMT_RGBA32)
+#if defined(FMT_RGB24) || defined(FMT_RGB32)
static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
int width, int height)
@@ -834,7 +834,7 @@ static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
build_rgb_palette(dst->data[1], has_alpha);
}
-#endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */
+#endif /* defined(FMT_RGB24) || defined(FMT_RGB32) */
#ifdef RGBA_IN
@@ -872,4 +872,4 @@ static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
#undef BPP
#undef RGB_NAME
#undef FMT_RGB24
-#undef FMT_RGBA32
+#undef FMT_RGB32
diff --git a/contrib/ffmpeg/libavcodec/imgresample.c b/contrib/ffmpeg/libavcodec/imgresample.c
index ce1a05ce4..2722d5acf 100644
--- a/contrib/ffmpeg/libavcodec/imgresample.c
+++ b/contrib/ffmpeg/libavcodec/imgresample.c
@@ -672,6 +672,8 @@ struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
void sws_freeContext(struct SwsContext *ctx)
{
+ if (!ctx)
+ return;
if ((ctx->resampling_ctx->iwidth != ctx->resampling_ctx->owidth) ||
(ctx->resampling_ctx->iheight != ctx->resampling_ctx->oheight)) {
img_resample_close(ctx->resampling_ctx);
@@ -800,7 +802,7 @@ int sws_scale(struct SwsContext *ctx, uint8_t* src[], int srcStride[],
goto the_end;
}
} else if (resampled_picture != &dst_pict) {
- img_copy(&dst_pict, resampled_picture, current_pix_fmt,
+ av_picture_copy(&dst_pict, resampled_picture, current_pix_fmt,
ctx->resampling_ctx->owidth, ctx->resampling_ctx->oheight);
}
diff --git a/contrib/ffmpeg/libavcodec/indeo2.c b/contrib/ffmpeg/libavcodec/indeo2.c
index f3917ff3a..2b129d141 100644
--- a/contrib/ffmpeg/libavcodec/indeo2.c
+++ b/contrib/ffmpeg/libavcodec/indeo2.c
@@ -87,11 +87,11 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst
}
} else { /* add two deltas from table */
t = dst[out - stride] + (table[c * 2] - 128);
- t= clip_uint8(t);
+ t= av_clip_uint8(t);
dst[out] = t;
out++;
t = dst[out - stride] + (table[(c * 2) + 1] - 128);
- t= clip_uint8(t);
+ t= av_clip_uint8(t);
dst[out] = t;
out++;
}
@@ -121,11 +121,11 @@ static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_
out += c * 2;
} else { /* add two deltas from table */
t = dst[out] + (((table[c * 2] - 128)*3) >> 2);
- t= clip_uint8(t);
+ t= av_clip_uint8(t);
dst[out] = t;
out++;
t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2);
- t= clip_uint8(t);
+ t= av_clip_uint8(t);
dst[out] = t;
out++;
}
diff --git a/contrib/ffmpeg/libavcodec/indeo3.c b/contrib/ffmpeg/libavcodec/indeo3.c
index 33dcff820..1b1914406 100644
--- a/contrib/ffmpeg/libavcodec/indeo3.c
+++ b/contrib/ffmpeg/libavcodec/indeo3.c
@@ -97,10 +97,6 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, unsigned char *cur,
long fflags2, unsigned char *hdr,
unsigned char *buf2, int min_width_160);
-#ifndef min
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
/* ---------------------------------------------------------------------- */
static void iv_alloc_frames(Indeo3DecodeContext *s)
{
@@ -230,7 +226,7 @@ static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width,
hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
- min(hdr_width, 160));
+ FFMIN(hdr_width, 160));
if (!(s->avctx->flags & CODEC_FLAG_GRAY))
{
@@ -241,7 +237,7 @@ static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
- min(chroma_width, 40));
+ FFMIN(chroma_width, 40));
buf_pos = buf + 16 + offs3;
offs = le2me_32(*(uint32_t *)buf_pos);
@@ -249,7 +245,7 @@ static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
- min(chroma_width, 40));
+ FFMIN(chroma_width, 40));
}
diff --git a/contrib/ffmpeg/libavcodec/jfdctfst.c b/contrib/ffmpeg/libavcodec/jfdctfst.c
index 38424563d..a9dcfab82 100644
--- a/contrib/ffmpeg/libavcodec/jfdctfst.c
+++ b/contrib/ffmpeg/libavcodec/jfdctfst.c
@@ -145,7 +145,7 @@
#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
-static always_inline void row_fdct(DCTELEM * data){
+static av_always_inline void row_fdct(DCTELEM * data){
int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int_fast16_t tmp10, tmp11, tmp12, tmp13;
int_fast16_t z1, z2, z3, z4, z5, z11, z13;
diff --git a/contrib/ffmpeg/libavcodec/jfdctint.c b/contrib/ffmpeg/libavcodec/jfdctint.c
index 58f3a1446..250312467 100644
--- a/contrib/ffmpeg/libavcodec/jfdctint.c
+++ b/contrib/ffmpeg/libavcodec/jfdctint.c
@@ -181,7 +181,7 @@
#endif
-static always_inline void row_fdct(DCTELEM * data){
+static av_always_inline void row_fdct(DCTELEM * data){
int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int_fast32_t tmp10, tmp11, tmp12, tmp13;
int_fast32_t z1, z2, z3, z4, z5;
diff --git a/contrib/ffmpeg/libavcodec/jpeg_ls.c b/contrib/ffmpeg/libavcodec/jpeg_ls.c
index 1b4df2b1a..136e3fb80 100644
--- a/contrib/ffmpeg/libavcodec/jpeg_ls.c
+++ b/contrib/ffmpeg/libavcodec/jpeg_ls.c
@@ -366,10 +366,10 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void *
}
if(sign){
- pred = clip(pred - state->C[context], 0, state->maxval);
+ pred = av_clip(pred - state->C[context], 0, state->maxval);
err = -ls_get_code_regular(&s->gb, state, context);
} else {
- pred = clip(pred + state->C[context], 0, state->maxval);
+ pred = av_clip(pred + state->C[context], 0, state->maxval);
err = ls_get_code_regular(&s->gb, state, context);
}
@@ -381,7 +381,7 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void *
pred += state->range * state->twonear;
else if(pred > state->maxval + state->near)
pred -= state->range * state->twonear;
- pred = clip(pred, 0, state->maxval);
+ pred = av_clip(pred, 0, state->maxval);
}
pred &= state->maxval;
@@ -480,7 +480,7 @@ static int ls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor
src += s->picture.linesize[0];
}
}else{
- uint16_t *src = s->picture.data[0];
+ uint16_t *src = (uint16_t*) s->picture.data[0];
for(i = 0; i < s->height; i++){
for(x = 0; x < w; x++){
@@ -623,9 +623,9 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last
err = -(state->near - err) / state->twonear;
if(RItype || (Rb >= Ra))
- Ra = clip(pred + err * state->twonear, 0, state->maxval);
+ Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
else
- Ra = clip(pred - err * state->twonear, 0, state->maxval);
+ Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
W(cur, x, Ra);
}
if(err < 0)
@@ -646,11 +646,11 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last
if(context < 0){
context = -context;
sign = 1;
- pred = clip(pred - state->C[context], 0, state->maxval);
+ pred = av_clip(pred - state->C[context], 0, state->maxval);
err = pred - R(cur, x);
}else{
sign = 0;
- pred = clip(pred + state->C[context], 0, state->maxval);
+ pred = av_clip(pred + state->C[context], 0, state->maxval);
err = R(cur, x) - pred;
}
@@ -660,9 +660,9 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last
else
err = -(state->near - err) / state->twonear;
if(!sign)
- Ra = clip(pred + err * state->twonear, 0, state->maxval);
+ Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
else
- Ra = clip(pred - err * state->twonear, 0, state->maxval);
+ Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
W(cur, x, Ra);
}
@@ -804,11 +804,16 @@ static int encode_picture_ls(AVCodecContext *avctx, unsigned char *buf, int buf_
av_free(zero);
av_free(state);
+ // the specification says that after doing 0xff escaping unused bits in the
+ // last byte must be set to 0, so just append 7 "optional" zero-bits to
+ // avoid special-casing.
+ put_bits(&pb2, 7, 0);
+ size = put_bits_count(&pb2);
flush_put_bits(&pb2);
/* do escape coding */
- size = put_bits_count(&pb2) >> 3;
init_get_bits(&gb, buf2, size);
- while(get_bits_count(&gb) < size * 8){
+ size -= 7;
+ while(get_bits_count(&gb) < size){
int v;
v = get_bits(&gb, 8);
put_bits(&pb, 8, v);
diff --git a/contrib/ffmpeg/libavcodec/kmvc.c b/contrib/ffmpeg/libavcodec/kmvc.c
index e8f39fca1..08de05188 100644
--- a/contrib/ffmpeg/libavcodec/kmvc.c
+++ b/contrib/ffmpeg/libavcodec/kmvc.c
@@ -346,7 +346,6 @@ static int decode_init(AVCodecContext * avctx)
int i;
c->avctx = avctx;
- avctx->has_b_frames = 0;
c->pic.data[0] = NULL;
@@ -368,13 +367,13 @@ static int decode_init(AVCodecContext * avctx)
av_log(NULL, 0, "Extradata missing, decoding may not work properly...\n");
c->palsize = 127;
} else {
- c->palsize = LE_16(avctx->extradata + 10);
+ c->palsize = AV_RL16(avctx->extradata + 10);
}
if (avctx->extradata_size == 1036) { // palette in extradata
uint8_t *src = avctx->extradata + 12;
for (i = 0; i < 256; i++) {
- c->pal[i] = LE_32(src);
+ c->pal[i] = AV_RL32(src);
src += 4;
}
c->setpal = 1;
diff --git a/contrib/ffmpeg/libavcodec/liba52/a52.h b/contrib/ffmpeg/libavcodec/liba52/a52.h
deleted file mode 100644
index f2ea5f836..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/a52.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * a52.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef A52_H
-#define A52_H
-
-#include "../avcodec.h"
-
-#undef malloc
-#undef free
-#undef realloc
-
-#if defined(LIBA52_FIXED)
-typedef int32_t sample_t;
-typedef int32_t level_t;
-#elif defined(LIBA52_DOUBLE)
-typedef double sample_t;
-typedef double level_t;
-#else
-typedef float sample_t;
-typedef float level_t;
-#endif
-
-typedef struct a52_state_s a52_state_t;
-
-#define A52_CHANNEL 0
-#define A52_MONO 1
-#define A52_STEREO 2
-#define A52_3F 3
-#define A52_2F1R 4
-#define A52_3F1R 5
-#define A52_2F2R 6
-#define A52_3F2R 7
-#define A52_CHANNEL1 8
-#define A52_CHANNEL2 9
-#define A52_DOLBY 10
-#define A52_CHANNEL_MASK 15
-
-#define A52_LFE 16
-#define A52_ADJUST_LEVEL 32
-
-a52_state_t * a52_init (uint32_t mm_accel);
-sample_t * a52_samples (a52_state_t * state);
-int a52_syncinfo (uint8_t * buf, int * flags,
- int * sample_rate, int * bit_rate);
-int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
- level_t * level, sample_t bias);
-void a52_dynrng (a52_state_t * state,
- level_t (* call) (level_t, void *), void * data);
-int a52_block (a52_state_t * state);
-void a52_free (a52_state_t * state);
-
-#endif /* A52_H */
diff --git a/contrib/ffmpeg/libavcodec/liba52/a52_internal.h b/contrib/ffmpeg/libavcodec/liba52/a52_internal.h
deleted file mode 100644
index 49fd4ef99..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/a52_internal.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * a52_internal.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-typedef struct {
- uint8_t bai; /* fine SNR offset, fast gain */
- uint8_t deltbae; /* delta bit allocation exists */
- int8_t deltba[50]; /* per-band delta bit allocation */
-} ba_t;
-
-typedef struct {
- uint8_t exp[256]; /* decoded channel exponents */
- int8_t bap[256]; /* derived channel bit allocation */
-} expbap_t;
-
-struct a52_state_s {
- uint8_t fscod; /* sample rate */
- uint8_t halfrate; /* halfrate factor */
- uint8_t acmod; /* coded channels */
- uint8_t lfeon; /* coded lfe channel */
- level_t clev; /* centre channel mix level */
- level_t slev; /* surround channels mix level */
-
- int output; /* type of output */
- level_t level; /* output level */
- sample_t bias; /* output bias */
-
- int dynrnge; /* apply dynamic range */
- level_t dynrng; /* dynamic range */
- void * dynrngdata; /* dynamic range callback funtion and data */
- level_t (* dynrngcall) (level_t range, void * dynrngdata);
-
- uint8_t chincpl; /* channel coupled */
- uint8_t phsflginu; /* phase flags in use (stereo only) */
- uint8_t cplstrtmant; /* coupling channel start mantissa */
- uint8_t cplendmant; /* coupling channel end mantissa */
- uint32_t cplbndstrc; /* coupling band structure */
- level_t cplco[5][18]; /* coupling coordinates */
-
- /* derived information */
- uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
- uint8_t ncplbnd; /* number of coupling bands */
-
- uint8_t rematflg; /* stereo rematrixing */
-
- uint8_t endmant[5]; /* channel end mantissa */
-
- uint16_t bai; /* bit allocation information */
-
- uint32_t * buffer_start;
- uint16_t lfsr_state; /* dither state */
- uint32_t bits_left;
- uint32_t current_word;
-
- uint8_t csnroffst; /* coarse SNR offset */
- ba_t cplba; /* coupling bit allocation parameters */
- ba_t ba[5]; /* channel bit allocation parameters */
- ba_t lfeba; /* lfe bit allocation parameters */
-
- uint8_t cplfleak; /* coupling fast leak init */
- uint8_t cplsleak; /* coupling slow leak init */
-
- expbap_t cpl_expbap;
- expbap_t fbw_expbap[5];
- expbap_t lfe_expbap;
-
- sample_t * samples;
- int downmixed;
-};
-
-#define LEVEL_PLUS6DB 2.0
-#define LEVEL_PLUS3DB 1.4142135623730951
-#define LEVEL_3DB 0.7071067811865476
-#define LEVEL_45DB 0.5946035575013605
-#define LEVEL_6DB 0.5
-
-#define EXP_REUSE (0)
-#define EXP_D15 (1)
-#define EXP_D25 (2)
-#define EXP_D45 (3)
-
-#define DELTA_BIT_REUSE (0)
-#define DELTA_BIT_NEW (1)
-#define DELTA_BIT_NONE (2)
-#define DELTA_BIT_RESERVED (3)
-
-void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
- int start, int end, int fastleak, int slowleak,
- expbap_t * expbap);
-
-int a52_downmix_init (int input, int flags, level_t * level,
- level_t clev, level_t slev);
-int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
- level_t clev, level_t slev);
-void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
- level_t clev, level_t slev);
-void a52_upmix (sample_t * samples, int acmod, int output);
-
-void a52_imdct_init (uint32_t mm_accel);
-void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
-void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);
-//extern void (* a52_imdct_256) (sample_t data[], sample_t delay[], sample_t bias);
-//extern void (* a52_imdct_512) (sample_t data[], sample_t delay[], sample_t bias);
-
-#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
-
-#ifndef LIBA52_FIXED
-
-typedef sample_t quantizer_t;
-#define SAMPLE(x) (x)
-#define LEVEL(x) (x)
-#define MUL(a,b) ((a) * (b))
-#define MUL_L(a,b) ((a) * (b))
-#define MUL_C(a,b) ((a) * (b))
-#define DIV(a,b) ((a) / (b))
-#define BIAS(x) ((x) + bias)
-
-#else /* LIBA52_FIXED */
-
-typedef int16_t quantizer_t;
-#define SAMPLE(x) (sample_t)((x) * (1 << 30))
-#define LEVEL(x) (level_t)((x) * (1 << 26))
-
-#if 0
-#define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30))
-#define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26))
-#elif 1
-#define MUL(a,b) \
-({ int32_t _ta=(a), _tb=(b), _tc; \
- _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); })
-#define MUL_L(a,b) \
-({ int32_t _ta=(a), _tb=(b), _tc; \
- _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); })
-#else
-#define MUL(a,b) (((a) >> 15) * ((b) >> 15))
-#define MUL_L(a,b) (((a) >> 13) * ((b) >> 13))
-#endif
-
-#define MUL_C(a,b) MUL_L (a, LEVEL (b))
-#define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b))
-#define BIAS(x) (x)
-
-#endif
diff --git a/contrib/ffmpeg/libavcodec/liba52/a52_util.h b/contrib/ffmpeg/libavcodec/liba52/a52_util.h
deleted file mode 100644
index 8ef2cece9..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/a52_util.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * a52_util.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef A52_UTIL_H
-#define A52_UTIL_H
-
-uint16_t a52_crc16_block(uint8_t *data,uint32_t num_bytes);
-
-void* a52_resample_init(uint32_t mm_accel,int flags,int chans);
-extern int (* a52_resample) (float * _f, int16_t * s16);
-
-#endif /* A52_H */
diff --git a/contrib/ffmpeg/libavcodec/liba52/bit_allocate.c b/contrib/ffmpeg/libavcodec/liba52/bit_allocate.c
deleted file mode 100644
index 415a08d21..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/bit_allocate.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * bit_allocate.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-
-static int hthtab[3][50] = {
- {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860,
- 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890,
- 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900,
- 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0,
- 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0},
- {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860,
- 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880,
- 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0,
- 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820,
- 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0},
- {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850,
- 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860,
- 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0,
- 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0,
- 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720}
-};
-
-static int8_t baptab[305] = {
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, /* 93 padding elems */
-
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14,
- 14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9,
- 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5,
- 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -1, 0,
-
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0 /* 148 padding elems */
-};
-
-static int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
- 37, 40, 43, 46, 49, 55, 61, 67, 73, 79,
- 85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
-
-static int8_t latab[256] = {
- -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53,
- -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44,
- -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35,
- -35, -34, -33, -33, -32, -32, -31, -30, -30, -29, -29, -28,
- -28, -27, -27, -26, -26, -25, -25, -24, -24, -23, -23, -22,
- -22, -21, -21, -21, -20, -20, -19, -19, -19, -18, -18, -18,
- -17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14,
- -13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11,
- -10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8,
- -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6,
- -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5,
- -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
-};
-
-#define UPDATE_LEAK() \
-do { \
- fastleak += fdecay; \
- if (fastleak > psd + fgain) \
- fastleak = psd + fgain; \
- slowleak += sdecay; \
- if (slowleak > psd + sgain) \
- slowleak = psd + sgain; \
-} while (0)
-
-#define COMPUTE_MASK() \
-do { \
- if (psd > dbknee) \
- mask -= (psd - dbknee) >> 2; \
- if (mask > hth [i >> halfrate]) \
- mask = hth [i >> halfrate]; \
- mask -= snroffset + 128 * deltba[i]; \
- mask = (mask > 0) ? 0 : ((-mask) >> 5); \
- mask -= floor; \
-} while (0)
-
-void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
- int start, int end, int fastleak, int slowleak,
- expbap_t * expbap)
-{
- static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
- static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100};
- static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
- 0xa10, 0xa90, 0xb10, 0x1400};
-
- int i, j;
- uint8_t * exp;
- int8_t * bap;
- int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset;
- int psd, mask;
- int8_t * deltba;
- int * hth;
- int halfrate;
-
- halfrate = state->halfrate;
- fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate; /* fdcycod */
- fgain = 128 + 128 * (ba->bai & 7); /* fgaincod */
- sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate; /* sdcycod */
- sgain = slowgain[(state->bai >> 5) & 3]; /* sgaincod */
- dbknee = dbpbtab[(state->bai >> 3) & 3]; /* dbpbcod */
- hth = hthtab[state->fscod];
- /*
- * if there is no delta bit allocation, make deltba point to an area
- * known to contain zeroes. baptab+156 here.
- */
- deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba;
- floor = floortab[state->bai & 7]; /* floorcod */
- snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor;
- floor >>= 5;
-
- exp = expbap->exp;
- bap = expbap->bap;
-
- i = bndstart;
- j = start;
- if (start == 0) { /* not the coupling channel */
- int lowcomp;
-
- lowcomp = 0;
- j = end - 1;
- do {
- if (i < j) {
- if (exp[i+1] == exp[i] - 2)
- lowcomp = 384;
- else if (lowcomp && (exp[i+1] > exp[i]))
- lowcomp -= 64;
- }
- psd = 128 * exp[i];
- mask = psd + fgain + lowcomp;
- COMPUTE_MASK ();
- bap[i] = (baptab+156)[mask + 4 * exp[i]];
- i++;
- } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
- fastleak = psd + fgain;
- slowleak = psd + sgain;
-
- while (i < 7) {
- if (i < j) {
- if (exp[i+1] == exp[i] - 2)
- lowcomp = 384;
- else if (lowcomp && (exp[i+1] > exp[i]))
- lowcomp -= 64;
- }
- psd = 128 * exp[i];
- UPDATE_LEAK ();
- mask = ((fastleak + lowcomp < slowleak) ?
- fastleak + lowcomp : slowleak);
- COMPUTE_MASK ();
- bap[i] = (baptab+156)[mask + 4 * exp[i]];
- i++;
- }
-
- if (end == 7) /* lfe channel */
- return;
-
- do {
- if (exp[i+1] == exp[i] - 2)
- lowcomp = 320;
- else if (lowcomp && (exp[i+1] > exp[i]))
- lowcomp -= 64;
- psd = 128 * exp[i];
- UPDATE_LEAK ();
- mask = ((fastleak + lowcomp < slowleak) ?
- fastleak + lowcomp : slowleak);
- COMPUTE_MASK ();
- bap[i] = (baptab+156)[mask + 4 * exp[i]];
- i++;
- } while (i < 20);
-
- while (lowcomp > 128) { /* two iterations maximum */
- lowcomp -= 128;
- psd = 128 * exp[i];
- UPDATE_LEAK ();
- mask = ((fastleak + lowcomp < slowleak) ?
- fastleak + lowcomp : slowleak);
- COMPUTE_MASK ();
- bap[i] = (baptab+156)[mask + 4 * exp[i]];
- i++;
- }
- j = i;
- }
-
- do {
- int startband, endband;
-
- startband = j;
- endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
- psd = 128 * exp[j++];
- while (j < endband) {
- int next, delta;
-
- next = 128 * exp[j++];
- delta = next - psd;
- switch (delta >> 9) {
- case -6: case -5: case -4: case -3: case -2:
- psd = next;
- break;
- case -1:
- psd = next + latab[(-delta) >> 1];
- break;
- case 0:
- psd += latab[delta >> 1];
- break;
- }
- }
- /* minpsd = -289 */
- UPDATE_LEAK ();
- mask = (fastleak < slowleak) ? fastleak : slowleak;
- COMPUTE_MASK ();
- i++;
- j = startband;
- do {
- /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
- /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
- bap[j] = (baptab+156)[mask + 4 * exp[j]];
- } while (++j < endband);
- } while (j < end);
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/bitstream.c b/contrib/ffmpeg/libavcodec/liba52/bitstream.c
deleted file mode 100644
index f6b05c5e6..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/bitstream.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * bitstream.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-#include "bitstream.h"
-
-#define BUFFER_SIZE 4096
-
-void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
-{
- int align;
-
- align = (long)buf & 3;
- state->buffer_start = (uint32_t *) (buf - align);
- state->bits_left = 0;
- state->current_word = 0;
- bitstream_get (state, align * 8);
-}
-
-static inline void bitstream_fill_current (a52_state_t * state)
-{
- uint32_t tmp;
-
- tmp = *(state->buffer_start++);
- state->current_word = swab32 (tmp);
-}
-
-/*
- * The fast paths for _get is in the
- * bitstream.h header file so it can be inlined.
- *
- * The "bottom half" of this routine is suffixed _bh
- *
- * -ah
- */
-
-uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits)
-{
- uint32_t result;
-
- num_bits -= state->bits_left;
- result = ((state->current_word << (32 - state->bits_left)) >>
- (32 - state->bits_left));
-
- bitstream_fill_current (state);
-
- if (num_bits != 0)
- result = (result << num_bits) | (state->current_word >> (32 - num_bits));
-
- state->bits_left = 32 - num_bits;
-
- return result;
-}
-
-int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits)
-{
- int32_t result;
-
- num_bits -= state->bits_left;
- result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >>
- (32 - state->bits_left));
-
- bitstream_fill_current(state);
-
- if (num_bits != 0)
- result = (result << num_bits) | (state->current_word >> (32 - num_bits));
-
- state->bits_left = 32 - num_bits;
-
- return result;
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/bitstream.h b/contrib/ffmpeg/libavcodec/liba52/bitstream.h
deleted file mode 100644
index 4a64bf3d9..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/bitstream.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * bitstream.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* (stolen from the kernel) */
-#ifdef WORDS_BIGENDIAN
-
-# define swab32(x) (x)
-
-#else
-
-# if 0 && defined (__i386__)
-
-# define swab32(x) __i386_swab32(x)
- static inline const uint32_t __i386_swab32(uint32_t x)
- {
- __asm__("bswap %0" : "=r" (x) : "0" (x));
- return x;
- }
-
-# else
-
-# define swab32(x)\
-((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | \
- (((uint8_t*)&x)[2] << 8) | (((uint8_t*)&x)[3]))
-
-# endif
-#endif
-
-void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf);
-uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits);
-int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits);
-
-static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
-{
- uint32_t result;
-
- if (num_bits < state->bits_left) {
- result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
- state->bits_left -= num_bits;
- return result;
- }
-
- return a52_bitstream_get_bh (state, num_bits);
-}
-
-static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits)
-{
- int32_t result;
-
- if (num_bits < state->bits_left) {
- result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
- state->bits_left -= num_bits;
- return result;
- }
-
- return a52_bitstream_get_bh_2 (state, num_bits);
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/crc.c b/contrib/ffmpeg/libavcodec/liba52/crc.c
deleted file mode 100644
index 1ec4b085f..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/crc.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * crc.c
- *
- * Copyright (C) Aaron Holtzman - May 1999
- *
- * This file is part of ac3dec, a free Dolby AC-3 stream decoder.
- *
- * ac3dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * ac3dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
-
-static const uint16_t crc_lut[256] =
-{
- 0x0000,0x8005,0x800f,0x000a,0x801b,0x001e,0x0014,0x8011,
- 0x8033,0x0036,0x003c,0x8039,0x0028,0x802d,0x8027,0x0022,
- 0x8063,0x0066,0x006c,0x8069,0x0078,0x807d,0x8077,0x0072,
- 0x0050,0x8055,0x805f,0x005a,0x804b,0x004e,0x0044,0x8041,
- 0x80c3,0x00c6,0x00cc,0x80c9,0x00d8,0x80dd,0x80d7,0x00d2,
- 0x00f0,0x80f5,0x80ff,0x00fa,0x80eb,0x00ee,0x00e4,0x80e1,
- 0x00a0,0x80a5,0x80af,0x00aa,0x80bb,0x00be,0x00b4,0x80b1,
- 0x8093,0x0096,0x009c,0x8099,0x0088,0x808d,0x8087,0x0082,
- 0x8183,0x0186,0x018c,0x8189,0x0198,0x819d,0x8197,0x0192,
- 0x01b0,0x81b5,0x81bf,0x01ba,0x81ab,0x01ae,0x01a4,0x81a1,
- 0x01e0,0x81e5,0x81ef,0x01ea,0x81fb,0x01fe,0x01f4,0x81f1,
- 0x81d3,0x01d6,0x01dc,0x81d9,0x01c8,0x81cd,0x81c7,0x01c2,
- 0x0140,0x8145,0x814f,0x014a,0x815b,0x015e,0x0154,0x8151,
- 0x8173,0x0176,0x017c,0x8179,0x0168,0x816d,0x8167,0x0162,
- 0x8123,0x0126,0x012c,0x8129,0x0138,0x813d,0x8137,0x0132,
- 0x0110,0x8115,0x811f,0x011a,0x810b,0x010e,0x0104,0x8101,
- 0x8303,0x0306,0x030c,0x8309,0x0318,0x831d,0x8317,0x0312,
- 0x0330,0x8335,0x833f,0x033a,0x832b,0x032e,0x0324,0x8321,
- 0x0360,0x8365,0x836f,0x036a,0x837b,0x037e,0x0374,0x8371,
- 0x8353,0x0356,0x035c,0x8359,0x0348,0x834d,0x8347,0x0342,
- 0x03c0,0x83c5,0x83cf,0x03ca,0x83db,0x03de,0x03d4,0x83d1,
- 0x83f3,0x03f6,0x03fc,0x83f9,0x03e8,0x83ed,0x83e7,0x03e2,
- 0x83a3,0x03a6,0x03ac,0x83a9,0x03b8,0x83bd,0x83b7,0x03b2,
- 0x0390,0x8395,0x839f,0x039a,0x838b,0x038e,0x0384,0x8381,
- 0x0280,0x8285,0x828f,0x028a,0x829b,0x029e,0x0294,0x8291,
- 0x82b3,0x02b6,0x02bc,0x82b9,0x02a8,0x82ad,0x82a7,0x02a2,
- 0x82e3,0x02e6,0x02ec,0x82e9,0x02f8,0x82fd,0x82f7,0x02f2,
- 0x02d0,0x82d5,0x82df,0x02da,0x82cb,0x02ce,0x02c4,0x82c1,
- 0x8243,0x0246,0x024c,0x8249,0x0258,0x825d,0x8257,0x0252,
- 0x0270,0x8275,0x827f,0x027a,0x826b,0x026e,0x0264,0x8261,
- 0x0220,0x8225,0x822f,0x022a,0x823b,0x023e,0x0234,0x8231,
- 0x8213,0x0216,0x021c,0x8219,0x0208,0x820d,0x8207,0x0202
-};
-
-uint16_t a52_crc16_block(uint8_t *data,uint32_t num_bytes)
-{
- uint32_t i;
- uint16_t state=0;
-
- for(i=0;i<num_bytes;i++)
- state = crc_lut[data[i] ^ (state>>8)] ^ (state<<8);
-
- return state;
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/downmix.c b/contrib/ffmpeg/libavcodec/liba52/downmix.c
deleted file mode 100644
index 7999b7db0..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/downmix.c
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * downmix.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-
-#define CONVERT(acmod,output) (((output) << 3) + (acmod))
-
-int a52_downmix_init (int input, int flags, level_t * level,
- level_t clev, level_t slev)
-{
- static uint8_t table[11][8] = {
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
- {A52_MONO, A52_MONO, A52_MONO, A52_MONO,
- A52_MONO, A52_MONO, A52_MONO, A52_MONO},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
- A52_STEREO, A52_3F, A52_STEREO, A52_3F},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
- A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
- A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
- {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
- A52_MONO, A52_MONO, A52_MONO, A52_MONO},
- {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
- A52_MONO, A52_MONO, A52_MONO, A52_MONO},
- {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
- A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
- };
- int output;
-
- output = flags & A52_CHANNEL_MASK;
- if (output > A52_DOLBY)
- return -1;
-
- output = table[output][input & 7];
-
- if (output == A52_STEREO &&
- (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB))))
- output = A52_DOLBY;
-
- if (flags & A52_ADJUST_LEVEL) {
- level_t adjust;
-
- switch (CONVERT (input & 7, output)) {
-
- case CONVERT (A52_3F, A52_MONO):
- adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
- break;
-
- case CONVERT (A52_STEREO, A52_MONO):
- case CONVERT (A52_2F2R, A52_2F1R):
- case CONVERT (A52_3F2R, A52_3F1R):
- level_3db:
- adjust = LEVEL (LEVEL_3DB);
- break;
-
- case CONVERT (A52_3F2R, A52_2F1R):
- if (clev < LEVEL (LEVEL_PLUS3DB - 1))
- goto level_3db;
- /* break thru */
- case CONVERT (A52_3F, A52_STEREO):
- case CONVERT (A52_3F1R, A52_2F1R):
- case CONVERT (A52_3F1R, A52_2F2R):
- case CONVERT (A52_3F2R, A52_2F2R):
- adjust = DIV (1, LEVEL (1) + clev);
- break;
-
- case CONVERT (A52_2F1R, A52_MONO):
- adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
- break;
-
- case CONVERT (A52_2F1R, A52_STEREO):
- case CONVERT (A52_3F1R, A52_3F):
- adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
- break;
-
- case CONVERT (A52_3F1R, A52_MONO):
- adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
- break;
-
- case CONVERT (A52_3F1R, A52_STEREO):
- adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
- break;
-
- case CONVERT (A52_2F2R, A52_MONO):
- adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
- break;
-
- case CONVERT (A52_2F2R, A52_STEREO):
- case CONVERT (A52_3F2R, A52_3F):
- adjust = DIV (1, LEVEL (1) + slev);
- break;
-
- case CONVERT (A52_3F2R, A52_MONO):
- adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
- break;
-
- case CONVERT (A52_3F2R, A52_STEREO):
- adjust = DIV (1, LEVEL (1) + clev + slev);
- break;
-
- case CONVERT (A52_MONO, A52_DOLBY):
- adjust = LEVEL (LEVEL_PLUS3DB);
- break;
-
- case CONVERT (A52_3F, A52_DOLBY):
- case CONVERT (A52_2F1R, A52_DOLBY):
- adjust = LEVEL (1 / (1 + LEVEL_3DB));
- break;
-
- case CONVERT (A52_3F1R, A52_DOLBY):
- case CONVERT (A52_2F2R, A52_DOLBY):
- adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
- break;
-
- case CONVERT (A52_3F2R, A52_DOLBY):
- adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
- break;
-
- default:
- return output;
- }
-
- *level = MUL_L (*level, adjust);
- }
-
- return output;
-}
-
-int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
- level_t clev, level_t slev)
-{
- level_t level_3db;
-
- level_3db = MUL_C (level, LEVEL_3DB);
-
- switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
-
- case CONVERT (A52_CHANNEL, A52_CHANNEL):
- case CONVERT (A52_MONO, A52_MONO):
- case CONVERT (A52_STEREO, A52_STEREO):
- case CONVERT (A52_3F, A52_3F):
- case CONVERT (A52_2F1R, A52_2F1R):
- case CONVERT (A52_3F1R, A52_3F1R):
- case CONVERT (A52_2F2R, A52_2F2R):
- case CONVERT (A52_3F2R, A52_3F2R):
- case CONVERT (A52_STEREO, A52_DOLBY):
- coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
- return 0;
-
- case CONVERT (A52_CHANNEL, A52_MONO):
- coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
- return 3;
-
- case CONVERT (A52_STEREO, A52_MONO):
- coeff[0] = coeff[1] = level_3db;
- return 3;
-
- case CONVERT (A52_3F, A52_MONO):
- coeff[0] = coeff[2] = level_3db;
- coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
- return 7;
-
- case CONVERT (A52_2F1R, A52_MONO):
- coeff[0] = coeff[1] = level_3db;
- coeff[2] = MUL_L (level_3db, slev);
- return 7;
-
- case CONVERT (A52_2F2R, A52_MONO):
- coeff[0] = coeff[1] = level_3db;
- coeff[2] = coeff[3] = MUL_L (level_3db, slev);
- return 15;
-
- case CONVERT (A52_3F1R, A52_MONO):
- coeff[0] = coeff[2] = level_3db;
- coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
- coeff[3] = MUL_L (level_3db, slev);
- return 15;
-
- case CONVERT (A52_3F2R, A52_MONO):
- coeff[0] = coeff[2] = level_3db;
- coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
- coeff[3] = coeff[4] = MUL_L (level_3db, slev);
- return 31;
-
- case CONVERT (A52_MONO, A52_DOLBY):
- coeff[0] = level_3db;
- return 0;
-
- case CONVERT (A52_3F, A52_DOLBY):
- coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
- coeff[1] = level_3db;
- return 7;
-
- case CONVERT (A52_3F, A52_STEREO):
- case CONVERT (A52_3F1R, A52_2F1R):
- case CONVERT (A52_3F2R, A52_2F2R):
- coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
- coeff[1] = MUL_L (level, clev);
- return 7;
-
- case CONVERT (A52_2F1R, A52_DOLBY):
- coeff[0] = coeff[1] = level;
- coeff[2] = level_3db;
- return 7;
-
- case CONVERT (A52_2F1R, A52_STEREO):
- coeff[0] = coeff[1] = level;
- coeff[2] = MUL_L (level_3db, slev);
- return 7;
-
- case CONVERT (A52_3F1R, A52_DOLBY):
- coeff[0] = coeff[2] = level;
- coeff[1] = coeff[3] = level_3db;
- return 15;
-
- case CONVERT (A52_3F1R, A52_STEREO):
- coeff[0] = coeff[2] = level;
- coeff[1] = MUL_L (level, clev);
- coeff[3] = MUL_L (level_3db, slev);
- return 15;
-
- case CONVERT (A52_2F2R, A52_DOLBY):
- coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = level_3db;
- return 15;
-
- case CONVERT (A52_2F2R, A52_STEREO):
- coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = MUL_L (level, slev);
- return 15;
-
- case CONVERT (A52_3F2R, A52_DOLBY):
- coeff[0] = coeff[2] = level;
- coeff[1] = coeff[3] = coeff[4] = level_3db;
- return 31;
-
- case CONVERT (A52_3F2R, A52_2F1R):
- coeff[0] = coeff[2] = level;
- coeff[1] = MUL_L (level, clev);
- coeff[3] = coeff[4] = level_3db;
- return 31;
-
- case CONVERT (A52_3F2R, A52_STEREO):
- coeff[0] = coeff[2] = level;
- coeff[1] = MUL_L (level, clev);
- coeff[3] = coeff[4] = MUL_L (level, slev);
- return 31;
-
- case CONVERT (A52_3F1R, A52_3F):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = MUL_L (level_3db, slev);
- return 13;
-
- case CONVERT (A52_3F2R, A52_3F):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = coeff[4] = MUL_L (level, slev);
- return 29;
-
- case CONVERT (A52_2F2R, A52_2F1R):
- coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = level_3db;
- return 12;
-
- case CONVERT (A52_3F2R, A52_3F1R):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = coeff[4] = level_3db;
- return 24;
-
- case CONVERT (A52_2F1R, A52_2F2R):
- coeff[0] = coeff[1] = level;
- coeff[2] = level_3db;
- return 0;
-
- case CONVERT (A52_3F1R, A52_2F2R):
- coeff[0] = coeff[2] = level;
- coeff[1] = MUL_L (level, clev);
- coeff[3] = level_3db;
- return 7;
-
- case CONVERT (A52_3F1R, A52_3F2R):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = level_3db;
- return 0;
-
- case CONVERT (A52_CHANNEL, A52_CHANNEL1):
- coeff[0] = level;
- coeff[1] = 0;
- return 0;
-
- case CONVERT (A52_CHANNEL, A52_CHANNEL2):
- coeff[0] = 0;
- coeff[1] = level;
- return 0;
- }
-
- return -1; /* NOTREACHED */
-}
-
-static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
-{
- int i;
-
- for (i = 0; i < 256; i++)
- dest[i] += BIAS (src[i]);
-}
-
-static void mix3to1 (sample_t * samples, sample_t bias)
-{
- int i;
-
- for (i = 0; i < 256; i++)
- samples[i] += BIAS (samples[i + 256] + samples[i + 512]);
-}
-
-static void mix4to1 (sample_t * samples, sample_t bias)
-{
- int i;
-
- for (i = 0; i < 256; i++)
- samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
- samples[i + 768]);
-}
-
-static void mix5to1 (sample_t * samples, sample_t bias)
-{
- int i;
-
- for (i = 0; i < 256; i++)
- samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
- samples[i + 768] + samples[i + 1024]);
-}
-
-static void mix3to2 (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t common;
-
- for (i = 0; i < 256; i++) {
- common = BIAS (samples[i + 256]);
- samples[i] += common;
- samples[i + 256] = samples[i + 512] + common;
- }
-}
-
-static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
-{
- int i;
- sample_t common;
-
- for (i = 0; i < 256; i++) {
- common = BIAS (right[i + 256]);
- left[i] += common;
- right[i] += common;
- }
-}
-
-static void mix21toS (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t surround;
-
- for (i = 0; i < 256; i++) {
- surround = samples[i + 512];
- samples[i] += BIAS (-surround);
- samples[i + 256] += BIAS (surround);
- }
-}
-
-static void mix31to2 (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t common;
-
- for (i = 0; i < 256; i++) {
- common = BIAS (samples[i + 256] + samples[i + 768]);
- samples[i] += common;
- samples[i + 256] = samples[i + 512] + common;
- }
-}
-
-static void mix31toS (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t common, surround;
-
- for (i = 0; i < 256; i++) {
- common = BIAS (samples[i + 256]);
- surround = samples[i + 768];
- samples[i] += common - surround;
- samples[i + 256] = samples[i + 512] + common + surround;
- }
-}
-
-static void mix22toS (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t surround;
-
- for (i = 0; i < 256; i++) {
- surround = samples[i + 512] + samples[i + 768];
- samples[i] += BIAS (-surround);
- samples[i + 256] += BIAS (surround);
- }
-}
-
-static void mix32to2 (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t common;
-
- for (i = 0; i < 256; i++) {
- common = BIAS (samples[i + 256]);
- samples[i] += common + samples[i + 768];
- samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
- }
-}
-
-static void mix32toS (sample_t * samples, sample_t bias)
-{
- int i;
- sample_t common, surround;
-
- for (i = 0; i < 256; i++) {
- common = BIAS (samples[i + 256]);
- surround = samples[i + 768] + samples[i + 1024];
- samples[i] += common - surround;
- samples[i + 256] = samples[i + 512] + common + surround;
- }
-}
-
-static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
-{
- int i;
-
- for (i = 0; i < 256; i++)
- dest[i] = BIAS (src[i] + src[i + 256]);
-}
-
-static void zero (sample_t * samples)
-{
- int i;
-
- for (i = 0; i < 256; i++)
- samples[i] = 0;
-}
-
-void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
- level_t clev, level_t slev)
-{
- switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
-
- case CONVERT (A52_CHANNEL, A52_CHANNEL2):
- memcpy (samples, samples + 256, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_CHANNEL, A52_MONO):
- case CONVERT (A52_STEREO, A52_MONO):
- mix_2to1:
- mix2to1 (samples, samples + 256, bias);
- break;
-
- case CONVERT (A52_2F1R, A52_MONO):
- if (slev == 0)
- goto mix_2to1;
- case CONVERT (A52_3F, A52_MONO):
- mix_3to1:
- mix3to1 (samples, bias);
- break;
-
- case CONVERT (A52_3F1R, A52_MONO):
- if (slev == 0)
- goto mix_3to1;
- case CONVERT (A52_2F2R, A52_MONO):
- if (slev == 0)
- goto mix_2to1;
- mix4to1 (samples, bias);
- break;
-
- case CONVERT (A52_3F2R, A52_MONO):
- if (slev == 0)
- goto mix_3to1;
- mix5to1 (samples, bias);
- break;
-
- case CONVERT (A52_MONO, A52_DOLBY):
- memcpy (samples + 256, samples, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_3F, A52_STEREO):
- case CONVERT (A52_3F, A52_DOLBY):
- mix_3to2:
- mix3to2 (samples, bias);
- break;
-
- case CONVERT (A52_2F1R, A52_STEREO):
- if (slev == 0)
- break;
- mix21to2 (samples, samples + 256, bias);
- break;
-
- case CONVERT (A52_2F1R, A52_DOLBY):
- mix21toS (samples, bias);
- break;
-
- case CONVERT (A52_3F1R, A52_STEREO):
- if (slev == 0)
- goto mix_3to2;
- mix31to2 (samples, bias);
- break;
-
- case CONVERT (A52_3F1R, A52_DOLBY):
- mix31toS (samples, bias);
- break;
-
- case CONVERT (A52_2F2R, A52_STEREO):
- if (slev == 0)
- break;
- mix2to1 (samples, samples + 512, bias);
- mix2to1 (samples + 256, samples + 768, bias);
- break;
-
- case CONVERT (A52_2F2R, A52_DOLBY):
- mix22toS (samples, bias);
- break;
-
- case CONVERT (A52_3F2R, A52_STEREO):
- if (slev == 0)
- goto mix_3to2;
- mix32to2 (samples, bias);
- break;
-
- case CONVERT (A52_3F2R, A52_DOLBY):
- mix32toS (samples, bias);
- break;
-
- case CONVERT (A52_3F1R, A52_3F):
- if (slev == 0)
- break;
- mix21to2 (samples, samples + 512, bias);
- break;
-
- case CONVERT (A52_3F2R, A52_3F):
- if (slev == 0)
- break;
- mix2to1 (samples, samples + 768, bias);
- mix2to1 (samples + 512, samples + 1024, bias);
- break;
-
- case CONVERT (A52_3F1R, A52_2F1R):
- mix3to2 (samples, bias);
- memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_2F2R, A52_2F1R):
- mix2to1 (samples + 512, samples + 768, bias);
- break;
-
- case CONVERT (A52_3F2R, A52_2F1R):
- mix3to2 (samples, bias);
- move2to1 (samples + 768, samples + 512, bias);
- break;
-
- case CONVERT (A52_3F2R, A52_3F1R):
- mix2to1 (samples + 768, samples + 1024, bias);
- break;
-
- case CONVERT (A52_2F1R, A52_2F2R):
- memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_3F1R, A52_2F2R):
- mix3to2 (samples, bias);
- memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_3F2R, A52_2F2R):
- mix3to2 (samples, bias);
- memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
- memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_3F1R, A52_3F2R):
- memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
- break;
- }
-}
-
-void a52_upmix (sample_t * samples, int acmod, int output)
-{
- switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
-
- case CONVERT (A52_CHANNEL, A52_CHANNEL2):
- memcpy (samples + 256, samples, 256 * sizeof (sample_t));
- break;
-
- case CONVERT (A52_3F2R, A52_MONO):
- zero (samples + 1024);
- case CONVERT (A52_3F1R, A52_MONO):
- case CONVERT (A52_2F2R, A52_MONO):
- zero (samples + 768);
- case CONVERT (A52_3F, A52_MONO):
- case CONVERT (A52_2F1R, A52_MONO):
- zero (samples + 512);
- case CONVERT (A52_CHANNEL, A52_MONO):
- case CONVERT (A52_STEREO, A52_MONO):
- zero (samples + 256);
- break;
-
- case CONVERT (A52_3F2R, A52_STEREO):
- case CONVERT (A52_3F2R, A52_DOLBY):
- zero (samples + 1024);
- case CONVERT (A52_3F1R, A52_STEREO):
- case CONVERT (A52_3F1R, A52_DOLBY):
- zero (samples + 768);
- case CONVERT (A52_3F, A52_STEREO):
- case CONVERT (A52_3F, A52_DOLBY):
- mix_3to2:
- memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
- zero (samples + 256);
- break;
-
- case CONVERT (A52_2F2R, A52_STEREO):
- case CONVERT (A52_2F2R, A52_DOLBY):
- zero (samples + 768);
- case CONVERT (A52_2F1R, A52_STEREO):
- case CONVERT (A52_2F1R, A52_DOLBY):
- zero (samples + 512);
- break;
-
- case CONVERT (A52_3F2R, A52_3F):
- zero (samples + 1024);
- case CONVERT (A52_3F1R, A52_3F):
- case CONVERT (A52_2F2R, A52_2F1R):
- zero (samples + 768);
- break;
-
- case CONVERT (A52_3F2R, A52_3F1R):
- zero (samples + 1024);
- break;
-
- case CONVERT (A52_3F2R, A52_2F1R):
- zero (samples + 1024);
- case CONVERT (A52_3F1R, A52_2F1R):
- mix_31to21:
- memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
- goto mix_3to2;
-
- case CONVERT (A52_3F2R, A52_2F2R):
- memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
- goto mix_31to21;
- }
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/imdct.c b/contrib/ffmpeg/libavcodec/liba52/imdct.c
deleted file mode 100644
index 21a2a6565..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/imdct.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * imdct.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * The ifft algorithms in this file have been largely inspired by Dan
- * Bernstein's work, djbfft, available at http://cr.yp.to/djbfft.html
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "a52.h"
-#include "a52_internal.h"
-#include "mm_accel.h"
-
-typedef struct complex_s {
- sample_t real;
- sample_t imag;
-} complex_t;
-
-static uint8_t fftorder[] = {
- 0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176,
- 8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88,
- 4,132, 68,196, 36,164,228,100, 20,148, 84,212,244,116, 52,180,
- 252,124, 60,188, 28,156,220, 92, 12,140, 76,204,236,108, 44,172,
- 2,130, 66,194, 34,162,226, 98, 18,146, 82,210,242,114, 50,178,
- 10,138, 74,202, 42,170,234,106,250,122, 58,186, 26,154,218, 90,
- 254,126, 62,190, 30,158,222, 94, 14,142, 78,206,238,110, 46,174,
- 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86
-};
-
-/* Root values for IFFT */
-static sample_t roots16[3];
-static sample_t roots32[7];
-static sample_t roots64[15];
-static sample_t roots128[31];
-
-/* Twiddle factors for IMDCT */
-static complex_t pre1[128];
-static complex_t post1[64];
-static complex_t pre2[64];
-static complex_t post2[32];
-
-static sample_t a52_imdct_window[256];
-
-static void (* ifft128) (complex_t * buf);
-static void (* ifft64) (complex_t * buf);
-
-static inline void ifft2 (complex_t * buf)
-{
- sample_t r, i;
-
- r = buf[0].real;
- i = buf[0].imag;
- buf[0].real += buf[1].real;
- buf[0].imag += buf[1].imag;
- buf[1].real = r - buf[1].real;
- buf[1].imag = i - buf[1].imag;
-}
-
-static inline void ifft4 (complex_t * buf)
-{
- sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
-
- tmp1 = buf[0].real + buf[1].real;
- tmp2 = buf[3].real + buf[2].real;
- tmp3 = buf[0].imag + buf[1].imag;
- tmp4 = buf[2].imag + buf[3].imag;
- tmp5 = buf[0].real - buf[1].real;
- tmp6 = buf[0].imag - buf[1].imag;
- tmp7 = buf[2].imag - buf[3].imag;
- tmp8 = buf[3].real - buf[2].real;
-
- buf[0].real = tmp1 + tmp2;
- buf[0].imag = tmp3 + tmp4;
- buf[2].real = tmp1 - tmp2;
- buf[2].imag = tmp3 - tmp4;
- buf[1].real = tmp5 + tmp7;
- buf[1].imag = tmp6 + tmp8;
- buf[3].real = tmp5 - tmp7;
- buf[3].imag = tmp6 - tmp8;
-}
-
-/* basic radix-2 ifft butterfly */
-
-#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do { \
- t0 = MUL (W1, d1) + MUL (W0, d0); \
- t1 = MUL (W0, d1) - MUL (W1, d0); \
-} while (0)
-
-/* radix-2 ifft butterfly with bias */
-
-#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do { \
- t0 = BIAS (MUL (d1, W1) + MUL (d0, W0)); \
- t1 = BIAS (MUL (d1, W0) - MUL (d0, W1)); \
-} while (0)
-
-/* the basic split-radix ifft butterfly */
-
-#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \
- BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag); \
- BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real); \
- tmp1 = tmp5 + tmp7; \
- tmp2 = tmp6 + tmp8; \
- tmp3 = tmp6 - tmp8; \
- tmp4 = tmp7 - tmp5; \
- a2.real = a0.real - tmp1; \
- a2.imag = a0.imag - tmp2; \
- a3.real = a1.real - tmp3; \
- a3.imag = a1.imag - tmp4; \
- a0.real += tmp1; \
- a0.imag += tmp2; \
- a1.real += tmp3; \
- a1.imag += tmp4; \
-} while (0)
-
-/* split-radix ifft butterfly, specialized for wr=1 wi=0 */
-
-#define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \
- tmp1 = a2.real + a3.real; \
- tmp2 = a2.imag + a3.imag; \
- tmp3 = a2.imag - a3.imag; \
- tmp4 = a3.real - a2.real; \
- a2.real = a0.real - tmp1; \
- a2.imag = a0.imag - tmp2; \
- a3.real = a1.real - tmp3; \
- a3.imag = a1.imag - tmp4; \
- a0.real += tmp1; \
- a0.imag += tmp2; \
- a1.real += tmp3; \
- a1.imag += tmp4; \
-} while (0)
-
-/* split-radix ifft butterfly, specialized for wr=wi */
-
-#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \
- tmp5 = MUL (a2.real + a2.imag, w); \
- tmp6 = MUL (a2.imag - a2.real, w); \
- tmp7 = MUL (a3.real - a3.imag, w); \
- tmp8 = MUL (a3.imag + a3.real, w); \
- tmp1 = tmp5 + tmp7; \
- tmp2 = tmp6 + tmp8; \
- tmp3 = tmp6 - tmp8; \
- tmp4 = tmp7 - tmp5; \
- a2.real = a0.real - tmp1; \
- a2.imag = a0.imag - tmp2; \
- a3.real = a1.real - tmp3; \
- a3.imag = a1.imag - tmp4; \
- a0.real += tmp1; \
- a0.imag += tmp2; \
- a1.real += tmp3; \
- a1.imag += tmp4; \
-} while (0)
-
-static inline void ifft8 (complex_t * buf)
-{
- sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
-
- ifft4 (buf);
- ifft2 (buf + 4);
- ifft2 (buf + 6);
- BUTTERFLY_ZERO (buf[0], buf[2], buf[4], buf[6]);
- BUTTERFLY_HALF (buf[1], buf[3], buf[5], buf[7], roots16[1]);
-}
-
-static void ifft_pass (complex_t * buf, sample_t * weight, int n)
-{
- complex_t * buf1;
- complex_t * buf2;
- complex_t * buf3;
- sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
- int i;
-
- buf++;
- buf1 = buf + n;
- buf2 = buf + 2 * n;
- buf3 = buf + 3 * n;
-
- BUTTERFLY_ZERO (buf[-1], buf1[-1], buf2[-1], buf3[-1]);
-
- i = n - 1;
-
- do {
- BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0],
- weight[0], weight[2*i-n]);
- buf++;
- buf1++;
- buf2++;
- buf3++;
- weight++;
- } while (--i);
-}
-
-static void ifft16 (complex_t * buf)
-{
- ifft8 (buf);
- ifft4 (buf + 8);
- ifft4 (buf + 12);
- ifft_pass (buf, roots16, 4);
-}
-
-static void ifft32 (complex_t * buf)
-{
- ifft16 (buf);
- ifft8 (buf + 16);
- ifft8 (buf + 24);
- ifft_pass (buf, roots32, 8);
-}
-
-static void ifft64_c (complex_t * buf)
-{
- ifft32 (buf);
- ifft16 (buf + 32);
- ifft16 (buf + 48);
- ifft_pass (buf, roots64, 16);
-}
-
-static void ifft128_c (complex_t * buf)
-{
- ifft32 (buf);
- ifft16 (buf + 32);
- ifft16 (buf + 48);
- ifft_pass (buf, roots64, 16);
-
- ifft32 (buf + 64);
- ifft32 (buf + 96);
- ifft_pass (buf, roots128, 32);
-}
-
-void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias)
-{
- int i, k;
- sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2;
- const sample_t * window = a52_imdct_window;
- complex_t buf[128];
-
- for (i = 0; i < 128; i++) {
- k = fftorder[i];
- t_r = pre1[i].real;
- t_i = pre1[i].imag;
- BUTTERFLY_0 (buf[i].real, buf[i].imag, t_r, t_i, data[k], data[255-k]);
- }
-
- ifft128 (buf);
-
- /* Post IFFT complex multiply plus IFFT complex conjugate*/
- /* Window and convert to real valued signal */
- for (i = 0; i < 64; i++) {
- /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
- t_r = post1[i].real;
- t_i = post1[i].imag;
- BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf[i].imag, buf[i].real);
- BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf[127-i].imag, buf[127-i].real);
-
- w_1 = window[2*i];
- w_2 = window[255-2*i];
- BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]);
- delay[2*i] = a_i;
-
- w_1 = window[2*i+1];
- w_2 = window[254-2*i];
- BUTTERFLY_B (data[2*i+1], data[254-2*i], w_1, w_2, b_r, delay[2*i+1]);
- delay[2*i+1] = b_i;
- }
-}
-
-void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias)
-{
- int i, k;
- sample_t t_r, t_i, a_r, a_i, b_r, b_i, c_r, c_i, d_r, d_i, w_1, w_2;
- const sample_t * window = a52_imdct_window;
- complex_t buf1[64], buf2[64];
-
- /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
- for (i = 0; i < 64; i++) {
- k = fftorder[i];
- t_r = pre2[i].real;
- t_i = pre2[i].imag;
- BUTTERFLY_0 (buf1[i].real, buf1[i].imag, t_r, t_i, data[k], data[254-k]);
- BUTTERFLY_0 (buf2[i].real, buf2[i].imag, t_r, t_i, data[k+1], data[255-k]);
- }
-
- ifft64 (buf1);
- ifft64 (buf2);
-
- /* Post IFFT complex multiply */
- /* Window and convert to real valued signal */
- for (i = 0; i < 32; i++) {
- /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
- t_r = post2[i].real;
- t_i = post2[i].imag;
- BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf1[i].imag, buf1[i].real);
- BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf1[63-i].imag, buf1[63-i].real);
- BUTTERFLY_0 (c_r, c_i, t_i, t_r, buf2[i].imag, buf2[i].real);
- BUTTERFLY_0 (d_r, d_i, t_r, t_i, buf2[63-i].imag, buf2[63-i].real);
-
- w_1 = window[2*i];
- w_2 = window[255-2*i];
- BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]);
- delay[2*i] = c_i;
-
- w_1 = window[128+2*i];
- w_2 = window[127-2*i];
- BUTTERFLY_B (data[128+2*i], data[127-2*i], w_1, w_2, a_i, delay[127-2*i]);
- delay[127-2*i] = c_r;
-
- w_1 = window[2*i+1];
- w_2 = window[254-2*i];
- BUTTERFLY_B (data[254-2*i], data[2*i+1], w_2, w_1, b_i, delay[2*i+1]);
- delay[2*i+1] = d_r;
-
- w_1 = window[129+2*i];
- w_2 = window[126-2*i];
- BUTTERFLY_B (data[129+2*i], data[126-2*i], w_1, w_2, b_r, delay[126-2*i]);
- delay[126-2*i] = d_i;
- }
-}
-
-static double besselI0 (double x)
-{
- double bessel = 1;
- int i = 100;
-
- do
- bessel = bessel * x / (i * i) + 1;
- while (--i);
- return bessel;
-}
-
-void a52_imdct_init (uint32_t mm_accel)
-{
- int i, k;
- double sum;
- double local_imdct_window[256];
-
- /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */
- sum = 0;
- for (i = 0; i < 256; i++) {
- sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
- local_imdct_window[i] = sum;
- }
- sum++;
- for (i = 0; i < 256; i++)
- a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum));
-
- for (i = 0; i < 3; i++)
- roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1)));
-
- for (i = 0; i < 7; i++)
- roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1)));
-
- for (i = 0; i < 15; i++)
- roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1)));
-
- for (i = 0; i < 31; i++)
- roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1)));
-
- for (i = 0; i < 64; i++) {
- k = fftorder[i] / 2 + 64;
- pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25)));
- pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25)));
- }
-
- for (i = 64; i < 128; i++) {
- k = fftorder[i] / 2 + 64;
- pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25)));
- pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25)));
- }
-
- for (i = 0; i < 64; i++) {
- post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5)));
- post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5)));
- }
-
- for (i = 0; i < 64; i++) {
- k = fftorder[i] / 4;
- pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25)));
- pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25)));
- }
-
- for (i = 0; i < 32; i++) {
- post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5)));
- post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5)));
- }
-
-#ifdef LIBA52_DJBFFT
- if (mm_accel & MM_ACCEL_DJBFFT) {
- ifft128 = (void (*) (complex_t *)) fftc4_un128;
- ifft64 = (void (*) (complex_t *)) fftc4_un64;
- } else
-#endif
- {
- ifft128 = ifft128_c;
- ifft64 = ifft64_c;
- }
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/mm_accel.h b/contrib/ffmpeg/libavcodec/liba52/mm_accel.h
deleted file mode 100644
index 9a475f5a2..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/mm_accel.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * mm_accel.h
- * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef MM_ACCEL_H
-#define MM_ACCEL_H
-
-/* generic accelerations */
-#define MM_ACCEL_DJBFFT 0x00000001
-
-/* x86 accelerations */
-#define MM_ACCEL_X86_MMX 0x80000000
-#define MM_ACCEL_X86_3DNOW 0x40000000
-#define MM_ACCEL_X86_MMXEXT 0x20000000
-#define MM_ACCEL_X86_SSE 0x10000000
-#define MM_ACCEL_X86_3DNOWEXT 0x08000000
-
-/* PPC accelerations */
-#define MM_ACCEL_PPC_ALTIVEC 0x00010000
-
-uint32_t mm_accel (void);
-
-#endif /* MM_ACCEL_H */
diff --git a/contrib/ffmpeg/libavcodec/liba52/parse.c b/contrib/ffmpeg/libavcodec/liba52/parse.c
deleted file mode 100644
index 5a0701564..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/parse.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * parse.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-#include "bitstream.h"
-#include "tables.h"
-
-#if defined(HAVE_MEMALIGN) && !defined(__cplusplus)
-/* some systems have memalign() but no declaration for it */
-void * memalign (size_t align, size_t size);
-#else
-/* assume malloc alignment is sufficient */
-#define memalign(align,size) malloc (size)
-#endif
-
-typedef struct {
- quantizer_t q1[2];
- quantizer_t q2[2];
- quantizer_t q4;
- int q1_ptr;
- int q2_ptr;
- int q4_ptr;
-} quantizer_set_t;
-
-static uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
-
-a52_state_t * a52_init (uint32_t mm_accel)
-{
- a52_state_t * state;
- int i;
-
- state = (a52_state_t *) malloc (sizeof (a52_state_t));
- if (state == NULL)
- return NULL;
-
- state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t));
- if (state->samples == NULL) {
- free (state);
- return NULL;
- }
-
- for (i = 0; i < 256 * 12; i++)
- state->samples[i] = 0;
-
- state->downmixed = 1;
-
- state->lfsr_state = 1;
-
- a52_imdct_init (mm_accel);
-
- return state;
-}
-
-sample_t * a52_samples (a52_state_t * state)
-{
- return state->samples;
-}
-
-int a52_syncinfo (uint8_t * buf, int * flags,
- int * sample_rate, int * bit_rate)
-{
- static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112,
- 128, 160, 192, 224, 256, 320, 384, 448,
- 512, 576, 640};
- static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
- int frmsizecod;
- int bitrate;
- int half;
- int acmod;
-
- if ((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */
- return 0;
-
- if (buf[5] >= 0x60) /* bsid >= 12 */
- return 0;
- half = halfrate[buf[5] >> 3];
-
- /* acmod, dsurmod and lfeon */
- acmod = buf[6] >> 5;
- *flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) |
- ((buf[6] & lfeon[acmod]) ? A52_LFE : 0));
-
- frmsizecod = buf[4] & 63;
- if (frmsizecod >= 38)
- return 0;
- bitrate = rate [frmsizecod >> 1];
- *bit_rate = (bitrate * 1000) >> half;
-
- switch (buf[4] & 0xc0) {
- case 0:
- *sample_rate = 48000 >> half;
- return 4 * bitrate;
- case 0x40:
- *sample_rate = 44100 >> half;
- return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
- case 0x80:
- *sample_rate = 32000 >> half;
- return 6 * bitrate;
- default:
- return 0;
- }
-}
-
-int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
- level_t * level, sample_t bias)
-{
- static level_t clev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_45DB),
- LEVEL (LEVEL_6DB), LEVEL (LEVEL_45DB) };
- static level_t slev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_6DB),
- 0, LEVEL (LEVEL_6DB) };
- int chaninfo;
- int acmod;
-
- state->fscod = buf[4] >> 6;
- state->halfrate = halfrate[buf[5] >> 3];
- state->acmod = acmod = buf[6] >> 5;
-
- a52_bitstream_set_ptr (state, buf + 6);
- bitstream_get (state, 3); /* skip acmod we already parsed */
-
- if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */
- acmod = A52_DOLBY;
-
- state->clev = state->slev = 0;
-
- if ((acmod & 1) && (acmod != 1))
- state->clev = clev[bitstream_get (state, 2)]; /* cmixlev */
-
- if (acmod & 4)
- state->slev = slev[bitstream_get (state, 2)]; /* surmixlev */
-
- state->lfeon = bitstream_get (state, 1);
-
- state->output = a52_downmix_init (acmod, *flags, level,
- state->clev, state->slev);
- if (state->output < 0)
- return 1;
- if (state->lfeon && (*flags & A52_LFE))
- state->output |= A52_LFE;
- *flags = state->output;
- /* the 2* compensates for differences in imdct */
- state->dynrng = state->level = MUL_C (*level, 2);
- state->bias = bias;
- state->dynrnge = 1;
- state->dynrngcall = NULL;
- state->cplba.deltbae = DELTA_BIT_NONE;
- state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae =
- state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE;
-
- chaninfo = !acmod;
- do {
- bitstream_get (state, 5); /* dialnorm */
- if (bitstream_get (state, 1)) /* compre */
- bitstream_get (state, 8); /* compr */
- if (bitstream_get (state, 1)) /* langcode */
- bitstream_get (state, 8); /* langcod */
- if (bitstream_get (state, 1)) /* audprodie */
- bitstream_get (state, 7); /* mixlevel + roomtyp */
- } while (chaninfo--);
-
- bitstream_get (state, 2); /* copyrightb + origbs */
-
- if (bitstream_get (state, 1)) /* timecod1e */
- bitstream_get (state, 14); /* timecod1 */
- if (bitstream_get (state, 1)) /* timecod2e */
- bitstream_get (state, 14); /* timecod2 */
-
- if (bitstream_get (state, 1)) { /* addbsie */
- int addbsil;
-
- addbsil = bitstream_get (state, 6);
- do {
- bitstream_get (state, 8); /* addbsi */
- } while (addbsil--);
- }
-
- return 0;
-}
-
-void a52_dynrng (a52_state_t * state,
- level_t (* call) (level_t, void *), void * data)
-{
- state->dynrnge = 0;
- if (call) {
- state->dynrnge = 1;
- state->dynrngcall = call;
- state->dynrngdata = data;
- }
-}
-
-static int parse_exponents (a52_state_t * state, int expstr, int ngrps,
- uint8_t exponent, uint8_t * dest)
-{
- int exps;
-
- while (ngrps--) {
- exps = bitstream_get (state, 7);
-
- exponent += exp_1[exps];
- if (exponent > 24)
- return 1;
-
- switch (expstr) {
- case EXP_D45:
- *(dest++) = exponent;
- *(dest++) = exponent;
- case EXP_D25:
- *(dest++) = exponent;
- case EXP_D15:
- *(dest++) = exponent;
- }
-
- exponent += exp_2[exps];
- if (exponent > 24)
- return 1;
-
- switch (expstr) {
- case EXP_D45:
- *(dest++) = exponent;
- *(dest++) = exponent;
- case EXP_D25:
- *(dest++) = exponent;
- case EXP_D15:
- *(dest++) = exponent;
- }
-
- exponent += exp_3[exps];
- if (exponent > 24)
- return 1;
-
- switch (expstr) {
- case EXP_D45:
- *(dest++) = exponent;
- *(dest++) = exponent;
- case EXP_D25:
- *(dest++) = exponent;
- case EXP_D15:
- *(dest++) = exponent;
- }
- }
-
- return 0;
-}
-
-static int parse_deltba (a52_state_t * state, int8_t * deltba)
-{
- int deltnseg, deltlen, delta, j;
-
- memset (deltba, 0, 50);
-
- deltnseg = bitstream_get (state, 3);
- j = 0;
- do {
- j += bitstream_get (state, 5);
- deltlen = bitstream_get (state, 4);
- delta = bitstream_get (state, 3);
- delta -= (delta >= 4) ? 3 : 4;
- if (!deltlen)
- continue;
- if (j + deltlen >= 50)
- return 1;
- while (deltlen--)
- deltba[j++] = delta;
- } while (deltnseg--);
-
- return 0;
-}
-
-static inline int zero_snr_offsets (int nfchans, a52_state_t * state)
-{
- int i;
-
- if ((state->csnroffst) ||
- (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */
- (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */
- return 0;
- for (i = 0; i < nfchans; i++)
- if (state->ba[i].bai >> 3) /* fsnroffst */
- return 0;
- return 1;
-}
-
-static inline int16_t dither_gen (a52_state_t * state)
-{
- int16_t nstate;
-
- nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8);
-
- state->lfsr_state = (uint16_t) nstate;
-
- return (3 * nstate) >> 2;
-}
-
-#ifndef LIBA52_FIXED
-#define COEFF(c,t,l,s,e) (c) = (t) * (s)[e]
-#else
-#define COEFF(c,_t,_l,s,e) do { \
- quantizer_t t = (_t); \
- level_t l = (_l); \
- int shift = e - 5; \
- sample_t tmp = t * (l >> 16) + ((t * (l & 0xffff)) >> 16); \
- if (shift >= 0) \
- (c) = tmp >> shift; \
- else \
- (c) = tmp << -shift; \
-} while (0)
-#endif
-
-static void coeff_get (a52_state_t * state, sample_t * coeff,
- expbap_t * expbap, quantizer_set_t * quant,
- level_t level, int dither, int end)
-{
- int i;
- uint8_t * exp;
- int8_t * bap;
-
-#ifndef LIBA52_FIXED
- sample_t factor[25];
-
- for (i = 0; i <= 24; i++)
- factor[i] = scale_factor[i] * level;
-#endif
-
- exp = expbap->exp;
- bap = expbap->bap;
-
- for (i = 0; i < end; i++) {
- int bapi;
-
- bapi = bap[i];
- switch (bapi) {
- case 0:
- if (dither) {
- COEFF (coeff[i], dither_gen (state), level, factor, exp[i]);
- continue;
- } else {
- coeff[i] = 0;
- continue;
- }
-
- case -1:
- if (quant->q1_ptr >= 0) {
- COEFF (coeff[i], quant->q1[quant->q1_ptr--], level,
- factor, exp[i]);
- continue;
- } else {
- int code;
-
- code = bitstream_get (state, 5);
-
- quant->q1_ptr = 1;
- quant->q1[0] = q_1_2[code];
- quant->q1[1] = q_1_1[code];
- COEFF (coeff[i], q_1_0[code], level, factor, exp[i]);
- continue;
- }
-
- case -2:
- if (quant->q2_ptr >= 0) {
- COEFF (coeff[i], quant->q2[quant->q2_ptr--], level,
- factor, exp[i]);
- continue;
- } else {
- int code;
-
- code = bitstream_get (state, 7);
-
- quant->q2_ptr = 1;
- quant->q2[0] = q_2_2[code];
- quant->q2[1] = q_2_1[code];
- COEFF (coeff[i], q_2_0[code], level, factor, exp[i]);
- continue;
- }
-
- case 3:
- COEFF (coeff[i], q_3[bitstream_get (state, 3)], level,
- factor, exp[i]);
- continue;
-
- case -3:
- if (quant->q4_ptr == 0) {
- quant->q4_ptr = -1;
- COEFF (coeff[i], quant->q4, level, factor, exp[i]);
- continue;
- } else {
- int code;
-
- code = bitstream_get (state, 7);
-
- quant->q4_ptr = 0;
- quant->q4 = q_4_1[code];
- COEFF (coeff[i], q_4_0[code], level, factor, exp[i]);
- continue;
- }
-
- case 4:
- COEFF (coeff[i], q_5[bitstream_get (state, 4)], level,
- factor, exp[i]);
- continue;
-
- default:
- COEFF (coeff[i], bitstream_get_2 (state, bapi) << (16 - bapi),
- level, factor, exp[i]);
- }
- }
-}
-
-static void coeff_get_coupling (a52_state_t * state, int nfchans,
- level_t * coeff, sample_t (* samples)[256],
- quantizer_set_t * quant, uint8_t dithflag[5])
-{
- int cplbndstrc, bnd, i, i_end, ch;
- uint8_t * exp;
- int8_t * bap;
- level_t cplco[5];
-
- exp = state->cpl_expbap.exp;
- bap = state->cpl_expbap.bap;
- bnd = 0;
- cplbndstrc = state->cplbndstrc;
- i = state->cplstrtmant;
- while (i < state->cplendmant) {
- i_end = i + 12;
- while (cplbndstrc & 1) {
- cplbndstrc >>= 1;
- i_end += 12;
- }
- cplbndstrc >>= 1;
- for (ch = 0; ch < nfchans; ch++)
- cplco[ch] = MUL_L (state->cplco[ch][bnd], coeff[ch]);
- bnd++;
-
- while (i < i_end) {
- quantizer_t cplcoeff;
- int bapi;
-
- bapi = bap[i];
- switch (bapi) {
- case 0:
- for (ch = 0; ch < nfchans; ch++)
- if ((state->chincpl >> ch) & 1) {
- if (dithflag[ch])
-#ifndef LIBA52_FIXED
- samples[ch][i] = (scale_factor[exp[i]] *
- cplco[ch] * dither_gen (state));
-#else
- COEFF (samples[ch][i], dither_gen (state),
- cplco[ch], scale_factor, exp[i]);
-#endif
- else
- samples[ch][i] = 0;
- }
- i++;
- continue;
-
- case -1:
- if (quant->q1_ptr >= 0) {
- cplcoeff = quant->q1[quant->q1_ptr--];
- break;
- } else {
- int code;
-
- code = bitstream_get (state, 5);
-
- quant->q1_ptr = 1;
- quant->q1[0] = q_1_2[code];
- quant->q1[1] = q_1_1[code];
- cplcoeff = q_1_0[code];
- break;
- }
-
- case -2:
- if (quant->q2_ptr >= 0) {
- cplcoeff = quant->q2[quant->q2_ptr--];
- break;
- } else {
- int code;
-
- code = bitstream_get (state, 7);
-
- quant->q2_ptr = 1;
- quant->q2[0] = q_2_2[code];
- quant->q2[1] = q_2_1[code];
- cplcoeff = q_2_0[code];
- break;
- }
-
- case 3:
- cplcoeff = q_3[bitstream_get (state, 3)];
- break;
-
- case -3:
- if (quant->q4_ptr == 0) {
- quant->q4_ptr = -1;
- cplcoeff = quant->q4;
- break;
- } else {
- int code;
-
- code = bitstream_get (state, 7);
-
- quant->q4_ptr = 0;
- quant->q4 = q_4_1[code];
- cplcoeff = q_4_0[code];
- break;
- }
-
- case 4:
- cplcoeff = q_5[bitstream_get (state, 4)];
- break;
-
- default:
- cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi);
- }
-#ifndef LIBA52_FIXED
- cplcoeff *= scale_factor[exp[i]];
-#endif
- for (ch = 0; ch < nfchans; ch++)
- if ((state->chincpl >> ch) & 1)
-#ifndef LIBA52_FIXED
- samples[ch][i] = cplcoeff * cplco[ch];
-#else
- COEFF (samples[ch][i], cplcoeff, cplco[ch],
- scale_factor, exp[i]);
-#endif
- i++;
- }
- }
-}
-
-int a52_block (a52_state_t * state)
-{
- static const uint8_t nfchans_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5, 1, 1, 2};
- static int rematrix_band[4] = {25, 37, 61, 253};
- int i, nfchans, chaninfo;
- uint8_t cplexpstr, chexpstr[5], lfeexpstr, do_bit_alloc, done_cpl;
- uint8_t blksw[5], dithflag[5];
- level_t coeff[5];
- int chanbias;
- quantizer_set_t quant;
- sample_t * samples;
-
- nfchans = nfchans_tbl[state->acmod];
-
- for (i = 0; i < nfchans; i++)
- blksw[i] = bitstream_get (state, 1);
-
- for (i = 0; i < nfchans; i++)
- dithflag[i] = bitstream_get (state, 1);
-
- chaninfo = !state->acmod;
- do {
- if (bitstream_get (state, 1)) { /* dynrnge */
- int dynrng;
-
- dynrng = bitstream_get_2 (state, 8);
- if (state->dynrnge) {
- level_t range;
-
-#if !defined(LIBA52_FIXED)
- range = ((((dynrng & 0x1f) | 0x20) << 13) *
- scale_factor[3 - (dynrng >> 5)]);
-#else
- range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5));
-#endif
- if (state->dynrngcall)
- range = state->dynrngcall (range, state->dynrngdata);
- state->dynrng = MUL_L (state->level, range);
- }
- }
- } while (chaninfo--);
-
- if (bitstream_get (state, 1)) { /* cplstre */
- state->chincpl = 0;
- if (bitstream_get (state, 1)) { /* cplinu */
- static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44,
- 45, 45, 46, 46, 47, 47, 48, 48};
- int cplbegf;
- int cplendf;
- int ncplsubnd;
-
- for (i = 0; i < nfchans; i++)
- state->chincpl |= bitstream_get (state, 1) << i;
- switch (state->acmod) {
- case 0: case 1:
- return 1;
- case 2:
- state->phsflginu = bitstream_get (state, 1);
- }
- cplbegf = bitstream_get (state, 4);
- cplendf = bitstream_get (state, 4);
-
- if (cplendf + 3 - cplbegf < 0)
- return 1;
- state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf;
- state->cplstrtbnd = bndtab[cplbegf];
- state->cplstrtmant = cplbegf * 12 + 37;
- state->cplendmant = cplendf * 12 + 73;
-
- state->cplbndstrc = 0;
- for (i = 0; i < ncplsubnd - 1; i++)
- if (bitstream_get (state, 1)) {
- state->cplbndstrc |= 1 << i;
- state->ncplbnd--;
- }
- }
- }
-
- if (state->chincpl) { /* cplinu */
- int j, cplcoe;
-
- cplcoe = 0;
- for (i = 0; i < nfchans; i++)
- if ((state->chincpl) >> i & 1)
- if (bitstream_get (state, 1)) { /* cplcoe */
- int mstrcplco, cplcoexp, cplcomant;
-
- cplcoe = 1;
- mstrcplco = 3 * bitstream_get (state, 2);
- for (j = 0; j < state->ncplbnd; j++) {
- cplcoexp = bitstream_get (state, 4);
- cplcomant = bitstream_get (state, 4);
- if (cplcoexp == 15)
- cplcomant <<= 14;
- else
- cplcomant = (cplcomant | 0x10) << 13;
-#ifndef LIBA52_FIXED
- state->cplco[i][j] =
- cplcomant * scale_factor[cplcoexp + mstrcplco];
-#else
- state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco);
-#endif
-
- }
- }
- if ((state->acmod == 2) && state->phsflginu && cplcoe)
- for (j = 0; j < state->ncplbnd; j++)
- if (bitstream_get (state, 1)) /* phsflg */
- state->cplco[1][j] = -state->cplco[1][j];
- }
-
- if ((state->acmod == 2) && (bitstream_get (state, 1))) { /* rematstr */
- int end;
-
- state->rematflg = 0;
- end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */
- i = 0;
- do
- state->rematflg |= bitstream_get (state, 1) << i;
- while (rematrix_band[i++] < end);
- }
-
- cplexpstr = EXP_REUSE;
- lfeexpstr = EXP_REUSE;
- if (state->chincpl) /* cplinu */
- cplexpstr = bitstream_get (state, 2);
- for (i = 0; i < nfchans; i++)
- chexpstr[i] = bitstream_get (state, 2);
- if (state->lfeon)
- lfeexpstr = bitstream_get (state, 1);
-
- for (i = 0; i < nfchans; i++)
- if (chexpstr[i] != EXP_REUSE) {
- if ((state->chincpl >> i) & 1)
- state->endmant[i] = state->cplstrtmant;
- else {
- int chbwcod;
-
- chbwcod = bitstream_get (state, 6);
- if (chbwcod > 60)
- return 1;
- state->endmant[i] = chbwcod * 3 + 73;
- }
- }
-
- do_bit_alloc = 0;
-
- if (cplexpstr != EXP_REUSE) {
- int cplabsexp, ncplgrps;
-
- do_bit_alloc = 64;
- ncplgrps = ((state->cplendmant - state->cplstrtmant) /
- (3 << (cplexpstr - 1)));
- cplabsexp = bitstream_get (state, 4) << 1;
- if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp,
- state->cpl_expbap.exp + state->cplstrtmant))
- return 1;
- }
- for (i = 0; i < nfchans; i++)
- if (chexpstr[i] != EXP_REUSE) {
- int grp_size, nchgrps;
-
- do_bit_alloc |= 1 << i;
- grp_size = 3 << (chexpstr[i] - 1);
- nchgrps = (state->endmant[i] + grp_size - 4) / grp_size;
- state->fbw_expbap[i].exp[0] = bitstream_get (state, 4);
- if (parse_exponents (state, chexpstr[i], nchgrps,
- state->fbw_expbap[i].exp[0],
- state->fbw_expbap[i].exp + 1))
- return 1;
- bitstream_get (state, 2); /* gainrng */
- }
- if (lfeexpstr != EXP_REUSE) {
- do_bit_alloc |= 32;
- state->lfe_expbap.exp[0] = bitstream_get (state, 4);
- if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0],
- state->lfe_expbap.exp + 1))
- return 1;
- }
-
- if (bitstream_get (state, 1)) { /* baie */
- do_bit_alloc = 127;
- state->bai = bitstream_get (state, 11);
- }
- if (bitstream_get (state, 1)) { /* snroffste */
- do_bit_alloc = 127;
- state->csnroffst = bitstream_get (state, 6);
- if (state->chincpl) /* cplinu */
- state->cplba.bai = bitstream_get (state, 7);
- for (i = 0; i < nfchans; i++)
- state->ba[i].bai = bitstream_get (state, 7);
- if (state->lfeon)
- state->lfeba.bai = bitstream_get (state, 7);
- }
- if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */
- do_bit_alloc |= 64;
- state->cplfleak = 9 - bitstream_get (state, 3);
- state->cplsleak = 9 - bitstream_get (state, 3);
- }
-
- if (bitstream_get (state, 1)) { /* deltbaie */
- do_bit_alloc = 127;
- if (state->chincpl) /* cplinu */
- state->cplba.deltbae = bitstream_get (state, 2);
- for (i = 0; i < nfchans; i++)
- state->ba[i].deltbae = bitstream_get (state, 2);
- if (state->chincpl && /* cplinu */
- (state->cplba.deltbae == DELTA_BIT_NEW) &&
- parse_deltba (state, state->cplba.deltba))
- return 1;
- for (i = 0; i < nfchans; i++)
- if ((state->ba[i].deltbae == DELTA_BIT_NEW) &&
- parse_deltba (state, state->ba[i].deltba))
- return 1;
- }
-
- if (do_bit_alloc) {
- if (zero_snr_offsets (nfchans, state)) {
- memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap));
- for (i = 0; i < nfchans; i++)
- memset (state->fbw_expbap[i].bap, 0,
- sizeof (state->fbw_expbap[i].bap));
- memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap));
- } else {
- if (state->chincpl && (do_bit_alloc & 64)) /* cplinu */
- a52_bit_allocate (state, &state->cplba, state->cplstrtbnd,
- state->cplstrtmant, state->cplendmant,
- state->cplfleak << 8, state->cplsleak << 8,
- &state->cpl_expbap);
- for (i = 0; i < nfchans; i++)
- if (do_bit_alloc & (1 << i))
- a52_bit_allocate (state, state->ba + i, 0, 0,
- state->endmant[i], 0, 0,
- state->fbw_expbap +i);
- if (state->lfeon && (do_bit_alloc & 32)) {
- state->lfeba.deltbae = DELTA_BIT_NONE;
- a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0,
- &state->lfe_expbap);
- }
- }
- }
-
- if (bitstream_get (state, 1)) { /* skiple */
- i = bitstream_get (state, 9); /* skipl */
- while (i--)
- bitstream_get (state, 8);
- }
-
- samples = state->samples;
- if (state->output & A52_LFE)
- samples += 256; /* shift for LFE channel */
-
- chanbias = a52_downmix_coeff (coeff, state->acmod, state->output,
- state->dynrng, state->clev, state->slev);
-
- quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1;
- done_cpl = 0;
-
- for (i = 0; i < nfchans; i++) {
- int j;
-
- coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant,
- coeff[i], dithflag[i], state->endmant[i]);
-
- if ((state->chincpl >> i) & 1) {
- if (!done_cpl) {
- done_cpl = 1;
- coeff_get_coupling (state, nfchans, coeff,
- (sample_t (*)[256])samples, &quant,
- dithflag);
- }
- j = state->cplendmant;
- } else
- j = state->endmant[i];
- do
- (samples + 256 * i)[j] = 0;
- while (++j < 256);
- }
-
- if (state->acmod == 2) {
- int j, end, band, rematflg;
-
- end = ((state->endmant[0] < state->endmant[1]) ?
- state->endmant[0] : state->endmant[1]);
-
- i = 0;
- j = 13;
- rematflg = state->rematflg;
- do {
- if (! (rematflg & 1)) {
- rematflg >>= 1;
- j = rematrix_band[i++];
- continue;
- }
- rematflg >>= 1;
- band = rematrix_band[i++];
- if (band > end)
- band = end;
- do {
- sample_t tmp0, tmp1;
-
- tmp0 = samples[j];
- tmp1 = (samples+256)[j];
- samples[j] = tmp0 + tmp1;
- (samples+256)[j] = tmp0 - tmp1;
- } while (++j < band);
- } while (j < end);
- }
-
- if (state->lfeon) {
- if (state->output & A52_LFE) {
- coeff_get (state, samples - 256, &state->lfe_expbap, &quant,
- state->dynrng, 0, 7);
- for (i = 7; i < 256; i++)
- (samples-256)[i] = 0;
- a52_imdct_512 (samples - 256, samples + 1536 - 256, state->bias);
- } else {
- /* just skip the LFE coefficients */
- coeff_get (state, samples + 1280, &state->lfe_expbap, &quant,
- 0, 0, 7);
- }
- }
-
- i = 0;
- if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans)
- for (i = 1; i < nfchans; i++)
- if (blksw[i] != blksw[0])
- break;
-
- if (i < nfchans) {
- if (state->downmixed) {
- state->downmixed = 0;
- a52_upmix (samples + 1536, state->acmod, state->output);
- }
-
- for (i = 0; i < nfchans; i++) {
- sample_t bias;
-
- bias = 0;
- if (!(chanbias & (1 << i)))
- bias = state->bias;
-
- if (coeff[i]) {
- if (blksw[i])
- a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,
- bias);
- else
- a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,
- bias);
- } else {
- int j;
-
- for (j = 0; j < 256; j++)
- (samples + 256 * i)[j] = bias;
- }
- }
-
- a52_downmix (samples, state->acmod, state->output, state->bias,
- state->clev, state->slev);
- } else {
- nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK];
-
- a52_downmix (samples, state->acmod, state->output, 0,
- state->clev, state->slev);
-
- if (!state->downmixed) {
- state->downmixed = 1;
- a52_downmix (samples + 1536, state->acmod, state->output, 0,
- state->clev, state->slev);
- }
-
- if (blksw[0])
- for (i = 0; i < nfchans; i++)
- a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,
- state->bias);
- else
- for (i = 0; i < nfchans; i++)
- a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,
- state->bias);
- }
-
- return 0;
-}
-
-void a52_free (a52_state_t * state)
-{
- free (state->samples);
- free (state);
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/resample.c b/contrib/ffmpeg/libavcodec/liba52/resample.c
deleted file mode 100644
index 3f06aba1f..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/resample.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * copyright (C) 2001 Arpad Gereoffy
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-// a52_resample_init should find the requested converter (from type flags ->
-// given number of channels) and set up some function pointers...
-
-// a52_resample() should do the conversion.
-
-#include "a52.h"
-#include "mm_accel.h"
-#include "config.h"
-#include "../../libpostproc/mangle.h"
-
-int (* a52_resample) (float * _f, int16_t * s16)=NULL;
-
-#include "resample_c.c"
-
-#ifdef ARCH_X86_32
-#include "resample_mmx.c"
-#endif
-
-void* a52_resample_init(uint32_t mm_accel,int flags,int chans){
-void* tmp;
-
-#ifdef ARCH_X86_32
- if(mm_accel&MM_ACCEL_X86_MMX){
- tmp=a52_resample_MMX(flags,chans);
- if(tmp){
- if(a52_resample==NULL) av_log(NULL, AV_LOG_INFO, "Using MMX optimized resampler\n");
- a52_resample=tmp;
- return tmp;
- }
- }
-#endif
-
- tmp=a52_resample_C(flags,chans);
- if(tmp){
- if(a52_resample==NULL) av_log(NULL, AV_LOG_INFO, "No accelerated resampler found\n");
- a52_resample=tmp;
- return tmp;
- }
-
- av_log(NULL, AV_LOG_ERROR, "Unimplemented resampler for mode 0x%X -> %d channels conversion - Contact MPlayer developers!\n", flags, chans);
- return NULL;
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/resample_c.c b/contrib/ffmpeg/libavcodec/liba52/resample_c.c
deleted file mode 100644
index 905146a7d..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/resample_c.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * this code is based on a52dec/libao/audio_out_oss.c
- * copyright (C) 2001 Arpad Gereoffy
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-static inline int16_t convert (int32_t i)
-{
- if (i > 0x43c07fff)
- return 32767;
- else if (i < 0x43bf8000)
- return -32768;
- else
- return i - 0x43c00000;
-}
-
-static int a52_resample_MONO_to_5_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
- s16[5*i+4] = convert (f[i]);
- }
- return 5*256;
-}
-
-static int a52_resample_MONO_to_1_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[i] = convert (f[i]);
- }
- return 1*256;
-}
-
-static int a52_resample_STEREO_to_2_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[2*i] = convert (f[i]);
- s16[2*i+1] = convert (f[i+256]);
- }
- return 2*256;
-}
-
-static int a52_resample_3F_to_5_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[5*i] = convert (f[i]);
- s16[5*i+1] = convert (f[i+512]);
- s16[5*i+2] = s16[5*i+3] = 0;
- s16[5*i+4] = convert (f[i+256]);
- }
- return 5*256;
-}
-
-static int a52_resample_2F_2R_to_4_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[4*i] = convert (f[i]);
- s16[4*i+1] = convert (f[i+256]);
- s16[4*i+2] = convert (f[i+512]);
- s16[4*i+3] = convert (f[i+768]);
- }
- return 4*256;
-}
-
-static int a52_resample_3F_2R_to_5_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[5*i] = convert (f[i]);
- s16[5*i+1] = convert (f[i+512]);
- s16[5*i+2] = convert (f[i+768]);
- s16[5*i+3] = convert (f[i+1024]);
- s16[5*i+4] = convert (f[i+256]);
- }
- return 5*256;
-}
-
-static int a52_resample_MONO_LFE_to_6_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
- s16[6*i+4] = convert (f[i+256]);
- s16[6*i+5] = convert (f[i]);
- }
- return 6*256;
-}
-
-static int a52_resample_STEREO_LFE_to_6_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+512]);
- s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
- s16[6*i+5] = convert (f[i]);
- }
- return 6*256;
-}
-
-static int a52_resample_3F_LFE_to_6_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+768]);
- s16[6*i+2] = s16[6*i+3] = 0;
- s16[6*i+4] = convert (f[i+512]);
- s16[6*i+5] = convert (f[i]);
- }
- return 6*256;
-}
-
-static int a52_resample_2F_2R_LFE_to_6_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+512]);
- s16[6*i+2] = convert (f[i+768]);
- s16[6*i+3] = convert (f[i+1024]);
- s16[6*i+4] = 0;
- s16[6*i+5] = convert (f[i]);
- }
- return 6*256;
-}
-
-static int a52_resample_3F_2R_LFE_to_6_C(float * _f, int16_t * s16){
- int i;
- int32_t * f = (int32_t *) _f;
- for (i = 0; i < 256; i++) {
- s16[6*i] = convert (f[i+256]);
- s16[6*i+1] = convert (f[i+768]);
- s16[6*i+2] = convert (f[i+1024]);
- s16[6*i+3] = convert (f[i+1280]);
- s16[6*i+4] = convert (f[i+512]);
- s16[6*i+5] = convert (f[i]);
- }
- return 6*256;
-}
-
-
-static void* a52_resample_C(int flags, int ch){
- switch (flags) {
- case A52_MONO:
- if(ch==5) return a52_resample_MONO_to_5_C;
- if(ch==1) return a52_resample_MONO_to_1_C;
- break;
- case A52_CHANNEL:
- case A52_STEREO:
- case A52_DOLBY:
- if(ch==2) return a52_resample_STEREO_to_2_C;
- break;
- case A52_3F:
- if(ch==5) return a52_resample_3F_to_5_C;
- break;
- case A52_2F2R:
- if(ch==4) return a52_resample_2F_2R_to_4_C;
- break;
- case A52_3F2R:
- if(ch==5) return a52_resample_3F_2R_to_5_C;
- break;
- case A52_MONO | A52_LFE:
- if(ch==6) return a52_resample_MONO_LFE_to_6_C;
- break;
- case A52_CHANNEL | A52_LFE:
- case A52_STEREO | A52_LFE:
- case A52_DOLBY | A52_LFE:
- if(ch==6) return a52_resample_STEREO_LFE_to_6_C;
- break;
- case A52_3F | A52_LFE:
- if(ch==6) return a52_resample_3F_LFE_to_6_C;
- break;
- case A52_2F2R | A52_LFE:
- if(ch==6) return a52_resample_2F_2R_LFE_to_6_C;
- break;
- case A52_3F2R | A52_LFE:
- if(ch==6) return a52_resample_3F_2R_LFE_to_6_C;
- break;
- }
- return NULL;
-}
diff --git a/contrib/ffmpeg/libavcodec/liba52/resample_mmx.c b/contrib/ffmpeg/libavcodec/liba52/resample_mmx.c
deleted file mode 100644
index 173c804d9..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/resample_mmx.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * resample_mmx.c
- * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* optimization TODO / NOTES
- movntq is slightly faster (0.5% with the current test.c benchmark)
- (but thats just test.c so that needs to be testd in reallity)
- and it would mean (C / MMX2 / MMX / 3DNOW) versions
-*/
-
-static uint64_t __attribute__((aligned(8))) attribute_used magicF2W= 0x43c0000043c00000LL;
-static uint64_t __attribute__((aligned(8))) attribute_used wm1010= 0xFFFF0000FFFF0000LL;
-static uint64_t __attribute__((aligned(8))) attribute_used wm0101= 0x0000FFFF0000FFFFLL;
-static uint64_t __attribute__((aligned(8))) attribute_used wm1100= 0xFFFFFFFF00000000LL;
-
-static int a52_resample_MONO_to_5_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-512, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "movq "MANGLE(wm1100)", %%mm3 \n\t"
- "movq "MANGLE(wm0101)", %%mm4 \n\t"
- "movq "MANGLE(wm1010)", %%mm5 \n\t"
- "pxor %%mm6, %%mm6 \n\t"
- "1: \n\t"
- "movq (%1, %%esi, 2), %%mm0 \n\t"
- "movq 8(%1, %%esi, 2), %%mm1 \n\t"
- "leal (%%esi, %%esi, 4), %%edi \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "pand %%mm4, %%mm0 \n\t"
- "pand %%mm5, %%mm1 \n\t"
- "movq %%mm6, (%0, %%edi) \n\t" // 0 0 0 0
- "movd %%mm0, 8(%0, %%edi) \n\t" // A 0
- "pand %%mm3, %%mm0 \n\t"
- "movd %%mm6, 12(%0, %%edi) \n\t" // 0 0
- "movd %%mm1, 16(%0, %%edi) \n\t" // 0 B
- "pand %%mm3, %%mm1 \n\t"
- "movd %%mm6, 20(%0, %%edi) \n\t" // 0 0
- "movq %%mm0, 24(%0, %%edi) \n\t" // 0 0 C 0
- "movq %%mm1, 32(%0, %%edi) \n\t" // 0 0 0 B
- "addl $8, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1280), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 5*256;
-}
-
-static int a52_resample_STEREO_to_2_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
-/* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it
-#ifdef HAVE_SSE
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "1: \n\t"
- "cvtps2pi (%1, %%esi), %%mm0 \n\t"
- "cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
- "movq %%mm0, %%mm1 \n\t"
- "punpcklwd %%mm2, %%mm0 \n\t"
- "punpckhwd %%mm2, %%mm1 \n\t"
- "movq %%mm0, (%0, %%esi) \n\t"
- "movq %%mm1, 8(%0, %%esi) \n\t"
- "addl $16, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+512), "r" (f+256)
- :"%esi", "memory"
- );*/
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "1: \n\t"
- "movq (%1, %%esi), %%mm0 \n\t"
- "movq 8(%1, %%esi), %%mm1 \n\t"
- "movq 1024(%1, %%esi), %%mm2 \n\t"
- "movq 1032(%1, %%esi), %%mm3 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "punpcklwd %%mm2, %%mm0 \n\t"
- "punpckhwd %%mm2, %%mm1 \n\t"
- "movq %%mm0, (%0, %%esi) \n\t"
- "movq %%mm1, 8(%0, %%esi) \n\t"
- "addl $16, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+512), "r" (f+256)
- :"%esi", "memory"
- );
- return 2*256;
-}
-
-static int a52_resample_3F_to_5_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "pxor %%mm6, %%mm6 \n\t"
- "movq %%mm7, %%mm5 \n\t"
- "punpckldq %%mm6, %%mm5 \n\t"
- "1: \n\t"
- "movd (%1, %%esi), %%mm0 \n\t"
- "punpckldq 2048(%1, %%esi), %%mm0\n\t"
- "movd 1024(%1, %%esi), %%mm1 \n\t"
- "punpckldq 4(%1, %%esi), %%mm1 \n\t"
- "movd 2052(%1, %%esi), %%mm2 \n\t"
- "movq %%mm7, %%mm3 \n\t"
- "punpckldq 1028(%1, %%esi), %%mm3\n\t"
- "movd 8(%1, %%esi), %%mm4 \n\t"
- "punpckldq 2056(%1, %%esi), %%mm4\n\t"
- "leal (%%esi, %%esi, 4), %%edi \n\t"
- "sarl $1, %%edi \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm5, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "psubd %%mm7, %%mm4 \n\t"
- "packssdw %%mm6, %%mm0 \n\t"
- "packssdw %%mm2, %%mm1 \n\t"
- "packssdw %%mm4, %%mm3 \n\t"
- "movq %%mm0, (%0, %%edi) \n\t"
- "movq %%mm1, 8(%0, %%edi) \n\t"
- "movq %%mm3, 16(%0, %%edi) \n\t"
-
- "movd 1032(%1, %%esi), %%mm1 \n\t"
- "punpckldq 12(%1, %%esi), %%mm1\n\t"
- "movd 2060(%1, %%esi), %%mm2 \n\t"
- "movq %%mm7, %%mm3 \n\t"
- "punpckldq 1036(%1, %%esi), %%mm3\n\t"
- "pxor %%mm0, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm5, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "movq %%mm0, 24(%0, %%edi) \n\t"
- "movq %%mm2, 32(%0, %%edi) \n\t"
-
- "addl $16, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1280), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 5*256;
-}
-
-static int a52_resample_2F_2R_to_4_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "1: \n\t"
- "movq (%1, %%esi), %%mm0 \n\t"
- "movq 8(%1, %%esi), %%mm1 \n\t"
- "movq 1024(%1, %%esi), %%mm2 \n\t"
- "movq 1032(%1, %%esi), %%mm3 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "movq 2048(%1, %%esi), %%mm3 \n\t"
- "movq 2056(%1, %%esi), %%mm4 \n\t"
- "movq 3072(%1, %%esi), %%mm5 \n\t"
- "movq 3080(%1, %%esi), %%mm6 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "psubd %%mm7, %%mm4 \n\t"
- "psubd %%mm7, %%mm5 \n\t"
- "psubd %%mm7, %%mm6 \n\t"
- "packssdw %%mm4, %%mm3 \n\t"
- "packssdw %%mm6, %%mm5 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "punpcklwd %%mm2, %%mm0 \n\t"
- "punpckhwd %%mm2, %%mm1 \n\t"
- "punpcklwd %%mm5, %%mm3 \n\t"
- "punpckhwd %%mm5, %%mm4 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm1, %%mm5 \n\t"
- "punpckldq %%mm3, %%mm0 \n\t"
- "punpckhdq %%mm3, %%mm2 \n\t"
- "punpckldq %%mm4, %%mm1 \n\t"
- "punpckhdq %%mm4, %%mm5 \n\t"
- "movq %%mm0, (%0, %%esi,2) \n\t"
- "movq %%mm2, 8(%0, %%esi,2) \n\t"
- "movq %%mm1, 16(%0, %%esi,2) \n\t"
- "movq %%mm5, 24(%0, %%esi,2) \n\t"
- "addl $16, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1024), "r" (f+256)
- :"%esi", "memory"
- );
- return 4*256;
-}
-
-static int a52_resample_3F_2R_to_5_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "1: \n\t"
- "movd (%1, %%esi), %%mm0 \n\t"
- "punpckldq 2048(%1, %%esi), %%mm0\n\t"
- "movd 3072(%1, %%esi), %%mm1 \n\t"
- "punpckldq 4096(%1, %%esi), %%mm1\n\t"
- "movd 1024(%1, %%esi), %%mm2 \n\t"
- "punpckldq 4(%1, %%esi), %%mm2 \n\t"
- "movd 2052(%1, %%esi), %%mm3 \n\t"
- "punpckldq 3076(%1, %%esi), %%mm3\n\t"
- "movd 4100(%1, %%esi), %%mm4 \n\t"
- "punpckldq 1028(%1, %%esi), %%mm4\n\t"
- "movd 8(%1, %%esi), %%mm5 \n\t"
- "punpckldq 2056(%1, %%esi), %%mm5\n\t"
- "leal (%%esi, %%esi, 4), %%edi \n\t"
- "sarl $1, %%edi \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "psubd %%mm7, %%mm4 \n\t"
- "psubd %%mm7, %%mm5 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "packssdw %%mm5, %%mm4 \n\t"
- "movq %%mm0, (%0, %%edi) \n\t"
- "movq %%mm2, 8(%0, %%edi) \n\t"
- "movq %%mm4, 16(%0, %%edi) \n\t"
-
- "movd 3080(%1, %%esi), %%mm0 \n\t"
- "punpckldq 4104(%1, %%esi), %%mm0\n\t"
- "movd 1032(%1, %%esi), %%mm1 \n\t"
- "punpckldq 12(%1, %%esi), %%mm1\n\t"
- "movd 2060(%1, %%esi), %%mm2 \n\t"
- "punpckldq 3084(%1, %%esi), %%mm2\n\t"
- "movd 4108(%1, %%esi), %%mm3 \n\t"
- "punpckldq 1036(%1, %%esi), %%mm3\n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "movq %%mm0, 24(%0, %%edi) \n\t"
- "movq %%mm2, 32(%0, %%edi) \n\t"
-
- "addl $16, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1280), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 5*256;
-}
-
-static int a52_resample_MONO_LFE_to_6_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "pxor %%mm6, %%mm6 \n\t"
- "1: \n\t"
- "movq 1024(%1, %%esi), %%mm0 \n\t"
- "movq 1032(%1, %%esi), %%mm1 \n\t"
- "movq (%1, %%esi), %%mm2 \n\t"
- "movq 8(%1, %%esi), %%mm3 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "punpcklwd %%mm2, %%mm0 \n\t"
- "punpckhwd %%mm2, %%mm1 \n\t"
- "leal (%%esi, %%esi, 2), %%edi \n\t"
- "movq %%mm6, (%0, %%edi) \n\t"
- "movd %%mm0, 8(%0, %%edi) \n\t"
- "punpckhdq %%mm0, %%mm0 \n\t"
- "movq %%mm6, 12(%0, %%edi) \n\t"
- "movd %%mm0, 20(%0, %%edi) \n\t"
- "movq %%mm6, 24(%0, %%edi) \n\t"
- "movd %%mm1, 32(%0, %%edi) \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movq %%mm6, 36(%0, %%edi) \n\t"
- "movd %%mm1, 44(%0, %%edi) \n\t"
- "addl $16, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1536), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 6*256;
-}
-
-static int a52_resample_STEREO_LFE_to_6_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "pxor %%mm6, %%mm6 \n\t"
- "1: \n\t"
- "movq 1024(%1, %%esi), %%mm0 \n\t"
- "movq 2048(%1, %%esi), %%mm1 \n\t"
- "movq (%1, %%esi), %%mm5 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm5 \n\t"
- "leal (%%esi, %%esi, 2), %%edi \n\t"
-
- "pxor %%mm4, %%mm4 \n\t"
- "packssdw %%mm5, %%mm0 \n\t" // FfAa
- "packssdw %%mm4, %%mm1 \n\t" // 00Bb
- "punpckhwd %%mm0, %%mm4 \n\t" // F0f0
- "punpcklwd %%mm1, %%mm0 \n\t" // BAba
- "movq %%mm0, %%mm1 \n\t" // BAba
- "punpckldq %%mm4, %%mm3 \n\t" // f0XX
- "punpckldq %%mm6, %%mm0 \n\t" // 00ba
- "punpckhdq %%mm1, %%mm3 \n\t" // BAf0
-
- "movq %%mm0, (%0, %%edi) \n\t" // 00ba
- "punpckhdq %%mm4, %%mm0 \n\t" // F000
- "movq %%mm3, 8(%0, %%edi) \n\t" // BAf0
- "movq %%mm0, 16(%0, %%edi) \n\t" // F000
- "addl $8, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1536), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 6*256;
-}
-
-static int a52_resample_3F_LFE_to_6_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
- "pxor %%mm6, %%mm6 \n\t"
- "1: \n\t"
- "movq 1024(%1, %%esi), %%mm0 \n\t"
- "movq 3072(%1, %%esi), %%mm1 \n\t"
- "movq 2048(%1, %%esi), %%mm4 \n\t"
- "movq (%1, %%esi), %%mm5 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm4 \n\t"
- "psubd %%mm7, %%mm5 \n\t"
- "leal (%%esi, %%esi, 2), %%edi \n\t"
-
- "packssdw %%mm4, %%mm0 \n\t" // EeAa
- "packssdw %%mm5, %%mm1 \n\t" // FfBb
- "movq %%mm0, %%mm2 \n\t" // EeAa
- "punpcklwd %%mm1, %%mm0 \n\t" // BAba
- "punpckhwd %%mm1, %%mm2 \n\t" // FEfe
- "movq %%mm0, %%mm1 \n\t" // BAba
- "punpckldq %%mm6, %%mm0 \n\t" // 00ba
- "punpckhdq %%mm1, %%mm1 \n\t" // BABA
-
- "movq %%mm0, (%0, %%edi) \n\t"
- "punpckhdq %%mm2, %%mm0 \n\t" // FE00
- "punpckldq %%mm1, %%mm2 \n\t" // BAfe
- "movq %%mm2, 8(%0, %%edi) \n\t"
- "movq %%mm0, 16(%0, %%edi) \n\t"
- "addl $8, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1536), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 6*256;
-}
-
-static int a52_resample_2F_2R_LFE_to_6_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
-// "pxor %%mm6, %%mm6 \n\t"
- "1: \n\t"
- "movq 1024(%1, %%esi), %%mm0 \n\t"
- "movq 2048(%1, %%esi), %%mm1 \n\t"
- "movq 3072(%1, %%esi), %%mm2 \n\t"
- "movq 4096(%1, %%esi), %%mm3 \n\t"
- "movq (%1, %%esi), %%mm5 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "psubd %%mm7, %%mm5 \n\t"
- "leal (%%esi, %%esi, 2), %%edi \n\t"
-
- "packssdw %%mm2, %%mm0 \n\t" // CcAa
- "packssdw %%mm3, %%mm1 \n\t" // DdBb
- "packssdw %%mm5, %%mm5 \n\t" // FfFf
- "movq %%mm0, %%mm2 \n\t" // CcAa
- "punpcklwd %%mm1, %%mm0 \n\t" // BAba
- "punpckhwd %%mm1, %%mm2 \n\t" // DCdc
- "pxor %%mm4, %%mm4 \n\t" // 0000
- "punpcklwd %%mm5, %%mm4 \n\t" // F0f0
- "movq %%mm0, %%mm1 \n\t" // BAba
- "movq %%mm4, %%mm3 \n\t" // F0f0
- "punpckldq %%mm2, %%mm0 \n\t" // dcba
- "punpckhdq %%mm1, %%mm1 \n\t" // BABA
- "punpckldq %%mm1, %%mm4 \n\t" // BAf0
- "punpckhdq %%mm3, %%mm2 \n\t" // F0DC
-
- "movq %%mm0, (%0, %%edi) \n\t"
- "movq %%mm4, 8(%0, %%edi) \n\t"
- "movq %%mm2, 16(%0, %%edi) \n\t"
- "addl $8, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1536), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 6*256;
-}
-
-static int a52_resample_3F_2R_LFE_to_6_MMX(float * _f, int16_t * s16){
- int32_t * f = (int32_t *) _f;
- asm volatile(
- "movl $-1024, %%esi \n\t"
- "movq "MANGLE(magicF2W)", %%mm7 \n\t"
-// "pxor %%mm6, %%mm6 \n\t"
- "1: \n\t"
- "movq 1024(%1, %%esi), %%mm0 \n\t"
- "movq 3072(%1, %%esi), %%mm1 \n\t"
- "movq 4096(%1, %%esi), %%mm2 \n\t"
- "movq 5120(%1, %%esi), %%mm3 \n\t"
- "movq 2048(%1, %%esi), %%mm4 \n\t"
- "movq (%1, %%esi), %%mm5 \n\t"
- "psubd %%mm7, %%mm0 \n\t"
- "psubd %%mm7, %%mm1 \n\t"
- "psubd %%mm7, %%mm2 \n\t"
- "psubd %%mm7, %%mm3 \n\t"
- "psubd %%mm7, %%mm4 \n\t"
- "psubd %%mm7, %%mm5 \n\t"
- "leal (%%esi, %%esi, 2), %%edi \n\t"
-
- "packssdw %%mm2, %%mm0 \n\t" // CcAa
- "packssdw %%mm3, %%mm1 \n\t" // DdBb
- "packssdw %%mm4, %%mm4 \n\t" // EeEe
- "packssdw %%mm5, %%mm5 \n\t" // FfFf
- "movq %%mm0, %%mm2 \n\t" // CcAa
- "punpcklwd %%mm1, %%mm0 \n\t" // BAba
- "punpckhwd %%mm1, %%mm2 \n\t" // DCdc
- "punpcklwd %%mm5, %%mm4 \n\t" // FEfe
- "movq %%mm0, %%mm1 \n\t" // BAba
- "movq %%mm4, %%mm3 \n\t" // FEfe
- "punpckldq %%mm2, %%mm0 \n\t" // dcba
- "punpckhdq %%mm1, %%mm1 \n\t" // BABA
- "punpckldq %%mm1, %%mm4 \n\t" // BAfe
- "punpckhdq %%mm3, %%mm2 \n\t" // FEDC
-
- "movq %%mm0, (%0, %%edi) \n\t"
- "movq %%mm4, 8(%0, %%edi) \n\t"
- "movq %%mm2, 16(%0, %%edi) \n\t"
- "addl $8, %%esi \n\t"
- " jnz 1b \n\t"
- "emms \n\t"
- :: "r" (s16+1536), "r" (f+256)
- :"%esi", "%edi", "memory"
- );
- return 6*256;
-}
-
-
-static void* a52_resample_MMX(int flags, int ch){
- switch (flags) {
- case A52_MONO:
- if(ch==5) return a52_resample_MONO_to_5_MMX;
- break;
- case A52_CHANNEL:
- case A52_STEREO:
- case A52_DOLBY:
- if(ch==2) return a52_resample_STEREO_to_2_MMX;
- break;
- case A52_3F:
- if(ch==5) return a52_resample_3F_to_5_MMX;
- break;
- case A52_2F2R:
- if(ch==4) return a52_resample_2F_2R_to_4_MMX;
- break;
- case A52_3F2R:
- if(ch==5) return a52_resample_3F_2R_to_5_MMX;
- break;
- case A52_MONO | A52_LFE:
- if(ch==6) return a52_resample_MONO_LFE_to_6_MMX;
- break;
- case A52_CHANNEL | A52_LFE:
- case A52_STEREO | A52_LFE:
- case A52_DOLBY | A52_LFE:
- if(ch==6) return a52_resample_STEREO_LFE_to_6_MMX;
- break;
- case A52_3F | A52_LFE:
- if(ch==6) return a52_resample_3F_LFE_to_6_MMX;
- break;
- case A52_2F2R | A52_LFE:
- if(ch==6) return a52_resample_2F_2R_LFE_to_6_MMX;
- break;
- case A52_3F2R | A52_LFE:
- if(ch==6) return a52_resample_3F_2R_LFE_to_6_MMX;
- break;
- }
- return NULL;
-}
-
-
diff --git a/contrib/ffmpeg/libavcodec/liba52/tables.h b/contrib/ffmpeg/libavcodec/liba52/tables.h
deleted file mode 100644
index 7f921c9d0..000000000
--- a/contrib/ffmpeg/libavcodec/liba52/tables.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * tables.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * a52dec is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-static const int8_t exp_1[128] = {
- -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 25,25,25
-};
-static const int8_t exp_2[128] = {
- -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- 25,25,25
-};
-static const int8_t exp_3[128] = {
- -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
- -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
- -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
- -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
- -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
- 25,25,25
-};
-
-#define Q(x) ROUND (32768.0 * x)
-
-#define Q0 Q (-2/3)
-#define Q1 Q (0)
-#define Q2 Q (2/3)
-
-static const quantizer_t q_1_0[32] = {
- Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
- Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
- Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
- 0, 0, 0, 0, 0
-};
-
-static const quantizer_t q_1_1[32] = {
- Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
- Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
- Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
- 0, 0, 0, 0, 0
-};
-
-static const quantizer_t q_1_2[32] = {
- Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
- Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
- Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
- 0, 0, 0, 0, 0
-};
-
-#undef Q0
-#undef Q1
-#undef Q2
-
-#define Q0 Q (-4/5)
-#define Q1 Q (-2/5)
-#define Q2 Q (0)
-#define Q3 Q (2/5)
-#define Q4 Q (4/5)
-
-static const quantizer_t q_2_0[128] = {
- Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
- Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,
- Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
- Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,
- Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,
- 0,0,0
-};
-
-static const quantizer_t q_2_1[128] = {
- Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
- Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
- Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
- Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
- Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
- 0,0,0
-};
-
-static const quantizer_t q_2_2[128] = {
- Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
- Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
- Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
- Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
- Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
- 0,0,0
-};
-
-#undef Q0
-#undef Q1
-#undef Q2
-#undef Q3
-#undef Q4
-
-static const quantizer_t q_3[8] = {
- Q (-6/7), Q (-4/7), Q (-2/7), Q (0), Q (2/7), Q (4/7), Q (6/7), 0
-};
-
-#define Q0 Q (-10/11)
-#define Q1 Q (-8/11)
-#define Q2 Q (-6/11)
-#define Q3 Q (-4/11)
-#define Q4 Q (-2/11)
-#define Q5 Q (0)
-#define Q6 Q (2/11)
-#define Q7 Q (4/11)
-#define Q8 Q (6/11)
-#define Q9 Q (8/11)
-#define QA Q (10/11)
-
-static const quantizer_t q_4_0[128] = {
- Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
- Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
- Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
- Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3,
- Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4,
- Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5,
- Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6,
- Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7,
- Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8,
- Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9,
- QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA,
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const quantizer_t q_4_1[128] = {
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
- 0, 0, 0, 0, 0, 0, 0
-};
-
-#undef Q0
-#undef Q1
-#undef Q2
-#undef Q3
-#undef Q4
-#undef Q5
-#undef Q6
-#undef Q7
-#undef Q8
-#undef Q9
-#undef QA
-
-static const quantizer_t q_5[16] = {
- Q (-14/15), Q (-12/15), Q (-10/15), Q (-8/15), Q (-6/15),
- Q (-4/15), Q (-2/15), Q (0), Q (2/15), Q (4/15),
- Q (6/15), Q (8/15), Q (10/15), Q (12/15), Q (14/15), 0
-};
-
-#ifndef LIBA52_FIXED
-static const sample_t scale_factor[25] = {
- 0.000030517578125,
- 0.0000152587890625,
- 0.00000762939453125,
- 0.000003814697265625,
- 0.0000019073486328125,
- 0.00000095367431640625,
- 0.000000476837158203125,
- 0.0000002384185791015625,
- 0.00000011920928955078125,
- 0.000000059604644775390625,
- 0.0000000298023223876953125,
- 0.00000001490116119384765625,
- 0.000000007450580596923828125,
- 0.0000000037252902984619140625,
- 0.00000000186264514923095703125,
- 0.000000000931322574615478515625,
- 0.0000000004656612873077392578125,
- 0.00000000023283064365386962890625,
- 0.000000000116415321826934814453125,
- 0.0000000000582076609134674072265625,
- 0.00000000002910383045673370361328125,
- 0.000000000014551915228366851806640625,
- 0.0000000000072759576141834259033203125,
- 0.00000000000363797880709171295166015625,
- 0.000000000001818989403545856475830078125
-};
-#endif
-
-static const uint16_t dither_lut[256] = {
- 0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055,
- 0xc0ee, 0x60ff, 0x20dd, 0x80cc, 0xa099, 0x0088, 0x40aa, 0xe0bb,
- 0x21cd, 0x81dc, 0xc1fe, 0x61ef, 0x41ba, 0xe1ab, 0xa189, 0x0198,
- 0xe123, 0x4132, 0x0110, 0xa101, 0x8154, 0x2145, 0x6167, 0xc176,
- 0x439a, 0xe38b, 0xa3a9, 0x03b8, 0x23ed, 0x83fc, 0xc3de, 0x63cf,
- 0x8374, 0x2365, 0x6347, 0xc356, 0xe303, 0x4312, 0x0330, 0xa321,
- 0x6257, 0xc246, 0x8264, 0x2275, 0x0220, 0xa231, 0xe213, 0x4202,
- 0xa2b9, 0x02a8, 0x428a, 0xe29b, 0xc2ce, 0x62df, 0x22fd, 0x82ec,
- 0x8734, 0x2725, 0x6707, 0xc716, 0xe743, 0x4752, 0x0770, 0xa761,
- 0x47da, 0xe7cb, 0xa7e9, 0x07f8, 0x27ad, 0x87bc, 0xc79e, 0x678f,
- 0xa6f9, 0x06e8, 0x46ca, 0xe6db, 0xc68e, 0x669f, 0x26bd, 0x86ac,
- 0x6617, 0xc606, 0x8624, 0x2635, 0x0660, 0xa671, 0xe653, 0x4642,
- 0xc4ae, 0x64bf, 0x249d, 0x848c, 0xa4d9, 0x04c8, 0x44ea, 0xe4fb,
- 0x0440, 0xa451, 0xe473, 0x4462, 0x6437, 0xc426, 0x8404, 0x2415,
- 0xe563, 0x4572, 0x0550, 0xa541, 0x8514, 0x2505, 0x6527, 0xc536,
- 0x258d, 0x859c, 0xc5be, 0x65af, 0x45fa, 0xe5eb, 0xa5c9, 0x05d8,
- 0xae79, 0x0e68, 0x4e4a, 0xee5b, 0xce0e, 0x6e1f, 0x2e3d, 0x8e2c,
- 0x6e97, 0xce86, 0x8ea4, 0x2eb5, 0x0ee0, 0xaef1, 0xeed3, 0x4ec2,
- 0x8fb4, 0x2fa5, 0x6f87, 0xcf96, 0xefc3, 0x4fd2, 0x0ff0, 0xafe1,
- 0x4f5a, 0xef4b, 0xaf69, 0x0f78, 0x2f2d, 0x8f3c, 0xcf1e, 0x6f0f,
- 0xede3, 0x4df2, 0x0dd0, 0xadc1, 0x8d94, 0x2d85, 0x6da7, 0xcdb6,
- 0x2d0d, 0x8d1c, 0xcd3e, 0x6d2f, 0x4d7a, 0xed6b, 0xad49, 0x0d58,
- 0xcc2e, 0x6c3f, 0x2c1d, 0x8c0c, 0xac59, 0x0c48, 0x4c6a, 0xec7b,
- 0x0cc0, 0xacd1, 0xecf3, 0x4ce2, 0x6cb7, 0xcca6, 0x8c84, 0x2c95,
- 0x294d, 0x895c, 0xc97e, 0x696f, 0x493a, 0xe92b, 0xa909, 0x0918,
- 0xe9a3, 0x49b2, 0x0990, 0xa981, 0x89d4, 0x29c5, 0x69e7, 0xc9f6,
- 0x0880, 0xa891, 0xe8b3, 0x48a2, 0x68f7, 0xc8e6, 0x88c4, 0x28d5,
- 0xc86e, 0x687f, 0x285d, 0x884c, 0xa819, 0x0808, 0x482a, 0xe83b,
- 0x6ad7, 0xcac6, 0x8ae4, 0x2af5, 0x0aa0, 0xaab1, 0xea93, 0x4a82,
- 0xaa39, 0x0a28, 0x4a0a, 0xea1b, 0xca4e, 0x6a5f, 0x2a7d, 0x8a6c,
- 0x4b1a, 0xeb0b, 0xab29, 0x0b38, 0x2b6d, 0x8b7c, 0xcb5e, 0x6b4f,
- 0x8bf4, 0x2be5, 0x6bc7, 0xcbd6, 0xeb83, 0x4b92, 0x0bb0, 0xaba1
-};
diff --git a/contrib/ffmpeg/libavcodec/libgsm.c b/contrib/ffmpeg/libavcodec/libgsm.c
index 7cf59be7a..86dfce575 100644
--- a/contrib/ffmpeg/libavcodec/libgsm.c
+++ b/contrib/ffmpeg/libavcodec/libgsm.c
@@ -1,6 +1,7 @@
/*
* Interface to libgsm for gsm encoding/decoding
* Copyright (c) 2005 Alban Bedel <albeu@free.fr>
+ * Copyright (c) 2006, 2007 Michel Bardiaux <mbardiaux@mediaxim.be>
*
* This file is part of FFmpeg.
*
@@ -24,22 +25,35 @@
* Interface to libgsm for gsm encoding/decoding
*/
+// The idiosyncrasies of GSM-in-WAV are explained at http://kbs.cs.tu-berlin.de/~jutta/toast.html
+
#include "avcodec.h"
#include <gsm.h>
// gsm.h miss some essential constants
#define GSM_BLOCK_SIZE 33
+#define GSM_MS_BLOCK_SIZE 65
#define GSM_FRAME_SIZE 160
static int libgsm_init(AVCodecContext *avctx) {
- if (avctx->channels > 1 || avctx->sample_rate != 8000)
+ if (avctx->channels > 1 || avctx->sample_rate != 8000 || avctx->bit_rate != 13000)
return -1;
- avctx->frame_size = GSM_FRAME_SIZE;
- avctx->block_align = GSM_BLOCK_SIZE;
-
avctx->priv_data = gsm_create();
+ switch(avctx->codec_id) {
+ case CODEC_ID_GSM:
+ avctx->frame_size = GSM_FRAME_SIZE;
+ avctx->block_align = GSM_BLOCK_SIZE;
+ break;
+ case CODEC_ID_GSM_MS: {
+ int one = 1;
+ gsm_option(avctx->priv_data, GSM_OPT_WAV49, &one);
+ avctx->frame_size = 2*GSM_FRAME_SIZE;
+ avctx->block_align = GSM_MS_BLOCK_SIZE;
+ }
+ }
+
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;
@@ -55,11 +69,17 @@ static int libgsm_close(AVCodecContext *avctx) {
static int libgsm_encode_frame(AVCodecContext *avctx,
unsigned char *frame, int buf_size, void *data) {
// we need a full block
- if(buf_size < GSM_BLOCK_SIZE) return 0;
-
- gsm_encode(avctx->priv_data,data,frame);
-
- return GSM_BLOCK_SIZE;
+ if(buf_size < avctx->block_align) return 0;
+
+ switch(avctx->codec_id) {
+ case CODEC_ID_GSM:
+ gsm_encode(avctx->priv_data,data,frame);
+ break;
+ case CODEC_ID_GSM_MS:
+ gsm_encode(avctx->priv_data,data,frame);
+ gsm_encode(avctx->priv_data,((short*)data)+GSM_FRAME_SIZE,frame+32);
+ }
+ return avctx->block_align;
}
@@ -73,16 +93,33 @@ AVCodec libgsm_encoder = {
libgsm_close,
};
+AVCodec libgsm_ms_encoder = {
+ "gsm",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_GSM_MS,
+ 0,
+ libgsm_init,
+ libgsm_encode_frame,
+ libgsm_close,
+};
+
static int libgsm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size) {
- if(buf_size < GSM_BLOCK_SIZE) return 0;
-
- if(gsm_decode(avctx->priv_data,buf,data)) return -1;
-
- *data_size = GSM_FRAME_SIZE*2;
- return GSM_BLOCK_SIZE;
+ if(buf_size < avctx->block_align) return 0;
+
+ switch(avctx->codec_id) {
+ case CODEC_ID_GSM:
+ if(gsm_decode(avctx->priv_data,buf,data)) return -1;
+ *data_size = GSM_FRAME_SIZE*sizeof(int16_t);
+ break;
+ case CODEC_ID_GSM_MS:
+ if(gsm_decode(avctx->priv_data,buf,data) ||
+ gsm_decode(avctx->priv_data,buf+33,((int16_t*)data)+GSM_FRAME_SIZE)) return -1;
+ *data_size = GSM_FRAME_SIZE*sizeof(int16_t)*2;
+ }
+ return avctx->block_align;
}
AVCodec libgsm_decoder = {
@@ -95,3 +132,14 @@ AVCodec libgsm_decoder = {
libgsm_close,
libgsm_decode_frame,
};
+
+AVCodec libgsm_ms_decoder = {
+ "gsm_ms",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_GSM_MS,
+ 0,
+ libgsm_init,
+ NULL,
+ libgsm_close,
+ libgsm_decode_frame,
+};
diff --git a/contrib/ffmpeg/libavcodec/libtheoraenc.c b/contrib/ffmpeg/libavcodec/libtheoraenc.c
new file mode 100644
index 000000000..7f531dbee
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/libtheoraenc.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2006 Paul Richards <paul.richards@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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*!
+ * \file theoraenc.c
+ * \brief Theora encoder using libtheora.
+ * \author Paul Richards <paul.richards@gmail.com>
+ *
+ * A lot of this is copy / paste from other output codecs in
+ * libavcodec or pure guesswork (or both).
+ *
+ * I have used t_ prefixes on variables which are libtheora types
+ * and o_ prefixes on variables which are libogg types.
+ */
+
+/* FFmpeg includes */
+#include "avcodec.h"
+#include "log.h"
+
+/* libtheora includes */
+#include <theora/theora.h>
+
+typedef struct TheoraContext{
+ theora_state t_state;
+} TheoraContext;
+
+/*!
+ Concatenates an ogg_packet into the extradata.
+*/
+static int concatenate_packet(unsigned int* offset, AVCodecContext* avc_context, const ogg_packet* packet)
+{
+ char* message = NULL;
+ uint8_t* newdata = NULL;
+ int newsize = avc_context->extradata_size + 2 + packet->bytes;
+
+ if (packet->bytes < 0) {
+ message = "ogg_packet has negative size";
+ } else if (packet->bytes > 0xffff) {
+ message = "ogg_packet is larger than 65535 bytes";
+ } else if (newsize < avc_context->extradata_size) {
+ message = "extradata_size would overflow";
+ } else {
+ newdata = av_realloc(avc_context->extradata, newsize);
+ if (newdata == NULL) {
+ message = "av_realloc failed";
+ }
+ }
+ if (message != NULL) {
+ av_log(avc_context, AV_LOG_ERROR, "concatenate_packet failed: %s\n", message);
+ return -1;
+ }
+
+ avc_context->extradata = newdata;
+ avc_context->extradata_size = newsize;
+ avc_context->extradata[ (*offset)++ ] = packet->bytes >> 8;
+ avc_context->extradata[ (*offset)++ ] = packet->bytes & 0xff;
+ memcpy( avc_context->extradata + (*offset), packet->packet, packet->bytes );
+ (*offset) += packet->bytes;
+ return 0;
+}
+
+static int encode_init(AVCodecContext* avc_context)
+{
+ theora_info t_info;
+ theora_comment t_comment;
+ ogg_packet o_packet;
+ unsigned int offset;
+ TheoraContext *h = avc_context->priv_data;
+
+ /* Set up the theora_info struct */
+ theora_info_init( &t_info );
+ t_info.width = avc_context->width;
+ t_info.height = avc_context->height;
+ t_info.frame_width = avc_context->width;
+ t_info.frame_height = avc_context->height;
+ t_info.offset_x = 0;
+ t_info.offset_y = 0;
+ /* Swap numerator and denominator as time_base in AVCodecContext gives the
+ * time period between frames, but theora_info needs the framerate. */
+ t_info.fps_numerator = avc_context->time_base.den;
+ t_info.fps_denominator = avc_context->time_base.num;
+ if (avc_context->sample_aspect_ratio.num != 0) {
+ t_info.aspect_numerator = avc_context->sample_aspect_ratio.num;
+ t_info.aspect_denominator = avc_context->sample_aspect_ratio.den;
+ } else {
+ t_info.aspect_numerator = 1;
+ t_info.aspect_denominator = 1;
+ }
+ t_info.colorspace = OC_CS_UNSPECIFIED;
+ t_info.pixelformat = OC_PF_420;
+ t_info.target_bitrate = avc_context->bit_rate;
+ t_info.keyframe_frequency = avc_context->gop_size;
+ t_info.keyframe_frequency_force = avc_context->gop_size;
+ t_info.keyframe_mindistance = avc_context->keyint_min;
+ t_info.quality = 0;
+
+ t_info.quick_p = 1;
+ t_info.dropframes_p = 0;
+ t_info.keyframe_auto_p = 1;
+ t_info.keyframe_data_target_bitrate = t_info.target_bitrate * 1.5;
+ t_info.keyframe_auto_threshold = 80;
+ t_info.noise_sensitivity = 1;
+ t_info.sharpness = 0;
+
+ /* Now initialise libtheora */
+ if (theora_encode_init( &(h->t_state), &t_info ) != 0) {
+ av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
+ return -1;
+ }
+
+ /* Clear up theora_info struct */
+ theora_info_clear( &t_info );
+
+ /*
+ Output first header packet consisting of theora
+ header, comment, and tables.
+
+ Each one is prefixed with a 16bit size, then they
+ are concatenated together into ffmpeg's extradata.
+ */
+ offset = 0;
+
+ /* Header */
+ theora_encode_header( &(h->t_state), &o_packet );
+ if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
+ return -1;
+ }
+
+ /* Comment */
+ theora_comment_init( &t_comment );
+ theora_encode_comment( &t_comment, &o_packet );
+ if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
+ return -1;
+ }
+
+ /* Tables */
+ theora_encode_tables( &(h->t_state), &o_packet );
+ if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
+ return -1;
+ }
+
+ /* Clear up theora_comment struct */
+ theora_comment_clear( &t_comment );
+
+ /* Set up the output AVFrame */
+ avc_context->coded_frame= avcodec_alloc_frame();
+
+ return 0;
+}
+
+static int encode_frame(
+ AVCodecContext* avc_context,
+ uint8_t *outbuf,
+ int buf_size,
+ void *data)
+{
+ yuv_buffer t_yuv_buffer;
+ TheoraContext *h = avc_context->priv_data;
+ AVFrame *frame = data;
+ ogg_packet o_packet;
+ int result;
+
+ assert(avc_context->pix_fmt == PIX_FMT_YUV420P);
+
+ /* Copy planes to the theora yuv_buffer */
+ if (frame->linesize[1] != frame->linesize[2]) {
+ av_log(avc_context, AV_LOG_ERROR, "U and V stride differ\n");
+ return -1;
+ }
+
+ t_yuv_buffer.y_width = avc_context->width;
+ t_yuv_buffer.y_height = avc_context->height;
+ t_yuv_buffer.y_stride = frame->linesize[0];
+ t_yuv_buffer.uv_width = t_yuv_buffer.y_width / 2;
+ t_yuv_buffer.uv_height = t_yuv_buffer.y_height / 2;
+ t_yuv_buffer.uv_stride = frame->linesize[1];
+
+ t_yuv_buffer.y = frame->data[0];
+ t_yuv_buffer.u = frame->data[1];
+ t_yuv_buffer.v = frame->data[2];
+
+ /* Now call into theora_encode_YUVin */
+ result = theora_encode_YUVin( &(h->t_state), &t_yuv_buffer );
+ if (result != 0) {
+ const char* message;
+ switch (result) {
+ case -1:
+ message = "differing frame sizes";
+ break;
+ case OC_EINVAL:
+ message = "encoder is not ready or is finished";
+ break;
+ default:
+ message = "unknown reason";
+ break;
+ }
+ av_log(avc_context, AV_LOG_ERROR, "theora_encode_YUVin failed (%s) [%d]\n", message, result);
+ return -1;
+ }
+
+ /* Pick up returned ogg_packet */
+ result = theora_encode_packetout( &(h->t_state), 0, &o_packet );
+ switch (result) {
+ case 0:
+ /* No packet is ready */
+ return 0;
+ case 1:
+ /* Success, we have a packet */
+ break;
+ default:
+ av_log(avc_context, AV_LOG_ERROR, "theora_encode_packetout failed [%d]\n", result);
+ return -1;
+ }
+
+ /* Copy ogg_packet content out to buffer */
+ if (buf_size < o_packet.bytes) {
+ av_log(avc_context, AV_LOG_ERROR, "encoded frame too large\n");
+ return -1;
+ }
+ memcpy(outbuf, o_packet.packet, o_packet.bytes);
+
+ return o_packet.bytes;
+}
+
+static int encode_close(AVCodecContext* avc_context)
+{
+ ogg_packet o_packet;
+ TheoraContext *h = avc_context->priv_data;
+ int result;
+ const char* message;
+
+ result = theora_encode_packetout( &(h->t_state), 1, &o_packet );
+ theora_clear( &(h->t_state) );
+ switch (result) {
+ case 0:/* No packet is ready */
+ case -1:/* Encoding finished */
+ return 0;
+ case 1:
+ /* We have a packet */
+ message = "gave us a packet";
+ break;
+ default:
+ message = "unknown reason";
+ break;
+ }
+ av_log(avc_context, AV_LOG_ERROR, "theora_encode_packetout failed (%s) [%d]\n", message, result);
+ return -1;
+}
+
+static const enum PixelFormat supported_pixel_formats[] = { PIX_FMT_YUV420P, -1 };
+
+/*! AVCodec struct exposed to libavcodec */
+AVCodec libtheora_encoder =
+{
+ .name = "libtheora",
+ .type = CODEC_TYPE_VIDEO,
+ .id = CODEC_ID_THEORA,
+ .priv_data_size = sizeof(TheoraContext),
+ .init = encode_init,
+ .close = encode_close,
+ .encode = encode_frame,
+ .pix_fmts = supported_pixel_formats,
+};
diff --git a/contrib/ffmpeg/libavcodec/loco.c b/contrib/ffmpeg/libavcodec/loco.c
index 2ec850ed0..760699d45 100644
--- a/contrib/ffmpeg/libavcodec/loco.c
+++ b/contrib/ffmpeg/libavcodec/loco.c
@@ -237,20 +237,20 @@ static int decode_init(AVCodecContext *avctx){
avctx->extradata_size);
return -1;
}
- version = LE_32(avctx->extradata);
+ version = AV_RL32(avctx->extradata);
switch(version) {
case 1:
l->lossy = 0;
break;
case 2:
- l->lossy = LE_32(avctx->extradata + 8);
+ l->lossy = AV_RL32(avctx->extradata + 8);
break;
default:
- l->lossy = LE_32(avctx->extradata + 8);
+ l->lossy = AV_RL32(avctx->extradata + 8);
av_log(avctx, AV_LOG_INFO, "This is LOCO codec version %i, please upload file for study\n", version);
}
- l->mode = LE_32(avctx->extradata + 4);
+ l->mode = AV_RL32(avctx->extradata + 4);
switch(l->mode) {
case LOCO_CYUY2: case LOCO_YUY2: case LOCO_UYVY:
avctx->pix_fmt = PIX_FMT_YUV422P;
@@ -262,7 +262,7 @@ static int decode_init(AVCodecContext *avctx){
avctx->pix_fmt = PIX_FMT_YUV420P;
break;
case LOCO_CRGBA: case LOCO_RGBA:
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
break;
default:
av_log(avctx, AV_LOG_INFO, "Unknown colorspace, index = %i\n", l->mode);
diff --git a/contrib/ffmpeg/libavcodec/lzw.c b/contrib/ffmpeg/libavcodec/lzw.c
index b5bb33a21..6bc0b9a48 100644
--- a/contrib/ffmpeg/libavcodec/lzw.c
+++ b/contrib/ffmpeg/libavcodec/lzw.c
@@ -42,7 +42,6 @@ static const uint16_t mask[17] =
};
struct LZWState {
- int eob_reached;
uint8_t *pbuf, *ebuf;
int bbits;
unsigned int bbuf;
@@ -55,7 +54,7 @@ struct LZWState {
int end_code;
int newcodes; ///< First available code
int top_slot; ///< Highest code for current size
- int top_slot2; ///< Highest possible code for current size (<=top_slot)
+ int extra_slot;
int slot; ///< Last read code
int fc, oc;
uint8_t *sp;
@@ -68,35 +67,28 @@ struct LZWState {
/* get one code from stream */
static int lzw_get_code(struct LZWState * s)
{
- int c, sizbuf;
+ int c;
if(s->mode == FF_LZW_GIF) {
while (s->bbits < s->cursize) {
if (!s->bs) {
- sizbuf = *s->pbuf++;
- s->bs = sizbuf;
- if(!sizbuf) {
- s->eob_reached = 1;
- }
+ s->bs = *s->pbuf++;
}
s->bbuf |= (*s->pbuf++) << s->bbits;
s->bbits += 8;
s->bs--;
}
- c = s->bbuf & s->curmask;
- s->bbuf >>= s->cursize;
+ c = s->bbuf;
+ s->bbuf >>= s->cursize;
} else { // TIFF
while (s->bbits < s->cursize) {
- if (s->pbuf >= s->ebuf) {
- s->eob_reached = 1;
- }
s->bbuf = (s->bbuf << 8) | (*s->pbuf++);
s->bbits += 8;
}
- c = (s->bbuf >> (s->bbits - s->cursize)) & s->curmask;
+ c = s->bbuf >> (s->bbits - s->cursize);
}
s->bbits -= s->cursize;
- return c;
+ return c & s->curmask;
}
uint8_t* ff_lzw_cur_ptr(LZWState *p)
@@ -107,8 +99,14 @@ uint8_t* ff_lzw_cur_ptr(LZWState *p)
void ff_lzw_decode_tail(LZWState *p)
{
struct LZWState *s = (struct LZWState *)p;
- while(!s->eob_reached)
- lzw_get_code(s);
+
+ if(s->mode == FF_LZW_GIF) {
+ while(s->pbuf < s->ebuf && s->bs>0){
+ s->pbuf += s->bs;
+ s->bs = *s->pbuf++;
+ }
+ }else
+ s->pbuf= s->ebuf;
}
void ff_lzw_decode_open(LZWState **p)
@@ -136,7 +134,6 @@ int ff_lzw_decode_init(LZWState *p, int csize, uint8_t *buf, int buf_size, int m
if(csize < 1 || csize > LZW_MAXBITS)
return -1;
/* read buffer */
- s->eob_reached = 0;
s->pbuf = buf;
s->ebuf = s->pbuf + buf_size;
s->bbuf = 0;
@@ -151,20 +148,11 @@ int ff_lzw_decode_init(LZWState *p, int csize, uint8_t *buf, int buf_size, int m
s->clear_code = 1 << s->codesize;
s->end_code = s->clear_code + 1;
s->slot = s->newcodes = s->clear_code + 2;
- s->oc = s->fc = 0;
+ s->oc = s->fc = -1;
s->sp = s->stack;
s->mode = mode;
- switch(s->mode){
- case FF_LZW_GIF:
- s->top_slot2 = s->top_slot;
- break;
- case FF_LZW_TIFF:
- s->top_slot2 = s->top_slot - 1;
- break;
- default:
- return -1;
- }
+ s->extra_slot = s->mode == FF_LZW_TIFF;
return 0;
}
@@ -191,69 +179,48 @@ int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){
oc = s->oc;
fc = s->fc;
- while (sp > s->stack) {
- *buf++ = *(--sp);
- if ((--l) == 0)
- goto the_end;
- }
-
for (;;) {
+ while (sp > s->stack) {
+ *buf++ = *(--sp);
+ if ((--l) == 0)
+ goto the_end;
+ }
c = lzw_get_code(s);
if (c == s->end_code) {
- s->end_code = -1;
break;
} else if (c == s->clear_code) {
s->cursize = s->codesize + 1;
s->curmask = mask[s->cursize];
s->slot = s->newcodes;
s->top_slot = 1 << s->cursize;
- s->top_slot2 = s->top_slot;
- if(s->mode == FF_LZW_TIFF)
- s->top_slot2--;
- while ((c = lzw_get_code(s)) == s->clear_code);
- if (c == s->end_code) {
- s->end_code = -1;
- break;
- }
- /* test error */
- if (c >= s->slot)
- c = 0;
- fc = oc = c;
- *buf++ = c;
- if ((--l) == 0)
- break;
+ fc= oc= -1;
} else {
code = c;
- if (code >= s->slot) {
+ if (code == s->slot && fc>=0) {
*sp++ = fc;
code = oc;
- }
+ }else if(code >= s->slot)
+ break;
while (code >= s->newcodes) {
*sp++ = s->suffix[code];
code = s->prefix[code];
}
*sp++ = code;
- if (s->slot < s->top_slot) {
- s->suffix[s->slot] = fc = code;
+ if (s->slot < s->top_slot && oc>=0) {
+ s->suffix[s->slot] = code;
s->prefix[s->slot++] = oc;
- oc = c;
}
- if (s->slot >= s->top_slot2) {
+ fc = code;
+ oc = c;
+ if (s->slot >= s->top_slot - s->extra_slot) {
if (s->cursize < LZW_MAXBITS) {
s->top_slot <<= 1;
- s->top_slot2 = s->top_slot;
- if(s->mode == FF_LZW_TIFF)
- s->top_slot2--;
s->curmask = mask[++s->cursize];
}
}
- while (sp > s->stack) {
- *buf++ = *(--sp);
- if ((--l) == 0)
- goto the_end;
- }
}
}
+ s->end_code = -1;
the_end:
s->sp = sp;
s->oc = oc;
diff --git a/contrib/ffmpeg/libavcodec/mathops.h b/contrib/ffmpeg/libavcodec/mathops.h
index 9ae34d71b..c6ec70597 100644
--- a/contrib/ffmpeg/libavcodec/mathops.h
+++ b/contrib/ffmpeg/libavcodec/mathops.h
@@ -46,7 +46,7 @@
//gcc 3.4 creates an incredibly bloated mess out of this
//# define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32)
-static always_inline int MULH(int a, int b){
+static av_always_inline int MULH(int a, int b){
return ((int64_t)(a) * (int64_t)(b))>>32;
}
#endif
diff --git a/contrib/ffmpeg/libavcodec/mjpeg.c b/contrib/ffmpeg/libavcodec/mjpeg.c
index 3d8383e7b..e3583e54e 100644
--- a/contrib/ffmpeg/libavcodec/mjpeg.c
+++ b/contrib/ffmpeg/libavcodec/mjpeg.c
@@ -441,7 +441,7 @@ void mjpeg_picture_header(MpegEncContext *s)
}
put_bits(&s->pb, 16, 17);
- if(lossless && s->avctx->pix_fmt == PIX_FMT_RGBA32)
+ if(lossless && s->avctx->pix_fmt == PIX_FMT_RGB32)
put_bits(&s->pb, 8, 9); /* 9 bits/component RCT */
else
put_bits(&s->pb, 8, 8); /* 8 bits/component */
@@ -700,7 +700,7 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in
s->header_bits= put_bits_count(&s->pb);
- if(avctx->pix_fmt == PIX_FMT_RGBA32){
+ if(avctx->pix_fmt == PIX_FMT_RGB32){
int x, y, i;
const int linesize= p->linesize[0];
uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
@@ -901,7 +901,7 @@ typedef struct MJpegDecodeContext {
int cur_scan; /* current scan, used by JPEG-LS */
} MJpegDecodeContext;
-#include "jpeg_ls.c" //FIXME make jpeg-ls more independant
+#include "jpeg_ls.c" //FIXME make jpeg-ls more independent
static int mjpeg_decode_dht(MJpegDecodeContext *s);
@@ -965,6 +965,13 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
mjpeg_decode_dht(s);
/* should check for error - but dunno */
}
+ if (avctx->extradata_size > 9 &&
+ AV_RL32(avctx->extradata + 4) == MKTAG('f','i','e','l')) {
+ if (avctx->extradata[9] == 6) { /* quicktime icefloe 019 */
+ s->interlace_polarity = 1; /* bottom field first */
+ av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
+ }
+ }
return 0;
}
@@ -1043,13 +1050,13 @@ static int mjpeg_decode_dqt(MJpegDecodeContext *s)
/* only 8 bit precision handled */
if (get_bits(&s->gb, 4) != 0)
{
- dprintf("dqt: 16bit precision\n");
+ av_log(s->avctx, AV_LOG_ERROR, "dqt: 16bit precision\n");
return -1;
}
index = get_bits(&s->gb, 4);
if (index >= 4)
return -1;
- dprintf("index=%d\n", index);
+ av_log(s->avctx, AV_LOG_DEBUG, "index=%d\n", index);
/* read quant table */
for(i=0;i<64;i++) {
j = s->scantable.permutated[i];
@@ -1060,7 +1067,7 @@ static int mjpeg_decode_dqt(MJpegDecodeContext *s)
s->qscale[index]= FFMAX(
s->quant_matrixes[index][s->scantable.permutated[1]],
s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
- dprintf("qscale[%d]: %d\n", index, s->qscale[index]);
+ av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n", index, s->qscale[index]);
len -= 65;
}
@@ -1105,7 +1112,7 @@ static int mjpeg_decode_dht(MJpegDecodeContext *s)
/* build VLC and flush previous vlc if present */
free_vlc(&s->vlcs[class][index]);
- dprintf("class=%d index=%d nb_codes=%d\n",
+ av_log(s->avctx, AV_LOG_DEBUG, "class=%d index=%d nb_codes=%d\n",
class, index, code_max + 1);
if(build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1, 0, class > 0) < 0){
return -1;
@@ -1133,7 +1140,7 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
height = get_bits(&s->gb, 16);
width = get_bits(&s->gb, 16);
- dprintf("sof0: picture: %dx%d\n", width, height);
+ av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
if(avcodec_check_dimensions(s->avctx, width, height))
return -1;
@@ -1161,8 +1168,8 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return -1;
- dprintf("component %d %d:%d id: %d quant:%d\n", i, s->h_count[i],
- s->v_count[i], s->component_id[i], s->quant_index[i]);
+ av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n", i, s->h_count[i],
+ s->v_count[i], s->component_id[i], s->quant_index[i]);
}
if(s->ls && (s->h_max > 1 || s->v_max > 1)) {
@@ -1185,8 +1192,9 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
s->org_height != 0 &&
s->height < ((s->org_height * 3) / 4)) {
s->interlaced = 1;
-// s->bottom_field = (s->interlace_polarity) ? 1 : 0;
- s->bottom_field = 0;
+ s->bottom_field = s->interlace_polarity;
+ s->picture.interlaced_frame = 1;
+ s->picture.top_field_first = !s->interlace_polarity;
height *= 2;
}
@@ -1197,19 +1205,19 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
s->first_picture = 0;
}
- if(s->interlaced && s->bottom_field)
+ if(s->interlaced && (s->bottom_field == !s->interlace_polarity))
return 0;
/* XXX: not complete test ! */
pix_fmt_id = (s->h_count[0] << 20) | (s->v_count[0] << 16) |
(s->h_count[1] << 12) | (s->v_count[1] << 8) |
(s->h_count[2] << 4) | s->v_count[2];
- dprintf("pix fmt id %x\n", pix_fmt_id);
+ av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
switch(pix_fmt_id){
case 0x222222:
case 0x111111:
if(s->rgb){
- s->avctx->pix_fmt = PIX_FMT_RGBA32;
+ s->avctx->pix_fmt = PIX_FMT_RGB32;
}else if(s->nb_components==3)
s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV444P : PIX_FMT_YUVJ444P;
else
@@ -1252,7 +1260,7 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
if (len != (8+(3*nb_components)))
{
- dprintf("decode_sof0: error, len(%d) mismatch\n", len);
+ av_log(s->avctx, AV_LOG_DEBUG, "decode_sof0: error, len(%d) mismatch\n", len);
}
/* totally blank picture as progressive JPEG will only add details to it */
@@ -1270,8 +1278,8 @@ static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
if (code < 0)
{
- dprintf("mjpeg_decode_dc: bad vlc: %d:%d (%p)\n", 0, dc_index,
- &s->vlcs[0][dc_index]);
+ av_log(s->avctx, AV_LOG_WARNING, "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n", 0, dc_index,
+ &s->vlcs[0][dc_index]);
return 0xffff;
}
@@ -1290,7 +1298,7 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
/* DC coef */
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xffff) {
- dprintf("error dc\n");
+ av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return -1;
}
val = val * quant_matrix[0] + s->last_dc[component];
@@ -1326,7 +1334,7 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
block[j] = level * quant_matrix[j];
break;
}
- dprintf("error count: %d\n", i);
+ av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
@@ -1349,7 +1357,7 @@ static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block,
if(!ss){
val = mjpeg_decode_dc(s, dc_index);
if (val == 0xffff) {
- dprintf("error dc\n");
+ av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
return -1;
}
val = (val * quant_matrix[0] << Al) + s->last_dc[component];
@@ -1389,7 +1397,7 @@ static int decode_block_progressive(MJpegDecodeContext *s, DCTELEM *block,
block[j] = level * quant_matrix[j] << Al;
break;
}
- dprintf("error count: %d\n", i);
+ av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return -1;
}
j = s->scantable.permutated[i];
@@ -1590,16 +1598,16 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int ss, i
if (!s->progressive && decode_block(s, s->block, i,
s->dc_index[i], s->ac_index[i],
s->quant_matrixes[ s->quant_index[c] ]) < 0) {
- dprintf("error y=%d x=%d\n", mb_y, mb_x);
+ av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x);
return -1;
}
if (s->progressive && decode_block_progressive(s, s->block, i,
s->dc_index[i], s->ac_index[i],
s->quant_matrixes[ s->quant_index[c] ], ss, se, Ah, Al, &EOBRUN) < 0) {
- dprintf("error y=%d x=%d\n", mb_y, mb_x);
+ av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x);
return -1;
}
-// dprintf("mb: %d %d processed\n", mb_y, mb_x);
+// av_log(s->avctx, AV_LOG_DEBUG, "mb: %d %d processed\n", mb_y, mb_x);
ptr = s->picture.data[c] +
(((s->linesize[c] * (v * mb_y + y) * 8) +
(h * mb_x + x) * 8) >> s->avctx->lowres);
@@ -1641,21 +1649,21 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s)
nb_components = get_bits(&s->gb, 8);
if (len != 6+2*nb_components)
{
- dprintf("decode_sos: invalid len (%d)\n", len);
+ av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
return -1;
}
vmax = 0;
hmax = 0;
for(i=0;i<nb_components;i++) {
id = get_bits(&s->gb, 8) - 1;
- dprintf("component: %d\n", id);
+ av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
/* find component index */
for(index=0;index<s->nb_components;index++)
if (id == s->component_id[index])
break;
if (index == s->nb_components)
{
- dprintf("decode_sos: index(%d) out of components\n", index);
+ av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
return -1;
}
@@ -1745,7 +1753,7 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s)
emms_c();
return 0;
out_of_range:
- dprintf("decode_sos: ac/dc index out of range\n");
+ av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
return -1;
}
@@ -1755,7 +1763,7 @@ static int mjpeg_decode_dri(MJpegDecodeContext *s)
return -1;
s->restart_interval = get_bits(&s->gb, 16);
s->restart_count = 0;
- dprintf("restart interval: %d\n", s->restart_interval);
+ av_log(s->avctx, AV_LOG_DEBUG, "restart interval: %d\n", s->restart_interval);
return 0;
}
@@ -1989,7 +1997,7 @@ static int find_marker(uint8_t **pbuf_ptr, uint8_t *buf_end)
val = -1;
found:
#ifdef DEBUG
- dprintf("find_marker skipped %d bytes\n", skipped);
+ av_log(NULL, AV_LOG_VERBOSE, "find_marker skipped %d bytes\n", skipped);
#endif
*pbuf_ptr = buf_ptr;
return val;
@@ -2014,14 +2022,14 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
if (start_code < 0) {
goto the_end;
} else {
- dprintf("marker=%x avail_size_in_buf=%d\n", start_code, buf_end - buf_ptr);
+ av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%d\n", start_code, buf_end - buf_ptr);
if ((buf_end - buf_ptr) > s->buffer_size)
{
av_free(s->buffer);
s->buffer_size = buf_end-buf_ptr;
s->buffer = av_malloc(s->buffer_size + FF_INPUT_BUFFER_PADDING_SIZE);
- dprintf("buffer too small, expanding to %d bytes\n",
+ av_log(avctx, AV_LOG_DEBUG, "buffer too small, expanding to %d bytes\n",
s->buffer_size);
}
@@ -2036,21 +2044,23 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
uint8_t x = *(src++);
*(dst++) = x;
- if (x == 0xff)
+ if (avctx->codec_id != CODEC_ID_THP)
{
- while(src<buf_end && x == 0xff)
- x = *(src++);
-
- if (x >= 0xd0 && x <= 0xd7)
- *(dst++) = x;
- else if (x)
- break;
+ if (x == 0xff) {
+ while (src < buf_end && x == 0xff)
+ x = *(src++);
+
+ if (x >= 0xd0 && x <= 0xd7)
+ *(dst++) = x;
+ else if (x)
+ break;
+ }
}
}
init_get_bits(&s->gb, s->buffer, (dst - s->buffer)*8);
- dprintf("escaping removed %d bytes\n",
- (buf_end - buf_ptr) - (dst - s->buffer));
+ av_log(avctx, AV_LOG_DEBUG, "escaping removed %d bytes\n",
+ (buf_end - buf_ptr) - (dst - s->buffer));
}
else if(start_code == SOS && s->ls){
uint8_t *src = buf_ptr;
@@ -2096,12 +2106,12 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
s->start_code = start_code;
if(s->avctx->debug & FF_DEBUG_STARTCODE){
- av_log(s->avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
+ av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
}
/* process markers */
if (start_code >= 0xd0 && start_code <= 0xd7) {
- dprintf("restart marker: %d\n", start_code&0x0f);
+ av_log(avctx, AV_LOG_DEBUG, "restart marker: %d\n", start_code&0x0f);
/* APP fields */
} else if (start_code >= APP0 && start_code <= APP15) {
mjpeg_decode_app(s);
@@ -2122,24 +2132,27 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
break;
case DHT:
if(mjpeg_decode_dht(s) < 0){
- av_log(s->avctx, AV_LOG_ERROR, "huffman table decode error\n");
+ av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n");
return -1;
}
break;
case SOF0:
s->lossless=0;
+ s->ls=0;
s->progressive=0;
if (mjpeg_decode_sof(s) < 0)
return -1;
break;
case SOF2:
s->lossless=0;
+ s->ls=0;
s->progressive=1;
if (mjpeg_decode_sof(s) < 0)
return -1;
break;
case SOF3:
s->lossless=1;
+ s->ls=0;
s->progressive=0;
if (mjpeg_decode_sof(s) < 0)
return -1;
@@ -2164,7 +2177,7 @@ eoi_parser:
if (s->interlaced) {
s->bottom_field ^= 1;
/* if not bottom field, do not output image yet */
- if (s->bottom_field)
+ if (s->bottom_field == !s->interlace_polarity)
goto not_the_end;
}
*picture = s->picture;
@@ -2176,7 +2189,7 @@ eoi_parser:
picture->qscale_table= s->qscale_table;
memset(picture->qscale_table, picture->quality, (s->width+15)/16);
if(avctx->debug & FF_DEBUG_QP)
- av_log(s->avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
+ av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
picture->quality*= FF_QP2LAMBDA;
}
@@ -2204,7 +2217,7 @@ eoi_parser:
case SOF14:
case SOF15:
case JPG:
- av_log(s->avctx, AV_LOG_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code);
+ av_log(avctx, AV_LOG_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code);
break;
// default:
// printf("mjpeg: unsupported marker (%x)\n", start_code);
@@ -2214,13 +2227,13 @@ eoi_parser:
not_the_end:
/* eof process start code */
buf_ptr += (get_bits_count(&s->gb)+7)/8;
- dprintf("marker parser used %d bytes (%d bits)\n",
- (get_bits_count(&s->gb)+7)/8, get_bits_count(&s->gb));
+ av_log(avctx, AV_LOG_DEBUG, "marker parser used %d bytes (%d bits)\n",
+ (get_bits_count(&s->gb)+7)/8, get_bits_count(&s->gb));
}
}
}
the_end:
- dprintf("mjpeg decode frame unused %d bytes\n", buf_end - buf_ptr);
+ av_log(avctx, AV_LOG_DEBUG, "mjpeg decode frame unused %d bytes\n", buf_end - buf_ptr);
// return buf_end - buf_ptr;
return buf_ptr - buf;
}
@@ -2249,22 +2262,22 @@ read_header:
skip_bits(&hgb, 32); /* reserved zeros */
- if (get_bits_long(&hgb, 32) != be2me_32(ff_get_fourcc("mjpg")))
+ if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
{
- dprintf("not mjpeg-b (bad fourcc)\n");
+ av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
return 0;
}
field_size = get_bits_long(&hgb, 32); /* field size */
- dprintf("field size: 0x%x\n", field_size);
+ av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\n", field_size);
skip_bits(&hgb, 32); /* padded field size */
second_field_offs = get_bits_long(&hgb, 32);
- dprintf("second field offs: 0x%x\n", second_field_offs);
+ av_log(avctx, AV_LOG_DEBUG, "second field offs: 0x%x\n", second_field_offs);
if (second_field_offs)
s->interlaced = 1;
dqt_offs = get_bits_long(&hgb, 32);
- dprintf("dqt offs: 0x%x\n", dqt_offs);
+ av_log(avctx, AV_LOG_DEBUG, "dqt offs: 0x%x\n", dqt_offs);
if (dqt_offs)
{
init_get_bits(&s->gb, buf+dqt_offs, (buf_end - (buf+dqt_offs))*8);
@@ -2273,7 +2286,7 @@ read_header:
}
dht_offs = get_bits_long(&hgb, 32);
- dprintf("dht offs: 0x%x\n", dht_offs);
+ av_log(avctx, AV_LOG_DEBUG, "dht offs: 0x%x\n", dht_offs);
if (dht_offs)
{
init_get_bits(&s->gb, buf+dht_offs, (buf_end - (buf+dht_offs))*8);
@@ -2282,7 +2295,7 @@ read_header:
}
sof_offs = get_bits_long(&hgb, 32);
- dprintf("sof offs: 0x%x\n", sof_offs);
+ av_log(avctx, AV_LOG_DEBUG, "sof offs: 0x%x\n", sof_offs);
if (sof_offs)
{
init_get_bits(&s->gb, buf+sof_offs, (buf_end - (buf+sof_offs))*8);
@@ -2292,9 +2305,9 @@ read_header:
}
sos_offs = get_bits_long(&hgb, 32);
- dprintf("sos offs: 0x%x\n", sos_offs);
+ av_log(avctx, AV_LOG_DEBUG, "sos offs: 0x%x\n", sos_offs);
sod_offs = get_bits_long(&hgb, 32);
- dprintf("sod offs: 0x%x\n", sod_offs);
+ av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
if (sos_offs)
{
// init_get_bits(&s->gb, buf+sos_offs, (buf_end - (buf+sos_offs))*8);
@@ -2540,12 +2553,12 @@ static int mjpega_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *av
break;
case SOS:
bytestream_put_be32(&poutbufp, i + 46); /* scan off */
- bytestream_put_be32(&poutbufp, i + 46 + BE_16(buf + i + 2)); /* data off */
+ bytestream_put_be32(&poutbufp, i + 46 + AV_RB16(buf + i + 2)); /* data off */
bytestream_put_buffer(&poutbufp, buf + 2, buf_size - 2); /* skip already written SOI */
*poutbuf_size = poutbufp - *poutbuf;
return 1;
case APP1:
- if (i + 8 < buf_size && LE_32(buf + i + 8) == ff_get_fourcc("mjpg")) {
+ if (i + 8 < buf_size && AV_RL32(buf + i + 8) == ff_get_fourcc("mjpg")) {
av_log(avctx, AV_LOG_ERROR, "bitstream already formatted\n");
memcpy(*poutbuf, buf, buf_size);
*poutbuf_size = buf_size;
@@ -2572,6 +2585,19 @@ AVCodec mjpeg_decoder = {
NULL
};
+AVCodec thp_decoder = {
+ "thp",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_THP,
+ sizeof(MJpegDecodeContext),
+ mjpeg_decode_init,
+ NULL,
+ mjpeg_decode_end,
+ mjpeg_decode_frame,
+ CODEC_CAP_DR1,
+ NULL
+};
+
AVCodec mjpegb_decoder = {
"mjpegb",
CODEC_TYPE_VIDEO,
diff --git a/contrib/ffmpeg/libavcodec/mmvideo.c b/contrib/ffmpeg/libavcodec/mmvideo.c
index 07d3f3fc5..7ba1321cb 100644
--- a/contrib/ffmpeg/libavcodec/mmvideo.c
+++ b/contrib/ffmpeg/libavcodec/mmvideo.c
@@ -110,7 +110,7 @@ static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const
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 + LE_16(&buf[0]);
+ const int data_ptr = 2 + AV_RL16(&buf[0]);
int d, r, y;
d = data_ptr; r = 2; y = 0;
@@ -162,7 +162,7 @@ static int mm_decode_frame(AVCodecContext *avctx,
palette_control->palette_changed = 0;
}
- type = LE_16(&buf[0]);
+ type = AV_RL16(&buf[0]);
buf += MM_PREAMBLE_SIZE;
buf_size -= MM_PREAMBLE_SIZE;
diff --git a/contrib/ffmpeg/libavcodec/motion_est.c b/contrib/ffmpeg/libavcodec/motion_est.c
index 4dc17b99b..a042f4916 100644
--- a/contrib/ffmpeg/libavcodec/motion_est.c
+++ b/contrib/ffmpeg/libavcodec/motion_est.c
@@ -103,7 +103,10 @@ static int get_flags(MotionEstContext *c, int direct, int chroma){
+ (chroma ? FLAG_CHROMA : 0);
}
-static always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
+/*! \brief compares a block (either a full macroblock or a partition thereof)
+ against a proposed motion-compensated prediction of that block
+ */
+static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
const int size, const int h, int ref_index, int src_index,
me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
MotionEstContext * const c= &s->me;
@@ -119,6 +122,7 @@ static always_inline int cmp(MpegEncContext *s, const int x, const int y, const
int d;
//FIXME check chroma 4mv, (no crashes ...)
if(flags&FLAG_DIRECT){
+ assert(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1));
if(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1)){
const int time_pp= s->pp_time;
const int time_pb= s->pb_time;
@@ -230,8 +234,14 @@ static void zero_hpel(uint8_t *a, const uint8_t *b, int stride, int h){
void ff_init_me(MpegEncContext *s){
MotionEstContext * const c= &s->me;
+ int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT);
+ int dia_size= FFMAX(FFABS(s->avctx->dia_size)&255, FFABS(s->avctx->pre_dia_size)&255);
c->avctx= s->avctx;
+ if(cache_size < 2*dia_size && !c->stride){
+ av_log(s->avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n");
+ }
+
ff_set_cmp(&s->dsp, s->dsp.me_pre_cmp, c->avctx->me_pre_cmp);
ff_set_cmp(&s->dsp, s->dsp.me_cmp, c->avctx->me_cmp);
ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, c->avctx->me_sub_cmp);
@@ -689,6 +699,7 @@ static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4)
static inline void get_limits(MpegEncContext *s, int x, int y)
{
MotionEstContext * const c= &s->me;
+ int range= c->avctx->me_range >> (1 + !!(c->flags&FLAG_QPEL));
/*
if(c->avctx->me_range) c->range= c->avctx->me_range >> 1;
else c->range= 16;
@@ -710,6 +721,12 @@ static inline void get_limits(MpegEncContext *s, int x, int y)
c->xmax = - x + s->mb_width *16 - 16;
c->ymax = - y + s->mb_height*16 - 16;
}
+ if(range){
+ c->xmin = FFMAX(c->xmin,-range);
+ c->xmax = FFMIN(c->xmax, range);
+ c->ymin = FFMAX(c->ymin,-range);
+ c->ymax = FFMIN(c->ymax, range);
+ }
}
static inline void init_mv4_ref(MotionEstContext *c){
@@ -1145,7 +1162,9 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
{
MotionEstContext * const c= &s->me;
uint8_t *pix, *ppix;
- int sum, varc, vard, mx, my, dmin;
+ int sum, mx, my, dmin;
+ int varc; ///< the variance of the block (sum of squared (p[y][x]-average))
+ int vard; ///< sum of squared differences with the estimated motion vector
int P[10][2];
const int shift= 1+s->quarter_sample;
int mb_type=0;
@@ -1782,15 +1801,15 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y)
c->pred_x=0;
c->pred_y=0;
- P_LEFT[0] = clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
- P_LEFT[1] = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
+ P_LEFT[0] = av_clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
+ P_LEFT[1] = av_clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
/* special case for first line */
- if (!s->first_slice_line) { //FIXME maybe allow this over thread boundary as its cliped
- P_TOP[0] = clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift);
- P_TOP[1] = clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift);
- P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift);
- P_TOPRIGHT[1] = clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift);
+ if (!s->first_slice_line) { //FIXME maybe allow this over thread boundary as its clipped
+ P_TOP[0] = av_clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift);
+ P_TOP[1] = av_clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift);
+ P_TOPRIGHT[0] = av_clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift);
+ P_TOPRIGHT[1] = av_clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift);
P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
@@ -1807,8 +1826,8 @@ static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y)
get_limits(s, 16*mb_x, 16*mb_y); //restore c->?min/max, maybe not needed
- s->b_direct_mv_table[mot_xy][0]= mx;
- s->b_direct_mv_table[mot_xy][1]= my;
+ mv_table[mot_xy][0]= mx;
+ mv_table[mot_xy][1]= my;
c->flags &= ~FLAG_DIRECT;
c->sub_flags &= ~FLAG_DIRECT;
@@ -1828,6 +1847,18 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
get_limits(s, 16*mb_x, 16*mb_y);
c->skip=0;
+
+ if(s->codec_id == CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]){
+ int score= direct_search(s, mb_x, mb_y); //FIXME just check 0,0
+
+ score= ((unsigned)(score*score + 128*256))>>16;
+ c->mc_mb_var_sum_temp += score;
+ s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE
+ s->mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_DIRECT0;
+
+ return;
+ }
+
if(c->avctx->me_threshold){
int vard= check_input_motion(s, mb_x, mb_y, 0);
@@ -1950,6 +1981,8 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
}
//FIXME something smarter
if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT; //dont try direct mode if its invalid for this MB
+ if(s->codec_id == CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT && s->flags&CODEC_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy])
+ type |= CANDIDATE_MB_TYPE_DIRECT0;
#if 0
if(s->out_format == FMT_MPEG1)
type |= CANDIDATE_MB_TYPE_INTRA;
diff --git a/contrib/ffmpeg/libavcodec/motion_est_template.c b/contrib/ffmpeg/libavcodec/motion_est_template.c
index 193a8b24e..37443b022 100644
--- a/contrib/ffmpeg/libavcodec/motion_est_template.c
+++ b/contrib/ffmpeg/libavcodec/motion_est_template.c
@@ -515,7 +515,7 @@ static int qpel_motion_search(MpegEncContext * s,
}\
}
-#define CHECK_CLIPED_MV(ax,ay)\
+#define CHECK_CLIPPED_MV(ax,ay)\
{\
const int Lx= ax;\
const int Ly= ay;\
@@ -555,7 +555,7 @@ if( (y)>(ymax<<(S)) ) printf("%d %d %d %d %d ymax" #v, ymax, (x), (y), s->mb_x,
const int qpel= flags&FLAG_QPEL;\
const int shift= 1+qpel;\
-static always_inline int small_diamond_search(MpegEncContext * s, int *best, int dmin,
+static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
{
@@ -658,6 +658,78 @@ if(256*256*256*64 % (stats[0]+1)==0){
return dmin;
}
+static int hex_search(MpegEncContext * s, int *best, int dmin,
+ int src_index, int ref_index, int const penalty_factor,
+ int size, int h, int flags, int dia_size)
+{
+ MotionEstContext * const c= &s->me;
+ me_cmp_func cmpf, chroma_cmpf;
+ LOAD_COMMON
+ LOAD_COMMON2
+ int map_generation= c->map_generation;
+ int x,y,d;
+ const int dec= dia_size & (dia_size-1);
+
+ cmpf= s->dsp.me_cmp[size];
+ chroma_cmpf= s->dsp.me_cmp[size+1];
+
+ for(;dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){
+ do{
+ x= best[0];
+ y= best[1];
+
+ CHECK_CLIPPED_MV(x -dia_size , y);
+ CHECK_CLIPPED_MV(x+ dia_size , y);
+ CHECK_CLIPPED_MV(x+( dia_size>>1), y+dia_size);
+ CHECK_CLIPPED_MV(x+( dia_size>>1), y-dia_size);
+ if(dia_size>1){
+ CHECK_CLIPPED_MV(x+(-dia_size>>1), y+dia_size);
+ CHECK_CLIPPED_MV(x+(-dia_size>>1), y-dia_size);
+ }
+ }while(best[0] != x || best[1] != y);
+ }
+
+ return dmin;
+}
+
+static int l2s_dia_search(MpegEncContext * s, int *best, int dmin,
+ int src_index, int ref_index, int const penalty_factor,
+ int size, int h, int flags)
+{
+ MotionEstContext * const c= &s->me;
+ me_cmp_func cmpf, chroma_cmpf;
+ LOAD_COMMON
+ LOAD_COMMON2
+ int map_generation= c->map_generation;
+ int x,y,i,d;
+ int dia_size= c->dia_size&0xFF;
+ const int dec= dia_size & (dia_size-1);
+ static const int hex[8][2]={{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1},
+ { 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}};
+
+ cmpf= s->dsp.me_cmp[size];
+ chroma_cmpf= s->dsp.me_cmp[size+1];
+
+ for(; dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){
+ do{
+ x= best[0];
+ y= best[1];
+ for(i=0; i<8; i++){
+ CHECK_CLIPPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
+ }
+ }while(best[0] != x || best[1] != y);
+ }
+
+ x= best[0];
+ y= best[1];
+ CHECK_CLIPPED_MV(x+1, y);
+ CHECK_CLIPPED_MV(x, y+1);
+ CHECK_CLIPPED_MV(x-1, y);
+ CHECK_CLIPPED_MV(x, y-1);
+
+ return dmin;
+}
+
static int umh_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags)
@@ -668,21 +740,21 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
LOAD_COMMON2
int map_generation= c->map_generation;
int x,y,x2,y2, i, j, d;
+ const int dia_size= c->dia_size&0xFE;
static const int hex[16][2]={{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2},
{ 4,-2}, { 4,-1}, { 4, 0}, { 4, 1}, { 4, 2},
{-2, 3}, { 0, 4}, { 2, 3},
{-2,-3}, { 0,-4}, { 2,-3},};
- static const int hex2[6][2]={{-2, 0}, { 2,0}, {-1,-2}, {1,-2}, {-1,2},{1,2}};
cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1];
x= best[0];
y= best[1];
- for(x2=FFMAX(x-15, xmin); x2<=FFMIN(x+15,xmax); x2+=2){
+ for(x2=FFMAX(x-dia_size+1, xmin); x2<=FFMIN(x+dia_size-1,xmax); x2+=2){
CHECK_MV(x2, y);
}
- for(y2=FFMAX(y- 7, ymin); y2<=FFMIN(y+ 7,ymax); y2+=2){
+ for(y2=FFMAX(y-dia_size/2+1, ymin); y2<=FFMIN(y+dia_size/2-1,ymax); y2+=2){
CHECK_MV(x, y2);
}
@@ -696,30 +768,13 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
//FIXME prevent the CLIP stuff
- for(j=1; j<=4; j++){
+ for(j=1; j<=dia_size/4; j++){
for(i=0; i<16; i++){
- CHECK_CLIPED_MV(x+hex[i][0]*j, y+hex[i][1]*j);
+ CHECK_CLIPPED_MV(x+hex[i][0]*j, y+hex[i][1]*j);
}
}
- do{
- x= best[0];
- y= best[1];
- for(i=0; i<6; i++){
- CHECK_CLIPED_MV(x+hex2[i][0], y+hex2[i][1]);
- }
- }while(best[0] != x || best[1] != y);
-
- do{
- x= best[0];
- y= best[1];
- CHECK_CLIPED_MV(x+1, y);
- CHECK_CLIPED_MV(x, y+1);
- CHECK_CLIPED_MV(x-1, y);
- CHECK_CLIPED_MV(x, y-1);
- }while(best[0] != x || best[1] != y);
-
- return dmin;
+ return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, 2);
}
#define SAB_CHECK_MV(ax,ay)\
@@ -768,20 +823,27 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1];
- for(j=i=0; i<ME_MAP_SIZE; i++){
+ /*Note j<MAX_SAB_SIZE is needed if MAX_SAB_SIZE < ME_MAP_SIZE as j can
+ become larger due to MVs overflowing their ME_MAP_MV_BITS bits space in map
+ */
+ for(j=i=0; i<ME_MAP_SIZE && j<MAX_SAB_SIZE; i++){
uint32_t key= map[i];
key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1));
if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;
- assert(j<MAX_SAB_SIZE); //max j = number of predictors
-
minima[j].height= score_map[i];
minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;
minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1);
minima[j].x-= (1<<(ME_MAP_MV_BITS-1));
minima[j].y-= (1<<(ME_MAP_MV_BITS-1));
+
+ // all entries in map should be in range except if the mv overflows their ME_MAP_MV_BITS bits space
+ if( minima[j].x > xmax || minima[j].x < xmin
+ || minima[j].y > ymax || minima[j].y < ymin)
+ continue;
+
minima[j].checked=0;
if(minima[j].x || minima[j].y)
minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor;
@@ -909,27 +971,44 @@ if(256*256*256*64 % (stats[0]+1)==0){
return dmin;
}
-static always_inline int diamond_search(MpegEncContext * s, int *best, int dmin,
+static av_always_inline int diamond_search(MpegEncContext * s, int *best, int dmin,
int src_index, int ref_index, int const penalty_factor,
int size, int h, int flags){
MotionEstContext * const c= &s->me;
if(c->dia_size==-1)
- return umh_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
+ return funny_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else if(c->dia_size<-1)
return sab_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else if(c->dia_size<2)
return small_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
+ else if(c->dia_size>768)
+ return umh_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
+ else if(c->dia_size>512)
+ return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, c->dia_size&0xFF);
+ else if(c->dia_size>256)
+ return l2s_dia_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else
return var_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
}
-static always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx_ptr, int *my_ptr,
+/*!
+ \param P[10][2] a list of candidate mvs to check before starting the
+ iterative search. If one of the candidates is close to the optimal mv, then
+ it takes fewer iterations. And it increases the chance that we find the
+ optimal mv.
+ */
+static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx_ptr, int *my_ptr,
int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2],
int ref_mv_scale, int flags, int size, int h)
{
MotionEstContext * const c= &s->me;
- int best[2]={0, 0};
- int d, dmin;
+ int best[2]={0, 0}; /*!< x and y coordinates of the best motion vector.
+ i.e. the difference between the position of the
+ block currently being encoded and the position of
+ the block chosen to predict it from. */
+ int d; ///< the score (cmp + penalty) of any given mv
+ int dmin; /*!< the best value of d, i.e. the score
+ corresponding to the mv stored in best[]. */
int map_generation;
int penalty_factor;
const int ref_mv_stride= s->mb_stride; //pass as arg FIXME
@@ -956,10 +1035,14 @@ static always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx
map[0]= map_generation;
score_map[0]= dmin;
+ //FIXME precalc first term below?
+ if((s->pict_type == B_TYPE && !(c->flags & FLAG_DIRECT)) || s->flags&CODEC_FLAG_MV0)
+ dmin += (mv_penalty[pred_x] + mv_penalty[pred_y])*penalty_factor;
+
/* first line */
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
- CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
}else{
if(dmin<((h*h*s->avctx->mv0_threshold)>>8)
@@ -972,28 +1055,28 @@ static always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx
return dmin;
}
CHECK_MV( P_MEDIAN[0] >>shift , P_MEDIAN[1] >>shift)
- CHECK_CLIPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)-1)
- CHECK_CLIPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)+1)
- CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)-1, (P_MEDIAN[1]>>shift) )
- CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)+1, (P_MEDIAN[1]>>shift) )
- CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
- (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
- CHECK_MV(P_LEFT[0] >>shift, P_LEFT[1] >>shift)
- CHECK_MV(P_TOP[0] >>shift, P_TOP[1] >>shift)
- CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
+ CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)-1)
+ CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)+1)
+ CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)-1, (P_MEDIAN[1]>>shift) )
+ CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)+1, (P_MEDIAN[1]>>shift) )
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
+ (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
+ CHECK_MV(P_LEFT[0] >>shift, P_LEFT[1] >>shift)
+ CHECK_MV(P_TOP[0] >>shift, P_TOP[1] >>shift)
+ CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
}
if(dmin>h*h*4){
if(c->pre_pass){
- CHECK_CLIPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16)
if(!s->first_slice_line)
- CHECK_CLIPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}else{
- CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
- CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}
}
@@ -1075,24 +1158,24 @@ static int epzs_motion_search4(MpegEncContext * s,
/* first line */
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
- CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
}else{
CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
//FIXME try some early stop
- CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
- CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
- CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
- CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
- CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
- (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
+ CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
+ CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
+ CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
+ CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
+ (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
}
if(dmin>64*4){
- CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
- CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}
@@ -1135,24 +1218,24 @@ static int epzs_motion_search2(MpegEncContext * s,
/* first line */
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
- CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
}else{
CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
//FIXME try some early stop
- CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
- CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
- CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
- CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
- CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
- (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
+ CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
+ CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
+ CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
+ CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
+ (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
}
if(dmin>64*4){
- CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
- CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
+ CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}
diff --git a/contrib/ffmpeg/libavcodec/motion_test.c b/contrib/ffmpeg/libavcodec/motion_test.c
index 8540b7483..ecdb62a4e 100644
--- a/contrib/ffmpeg/libavcodec/motion_test.c
+++ b/contrib/ffmpeg/libavcodec/motion_test.c
@@ -33,6 +33,7 @@
#include "i386/mmx.h"
+#undef exit
#undef printf
int pix_abs16x16_mmx(uint8_t *blk1, uint8_t *blk2, int lx);
diff --git a/contrib/ffmpeg/libavcodec/mpc.c b/contrib/ffmpeg/libavcodec/mpc.c
new file mode 100644
index 000000000..f351c549f
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/mpc.c
@@ -0,0 +1,355 @@
+/*
+ * Musepack decoder
+ * Copyright (c) 2006 Konstantin Shishkov
+ *
+ * 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 mpc.c Musepack decoder
+ * MPEG Audio Layer 1/2 -like codec with frames of 1152 samples
+ * divided into 32 subbands.
+ */
+
+#include "avcodec.h"
+#include "bitstream.h"
+#include "dsputil.h"
+#include "random.h"
+
+#ifdef CONFIG_MPEGAUDIO_HP
+#define USE_HIGHPRECISION
+#endif
+#include "mpegaudio.h"
+
+#include "mpcdata.h"
+
+#define BANDS 32
+#define SAMPLES_PER_BAND 36
+#define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND)
+
+static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2];
+
+static DECLARE_ALIGNED_16(MPA_INT, mpa_window[512]);
+
+typedef struct {
+ DSPContext dsp;
+ int IS, MSS, gapless;
+ int lastframelen, bands;
+ int oldDSCF[2][BANDS];
+ AVRandomState rnd;
+ int frames_to_skip;
+ /* for synthesis */
+ DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]);
+ int synth_buf_offset[MPA_MAX_CHANNELS];
+ DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]);
+} MPCContext;
+
+/** Subband structure - hold all variables for each subband */
+typedef struct {
+ int msf; ///< mid-stereo flag
+ int res[2];
+ int scfi[2];
+ int scf_idx[2][3];
+ int Q[2];
+}Band;
+
+static int mpc7_decode_init(AVCodecContext * avctx)
+{
+ int i, j;
+ MPCContext *c = avctx->priv_data;
+ GetBitContext gb;
+ uint8_t buf[16];
+ float f1=1.20050805774840750476 * 256;
+ static int vlc_inited = 0;
+
+ if(avctx->extradata_size < 16){
+ av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size);
+ return -1;
+ }
+ memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
+ av_init_random(0xDEADBEEF, &c->rnd);
+ dsputil_init(&c->dsp, avctx);
+ c->dsp.bswap_buf(buf, avctx->extradata, 4);
+ ff_mpa_synth_init(mpa_window);
+ init_get_bits(&gb, buf, 128);
+
+ c->IS = get_bits1(&gb);
+ c->MSS = get_bits1(&gb);
+ c->bands = get_bits(&gb, 6);
+ if(c->bands >= BANDS){
+ av_log(avctx, AV_LOG_ERROR, "Too many bands: %i\n", c->bands);
+ return -1;
+ }
+ skip_bits(&gb, 88);
+ c->gapless = get_bits1(&gb);
+ c->lastframelen = get_bits(&gb, 11);
+ av_log(avctx, AV_LOG_DEBUG, "IS: %d, MSS: %d, TG: %d, LFL: %d, bands: %d\n",
+ c->IS, c->MSS, c->gapless, c->lastframelen, c->bands);
+ c->frames_to_skip = 0;
+
+ if(vlc_inited) return 0;
+ av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
+ if(init_vlc(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE,
+ &mpc7_scfi[1], 2, 1,
+ &mpc7_scfi[0], 2, 1, INIT_VLC_USE_STATIC)){
+ av_log(avctx, AV_LOG_ERROR, "Cannot init SCFI VLC\n");
+ return -1;
+ }
+ if(init_vlc(&dscf_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE,
+ &mpc7_dscf[1], 2, 1,
+ &mpc7_dscf[0], 2, 1, INIT_VLC_USE_STATIC)){
+ av_log(avctx, AV_LOG_ERROR, "Cannot init DSCF VLC\n");
+ return -1;
+ }
+ if(init_vlc(&hdr_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE,
+ &mpc7_hdr[1], 2, 1,
+ &mpc7_hdr[0], 2, 1, INIT_VLC_USE_STATIC)){
+ av_log(avctx, AV_LOG_ERROR, "Cannot init HDR VLC\n");
+ return -1;
+ }
+ for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){
+ for(j = 0; j < 2; j++){
+ if(init_vlc(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i],
+ &mpc7_quant_vlc[i][j][1], 4, 2,
+ &mpc7_quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_STATIC)){
+ av_log(avctx, AV_LOG_ERROR, "Cannot init QUANT VLC %i,%i\n",i,j);
+ return -1;
+ }
+ }
+ }
+ vlc_inited = 1;
+ return 0;
+}
+
+/**
+ * Process decoded Musepack data and produce PCM
+ * @todo make it available for MPC8 and MPC6
+ */
+static void mpc_synth(MPCContext *c, int16_t *out)
+{
+ int dither_state = 0;
+ int i, ch;
+ OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;
+
+ for(ch = 0; ch < 2; 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]),
+ mpa_window, &dither_state,
+ samples_ptr, 2,
+ c->sb_samples[ch][i]);
+ samples_ptr += 64;
+ }
+ }
+ for(i = 0; i < MPC_FRAME_SIZE*2; i++)
+ *out++=samples[i];
+}
+
+/**
+ * Fill samples for given subband
+ */
+static void inline idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int *dst)
+{
+ int i, i1, t;
+ switch(idx){
+ case -1:
+ for(i = 0; i < SAMPLES_PER_BAND; i++){
+ *dst++ = (av_random(&c->rnd) & 0x3FC) - 510;
+ }
+ break;
+ case 1:
+ i1 = get_bits1(gb);
+ for(i = 0; i < SAMPLES_PER_BAND/3; i++){
+ t = get_vlc2(gb, quant_vlc[0][i1].table, 9, 2);
+ *dst++ = mpc_idx30[t];
+ *dst++ = mpc_idx31[t];
+ *dst++ = mpc_idx32[t];
+ }
+ break;
+ case 2:
+ i1 = get_bits1(gb);
+ for(i = 0; i < SAMPLES_PER_BAND/2; i++){
+ t = get_vlc2(gb, quant_vlc[1][i1].table, 9, 2);
+ *dst++ = mpc_idx50[t];
+ *dst++ = mpc_idx51[t];
+ }
+ break;
+ case 3: case 4: case 5: case 6: case 7:
+ i1 = get_bits1(gb);
+ for(i = 0; i < SAMPLES_PER_BAND; i++)
+ *dst++ = get_vlc2(gb, quant_vlc[idx-1][i1].table, 9, 2) - mpc7_quant_vlc_off[idx-1];
+ break;
+ case 8: case 9: case 10: case 11: case 12:
+ case 13: case 14: case 15: case 16: case 17:
+ t = (1 << (idx - 2)) - 1;
+ for(i = 0; i < SAMPLES_PER_BAND; i++)
+ *dst++ = get_bits(gb, idx - 1) - t;
+ break;
+ default: // case 0 and -2..-17
+ return;
+ }
+}
+
+static int mpc7_decode_frame(AVCodecContext * avctx,
+ void *data, int *data_size,
+ uint8_t * buf, int buf_size)
+{
+ MPCContext *c = avctx->priv_data;
+ GetBitContext gb;
+ uint8_t *bits;
+ int i, j, ch, t;
+ int mb = -1;
+ Band bands[BANDS];
+ int Q[2][MPC_FRAME_SIZE];
+ int off;
+ float mul;
+ int bits_used, bits_avail;
+
+ memset(bands, 0, sizeof(bands));
+ if(buf_size <= 4){
+ av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size);
+ }
+
+ bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
+ c->dsp.bswap_buf(bits, buf + 4, (buf_size - 4) >> 2);
+ init_get_bits(&gb, bits, (buf_size - 4)* 8);
+ skip_bits(&gb, buf[0]);
+
+ /* read subband indexes */
+ for(i = 0; i <= c->bands; i++){
+ for(ch = 0; ch < 2; ch++){
+ if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5;
+ if(!i || (t == 4)) bands[i].res[ch] = get_bits(&gb, 4);
+ else bands[i].res[ch] = bands[i-1].res[ch] + t;
+ }
+
+ if(bands[i].res[0] || bands[i].res[1]){
+ mb = i;
+ if(c->MSS) bands[i].msf = get_bits1(&gb);
+ }
+ }
+ /* get scale indexes coding method */
+ for(i = 0; i <= mb; i++)
+ for(ch = 0; ch < 2; ch++)
+ if(bands[i].res[ch]) bands[i].scfi[ch] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1);
+ /* get scale indexes */
+ for(i = 0; i <= mb; i++){
+ for(ch = 0; ch < 2; ch++){
+ if(bands[i].res[ch]){
+ bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i];
+ t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
+ bands[i].scf_idx[ch][0] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][2] + t);
+ switch(bands[i].scfi[ch]){
+ case 0:
+ t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
+ bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t);
+ t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
+ bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t);
+ break;
+ case 1:
+ t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
+ bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t);
+ bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1];
+ break;
+ case 2:
+ bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
+ t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
+ bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t);
+ break;
+ case 3:
+ bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
+ break;
+ }
+ c->oldDSCF[ch][i] = bands[i].scf_idx[ch][2];
+ }
+ }
+ }
+ /* get quantizers */
+ memset(Q, 0, sizeof(Q));
+ off = 0;
+ for(i = 0; i < BANDS; i++, off += SAMPLES_PER_BAND)
+ for(ch = 0; ch < 2; ch++)
+ idx_to_quant(c, &gb, bands[i].res[ch], Q[ch] + off);
+ /* dequantize */
+ memset(c->sb_samples, 0, sizeof(c->sb_samples));
+ off = 0;
+ for(i = 0; i <= mb; i++, off += SAMPLES_PER_BAND){
+ for(ch = 0; ch < 2; ch++){
+ if(bands[i].res[ch]){
+ j = 0;
+ mul = mpc_CC[bands[i].res[ch]] * mpc7_SCF[bands[i].scf_idx[ch][0]];
+ for(; j < 12; j++)
+ c->sb_samples[ch][j][i] = mul * Q[ch][j + off];
+ mul = mpc_CC[bands[i].res[ch]] * mpc7_SCF[bands[i].scf_idx[ch][1]];
+ for(; j < 24; j++)
+ c->sb_samples[ch][j][i] = mul * Q[ch][j + off];
+ mul = mpc_CC[bands[i].res[ch]] * mpc7_SCF[bands[i].scf_idx[ch][2]];
+ for(; j < 36; j++)
+ c->sb_samples[ch][j][i] = mul * Q[ch][j + off];
+ }
+ }
+ if(bands[i].msf){
+ int t1, t2;
+ for(j = 0; j < SAMPLES_PER_BAND; j++){
+ t1 = c->sb_samples[0][j][i];
+ t2 = c->sb_samples[1][j][i];
+ c->sb_samples[0][j][i] = t1 + t2;
+ c->sb_samples[1][j][i] = t1 - t2;
+ }
+ }
+ }
+
+ mpc_synth(c, data);
+
+ av_free(bits);
+
+ bits_used = get_bits_count(&gb);
+ bits_avail = (buf_size - 4) * 8;
+ if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){
+ av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail);
+ return -1;
+ }
+ if(c->frames_to_skip){
+ c->frames_to_skip--;
+ *data_size = 0;
+ return buf_size;
+ }
+ *data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
+
+ return buf_size;
+}
+
+static void mpc7_decode_flush(AVCodecContext *avctx)
+{
+ MPCContext *c = avctx->priv_data;
+
+ memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
+ c->frames_to_skip = 32;
+}
+
+AVCodec mpc7_decoder = {
+ "mpc sv7",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_MUSEPACK7,
+ sizeof(MPCContext),
+ mpc7_decode_init,
+ NULL,
+ NULL,
+ mpc7_decode_frame,
+ .flush = mpc7_decode_flush,
+};
diff --git a/contrib/ffmpeg/libavcodec/mpcdata.h b/contrib/ffmpeg/libavcodec/mpcdata.h
new file mode 100644
index 000000000..2b74765ed
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/mpcdata.h
@@ -0,0 +1,206 @@
+/*
+ * Musepack decoder
+ * Copyright (c) 2006 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+static const int8_t mpc_idx30[] = { -1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1};
+static const int8_t mpc_idx31[] = { -1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1};
+static const int8_t mpc_idx32[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+static const int8_t mpc_idx50[] = { -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2};
+static const int8_t mpc_idx51[] = { -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
+
+static const float mpc_CC[18] = {
+ 65536.0000, 21845.3333, 13107.2000, 9362.2857, 7281.7778, 4369.0667, 2114.0645,
+ 1040.2539, 516.0315, 257.0039, 128.2505, 64.0626, 32.0156, 16.0039, 8.0010,
+ 4.0002, 2.0001, 1.0000
+};
+
+#define MPC7_SCFI_SIZE 4
+#define MPC7_SCFI_BITS 3
+static const uint8_t mpc7_scfi[MPC7_SCFI_SIZE * 2] = {
+ 0x2, 3, 0x1, 1, 0x3, 3, 0x0, 2
+};
+
+#define MPC7_DSCF_SIZE 16
+#define MPC7_DSCF_BITS 6
+static const uint8_t mpc7_dscf[MPC7_DSCF_SIZE * 2] = {
+ 0x20, 6, 0x04, 5, 0x11, 5, 0x1E, 5, 0x0D, 4, 0x00, 3, 0x03, 3, 0x09, 4,
+ 0x05, 3, 0x02, 3, 0x0E, 4, 0x03, 4, 0x1F, 5, 0x05, 5, 0x21, 6, 0x0C, 4
+};
+
+#define MPC7_HDR_SIZE 10
+#define MPC7_HDR_BITS 9
+static const uint8_t mpc7_hdr[MPC7_HDR_SIZE * 2] = {
+ 0x5C, 8, 0x2F, 7, 0x0A, 5, 0x04, 4, 0x00, 2,
+ 0x01, 1, 0x03, 3, 0x16, 6, 0xBB, 9, 0xBA, 9
+};
+
+#define MPC7_QUANT_VLC_TABLES 7
+static const uint8_t mpc7_quant_vlc_sizes[MPC7_QUANT_VLC_TABLES * 2] = {
+ 27, 25, 7, 9, 15, 31, 63
+};
+
+static const uint8_t mpc7_quant_vlc_off[MPC7_QUANT_VLC_TABLES] = {
+ 0, 0, 3, 4, 7, 15, 31
+};
+
+static const uint16_t mpc7_quant_vlc[MPC7_QUANT_VLC_TABLES][2][64 * 2] = {
+{
+ {
+ 0x0036, 6, 0x0009, 5, 0x0020, 6, 0x0005, 5, 0x000A, 4, 0x0007, 5,
+ 0x0034, 6, 0x0000, 5, 0x0023, 6, 0x000A, 5, 0x0006, 4, 0x0004, 5,
+ 0x000B, 4, 0x0007, 3, 0x000C, 4, 0x0003, 5, 0x0007, 4, 0x000B, 5,
+ 0x0022, 6, 0x0001, 5, 0x0035, 6, 0x0006, 5, 0x0009, 4, 0x0002, 5,
+ 0x0021, 6, 0x0008, 5, 0x0037, 6
+ },
+ {
+ 0x0067, 8, 0x003E, 7, 0x00E1, 9, 0x0037, 7, 0x0003, 4, 0x0034, 7,
+ 0x0065, 8, 0x003C, 7, 0x00E3, 9, 0x0018, 6, 0x0000, 4, 0x003D, 7,
+ 0x0004, 4, 0x0001, 1, 0x0005, 4, 0x003F, 7, 0x0001, 4, 0x003B, 7,
+ 0x00E2, 9, 0x0039, 7, 0x0064, 8, 0x0035, 7, 0x0002, 4, 0x0036, 7,
+ 0x00E0, 9, 0x003A, 7, 0x0066, 8
+ }
+},
+{
+ {
+ 0x0059, 7, 0x002F, 6, 0x000F, 5, 0x0000, 5, 0x005B, 7, 0x0004, 5,
+ 0x0006, 4, 0x000D, 4, 0x0004, 4, 0x0005, 5, 0x0014, 5, 0x000C, 4,
+ 0x0004, 3, 0x000F, 4, 0x000E, 5, 0x0003, 5, 0x0003, 4, 0x000E, 4,
+ 0x0005, 4, 0x0001, 5, 0x005A, 7, 0x0002, 5, 0x0015, 5, 0x002E, 6,
+ 0x0058, 7
+ },
+ {
+ 0x0399, 10, 0x0071, 7, 0x0033, 6, 0x00E7, 8, 0x039A, 10, 0x0068, 7,
+ 0x001E, 5, 0x0000, 3, 0x001D, 5, 0x0069, 7, 0x0032, 6, 0x0001, 3,
+ 0x0002, 2, 0x0003, 3, 0x0031, 6, 0x006B, 7, 0x001B, 5, 0x0002, 3,
+ 0x001F, 5, 0x0070, 7, 0x0398, 10, 0x006A, 7, 0x0030, 6, 0x0072, 7,
+ 0x039B, 10
+ }
+},
+{
+ {
+ 0x000C, 4, 0x0004, 3, 0x0000, 2, 0x0001, 2, 0x0007, 3, 0x0005, 3, 0x000D, 4
+ },
+ {
+ 0x0004, 5, 0x0003, 4, 0x0002, 2, 0x0003, 2, 0x0001, 2, 0x0000, 3, 0x0005, 5
+ }
+},
+{
+ {
+ 0x0005, 4, 0x0000, 3, 0x0004, 3, 0x0006, 3, 0x0007, 3, 0x0005, 3, 0x0003, 3, 0x0001, 3, 0x0004, 4
+ },
+ {
+ 0x0009, 5, 0x000C, 4, 0x0003, 3, 0x0000, 2, 0x0002, 2, 0x0007, 3, 0x000D, 4, 0x0005, 4, 0x0008, 5
+ }
+},
+{
+ {
+ 0x0039, 6, 0x0017, 5, 0x0008, 4, 0x000A, 4, 0x000D, 4, 0x0000, 3,
+ 0x0002, 3, 0x0003, 3, 0x0001, 3, 0x000F, 4, 0x000C, 4, 0x0009, 4,
+ 0x001D, 5, 0x0016, 5, 0x0038, 6,
+ },
+ {
+ 0x00E5, 8, 0x0038, 6, 0x0007, 5, 0x0002, 4, 0x0000, 3, 0x0003, 3,
+ 0x0005, 3, 0x0006, 3, 0x0004, 3, 0x0002, 3, 0x000F, 4, 0x001D, 5,
+ 0x0006, 5, 0x0073, 7, 0x00E4, 8,
+ },
+},
+{
+ {
+ 0x0041, 7, 0x0006, 6, 0x002C, 6, 0x002D, 6, 0x003B, 6, 0x000D, 5,
+ 0x0011, 5, 0x0013, 5, 0x0017, 5, 0x0015, 5, 0x001A, 5, 0x001E, 5,
+ 0x0000, 4, 0x0002, 4, 0x0005, 4, 0x0007, 4, 0x0003, 4, 0x0004, 4,
+ 0x001F, 5, 0x001C, 5, 0x0019, 5, 0x001B, 5, 0x0018, 5, 0x0014, 5,
+ 0x0012, 5, 0x000C, 5, 0x0002, 5, 0x003A, 6, 0x0021, 6, 0x0007, 6,
+ 0x0040, 7
+ },
+ {
+ 0x1948, 13, 0x194A, 13, 0x0328, 10, 0x0195, 9, 0x00CB, 8, 0x0066, 7,
+ 0x0031, 6, 0x0009, 5, 0x000F, 5, 0x001F, 5, 0x0002, 4, 0x0006, 4,
+ 0x0008, 4, 0x000B, 4, 0x000D, 4, 0x0000, 3, 0x000E, 4, 0x000A, 4,
+ 0x0009, 4, 0x0005, 4, 0x0003, 4, 0x001E, 5, 0x000E, 5, 0x0008, 5,
+ 0x0030, 6, 0x0067, 7, 0x00C9, 8, 0x00C8, 8, 0x0653, 11, 0x1949, 13,
+ 0x194B, 13
+ }
+},
+{
+ {
+ 0x0067, 8, 0x0099, 8, 0x00B5, 8, 0x00E9, 8, 0x0040, 7, 0x0041, 7,
+ 0x004D, 7, 0x0051, 7, 0x005B, 7, 0x0071, 7, 0x0070, 7, 0x0018, 6,
+ 0x001D, 6, 0x0023, 6, 0x0025, 6, 0x0029, 6, 0x002C, 6, 0x002E, 6,
+ 0x0033, 6, 0x0031, 6, 0x0036, 6, 0x0037, 6, 0x0039, 6, 0x003C, 6,
+ 0x0000, 5, 0x0002, 5, 0x000A, 5, 0x0005, 5, 0x0009, 5, 0x0006, 5,
+ 0x000D, 5, 0x0007, 5, 0x000B, 5, 0x000F, 5, 0x0008, 5, 0x0004, 5,
+ 0x0003, 5, 0x0001, 5, 0x003F, 6, 0x003E, 6, 0x003D, 6, 0x0035, 6,
+ 0x003B, 6, 0x0034, 6, 0x0030, 6, 0x002F, 6, 0x002B, 6, 0x002A, 6,
+ 0x0027, 6, 0x0024, 6, 0x0021, 6, 0x001C, 6, 0x0075, 7, 0x0065, 7,
+ 0x0064, 7, 0x0050, 7, 0x0045, 7, 0x0044, 7, 0x0032, 7, 0x00E8, 8,
+ 0x00B4, 8, 0x0098, 8, 0x0066, 8
+ },
+ {
+ 0x37A4, 14, 0x37AD, 14, 0x37A6, 14, 0x37AE, 14, 0x0DEA, 12, 0x02F0, 10,
+ 0x02F1, 10, 0x00A0, 9, 0x00A2, 9, 0x01BC, 9, 0x007A, 8, 0x00DF, 8,
+ 0x003C, 7, 0x0049, 7, 0x006E, 7, 0x000E, 6, 0x0018, 6, 0x0019, 6,
+ 0x0022, 6, 0x0025, 6, 0x0036, 6, 0x0003, 5, 0x0009, 5, 0x000B, 5,
+ 0x0010, 5, 0x0013, 5, 0x0015, 5, 0x0018, 5, 0x001A, 5, 0x001D, 5,
+ 0x001F, 5, 0x0002, 4, 0x0000, 4, 0x001E, 5, 0x001C, 5, 0x0019, 5,
+ 0x0016, 5, 0x0014, 5, 0x000E, 5, 0x000D, 5, 0x0008, 5, 0x0006, 5,
+ 0x0002, 5, 0x002E, 6, 0x0023, 6, 0x001F, 6, 0x0015, 6, 0x000F, 6,
+ 0x005F, 7, 0x0048, 7, 0x0029, 7, 0x00BD, 8, 0x007B, 8, 0x0179, 9,
+ 0x00A1, 9, 0x037B, 10, 0x0147, 10, 0x0146, 10, 0x0DE8, 12, 0x37AF, 14,
+ 0x37A7, 14, 0x37AC, 14, 0x37A5, 14
+ }
+}
+};
+
+static const float mpc7_SCF[128] = {
+ 307.330047607421875000, 255.999984741210937500, 213.243041992187500000, 177.627334594726562500,
+ 147.960128784179687500, 123.247924804687500000, 102.663139343261718750, 85.516410827636718750,
+ 71.233520507812500000, 59.336143493652343750, 49.425861358642578125, 41.170787811279296875,
+ 34.294471740722656250, 28.566631317138671875, 23.795452117919921875, 19.821151733398437500,
+ 16.510635375976562500, 13.753040313720703125, 11.456016540527343750, 9.542640686035156250,
+ 7.948835372924804688, 6.621226310729980469, 5.515353679656982422, 4.594182968139648438,
+ 3.826865673065185547, 3.187705039978027344, 2.655296564102172852, 2.211810588836669922,
+ 1.842395424842834473, 1.534679770469665527, 1.278358578681945801, 1.064847946166992188,
+ 0.886997759342193604, 0.738851964473724365, 0.615449428558349609, 0.512657463550567627,
+ 0.427033752202987671, 0.355710864067077637, 0.296300262212753296, 0.246812388300895691,
+ 0.205589950084686279, 0.171252459287643433, 0.142649993300437927, 0.118824683129787445,
+ 0.098978661000728607, 0.082447312772274017, 0.068677015602588654, 0.057206626981496811,
+ 0.047652013599872589, 0.039693206548690796, 0.033063672482967377, 0.027541399002075195,
+ 0.022941453382372856, 0.019109787419438362, 0.015918083488941193, 0.013259455561637878,
+ 0.011044870130717754, 0.009200163185596466, 0.007663558237254620, 0.006383595988154411,
+ 0.005317411851137877, 0.004429301247000694, 0.003689522389322519, 0.003073300700634718,
+ 0.002560000168159604, 0.002132430672645569, 0.001776273478753865, 0.001479601487517357,
+ 0.001232479466125369, 0.001026631565764546, 0.000855164253152907, 0.000712335284333676,
+ 0.000593361502978951, 0.000494258652906865, 0.000411707907915115, 0.000342944724252447,
+ 0.000285666319541633, 0.000237954518524930, 0.000198211506358348, 0.000165106350323185,
+ 0.000137530398205854, 0.000114560163638089, 0.000095426403277088, 0.000079488345363643,
+ 0.000066212254751008, 0.000055153526773211, 0.000045941822463647, 0.000038268648495432,
+ 0.000031877043511486, 0.000026552961571724, 0.000022118103515822, 0.000018423952496960,
+ 0.000015346795407822, 0.000012783583770215, 0.000010648477655195, 0.000008869976227288,
+ 0.000007388518497464, 0.000006154492893984, 0.000005126573796588, 0.000004270336830814,
+ 0.000003557107902452, 0.000002963002089018, 0.000002468123511790, 0.000002055899130937,
+ 0.000001712524181130, 0.000001426499579793, 0.000001188246528727, 0.000000989786371974,
+ 0.000000824472920158, 0.000000686770022185, 0.000000572066142013, 0.000000476520028769,
+ 0.000000396931966407, 0.000000330636652279, 0.000000275413924555, 0.000000229414467867,
+ 0.000000191097811353, 0.000000159180785886, 0.000000132594522029, 0.000000110448674207,
+ 0.000000092001613439, 0.000000076635565449, 0.000000063835940978, 0.000000053174105119,
+ 0.000000044293003043, 0.000000036895215771, 0.000000030733001921, 0.000000025599996789
+};
diff --git a/contrib/ffmpeg/libavcodec/mpeg12.c b/contrib/ffmpeg/libavcodec/mpeg12.c
index c392e17af..c0fa7e4bc 100644
--- a/contrib/ffmpeg/libavcodec/mpeg12.c
+++ b/contrib/ffmpeg/libavcodec/mpeg12.c
@@ -31,6 +31,7 @@
#include "mpegvideo.h"
#include "mpeg12data.h"
+#include "bytestream.h"
//#undef NDEBUG
//#include <assert.h>
@@ -93,7 +94,7 @@ static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = {
PIX_FMT_XVMC_MPEG2_MC,
-1};
#ifdef CONFIG_ENCODERS
-static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
+static uint8_t mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
static uint8_t fcode_tab[MAX_MV*2+1];
static uint8_t uni_mpeg1_ac_vlc_len [64*64*2];
@@ -107,6 +108,8 @@ static uint8_t mpeg1_index_run[2][64];
static int8_t mpeg1_max_level[2][64];
#endif //CONFIG_ENCODERS
+static uint8_t static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
+
static void init_2d_vlc_rl(RLTable *rl, int use_static)
{
int i;
@@ -234,11 +237,28 @@ static int encode_init(AVCodecContext *avctx)
}
}
- if(avctx->profile == FF_PROFILE_UNKNOWN)
- avctx->profile = s->chroma_format == CHROMA_420 ? 4 : 0;
+ if(avctx->profile == FF_PROFILE_UNKNOWN){
+ if(avctx->level != FF_LEVEL_UNKNOWN){
+ av_log(avctx, AV_LOG_ERROR, "Set profile and level\n");
+ return -1;
+ }
+ avctx->profile = s->chroma_format == CHROMA_420 ? 4 : 0; /* Main or 4:2:2 */
+ }
- if(avctx->level == FF_LEVEL_UNKNOWN)
- avctx->level = s->chroma_format == CHROMA_420 ? 8 : 5;
+ if(avctx->level == FF_LEVEL_UNKNOWN){
+ if(avctx->profile == 0){ /* 4:2:2 */
+ if(avctx->width <= 720 && avctx->height <= 608) avctx->level = 5; /* Main */
+ else avctx->level = 2; /* High */
+ }else{
+ if(avctx->profile != 1 && s->chroma_format != CHROMA_420){
+ av_log(avctx, AV_LOG_ERROR, "Only High(1) and 4:2:2(0) profiles support 4:2:2 color sampling\n");
+ return -1;
+ }
+ if(avctx->width <= 720 && avctx->height <= 576) avctx->level = 8; /* Main */
+ else if(avctx->width <= 1440) avctx->level = 6; /* High 1440 */
+ else avctx->level = 4; /* High */
+ }
+ }
if((avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE) && s->frame_rate_index != 4){
av_log(avctx, AV_LOG_ERROR, "Drop frame time code only allowed with 1001/30000 fps\n");
@@ -333,7 +353,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_header(s, EXT_START_CODE);
put_bits(&s->pb, 4, 1); //seq ext
- put_bits(&s->pb, 1, s->chroma_format == CHROMA_422); //escx
+ put_bits(&s->pb, 1, s->avctx->profile == 0); //escx 1 for 4:2:2 profile */
put_bits(&s->pb, 3, s->avctx->profile); //profile
put_bits(&s->pb, 4, s->avctx->level); //level
@@ -351,7 +371,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
}
put_header(s, GOP_START_CODE);
- put_bits(&s->pb, 1, !!(s->avctx->flags & CODEC_FLAG2_DROP_FRAME_TIMECODE)); /* drop frame flag */
+ put_bits(&s->pb, 1, !!(s->avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE)); /* drop frame flag */
/* time code : we must convert from the real frame rate to a
fake mpeg frame rate in case of low frame rate */
fps = (framerate.num + framerate.den/2)/ framerate.den;
@@ -402,9 +422,19 @@ void ff_mpeg1_clean_buffers(MpegEncContext *s){
#ifdef CONFIG_ENCODERS
+static av_always_inline void put_qscale(MpegEncContext *s)
+{
+ if(s->q_scale_type){
+ assert(s->qscale>=1 && s->qscale <=12);
+ put_bits(&s->pb, 5, inv_non_linear_qscale[s->qscale]);
+ }else{
+ put_bits(&s->pb, 5, s->qscale);
+ }
+}
+
void ff_mpeg1_encode_slice_header(MpegEncContext *s){
put_header(s, SLICE_MIN_START_CODE + s->mb_y);
- put_bits(&s->pb, 5, s->qscale); /* quantizer scale */
+ put_qscale(s);
put_bits(&s->pb, 1, 0); /* slice extra information */
}
@@ -508,7 +538,7 @@ static inline void put_mb_modes(MpegEncContext *s, int n, int bits,
}
}
-static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
+static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
DCTELEM block[6][64],
int motion_x, int motion_y,
int mb_block_count)
@@ -550,7 +580,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
if (s->pict_type == I_TYPE) {
if(s->dquant && cbp){
put_mb_modes(s, 2, 1, 0, 0); /* macroblock_type : macroblock_quant = 1 */
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
}else{
put_mb_modes(s, 1, 1, 0, 0); /* macroblock_type : macroblock_quant = 0 */
s->qscale -= s->dquant;
@@ -560,7 +590,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
} else if (s->mb_intra) {
if(s->dquant && cbp){
put_mb_modes(s, 6, 0x01, 0, 0);
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
}else{
put_mb_modes(s, 5, 0x03, 0, 0);
s->qscale -= s->dquant;
@@ -574,7 +604,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
if ((motion_x|motion_y) == 0) {
if(s->dquant){
put_mb_modes(s, 5, 1, 0, 0); /* macroblock_pattern & quant */
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
}else{
put_mb_modes(s, 2, 1, 0, 0); /* macroblock_pattern only */
}
@@ -582,7 +612,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
} else {
if(s->dquant){
put_mb_modes(s, 5, 2, 1, 0); /* motion + cbp */
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
}else{
put_mb_modes(s, 1, 1, 1, 0); /* motion + cbp */
}
@@ -609,7 +639,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
if (cbp) {
if(s->dquant){
put_mb_modes(s, 5, 2, 1, 1); /* motion + cbp */
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
}else{
put_mb_modes(s, 1, 1, 1, 1); /* motion + cbp */
}
@@ -647,7 +677,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
put_mb_modes(s, 6, 3, 1, 0);
else
put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 0);
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
} else {
put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 0);
}
@@ -681,7 +711,7 @@ static always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
put_mb_modes(s, 6, 3, 1, 1);
else
put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 1);
- put_bits(&s->pb, 5, s->qscale);
+ put_qscale(s);
} else {
put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 1);
}
@@ -797,9 +827,8 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
int i;
done=1;
- init_rl(&rl_mpeg1, 1);
- if(s->intra_vlc_format)
- init_rl(&rl_mpeg2, 1);
+ init_rl(&rl_mpeg1, static_rl_table_store[0]);
+ init_rl(&rl_mpeg2, static_rl_table_store[1]);
for(i=0; i<64; i++)
{
@@ -831,8 +860,6 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
mpeg1_chr_dc_uni[i+255]= bits + (code<<8);
}
- mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
-
for(f_code=1; f_code<=MAX_FCODE; f_code++){
for(mv=-MAX_MV; mv<=MAX_MV; mv++){
int len;
@@ -968,7 +995,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
next_coef:
#if 0
if (level != 0)
- dprintf("level[%d]=%d\n", i, level);
+ dprintf(s->avctx, "level[%d]=%d\n", i, level);
#endif
/* encode using VLC */
if (level != 0) {
@@ -1049,8 +1076,8 @@ static void init_vlcs(void)
init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1, 1);
- init_rl(&rl_mpeg1, 1);
- init_rl(&rl_mpeg2, 1);
+ init_rl(&rl_mpeg1, static_rl_table_store[0]);
+ init_rl(&rl_mpeg2, static_rl_table_store[1]);
init_2d_vlc_rl(&rl_mpeg1, 1);
init_2d_vlc_rl(&rl_mpeg2, 1);
@@ -1087,7 +1114,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("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
+ dprintf(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
assert(s->mb_skipped==0);
@@ -1171,7 +1198,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
mb_type = btype2mb_type[ mb_type ];
break;
}
- dprintf("mb_type=%x\n", mb_type);
+ dprintf(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]);
@@ -1281,7 +1308,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
for(i=0;i<2;i++) {
if (USES_LIST(mb_type, i)) {
s->mv_dir |= (MV_DIR_FORWARD >> i);
- dprintf("motion_type=%d\n", motion_type);
+ dprintf(s->avctx, "motion_type=%d\n", motion_type);
switch(motion_type) {
case MT_FRAME: /* or MT_16X8 */
if (s->picture_structure == PICT_FRAME) {
@@ -1322,12 +1349,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("fmx=%d\n", val);
+ dprintf(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("fmy=%d\n", val);
+ dprintf(s->avctx, "fmy=%d\n", val);
}
} else {
mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
@@ -1552,7 +1579,7 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
dc += diff;
s->last_dc[component] = dc;
block[0] = dc<<3;
- dprintf("dc=%d diff=%d\n", dc, diff);
+ dprintf(s->avctx, "dc=%d diff=%d\n", dc, diff);
i = 0;
{
OPEN_READER(re, &s->gb);
@@ -1926,7 +1953,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("dc=%d\n", block[0]);
+ dprintf(s->avctx, "dc=%d\n", block[0]);
mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
@@ -2277,7 +2304,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("sequence extension\n");
+ dprintf(s->avctx, "sequence extension\n");
s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
s->avctx->sub_id = 2; /* indicates mpeg2 found */
@@ -2349,7 +2376,7 @@ static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
{
int i, v, j;
- dprintf("matrix extension\n");
+ dprintf(s->avctx, "matrix extension\n");
if (get_bits1(&s->gb)) {
for(i=0;i<64;i++) {
@@ -2420,15 +2447,15 @@ static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
}
/* composite display not parsed */
- dprintf("intra_dc_precision=%d\n", s->intra_dc_precision);
- dprintf("picture_structure=%d\n", s->picture_structure);
- dprintf("top field first=%d\n", s->top_field_first);
- dprintf("repeat first field=%d\n", s->repeat_first_field);
- dprintf("conceal=%d\n", s->concealment_motion_vectors);
- dprintf("intra_vlc_format=%d\n", s->intra_vlc_format);
- dprintf("alternate_scan=%d\n", s->alternate_scan);
- dprintf("frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
- dprintf("progressive_frame=%d\n", s->progressive_frame);
+ 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);
}
static void mpeg_decode_extension(AVCodecContext *avctx,
@@ -2576,6 +2603,10 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
break;
}
}
+ if(s->mb_x >= (unsigned)s->mb_width){
+ av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n");
+ return -1;
+ }
s->resync_mb_x= s->mb_x;
s->resync_mb_y= s->mb_y= mb_y;
@@ -2603,7 +2634,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
ret = mpeg_decode_mb(s, s->block);
s->chroma_qscale= s->qscale;
- dprintf("ret=%d\n", ret);
+ dprintf(s->avctx, "ret=%d\n", ret);
if (ret < 0)
return -1;
@@ -2826,10 +2857,10 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->chroma_intra_matrix[j] = v;
}
#ifdef DEBUG
- dprintf("intra matrix present\n");
+ dprintf(s->avctx, "intra matrix present\n");
for(i=0;i<64;i++)
- dprintf(" %d", s->intra_matrix[s->dsp.idct_permutation[i]]);
- dprintf("\n");
+ dprintf(s->avctx, " %d", s->intra_matrix[s->dsp.idct_permutation[i]]);
+ dprintf(s->avctx, "\n");
#endif
} else {
for(i=0;i<64;i++) {
@@ -2851,10 +2882,10 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
s->chroma_inter_matrix[j] = v;
}
#ifdef DEBUG
- dprintf("non intra matrix present\n");
+ dprintf(s->avctx, "non intra matrix present\n");
for(i=0;i<64;i++)
- dprintf(" %d", s->inter_matrix[s->dsp.idct_permutation[i]]);
- dprintf("\n");
+ dprintf(s->avctx, " %d", s->inter_matrix[s->dsp.idct_permutation[i]]);
+ dprintf(s->avctx, "\n");
#endif
} else {
for(i=0;i<64;i++) {
@@ -3054,7 +3085,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
int ret, input_size;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
- dprintf("fill_buffer\n");
+ dprintf(avctx, "fill_buffer\n");
if (buf_size == 0) {
/* special case for last picture */
@@ -3178,6 +3209,10 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
if(mpeg_field_start(s2) < 0)
return -1;
}
+ if(!s2->current_picture_ptr){
+ av_log(avctx, AV_LOG_ERROR, "current_picture not initalized\n");
+ return -1;
+ }
if(avctx->thread_count > 1){
int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
@@ -3298,7 +3333,7 @@ static 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("mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
+ dprintf(avctx, "mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
}
mpeg_decode_init(avctx);
s = avctx->priv_data;
@@ -3487,6 +3522,35 @@ AVCodecParser mpegvideo_parser = {
};
#endif /* !CONFIG_MPEGVIDEO_PARSER */
+static int imx_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size, int keyframe)
+{
+ /* MXF essence element key */
+ static const uint8_t imx_header[16] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01,0x05,0x01,0x01,0x00 };
+ uint8_t *poutbufp;
+
+ if (avctx->codec_id != CODEC_ID_MPEG2VIDEO) {
+ av_log(avctx, AV_LOG_ERROR, "imx bitstream filter only applies to mpeg2video codec\n");
+ return 0;
+ }
+
+ *poutbuf = av_malloc(buf_size + 20 + FF_INPUT_BUFFER_PADDING_SIZE);
+ poutbufp = *poutbuf;
+ bytestream_put_buffer(&poutbufp, imx_header, 16);
+ bytestream_put_byte(&poutbufp, 0x83); /* KLV BER long form */
+ bytestream_put_be24(&poutbufp, buf_size);
+ bytestream_put_buffer(&poutbufp, buf, buf_size);
+ *poutbuf_size = poutbufp - *poutbuf;
+ return 1;
+}
+
+AVBitStreamFilter imx_dump_header_bsf = {
+ "imxdump",
+ 0,
+ imx_dump_header,
+};
+
/* this is ugly i know, but the alternative is too make
hundreds of vars global and prefix them with ff_mpeg1_
which is far uglier. */
diff --git a/contrib/ffmpeg/libavcodec/mpeg12data.h b/contrib/ffmpeg/libavcodec/mpeg12data.h
index 6c96a495b..1176a75fa 100644
--- a/contrib/ffmpeg/libavcodec/mpeg12data.h
+++ b/contrib/ffmpeg/libavcodec/mpeg12data.h
@@ -381,6 +381,11 @@ static const uint8_t non_linear_qscale[32] = {
56,64,72,80,88,96,104,112,
};
+static const uint8_t inv_non_linear_qscale[13] = {
+ 0, 2, 4, 6, 8,
+ 9,10,11,12,13,14,15,16,
+};
+
const uint8_t ff_mpeg1_dc_scale_table[128]={
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
diff --git a/contrib/ffmpeg/libavcodec/mpegaudio.c b/contrib/ffmpeg/libavcodec/mpegaudio.c
index 2e5e28a18..aa93442d5 100644
--- a/contrib/ffmpeg/libavcodec/mpegaudio.c
+++ b/contrib/ffmpeg/libavcodec/mpegaudio.c
@@ -785,7 +785,6 @@ static int MPA_encode_close(AVCodecContext *avctx)
return 0;
}
-#ifdef CONFIG_MP2_ENCODER
AVCodec mp2_encoder = {
"mp2",
CODEC_TYPE_AUDIO,
@@ -796,6 +795,5 @@ AVCodec mp2_encoder = {
MPA_encode_close,
NULL,
};
-#endif // CONFIG_MP2_ENCODER
#undef FIX
diff --git a/contrib/ffmpeg/libavcodec/mpegaudiodec.c b/contrib/ffmpeg/libavcodec/mpegaudiodec.c
index 54bcee3b0..d64c9f611 100644
--- a/contrib/ffmpeg/libavcodec/mpegaudiodec.c
+++ b/contrib/ffmpeg/libavcodec/mpegaudiodec.c
@@ -90,6 +90,7 @@ typedef struct MPADecodeContext {
int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3
int dither_state;
int error_resilience;
+ AVCodecContext* avctx;
} MPADecodeContext;
/**
@@ -143,8 +144,8 @@ static VLC huff_quad_vlc[2];
static uint16_t band_index_long[9][23];
/* XXX: free when all decoders are closed */
#define TABLE_4_3_SIZE (8191 + 16)*4
-static int8_t *table_4_3_exp;
-static uint32_t *table_4_3_value;
+static int8_t table_4_3_exp[TABLE_4_3_SIZE];
+static uint32_t table_4_3_value[TABLE_4_3_SIZE];
static uint32_t exp_table[512];
static uint32_t expval_table[512][16];
/* intensity stereo coef table */
@@ -301,6 +302,8 @@ static int decode_init(AVCodecContext * avctx)
static int init=0;
int i, j, k;
+ s->avctx = avctx;
+
#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
avctx->sample_fmt= SAMPLE_FMT_S32;
#else
@@ -327,11 +330,11 @@ static int decode_init(AVCodecContext * avctx)
for(i=0;i<15;i++) {
int n, norm;
n = i + 2;
- norm = ((int64_t_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
+ norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm);
scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm);
scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm);
- dprintf("%d: norm=%x s=%x %x %x\n",
+ dprintf(avctx, "%d: norm=%x s=%x %x %x\n",
i, norm,
scale_factor_mult[i][0],
scale_factor_mult[i][1],
@@ -381,12 +384,6 @@ static int decode_init(AVCodecContext * avctx)
}
/* compute n ^ (4/3) and store it in mantissa/exp format */
- table_4_3_exp= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0]));
- if(!table_4_3_exp)
- return -1;
- table_4_3_value= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_value[0]));
- if(!table_4_3_value)
- return -1;
int_pow_init();
for(i=1;i<TABLE_4_3_SIZE;i++) {
@@ -436,7 +433,7 @@ static 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("is_table_lsf %d %d: %x %x\n",
+ dprintf(avctx, "is_table_lsf %d %d: %x %x\n",
i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]);
}
}
@@ -1172,20 +1169,20 @@ static int decode_header(MPADecodeContext *s, uint32_t header)
}
#if defined(DEBUG)
- dprintf("layer%d, %d Hz, %d kbits/s, ",
+ dprintf(s->avctx, "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("ms-");
+ dprintf(s->avctx, "ms-");
if (s->mode_ext & MODE_EXT_I_STEREO)
- dprintf("i-");
+ dprintf(s->avctx, "i-");
}
- dprintf("stereo");
+ dprintf(s->avctx, "stereo");
} else {
- dprintf("mono");
+ dprintf(s->avctx, "mono");
}
- dprintf("\n");
+ dprintf(s->avctx, "\n");
#endif
return 0;
}
@@ -1195,6 +1192,7 @@ static int decode_header(MPADecodeContext *s, uint32_t header)
int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate)
{
MPADecodeContext s1, *s = &s1;
+ s1.avctx = avctx;
if (ff_mpa_check_header(head) != 0)
return -1;
@@ -1336,7 +1334,7 @@ static int mp_decode_layer2(MPADecodeContext *s)
else
bound = sblimit;
- dprintf("bound=%d sblimit=%d\n", bound, sblimit);
+ dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
/* sanity check */
if( bound > sblimit ) bound = sblimit;
@@ -1362,8 +1360,8 @@ static int mp_decode_layer2(MPADecodeContext *s)
{
for(ch=0;ch<s->nb_channels;ch++) {
for(i=0;i<sblimit;i++)
- dprintf(" %d", bit_alloc[ch][i]);
- dprintf("\n");
+ dprintf(s->avctx, " %d", bit_alloc[ch][i]);
+ dprintf(s->avctx, "\n");
}
}
#endif
@@ -1413,12 +1411,12 @@ static int mp_decode_layer2(MPADecodeContext *s)
for(i=0;i<sblimit;i++) {
if (bit_alloc[ch][i]) {
sf = scale_factors[ch][i];
- dprintf(" %d %d %d", sf[0], sf[1], sf[2]);
+ dprintf(s->avctx, " %d %d %d", sf[0], sf[1], sf[2]);
} else {
- dprintf(" -");
+ dprintf(s->avctx, " -");
}
}
- dprintf("\n");
+ dprintf(s->avctx, "\n");
}
#endif
@@ -1592,6 +1590,19 @@ static inline int get_bitsz(GetBitContext *s, int n)
return get_bits(s, n);
}
+
+static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2){
+ if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){
+ s->gb= s->in_gb;
+ s->in_gb.buffer=NULL;
+ assert((get_bits_count(&s->gb) & 7) == 0);
+ skip_bits_long(&s->gb, *pos - *end_pos);
+ *end_pos2=
+ *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos;
+ *pos= get_bits_count(&s->gb);
+ }
+}
+
static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
int16_t *exponents, int end_pos2)
{
@@ -1627,15 +1638,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
if (pos >= end_pos){
// av_log(NULL, AV_LOG_ERROR, "pos: %d %d %d %d\n", pos, end_pos, end_pos2, s_index);
- if(s->in_gb.buffer && pos >= s->gb.size_in_bits){
- s->gb= s->in_gb;
- s->in_gb.buffer=NULL;
- assert((get_bits_count(&s->gb) & 7) == 0);
- skip_bits_long(&s->gb, pos - end_pos);
- end_pos2=
- end_pos= end_pos2 + get_bits_count(&s->gb) - pos;
- pos= get_bits_count(&s->gb);
- }
+ switch_buffer(s, &pos, &end_pos, &end_pos2);
// av_log(NULL, AV_LOG_ERROR, "new pos: %d %d\n", pos, end_pos);
if(pos >= end_pos)
break;
@@ -1651,7 +1654,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
exponent= exponents[s_index];
- dprintf("region=%d n=%d x=%d y=%d exp=%d\n",
+ dprintf(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;
@@ -1712,15 +1715,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
break;
}
// av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index);
- if(s->in_gb.buffer && pos >= s->gb.size_in_bits){
- s->gb= s->in_gb;
- s->in_gb.buffer=NULL;
- assert((get_bits_count(&s->gb) & 7) == 0);
- skip_bits_long(&s->gb, pos - end_pos);
- end_pos2=
- end_pos= end_pos2 + get_bits_count(&s->gb) - pos;
- pos= get_bits_count(&s->gb);
- }
+ switch_buffer(s, &pos, &end_pos, &end_pos2);
// av_log(NULL, AV_LOG_ERROR, "new pos2: %d %d %d\n", pos, end_pos, s_index);
if(pos >= end_pos)
break;
@@ -1728,7 +1723,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
last_pos= pos;
code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1);
- dprintf("t=%d code=%d\n", g->count1table_select, code);
+ dprintf(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]=
@@ -1747,9 +1742,9 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
s_index+=4;
}
/* skip extension bits */
- bits_left = end_pos - get_bits_count(&s->gb);
+ bits_left = end_pos2 - get_bits_count(&s->gb);
//av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer);
- if (bits_left < 0 || bits_left > 16) {
+ if (bits_left < 0/* || bits_left > 500*/) {
av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
s_index=0;
}else if(bits_left > 0 && s->error_resilience >= FF_ER_AGGRESSIVE){
@@ -1759,6 +1754,9 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index));
skip_bits_long(&s->gb, bits_left);
+ i= get_bits_count(&s->gb);
+ switch_buffer(s, &i, &end_pos, &end_pos2);
+
return 0;
}
@@ -2168,12 +2166,12 @@ static int mp_decode_layer3(MPADecodeContext *s)
for(gr=0;gr<nb_granules;gr++) {
for(ch=0;ch<s->nb_channels;ch++) {
- dprintf("gr=%d ch=%d: side_info\n", gr, ch);
+ dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch);
g = &granules[ch][gr];
g->part2_3_length = get_bits(&s->gb, 12);
g->big_values = get_bits(&s->gb, 9);
if(g->big_values > 288){
- av_log(NULL, AV_LOG_ERROR, "big_values too big\n");
+ av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n");
return -1;
}
@@ -2220,7 +2218,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("region1=%d region2=%d\n",
+ dprintf(s->avctx, "region1=%d region2=%d\n",
region_address1, region_address2);
g->region_size[0] =
band_index_long[s->sample_rate_index][region_address1 + 1] >> 1;
@@ -2269,7 +2267,7 @@ static int mp_decode_layer3(MPADecodeContext *s)
g->preflag = get_bits(&s->gb, 1);
g->scalefac_scale = get_bits(&s->gb, 1);
g->count1table_select = get_bits(&s->gb, 1);
- dprintf("block_type=%d switch_point=%d\n",
+ dprintf(s->avctx, "block_type=%d switch_point=%d\n",
g->block_type, g->switch_point);
}
}
@@ -2278,7 +2276,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("seekback: %d\n", main_data_begin);
+ dprintf(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);
@@ -2312,7 +2310,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("slen1=%d slen2=%d\n", slen1, slen2);
+ dprintf(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2);
if (g->block_type == 2) {
n = g->switch_point ? 17 : 18;
j = 0;
@@ -2358,11 +2356,11 @@ static int mp_decode_layer3(MPADecodeContext *s)
}
#if defined(DEBUG)
{
- dprintf("scfsi=%x gr=%d ch=%d scale_factors:\n",
+ dprintf(s->avctx, "scfsi=%x gr=%d ch=%d scale_factors:\n",
g->scfsi, gr, ch);
for(i=0;i<j;i++)
- dprintf(" %d", g->scale_factors[i]);
- dprintf("\n");
+ dprintf(s->avctx, " %d", g->scale_factors[i]);
+ dprintf(s->avctx, "\n");
}
#endif
} else {
@@ -2420,11 +2418,11 @@ static int mp_decode_layer3(MPADecodeContext *s)
g->scale_factors[j] = 0;
#if defined(DEBUG)
{
- dprintf("gr=%d ch=%d scale_factors:\n",
+ dprintf(s->avctx, "gr=%d ch=%d scale_factors:\n",
gr, ch);
for(i=0;i<40;i++)
- dprintf(" %d", g->scale_factors[i]);
- dprintf("\n");
+ dprintf(s->avctx, " %d", g->scale_factors[i]);
+ dprintf(s->avctx, "\n");
}
#endif
}
@@ -2475,7 +2473,7 @@ static int mp_decode_frame(MPADecodeContext *s,
if (s->error_protection)
get_bits(&s->gb, 16);
- dprintf("frame %d:\n", s->frame_count);
+ dprintf(s->avctx, "frame %d:\n", s->frame_count);
switch(s->layer) {
case 1:
nb_frames = mp_decode_layer1(s);
@@ -2518,10 +2516,10 @@ static int mp_decode_frame(MPADecodeContext *s,
for(i=0;i<nb_frames;i++) {
for(ch=0;ch<s->nb_channels;ch++) {
int j;
- dprintf("%d-%d:", i, ch);
+ dprintf(s->avctx, "%d-%d:", i, ch);
for(j=0;j<SBLIMIT;j++)
- dprintf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE);
- dprintf("\n");
+ dprintf(s->avctx, " %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE);
+ dprintf(s->avctx, "\n");
}
}
#endif
@@ -2717,6 +2715,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx)
s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias;
s->mp3decctx[i]->adu_mode = 1;
+ s->mp3decctx[i]->avctx = avctx;
}
return 0;
diff --git a/contrib/ffmpeg/libavcodec/mpegvideo.c b/contrib/ffmpeg/libavcodec/mpegvideo.c
index f0a04a402..f0069fa1e 100644
--- a/contrib/ffmpeg/libavcodec/mpegvideo.c
+++ b/contrib/ffmpeg/libavcodec/mpegvideo.c
@@ -107,7 +107,7 @@ static const uint8_t ff_default_chroma_qscale_table[32]={
};
#ifdef CONFIG_ENCODERS
-static uint8_t (*default_mv_penalty)[MAX_MV*2+1]=NULL;
+static uint8_t default_mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
static uint8_t default_fcode_tab[MAX_MV*2+1];
enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1};
@@ -132,7 +132,7 @@ static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[
/* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
/* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
- qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) /
+ qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) /
(qscale * quant_matrix[j]));
}
} else if (dsp->fdct == fdct_ifast
@@ -147,7 +147,7 @@ static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[
/* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
/* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
- qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) /
+ qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) /
(aanscales[i] * qscale * quant_matrix[j]));
}
} else {
@@ -158,7 +158,7 @@ static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[
so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905
so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67
*/
- qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));
+ qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));
// qmat [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]);
qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]);
@@ -182,13 +182,13 @@ static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[
}
}
if(shift){
- av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger then %d, overflows possible\n", QMAT_SHIFT - shift);
+ av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger than %d, overflows possible\n", QMAT_SHIFT - shift);
}
}
static inline void update_qscale(MpegEncContext *s){
s->qscale= (s->lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
- s->qscale= clip(s->qscale, s->avctx->qmin, s->avctx->qmax);
+ s->qscale= av_clip(s->qscale, s->avctx->qmin, s->avctx->qmax);
s->lambda2= (s->lambda*s->lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT;
}
@@ -625,20 +625,11 @@ void MPV_decode_defaults(MpegEncContext *s){
#ifdef CONFIG_ENCODERS
static void MPV_encode_defaults(MpegEncContext *s){
- static int done=0;
-
+ int i;
MPV_common_defaults(s);
- if(!done){
- int i;
- done=1;
-
- default_mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
- memset(default_fcode_tab , 0, sizeof(uint8_t)*(2*MAX_MV+1));
-
- for(i=-16; i<16; i++){
- default_fcode_tab[i + MAX_MV]= 1;
- }
+ for(i=-16; i<16; i++){
+ default_fcode_tab[i + MAX_MV]= 1;
}
s->me.mv_penalty= default_mv_penalty;
s->fcode_tab= default_fcode_tab;
@@ -1015,6 +1006,7 @@ int MPV_encode_init(AVCodecContext *avctx)
s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC);
+ s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT);
if(avctx->rc_max_rate && !avctx->rc_buffer_size){
av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
@@ -1095,7 +1087,7 @@ int MPV_encode_init(AVCodecContext *avctx)
}
if(s->avctx->scenechange_threshold < 1000000000 && (s->flags & CODEC_FLAG_CLOSED_GOP)){
- av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet\n");
+ av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet, set threshold to 1000000000\n");
return -1;
}
@@ -1115,6 +1107,17 @@ int MPV_encode_init(AVCodecContext *avctx)
}
}
+ if(s->q_scale_type == 1){
+ if(s->codec_id != CODEC_ID_MPEG2VIDEO){
+ av_log(avctx, AV_LOG_ERROR, "non linear quant is only available for mpeg2\n");
+ return -1;
+ }
+ if(avctx->qmax > 12){
+ av_log(avctx, AV_LOG_ERROR, "non linear quant only supports qmax <= 12 currently\n");
+ return -1;
+ }
+ }
+
if(s->avctx->thread_count > 1 && s->codec_id != CODEC_ID_MPEG4
&& s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO
&& (s->codec_id != CODEC_ID_H263P || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))){
@@ -1233,7 +1236,7 @@ int MPV_encode_init(AVCodecContext *avctx)
s->h263_plus = 1;
/* Fx */
s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
- s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
+ s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0;
s->modified_quant= s->h263_aic;
s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
@@ -1408,14 +1411,14 @@ int MPV_encode_end(AVCodecContext *avctx)
#endif //CONFIG_ENCODERS
-void init_rl(RLTable *rl, int use_static)
+void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3])
{
int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1];
uint8_t index_run[MAX_RUN+1];
int last, run, level, start, end, i;
/* If table is static, we can quit if rl->max_level[0] is not NULL */
- if(use_static && rl->max_level[0])
+ if(static_store && rl->max_level[0])
return;
/* compute max_level[], max_run[] and index_run[] */
@@ -1441,18 +1444,18 @@ void init_rl(RLTable *rl, int use_static)
if (run > max_run[level])
max_run[level] = run;
}
- if(use_static)
- rl->max_level[last] = av_mallocz_static(MAX_RUN + 1);
+ if(static_store)
+ rl->max_level[last] = static_store[last];
else
rl->max_level[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
- if(use_static)
- rl->max_run[last] = av_mallocz_static(MAX_LEVEL + 1);
+ if(static_store)
+ rl->max_run[last] = static_store[last] + MAX_RUN + 1;
else
rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
- if(use_static)
- rl->index_run[last] = av_mallocz_static(MAX_RUN + 1);
+ if(static_store)
+ rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
else
rl->index_run[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
@@ -1538,6 +1541,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
/* mark&release old frames */
if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
+ if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
/* release forgotten pictures */
@@ -1550,6 +1554,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
}
}
+ }
}
alloc:
if(!s->encoding){
@@ -1587,7 +1592,6 @@ alloc:
copy_picture(&s->current_picture, s->current_picture_ptr);
- if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
if (s->pict_type != B_TYPE) {
s->last_picture_ptr= s->next_picture_ptr;
if(!s->dropable)
@@ -1602,7 +1606,7 @@ alloc:
if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr);
if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
- if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){
+ if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable){
av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
assert(s->pict_type != B_TYPE); //these should have been dropped if we don't have a reference
goto alloc;
@@ -1621,7 +1625,6 @@ alloc:
s->next_picture.linesize[i] *=2;
}
}
- }
s->hurry_up= s->avctx->hurry_up;
s->error_resilience= avctx->error_resilience;
@@ -1713,10 +1716,10 @@ void MPV_frame_end(MpegEncContext *s)
static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
int x, y, fr, f;
- sx= clip(sx, 0, w-1);
- sy= clip(sy, 0, h-1);
- ex= clip(ex, 0, w-1);
- ey= clip(ey, 0, h-1);
+ sx= av_clip(sx, 0, w-1);
+ sy= av_clip(sy, 0, h-1);
+ ex= av_clip(ex, 0, w-1);
+ ey= av_clip(ey, 0, h-1);
buf[sy*stride + sx]+= color;
@@ -1762,10 +1765,10 @@ static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h
static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
int dx,dy;
- sx= clip(sx, -100, w+100);
- sy= clip(sy, -100, h+100);
- ex= clip(ex, -100, w+100);
- ey= clip(ey, -100, h+100);
+ sx= av_clip(sx, -100, w+100);
+ sy= av_clip(sy, -100, h+100);
+ ex= av_clip(ex, -100, w+100);
+ ey= av_clip(ey, -100, h+100);
dx= ex - sx;
dy= ey - sy;
@@ -2260,15 +2263,6 @@ static int estimate_best_b_count(MpegEncContext *s){
int csize= (c->width/2)*(c->height/2);
Picture pre_input, *pre_input_ptr= i ? s->input_picture[i-1] : s->next_picture_ptr;
- if(pre_input_ptr)
- pre_input= *pre_input_ptr;
-
- if(pre_input.type != FF_BUFFER_TYPE_SHARED && i){
- pre_input.data[0]+=INPLACE_OFFSET;
- pre_input.data[1]+=INPLACE_OFFSET;
- pre_input.data[2]+=INPLACE_OFFSET;
- }
-
avcodec_get_frame_defaults(&input[i]);
input[i].data[0]= av_malloc(ysize + 2*csize);
input[i].data[1]= input[i].data[0] + ysize;
@@ -2277,7 +2271,15 @@ static int estimate_best_b_count(MpegEncContext *s){
input[i].linesize[1]=
input[i].linesize[2]= c->width/2;
- if(!i || s->input_picture[i-1]){
+ if(pre_input_ptr && (!i || s->input_picture[i-1])) {
+ pre_input= *pre_input_ptr;
+
+ if(pre_input.type != FF_BUFFER_TYPE_SHARED && i) {
+ pre_input.data[0]+=INPLACE_OFFSET;
+ pre_input.data[1]+=INPLACE_OFFSET;
+ pre_input.data[2]+=INPLACE_OFFSET;
+ }
+
s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.data[0], pre_input.linesize[0], c->width, c->height);
s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.data[1], pre_input.linesize[1], c->width>>1, c->height>>1);
s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.data[2], pre_input.linesize[2], c->width>>1, c->height>>1);
@@ -2665,10 +2667,10 @@ static inline void gmc1_motion(MpegEncContext *s,
src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy+1));
motion_x<<=(3-s->sprite_warping_accuracy);
motion_y<<=(3-s->sprite_warping_accuracy);
- src_x = clip(src_x, -16, s->width);
+ src_x = av_clip(src_x, -16, s->width);
if (src_x == s->width)
motion_x =0;
- src_y = clip(src_y, -16, s->height);
+ src_y = av_clip(src_y, -16, s->height);
if (src_y == s->height)
motion_y =0;
@@ -2707,10 +2709,10 @@ static inline void gmc1_motion(MpegEncContext *s,
src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy+1));
motion_x<<=(3-s->sprite_warping_accuracy);
motion_y<<=(3-s->sprite_warping_accuracy);
- src_x = clip(src_x, -8, s->width>>1);
+ src_x = av_clip(src_x, -8, s->width>>1);
if (src_x == s->width>>1)
motion_x =0;
- src_y = clip(src_y, -8, s->height>>1);
+ src_y = av_clip(src_y, -8, s->height>>1);
if (src_y == s->height>>1)
motion_y =0;
@@ -2880,10 +2882,10 @@ static inline int hpel_motion(MpegEncContext *s,
src_y += motion_y >> 1;
/* WARNING: do no forget half pels */
- src_x = clip(src_x, -16, width); //FIXME unneeded for emu?
+ src_x = av_clip(src_x, -16, width); //FIXME unneeded for emu?
if (src_x == width)
dxy &= ~1;
- src_y = clip(src_y, -16, height);
+ src_y = av_clip(src_y, -16, height);
if (src_y == height)
dxy &= ~2;
src += src_y * stride + src_x;
@@ -2946,7 +2948,7 @@ static inline int hpel_motion_lowres(MpegEncContext *s,
}
/* apply one mpeg motion vector to the three components */
-static always_inline void mpeg_motion(MpegEncContext *s,
+static av_always_inline void mpeg_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int field_based, int bottom_field, int field_select,
uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
@@ -3063,7 +3065,7 @@ if(s->quarter_sample)
}
/* apply one mpeg motion vector to the three components */
-static always_inline void mpeg_motion_lowres(MpegEncContext *s,
+static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int field_based, int bottom_field, int field_select,
uint8_t **ref_picture, h264_chroma_mc_func *pix_op,
@@ -3359,10 +3361,10 @@ static inline void chroma_4mv_motion(MpegEncContext *s,
src_x = s->mb_x * 8 + mx;
src_y = s->mb_y * 8 + my;
- src_x = clip(src_x, -8, s->width/2);
+ src_x = av_clip(src_x, -8, s->width/2);
if (src_x == s->width/2)
dxy &= ~1;
- src_y = clip(src_y, -8, s->height/2);
+ src_y = av_clip(src_y, -8, s->height/2);
if (src_y == s->height/2)
dxy &= ~2;
@@ -3575,10 +3577,10 @@ static inline void MPV_motion(MpegEncContext *s,
src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
/* WARNING: do no forget half pels */
- src_x = clip(src_x, -16, s->width);
+ src_x = av_clip(src_x, -16, s->width);
if (src_x == s->width)
dxy &= ~3;
- src_y = clip(src_y, -16, s->height);
+ src_y = av_clip(src_y, -16, s->height);
if (src_y == s->height)
dxy &= ~12;
@@ -3895,7 +3897,7 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
s->mv : motion vector
s->interlaced_dct : true if interlaced dct used (mpeg2)
*/
-static always_inline void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], int lowres_flag)
+static av_always_inline void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], int lowres_flag)
{
int mb_x, mb_y;
const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
@@ -4318,7 +4320,7 @@ static void get_vissual_weight(int16_t *weight, uint8_t *ptr, int stride){
}
}
-static always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)
+static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, int motion_y, int mb_block_height, int mb_block_count)
{
int16_t weight[8][64];
DCTELEM orig[8][64];
@@ -4330,7 +4332,7 @@ static always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, in
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int wrap_y, wrap_c;
- for(i=0; i<mb_block_count; i++) skip_dct[i]=0;
+ for(i=0; i<mb_block_count; i++) skip_dct[i]=s->skipdct;
if(s->adaptive_quant){
const int last_qp= s->qscale;
@@ -4340,17 +4342,16 @@ static always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, in
update_qscale(s);
if(!(s->flags&CODEC_FLAG_QP_RD)){
+ s->qscale= s->current_picture_ptr->qscale_table[mb_xy];
s->dquant= s->qscale - last_qp;
if(s->out_format==FMT_H263){
- s->dquant= clip(s->dquant, -2, 2); //FIXME RD
+ s->dquant= av_clip(s->dquant, -2, 2);
if(s->codec_id==CODEC_ID_MPEG4){
if(!s->mb_intra){
if(s->pict_type == B_TYPE){
- if(s->dquant&1)
- s->dquant= (s->dquant/2)*2;
- if(s->mv_dir&MV_DIRECT)
+ if(s->dquant&1 || s->mv_dir&MV_DIRECT)
s->dquant= 0;
}
if(s->mv_type==MV_TYPE_8X8)
@@ -4600,7 +4601,7 @@ static always_inline void encode_mb_internal(MpegEncContext *s, int motion_x, in
}
}
-static always_inline void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
+static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
{
if (s->chroma_format == CHROMA_420) encode_mb_internal(s, motion_x, motion_y, 8, 6);
else encode_mb_internal(s, motion_x, motion_y, 16, 8);
@@ -4631,6 +4632,7 @@ void ff_mpeg_flush(AVCodecContext *avctx){
s->parse_context.index= 0;
s->parse_context.last_index= 0;
s->bitstream_buffer_size=0;
+ s->pp_time=0;
}
#ifdef CONFIG_ENCODERS
@@ -4838,6 +4840,8 @@ static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
static int estimate_motion_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= arg;
+ ff_check_alignment();
+
s->me.dia_size= s->avctx->dia_size;
s->first_slice_line=1;
for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
@@ -4864,6 +4868,8 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
MpegEncContext *s= arg;
int mb_x, mb_y;
+ ff_check_alignment();
+
for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
for(mb_x=0; mb_x < s->mb_width; mb_x++) {
int xx = mb_x * 16;
@@ -4911,6 +4917,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
PutBitContext pb[2], pb2[2], tex_pb[2];
//printf("%d->%d\n", s->resync_mb_y, s->end_mb_y);
+ ff_check_alignment();
+
for(i=0; i<2; i++){
init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES);
init_put_bits(&pb2 [i], bit_buf2 [i], MAX_MB_BYTES);
@@ -5166,16 +5174,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb,
&dmin, &next_block, 0, 0);
}
- if(mb_type&CANDIDATE_MB_TYPE_DIRECT){
- int mx= s->b_direct_mv_table[xy][0];
- int my= s->b_direct_mv_table[xy][1];
-
- s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
- s->mb_intra= 0;
- ff_mpeg4_set_direct_mv(s, mx, my);
- encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
- &dmin, &next_block, mx, my);
- }
if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_FIELD;
@@ -5230,8 +5228,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
}
- if(s->flags & CODEC_FLAG_QP_RD){
- if(best_s.mv_type==MV_TYPE_16X16 && !(best_s.mv_dir&MV_DIRECT)){
+ if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){
+ if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD
const int last_qp= backup_s.qscale;
int qpi, qp, dc[6];
DCTELEM ac[6][16];
@@ -5274,10 +5272,61 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
}
}
- qp= best_s.qscale;
- s->current_picture.qscale_table[xy]= qp;
}
}
+ if(mb_type&CANDIDATE_MB_TYPE_DIRECT){
+ int mx= s->b_direct_mv_table[xy][0];
+ int my= s->b_direct_mv_table[xy][1];
+
+ backup_s.dquant = 0;
+ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
+ s->mb_intra= 0;
+ ff_mpeg4_set_direct_mv(s, mx, my);
+ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
+ &dmin, &next_block, mx, my);
+ }
+ if(mb_type&CANDIDATE_MB_TYPE_DIRECT0){
+ backup_s.dquant = 0;
+ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
+ s->mb_intra= 0;
+ ff_mpeg4_set_direct_mv(s, 0, 0);
+ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb,
+ &dmin, &next_block, 0, 0);
+ }
+ if(!best_s.mb_intra && s->flags2&CODEC_FLAG2_SKIP_RD){
+ int coded=0;
+ for(i=0; i<6; i++)
+ coded |= s->block_last_index[i];
+ if(coded){
+ int mx,my;
+ memcpy(s->mv, best_s.mv, sizeof(s->mv));
+ if(best_s.mv_dir & MV_DIRECT){
+ mx=my=0; //FIXME find the one we actually used
+ ff_mpeg4_set_direct_mv(s, mx, my);
+ }else if(best_s.mv_dir&MV_DIR_BACKWARD){
+ mx= s->mv[1][0][0];
+ my= s->mv[1][0][1];
+ }else{
+ mx= s->mv[0][0][0];
+ my= s->mv[0][0][1];
+ }
+
+ s->mv_dir= best_s.mv_dir;
+ s->mv_type = best_s.mv_type;
+ s->mb_intra= 0;
+/* s->mv[0][0][0] = best_s.mv[0][0][0];
+ s->mv[0][0][1] = best_s.mv[0][0][1];
+ s->mv[1][0][0] = best_s.mv[1][0][0];
+ s->mv[1][0][1] = best_s.mv[1][0][1];*/
+ backup_s.dquant= 0;
+ s->skipdct=1;
+ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb,
+ &dmin, &next_block, mx, my);
+ s->skipdct=0;
+ }
+ }
+
+ s->current_picture.qscale_table[xy]= best_s.qscale;
copy_context_after_encode(s, &best_s, -1);
@@ -5311,7 +5360,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
MPV_decode_mb(s, s->block);
} else {
- int motion_x, motion_y;
+ int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
// only one MB-Type possible
@@ -5337,7 +5386,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
- motion_x = motion_y = 0;
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
@@ -5347,7 +5395,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
- motion_x= motion_y= 0;
break;
case CANDIDATE_MB_TYPE_DIRECT:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
@@ -5356,11 +5403,14 @@ static int encode_thread(AVCodecContext *c, void *arg){
motion_y=s->b_direct_mv_table[xy][1];
ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
break;
+ case CANDIDATE_MB_TYPE_DIRECT0:
+ s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
+ s->mb_intra= 0;
+ ff_mpeg4_set_direct_mv(s, 0, 0);
+ break;
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
- motion_x=0;
- motion_y=0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
@@ -5388,7 +5438,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
- motion_x=motion_y=0;
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
@@ -5399,7 +5448,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
- motion_x=motion_y=0;
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
@@ -5412,10 +5460,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
- motion_x=motion_y=0;
break;
default:
- motion_x=motion_y=0; //gcc warning fix
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
@@ -5699,7 +5745,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
for(i=1;i<64;i++){
int j= s->dsp.idct_permutation[i];
- s->intra_matrix[j] = clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
+ s->intra_matrix[j] = av_clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
}
convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
@@ -6118,7 +6164,7 @@ static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise?
uint8_t * length;
uint8_t * last_length;
int lambda;
- int rle_index, run, q, sum;
+ int rle_index, run, q = 1, sum; //q is only used when s->mb_intra is true
#ifdef REFINE_STATS
static int count=0;
static int after_last=0;
diff --git a/contrib/ffmpeg/libavcodec/mpegvideo.h b/contrib/ffmpeg/libavcodec/mpegvideo.h
index 011678a42..80e0f9065 100644
--- a/contrib/ffmpeg/libavcodec/mpegvideo.h
+++ b/contrib/ffmpeg/libavcodec/mpegvideo.h
@@ -162,7 +162,11 @@ typedef struct MotionEstContext{
uint32_t *score_map; ///< map to store the scores
int map_generation;
int pre_penalty_factor;
- int penalty_factor;
+ int penalty_factor; /*!< an estimate of the bits required to
+ code a given mv value, e.g. (1,0) takes
+ more bits than (0,0). We have to
+ estimate whether any reduction in
+ residual is worth the extra bits. */
int sub_penalty_factor;
int mb_penalty_factor;
int flags;
@@ -324,6 +328,7 @@ typedef struct MpegEncContext {
int dropable;
int frame_rate_index;
int last_lambda_for[5]; ///< last lambda for a specific pict type
+ int skipdct; ///< skip dct and code zero residual
/* motion compensation */
int unrestricted_mv; ///< mv can point outside of the coded picture
@@ -402,6 +407,8 @@ typedef struct MpegEncContext {
#define CANDIDATE_MB_TYPE_BACKWARD_I 0x400
#define CANDIDATE_MB_TYPE_BIDIR_I 0x800
+#define CANDIDATE_MB_TYPE_DIRECT0 0x1000
+
int block_index[6]; ///< index to current MB in block based arrays with edges
int block_wrap[6];
uint8_t *dest[3];
@@ -779,34 +786,7 @@ void ff_mpeg1_encode_init(MpegEncContext *s);
void ff_mpeg1_encode_slice_header(MpegEncContext *s);
void ff_mpeg1_clean_buffers(MpegEncContext *s);
-
-/** RLTable. */
-typedef struct RLTable {
- int n; ///< number of entries of table_vlc minus 1
- int last; ///< number of values for last = 0
- const uint16_t (*table_vlc)[2];
- const int8_t *table_run;
- const int8_t *table_level;
- uint8_t *index_run[2]; ///< encoding only
- int8_t *max_level[2]; ///< encoding & decoding
- int8_t *max_run[2]; ///< encoding & decoding
- VLC vlc; ///< decoding only deprected FIXME remove
- RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
-} RLTable;
-
-void init_rl(RLTable *rl, int use_static);
-void init_vlc_rl(RLTable *rl, int use_static);
-
-static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
-{
- int index;
- index = rl->index_run[last][run];
- if (index >= rl->n)
- return rl->n;
- if (level > rl->max_level[last][run])
- return rl->n;
- return index + level - 1;
-}
+#include "rl.h"
extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
diff --git a/contrib/ffmpeg/libavcodec/msmpeg4.c b/contrib/ffmpeg/libavcodec/msmpeg4.c
index a8124172b..62076d140 100644
--- a/contrib/ffmpeg/libavcodec/msmpeg4.c
+++ b/contrib/ffmpeg/libavcodec/msmpeg4.c
@@ -91,6 +91,8 @@ int frame_count = 0;
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
#endif //CONFIG_ENCODERS
+static uint8_t static_rl_table_store[NB_RL_TABLES][2][2*MAX_RUN + MAX_LEVEL + 3];
+
static void common_init(MpegEncContext * s)
{
static int inited=0;
@@ -186,7 +188,7 @@ void ff_msmpeg4_encode_init(MpegEncContext *s)
init_mv_table(&mv_tables[0]);
init_mv_table(&mv_tables[1]);
for(i=0;i<NB_RL_TABLES;i++)
- init_rl(&rl_table[i], 1);
+ init_rl(&rl_table[i], static_rl_table_store[i]);
for(i=0; i<NB_RL_TABLES; i++){
int level;
@@ -1051,7 +1053,7 @@ int ff_msmpeg4_decode_init(MpegEncContext *s)
done = 1;
for(i=0;i<NB_RL_TABLES;i++) {
- init_rl(&rl_table[i], 1);
+ init_rl(&rl_table[i], static_rl_table_store[i]);
init_vlc_rl(&rl_table[i], 1);
}
for(i=0;i<2;i++) {
diff --git a/contrib/ffmpeg/libavcodec/msvideo1.c b/contrib/ffmpeg/libavcodec/msvideo1.c
index 5929e1c63..1e3f6cce2 100644
--- a/contrib/ffmpeg/libavcodec/msvideo1.c
+++ b/contrib/ffmpeg/libavcodec/msvideo1.c
@@ -245,25 +245,25 @@ static void msvideo1_decode_16bit(Msvideo1Context *s)
flags = (byte_b << 8) | byte_a;
CHECK_STREAM_PTR(4);
- colors[0] = LE_16(&s->buf[stream_ptr]);
+ colors[0] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[1] = LE_16(&s->buf[stream_ptr]);
+ colors[1] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
if (colors[0] & 0x8000) {
/* 8-color encoding */
CHECK_STREAM_PTR(12);
- colors[2] = LE_16(&s->buf[stream_ptr]);
+ colors[2] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[3] = LE_16(&s->buf[stream_ptr]);
+ colors[3] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[4] = LE_16(&s->buf[stream_ptr]);
+ colors[4] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[5] = LE_16(&s->buf[stream_ptr]);
+ colors[5] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[6] = LE_16(&s->buf[stream_ptr]);
+ colors[6] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[7] = LE_16(&s->buf[stream_ptr]);
+ colors[7] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
diff --git a/contrib/ffmpeg/libavcodec/nuv.c b/contrib/ffmpeg/libavcodec/nuv.c
index 592d3de03..5989c6cc2 100644
--- a/contrib/ffmpeg/libavcodec/nuv.c
+++ b/contrib/ffmpeg/libavcodec/nuv.c
@@ -50,7 +50,7 @@ static void copy_frame(AVFrame *f, uint8_t *src,
int width, int height) {
AVPicture pic;
avpicture_fill(&pic, src, PIX_FMT_YUV420P, width, height);
- img_copy((AVPicture *)f, &pic, PIX_FMT_YUV420P, width, height);
+ av_picture_copy((AVPicture *)f, &pic, PIX_FMT_YUV420P, width, height);
}
/**
@@ -64,9 +64,9 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c,
return -1;
}
for (i = 0; i < 64; i++, buf += 4)
- c->lq[i] = LE_32(buf);
+ c->lq[i] = AV_RL32(buf);
for (i = 0; i < 64; i++, buf += 4)
- c->cq[i] = LE_32(buf);
+ c->cq[i] = AV_RL32(buf);
return 0;
}
diff --git a/contrib/ffmpeg/libavcodec/oggvorbis.c b/contrib/ffmpeg/libavcodec/oggvorbis.c
index 9e684a0f4..da97e9a78 100644
--- a/contrib/ffmpeg/libavcodec/oggvorbis.c
+++ b/contrib/ffmpeg/libavcodec/oggvorbis.c
@@ -159,7 +159,9 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
vorbis_bitrate_addblock(&context->vb) ;
while(vorbis_bitrate_flushpacket(&context->vd, &op)) {
- if(op.bytes==1) //id love to say this is a hack, bad sadly its not, appearently the end of stream decission is in libogg
+ /* i'd love to say the following line is a hack, but sadly it's
+ * not, apparently the end of stream decision is in libogg. */
+ if(op.bytes==1)
continue;
memcpy(context->buffer + context->buffer_index, &op, sizeof(ogg_packet));
context->buffer_index += sizeof(ogg_packet);
diff --git a/contrib/ffmpeg/libavcodec/opt.c b/contrib/ffmpeg/libavcodec/opt.c
index a200d9a82..97b593cb2 100644
--- a/contrib/ffmpeg/libavcodec/opt.c
+++ b/contrib/ffmpeg/libavcodec/opt.c
@@ -31,25 +31,25 @@
#include "eval.h"
//FIXME order them and do a bin search
-static AVOption *find_opt(void *v, const char *name, const char *unit){
+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
- AVOption *o= c->option;
+ const AVOption *o= c->option;
for(;o && o->name; o++){
- if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) )
+ if(!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags )
return o;
}
return NULL;
}
-AVOption *av_next_option(void *obj, AVOption *last){
+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;
}
-static AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
- AVOption *o= find_opt(obj, name, NULL);
+static const AVOption *av_set_number(void *obj, const char *name, 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)
return NULL;
@@ -76,10 +76,10 @@ static AVOption *av_set_number(void *obj, const char *name, double num, int den,
return o;
}
-static AVOption *set_all_opt(void *v, const char *unit, double d){
+static const AVOption *set_all_opt(void *v, const char *unit, double d){
AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
- AVOption *o= c->option;
- AVOption *ret=NULL;
+ const AVOption *o= c->option;
+ const AVOption *ret=NULL;
for(;o && o->name; o++){
if(o->type != FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)){
@@ -108,8 +108,8 @@ static const char *const_names[]={
0
};
-AVOption *av_set_string(void *obj, const char *name, const char *val){
- AVOption *o= find_opt(obj, name, NULL);
+const AVOption *av_set_string(void *obj, const char *name, const char *val){
+ const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){
return set_all_opt(obj, o->unit, o->default_val);
}
@@ -133,12 +133,14 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
d = ff_eval2(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error);
if(isnan(d)) {
- AVOption *o_named= find_opt(obj, buf, o->unit);
+ 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 {
if (!error)
av_log(NULL, AV_LOG_ERROR, "Unable to parse option value \"%s\": %s\n", val, error);
@@ -162,15 +164,15 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
return o;
}
-AVOption *av_set_double(void *obj, const char *name, double n){
+const AVOption *av_set_double(void *obj, const char *name, double n){
return av_set_number(obj, name, n, 1, 1);
}
-AVOption *av_set_q(void *obj, const char *name, AVRational n){
+const AVOption *av_set_q(void *obj, const char *name, AVRational n){
return av_set_number(obj, name, n.num, n.den, 1);
}
-AVOption *av_set_int(void *obj, const char *name, int64_t n){
+const AVOption *av_set_int(void *obj, const char *name, int64_t n){
return av_set_number(obj, name, 1, 1, n);
}
@@ -179,8 +181,8 @@ AVOption *av_set_int(void *obj, const char *name, int64_t n){
* @param buf a buffer which is used for returning non string values as strings, can be NULL
* @param buf_len allocated length in bytes of buf
*/
-const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len){
- AVOption *o= find_opt(obj, name, NULL);
+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;
if(!o || o->offset<=0)
return NULL;
@@ -205,8 +207,8 @@ const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *b
return buf;
}
-static int av_get_number(void *obj, const char *name, AVOption **o_out, double *num, int *den, int64_t *intnum){
- AVOption *o= find_opt(obj, name, NULL);
+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;
@@ -230,7 +232,7 @@ error:
return -1;
}
-double av_get_double(void *obj, const char *name, AVOption **o_out){
+double av_get_double(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
@@ -239,7 +241,7 @@ double av_get_double(void *obj, const char *name, AVOption **o_out){
return num*intnum/den;
}
-AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
+AVRational av_get_q(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
@@ -251,7 +253,7 @@ AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
return av_d2q(num*intnum/den, 1<<24);
}
-int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
+int64_t av_get_int(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
@@ -260,9 +262,9 @@ int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
return num*intnum/den;
}
-static void opt_list(void *obj, void *av_log_obj, char *unit)
+static void opt_list(void *obj, void *av_log_obj, const char *unit)
{
- AVOption *opt=NULL;
+ const AVOption *opt=NULL;
while((opt= av_next_option(obj, opt))){
if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM)))
@@ -343,10 +345,12 @@ int av_opt_show(void *obj, void *av_log_obj){
*
* @param s AVCodecContext or AVFormatContext for which the defaults will be set
*/
-void av_opt_set_defaults(void *s)
+void av_opt_set_defaults2(void *s, int mask, int flags)
{
- AVOption *opt = NULL;
+ 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 */
@@ -379,3 +383,7 @@ void av_opt_set_defaults(void *s)
}
}
+void av_opt_set_defaults(void *s){
+ av_opt_set_defaults2(s, 0, 0);
+}
+
diff --git a/contrib/ffmpeg/libavcodec/opt.h b/contrib/ffmpeg/libavcodec/opt.h
index b8a17031b..151dbb788 100644
--- a/contrib/ffmpeg/libavcodec/opt.h
+++ b/contrib/ffmpeg/libavcodec/opt.h
@@ -68,16 +68,18 @@ typedef struct AVOption {
} AVOption;
-AVOption *av_set_string(void *obj, const char *name, const char *val);
-AVOption *av_set_double(void *obj, const char *name, double n);
-AVOption *av_set_q(void *obj, const char *name, AVRational n);
-AVOption *av_set_int(void *obj, const char *name, int64_t n);
-double av_get_double(void *obj, const char *name, AVOption **o_out);
-AVRational av_get_q(void *obj, const char *name, AVOption **o_out);
-int64_t av_get_int(void *obj, const char *name, AVOption **o_out);
-const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len);
-AVOption *av_next_option(void *obj, AVOption *last);
+const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
+const AVOption *av_set_string(void *obj, const char *name, const char *val);
+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);
#endif
diff --git a/contrib/ffmpeg/libavcodec/parser.c b/contrib/ffmpeg/libavcodec/parser.c
index 72a3e55a3..f3e7ee335 100644
--- a/contrib/ffmpeg/libavcodec/parser.c
+++ b/contrib/ffmpeg/libavcodec/parser.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "mpegvideo.h"
#include "mpegaudio.h"
+#include "ac3.h"
#include "parser.h"
AVCodecParser *av_first_parser = NULL;
@@ -69,6 +70,7 @@ AVCodecParserContext *av_parser_init(int codec_id)
}
}
s->fetch_timestamp=1;
+ s->pict_type = FF_I_TYPE;
return s;
}
@@ -91,7 +93,8 @@ AVCodecParserContext *av_parser_init(int codec_id)
* in_data += len;
* in_len -= len;
*
- * decode_frame(data, size);
+ * if(size)
+ * decode_frame(data, size);
* }
* @endcode
*/
@@ -449,7 +452,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
/* no sync found : move by one byte (inefficient, but simple!) */
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
- dprintf("skip %x\n", header);
+ dprintf(avctx, "skip %x\n", header);
/* reset free format frame size to give a chance
to get a new bitrate */
s->free_format_frame_size = 0;
@@ -513,7 +516,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
- dprintf("free frame size=%d padding=%d\n",
+ dprintf(avctx, "free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
decode_header(s, header1);
goto next_data;
@@ -580,60 +583,11 @@ typedef struct AC3ParseContext {
#define AAC_HEADER_SIZE 7
#ifdef CONFIG_AC3_PARSER
-static const int ac3_sample_rates[4] = {
- 48000, 44100, 32000, 0
-};
-
-static const int ac3_frame_sizes[64][3] = {
- { 64, 69, 96 },
- { 64, 70, 96 },
- { 80, 87, 120 },
- { 80, 88, 120 },
- { 96, 104, 144 },
- { 96, 105, 144 },
- { 112, 121, 168 },
- { 112, 122, 168 },
- { 128, 139, 192 },
- { 128, 140, 192 },
- { 160, 174, 240 },
- { 160, 175, 240 },
- { 192, 208, 288 },
- { 192, 209, 288 },
- { 224, 243, 336 },
- { 224, 244, 336 },
- { 256, 278, 384 },
- { 256, 279, 384 },
- { 320, 348, 480 },
- { 320, 349, 480 },
- { 384, 417, 576 },
- { 384, 418, 576 },
- { 448, 487, 672 },
- { 448, 488, 672 },
- { 512, 557, 768 },
- { 512, 558, 768 },
- { 640, 696, 960 },
- { 640, 697, 960 },
- { 768, 835, 1152 },
- { 768, 836, 1152 },
- { 896, 975, 1344 },
- { 896, 976, 1344 },
- { 1024, 1114, 1536 },
- { 1024, 1115, 1536 },
- { 1152, 1253, 1728 },
- { 1152, 1254, 1728 },
- { 1280, 1393, 1920 },
- { 1280, 1394, 1920 },
-};
-static const int ac3_bitrates[64] = {
- 32, 32, 40, 40, 48, 48, 56, 56, 64, 64, 80, 80, 96, 96, 112, 112,
- 128, 128, 160, 160, 192, 192, 224, 224, 256, 256, 320, 320, 384,
- 384, 448, 448, 512, 512, 576, 576, 640, 640,
+static const uint8_t eac3_blocks[4] = {
+ 1, 2, 3, 6
};
-static const int ac3_channels[8] = {
- 2, 1, 2, 3, 3, 4, 4, 5
-};
#endif /* CONFIG_AC3_PARSER */
#ifdef CONFIG_AAC_PARSER
@@ -651,40 +605,60 @@ static const int aac_channels[8] = {
static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
int *bit_rate, int *samples)
{
- unsigned int fscod, frmsizecod, acmod, bsid, lfeon;
+ int err;
+ unsigned int fscod, acmod, bsid, lfeon;
+ unsigned int strmtyp, substreamid, frmsiz, fscod2, numblkscod;
GetBitContext bits;
+ AC3HeaderInfo hdr;
- init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8);
+ err = ff_ac3_parse_header(buf, &hdr);
- if(get_bits(&bits, 16) != 0x0b77)
+ if(err < 0 && err != -2)
return 0;
- skip_bits(&bits, 16); /* crc */
- fscod = get_bits(&bits, 2);
- frmsizecod = get_bits(&bits, 6);
+ bsid = hdr.bsid;
+ if(bsid <= 10) { /* Normal AC-3 */
+ *sample_rate = hdr.sample_rate;
+ *bit_rate = hdr.bit_rate;
+ *channels = hdr.channels;
+ *samples = AC3_FRAME_SIZE;
+ return hdr.frame_size;
+ } else if (bsid > 10 && bsid <= 16) { /* Enhanced AC-3 */
+ init_get_bits(&bits, &buf[2], (AC3_HEADER_SIZE-2) * 8);
+ strmtyp = get_bits(&bits, 2);
+ substreamid = get_bits(&bits, 3);
+
+ if (strmtyp != 0 || substreamid != 0)
+ return 0; /* Currently don't support additional streams */
+
+ frmsiz = get_bits(&bits, 11) + 1;
+ fscod = get_bits(&bits, 2);
+ if (fscod == 3) {
+ fscod2 = get_bits(&bits, 2);
+ numblkscod = 3;
+
+ if(fscod2 == 3)
+ return 0;
+
+ *sample_rate = ff_ac3_freqs[fscod2] / 2;
+ } else {
+ numblkscod = get_bits(&bits, 2);
- if(!ac3_sample_rates[fscod])
- return 0;
+ *sample_rate = ff_ac3_freqs[fscod];
+ }
- bsid = get_bits(&bits, 5);
- if(bsid > 8)
- return 0;
- skip_bits(&bits, 3); /* bsmod */
- acmod = get_bits(&bits, 3);
- if(acmod & 1 && acmod != 1)
- skip_bits(&bits, 2); /* cmixlev */
- if(acmod & 4)
- skip_bits(&bits, 2); /* surmixlev */
- if(acmod & 2)
- skip_bits(&bits, 2); /* dsurmod */
- lfeon = get_bits1(&bits);
-
- *sample_rate = ac3_sample_rates[fscod];
- *bit_rate = ac3_bitrates[frmsizecod] * 1000;
- *channels = ac3_channels[acmod] + lfeon;
- *samples = 6 * 256;
-
- return ac3_frame_sizes[frmsizecod][fscod] * 2;
+ acmod = get_bits(&bits, 3);
+ lfeon = get_bits1(&bits);
+
+ *samples = eac3_blocks[numblkscod] * 256;
+ *bit_rate = frmsiz * (*sample_rate) * 16 / (*samples);
+ *channels = ff_ac3_channels[acmod] + lfeon;
+
+ return frmsiz * 2;
+ }
+
+ /* Unsupported bitstream version */
+ return 0;
}
#endif /* CONFIG_AC3_PARSER */
diff --git a/contrib/ffmpeg/libavcodec/pcm.c b/contrib/ffmpeg/libavcodec/pcm.c
index 26c38b329..5570c01bd 100644
--- a/contrib/ffmpeg/libavcodec/pcm.c
+++ b/contrib/ffmpeg/libavcodec/pcm.c
@@ -74,11 +74,8 @@ static int ulaw2linear(unsigned char u_val)
}
/* 16384 entries per table */
-static uint8_t *linear_to_alaw = NULL;
-static int linear_to_alaw_ref = 0;
-
-static uint8_t *linear_to_ulaw = NULL;
-static int linear_to_ulaw_ref = 0;
+static uint8_t linear_to_alaw[16384];
+static uint8_t linear_to_ulaw[16384];
static void build_xlaw_table(uint8_t *linear_to_xlaw,
int (*xlaw2linear)(unsigned char),
@@ -109,22 +106,10 @@ static int pcm_encode_init(AVCodecContext *avctx)
avctx->frame_size = 1;
switch(avctx->codec->id) {
case CODEC_ID_PCM_ALAW:
- if (linear_to_alaw_ref == 0) {
- linear_to_alaw = av_malloc(16384);
- if (!linear_to_alaw)
- return -1;
- build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);
- }
- linear_to_alaw_ref++;
+ build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);
break;
case CODEC_ID_PCM_MULAW:
- if (linear_to_ulaw_ref == 0) {
- linear_to_ulaw = av_malloc(16384);
- if (!linear_to_ulaw)
- return -1;
- build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
- }
- linear_to_ulaw_ref++;
+ build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
break;
default:
break;
@@ -170,19 +155,6 @@ static int pcm_encode_close(AVCodecContext *avctx)
{
av_freep(&avctx->coded_frame);
- switch(avctx->codec->id) {
- case CODEC_ID_PCM_ALAW:
- if (--linear_to_alaw_ref == 0)
- av_free(linear_to_alaw);
- break;
- case CODEC_ID_PCM_MULAW:
- if (--linear_to_ulaw_ref == 0)
- av_free(linear_to_ulaw);
- break;
- default:
- /* nothing to free */
- break;
- }
return 0;
}
@@ -410,8 +382,14 @@ static int pcm_decode_frame(AVCodecContext *avctx,
samples = data;
src = buf;
- if(buf_size > AVCODEC_MAX_AUDIO_FRAME_SIZE/2)
- buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE/2;
+ n= av_get_bits_per_sample(avctx->codec_id)/8;
+ if(n && buf_size % n){
+ av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
+ return -1;
+ }
+
+ buf_size= FFMIN(buf_size, *data_size/2);
+ *data_size=0;
switch(avctx->codec->id) {
case CODEC_ID_PCM_S32LE:
diff --git a/contrib/ffmpeg/libavcodec/png.c b/contrib/ffmpeg/libavcodec/png.c
index a257492b7..05b4512b7 100644
--- a/contrib/ffmpeg/libavcodec/png.c
+++ b/contrib/ffmpeg/libavcodec/png.c
@@ -25,7 +25,6 @@
* - use filters when generating a png (better compression)
*/
-#ifdef CONFIG_ZLIB
#include <zlib.h>
//#define DEBUG
@@ -345,7 +344,7 @@ static void png_filter_row(uint8_t *dst, int filter_type,
}
#ifdef CONFIG_ENCODERS
-static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width)
+static void convert_from_rgb32(uint8_t *dst, const uint8_t *src, int width)
{
uint8_t *d;
int j;
@@ -364,7 +363,7 @@ static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width)
#endif
#ifdef CONFIG_DECODERS
-static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width)
+static void convert_to_rgb32(uint8_t *dst, const uint8_t *src, int width)
{
int j;
unsigned int r, g, b, a;
@@ -393,7 +392,7 @@ static void png_handle_row(PNGContext *s)
png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
s->last_row, s->row_size, s->bpp);
memcpy(s->last_row, s->tmp_row, s->row_size);
- convert_to_rgba32(ptr, s->tmp_row, s->width);
+ convert_to_rgb32(ptr, s->tmp_row, s->width);
} else {
/* in normal case, we avoid one copy */
if (s->y == 0)
@@ -423,7 +422,7 @@ static void png_handle_row(PNGContext *s)
got_line = 1;
}
if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
- /* NOTE: rgba32 is handled directly in png_put_interlaced_row */
+ /* NOTE: RGB32 is handled directly in png_put_interlaced_row */
png_put_interlaced_row(ptr, s->width, s->bits_per_pixel, s->pass,
s->color_type, s->last_row);
}
@@ -563,7 +562,7 @@ static int decode_frame(AVCodecContext *avctx,
avctx->pix_fmt = PIX_FMT_RGB24;
} else if (s->bit_depth == 8 &&
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
} else if (s->bit_depth == 8 &&
s->color_type == PNG_COLOR_TYPE_GRAY) {
avctx->pix_fmt = PIX_FMT_GRAY8;
@@ -783,7 +782,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
is_progressive = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
switch(avctx->pix_fmt) {
- case PIX_FMT_RGBA32:
+ case PIX_FMT_RGB32:
bit_depth = 8;
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
break;
@@ -883,7 +882,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
if ((png_pass_ymask[pass] << (y & 7)) & 0x80) {
ptr = p->data[0] + y * p->linesize[0];
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- convert_from_rgba32(tmp_buf, ptr, avctx->width);
+ convert_from_rgb32(tmp_buf, ptr, avctx->width);
ptr1 = tmp_buf;
} else {
ptr1 = ptr;
@@ -901,7 +900,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
for(y = 0; y < avctx->height; y++) {
ptr = p->data[0] + y * p->linesize[0];
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- convert_from_rgba32(crow_buf + 1, ptr, avctx->width);
+ convert_from_rgb32(crow_buf + 1, ptr, avctx->width);
else
memcpy(crow_buf + 1, ptr, row_size);
crow_buf[0] = PNG_FILTER_VALUE_NONE;
@@ -962,7 +961,6 @@ AVCodec png_encoder = {
common_init,
encode_frame,
NULL, //encode_end,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, -1},
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_PAL8, PIX_FMT_GRAY8, PIX_FMT_MONOBLACK, -1},
};
#endif // CONFIG_PNG_ENCODER
-#endif
diff --git a/contrib/ffmpeg/libavcodec/pnm.c b/contrib/ffmpeg/libavcodec/pnm.c
index 610bb28be..4c9c46fee 100644
--- a/contrib/ffmpeg/libavcodec/pnm.c
+++ b/contrib/ffmpeg/libavcodec/pnm.c
@@ -124,7 +124,7 @@ static int pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
} else if (depth == 3) {
avctx->pix_fmt = PIX_FMT_RGB24;
} else if (depth == 4) {
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
} else {
return -1;
}
@@ -240,7 +240,7 @@ static int pnm_decode_frame(AVCodecContext *avctx,
}
}
break;
- case PIX_FMT_RGBA32:
+ case PIX_FMT_RGB32:
ptr = p->data[0];
linesize = p->linesize[0];
if(s->bytestream + avctx->width*avctx->height*4 > s->bytestream_end)
@@ -389,7 +389,7 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
maxval = 255;
tuple_type = "RGB";
break;
- case PIX_FMT_RGBA32:
+ case PIX_FMT_RGB32:
n = w * 4;
depth = 4;
maxval = 255;
@@ -406,7 +406,7 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int bu
ptr = p->data[0];
linesize = p->linesize[0];
- if (avctx->pix_fmt == PIX_FMT_RGBA32) {
+ if (avctx->pix_fmt == PIX_FMT_RGB32) {
int j;
unsigned int v;
@@ -601,6 +601,6 @@ AVCodec pam_encoder = {
pam_encode_frame,
NULL, //encode_end,
pnm_decode_frame,
- .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, -1},
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, -1},
};
#endif // CONFIG_PAM_ENCODER
diff --git a/contrib/ffmpeg/libavcodec/ppc/dsputil_altivec.c b/contrib/ffmpeg/libavcodec/ppc/dsputil_altivec.c
index 6f48893a4..bbc53d761 100644
--- a/contrib/ffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/contrib/ffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -1107,12 +1107,10 @@ POWERPC_PERF_START_COUNT(altivec_hadamard8_diff8x8_num, 1);
register vector signed short srcV, dstV; \
register vector signed short but0, but1, but2, op1, op2, op3; \
src1 = vec_ld(stride * i, src); \
- if ((((stride * i) + (unsigned long)src) & 0x0000000F) > 8) \
- src2 = vec_ld((stride * i) + 16, src); \
+ src2 = vec_ld((stride * i) + 15, src); \
srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
dst1 = vec_ld(stride * i, dst); \
- if ((((stride * i) + (unsigned long)dst) & 0x0000000F) > 8) \
- dst2 = vec_ld((stride * i) + 16, dst); \
+ dst2 = vec_ld((stride * i) + 15, dst); \
dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
/* promote the unsigned chars to signed shorts */ \
/* we're in the 8x8 function, we only care for the first 8 */ \
diff --git a/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.c b/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.c
index 9169eaef0..117a7adf1 100644
--- a/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.c
+++ b/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.c
@@ -55,7 +55,7 @@ int mm_support(void)
return result;
}
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
/* list below must match enum in dsputil_ppc.h */
static unsigned char* perfname[] = {
@@ -90,7 +90,7 @@ static unsigned char* perfname[] = {
#include <stdio.h>
#endif
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
void powerpc_display_perf_report(void)
{
int i, j;
@@ -112,7 +112,7 @@ void powerpc_display_perf_report(void)
}
}
}
-#endif /* POWERPC_PERFORMANCE_REPORT */
+#endif /* CONFIG_POWERPC_PERF */
/* ***** WARNING ***** WARNING ***** WARNING ***** */
/*
@@ -305,7 +305,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
}
}
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
{
int i, j;
for (i = 0 ; i < powerpc_perf_total ; i++)
@@ -319,7 +319,7 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
}
}
}
-#endif /* POWERPC_PERFORMANCE_REPORT */
+#endif /* CONFIG_POWERPC_PERF */
}
#endif /* HAVE_ALTIVEC */
}
diff --git a/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.h b/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.h
index ab2b05780..5b25732b2 100644
--- a/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.h
+++ b/contrib/ffmpeg/libavcodec/ppc/dsputil_ppc.h
@@ -21,7 +21,7 @@
#ifndef _DSPUTIL_PPC_
#define _DSPUTIL_PPC_
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
void powerpc_display_perf_report(void);
/* the 604* have 2, the G3* have 4, the G4s have 6,
and the G5 are completely different (they MUST use
@@ -145,11 +145,11 @@ extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][
} \
} \
} while (0)
-#else /* POWERPC_PERFORMANCE_REPORT */
+#else /* CONFIG_POWERPC_PERF */
// those are needed to avoid empty statements.
#define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
#define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
#define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
-#endif /* POWERPC_PERFORMANCE_REPORT */
+#endif /* CONFIG_POWERPC_PERF */
#endif /* _DSPUTIL_PPC_ */
diff --git a/contrib/ffmpeg/libavcodec/ppc/float_altivec.c b/contrib/ffmpeg/libavcodec/ppc/float_altivec.c
index c6e43dec2..22c2de61a 100644
--- a/contrib/ffmpeg/libavcodec/ppc/float_altivec.c
+++ b/contrib/ffmpeg/libavcodec/ppc/float_altivec.c
@@ -76,7 +76,6 @@ static void vector_fmul_add_add_altivec(float *dst, const float *src0,
vector unsigned char align = vec_lvsr(0,dst),
mask = vec_lvsl(0, dst);
- t0 = vec_ld(0, dst);
#if 0 //FIXME: there is still something wrong
if (step == 2) {
int y;
@@ -134,6 +133,7 @@ static void vector_fmul_add_add_altivec(float *dst, const float *src0,
#endif
if (step == 1 && src3 == 0)
for (i=0; i<len-3; i+=4) {
+ t0 = vec_ld(0, dst+i);
t1 = vec_ld(15, dst+i);
s0 = vec_ld(0, src0+i);
s1 = vec_ld(0, src1+i);
@@ -144,7 +144,6 @@ static void vector_fmul_add_add_altivec(float *dst, const float *src0,
t0 = vec_perm(edges, d, align);
vec_st(t1, 15, dst+i);
vec_st(t0, 0, dst+i);
- t0 = t1;
}
else
ff_vector_fmul_add_add_c(dst, src0, src1, src2, src3, len, step);
diff --git a/contrib/ffmpeg/libavcodec/ppc/h264_altivec.c b/contrib/ffmpeg/libavcodec/ppc/h264_altivec.c
index 4aa366f97..bac620e82 100644
--- a/contrib/ffmpeg/libavcodec/ppc/h264_altivec.c
+++ b/contrib/ffmpeg/libavcodec/ppc/h264_altivec.c
@@ -23,6 +23,7 @@
#include "gcc_fixes.h"
#include "dsputil_altivec.h"
+#include "types_altivec.h"
#define PUT_OP_U8_ALTIVEC(d, s, dst) d = s
#define AVG_OP_U8_ALTIVEC(d, s, dst) d = vec_avg(dst, s)
@@ -202,7 +203,7 @@ void put_no_rnd_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride
vector signed short vsrc0ssH, vsrc1ssH;
vector unsigned char vsrcCuc, vsrc2uc, vsrc3uc;
vector signed short vsrc2ssH, vsrc3ssH, psum;
- vector unsigned char vdst, ppsum, vfdst, fsum;
+ vector unsigned char vdst, ppsum, fsum;
if (((unsigned long)dst) % 16 == 0) {
fperm = (vector unsigned char)AVV(0x10, 0x11, 0x12, 0x13,
@@ -398,6 +399,131 @@ static inline void avg_pixels16_l2_altivec( uint8_t * dst, const uint8_t * src1,
H264_MC(put_, 16, altivec)
H264_MC(avg_, 16, altivec)
+
+/****************************************************************************
+ * IDCT transform:
+ ****************************************************************************/
+
+#define IDCT8_1D_ALTIVEC(s0, s1, s2, s3, s4, s5, s6, s7, d0, d1, d2, d3, d4, d5, d6, d7) {\
+ /* a0 = SRC(0) + SRC(4); */ \
+ vec_s16_t a0v = vec_add(s0, s4); \
+ /* a2 = SRC(0) - SRC(4); */ \
+ vec_s16_t a2v = vec_sub(s0, s4); \
+ /* a4 = (SRC(2)>>1) - SRC(6); */ \
+ vec_s16_t a4v = vec_sub(vec_sra(s2, onev), s6); \
+ /* a6 = (SRC(6)>>1) + SRC(2); */ \
+ vec_s16_t a6v = vec_add(vec_sra(s6, onev), s2); \
+ /* b0 = a0 + a6; */ \
+ vec_s16_t b0v = vec_add(a0v, a6v); \
+ /* b2 = a2 + a4; */ \
+ vec_s16_t b2v = vec_add(a2v, a4v); \
+ /* b4 = a2 - a4; */ \
+ vec_s16_t b4v = vec_sub(a2v, a4v); \
+ /* b6 = a0 - a6; */ \
+ vec_s16_t b6v = vec_sub(a0v, a6v); \
+ /* a1 = SRC(5) - SRC(3) - SRC(7) - (SRC(7)>>1); */ \
+ /* a1 = (SRC(5)-SRC(3)) - (SRC(7) + (SRC(7)>>1)); */ \
+ vec_s16_t a1v = vec_sub( vec_sub(s5, s3), vec_add(s7, vec_sra(s7, onev)) ); \
+ /* a3 = SRC(7) + SRC(1) - SRC(3) - (SRC(3)>>1); */ \
+ /* a3 = (SRC(7)+SRC(1)) - (SRC(3) + (SRC(3)>>1)); */ \
+ vec_s16_t a3v = vec_sub( vec_add(s7, s1), vec_add(s3, vec_sra(s3, onev)) );\
+ /* a5 = SRC(7) - SRC(1) + SRC(5) + (SRC(5)>>1); */ \
+ /* a5 = (SRC(7)-SRC(1)) + SRC(5) + (SRC(5)>>1); */ \
+ vec_s16_t a5v = vec_add( vec_sub(s7, s1), vec_add(s5, vec_sra(s5, onev)) );\
+ /* a7 = SRC(5)+SRC(3) + SRC(1) + (SRC(1)>>1); */ \
+ vec_s16_t a7v = vec_add( vec_add(s5, s3), vec_add(s1, vec_sra(s1, onev)) );\
+ /* b1 = (a7>>2) + a1; */ \
+ vec_s16_t b1v = vec_add( vec_sra(a7v, twov), a1v); \
+ /* b3 = a3 + (a5>>2); */ \
+ vec_s16_t b3v = vec_add(a3v, vec_sra(a5v, twov)); \
+ /* b5 = (a3>>2) - a5; */ \
+ vec_s16_t b5v = vec_sub( vec_sra(a3v, twov), a5v); \
+ /* b7 = a7 - (a1>>2); */ \
+ vec_s16_t b7v = vec_sub( a7v, vec_sra(a1v, twov)); \
+ /* DST(0, b0 + b7); */ \
+ d0 = vec_add(b0v, b7v); \
+ /* DST(1, b2 + b5); */ \
+ d1 = vec_add(b2v, b5v); \
+ /* DST(2, b4 + b3); */ \
+ d2 = vec_add(b4v, b3v); \
+ /* DST(3, b6 + b1); */ \
+ d3 = vec_add(b6v, b1v); \
+ /* DST(4, b6 - b1); */ \
+ d4 = vec_sub(b6v, b1v); \
+ /* DST(5, b4 - b3); */ \
+ d5 = vec_sub(b4v, b3v); \
+ /* DST(6, b2 - b5); */ \
+ d6 = vec_sub(b2v, b5v); \
+ /* DST(7, b0 - b7); */ \
+ d7 = vec_sub(b0v, b7v); \
+}
+
+#define ALTIVEC_STORE_SUM_CLIP(dest, idctv, perm_ldv, perm_stv, sel) { \
+ /* unaligned load */ \
+ vec_u8_t hv = vec_ld( 0, dest ); \
+ vec_u8_t lv = vec_ld( 7, dest ); \
+ vec_u8_t dstv = vec_perm( hv, lv, (vec_u8_t)perm_ldv ); \
+ vec_s16_t idct_sh6 = vec_sra(idctv, sixv); \
+ vec_u16_t dst16 = (vec_u16_t)vec_mergeh(zero_u8v, dstv); \
+ vec_s16_t idstsum = vec_adds(idct_sh6, (vec_s16_t)dst16); \
+ vec_u8_t idstsum8 = vec_packsu(zero_s16v, idstsum); \
+ vec_u8_t edgehv; \
+ /* unaligned store */ \
+ vec_u8_t bodyv = vec_perm( idstsum8, idstsum8, perm_stv );\
+ vec_u8_t edgelv = vec_perm( sel, zero_u8v, perm_stv ); \
+ lv = vec_sel( lv, bodyv, edgelv ); \
+ vec_st( lv, 7, dest ); \
+ hv = vec_ld( 0, dest ); \
+ edgehv = vec_perm( zero_u8v, sel, perm_stv ); \
+ hv = vec_sel( hv, bodyv, edgehv ); \
+ vec_st( hv, 0, dest ); \
+ }
+
+void ff_h264_idct8_add_altivec( uint8_t *dst, DCTELEM *dct, int stride ) {
+ vec_s16_t s0, s1, s2, s3, s4, s5, s6, s7;
+ vec_s16_t d0, d1, d2, d3, d4, d5, d6, d7;
+ vec_s16_t idct0, idct1, idct2, idct3, idct4, idct5, idct6, idct7;
+
+ vec_u8_t perm_ldv = vec_lvsl(0, dst);
+ vec_u8_t perm_stv = vec_lvsr(8, dst);
+
+ const vec_u16_t onev = vec_splat_u16(1);
+ const vec_u16_t twov = vec_splat_u16(2);
+ const vec_u16_t sixv = vec_splat_u16(6);
+
+ const vec_u8_t sel = (vec_u8_t) AVV(0,0,0,0,0,0,0,0,
+ -1,-1,-1,-1,-1,-1,-1,-1);
+ LOAD_ZERO;
+
+ dct[0] += 32; // rounding for the >>6 at the end
+
+ s0 = vec_ld(0x00, (int16_t*)dct);
+ s1 = vec_ld(0x10, (int16_t*)dct);
+ s2 = vec_ld(0x20, (int16_t*)dct);
+ s3 = vec_ld(0x30, (int16_t*)dct);
+ s4 = vec_ld(0x40, (int16_t*)dct);
+ s5 = vec_ld(0x50, (int16_t*)dct);
+ s6 = vec_ld(0x60, (int16_t*)dct);
+ s7 = vec_ld(0x70, (int16_t*)dct);
+
+ IDCT8_1D_ALTIVEC(s0, s1, s2, s3, s4, s5, s6, s7,
+ d0, d1, d2, d3, d4, d5, d6, d7);
+
+ TRANSPOSE8( d0, d1, d2, d3, d4, d5, d6, d7 );
+
+ IDCT8_1D_ALTIVEC(d0, d1, d2, d3, d4, d5, d6, d7,
+ idct0, idct1, idct2, idct3, idct4, idct5, idct6, idct7);
+
+ ALTIVEC_STORE_SUM_CLIP(&dst[0*stride], idct0, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[1*stride], idct1, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[2*stride], idct2, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[3*stride], idct3, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[4*stride], idct4, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[5*stride], idct5, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[6*stride], idct6, perm_ldv, perm_stv, sel);
+ ALTIVEC_STORE_SUM_CLIP(&dst[7*stride], idct7, perm_ldv, perm_stv, sel);
+}
+
void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
#ifdef HAVE_ALTIVEC
@@ -405,6 +531,7 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
c->put_no_rnd_h264_chroma_pixels_tab[0] = put_no_rnd_h264_chroma_mc8_altivec;
c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
+ c->h264_idct8_add = ff_h264_idct8_add_altivec;
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_altivec; \
diff --git a/contrib/ffmpeg/libavcodec/ppc/idct_altivec.c b/contrib/ffmpeg/libavcodec/ppc/idct_altivec.c
index cee46fc25..66c8082f7 100644
--- a/contrib/ffmpeg/libavcodec/ppc/idct_altivec.c
+++ b/contrib/ffmpeg/libavcodec/ppc/idct_altivec.c
@@ -171,7 +171,7 @@ void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)
POWERPC_PERF_DECLARE(altivec_idct_put_num, 1);
vector_u8_t tmp;
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1);
#endif
IDCT
@@ -202,7 +202,7 @@ POWERPC_PERF_DECLARE(altivec_idct_add_num, 1);
vector_u8_t perm1;
vector_u8_t p0, p1, p;
-#ifdef POWERPC_PERFORMANCE_REPORT
+#ifdef CONFIG_POWERPC_PERF
POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1);
#endif
diff --git a/contrib/ffmpeg/libavcodec/pthread.c b/contrib/ffmpeg/libavcodec/pthread.c
index 4737211cb..f2c636bbe 100644
--- a/contrib/ffmpeg/libavcodec/pthread.c
+++ b/contrib/ffmpeg/libavcodec/pthread.c
@@ -76,7 +76,7 @@ static void* worker(void *v)
}
}
-static always_inline void avcodec_thread_park_workers(ThreadContext *c, int thread_count)
+static av_always_inline void avcodec_thread_park_workers(ThreadContext *c, int thread_count)
{
pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
pthread_mutex_unlock(&c->current_job_lock);
diff --git a/contrib/ffmpeg/libavcodec/qdm2.c b/contrib/ffmpeg/libavcodec/qdm2.c
index b9462f3cb..a2630fe7f 100644
--- a/contrib/ffmpeg/libavcodec/qdm2.c
+++ b/contrib/ffmpeg/libavcodec/qdm2.c
@@ -1836,7 +1836,7 @@ static int qdm2_decode_init(AVCodecContext *avctx)
extradata += 8;
extradata_size -= 8;
- size = BE_32(extradata);
+ size = AV_RB32(extradata);
if(size > extradata_size){
av_log(avctx, AV_LOG_ERROR, "extradata size too small, %i < %i\n",
@@ -1846,29 +1846,29 @@ static int qdm2_decode_init(AVCodecContext *avctx)
extradata += 4;
av_log(avctx, AV_LOG_DEBUG, "size: %d\n", size);
- if (BE_32(extradata) != MKBETAG('Q','D','C','A')) {
+ if (AV_RB32(extradata) != MKBETAG('Q','D','C','A')) {
av_log(avctx, AV_LOG_ERROR, "invalid extradata, expecting QDCA\n");
return -1;
}
extradata += 8;
- avctx->channels = s->nb_channels = s->channels = BE_32(extradata);
+ avctx->channels = s->nb_channels = s->channels = AV_RB32(extradata);
extradata += 4;
- avctx->sample_rate = BE_32(extradata);
+ avctx->sample_rate = AV_RB32(extradata);
extradata += 4;
- avctx->bit_rate = BE_32(extradata);
+ avctx->bit_rate = AV_RB32(extradata);
extradata += 4;
- s->group_size = BE_32(extradata);
+ s->group_size = AV_RB32(extradata);
extradata += 4;
- s->fft_size = BE_32(extradata);
+ s->fft_size = AV_RB32(extradata);
extradata += 4;
- s->checksum_size = BE_32(extradata);
+ s->checksum_size = AV_RB32(extradata);
extradata += 4;
s->fft_order = av_log2(s->fft_size) + 1;
diff --git a/contrib/ffmpeg/libavcodec/qdrw.c b/contrib/ffmpeg/libavcodec/qdrw.c
index 8ebb43c4a..664be2f4f 100644
--- a/contrib/ffmpeg/libavcodec/qdrw.c
+++ b/contrib/ffmpeg/libavcodec/qdrw.c
@@ -58,7 +58,7 @@ static int decode_frame(AVCodecContext *avctx,
outdata = a->pic.data[0];
buf += 0x68; /* jump to palette */
- colors = BE_32(buf);
+ colors = AV_RB32(buf);
buf += 4;
if(colors < 0 || colors > 256) {
@@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx,
for (i = 0; i <= colors; i++) {
unsigned int idx;
- idx = BE_16(buf); /* color index */
+ idx = AV_RB16(buf); /* color index */
buf += 2;
if (idx > 255) {
@@ -93,7 +93,7 @@ static int decode_frame(AVCodecContext *avctx,
/* decode line */
out = outdata;
- size = BE_16(buf); /* size of packed line */
+ size = AV_RB16(buf); /* size of packed line */
buf += 2;
left = size;
next = buf + size;
diff --git a/contrib/ffmpeg/libavcodec/qpeg.c b/contrib/ffmpeg/libavcodec/qpeg.c
index 3c597e8df..d995bc3b7 100644
--- a/contrib/ffmpeg/libavcodec/qpeg.c
+++ b/contrib/ffmpeg/libavcodec/qpeg.c
@@ -293,7 +293,6 @@ static int decode_init(AVCodecContext *avctx){
a->avctx = avctx;
avctx->pix_fmt= PIX_FMT_PAL8;
- avctx->has_b_frames = 0;
a->pic.data[0] = NULL;
a->refdata = av_malloc(avctx->width * avctx->height);
diff --git a/contrib/ffmpeg/libavcodec/qtrle.c b/contrib/ffmpeg/libavcodec/qtrle.c
index d4b314d03..415f08098 100644
--- a/contrib/ffmpeg/libavcodec/qtrle.c
+++ b/contrib/ffmpeg/libavcodec/qtrle.c
@@ -29,7 +29,7 @@
* The QT RLE decoder has seven modes of operation:
* 1, 2, 4, 8, 16, 24, and 32 bits per pixel. For modes 1, 2, 4, and 8
* the decoder outputs PAL8 colorspace data. 16-bit data yields RGB555
- * data. 24-bit data is RGB24 and 32-bit data is RGBA32.
+ * data. 24-bit data is RGB24 and 32-bit data is RGB32.
*/
#include <stdio.h>
@@ -96,15 +96,15 @@ static void qtrle_decode_4bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -187,15 +187,15 @@ static void qtrle_decode_8bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -269,15 +269,15 @@ static void qtrle_decode_16bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -299,7 +299,7 @@ static void qtrle_decode_16bpp(QtrleContext *s)
/* decode the run length code */
rle_code = -rle_code;
CHECK_STREAM_PTR(2);
- rgb16 = BE_16(&s->buf[stream_ptr]);
+ rgb16 = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(rle_code * 2);
@@ -314,7 +314,7 @@ static void qtrle_decode_16bpp(QtrleContext *s)
/* copy pixels directly to output */
while (rle_code--) {
- rgb16 = BE_16(&s->buf[stream_ptr]);
+ rgb16 = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
*(unsigned short *)(&rgb[pixel_ptr]) = rgb16;
pixel_ptr += 2;
@@ -347,15 +347,15 @@ static void qtrle_decode_24bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -427,15 +427,15 @@ static void qtrle_decode_32bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -515,7 +515,7 @@ static int qtrle_decode_init(AVCodecContext *avctx)
break;
case 32:
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
break;
default:
diff --git a/contrib/ffmpeg/libavcodec/rangecoder.c b/contrib/ffmpeg/libavcodec/rangecoder.c
index 1f35d0852..fcd564ace 100644
--- a/contrib/ffmpeg/libavcodec/rangecoder.c
+++ b/contrib/ffmpeg/libavcodec/rangecoder.c
@@ -66,28 +66,6 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
memset(c->zero_state, 0, sizeof(c->zero_state));
memset(c-> one_state, 0, sizeof(c-> one_state));
-#if 0
- for(i=1; i<256; i++){
- if(c->one_state[i])
- continue;
-
- p= (i*one + 128) >> 8;
- last_p8= i;
- for(;;){
- p+= ((one-p)*factor + one/2) >> 32;
- p8= (256*p + one/2) >> 32; //FIXME try without the one
- if(p8 <= last_p8) p8= last_p8+1;
- if(p8 > max_p) p8= max_p;
- if(p8 < last_p8)
- break;
- c->one_state[last_p8]= p8;
- if(p8 == last_p8)
- break;
- last_p8= p8;
- }
- }
-#endif
-#if 1
last_p8= 0;
p= one/2;
for(i=0; i<128; i++){
@@ -99,7 +77,7 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
p+= ((one-p)*factor + one/2) >> 32;
last_p8= p8;
}
-#endif
+
for(i=256-max_p; i<=max_p; i++){
if(c->one_state[i])
continue;
@@ -114,10 +92,6 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
for(i=1; i<255; i++)
c->zero_state[i]= 256-c->one_state[256-i];
-#if 0
- for(i=0; i<256; i++)
- av_log(NULL, AV_LOG_DEBUG, "%3d %3d\n", i, c->one_state[i]);
-#endif
}
/**
@@ -155,7 +129,6 @@ int main(){
r[i]= random()%7;
}
-
for(i=0; i<SIZE; i++){
START_TIMER
put_rac(&c, state, r[i]&1);
@@ -177,5 +150,4 @@ STOP_TIMER("get_rac")
return 0;
}
-
#endif
diff --git a/contrib/ffmpeg/libavcodec/ratecontrol.c b/contrib/ffmpeg/libavcodec/ratecontrol.c
index d96c837e6..6d9270da8 100644
--- a/contrib/ffmpeg/libavcodec/ratecontrol.c
+++ b/contrib/ffmpeg/libavcodec/ratecontrol.c
@@ -280,7 +280,7 @@ int ff_vbv_update(MpegEncContext *s, int frame_size){
}
left= buffer_size - rcc->buffer_index - 1;
- rcc->buffer_index += clip(left, min_rate, max_rate);
+ rcc->buffer_index += av_clip(left, min_rate, max_rate);
if(rcc->buffer_index > buffer_size){
int stuffing= ceil((rcc->buffer_index - buffer_size)/8);
@@ -417,8 +417,8 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic
qmax= (int)(qmax*FFABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
}
- qmin= clip(qmin, 1, FF_LAMBDA_MAX);
- qmax= clip(qmax, 1, FF_LAMBDA_MAX);
+ qmin= av_clip(qmin, 1, FF_LAMBDA_MAX);
+ qmax= av_clip(qmax, 1, FF_LAMBDA_MAX);
if(qmax<qmin) qmax= qmin;
@@ -751,7 +751,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
//printf("%f ", q);
assert(q>0.0);
- if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependant blur like in 2-pass
+ if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependent blur like in 2-pass
rcc->short_term_qsum*=a->qblur;
rcc->short_term_qcount*=a->qblur;
@@ -811,7 +811,7 @@ static int init_pass2(MpegEncContext *s)
int i, toobig;
double fps= 1/av_q2d(s->avctx->time_base);
double complexity[5]={0,0,0,0,0}; // aproximate bits at quant=1
- uint64_t const_bits[5]={0,0,0,0,0}; // quantizer idependant bits
+ uint64_t const_bits[5]={0,0,0,0,0}; // quantizer independent bits
uint64_t all_const_bits;
uint64_t all_available_bits= (uint64_t)(s->bit_rate*(double)rcc->num_entries/fps);
double rate_factor=0;
@@ -915,7 +915,7 @@ static int init_pass2(MpegEncContext *s)
for(i=0; i<rcc->num_entries; i++){
/* av_log(s->avctx, AV_LOG_DEBUG, "[lavc rc] entry[%d].new_qscale = %.3f qp = %.3f\n",
i, rcc->entry[i].new_qscale, rcc->entry[i].new_qscale / FF_QP2LAMBDA); */
- qscale_sum += clip(rcc->entry[i].new_qscale / FF_QP2LAMBDA, s->avctx->qmin, s->avctx->qmax);
+ qscale_sum += av_clip(rcc->entry[i].new_qscale / FF_QP2LAMBDA, s->avctx->qmin, s->avctx->qmax);
}
assert(toobig <= 40);
av_log(s->avctx, AV_LOG_DEBUG,
diff --git a/contrib/ffmpeg/libavcodec/raw.c b/contrib/ffmpeg/libavcodec/raw.c
index f4fddf73c..268779803 100644
--- a/contrib/ffmpeg/libavcodec/raw.c
+++ b/contrib/ffmpeg/libavcodec/raw.c
@@ -48,8 +48,8 @@ static const PixelFormatTag pixelFormatTags[] = {
{ PIX_FMT_GRAY8, MKTAG(' ', ' ', 'Y', '8') },
- { PIX_FMT_YUV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */
- { PIX_FMT_YUV422, MKTAG('Y', '4', '2', '2') },
+ { PIX_FMT_YUYV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */
+ { PIX_FMT_YUYV422, MKTAG('Y', '4', '2', '2') },
{ PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') },
{ PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') },
{ PIX_FMT_RGB555, MKTAG('R', 'G', 'B', 15) },
@@ -59,13 +59,32 @@ static const PixelFormatTag pixelFormatTags[] = {
/* quicktime */
{ PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
+ { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */
{ -1, 0 },
};
-static int findPixelFormat(unsigned int fourcc)
+static const PixelFormatTag pixelFormatBpsAVI[] = {
+ { PIX_FMT_PAL8, 8 },
+ { PIX_FMT_RGB555, 15 },
+ { PIX_FMT_RGB555, 16 },
+ { PIX_FMT_BGR24, 24 },
+ { PIX_FMT_RGB32, 32 },
+ { -1, 0 },
+};
+
+static const PixelFormatTag pixelFormatBpsMOV[] = {
+ /* FIXME fix swscaler to support those */
+ /* http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html */
+ { PIX_FMT_PAL8, 8 },
+ { PIX_FMT_BGR555, 16 },
+ { PIX_FMT_RGB24, 24 },
+ { PIX_FMT_BGR32_1, 32 },
+ { -1, 0 },
+};
+
+static int findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
{
- const PixelFormatTag * tags = pixelFormatTags;
while (tags->pix_fmt >= 0) {
if (tags->fourcc == fourcc)
return tags->pix_fmt;
@@ -91,17 +110,12 @@ static int raw_init_decoder(AVCodecContext *avctx)
{
RawVideoContext *context = avctx->priv_data;
- if (avctx->codec_tag)
- avctx->pix_fmt = findPixelFormat(avctx->codec_tag);
- else if (avctx->bits_per_sample){
- switch(avctx->bits_per_sample){
- case 8: avctx->pix_fmt= PIX_FMT_PAL8 ; break;
- case 15: avctx->pix_fmt= PIX_FMT_RGB555; break;
- case 16: avctx->pix_fmt= PIX_FMT_RGB555; break;
- case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break;
- case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break;
- }
- }
+ if (avctx->codec_tag == MKTAG('r','a','w',' '))
+ avctx->pix_fmt = findPixelFormat(pixelFormatBpsMOV, avctx->bits_per_sample);
+ else if (avctx->codec_tag)
+ avctx->pix_fmt = findPixelFormat(pixelFormatTags, avctx->codec_tag);
+ else if (avctx->bits_per_sample)
+ avctx->pix_fmt = findPixelFormat(pixelFormatBpsAVI, avctx->bits_per_sample);
context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
context->buffer = av_malloc(context->length);
diff --git a/contrib/ffmpeg/libavcodec/resample.c b/contrib/ffmpeg/libavcodec/resample.c
index 043e812c8..ea5c6d61c 100644
--- a/contrib/ffmpeg/libavcodec/resample.c
+++ b/contrib/ffmpeg/libavcodec/resample.c
@@ -161,7 +161,8 @@ ReSampleContext *audio_resample_init(int output_channels, int input_channels,
if(s->filter_channels>2)
s->filter_channels = 2;
- s->resample_context= av_resample_init(output_rate, input_rate, 16, 10, 0, 1.0);
+#define TAPS 16
+ s->resample_context= av_resample_init(output_rate, input_rate, TAPS, 10, 0, 0.8);
return s;
}
diff --git a/contrib/ffmpeg/libavcodec/resample2.c b/contrib/ffmpeg/libavcodec/resample2.c
index 3ae0ba855..4209b9705 100644
--- a/contrib/ffmpeg/libavcodec/resample2.c
+++ b/contrib/ffmpeg/libavcodec/resample2.c
@@ -30,20 +30,31 @@
#include "common.h"
#include "dsputil.h"
-#if 1
+#ifndef CONFIG_RESAMPLE_HP
#define FILTER_SHIFT 15
#define FELEM int16_t
#define FELEM2 int32_t
+#define FELEML int64_t
#define FELEM_MAX INT16_MAX
#define FELEM_MIN INT16_MIN
-#else
-#define FILTER_SHIFT 22
+#define WINDOW_TYPE 9
+#elif !defined(CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE)
+#define FILTER_SHIFT 30
#define FELEM int32_t
#define FELEM2 int64_t
+#define FELEML int64_t
#define FELEM_MAX INT32_MAX
#define FELEM_MIN INT32_MIN
+#define WINDOW_TYPE 12
+#else
+#define FILTER_SHIFT 0
+
+#define FELEM double
+#define FELEM2 double
+#define FELEML double
+#define WINDOW_TYPE 24
#endif
@@ -69,9 +80,10 @@ static double bessel(double x){
double t=1;
int i;
+ x= x*x/4;
for(i=1; i<50; i++){
- t *= i;
- v += pow(x*x/4, i)/(t*t);
+ t *= x/(i*i);
+ v += t;
}
return v;
}
@@ -80,7 +92,7 @@ static double bessel(double x){
* builds a polyphase filterbank.
* @param factor resampling factor
* @param scale wanted sum of coefficients for each filter
- * @param type 0->cubic, 1->blackman nuttall windowed sinc, 2->kaiser windowed sinc beta=16
+ * @param type 0->cubic, 1->blackman nuttall windowed sinc, 2..16->kaiser windowed sinc beta=2..16
*/
void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type){
int ph, i, v;
@@ -93,7 +105,6 @@ void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_coun
for(ph=0;ph<phase_count;ph++) {
double norm = 0;
- double e= 0;
for(i=0;i<tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
@@ -109,9 +120,9 @@ void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_coun
w = 2.0*x / (factor*tap_count) + M_PI;
y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
break;
- case 2:
+ default:
w = 2.0*x / (factor*tap_count*M_PI);
- y *= bessel(16*sqrt(FFMAX(1-w*w, 0)));
+ y *= bessel(type*sqrt(FFMAX(1-w*w, 0)));
break;
}
@@ -121,11 +132,49 @@ void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_coun
/* normalize so that an uniform color remains the same */
for(i=0;i<tap_count;i++) {
- v = clip(lrintf(tab[i] * scale / norm + e), FELEM_MIN, FELEM_MAX);
- filter[ph * tap_count + i] = v;
- e += tab[i] * scale / norm - v;
+#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
+ filter[ph * tap_count + i] = tab[i] / norm;
+#else
+ filter[ph * tap_count + i] = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX);
+#endif
+ }
+ }
+#if 0
+ {
+#define LEN 1024
+ int j,k;
+ double sine[LEN + tap_count];
+ double filtered[LEN];
+ double maxff=-2, minff=2, maxsf=-2, minsf=2;
+ for(i=0; i<LEN; i++){
+ double ss=0, sf=0, ff=0;
+ for(j=0; j<LEN+tap_count; j++)
+ sine[j]= cos(i*j*M_PI/LEN);
+ for(j=0; j<LEN; j++){
+ double sum=0;
+ ph=0;
+ for(k=0; k<tap_count; k++)
+ sum += filter[ph * tap_count + k] * sine[k+j];
+ filtered[j]= sum / (1<<FILTER_SHIFT);
+ ss+= sine[j + center] * sine[j + center];
+ ff+= filtered[j] * filtered[j];
+ sf+= sine[j + center] * filtered[j];
+ }
+ ss= sqrt(2*ss/LEN);
+ ff= sqrt(2*ff/LEN);
+ sf= 2*sf/LEN;
+ maxff= FFMAX(maxff, ff);
+ minff= FFMIN(minff, ff);
+ maxsf= FFMAX(maxsf, sf);
+ minsf= FFMIN(minsf, sf);
+ if(i%11==0){
+ av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
+ minff=minsf= 2;
+ maxff=maxsf= -2;
+ }
}
}
+#endif
}
/**
@@ -143,7 +192,7 @@ AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size,
c->filter_length= FFMAX((int)ceil(filter_size/factor), 1);
c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
- av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, 1);
+ av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE);
memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
@@ -219,21 +268,24 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
}else if(sample_index + c->filter_length > src_size){
break;
}else if(c->linear){
- int64_t v=0;
- int sub_phase= (frac<<8) / c->src_incr;
+ FELEM2 v2=0;
for(i=0; i<c->filter_length; i++){
- int64_t coeff= filter[i]*(256 - sub_phase) + filter[i + c->filter_length]*sub_phase;
- v += src[sample_index + i] * coeff;
+ val += src[sample_index + i] * (FELEM2)filter[i];
+ v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
}
- val= v>>8;
+ val+=(v2-val)*(FELEML)frac / c->src_incr;
}else{
for(i=0; i<c->filter_length; i++){
val += src[sample_index + i] * (FELEM2)filter[i];
}
}
+#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
+ dst[dst_index] = av_clip(lrintf(val), -32768, 32767);
+#else
val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
+#endif
frac += dst_incr_frac;
index += dst_incr;
diff --git a/contrib/ffmpeg/libavcodec/rl.h b/contrib/ffmpeg/libavcodec/rl.h
new file mode 100644
index 000000000..1c2aae25a
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/rl.h
@@ -0,0 +1,42 @@
+/**
+ * @file rl.h
+ * rl header.
+ */
+
+#ifndef AVCODEC_RL_H
+#define AVCODEC_RL_H
+
+/** RLTable. */
+typedef struct RLTable {
+ int n; ///< number of entries of table_vlc minus 1
+ int last; ///< number of values for last = 0
+ const uint16_t (*table_vlc)[2];
+ const int8_t *table_run;
+ const int8_t *table_level;
+ uint8_t *index_run[2]; ///< encoding only
+ int8_t *max_level[2]; ///< encoding & decoding
+ int8_t *max_run[2]; ///< encoding & decoding
+ VLC vlc; ///< decoding only deprected FIXME remove
+ RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
+} RLTable;
+
+/**
+ *
+ * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold
+ * the level and run tables, if this is NULL av_malloc() will be used
+ */
+void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
+void init_vlc_rl(RLTable *rl, int use_static);
+
+static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
+{
+ int index;
+ index = rl->index_run[last][run];
+ if (index >= rl->n)
+ return rl->n;
+ if (level > rl->max_level[last][run])
+ return rl->n;
+ return index + level - 1;
+}
+
+#endif
diff --git a/contrib/ffmpeg/libavcodec/roqvideo.c b/contrib/ffmpeg/libavcodec/roqvideo.c
index 4595b047c..2a9aa6242 100644
--- a/contrib/ffmpeg/libavcodec/roqvideo.c
+++ b/contrib/ffmpeg/libavcodec/roqvideo.c
@@ -51,8 +51,9 @@ typedef struct RoqContext {
AVCodecContext *avctx;
DSPContext dsp;
- AVFrame last_frame;
- AVFrame current_frame;
+ AVFrame frames[2];
+ AVFrame *last_frame;
+ AVFrame *current_frame;
int first_frame;
int y_stride;
int c_stride;
@@ -87,14 +88,14 @@ static void apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell)
{
unsigned char *yptr;
- yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x;
+ yptr = ri->current_frame->data[0] + (y * ri->y_stride) + x;
*yptr++ = cell->y0;
*yptr++ = cell->y1;
yptr += (ri->y_stride - 2);
*yptr++ = cell->y2;
*yptr++ = cell->y3;
- ri->current_frame.data[1][(y/2) * (ri->c_stride) + x/2] = cell->u;
- ri->current_frame.data[2][(y/2) * (ri->c_stride) + x/2] = cell->v;
+ ri->current_frame->data[1][(y/2) * (ri->c_stride) + x/2] = cell->u;
+ ri->current_frame->data[2][(y/2) * (ri->c_stride) + x/2] = cell->v;
}
static void apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell)
@@ -103,9 +104,9 @@ static void apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell)
register unsigned char y0, y1, u, v;
unsigned char *yptr, *uptr, *vptr;
- yptr = ri->current_frame.data[0] + (y * ri->y_stride) + x;
- uptr = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;
- vptr = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;
+ yptr = ri->current_frame->data[0] + (y * ri->y_stride) + x;
+ uptr = ri->current_frame->data[1] + (y/2) * (ri->c_stride) + x/2;
+ vptr = ri->current_frame->data[2] + (y/2) * (ri->c_stride) + x/2;
row_inc = ri->y_stride - 4;
c_row_inc = (ri->c_stride) - 2;
@@ -153,8 +154,8 @@ static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,
return;
}
- pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;
- pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;
+ pa = ri->current_frame->data[0] + (y * ri->y_stride) + x;
+ pb = ri->last_frame->data[0] + (my * ri->y_stride) + mx;
for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
@@ -165,8 +166,8 @@ static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,
}
hw = ri->y_stride/2;
- pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2;
- pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ pa = ri->current_frame->data[1] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame->data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
for(i = 0; i < 2; i++) {
switch(((my & 0x01) << 1) | (mx & 0x01)) {
@@ -200,8 +201,8 @@ static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,
break;
}
- pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2;
- pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ pa = ri->current_frame->data[2] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame->data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
}
}
@@ -222,8 +223,8 @@ static void apply_motion_8x8(RoqContext *ri, int x, int y,
return;
}
- pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;
- pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;
+ pa = ri->current_frame->data[0] + (y * ri->y_stride) + x;
+ pb = ri->last_frame->data[0] + (my * ri->y_stride) + mx;
for(i = 0; i < 8; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
@@ -238,8 +239,8 @@ static void apply_motion_8x8(RoqContext *ri, int x, int y,
}
hw = ri->c_stride;
- pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2;
- pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ pa = ri->current_frame->data[1] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame->data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
for(j = 0; j < 2; j++) {
for(i = 0; i < 4; i++) {
switch(((my & 0x01) << 1) | (mx & 0x01)) {
@@ -276,8 +277,8 @@ static void apply_motion_8x8(RoqContext *ri, int x, int y,
pb += ri->c_stride;
}
- pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2;
- pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
+ pa = ri->current_frame->data[2] + (y * ri->y_stride)/4 + x/2;
+ pb = ri->last_frame->data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;
}
}
@@ -407,6 +408,8 @@ static int roq_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
s->first_frame = 1;
+ s->last_frame = &s->frames[0];
+ s->current_frame = &s->frames[1];
avctx->pix_fmt = PIX_FMT_YUV420P;
avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
@@ -424,12 +427,12 @@ static int roq_decode_frame(AVCodecContext *avctx,
{
RoqContext *s = avctx->priv_data;
- if (avctx->get_buffer(avctx, &s->current_frame)) {
+ if (avctx->get_buffer(avctx, s->current_frame)) {
av_log(avctx, AV_LOG_ERROR, " RoQ: get_buffer() failed\n");
return -1;
}
- s->y_stride = s->current_frame.linesize[0];
- s->c_stride = s->current_frame.linesize[1];
+ s->y_stride = s->current_frame->linesize[0];
+ s->c_stride = s->current_frame->linesize[1];
s->buf = buf;
s->size = buf_size;
@@ -439,13 +442,13 @@ static int roq_decode_frame(AVCodecContext *avctx,
if (s->first_frame)
s->first_frame = 0;
else
- avctx->release_buffer(avctx, &s->last_frame);
-
- /* shuffle frames */
- s->last_frame = s->current_frame;
+ avctx->release_buffer(avctx, s->last_frame);
*data_size = sizeof(AVFrame);
- *(AVFrame*)data = s->current_frame;
+ *(AVFrame*)data = *s->current_frame;
+
+ /* shuffle frames */
+ FFSWAP(AVFrame *, s->current_frame, s->last_frame);
return buf_size;
}
@@ -455,8 +458,8 @@ static int roq_decode_end(AVCodecContext *avctx)
RoqContext *s = avctx->priv_data;
/* release the last frame */
- if (s->last_frame.data[0])
- avctx->release_buffer(avctx, &s->last_frame);
+ if (s->last_frame->data[0])
+ avctx->release_buffer(avctx, s->last_frame);
return 0;
}
diff --git a/contrib/ffmpeg/libavcodec/rpza.c b/contrib/ffmpeg/libavcodec/rpza.c
index 9a996da37..8ab5dbb92 100644
--- a/contrib/ffmpeg/libavcodec/rpza.c
+++ b/contrib/ffmpeg/libavcodec/rpza.c
@@ -98,7 +98,7 @@ static void rpza_decode_stream(RpzaContext *s)
s->buf[stream_ptr]);
/* Get chunk size, ingnoring first byte */
- chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+ chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
/* If length mismatch use size from MOV file and try to decode anyway */
@@ -140,7 +140,7 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill blocks with one color */
case 0xa0:
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
@@ -157,10 +157,10 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill blocks with 4 colors */
case 0xc0:
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
case 0x20:
- colorB = BE_16 (&s->buf[stream_ptr]);
+ colorB = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
/* sort out the colors */
@@ -209,7 +209,7 @@ static void rpza_decode_stream(RpzaContext *s)
for (pixel_x = 0; pixel_x < 4; pixel_x++){
/* We already have color of upper left pixel */
if ((pixel_y != 0) || (pixel_x !=0)) {
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
}
pixels[block_ptr] = colorA;
diff --git a/contrib/ffmpeg/libavcodec/rv10.c b/contrib/ffmpeg/libavcodec/rv10.c
index 4b50609c1..e1e8287d5 100644
--- a/contrib/ffmpeg/libavcodec/rv10.c
+++ b/contrib/ffmpeg/libavcodec/rv10.c
@@ -454,6 +454,8 @@ 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_h, new_w) < 0)
+ return -1;
MPV_common_end(s);
s->width = s->avctx->width = new_w;
s->height = s->avctx->height= new_h;
@@ -535,7 +537,7 @@ static int rv10_decode_init(AVCodecContext *avctx)
s->height = avctx->height;
s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
- avctx->sub_id= BE_32((uint8_t*)avctx->extradata + 4);
+ avctx->sub_id= AV_RB32((uint8_t*)avctx->extradata + 4);
switch(avctx->sub_id){
case 0x10000000:
diff --git a/contrib/ffmpeg/libavcodec/shorten.c b/contrib/ffmpeg/libavcodec/shorten.c
index 358ecf23f..efb48b51d 100644
--- a/contrib/ffmpeg/libavcodec/shorten.c
+++ b/contrib/ffmpeg/libavcodec/shorten.c
@@ -293,7 +293,8 @@ static int shorten_decode_frame(AVCodecContext *avctx,
s->bitstream_size= buf_size;
if(buf_size < s->max_framesize){
- //dprintf("wanna more data ... %d\n", buf_size);
+ //dprintf(avctx, "wanna more data ... %d\n", buf_size);
+ *data_size = 0;
return input_buf_size;
}
}
@@ -471,6 +472,7 @@ static int shorten_decode_frame(AVCodecContext *avctx,
s->blocksize = get_uint(s, av_log2(s->blocksize));
break;
case FN_QUIT:
+ *data_size = 0;
return buf_size;
break;
default:
diff --git a/contrib/ffmpeg/libavcodec/simple_idct.c b/contrib/ffmpeg/libavcodec/simple_idct.c
index 2c026f08f..dcf752e16 100644
--- a/contrib/ffmpeg/libavcodec/simple_idct.c
+++ b/contrib/ffmpeg/libavcodec/simple_idct.c
@@ -78,13 +78,13 @@
static inline void idctRowCondDC (DCTELEM * row)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
-#ifdef FAST_64BIT
+#ifdef HAVE_FAST_64BIT
uint64_t temp;
#else
uint32_t temp;
#endif
-#ifdef FAST_64BIT
+#ifdef HAVE_FAST_64BIT
#ifdef WORDS_BIGENDIAN
#define ROW0_MASK 0xffff000000000000LL
#else
@@ -146,7 +146,7 @@ static inline void idctRowCondDC (DCTELEM * row)
MUL16(b3, W7, row[1]);
MAC16(b3, -W5, row[3]);
-#ifdef FAST_64BIT
+#ifdef HAVE_FAST_64BIT
temp = ((uint64_t*)row)[1];
#else
temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
diff --git a/contrib/ffmpeg/libavcodec/smacker.c b/contrib/ffmpeg/libavcodec/smacker.c
index 2f2185848..0dd76107b 100644
--- a/contrib/ffmpeg/libavcodec/smacker.c
+++ b/contrib/ffmpeg/libavcodec/smacker.c
@@ -277,10 +277,10 @@ static int decode_header_trees(SmackVContext *smk) {
GetBitContext gb;
int mmap_size, mclr_size, full_size, type_size;
- mmap_size = LE_32(smk->avctx->extradata);
- mclr_size = LE_32(smk->avctx->extradata + 4);
- full_size = LE_32(smk->avctx->extradata + 8);
- type_size = LE_32(smk->avctx->extradata + 12);
+ mmap_size = AV_RL32(smk->avctx->extradata);
+ mclr_size = AV_RL32(smk->avctx->extradata + 4);
+ full_size = AV_RL32(smk->avctx->extradata + 8);
+ type_size = AV_RL32(smk->avctx->extradata + 12);
init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
@@ -320,12 +320,12 @@ static int decode_header_trees(SmackVContext *smk) {
return 0;
}
-static always_inline void last_reset(int *recode, int *last) {
+static av_always_inline void last_reset(int *recode, int *last) {
recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
}
/* get code and update history */
-static always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last) {
+static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last) {
register int *table = recode;
int v, b;
@@ -584,7 +584,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
int bits, stereo;
int pred[2] = {0, 0};
- unp_size = LE_32(buf);
+ unp_size = AV_RL32(buf);
init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
@@ -620,14 +620,10 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
if(bits) { //decode 16-bit data
- pred[0] = get_bits(&gb, 8);
- pred[0] |= get_bits(&gb, 8);
- *samples++ = pred[0];
- if(stereo) {
- pred[1] = get_bits(&gb, 8);
- pred[1] |= get_bits(&gb, 8);
- *samples++ = pred[1];
- }
+ for(i = stereo; i >= 0; i--)
+ pred[i] = bswap_16(get_bits(&gb, 16));
+ for(i = 0; i < stereo; i++)
+ *samples++ = pred[i];
for(i = 0; i < unp_size / 2; i++) {
if(i & stereo) {
if(vlc[2].table)
@@ -658,12 +654,10 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
} else { //8-bit data
- pred[0] = get_bits(&gb, 8);
- *samples++ = (pred[0] - 0x80) << 8;
- if(stereo) {
- pred[1] = get_bits(&gb, 8);
- *samples++ = (pred[1] - 0x80) << 8;
- }
+ for(i = stereo; i >= 0; i--)
+ pred[i] = get_bits(&gb, 8);
+ for(i = 0; i < stereo; i++)
+ *samples++ = (pred[i] - 0x80) << 8;
for(i = 0; i < unp_size; i++) {
if(i & stereo){
if(vlc[1].table)
diff --git a/contrib/ffmpeg/libavcodec/smc.c b/contrib/ffmpeg/libavcodec/smc.c
index 77fae328b..349e5f81c 100644
--- a/contrib/ffmpeg/libavcodec/smc.c
+++ b/contrib/ffmpeg/libavcodec/smc.c
@@ -120,7 +120,7 @@ static void smc_decode_stream(SmcContext *s)
s->avctx->palctrl->palette_changed = 0;
}
- chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+ chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
if (chunk_size != s->size)
av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
@@ -278,7 +278,7 @@ static void smc_decode_stream(SmcContext *s)
color_table_index = CPAIR * s->buf[stream_ptr++];
while (n_blocks--) {
- color_flags = BE_16(&s->buf[stream_ptr]);
+ color_flags = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
flag_mask = 0x8000;
block_ptr = row_ptr + pixel_ptr;
@@ -321,7 +321,7 @@ static void smc_decode_stream(SmcContext *s)
color_table_index = CQUAD * s->buf[stream_ptr++];
while (n_blocks--) {
- color_flags = BE_32(&s->buf[stream_ptr]);
+ color_flags = AV_RB32(&s->buf[stream_ptr]);
stream_ptr += 4;
/* flag mask actually acts as a bit shift count here */
flag_mask = 30;
diff --git a/contrib/ffmpeg/libavcodec/snow.c b/contrib/ffmpeg/libavcodec/snow.c
index 6bc9a8f1a..dc50941fa 100644
--- a/contrib/ffmpeg/libavcodec/snow.c
+++ b/contrib/ffmpeg/libavcodec/snow.c
@@ -422,7 +422,7 @@ typedef struct Plane{
}Plane;
typedef struct SnowContext{
-// MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX)
+// MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX)
AVCodecContext *avctx;
RangeCoder c;
@@ -439,6 +439,7 @@ typedef struct SnowContext{
int always_reset;
int version;
int spatial_decomposition_type;
+ int last_spatial_decomposition_type;
int temporal_decomposition_type;
int spatial_decomposition_count;
int temporal_decomposition_count;
@@ -452,15 +453,19 @@ typedef struct SnowContext{
int chroma_v_shift;
int spatial_scalability;
int qlog;
+ int last_qlog;
int lambda;
int lambda2;
int pass1_rc;
int mv_scale;
+ int last_mv_scale;
int qbias;
+ int last_qbias;
#define QBIAS_SHIFT 3
int b_width;
int b_height;
int block_max_depth;
+ int last_block_max_depth;
Plane plane[MAX_PLANES];
BlockNode *block;
#define ME_CACHE_SIZE 1024
@@ -468,7 +473,7 @@ typedef struct SnowContext{
int me_cache_generation;
slice_buffer sb;
- MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX)
+ MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX)
}SnowContext;
typedef struct {
@@ -709,7 +714,7 @@ static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){
return v;
}
-static always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
+static av_always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
const int mirror_left= !highpass;
const int mirror_right= (width&1) ^ highpass;
const int w= (width>>1) - 1 + (highpass & width);
@@ -732,7 +737,7 @@ static always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst
}
#ifndef lift5
-static always_inline void lift5(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
+static av_always_inline void lift5(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
const int mirror_left= !highpass;
const int mirror_right= (width&1) ^ highpass;
const int w= (width>>1) - 1 + (highpass & width);
@@ -764,7 +769,7 @@ static always_inline void lift5(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int ds
#endif
#ifndef liftS
-static always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
+static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse){
const int mirror_left= !highpass;
const int mirror_right= (width&1) ^ highpass;
const int w= (width>>1) - 1 + (highpass & width);
@@ -1805,7 +1810,7 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i
static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
const int w= b->width;
int y;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int new_index = 0;
@@ -1849,7 +1854,7 @@ static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, sli
return;
}
-static void reset_contexts(SnowContext *s){
+static void reset_contexts(SnowContext *s){ //FIXME better initial contexts
int plane_index, level, orientation;
for(plane_index=0; plane_index<3; plane_index++){
@@ -1954,18 +1959,18 @@ static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3
}
static inline void pred_mv(SnowContext *s, int *mx, int *my, int ref,
- BlockNode *left, BlockNode *top, BlockNode *tr){
+ const BlockNode *left, const BlockNode *top, const BlockNode *tr){
if(s->ref_frames == 1){
*mx = mid_pred(left->mx, top->mx, tr->mx);
*my = mid_pred(left->my, top->my, tr->my);
}else{
const int *scale = scale_mv_ref[ref];
- *mx = mid_pred(left->mx * scale[left->ref] + 128 >>8,
- top ->mx * scale[top ->ref] + 128 >>8,
- tr ->mx * scale[tr ->ref] + 128 >>8);
- *my = mid_pred(left->my * scale[left->ref] + 128 >>8,
- top ->my * scale[top ->ref] + 128 >>8,
- tr ->my * scale[tr ->ref] + 128 >>8);
+ *mx = mid_pred((left->mx * scale[left->ref] + 128) >>8,
+ (top ->mx * scale[top ->ref] + 128) >>8,
+ (tr ->mx * scale[tr ->ref] + 128) >>8);
+ *my = mid_pred((left->my * scale[left->ref] + 128) >>8,
+ (top ->my * scale[top ->ref] + 128) >>8,
+ (tr ->my * scale[tr ->ref] + 128) >>8);
}
}
@@ -1993,12 +1998,12 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
const int block_w= 1<<(LOG2_MB_SIZE - level);
int trx= (x+1)<<rem_depth;
int try= (y+1)<<rem_depth;
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-w] : &null_block;
- BlockNode *right = trx<w ? &s->block[index+1] : &null_block;
- BlockNode *bottom= try<h ? &s->block[index+w] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-w-1] : left;
- BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-w] : &null_block;
+ const BlockNode *right = trx<w ? &s->block[index+1] : &null_block;
+ const BlockNode *bottom= try<h ? &s->block[index+w] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
+ const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int pl = left->color[0];
int pcb= left->color[1];
int pcr= left->color[2];
@@ -2046,10 +2051,10 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
s->m.mb_stride=2;
s->m.mb_x=
s->m.mb_y= 0;
- s->m.me.skip= 0;
+ c->skip= 0;
- assert(s->m.me. stride == stride);
- assert(s->m.me.uvstride == uvstride);
+ assert(c-> stride == stride);
+ assert(c->uvstride == uvstride);
c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
@@ -2093,7 +2098,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
assert(ref_my >= c->ymin);
assert(ref_my <= c->ymax);
- ref_score= s->m.me.sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w);
+ ref_score= c->sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w);
ref_score= ff_get_mb_score(&s->m, ref_mx, ref_my, 0, 0, level-LOG2_MB_SIZE+4, block_w, 0);
ref_score+= 2*av_log2(2*ref)*c->penalty_factor;
if(s->ref_mvs[ref]){
@@ -2206,7 +2211,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
}
}
-static always_inline int same_block(BlockNode *a, BlockNode *b){
+static av_always_inline int same_block(BlockNode *a, BlockNode *b){
if((a->type&BLOCK_INTRA) && (b->type&BLOCK_INTRA)){
return !((a->color[0] - b->color[0]) | (a->color[1] - b->color[1]) | (a->color[2] - b->color[2]));
}else{
@@ -2220,10 +2225,10 @@ static void encode_q_branch2(SnowContext *s, int level, int x, int y){
const int index= (x + y*w) << rem_depth;
int trx= (x+1)<<rem_depth;
BlockNode *b= &s->block[index];
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-w] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-w-1] : left;
- BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-w] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
+ const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int pl = left->color[0];
int pcb= left->color[1];
int pcr= left->color[2];
@@ -2273,10 +2278,10 @@ static void decode_q_branch(SnowContext *s, int level, int x, int y){
const int rem_depth= s->block_max_depth - level;
const int index= (x + y*w) << rem_depth;
int trx= (x+1)<<rem_depth;
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-w] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-w-1] : left;
- BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-w] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
+ const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
if(s->keyframe){
@@ -2285,12 +2290,10 @@ static void decode_q_branch(SnowContext *s, int level, int x, int y){
}
if(level==s->block_max_depth || get_rac(&s->c, &s->block_state[4 + s_context])){
- int type;
+ int type, mx, my;
int l = left->color[0];
int cb= left->color[1];
int cr= left->color[2];
- int mx= mid_pred(left->mx, top->mx, tr->mx);
- int my= mid_pred(left->my, top->my, tr->my);
int ref = 0;
int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx));
@@ -2518,16 +2521,16 @@ static void pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride, i
}
}
-void ff_snow_inner_add_yblock(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
+void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,
int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){
int y, x;
DWTELEM * dst;
for(y=0; y<b_h; y++){
//FIXME ugly missue of obmc_stride
- uint8_t *obmc1= obmc + y*obmc_stride;
- uint8_t *obmc2= obmc1+ (obmc_stride>>1);
- uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
- uint8_t *obmc4= obmc3+ (obmc_stride>>1);
+ const uint8_t *obmc1= obmc + y*obmc_stride;
+ const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
+ const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
+ const uint8_t *obmc4= obmc3+ (obmc_stride>>1);
dst = slice_buffer_get_line(sb, src_y + y);
for(x=0; x<b_w; x++){
int v= obmc1[x] * block[3][x + y*src_stride]
@@ -2553,7 +2556,7 @@ void ff_snow_inner_add_yblock(uint8_t *obmc, const int obmc_stride, uint8_t * *
}
//FIXME name clenup (b_w, block_w, b_width stuff)
-static always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, DWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
+static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, DWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
const int b_width = s->b_width << s->block_max_depth;
const int b_height= s->b_height << s->block_max_depth;
const int b_stride= b_width;
@@ -2684,10 +2687,10 @@ assert(src_stride > 2*MB_SIZE + 5);
}else
for(y=0; y<b_h; y++){
//FIXME ugly missue of obmc_stride
- uint8_t *obmc1= obmc + y*obmc_stride;
- uint8_t *obmc2= obmc1+ (obmc_stride>>1);
- uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
- uint8_t *obmc4= obmc3+ (obmc_stride>>1);
+ const uint8_t *obmc1= obmc + y*obmc_stride;
+ const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
+ const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
+ const uint8_t *obmc4= obmc3+ (obmc_stride>>1);
for(x=0; x<b_w; x++){
int v= obmc1[x] * block[3][x + y*src_stride]
+obmc2[x] * block[2][x + y*src_stride]
@@ -2712,7 +2715,7 @@ assert(src_stride > 2*MB_SIZE + 5);
#endif
}
-static always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, DWTELEM * old_buffer, int plane_index, int add, int mb_y){
+static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, DWTELEM * old_buffer, int plane_index, int add, int mb_y){
Plane *p= &s->plane[plane_index];
const int mb_w= s->b_width << s->block_max_depth;
const int mb_h= s->b_height << s->block_max_depth;
@@ -2779,7 +2782,7 @@ static always_inline void predict_slice_buffered(SnowContext *s, slice_buffer *
STOP_TIMER("predict_slice")
}
-static always_inline void predict_slice(SnowContext *s, DWTELEM *buf, int plane_index, int add, int mb_y){
+static av_always_inline void predict_slice(SnowContext *s, DWTELEM *buf, int plane_index, int add, int mb_y){
Plane *p= &s->plane[plane_index];
const int mb_w= s->b_width << s->block_max_depth;
const int mb_h= s->b_height << s->block_max_depth;
@@ -2836,7 +2839,7 @@ static always_inline void predict_slice(SnowContext *s, DWTELEM *buf, int plane_
STOP_TIMER("predict_slice")
}
-static always_inline void predict_plane(SnowContext *s, DWTELEM *buf, int plane_index, int add){
+static av_always_inline void predict_plane(SnowContext *s, DWTELEM *buf, int plane_index, int add){
const int mb_h= s->b_height << s->block_max_depth;
int mb_y;
for(mb_y=0; mb_y<=mb_h; mb_y++)
@@ -2895,18 +2898,18 @@ static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){
}
*b= backup;
- return clip(((ab<<LOG2_OBMC_MAX) + aa/2)/aa, 0, 255); //FIXME we shouldnt need cliping
+ return av_clip(((ab<<LOG2_OBMC_MAX) + aa/2)/aa, 0, 255); //FIXME we shouldnt need cliping
}
static inline int get_block_bits(SnowContext *s, int x, int y, int w){
const int b_stride = s->b_width << s->block_max_depth;
const int b_height = s->b_height<< s->block_max_depth;
int index= x + y*b_stride;
- BlockNode *b = &s->block[index];
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-b_stride] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left;
- BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl;
+ const BlockNode *b = &s->block[index];
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-b_stride] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left;
+ const BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl;
int dmx, dmy;
// int mx_context= av_log2(2*FFABS(left->mx - top->mx));
// int my_context= av_log2(2*FFABS(left->my - top->my));
@@ -3094,7 +3097,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){
return distortion + rate*penalty_factor;
}
-static always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3], int intra, const uint8_t *obmc_edged, int *best_rd){
+static av_always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3], int intra, const uint8_t *obmc_edged, int *best_rd){
const int b_stride= s->b_width << s->block_max_depth;
BlockNode *block= &s->block[mb_x + mb_y * b_stride];
BlockNode backup= *block;
@@ -3133,12 +3136,12 @@ static always_inline int check_block(SnowContext *s, int mb_x, int mb_y, int p[3
}
/* special case for int[2] args we discard afterward, fixes compilation prob with gcc 2.95 */
-static always_inline int check_block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, const uint8_t *obmc_edged, int *best_rd){
+static av_always_inline int check_block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, const uint8_t *obmc_edged, int *best_rd){
int p[2] = {p0, p1};
return check_block(s, mb_x, mb_y, p, 0, obmc_edged, best_rd);
}
-static always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd){
+static av_always_inline int check_4block_inter(SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd){
const int b_stride= s->b_width << s->block_max_depth;
BlockNode *block= &s->block[mb_x + mb_y * b_stride];
BlockNode backup[4]= {block[0], block[1], block[b_stride], block[b_stride+1]};
@@ -3404,7 +3407,7 @@ static void quantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int b
const int level= b->level;
const int w= b->width;
const int h= b->height;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
int x,y, thres1, thres2;
// START_TIMER
@@ -3463,7 +3466,7 @@ static void quantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int b
static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int start_y, int end_y){
const int w= b->width;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int x,y;
@@ -3491,7 +3494,7 @@ static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand
static void dequantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride){
const int w= b->width;
const int h= b->height;
- const int qlog= clip(s->qlog + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
int x,y;
@@ -3544,7 +3547,7 @@ static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand
// START_TIMER
- DWTELEM * line;
+ DWTELEM * line=0; // silence silly "could be used without having been initialized" warning
DWTELEM * prev;
if (start_y != 0)
@@ -3603,8 +3606,14 @@ static void encode_header(SnowContext *s){
memset(kstate, MID_STATE, sizeof(kstate));
put_rac(&s->c, kstate, s->keyframe);
- if(s->keyframe || s->always_reset)
+ if(s->keyframe || s->always_reset){
reset_contexts(s);
+ s->last_spatial_decomposition_type=
+ s->last_qlog=
+ s->last_qbias=
+ s->last_mv_scale=
+ s->last_block_max_depth= 0;
+ }
if(s->keyframe){
put_symbol(&s->c, s->header_state, s->version, 0);
put_rac(&s->c, s->header_state, s->always_reset);
@@ -3627,11 +3636,17 @@ static void encode_header(SnowContext *s){
}
}
}
- put_symbol(&s->c, s->header_state, s->spatial_decomposition_type, 0);
- put_symbol(&s->c, s->header_state, s->qlog, 1);
- put_symbol(&s->c, s->header_state, s->mv_scale, 0);
- put_symbol(&s->c, s->header_state, s->qbias, 1);
- put_symbol(&s->c, s->header_state, s->block_max_depth, 0);
+ put_symbol(&s->c, s->header_state, s->spatial_decomposition_type - s->last_spatial_decomposition_type, 1);
+ put_symbol(&s->c, s->header_state, s->qlog - s->last_qlog , 1);
+ put_symbol(&s->c, s->header_state, s->mv_scale - s->last_mv_scale, 1);
+ put_symbol(&s->c, s->header_state, s->qbias - s->last_qbias , 1);
+ put_symbol(&s->c, s->header_state, s->block_max_depth - s->last_block_max_depth, 1);
+
+ s->last_spatial_decomposition_type= s->spatial_decomposition_type;
+ s->last_qlog = s->qlog;
+ s->last_qbias = s->qbias;
+ s->last_mv_scale = s->mv_scale;
+ s->last_block_max_depth = s->block_max_depth;
}
static int decode_header(SnowContext *s){
@@ -3641,8 +3656,14 @@ static int decode_header(SnowContext *s){
memset(kstate, MID_STATE, sizeof(kstate));
s->keyframe= get_rac(&s->c, kstate);
- if(s->keyframe || s->always_reset)
+ if(s->keyframe || s->always_reset){
reset_contexts(s);
+ s->spatial_decomposition_type=
+ s->qlog=
+ s->qbias=
+ s->mv_scale=
+ s->block_max_depth= 0;
+ }
if(s->keyframe){
s->version= get_symbol(&s->c, s->header_state, 0);
if(s->version>0){
@@ -3673,16 +3694,16 @@ static int decode_header(SnowContext *s){
}
}
- s->spatial_decomposition_type= get_symbol(&s->c, s->header_state, 0);
+ s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1);
if(s->spatial_decomposition_type > 2){
av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type);
return -1;
}
- s->qlog= get_symbol(&s->c, s->header_state, 1);
- s->mv_scale= get_symbol(&s->c, s->header_state, 0);
- s->qbias= get_symbol(&s->c, s->header_state, 1);
- s->block_max_depth= get_symbol(&s->c, s->header_state, 0);
+ s->qlog += get_symbol(&s->c, s->header_state, 1);
+ s->mv_scale += get_symbol(&s->c, s->header_state, 1);
+ s->qbias += get_symbol(&s->c, s->header_state, 1);
+ s->block_max_depth+= get_symbol(&s->c, s->header_state, 1);
if(s->block_max_depth > 1 || s->block_max_depth < 0){
av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large", s->block_max_depth);
s->block_max_depth= 0;
@@ -3848,7 +3869,7 @@ static int ratecontrol_1pass(SnowContext *s, AVFrame *pict)
const int w= b->width;
const int h= b->height;
const int stride= b->stride;
- const int qlog= clip(2*QROOT + b->qlog, 0, QROOT*16);
+ const int qlog= av_clip(2*QROOT + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qdiv= (1<<16)/qmul;
int x, y;
@@ -3970,7 +3991,7 @@ static int encode_init(AVCodecContext *avctx)
// case PIX_FMT_YUV410P:
s->colorspace_type= 0;
break;
-/* case PIX_FMT_RGBA32:
+/* case PIX_FMT_RGB32:
s->colorspace= 1;
break;*/
default:
@@ -4170,7 +4191,6 @@ redo_frame:
pict->pict_type= FF_I_TYPE;
s->keyframe=1;
s->current_picture.key_frame=1;
- reset_contexts(s);
goto redo_frame;
}
diff --git a/contrib/ffmpeg/libavcodec/snow.h b/contrib/ffmpeg/libavcodec/snow.h
index f7cee131a..d75d6e3e0 100644
--- a/contrib/ffmpeg/libavcodec/snow.h
+++ b/contrib/ffmpeg/libavcodec/snow.h
@@ -125,7 +125,7 @@ struct slice_buffer_s {
extern void ff_snow_vertical_compose97i(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width);
extern void ff_snow_horizontal_compose97i(DWTELEM *b, int width);
-extern void ff_snow_inner_add_yblock(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
+extern void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
#ifdef CONFIG_SNOW_ENCODER
int w53_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h);
@@ -137,7 +137,7 @@ static int w97_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int
/* C bits used by mmx/sse2/altivec */
-static always_inline void snow_interleave_line_header(int * i, int width, DWTELEM * low, DWTELEM * high){
+static av_always_inline void snow_interleave_line_header(int * i, int width, DWTELEM * low, DWTELEM * high){
(*i) = (width) - 2;
if (width & 1){
@@ -146,14 +146,14 @@ static always_inline void snow_interleave_line_header(int * i, int width, DWTELE
}
}
-static always_inline void snow_interleave_line_footer(int * i, DWTELEM * low, DWTELEM * high){
+static av_always_inline void snow_interleave_line_footer(int * i, DWTELEM * low, DWTELEM * high){
for (; (*i)>=0; (*i)-=2){
low[(*i)+1] = high[(*i)>>1];
low[*i] = low[(*i)>>1];
}
}
-static always_inline void snow_horizontal_compose_lift_lead_out(int i, DWTELEM * dst, DWTELEM * src, DWTELEM * ref, int width, int w, int lift_high, int mul, int add, int shift){
+static av_always_inline void snow_horizontal_compose_lift_lead_out(int i, DWTELEM * dst, DWTELEM * src, DWTELEM * ref, int width, int w, int lift_high, int mul, int add, int shift){
for(; i<w; i++){
dst[i] = src[i] - ((mul * (ref[i] + ref[i + 1]) + add) >> shift);
}
@@ -163,7 +163,7 @@ static always_inline void snow_horizontal_compose_lift_lead_out(int i, DWTELEM *
}
}
-static always_inline void snow_horizontal_compose_liftS_lead_out(int i, DWTELEM * dst, DWTELEM * src, DWTELEM * ref, int width, int w){
+static av_always_inline void snow_horizontal_compose_liftS_lead_out(int i, DWTELEM * dst, DWTELEM * src, DWTELEM * ref, int width, int w){
for(; i<w; i++){
dst[i] = src[i] - (((-(ref[i] + ref[(i+1)])+W_BO) - 4 * src[i]) >> W_BS);
}
diff --git a/contrib/ffmpeg/libavcodec/sonic.c b/contrib/ffmpeg/libavcodec/sonic.c
index 2f798cc03..f3388589b 100644
--- a/contrib/ffmpeg/libavcodec/sonic.c
+++ b/contrib/ffmpeg/libavcodec/sonic.c
@@ -601,7 +601,7 @@ static int sonic_encode_init(AVCodecContext *avctx)
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->frame_size = s->block_align*s->downsampling;
diff --git a/contrib/ffmpeg/libavcodec/svq1.c b/contrib/ffmpeg/libavcodec/svq1.c
index 5e8616269..5087ba8cc 100644
--- a/contrib/ffmpeg/libavcodec/svq1.c
+++ b/contrib/ffmpeg/libavcodec/svq1.c
@@ -65,7 +65,7 @@ static VLC svq1_inter_mean;
#define SVQ1_BLOCK_INTRA 3
typedef struct SVQ1Context {
- MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independant of MpegEncContext, so this will be removed then (FIXME/XXX)
+ MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to make the motion estimation eventually independent of MpegEncContext, so this will be removed then (FIXME/XXX)
AVCodecContext *avctx;
DSPContext dsp;
AVFrame picture;
@@ -992,22 +992,16 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref, uint8_t *dec
for(i=0; i<16; i++){
int sum= codebook_sum[stage*16 + i];
- int sqr=0;
- int diff, mean, score;
+ int sqr, diff, score;
vector = codebook + stage*size*16 + i*size;
-
- for(j=0; j<size; j++){
- int v= vector[j];
- sqr += (v - block[stage][j])*(v - block[stage][j]);
- }
+ sqr = s->dsp.ssd_int8_vs_int16(vector, block[stage], size);
diff= block_sum[stage] - sum;
- mean= (diff + (size>>1)) >> (level+3);
- assert(mean >-300 && mean<300);
- if(intra) mean= clip(mean, 0, 255);
- else mean= clip(mean, -256, 255);
score= sqr - ((diff*(int64_t)diff)>>(level+3)); //FIXME 64bit slooow
if(score < best_vector_score){
+ int mean= (diff + (size>>1)) >> (level+3);
+ assert(mean >-300 && mean<300);
+ mean= av_clip(mean, intra?0:-256, 255);
best_vector_score= score;
best_vector[stage]= i;
best_vector_sum= sum;
diff --git a/contrib/ffmpeg/libavcodec/svq3.c b/contrib/ffmpeg/libavcodec/svq3.c
index edf3b6714..db601010b 100644
--- a/contrib/ffmpeg/libavcodec/svq3.c
+++ b/contrib/ffmpeg/libavcodec/svq3.c
@@ -285,8 +285,8 @@ static inline void svq3_mc_dir_part (MpegEncContext *s,
emu = 1;
}
- mx = clip (mx, -16, (s->h_edge_pos - width + 15));
- my = clip (my, -16, (s->v_edge_pos - height + 15));
+ mx = av_clip (mx, -16, (s->h_edge_pos - width + 15));
+ my = av_clip (my, -16, (s->v_edge_pos - height + 15));
}
/* form component predictions */
@@ -361,8 +361,8 @@ static inline int svq3_mc_dir (H264Context *h, int size, int mode, int dir, int
}
/* clip motion vector prediction to frame border */
- mx = clip (mx, extra_width - 6*x, h_edge_pos - 6*x);
- my = clip (my, extra_width - 6*y, v_edge_pos - 6*y);
+ mx = av_clip (mx, extra_width - 6*x, h_edge_pos - 6*x);
+ my = av_clip (my, extra_width - 6*y, v_edge_pos - 6*y);
/* get (optional) motion vector differential */
if (mode == PREDICT_MODE) {
@@ -826,11 +826,11 @@ static int svq3_decode_frame (AVCodecContext *avctx,
}
/* if a match was found, parse the extra data */
- if (!memcmp (extradata, "SEQH", 4)) {
+ if (extradata && !memcmp (extradata, "SEQH", 4)) {
GetBitContext gb;
- size = BE_32(&extradata[4]);
+ size = AV_RB32(&extradata[4]);
init_get_bits (&gb, extradata + 8, size*8);
/* 'frame size code' and optional 'width, height' */
@@ -910,7 +910,8 @@ static int svq3_decode_frame (AVCodecContext *avctx,
s->next_p_frame_damaged = 0;
}
- frame_start (h);
+ if (frame_start (h) < 0)
+ return -1;
if (s->pict_type == B_TYPE) {
h->frame_num_offset = (h->slice_num - h->prev_frame_num);
diff --git a/contrib/ffmpeg/libavcodec/targa.c b/contrib/ffmpeg/libavcodec/targa.c
index 4eb18f87e..d637bedae 100644
--- a/contrib/ffmpeg/libavcodec/targa.c
+++ b/contrib/ffmpeg/libavcodec/targa.c
@@ -61,7 +61,7 @@ static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, uint8_t *sr
*dst = *src;
break;
case 2:
- *((uint16_t*)dst) = LE_16(src);
+ *((uint16_t*)dst) = AV_RL16(src);
break;
case 3:
dst[0] = src[0];
@@ -69,7 +69,7 @@ static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, uint8_t *sr
dst[2] = src[2];
break;
case 4:
- *((uint32_t*)dst) = LE_32(src);
+ *((uint32_t*)dst) = AV_RL32(src);
break;
}
dst += depth;
@@ -104,13 +104,13 @@ static int decode_frame(AVCodecContext *avctx,
idlen = *buf++;
pal = *buf++;
compr = *buf++;
- first_clr = LE_16(buf); buf += 2;
- colors = LE_16(buf); buf += 2;
+ first_clr = AV_RL16(buf); buf += 2;
+ colors = AV_RL16(buf); buf += 2;
csize = *buf++;
- x = LE_16(buf); buf += 2;
- y = LE_16(buf); buf += 2;
- w = LE_16(buf); buf += 2;
- h = LE_16(buf); buf += 2;
+ x = AV_RL16(buf); buf += 2;
+ y = AV_RL16(buf); buf += 2;
+ w = AV_RL16(buf); buf += 2;
+ h = AV_RL16(buf); buf += 2;
bpp = *buf++;
flags = *buf++;
//skip identifier if any
@@ -132,7 +132,7 @@ static int decode_frame(AVCodecContext *avctx,
avctx->pix_fmt = PIX_FMT_BGR24;
break;
case 32:
- avctx->pix_fmt = PIX_FMT_RGBA32;
+ avctx->pix_fmt = PIX_FMT_RGB32;
break;
default:
av_log(avctx, AV_LOG_ERROR, "Bit depth %i is not supported\n", s->bpp);
@@ -200,11 +200,11 @@ static int decode_frame(AVCodecContext *avctx,
if((s->bpp + 1) >> 3 == 2){
uint16_t *dst16 = (uint16_t*)dst;
for(x = 0; x < s->width; x++)
- dst16[x] = LE_16(buf + x * 2);
+ dst16[x] = AV_RL16(buf + x * 2);
}else if((s->bpp + 1) >> 3 == 4){
uint32_t *dst32 = (uint32_t*)dst;
for(x = 0; x < s->width; x++)
- dst32[x] = LE_32(buf + x * 4);
+ dst32[x] = AV_RL32(buf + x * 4);
}else
#endif
memcpy(dst, buf, s->width * ((s->bpp + 1) >> 3));
diff --git a/contrib/ffmpeg/libavcodec/targaenc.c b/contrib/ffmpeg/libavcodec/targaenc.c
new file mode 100644
index 000000000..8b36e1d3d
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/targaenc.c
@@ -0,0 +1,199 @@
+/*
+ * Targa (.tga) image encoder
+ * Copyright (c) 2007 Bobby Bingham
+ *
+ * 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"
+
+/**
+ * Count up to 127 consecutive pixels which are either all the same or
+ * all differ from the previous and next pixels.
+ * @param start Pointer to the first pixel
+ * @param len Maximum number of pixels
+ * @param bpp Bytes per pixel
+ * @param same 1 if searching for identical pixel values. 0 for differing
+ * @return Number of matching consecutive pixels found
+ */
+static int count_pixels(uint8_t *start, int len, int bpp, int same)
+{
+ uint8_t *pos;
+ int count = 1;
+
+ for(pos = start + bpp; count < FFMIN(128, len); pos += bpp, count ++) {
+ if(same != !memcmp(pos-bpp, pos, bpp)) {
+ if(!same) {
+ /* if bpp == 1, then 0 1 1 0 is more efficiently encoded as a single
+ * raw block of pixels. for larger bpp, RLE is as good or better */
+ if(bpp == 1 && count + 1 < FFMIN(128, len) && *pos != *(pos+1))
+ continue;
+
+ /* if RLE can encode the next block better than as a raw block,
+ * back up and leave _all_ the identical pixels for RLE */
+ count --;
+ }
+ break;
+ }
+ }
+
+ return count;
+}
+
+/**
+ * RLE compress the image, with maximum size of out_size
+ * @param outbuf Output buffer
+ * @param out_size Maximum output size
+ * @param pic Image to compress
+ * @param bpp Bytes per pixel
+ * @param w Image width
+ * @param h Image height
+ * @return Size of output in bytes, or -1 if larger than out_size
+ */
+static int targa_encode_rle(uint8_t *outbuf, int out_size, AVFrame *pic,
+ int bpp, int w, int h)
+{
+ int count, x, y;
+ uint8_t *ptr, *line, *out;
+
+ out = outbuf;
+ line = pic->data[0];
+
+ for(y = 0; y < h; y ++) {
+ ptr = line;
+
+ for(x = 0; x < w; x += count) {
+ /* see if we can encode the next set of pixels with RLE */
+ if((count = count_pixels(ptr, w-x, bpp, 1)) > 1) {
+ if(out + bpp + 1 > outbuf + out_size) return -1;
+ *out++ = 0x80 | (count - 1);
+ memcpy(out, ptr, bpp);
+ out += bpp;
+ } else {
+ /* fall back on uncompressed */
+ count = count_pixels(ptr, w-x, bpp, 0);
+ *out++ = count - 1;
+
+ if(out + bpp*count > outbuf + out_size) return -1;
+ memcpy(out, ptr, bpp * count);
+ out += bpp * count;
+ }
+ ptr += count * bpp;
+ }
+
+ line += pic->linesize[0];
+ }
+
+ return out - outbuf;
+}
+
+static int targa_encode_normal(uint8_t *outbuf, AVFrame *pic, int bpp, int w, int h)
+{
+ int i, n = bpp * w;
+ uint8_t *out = outbuf;
+ uint8_t *ptr = pic->data[0];
+
+ for(i=0; i < h; i++) {
+ memcpy(out, ptr, n);
+ out += n;
+ ptr += pic->linesize[0];
+ }
+
+ return out - outbuf;
+}
+
+static int targa_encode_frame(AVCodecContext *avctx,
+ unsigned char *outbuf,
+ int buf_size, void *data){
+ AVFrame *p = data;
+ int bpp, picsize, datasize;
+ uint8_t *out;
+
+ if(avctx->width > 0xffff || avctx->height > 0xffff) {
+ av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n");
+ return -1;
+ }
+ 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;
+ }
+
+ p->pict_type= FF_I_TYPE;
+ p->key_frame= 1;
+
+ /* zero out the header and only set applicable fields */
+ memset(outbuf, 0, 11);
+ AV_WL16(outbuf+12, avctx->width);
+ AV_WL16(outbuf+14, avctx->height);
+ outbuf[17] = 0x20; /* origin is top-left. no alpha */
+
+ /* TODO: support alpha channel */
+ switch(avctx->pix_fmt) {
+ case PIX_FMT_GRAY8:
+ outbuf[2] = 3; /* uncompressed grayscale image */
+ outbuf[16] = 8; /* bpp */
+ break;
+ case PIX_FMT_RGB555:
+ outbuf[2] = 2; /* uncompresses true-color image */
+ outbuf[16] = 16; /* bpp */
+ break;
+ case PIX_FMT_BGR24:
+ outbuf[2] = 2; /* uncompressed true-color image */
+ outbuf[16] = 24; /* bpp */
+ break;
+ default:
+ return -1;
+ }
+ bpp = outbuf[16] >> 3;
+
+ out = outbuf + 18; /* skip past the header we just output */
+
+ /* try RLE compression */
+ datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
+
+ /* if that worked well, mark the picture as RLE compressed */
+ if(datasize >= 0)
+ outbuf[2] |= 8;
+
+ /* if RLE didn't make it smaller, go back to no compression */
+ else datasize = targa_encode_normal(out, p, bpp, avctx->width, avctx->height);
+
+ out += datasize;
+
+ /* The standard recommends including this section, even if we don't use
+ * any of the features it affords. TODO: take advantage of the pixel
+ * aspect ratio and encoder ID fields available? */
+ memcpy(out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.", 26);
+
+ return out + 26 - outbuf;
+}
+
+static int targa_encode_init(AVCodecContext *avctx)
+{
+ return 0;
+}
+
+AVCodec targa_encoder = {
+ .name = "targa",
+ .type = CODEC_TYPE_VIDEO,
+ .id = CODEC_ID_TARGA,
+ .priv_data_size = 0,
+ .init = targa_encode_init,
+ .encode = targa_encode_frame,
+ .pix_fmts= (enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB555, PIX_FMT_GRAY8, -1},
+};
diff --git a/contrib/ffmpeg/libavcodec/tiff.c b/contrib/ffmpeg/libavcodec/tiff.c
index 5925af1ae..344b5a311 100644
--- a/contrib/ffmpeg/libavcodec/tiff.c
+++ b/contrib/ffmpeg/libavcodec/tiff.c
@@ -87,13 +87,13 @@ typedef struct TiffContext {
} TiffContext;
static int tget_short(uint8_t **p, int le){
- int v = le ? LE_16(*p) : BE_16(*p);
+ int v = le ? AV_RL16(*p) : AV_RB16(*p);
*p += 2;
return v;
}
static int tget_long(uint8_t **p, int le){
- int v = le ? LE_32(*p) : BE_32(*p);
+ int v = le ? AV_RL32(*p) : AV_RB32(*p);
*p += 4;
return v;
}
@@ -332,6 +332,7 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
}else
s->stripdata = start + off;
s->strips = count;
+ if(s->strips == 1) s->rps = s->height;
s->sot = type;
if(s->stripdata > end_buf){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
@@ -447,7 +448,7 @@ static int decode_frame(AVCodecContext *avctx,
int i, entries;
//parse image header
- id = LE_16(buf); buf += 2;
+ id = AV_RL16(buf); buf += 2;
if(id == 0x4949) le = 1;
else if(id == 0x4D4D) le = 0;
else{
diff --git a/contrib/ffmpeg/libavcodec/truemotion1.c b/contrib/ffmpeg/libavcodec/truemotion1.c
index 11d9320c0..a7d3544f4 100644
--- a/contrib/ffmpeg/libavcodec/truemotion1.c
+++ b/contrib/ffmpeg/libavcodec/truemotion1.c
@@ -348,9 +348,9 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
header.compression = header_buffer[0];
header.deltaset = header_buffer[1];
header.vectable = header_buffer[2];
- header.ysize = LE_16(&header_buffer[3]);
- header.xsize = LE_16(&header_buffer[5]);
- header.checksum = LE_16(&header_buffer[7]);
+ header.ysize = AV_RL16(&header_buffer[3]);
+ header.xsize = AV_RL16(&header_buffer[5]);
+ header.checksum = AV_RL16(&header_buffer[7]);
header.version = header_buffer[9];
header.header_type = header_buffer[10];
header.flags = header_buffer[11];
@@ -374,10 +374,15 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if (s->flags & FLAG_SPRITE) {
av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n");
+ /* FIXME header.width, height, xoffset and yoffset aren't initialized */
+#if 0
s->w = header.width;
s->h = header.height;
s->x = header.xoffset;
s->y = header.yoffset;
+#else
+ return -1;
+#endif
} else {
s->w = header.xsize;
s->h = header.ysize;
@@ -412,9 +417,9 @@ 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_RGBA32;
+ s->avctx->pix_fmt = PIX_FMT_RGB32;
else
- s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported aswell
+ s->avctx->pix_fmt = PIX_FMT_RGB555; // RGB565 is supported as well
if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable))
{
diff --git a/contrib/ffmpeg/libavcodec/truemotion2.c b/contrib/ffmpeg/libavcodec/truemotion2.c
index 1b67bd22a..b282c967b 100644
--- a/contrib/ffmpeg/libavcodec/truemotion2.c
+++ b/contrib/ffmpeg/libavcodec/truemotion2.c
@@ -208,7 +208,7 @@ static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf)
obuf = buf;
- magic = LE_32(buf);
+ magic = AV_RL32(buf);
buf += 4;
if(magic == 0x00000100) { /* old header */
@@ -217,7 +217,7 @@ static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf)
} else if(magic == 0x00000101) { /* new header */
int w, h, size, flags, xr, yr;
- length = LE_32(buf);
+ length = AV_RL32(buf);
buf += 4;
init_get_bits(&ctx->gb, buf, 32 * 8);
@@ -270,17 +270,17 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
TM2Codes codes;
/* get stream length in dwords */
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
skip = len * 4 + 4;
if(len == 0)
return 4;
- toks = BE_32(buf); buf += 4; cur += 4;
+ toks = AV_RB32(buf); buf += 4; cur += 4;
if(toks & 1) {
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
if(len == TM2_ESCAPE) {
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
}
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
@@ -291,7 +291,7 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
}
}
/* skip unused fields */
- if(BE_32(buf) == TM2_ESCAPE) {
+ if(AV_RB32(buf) == TM2_ESCAPE) {
buf += 4; cur += 4; /* some unknown length - could be escaped too */
}
buf += 4; cur += 4;
@@ -312,7 +312,7 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ctx->tok_lens[stream_id] = toks;
- len = BE_32(buf); buf += 4; cur += 4;
+ 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++)
@@ -384,7 +384,7 @@ static inline void tm2_apply_deltas(TM2Context *ctx, int* Y, int stride, int *de
d = deltas[i + j * 4];
ct += d;
last[i] += ct;
- Y[i] = clip_uint8(last[i]);
+ Y[i] = av_clip_uint8(last[i]);
}
Y += stride;
ctx->D[j] = ct;
@@ -735,7 +735,7 @@ static int tm2_decode_blocks(TM2Context *ctx, AVFrame *p)
src = (ctx->cur?ctx->Y2:ctx->Y1);
for(j = 0; j < ctx->avctx->height; j++){
for(i = 0; i < ctx->avctx->width; i++){
- Y[i] = clip_uint8(*src++);
+ Y[i] = av_clip_uint8(*src++);
}
Y += p->linesize[0];
}
@@ -743,7 +743,7 @@ static int tm2_decode_blocks(TM2Context *ctx, AVFrame *p)
src = (ctx->cur?ctx->U2:ctx->U1);
for(j = 0; j < (ctx->avctx->height + 1) >> 1; j++){
for(i = 0; i < (ctx->avctx->width + 1) >> 1; i++){
- U[i] = clip_uint8(*src++);
+ U[i] = av_clip_uint8(*src++);
}
U += p->linesize[2];
}
@@ -751,7 +751,7 @@ static int tm2_decode_blocks(TM2Context *ctx, AVFrame *p)
src = (ctx->cur?ctx->V2:ctx->V1);
for(j = 0; j < (ctx->avctx->height + 1) >> 1; j++){
for(i = 0; i < (ctx->avctx->width + 1) >> 1; i++){
- V[i] = clip_uint8(*src++);
+ V[i] = av_clip_uint8(*src++);
}
V += p->linesize[1];
}
@@ -834,7 +834,6 @@ static int decode_init(AVCodecContext *avctx){
l->avctx = avctx;
l->pic.data[0]=NULL;
- avctx->has_b_frames = 0;
avctx->pix_fmt = PIX_FMT_YUV420P;
dsputil_init(&l->dsp, avctx);
diff --git a/contrib/ffmpeg/libavcodec/truespeech.c b/contrib/ffmpeg/libavcodec/truespeech.c
index 077e9b037..a03f2a0ce 100644
--- a/contrib/ffmpeg/libavcodec/truespeech.c
+++ b/contrib/ffmpeg/libavcodec/truespeech.c
@@ -62,7 +62,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
uint32_t t;
/* first dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->flag = t & 1;
@@ -77,7 +77,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->vector[7] = ts_codebook[7][(t >> 29) & 0x7];
/* second dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->offset2[0] = (t >> 0) & 0x7F;
@@ -88,7 +88,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] = ((t >> 28) & 0xF) << 4;
/* third dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulseval[0] = (t >> 0) & 0x3FFF;
@@ -97,7 +97,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[1] = (t >> 28) & 0x0F;
/* fourth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulseval[2] = (t >> 0) & 0x3FFF;
@@ -106,7 +106,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[1] |= ((t >> 28) & 0x0F) << 4;
/* fifth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[0] = (t >> 4) & 0x7FFFFFF;
@@ -116,7 +116,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] |= (t >> 31) & 1;
/* sixth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[1] = (t >> 4) & 0x7FFFFFF;
@@ -126,7 +126,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] |= ((t >> 31) & 1) << 1;
/* seventh dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[2] = (t >> 4) & 0x7FFFFFF;
@@ -136,7 +136,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] |= ((t >> 31) & 1) << 2;
/* eighth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[3] = (t >> 4) & 0x7FFFFFF;
@@ -281,7 +281,7 @@ static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
for(k = 0; k < 8; k++)
sum += ptr0[k] * ptr1[k];
sum = (sum + (out[i] << 12) + 0x800) >> 12;
- out[i] = clip(sum, -0x7FFE, 0x7FFE);
+ out[i] = av_clip(sum, -0x7FFE, 0x7FFE);
for(k = 7; k > 0; k--)
ptr0[k] = ptr0[k - 1];
ptr0[0] = out[i];
@@ -311,11 +311,11 @@ static void truespeech_synth(TSContext *dec, int16_t *out, int quart)
sum += ptr0[k] * t[k];
for(k = 7; k > 0; k--)
ptr0[k] = ptr0[k - 1];
- ptr0[0] = clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
+ ptr0[0] = av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
sum = ((ptr0[1] * (dec->filtval - (dec->filtval >> 2))) >> 4) + sum;
sum = sum - (sum >> 3);
- out[i] = clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
+ out[i] = av_clip((sum + 0x800) >> 12, -0x7FFE, 0x7FFE);
}
}
diff --git a/contrib/ffmpeg/libavcodec/tscc.c b/contrib/ffmpeg/libavcodec/tscc.c
index a24540f37..1453eb568 100644
--- a/contrib/ffmpeg/libavcodec/tscc.c
+++ b/contrib/ffmpeg/libavcodec/tscc.c
@@ -121,14 +121,14 @@ static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
}
} else if (c->bpp == 16) {
for(i = 0; i < p2; i++) {
- pix16 = LE_16(src);
+ pix16 = AV_RL16(src);
src += 2;
*(uint16_t*)output = pix16;
output += 2;
}
} else if (c->bpp == 32) {
for(i = 0; i < p2; i++) {
- pix32 = LE_32(src);
+ pix32 = AV_RL32(src);
src += 4;
*(uint32_t*)output = pix32;
output += 4;
@@ -140,7 +140,7 @@ static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
switch(c->bpp){
case 8: pix[0] = *src++;
break;
- case 16: pix16 = LE_16(src);
+ case 16: pix16 = AV_RL16(src);
src += 2;
*(uint16_t*)pix = pix16;
break;
@@ -148,7 +148,7 @@ static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
pix[1] = *src++;
pix[2] = *src++;
break;
- case 32: pix32 = LE_32(src);
+ case 32: pix32 = AV_RL32(src);
src += 4;
*(uint32_t*)pix = pix32;
break;
@@ -261,7 +261,6 @@ static int decode_init(AVCodecContext *avctx)
int zret; // Zlib return code
c->avctx = avctx;
- avctx->has_b_frames = 0;
c->pic.data[0] = NULL;
c->height = avctx->height;
@@ -283,7 +282,7 @@ static int decode_init(AVCodecContext *avctx)
case 24:
avctx->pix_fmt = PIX_FMT_BGR24;
break;
- case 32: avctx->pix_fmt = PIX_FMT_RGBA32; break;
+ case 32: avctx->pix_fmt = PIX_FMT_RGB32; break;
default: av_log(avctx, AV_LOG_ERROR, "Camtasia error: unknown depth %i bpp\n", avctx->bits_per_sample);
return -1;
}
diff --git a/contrib/ffmpeg/libavcodec/ulti.c b/contrib/ffmpeg/libavcodec/ulti.c
index b4028f439..d84a88dad 100644
--- a/contrib/ffmpeg/libavcodec/ulti.c
+++ b/contrib/ffmpeg/libavcodec/ulti.c
@@ -51,7 +51,6 @@ static int ulti_decode_init(AVCodecContext *avctx)
s->height = avctx->height;
s->blocks = (s->width / 8) * (s->height / 8);
avctx->pix_fmt = PIX_FMT_YUV410P;
- avctx->has_b_frames = 0;
avctx->coded_frame = (AVFrame*) &s->frame;
s->ulti_codebook = ulti_codebook;
diff --git a/contrib/ffmpeg/libavcodec/utils.c b/contrib/ffmpeg/libavcodec/utils.c
index 2c7a76c11..2129c9d15 100644
--- a/contrib/ffmpeg/libavcodec/utils.c
+++ b/contrib/ffmpeg/libavcodec/utils.c
@@ -59,9 +59,6 @@ const uint8_t ff_reverse[256]={
static int volatile entangled_thread_counter=0;
-/**
- * realloc which does nothing if the block is large enough
- */
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
{
if(min_size < *size)
@@ -76,9 +73,6 @@ static unsigned int last_static = 0;
static unsigned int allocated_static = 0;
static void** array_static = NULL;
-/**
- * allocation of static arrays - do not use for normal allocation.
- */
void *av_mallocz_static(unsigned int size)
{
void *ptr = av_mallocz(size);
@@ -93,11 +87,7 @@ void *av_mallocz_static(unsigned int size)
return ptr;
}
-/**
- * same as above, but does realloc
- */
-
-void *av_realloc_static(void *ptr, unsigned int size)
+void *ff_realloc_static(void *ptr, unsigned int size)
{
int i;
if(!ptr)
@@ -113,9 +103,6 @@ void *av_realloc_static(void *ptr, unsigned int size)
}
-/**
- * free all static arrays and reset pointers to 0.
- */
void av_free_static(void)
{
while(last_static){
@@ -172,7 +159,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
switch(s->pix_fmt){
case PIX_FMT_YUV420P:
- case PIX_FMT_YUV422:
+ case PIX_FMT_YUYV422:
case PIX_FMT_UYVY422:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV444P:
@@ -186,7 +173,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
h_align= 16;
break;
case PIX_FMT_YUV411P:
- case PIX_FMT_UYVY411:
+ case PIX_FMT_UYYVYY411:
w_align=32;
h_align=8;
break;
@@ -237,8 +224,14 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
InternalBuffer *buf;
int *picture_number;
- assert(pic->data[0]==NULL);
- assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count);
+ if(pic->data[0]!=NULL) {
+ av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n");
+ return -1;
+ }
+ if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) {
+ av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n");
+ return -1;
+ }
if(avcodec_check_dimensions(s,w,h))
return -1;
@@ -327,7 +320,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
int i;
- InternalBuffer *buf, *last, temp;
+ InternalBuffer *buf, *last;
assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
assert(s->internal_buffer_count);
@@ -342,9 +335,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
s->internal_buffer_count--;
last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
- temp= *buf;
- *buf= *last;
- *last= temp;
+ FFSWAP(InternalBuffer, *buf, *last);
for(i=0; i<3; i++){
pic->data[i]=NULL;
@@ -379,7 +370,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
if (s->get_buffer(s, pic))
return -1;
/* Copy image data from old buffer to new buffer */
- img_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
+ av_picture_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
s->height);
s->release_buffer(s, &temp_pic); // Release old frame
return 0;
@@ -420,8 +411,9 @@ static const char* context_to_name(void* ptr) {
#define AV_CODEC_DEFAULT_BITRATE 200*1000
static const AVOption options[]={
-{"b", "set video bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|A|E},
-{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE*20, INT_MIN, INT_MAX, V|E},
+{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|E},
+{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, 64*1000, INT_MIN, INT_MAX, A|E},
+{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE*20, 1, INT_MAX, V|E},
{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|A|E|D, "flags"},
{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_4MV, INT_MIN, INT_MAX, V|E, "flags"},
{"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_OBMC, INT_MIN, INT_MAX, V|E, "flags"},
@@ -464,7 +456,7 @@ static const AVOption options[]={
{"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, DEFAULT, INT_MIN, INT_MAX},
{"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, 12, INT_MIN, INT_MAX, V|E},
-{"rate_emu", NULL, OFFSET(rate_emu), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
+{"rate_emu", "frame rate emulation", OFFSET(rate_emu), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|E},
@@ -479,11 +471,13 @@ static const AVOption options[]={
{"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, 3, INT_MIN, INT_MAX, V|E},
{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, 0, FF_MAX_B_FRAMES, V|E},
{"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
-{"rc_strategy", NULL, OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"b_strategy", NULL, OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
+{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
{"hurry_up", NULL, OFFSET(hurry_up), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
{"rtp_mode", NULL, OFFSET(rtp_mode), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"rtp_payload_size", NULL, OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
+#endif
+{"ps", "rtp payload size in bits", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"header_bits", NULL, OFFSET(header_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"i_tex_bits", NULL, OFFSET(i_tex_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
@@ -496,30 +490,30 @@ static const AVOption options[]={
{"codec_tag", NULL, OFFSET(codec_tag), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"bug", "workaround not auto detected encoder bugs", OFFSET(workaround_bugs), FF_OPT_TYPE_FLAGS, FF_BUG_AUTODETECT, INT_MIN, INT_MAX, V|D, "bug"},
{"autodetect", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AUTODETECT, INT_MIN, INT_MAX, V|D, "bug"},
-{"old_msmpeg4", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_OLD_MSMPEG4, INT_MIN, INT_MAX, V|D, "bug"},
-{"xvid_ilace", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_XVID_ILACE, INT_MIN, INT_MAX, V|D, "bug"},
-{"ump4", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_UMP4, INT_MIN, INT_MAX, V|D, "bug"},
-{"no_padding", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_NO_PADDING, INT_MIN, INT_MAX, V|D, "bug"},
+{"old_msmpeg4", "some old lavc generated msmpeg4v3 files (no autodetection)", 0, FF_OPT_TYPE_CONST, FF_BUG_OLD_MSMPEG4, INT_MIN, INT_MAX, V|D, "bug"},
+{"xvid_ilace", "Xvid interlacing bug (autodetected if fourcc==XVIX)", 0, FF_OPT_TYPE_CONST, FF_BUG_XVID_ILACE, INT_MIN, INT_MAX, V|D, "bug"},
+{"ump4", "(autodetected if fourcc==UMP4)", 0, FF_OPT_TYPE_CONST, FF_BUG_UMP4, INT_MIN, INT_MAX, V|D, "bug"},
+{"no_padding", "padding bug (autodetected)", 0, FF_OPT_TYPE_CONST, FF_BUG_NO_PADDING, INT_MIN, INT_MAX, V|D, "bug"},
{"amv", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AMV, INT_MIN, INT_MAX, V|D, "bug"},
-{"ac_vlc", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AC_VLC, INT_MIN, INT_MAX, V|D, "bug"},
+{"ac_vlc", "illegal vlc bug (autodetected per fourcc)", 0, FF_OPT_TYPE_CONST, FF_BUG_AC_VLC, INT_MIN, INT_MAX, V|D, "bug"},
{"qpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_QPEL_CHROMA, INT_MIN, INT_MAX, V|D, "bug"},
-{"std_qpel", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_STD_QPEL, INT_MIN, INT_MAX, V|D, "bug"},
+{"std_qpel", "old standard qpel (autodetected per fourcc/version)", 0, FF_OPT_TYPE_CONST, FF_BUG_STD_QPEL, INT_MIN, INT_MAX, V|D, "bug"},
{"qpel_chroma2", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_QPEL_CHROMA2, INT_MIN, INT_MAX, V|D, "bug"},
-{"direct_blocksize", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_DIRECT_BLOCKSIZE, INT_MIN, INT_MAX, V|D, "bug"},
-{"edge", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_EDGE, INT_MIN, INT_MAX, V|D, "bug"},
+{"direct_blocksize", "direct-qpel-blocksize bug (autodetected per fourcc/version)", 0, FF_OPT_TYPE_CONST, FF_BUG_DIRECT_BLOCKSIZE, INT_MIN, INT_MAX, V|D, "bug"},
+{"edge", "edge padding bug (autodetected per fourcc/version)", 0, FF_OPT_TYPE_CONST, FF_BUG_EDGE, INT_MIN, INT_MAX, V|D, "bug"},
{"hpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_HPEL_CHROMA, INT_MIN, INT_MAX, V|D, "bug"},
{"dc_clip", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_DC_CLIP, INT_MIN, INT_MAX, V|D, "bug"},
-{"ms", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_MS, INT_MIN, INT_MAX, V|D, "bug"},
+{"ms", "workaround various bugs in microsofts broken decoders", 0, FF_OPT_TYPE_CONST, FF_BUG_MS, INT_MIN, INT_MAX, V|D, "bug"},
{"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "strict"},
-{"very", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_VERY_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
-{"strict", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
+{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|V|D, "strict"},
+{"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|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|E, "strict"},
{"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|E, "strict"},
-{"inofficial", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
-{"experimental", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
+{"inofficial", "allow inofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
+{"experimental", "allow non standarized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
{"b_qoffset", "qp offset between p and b frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
-{"er", NULL, OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
+{"er", "set error resilience strategy", OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, A|V|D, "er"},
{"careful", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
{"compliant", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_COMPLIANT, INT_MIN, INT_MAX, V|D, "er"},
{"aggressive", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_AGGRESSIVE, INT_MIN, INT_MAX, V|D, "er"},
@@ -527,36 +521,36 @@ static const AVOption options[]={
{"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"mpeg_quant", NULL, OFFSET(mpeg_quant), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"stats_out", NULL, OFFSET(stats_out), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX},
{"stats_in", NULL, OFFSET(stats_in), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX},
{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", OFFSET(rc_qsquish), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 99, V|E},
-{"rc_qmod_amp", NULL, OFFSET(rc_qmod_amp), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
-{"rc_qmod_freq", NULL, OFFSET(rc_qmod_freq), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"rc_qmod_amp", "experimental quantizer modulation", OFFSET(rc_qmod_amp), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
+{"rc_qmod_freq", "experimental quantizer modulation", OFFSET(rc_qmod_freq), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"rc_override_count", NULL, OFFSET(rc_override_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
{"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_buf_aggressivity", NULL, OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, 1.0, FLT_MIN, FLT_MAX, V|E},
+{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, 1.0, FLT_MIN, FLT_MAX, V|E},
{"i_qfactor", "qp factor between p and i frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E},
{"i_qoffset", "qp offset between p and i frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E},
{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
-{"dct", NULL, OFFSET(dct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E, "dct"},
-{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_AUTO, INT_MIN, INT_MAX, V|E, "dct"},
-{"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_FASTINT, INT_MIN, INT_MAX, V|E, "dct"},
-{"int", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_INT, INT_MIN, INT_MAX, V|E, "dct"},
+{"dct", "DCT algorithm", OFFSET(dct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E, "dct"},
+{"auto", "autoselect a good one (default)", 0, FF_OPT_TYPE_CONST, FF_DCT_AUTO, INT_MIN, INT_MAX, V|E, "dct"},
+{"fastint", "fast integer", 0, FF_OPT_TYPE_CONST, FF_DCT_FASTINT, INT_MIN, INT_MAX, V|E, "dct"},
+{"int", "accurate integer", 0, FF_OPT_TYPE_CONST, FF_DCT_INT, INT_MIN, INT_MAX, V|E, "dct"},
{"mmx", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_MMX, INT_MIN, INT_MAX, V|E, "dct"},
{"mlib", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_MLIB, INT_MIN, INT_MAX, V|E, "dct"},
{"altivec", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_ALTIVEC, INT_MIN, INT_MAX, V|E, "dct"},
-{"faan", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_FAAN, INT_MIN, INT_MAX, V|E, "dct"},
-{"lumi_mask", "lumimasking", OFFSET(lumi_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
+{"faan", "floating point AAN DCT", 0, FF_OPT_TYPE_CONST, FF_DCT_FAAN, INT_MIN, INT_MAX, V|E, "dct"},
+{"lumi_mask", "compresses bright areas stronger than medium ones", OFFSET(lumi_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
{"tcplx_mask", "temporal complexity masking", OFFSET(temporal_cplx_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
{"scplx_mask", "spatial complexity masking", OFFSET(spatial_cplx_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
{"p_mask", "inter masking", OFFSET(p_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
-{"dark_mask", "darkness masking", OFFSET(dark_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
+{"dark_mask", "compresses dark areas stronger than medium ones", OFFSET(dark_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
{"unused", NULL, OFFSET(unused), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"idct", NULL, OFFSET(idct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E|D, "idct"},
+{"idct", "select IDCT implementation", OFFSET(idct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E|D, "idct"},
{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_AUTO, INT_MIN, INT_MAX, V|E|D, "idct"},
{"int", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_INT, INT_MIN, INT_MAX, V|E|D, "idct"},
{"simple", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLE, INT_MIN, INT_MAX, V|E|D, "idct"},
@@ -574,63 +568,63 @@ static const AVOption options[]={
{"ipp", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_IPP, INT_MIN, INT_MAX, V|E|D, "idct"},
{"xvidmmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_XVIDMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
{"slice_count", NULL, OFFSET(slice_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"ec", NULL, OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, 3, INT_MIN, INT_MAX, V|D, "ec"},
-{"guess_mvs", NULL, 0, FF_OPT_TYPE_CONST, FF_EC_GUESS_MVS, INT_MIN, INT_MAX, V|D, "ec"},
-{"deblock", NULL, 0, FF_OPT_TYPE_CONST, FF_EC_DEBLOCK, INT_MIN, INT_MAX, V|D, "ec"},
+{"ec", "set error concealment strategy", OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, 3, INT_MIN, INT_MAX, V|D, "ec"},
+{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, FF_OPT_TYPE_CONST, FF_EC_GUESS_MVS, INT_MIN, INT_MAX, V|D, "ec"},
+{"deblock", "use strong deblock filter for damaged MBs", 0, FF_OPT_TYPE_CONST, FF_EC_DEBLOCK, INT_MIN, INT_MAX, V|D, "ec"},
{"bits_per_sample", NULL, OFFSET(bits_per_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"pred", "prediction method", OFFSET(prediction_method), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "pred"},
{"left", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_LEFT, INT_MIN, INT_MAX, V|E, "pred"},
{"plane", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_PLANE, INT_MIN, INT_MAX, V|E, "pred"},
{"median", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_MEDIAN, INT_MIN, INT_MAX, V|E, "pred"},
-{"aspect", NULL, OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, DEFAULT, 0, 10, V|E},
+{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, DEFAULT, 0, 10, V|E},
{"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, V|A|S|E|D, "debug"},
-{"pict", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_PICT_INFO, INT_MIN, INT_MAX, V|D, "debug"},
-{"rc", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_RC, INT_MIN, INT_MAX, V|E, "debug"},
+{"pict", "picture info", 0, FF_OPT_TYPE_CONST, FF_DEBUG_PICT_INFO, INT_MIN, INT_MAX, V|D, "debug"},
+{"rc", "rate control", 0, FF_OPT_TYPE_CONST, FF_DEBUG_RC, INT_MIN, INT_MAX, V|E, "debug"},
{"bitstream", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_BITSTREAM, INT_MIN, INT_MAX, V|D, "debug"},
-{"mb_type", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
-{"qp", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_QP, INT_MIN, INT_MAX, V|D, "debug"},
-{"mv", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MV, INT_MIN, INT_MAX, V|D, "debug"},
+{"mb_type", "macroblock (MB) type", 0, FF_OPT_TYPE_CONST, FF_DEBUG_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
+{"qp", "per-block quantization parameter (QP)", 0, FF_OPT_TYPE_CONST, FF_DEBUG_QP, INT_MIN, INT_MAX, V|D, "debug"},
+{"mv", "motion vector", 0, FF_OPT_TYPE_CONST, FF_DEBUG_MV, INT_MIN, INT_MAX, V|D, "debug"},
{"dct_coeff", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_DCT_COEFF, INT_MIN, INT_MAX, V|D, "debug"},
{"skip", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_SKIP, INT_MIN, INT_MAX, V|D, "debug"},
{"startcode", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_STARTCODE, INT_MIN, INT_MAX, V|D, "debug"},
{"pts", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_PTS, INT_MIN, INT_MAX, V|D, "debug"},
-{"er", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_ER, INT_MIN, INT_MAX, V|D, "debug"},
-{"mmco", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MMCO, INT_MIN, INT_MAX, V|D, "debug"},
+{"er", "error resilience", 0, FF_OPT_TYPE_CONST, FF_DEBUG_ER, INT_MIN, INT_MAX, V|D, "debug"},
+{"mmco", "memory management control operations (H.264)", 0, FF_OPT_TYPE_CONST, FF_DEBUG_MMCO, INT_MIN, INT_MAX, V|D, "debug"},
{"bugs", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_BUGS, INT_MIN, INT_MAX, V|D, "debug"},
-{"vis_qp", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_QP, INT_MIN, INT_MAX, V|D, "debug"},
-{"vis_mb_type", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
-{"vismv", "visualize motion vectors", OFFSET(debug_mv), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|D, "debug_mv"},
-{"pf", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_P_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"bf", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"bb", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_BACK, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"mb_qmin", NULL, OFFSET(mb_qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"mb_qmax", NULL, OFFSET(mb_qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"vis_qp", "visualize quantization parameter (QP), lower QP are tinted greener", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_QP, INT_MIN, INT_MAX, V|D, "debug"},
+{"vis_mb_type", "visualize block types", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
+{"vismv", "visualize motion vectors (MVs)", OFFSET(debug_mv), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|D, "debug_mv"},
+{"pf", "forward predicted MVs of P-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_P_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
+{"bf", "forward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
+{"bb", "backward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_BACK, INT_MIN, INT_MAX, V|D, "debug_mv"},
+{"mb_qmin", "obsolete, use qmin", OFFSET(mb_qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"mb_qmax", "obsolete, use qmax", OFFSET(mb_qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"cmp", "full pel me compare function", OFFSET(me_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"ildctcmp", "interlaced dct compare function", OFFSET(ildct_cmp), FF_OPT_TYPE_INT, FF_CMP_VSAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dia_size", NULL, OFFSET(dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"last_pred", NULL, OFFSET(last_predictor_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"preme", "pre motion estimation", OFFSET(pre_me), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"sad", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"sse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"satd", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SATD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dct", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_DCT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"psnr", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_PSNR, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"bit", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_BIT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"rd", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_RD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"zero", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_ZERO, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsad", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_VSAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_VSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"nsse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_NSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"sad", "sum of absolute differences, fast (default)", 0, FF_OPT_TYPE_CONST, FF_CMP_SAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"sse", "sum of squared errors", 0, FF_OPT_TYPE_CONST, FF_CMP_SSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"satd", "sum of absolute Hadamard transformed differences", 0, FF_OPT_TYPE_CONST, FF_CMP_SATD, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"dct", "sum of absolute DCT transformed differences", 0, FF_OPT_TYPE_CONST, FF_CMP_DCT, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"psnr", "sum of squared quantization errors (avoid, low quality)", 0, FF_OPT_TYPE_CONST, FF_CMP_PSNR, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"bit", "number of bits needed for the block", 0, FF_OPT_TYPE_CONST, FF_CMP_BIT, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"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"},
+{"nsse", "noise preserving sum of squared differences", 0, FF_OPT_TYPE_CONST, FF_CMP_NSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
#ifdef CONFIG_SNOW_ENCODER
-{"w53", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_W53, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"w97", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_W97, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"w53", "5/3 wavelet, only used in snow", 0, FF_OPT_TYPE_CONST, FF_CMP_W53, INT_MIN, INT_MAX, V|E, "cmp_func"},
+{"w97", "9/7 wavelet, only used in snow", 0, FF_OPT_TYPE_CONST, FF_CMP_W97, INT_MIN, INT_MAX, V|E, "cmp_func"},
#endif
{"dctmax", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_DCTMAX, INT_MIN, INT_MAX, V|E, "cmp_func"},
{"chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_CHROMA, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"pre_dia_size", NULL, OFFSET(pre_dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"pre_dia_size", "diamond type & size for motion estimation pre-pass", OFFSET(pre_dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"subq", "sub pel motion estimation quality", OFFSET(me_subpel_quality), FF_OPT_TYPE_INT, 8, INT_MIN, INT_MAX, V|E},
{"dtg_active_format", NULL, OFFSET(dtg_active_format), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
@@ -645,20 +639,20 @@ static const AVOption options[]={
{"context", "context model", OFFSET(context_model), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"slice_flags", NULL, OFFSET(slice_flags), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"mbd", NULL, OFFSET(mb_decision), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "mbd"},
-{"simple", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_SIMPLE, INT_MIN, INT_MAX, V|E, "mbd"},
-{"bits", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_BITS, INT_MIN, INT_MAX, V|E, "mbd"},
-{"rd", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_RD, INT_MIN, INT_MAX, V|E, "mbd"},
+{"mbd", "macroblock decision algorithm (high quality mode)", OFFSET(mb_decision), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "mbd"},
+{"simple", "use mbcmp (default)", 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_SIMPLE, INT_MIN, INT_MAX, V|E, "mbd"},
+{"bits", "use fewest bits", 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_BITS, INT_MIN, INT_MAX, V|E, "mbd"},
+{"rd", "use best rate distortion", 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_RD, INT_MIN, INT_MAX, V|E, "mbd"},
{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"lmin", "min lagrange factor (VBR)", OFFSET(lmin), FF_OPT_TYPE_INT, 2*FF_QP2LAMBDA, 0, INT_MAX, V|E},
{"lmax", "max lagrange factor (VBR)", OFFSET(lmax), FF_OPT_TYPE_INT, 31*FF_QP2LAMBDA, 0, INT_MAX, V|E},
{"nr", "noise reduction", OFFSET(noise_reduction), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_init_occupancy", NULL, OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|A|E|D, "flags2"},
{"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"antialias", NULL, OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
+{"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"},
{"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FASTINT, INT_MIN, INT_MAX, V|D, "aa"},
{"int", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_INT, INT_MIN, INT_MAX, V|D, "aa"},
@@ -669,61 +663,63 @@ static const AVOption options[]={
{"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"dc", "intra_dc_precision", OFFSET(intra_dc_precision), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
{"nssew", "nsse weight", OFFSET(nsse_weight), FF_OPT_TYPE_INT, 8, INT_MIN, INT_MAX, V|E},
-{"skip_top", NULL, OFFSET(skip_top), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
-{"skip_bottom", NULL, OFFSET(skip_bottom), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
+{"skip_top", "number of macroblock rows at the top which are skipped", OFFSET(skip_top), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
+{"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
{"profile", NULL, OFFSET(profile), FF_OPT_TYPE_INT, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
{"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
-{"lowres", NULL, OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|D},
+{"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},
{"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},
{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), FF_OPT_TYPE_INT, FF_CMP_DCTMAX, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"border_mask", NULL, OFFSET(border_masking), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
+{"border_mask", "increases the quantizer for macroblocks close to borders", OFFSET(border_masking), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
{"mblmin", "min macroblock lagrange factor (VBR)", OFFSET(mb_lmin), FF_OPT_TYPE_INT, FF_QP2LAMBDA * 2, 1, FF_LAMBDA_MAX, V|E},
{"mblmax", "max macroblock lagrange factor (VBR)", OFFSET(mb_lmax), FF_OPT_TYPE_INT, FF_QP2LAMBDA * 31, 1, FF_LAMBDA_MAX, V|E},
{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), FF_OPT_TYPE_INT, 256, INT_MIN, INT_MAX, V|E},
-{"bidir_refine", NULL, OFFSET(bidir_refine), FF_OPT_TYPE_INT, DEFAULT, 0, 4, V|E},
-{"brd_scale", NULL, OFFSET(brd_scale), FF_OPT_TYPE_INT, DEFAULT, 0, 10, V|E},
-{"crf", NULL, OFFSET(crf), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E},
-{"cqp", NULL, OFFSET(cqp), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, V|E},
-{"keyint_min", NULL, OFFSET(keyint_min), FF_OPT_TYPE_INT, 25, INT_MIN, INT_MAX, V|E},
-{"refs", NULL, OFFSET(refs), FF_OPT_TYPE_INT, 1, INT_MIN, INT_MAX, V|E},
-{"chromaoffset", NULL, OFFSET(chromaoffset), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"bframebias", NULL, OFFSET(bframebias), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"trellis", NULL, OFFSET(trellis), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|A|E},
-{"directpred", NULL, OFFSET(directpred), FF_OPT_TYPE_INT, 2, INT_MIN, INT_MAX, V|E},
-{"bpyramid", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BPYRAMID, INT_MIN, INT_MAX, V|E, "flags2"},
-{"wpred", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_WPRED, INT_MIN, INT_MAX, V|E, "flags2"},
-{"mixed_refs", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MIXED_REFS, INT_MIN, INT_MAX, V|E, "flags2"},
-{"8x8dct", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_8X8DCT, INT_MIN, INT_MAX, V|E, "flags2"},
-{"fastpskip", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|E, "flags2"},
-{"aud", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_AUD, INT_MIN, INT_MAX, V|E, "flags2"},
-{"brdo", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BRDO, INT_MIN, INT_MAX, V|E, "flags2"},
-{"complexityblur", NULL, OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, 20.0, FLT_MIN, FLT_MAX, V|E},
-{"deblockalpha", NULL, OFFSET(deblockalpha), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"deblockbeta", NULL, OFFSET(deblockbeta), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"partitions", NULL, OFFSET(partitions), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|E, "partitions"},
+{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), FF_OPT_TYPE_INT, DEFAULT, 0, 4, V|E},
+{"brd_scale", "downscales frames for dynamic B-frame decision", OFFSET(brd_scale), FF_OPT_TYPE_INT, DEFAULT, 0, 10, V|E},
+{"crf", "enables constant quality mode, and selects the quality (x264)", OFFSET(crf), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E},
+{"cqp", "constant quantization parameter rate control method", OFFSET(cqp), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, V|E},
+{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), FF_OPT_TYPE_INT, 25, INT_MIN, INT_MAX, V|E},
+{"refs", "reference frames to consider for motion compensation (Snow)", OFFSET(refs), FF_OPT_TYPE_INT, 1, INT_MIN, INT_MAX, V|E},
+{"chromaoffset", "chroma qp offset from luma", OFFSET(chromaoffset), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"bframebias", "influences how often B-frames are used", OFFSET(bframebias), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
+{"trellis", "rate-distortion optimal quantization", OFFSET(trellis), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|A|E},
+{"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal)", OFFSET(directpred), FF_OPT_TYPE_INT, 2, INT_MIN, INT_MAX, V|E},
+{"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BPYRAMID, INT_MIN, INT_MAX, V|E, "flags2"},
+{"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_WPRED, INT_MIN, INT_MAX, V|E, "flags2"},
+{"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MIXED_REFS, INT_MIN, INT_MAX, V|E, "flags2"},
+{"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_8X8DCT, INT_MIN, INT_MAX, V|E, "flags2"},
+{"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|E, "flags2"},
+{"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_AUD, INT_MIN, INT_MAX, V|E, "flags2"},
+{"brdo", "b-frame rate-distortion optimization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BRDO, INT_MIN, INT_MAX, V|E, "flags2"},
+{"skiprd", "RD optimal MB level residual skiping", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SKIP_RD, INT_MIN, INT_MAX, V|E, "flags2"},
+{"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, 20.0, FLT_MIN, FLT_MAX, V|E},
+{"deblockalpha", "in-loop deblocking filter alphac0 parameter", OFFSET(deblockalpha), FF_OPT_TYPE_INT, DEFAULT, -6, 6, V|E},
+{"deblockbeta", "in-loop deblocking filter beta parameter", OFFSET(deblockbeta), FF_OPT_TYPE_INT, DEFAULT, -6, 6, V|E},
+{"partitions", "macroblock subpartition sizes to consider", OFFSET(partitions), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|E, "partitions"},
{"parti4x4", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_I4X4, INT_MIN, INT_MAX, V|E, "partitions"},
{"parti8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_I8X8, INT_MIN, INT_MAX, V|E, "partitions"},
{"partp4x4", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_P4X4, INT_MIN, INT_MAX, V|E, "partitions"},
{"partp8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_P8X8, INT_MIN, INT_MAX, V|E, "partitions"},
{"partb8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_B8X8, INT_MIN, INT_MAX, V|E, "partitions"},
-{"sc_factor", NULL, OFFSET(scenechange_factor), FF_OPT_TYPE_INT, 6, 0, INT_MAX, V|E},
+{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), FF_OPT_TYPE_INT, 6, 0, INT_MAX, V|E},
{"mv0_threshold", NULL, OFFSET(mv0_threshold), FF_OPT_TYPE_INT, 256, 0, INT_MAX, V|E},
{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
-{"b_sensitivity", NULL, OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E},
+{"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},
-{"use_lpc", NULL, OFFSET(use_lpc), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
-{"lpc_coeff_precision", NULL, OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
+{"use_lpc", "sets whether to use LPC mode (FLAC)", OFFSET(use_lpc), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
+{"lpc_coeff_precision", "LPC coefficient precision (FLAC)", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
{"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
-{"prediction_order_method", NULL, OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
+{"prediction_order_method", "search method for selecting prediction order", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
{"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
{"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
-{"timecode_frame_start", NULL, OFFSET(timecode_frame_start), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
+{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
+{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},
{NULL},
};
@@ -736,12 +732,19 @@ static const AVOption options[]={
static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
-void avcodec_get_context_defaults(AVCodecContext *s){
+void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType codec_type){
+ int flags=0;
memset(s, 0, sizeof(AVCodecContext));
s->av_class= &av_codec_context_class;
- av_opt_set_defaults(s);
+ if(codec_type == CODEC_TYPE_AUDIO)
+ flags= AV_OPT_FLAG_AUDIO_PARAM;
+ else if(codec_type == CODEC_TYPE_VIDEO)
+ flags= AV_OPT_FLAG_VIDEO_PARAM;
+ else if(codec_type == CODEC_TYPE_SUBTITLE)
+ flags= AV_OPT_FLAG_SUBTITLE_PARAM;
+ av_opt_set_defaults2(s, flags, flags);
s->rc_eq= "tex^qComp";
s->time_base= (AVRational){0,1};
@@ -757,20 +760,24 @@ void avcodec_get_context_defaults(AVCodecContext *s){
s->reget_buffer= avcodec_default_reget_buffer;
}
-/**
- * allocates a AVCodecContext and set it to defaults.
- * this can be deallocated by simply calling free()
- */
-AVCodecContext *avcodec_alloc_context(void){
+AVCodecContext *avcodec_alloc_context2(enum CodecType codec_type){
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
if(avctx==NULL) return NULL;
- avcodec_get_context_defaults(avctx);
+ avcodec_get_context_defaults2(avctx, codec_type);
return avctx;
}
+void avcodec_get_context_defaults(AVCodecContext *s){
+ avcodec_get_context_defaults2(s, CODEC_TYPE_UNKNOWN);
+}
+
+AVCodecContext *avcodec_alloc_context(void){
+ return avcodec_alloc_context2(CODEC_TYPE_UNKNOWN);
+}
+
void avcodec_get_frame_defaults(AVFrame *pic){
memset(pic, 0, sizeof(AVFrame));
@@ -778,10 +785,6 @@ void avcodec_get_frame_defaults(AVFrame *pic){
pic->key_frame= 1;
}
-/**
- * allocates a AVPFrame and set it to defaults.
- * this can be deallocated by simply calling free()
- */
AVFrame *avcodec_alloc_frame(void){
AVFrame *pic= av_malloc(sizeof(AVFrame));
@@ -826,11 +829,13 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
avctx->codec = codec;
avctx->codec_id = codec->id;
avctx->frame_number = 0;
- ret = avctx->codec->init(avctx);
- if (ret < 0) {
- av_freep(&avctx->priv_data);
- avctx->codec= NULL;
- goto end;
+ if(avctx->codec->init){
+ ret = avctx->codec->init(avctx);
+ if (ret < 0) {
+ av_freep(&avctx->priv_data);
+ avctx->codec= NULL;
+ goto end;
+ }
}
ret=0;
end:
@@ -842,7 +847,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const short *samples)
{
if(buf_size < FF_MIN_BUFFER_SIZE && 0){
- av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
+ av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){
@@ -857,7 +862,7 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
if(buf_size < FF_MIN_BUFFER_SIZE){
- av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
+ av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
return -1;
}
if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
@@ -881,15 +886,6 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return ret;
}
-/**
- * decode a frame.
- * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
- * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
- * @param buf_size the size of the buffer in bytes
- * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero
- * @return -1 if error, otherwise return the number of
- * bytes used.
- */
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
uint8_t *buf, int buf_size)
@@ -913,29 +909,44 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
return ret;
}
-/* decode an audio frame. return -1 if error, otherwise return the
- *number of bytes used. If no frame could be decompressed,
- *frame_size_ptr is zero. Otherwise, it is the decompressed frame
- *size in BYTES. */
-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size)
{
int ret;
- *frame_size_ptr= 0;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
+ //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){
+ av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
+ return -1;
+ }
+ if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
+ *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
+ *frame_size_ptr < buf_size){
+ av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
+ return -1;
+ }
+
ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
buf, buf_size);
avctx->frame_number++;
- }else
+ }else{
ret= 0;
+ *frame_size_ptr=0;
+ }
return ret;
}
-/* decode a subtitle message. return -1 if error, otherwise return the
- *number of bytes used. If no subtitle could be decompressed,
- *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+ int *frame_size_ptr,
+ uint8_t *buf, int buf_size){
+ *frame_size_ptr= AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, buf_size);
+}
+#endif
+
int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
const uint8_t *buf, int buf_size)
@@ -1073,7 +1084,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %dx%d",
enc->width, enc->height);
- if(av_log_get_level() >= AV_LOG_DEBUG){
+ if(av_log_level >= AV_LOG_DEBUG){
int g= ff_gcd(enc->time_base.num, enc->time_base.den);
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %d/%d",
@@ -1180,15 +1191,16 @@ unsigned avcodec_build( void )
}
static void init_crcs(void){
+#if LIBAVUTIL_VERSION_INT < (50<<16)
av_crc04C11DB7= av_mallocz_static(sizeof(AVCRC) * 257);
av_crc8005 = av_mallocz_static(sizeof(AVCRC) * 257);
av_crc07 = av_mallocz_static(sizeof(AVCRC) * 257);
+#endif
av_crc_init(av_crc04C11DB7, 0, 32, 0x04c11db7, sizeof(AVCRC)*257);
av_crc_init(av_crc8005 , 0, 16, 0x8005 , sizeof(AVCRC)*257);
av_crc_init(av_crc07 , 0, 8, 0x07 , sizeof(AVCRC)*257);
}
-/* must be called before any other functions */
void avcodec_init(void)
{
static int inited = 0;
@@ -1201,9 +1213,6 @@ void avcodec_init(void)
init_crcs();
}
-/**
- * Flush buffers, should be called when seeking or when swicthing to a different stream.
- */
void avcodec_flush_buffers(AVCodecContext *avctx)
{
if(avctx->codec->flush)
diff --git a/contrib/ffmpeg/libavcodec/vc1.c b/contrib/ffmpeg/libavcodec/vc1.c
index cd3c0c2d6..84868904d 100644
--- a/contrib/ffmpeg/libavcodec/vc1.c
+++ b/contrib/ffmpeg/libavcodec/vc1.c
@@ -1,6 +1,6 @@
/*
* VC-1 and WMV3 decoder
- * Copyright (c) 2006 Konstantin Shishkov
+ * Copyright (c) 2006-2007 Konstantin Shishkov
* Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
*
* This file is part of FFmpeg.
@@ -46,6 +46,18 @@ extern const uint16_t ff_msmp4_mb_i_table[64][2];
#define AC_VLC_BITS 9
static const uint16_t table_mb_intra[64][2];
+/** Markers used if VC-1 AP frame data */
+//@{
+enum VC1Code{
+ VC1_CODE_RES0 = 0x00000100,
+ VC1_CODE_ENDOFSEQ = 0x0000010A,
+ VC1_CODE_SLICE,
+ VC1_CODE_FIELD,
+ VC1_CODE_FRAME,
+ VC1_CODE_ENTRYPOINT,
+ VC1_CODE_SEQHDR,
+};
+//@}
/** Available Profiles */
//@{
@@ -790,6 +802,10 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
}
uvmx = (mx + ((mx & 3) == 3)) >> 1;
uvmy = (my + ((my & 3) == 3)) >> 1;
+ if(v->fastuvmc) {
+ uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1));
+ uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1));
+ }
if(!dir) {
srcY = s->last_picture.data[0];
srcU = s->last_picture.data[1];
@@ -805,10 +821,17 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
- src_x = clip( src_x, -16, s->mb_width * 16);
- src_y = clip( src_y, -16, s->mb_height * 16);
- uvsrc_x = clip(uvsrc_x, -8, s->mb_width * 8);
- uvsrc_y = clip(uvsrc_y, -8, s->mb_height * 8);
+ if(v->profile != PROFILE_ADVANCED){
+ src_x = av_clip( src_x, -16, s->mb_width * 16);
+ src_y = av_clip( src_y, -16, s->mb_height * 16);
+ uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
+ uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
+ }else{
+ src_x = av_clip( src_x, -17, s->avctx->coded_width);
+ src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
+ uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
+ uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
+ }
srcY += src_y * s->linesize + src_x;
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
@@ -878,11 +901,6 @@ static void vc1_mc_1mv(VC1Context *v, int dir)
srcY += s->mspel * (1 + s->linesize);
}
- if(v->fastuvmc) {
- uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1));
- uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1));
- }
-
if(s->mspel) {
dxy = ((my & 3) << 2) | (mx & 3);
dsp->put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd);
@@ -933,8 +951,13 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n)
src_x = s->mb_x * 16 + (n&1) * 8 + (mx >> 2);
src_y = s->mb_y * 16 + (n&2) * 4 + (my >> 2);
- src_x = clip( src_x, -16, s->mb_width * 16);
- src_y = clip( src_y, -16, s->mb_height * 16);
+ if(v->profile != PROFILE_ADVANCED){
+ src_x = av_clip( src_x, -16, s->mb_width * 16);
+ src_y = av_clip( src_y, -16, s->mb_height * 16);
+ }else{
+ src_x = av_clip( src_x, -17, s->avctx->coded_width);
+ src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
+ }
srcY += src_y * s->linesize + src_x;
@@ -1045,19 +1068,32 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
for(i= t1+1; i<4; i++)if(!intra[i]) {t2 = i; break;}
tx = (mvx[t1] + mvx[t2]) / 2;
ty = (mvy[t1] + mvy[t2]) / 2;
- } else
+ } else {
+ s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
+ s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
return; //no need to do MC for inter blocks
+ }
s->current_picture.motion_val[1][s->block_index[0]][0] = tx;
s->current_picture.motion_val[1][s->block_index[0]][1] = ty;
uvmx = (tx + ((tx&3) == 3)) >> 1;
uvmy = (ty + ((ty&3) == 3)) >> 1;
+ if(v->fastuvmc) {
+ uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1));
+ uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1));
+ }
uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
- uvsrc_x = clip(uvsrc_x, -8, s->mb_width * 8);
- uvsrc_y = clip(uvsrc_y, -8, s->mb_height * 8);
+ if(v->profile != PROFILE_ADVANCED){
+ uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
+ uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
+ }else{
+ uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
+ uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
+ }
+
srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
@@ -1102,11 +1138,6 @@ static void vc1_mc_4mv_chroma(VC1Context *v)
}
}
- if(v->fastuvmc) {
- uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1));
- uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1));
- }
-
/* Chroma MC always uses qpel bilinear */
uvdxy = ((uvmy & 3) << 2) | (uvmx & 3);
uvmx = (uvmx&3)<<1;
@@ -1135,10 +1166,9 @@ static int decode_sequence_header(AVCodecContext *avctx, GetBitContext *gb)
av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits(gb, 32));
v->profile = get_bits(gb, 2);
- if (v->profile == 2)
+ if (v->profile == PROFILE_COMPLEX)
{
- av_log(avctx, AV_LOG_ERROR, "Profile value 2 is forbidden (and WMV3 Complex Profile is unsupported)\n");
- return -1;
+ av_log(avctx, AV_LOG_ERROR, "WMV3 Complex Profile is not fully supported\n");
}
if (v->profile == PROFILE_ADVANCED)
@@ -1231,6 +1261,8 @@ static int decode_sequence_header(AVCodecContext *avctx, GetBitContext *gb)
"Old WMV3 version detected, only I-frames will be decoded\n");
//return -1;
}
+ //TODO: figure out what they mean (always 0x402F)
+ if(!v->res_fasttx) skip_bits(gb, 16);
av_log(avctx, AV_LOG_DEBUG,
"Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
"LoopFilter=%i, MultiRes=%i, FastUVMC=%i, Extended MV=%i\n"
@@ -1268,36 +1300,60 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
v->s.avctx->coded_width = (get_bits(gb, 12) + 1) << 1;
v->s.avctx->coded_height = (get_bits(gb, 12) + 1) << 1;
+ v->s.avctx->width = v->s.avctx->coded_width;
+ v->s.avctx->height = v->s.avctx->coded_height;
v->broadcast = get_bits1(gb);
v->interlace = get_bits1(gb);
v->tfcntrflag = get_bits1(gb);
v->finterpflag = get_bits1(gb);
get_bits1(gb); // reserved
+
+ v->s.h_edge_pos = v->s.avctx->coded_width;
+ v->s.v_edge_pos = v->s.avctx->coded_height;
+
+ av_log(v->s.avctx, AV_LOG_DEBUG,
+ "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
+ "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n"
+ "TFCTRflag=%i, FINTERPflag=%i\n",
+ v->level, v->frmrtq_postproc, v->bitrtq_postproc,
+ v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace,
+ v->tfcntrflag, v->finterpflag
+ );
+
v->psf = get_bits1(gb);
if(v->psf) { //PsF, 6.1.13
av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n");
return -1;
}
+ v->s.max_b_frames = v->s.avctx->max_b_frames = 7;
if(get_bits1(gb)) { //Display Info - decoding is not affected by it
int w, h, ar = 0;
- av_log(v->s.avctx, AV_LOG_INFO, "Display extended info:\n");
- w = get_bits(gb, 14);
- h = get_bits(gb, 14);
- av_log(v->s.avctx, AV_LOG_INFO, "Display dimensions: %ix%i\n", w, h);
- //TODO: store aspect ratio in AVCodecContext
+ av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n");
+ v->s.avctx->width = v->s.width = w = get_bits(gb, 14) + 1;
+ v->s.avctx->height = v->s.height = h = get_bits(gb, 14) + 1;
+ av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h);
if(get_bits1(gb))
ar = get_bits(gb, 4);
- if(ar == 15) {
+ if(ar && ar < 14){
+ v->s.avctx->sample_aspect_ratio = vc1_pixel_aspect[ar];
+ }else if(ar == 15){
w = get_bits(gb, 8);
h = get_bits(gb, 8);
+ v->s.avctx->sample_aspect_ratio = (AVRational){w, h};
}
if(get_bits1(gb)){ //framerate stuff
if(get_bits1(gb)) {
- get_bits(gb, 16);
+ v->s.avctx->time_base.num = 32;
+ v->s.avctx->time_base.den = get_bits(gb, 16) + 1;
} else {
- get_bits(gb, 8);
- get_bits(gb, 4);
+ int nr, dr;
+ nr = get_bits(gb, 8);
+ dr = get_bits(gb, 4);
+ if(nr && nr < 8 && dr && dr < 3){
+ v->s.avctx->time_base.num = fps_dr[dr - 1];
+ v->s.avctx->time_base.den = fps_nr[nr - 1] * 1000;
+ }
}
}
@@ -1325,13 +1381,13 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
static int decode_entry_point(AVCodecContext *avctx, GetBitContext *gb)
{
VC1Context *v = avctx->priv_data;
- int i;
+ int i, blink, clentry, refdist;
av_log(avctx, AV_LOG_DEBUG, "Entry point: %08X\n", show_bits_long(gb, 32));
- get_bits1(gb); // broken link
- avctx->max_b_frames = 1 - get_bits1(gb); // 'closed entry' also signalize possible B-frames
+ blink = get_bits1(gb); // broken link
+ clentry = get_bits1(gb); // closed entry
v->panscanflag = get_bits1(gb);
- get_bits1(gb); // refdist flag
+ refdist = get_bits1(gb); // refdist flag
v->s.loop_filter = get_bits1(gb);
v->fastuvmc = get_bits1(gb);
v->extended_mv = get_bits1(gb);
@@ -1361,6 +1417,13 @@ static int decode_entry_point(AVCodecContext *avctx, GetBitContext *gb)
skip_bits(gb, 3); // UV range, ignored for now
}
+ av_log(avctx, AV_LOG_DEBUG, "Entry point info:\n"
+ "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n"
+ "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n"
+ "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n",
+ blink, clentry, v->panscanflag, refdist, v->s.loop_filter,
+ v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode);
+
return 0;
}
@@ -1427,6 +1490,9 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
else
if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2);
+ if(v->res_x8 && (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)){
+ if(get_bits1(gb))return -1;
+ }
//av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
// (v->s.pict_type == P_TYPE) ? 'P' : ((v->s.pict_type == I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm);
@@ -1461,8 +1527,8 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
shift = v->lumshift << 6;
}
for(i = 0; i < 256; i++) {
- v->luty[i] = clip_uint8((scale * i + shift + 32) >> 6);
- v->lutuv[i] = clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
+ v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6);
+ v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
}
}
if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
@@ -1577,14 +1643,15 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
static int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
{
- int fcm;
int pqindex, lowquant;
int status;
v->p_frame_skipped = 0;
- if(v->interlace)
- fcm = decode012(gb);
+ if(v->interlace){
+ v->fcm = decode012(gb);
+ if(v->fcm) return -1; // interlaced frames/fields are not implemented
+ }
switch(get_prefix(gb, 0, 4)) {
case 0:
v->s.pict_type = P_TYPE;
@@ -1606,11 +1673,11 @@ static int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
if(v->tfcntrflag)
get_bits(gb, 8);
if(v->broadcast) {
- if(!v->interlace || v->panscanflag) {
- get_bits(gb, 2);
+ if(!v->interlace || v->psf) {
+ v->rptfrm = get_bits(gb, 2);
} else {
- get_bits1(gb);
- get_bits1(gb);
+ v->tff = get_bits1(gb);
+ v->rptfrm = get_bits1(gb);
}
}
if(v->panscanflag) {
@@ -1645,6 +1712,8 @@ static int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
v->pquantizer = get_bits(gb, 1);
+ if(v->s.pict_type == I_TYPE || v->s.pict_type == P_TYPE) v->use_ic = 0;
+
switch(v->s.pict_type) {
case I_TYPE:
case BI_TYPE:
@@ -1699,9 +1768,10 @@ static int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
shift = v->lumshift << 6;
}
for(i = 0; i < 256; i++) {
- v->luty[i] = clip_uint8((scale * i + shift + 32) >> 6);
- v->lutuv[i] = clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
+ v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6);
+ v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
}
+ v->use_ic = 1;
}
if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
v->s.quarter_sample = 0;
@@ -1813,7 +1883,7 @@ static int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
}
/* DC Syntax */
v->s.dc_table_index = get_bits(gb, 1);
- if (v->s.pict_type == I_TYPE && v->dquant) {
+ if ((v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) && v->dquant) {
av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
vop_dquant_decoding(v);
}
@@ -1939,6 +2009,8 @@ static inline void vc1_pred_mv(MpegEncContext *s, int n, int dmv_x, int dmv_y, i
if(s->mb_intra){
s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0;
s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0;
+ s->current_picture.motion_val[1][xy][0] = 0;
+ s->current_picture.motion_val[1][xy][1] = 0;
if(mv1) { /* duplicate motion data for 1-MV block */
s->current_picture.motion_val[0][xy + 1][0] = 0;
s->current_picture.motion_val[0][xy + 1][1] = 0;
@@ -1946,6 +2018,12 @@ static inline void vc1_pred_mv(MpegEncContext *s, int n, int dmv_x, int dmv_y, i
s->current_picture.motion_val[0][xy + wrap][1] = 0;
s->current_picture.motion_val[0][xy + wrap + 1][0] = 0;
s->current_picture.motion_val[0][xy + wrap + 1][1] = 0;
+ s->current_picture.motion_val[1][xy + 1][0] = 0;
+ s->current_picture.motion_val[1][xy + 1][1] = 0;
+ s->current_picture.motion_val[1][xy + wrap][0] = 0;
+ s->current_picture.motion_val[1][xy + wrap][1] = 0;
+ s->current_picture.motion_val[1][xy + wrap + 1][0] = 0;
+ s->current_picture.motion_val[1][xy + wrap + 1][1] = 0;
}
return;
}
@@ -2061,6 +2139,10 @@ static void vc1_interp_mc(VC1Context *v)
my = s->mv[1][0][1];
uvmx = (mx + ((mx & 3) == 3)) >> 1;
uvmy = (my + ((my & 3) == 3)) >> 1;
+ if(v->fastuvmc) {
+ uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1));
+ uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1));
+ }
srcY = s->next_picture.data[0];
srcU = s->next_picture.data[1];
srcV = s->next_picture.data[2];
@@ -2070,10 +2152,17 @@ static void vc1_interp_mc(VC1Context *v)
uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
- src_x = clip( src_x, -16, s->mb_width * 16);
- src_y = clip( src_y, -16, s->mb_height * 16);
- uvsrc_x = clip(uvsrc_x, -8, s->mb_width * 8);
- uvsrc_y = clip(uvsrc_y, -8, s->mb_height * 8);
+ if(v->profile != PROFILE_ADVANCED){
+ src_x = av_clip( src_x, -16, s->mb_width * 16);
+ src_y = av_clip( src_y, -16, s->mb_height * 16);
+ uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
+ uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
+ }else{
+ src_x = av_clip( src_x, -17, s->avctx->coded_width);
+ src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
+ uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
+ uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
+ }
srcY += src_y * s->linesize + src_x;
srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
@@ -2123,11 +2212,6 @@ static void vc1_interp_mc(VC1Context *v)
srcY += s->mspel * (1 + s->linesize);
}
- if(v->fastuvmc) {
- uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1));
- uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1));
- }
-
mx >>= 1;
my >>= 1;
dxy = ((my & 1) << 1) | (mx & 1);
@@ -2143,7 +2227,7 @@ static void vc1_interp_mc(VC1Context *v)
dsp->avg_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
}
-static always_inline int scale_mv(int value, int bfrac, int inv, int qs)
+static av_always_inline int scale_mv(int value, int bfrac, int inv, int qs)
{
int n = bfrac;
@@ -2870,9 +2954,11 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.qscale_table[mb_pos];
- if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
- if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
- if(n && n<4) q2 = q1;
+ if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1];
+ if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
+ if(dc_pred_dir && n==1) q2 = q1;
+ if(!dc_pred_dir && n==2) q2 = q1;
+ if(n==3) q2 = q1;
if(coded) {
int last = 0, skip, value;
@@ -3075,9 +3161,11 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c
ac_val -= 16 * s->block_wrap[n];
q1 = s->current_picture.qscale_table[mb_pos];
- if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1];
- if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
- if(n && n<4) q2 = q1;
+ if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.qscale_table[mb_pos - 1];
+ if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
+ if(dc_pred_dir && n==1) q2 = q1;
+ if(!dc_pred_dir && n==2) q2 = q1;
+ if(n==3) q2 = q1;
if(coded) {
int last = 0, skip, value;
@@ -3394,6 +3482,7 @@ static int vc1_decode_p_mb(VC1Context *v)
s->dsp.vc1_inv_trans_8x8(s->block[i]);
if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
for(j = 0; j < 64; j++) s->block[i][j] += 128;
+ if(!v->res_fasttx && v->res_x8) for(j = 0; j < 64; j++) s->block[i][j] += 16;
s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
if(v->pq >= 9 && v->overlap) {
if(v->c_avail)
@@ -3497,6 +3586,7 @@ static int vc1_decode_p_mb(VC1Context *v)
s->dsp.vc1_inv_trans_8x8(s->block[i]);
if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
for(j = 0; j < 64; j++) s->block[i][j] += 128;
+ if(!v->res_fasttx && v->res_x8) for(j = 0; j < 64; j++) s->block[i][j] += 16;
s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
if(v->pq >= 9 && v->overlap) {
if(v->c_avail)
@@ -3761,6 +3851,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2);
s->dsp.vc1_inv_trans_8x8(s->block[k]);
+ if(!v->res_fasttx && !v->res_x8) for(j = 0; j < 64; j++) s->block[k][j] -= 16;
if(v->pq >= 9 && v->overlap) {
for(j = 0; j < 64; j++) s->block[k][j] += 128;
}
@@ -4063,14 +4154,53 @@ static void vc1_decode_blocks(VC1Context *v)
vc1_decode_p_blocks(v);
break;
case B_TYPE:
- if(v->bi_type)
- vc1_decode_i_blocks(v);
- else
+ if(v->bi_type){
+ if(v->profile == PROFILE_ADVANCED)
+ vc1_decode_i_blocks_adv(v);
+ else
+ vc1_decode_i_blocks(v);
+ }else
vc1_decode_b_blocks(v);
break;
}
}
+#define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
+
+/** Find VC-1 marker in buffer
+ * @return position where next marker starts or end of buffer if no marker found
+ */
+static av_always_inline uint8_t* find_next_marker(uint8_t *src, uint8_t *end)
+{
+ uint32_t mrk = 0xFFFFFFFF;
+
+ if(end-src < 4) return end;
+ while(src < end){
+ mrk = (mrk << 8) | *src++;
+ if(IS_MARKER(mrk))
+ return src-4;
+ }
+ return end;
+}
+
+static av_always_inline int vc1_unescape_buffer(uint8_t *src, int size, uint8_t *dst)
+{
+ int dsize = 0, i;
+
+ if(size < 4){
+ for(dsize = 0; dsize < size; dsize++) *dst++ = *src++;
+ return size;
+ }
+ for(i = 0; i < size; i++, src++) {
+ if(src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
+ dst[dsize++] = src[1];
+ src++;
+ i++;
+ } else
+ dst[dsize++] = *src;
+ }
+ return dsize;
+}
/** Initialize a VC1/WMV3 decoder
* @todo TODO: Handle VC-1 IDUs (Transport level?)
@@ -4122,44 +4252,47 @@ static int vc1_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
}
} else { // VC1/WVC1
- int edata_size = avctx->extradata_size;
- uint8_t *edata = avctx->extradata;
+ uint8_t *start = avctx->extradata, *end = avctx->extradata + avctx->extradata_size;
+ uint8_t *next; int size, buf2_size;
+ uint8_t *buf2 = NULL;
+ int seq_inited = 0, ep_inited = 0;
if(avctx->extradata_size < 16) {
- av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", edata_size);
+ av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size);
return -1;
}
- while(edata_size > 8) {
- // test if we've found header
- if(BE_32(edata) == 0x0000010F) {
- edata += 4;
- edata_size -= 4;
- break;
- }
- edata_size--;
- edata++;
- }
- init_get_bits(&gb, edata, edata_size*8);
-
- if (decode_sequence_header(avctx, &gb) < 0)
- return -1;
-
- while(edata_size > 8) {
- // test if we've found entry point
- if(BE_32(edata) == 0x0000010E) {
- edata += 4;
- edata_size -= 4;
+ buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if(start[0]) start++; // in WVC1 extradata first byte is its size
+ next = start;
+ for(; next < end; start = next){
+ next = find_next_marker(start + 4, end);
+ size = next - start - 4;
+ if(size <= 0) continue;
+ buf2_size = vc1_unescape_buffer(start + 4, size, buf2);
+ init_get_bits(&gb, buf2, buf2_size * 8);
+ switch(AV_RB32(start)){
+ case VC1_CODE_SEQHDR:
+ if(decode_sequence_header(avctx, &gb) < 0){
+ av_free(buf2);
+ return -1;
+ }
+ seq_inited = 1;
+ break;
+ case VC1_CODE_ENTRYPOINT:
+ if(decode_entry_point(avctx, &gb) < 0){
+ av_free(buf2);
+ return -1;
+ }
+ ep_inited = 1;
break;
}
- edata_size--;
- edata++;
}
-
- init_get_bits(&gb, edata, edata_size*8);
-
- if (decode_entry_point(avctx, &gb) < 0)
- return -1;
+ av_free(buf2);
+ if(!seq_inited || !ep_inited){
+ av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
+ return -1;
+ }
}
avctx->has_b_frames= !!(avctx->max_b_frames);
s->low_delay = !avctx->has_b_frames;
@@ -4223,17 +4356,49 @@ static int vc1_decode_frame(AVCodecContext *avctx,
s->current_picture_ptr= &s->picture[i];
}
- //for advanced profile we need to unescape buffer
+ //for advanced profile we may need to parse and unescape data
if (avctx->codec_id == CODEC_ID_VC1) {
- int i, buf_size2;
- buf2 = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- buf_size2 = 0;
- for(i = 0; i < buf_size; i++) {
- if(buf[i] == 3 && i >= 2 && !buf[i-1] && !buf[i-2] && i < buf_size-1 && buf[i+1] < 4) {
- buf2[buf_size2++] = buf[i+1];
- i++;
- } else
- buf2[buf_size2++] = buf[i];
+ int buf_size2 = 0;
+ buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ if(IS_MARKER(AV_RB32(buf))){ /* frame starts with marker and needs to be parsed */
+ uint8_t *dst = buf2, *start, *end, *next;
+ int size;
+
+ next = buf;
+ for(start = buf, end = buf + buf_size; next < end; start = next){
+ next = find_next_marker(start + 4, end);
+ size = next - start - 4;
+ if(size <= 0) continue;
+ switch(AV_RB32(start)){
+ case VC1_CODE_FRAME:
+ buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
+ break;
+ case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
+ buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
+ init_get_bits(&s->gb, buf2, buf_size2*8);
+ decode_entry_point(avctx, &s->gb);
+ break;
+ case VC1_CODE_SLICE:
+ av_log(avctx, AV_LOG_ERROR, "Sliced decoding is not implemented (yet)\n");
+ av_free(buf2);
+ return -1;
+ }
+ }
+ }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */
+ uint8_t *divider;
+
+ divider = find_next_marker(buf, buf + buf_size);
+ if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){
+ av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
+ return -1;
+ }
+
+ buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
+ // TODO
+ av_free(buf2);return -1;
+ }else{
+ buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
}
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
@@ -4368,3 +4533,94 @@ AVCodec wmv3_decoder = {
CODEC_CAP_DELAY,
NULL
};
+
+#ifdef CONFIG_VC1_PARSER
+/**
+ * finds the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or -1
+ */
+static int vc1_find_frame_end(ParseContext *pc, const uint8_t *buf,
+ int buf_size) {
+ int pic_found, i;
+ uint32_t state;
+
+ pic_found= pc->frame_start_found;
+ state= pc->state;
+
+ i=0;
+ if(!pic_found){
+ for(i=0; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(state == VC1_CODE_FRAME || state == VC1_CODE_FIELD){
+ i++;
+ pic_found=1;
+ break;
+ }
+ }
+ }
+
+ if(pic_found){
+ /* EOF considered as end of frame */
+ if (buf_size == 0)
+ return 0;
+ for(; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(IS_MARKER(state) && state != VC1_CODE_FIELD && state != VC1_CODE_SLICE){
+ pc->frame_start_found=0;
+ pc->state=-1;
+ return i-3;
+ }
+ }
+ }
+ pc->frame_start_found= pic_found;
+ pc->state= state;
+ return END_NOT_FOUND;
+}
+
+static int vc1_parse(AVCodecParserContext *s,
+ AVCodecContext *avctx,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+ ParseContext *pc = s->priv_data;
+ int next;
+
+ if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
+ next= buf_size;
+ }else{
+ next= vc1_find_frame_end(pc, buf, buf_size);
+
+ if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
+ }
+ *poutbuf = (uint8_t *)buf;
+ *poutbuf_size = buf_size;
+ return next;
+}
+
+int vc1_split(AVCodecContext *avctx,
+ const uint8_t *buf, int buf_size)
+{
+ int i;
+ uint32_t state= -1;
+
+ for(i=0; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(IS_MARKER(state) && state != VC1_CODE_SEQHDR && state != VC1_CODE_ENTRYPOINT)
+ return i-3;
+ }
+ return 0;
+}
+
+AVCodecParser vc1_parser = {
+ { CODEC_ID_VC1 },
+ sizeof(ParseContext1),
+ NULL,
+ vc1_parse,
+ ff_parse1_close,
+ vc1_split,
+};
+#endif /* CONFIG_VC1_PARSER */
diff --git a/contrib/ffmpeg/libavcodec/vc1data.h b/contrib/ffmpeg/libavcodec/vc1data.h
index 70e88b525..9b0a854bf 100644
--- a/contrib/ffmpeg/libavcodec/vc1data.h
+++ b/contrib/ffmpeg/libavcodec/vc1data.h
@@ -199,7 +199,7 @@ static const uint8_t vc1_4mv_block_pattern_codes[4][16] = {
{ 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2},
{ 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0},
{ 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0},
- { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 19}
+ { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10}
};
static const uint8_t vc1_4mv_block_pattern_bits[4][16] = {
{ 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
diff --git a/contrib/ffmpeg/libavcodec/vc1dsp.c b/contrib/ffmpeg/libavcodec/vc1dsp.c
index 9139ffb28..6102c0960 100644
--- a/contrib/ffmpeg/libavcodec/vc1dsp.c
+++ b/contrib/ffmpeg/libavcodec/vc1dsp.c
@@ -326,7 +326,7 @@ static void vc1_inv_trans_4x4_c(DCTELEM block[64], int n)
/** Filter used to interpolate fractional pel values
*/
-static always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
+static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
{
switch(mode){
case 0: //no shift
@@ -355,7 +355,7 @@ static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int mode,
tptr = tmp;
for(j = 0; j < 11; j++) {
for(i = 0; i < 8; i++)
- tptr[i] = clip_uint8(vc1_mspel_filter(src + i, 1, m, r));
+ tptr[i] = av_clip_uint8(vc1_mspel_filter(src + i, 1, m, r));
src += stride;
tptr += 8;
}
@@ -365,7 +365,7 @@ static void vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int mode,
tptr = tmp + 8;
for(j = 0; j < 8; j++) {
for(i = 0; i < 8; i++)
- dst[i] = clip_uint8(vc1_mspel_filter(tptr + i, 8, m, r));
+ dst[i] = av_clip_uint8(vc1_mspel_filter(tptr + i, 8, m, r));
dst += stride;
tptr += 8;
}
diff --git a/contrib/ffmpeg/libavcodec/vmdav.c b/contrib/ffmpeg/libavcodec/vmdav.c
index a9937144e..69e8a44d3 100644
--- a/contrib/ffmpeg/libavcodec/vmdav.c
+++ b/contrib/ffmpeg/libavcodec/vmdav.c
@@ -92,10 +92,10 @@ static void lz_unpack(unsigned char *src, unsigned char *dest, int dest_len)
s = src;
d = dest;
d_end = d + dest_len;
- dataleft = LE_32(s);
+ dataleft = AV_RL32(s);
s += 4;
memset(queue, 0x20, QUEUE_SIZE);
- if (LE_32(s) == 0x56781234) {
+ if (AV_RL32(s) == 0x56781234) {
s += 4;
qpos = 0x111;
speclen = 0xF + 3;
@@ -204,10 +204,10 @@ static void vmd_decode(VmdVideoContext *s)
int frame_width, frame_height;
int dp_size;
- frame_x = LE_16(&s->buf[6]);
- frame_y = LE_16(&s->buf[8]);
- frame_width = LE_16(&s->buf[10]) - frame_x + 1;
- frame_height = LE_16(&s->buf[12]) - frame_y + 1;
+ frame_x = AV_RL16(&s->buf[6]);
+ frame_y = AV_RL16(&s->buf[8]);
+ frame_width = AV_RL16(&s->buf[10]) - frame_x + 1;
+ frame_height = AV_RL16(&s->buf[12]) - frame_y + 1;
/* if only a certain region will be updated, copy the entire previous
* frame before the decode */
@@ -339,7 +339,7 @@ static int vmdvideo_decode_init(AVCodecContext *avctx)
}
vmd_header = (unsigned char *)avctx->extradata;
- s->unpack_buffer_size = LE_32(&vmd_header[800]);
+ s->unpack_buffer_size = AV_RL32(&vmd_header[800]);
s->unpack_buffer = av_malloc(s->unpack_buffer_size);
if (!s->unpack_buffer)
return -1;
@@ -462,7 +462,7 @@ static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data,
s->predictors[chan] -= vmdaudio_table[buf[i] & 0x7F];
else
s->predictors[chan] += vmdaudio_table[buf[i]];
- s->predictors[chan] = clip(s->predictors[chan], -32768, 32767);
+ s->predictors[chan] = av_clip(s->predictors[chan], -32768, 32767);
out[i] = s->predictors[chan];
chan ^= stereo;
}
diff --git a/contrib/ffmpeg/libavcodec/vmnc.c b/contrib/ffmpeg/libavcodec/vmnc.c
index 7b5f567e7..b430a7e66 100644
--- a/contrib/ffmpeg/libavcodec/vmnc.c
+++ b/contrib/ffmpeg/libavcodec/vmnc.c
@@ -72,14 +72,14 @@ typedef struct VmncContext {
} VmncContext;
/* read pixel value from stream */
-static always_inline int vmnc_get_pixel(uint8_t* buf, int bpp, int be) {
+static av_always_inline int vmnc_get_pixel(uint8_t* buf, int bpp, int be) {
switch(bpp * 2 + be) {
case 2:
case 3: return *buf;
- case 4: return LE_16(buf);
- case 5: return BE_16(buf);
- case 8: return LE_32(buf);
- case 9: return BE_32(buf);
+ case 4: return AV_RL16(buf);
+ case 5: return AV_RB16(buf);
+ case 8: return AV_RL32(buf);
+ case 9: return AV_RB32(buf);
default: return 0;
}
}
@@ -172,7 +172,7 @@ static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
}
/* fill rectangle with given colour */
-static always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
+static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
{
int i, j;
dst += dx * bpp + dy * stride;
@@ -202,7 +202,7 @@ static always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h,
}
}
-static always_inline void paint_raw(uint8_t *dst, int w, int h, uint8_t* src, int bpp, int be, int stride)
+static av_always_inline void paint_raw(uint8_t *dst, int w, int h, uint8_t* src, int bpp, int be, int stride)
{
int i, j, p;
for(j = 0; j < h; j++) {
@@ -328,13 +328,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
}
}
src += 2;
- chunks = BE_16(src); src += 2;
+ chunks = AV_RB16(src); src += 2;
while(chunks--) {
- dx = BE_16(src); src += 2;
- dy = BE_16(src); src += 2;
- w = BE_16(src); src += 2;
- h = BE_16(src); src += 2;
- enc = BE_32(src); src += 4;
+ dx = AV_RB16(src); src += 2;
+ dy = AV_RB16(src); src += 2;
+ w = AV_RB16(src); src += 2;
+ h = AV_RB16(src); src += 2;
+ enc = AV_RB32(src); src += 4;
outptr = c->pic.data[0] + dx * c->bpp2 + dy * c->pic.linesize[0];
size_left = buf_size - (src - buf);
switch(enc) {
@@ -463,7 +463,6 @@ static int decode_init(AVCodecContext *avctx)
VmncContext * const c = (VmncContext *)avctx->priv_data;
c->avctx = avctx;
- avctx->has_b_frames = 0;
c->pic.data[0] = NULL;
c->width = avctx->width;
diff --git a/contrib/ffmpeg/libavcodec/vorbis.c b/contrib/ffmpeg/libavcodec/vorbis.c
index ca8d0a956..7e5f0d349 100644
--- a/contrib/ffmpeg/libavcodec/vorbis.c
+++ b/contrib/ffmpeg/libavcodec/vorbis.c
@@ -33,6 +33,7 @@
#include "dsputil.h"
#include "vorbis.h"
+#include "xiph.h"
#define V_NB_BITS 8
#define V_NB_BITS2 11
@@ -1039,7 +1040,7 @@ static int vorbis_decode_init(AVCodecContext *avccontext) {
uint8_t *header_start[3];
int header_len[3];
GetBitContext *gb = &(vc->gb);
- int i, j, hdr_type;
+ int hdr_type;
vc->avccontext = avccontext;
dsputil_init(&vc->dsp, avccontext);
@@ -1057,32 +1058,7 @@ static int vorbis_decode_init(AVCodecContext *avccontext) {
return -1;
}
- if(headers[0] == 0 && headers[1] == 30) {
- for(i = 0; i < 3; i++){
- header_len[i] = *headers++ << 8;
- header_len[i] += *headers++;
- header_start[i] = headers;
- headers += header_len[i];
- }
- } else if(headers[0] == 2) {
- for(j=1,i=0;i<2;++i, ++j) {
- header_len[i]=0;
- while(j<headers_len && headers[j]==0xff) {
- header_len[i]+=0xff;
- ++j;
- }
- if (j>=headers_len) {
- av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n");
- return -1;
- }
- header_len[i]+=headers[j];
- }
- header_len[2]=headers_len-header_len[0]-header_len[1]-j;
- headers+=j;
- header_start[0] = headers;
- header_start[1] = header_start[0] + header_len[0];
- header_start[2] = header_start[1] + header_len[1];
- } else {
+ if (ff_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) {
av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n");
return -1;
}
diff --git a/contrib/ffmpeg/libavcodec/vorbis_enc.c b/contrib/ffmpeg/libavcodec/vorbis_enc.c
index 636b0cfae..3789ef7a2 100644
--- a/contrib/ffmpeg/libavcodec/vorbis_enc.c
+++ b/contrib/ffmpeg/libavcodec/vorbis_enc.c
@@ -906,7 +906,7 @@ static int apply_window_and_mdct(venc_context_t * venc, signed short * audio, in
float * offset = venc->samples + channel*window_len*2 + window_len;
j = channel;
for (i = 0; i < samples; i++, j += venc->channels)
- offset[i] = audio[j] / 32768. / n * win[window_len - i - 1];
+ offset[i] = -audio[j] / 32768. / n * win[window_len - i - 1]; //FIXME find out why the sign has to be fliped
}
} else {
for (channel = 0; channel < venc->channels; channel++) {
@@ -923,7 +923,7 @@ static int apply_window_and_mdct(venc_context_t * venc, signed short * audio, in
float * offset = venc->saved + channel*window_len;
j = channel;
for (i = 0; i < samples; i++, j += venc->channels)
- offset[i] = audio[j] / 32768. / n * win[i];
+ offset[i] = -audio[j] / 32768. / n * win[i]; //FIXME find out why the sign has to be fliped
}
venc->have_saved = 1;
} else {
diff --git a/contrib/ffmpeg/libavcodec/vp3.c b/contrib/ffmpeg/libavcodec/vp3.c
index 6a398693a..0d882da32 100644
--- a/contrib/ffmpeg/libavcodec/vp3.c
+++ b/contrib/ffmpeg/libavcodec/vp3.c
@@ -41,6 +41,7 @@
#include "mpegvideo.h"
#include "vp3data.h"
+#include "xiph.h"
#define FRAGMENT_PIXELS 8
@@ -633,7 +634,7 @@ static void init_dequantizer(Vp3DecodeContext *s)
int qmin= 8<<(inter + !i);
int qscale= i ? ac_scale_factor : dc_scale_factor;
- s->qmat[inter][plane][i]= clip((qscale * coeff)/100 * 4, qmin, 4096);
+ s->qmat[inter][plane][i]= av_clip((qscale * coeff)/100 * 4, qmin, 4096);
}
}
}
@@ -1729,8 +1730,8 @@ static void horizontal_filter(unsigned char *first_pixel, int stride,
(first_pixel[-2] - first_pixel[ 1])
+3*(first_pixel[ 0] - first_pixel[-1]);
filter_value = bounding_values[(filter_value + 4) >> 3];
- first_pixel[-1] = clip_uint8(first_pixel[-1] + filter_value);
- first_pixel[ 0] = clip_uint8(first_pixel[ 0] - filter_value);
+ first_pixel[-1] = av_clip_uint8(first_pixel[-1] + filter_value);
+ first_pixel[ 0] = av_clip_uint8(first_pixel[ 0] - filter_value);
}
}
@@ -1746,8 +1747,8 @@ static void vertical_filter(unsigned char *first_pixel, int stride,
(first_pixel[2 * nstride] - first_pixel[ stride])
+3*(first_pixel[0 ] - first_pixel[nstride]);
filter_value = bounding_values[(filter_value + 4) >> 3];
- first_pixel[nstride] = clip_uint8(first_pixel[nstride] + filter_value);
- first_pixel[0] = clip_uint8(first_pixel[0] - filter_value);
+ first_pixel[nstride] = av_clip_uint8(first_pixel[nstride] + filter_value);
+ first_pixel[0] = av_clip_uint8(first_pixel[0] - filter_value);
}
}
@@ -2574,8 +2575,9 @@ static int theora_decode_init(AVCodecContext *avctx)
Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb;
int ptype;
- uint8_t *p= avctx->extradata;
- int op_bytes, i;
+ uint8_t *header_start[3];
+ int header_len[3];
+ int i;
s->theora = 1;
@@ -2585,12 +2587,14 @@ static int theora_decode_init(AVCodecContext *avctx)
return -1;
}
- for(i=0;i<3;i++) {
- op_bytes = *(p++)<<8;
- op_bytes += *(p++);
+ if (ff_split_xiph_headers(avctx->extradata, avctx->extradata_size,
+ 42, header_start, header_len) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n");
+ return -1;
+ }
- init_get_bits(&gb, p, op_bytes);
- p += op_bytes;
+ for(i=0;i<3;i++) {
+ init_get_bits(&gb, header_start[i], header_len[i]);
ptype = get_bits(&gb, 8);
debug_vp3("Theora headerpacket type: %x\n", ptype);
@@ -2601,7 +2605,7 @@ static int theora_decode_init(AVCodecContext *avctx)
// return -1;
}
- // FIXME: check for this aswell
+ // FIXME: Check for this as well.
skip_bits(&gb, 6*8); /* "theora" */
switch(ptype)
@@ -2620,8 +2624,8 @@ static int theora_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80);
break;
}
- if(8*op_bytes != get_bits_count(&gb))
- av_log(avctx, AV_LOG_ERROR, "%d bits left in packet %X\n", 8*op_bytes - get_bits_count(&gb), ptype);
+ if(8*header_len[i] != get_bits_count(&gb))
+ av_log(avctx, AV_LOG_ERROR, "%d bits left in packet %X\n", 8*header_len[i] - get_bits_count(&gb), ptype);
if (s->theora < 0x030200)
break;
}
@@ -2643,7 +2647,6 @@ AVCodec vp3_decoder = {
NULL
};
-#ifndef CONFIG_LIBTHEORA
AVCodec theora_decoder = {
"theora",
CODEC_TYPE_VIDEO,
@@ -2656,4 +2659,3 @@ AVCodec theora_decoder = {
0,
NULL
};
-#endif
diff --git a/contrib/ffmpeg/libavcodec/vp3dsp.c b/contrib/ffmpeg/libavcodec/vp3dsp.c
index a48515a5e..bb9fed091 100644
--- a/contrib/ffmpeg/libavcodec/vp3dsp.c
+++ b/contrib/ffmpeg/libavcodec/vp3dsp.c
@@ -39,7 +39,7 @@
#define M(a,b) (((a) * (b))>>16)
-static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
+static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
{
int16_t *ip = input;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
diff --git a/contrib/ffmpeg/libavcodec/vp5.c b/contrib/ffmpeg/libavcodec/vp5.c
index ac953c7aa..8a8c217c0 100644
--- a/contrib/ffmpeg/libavcodec/vp5.c
+++ b/contrib/ffmpeg/libavcodec/vp5.c
@@ -41,10 +41,10 @@ static int vp5_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
int rows, cols;
vp56_init_range_decoder(&s->c, buf, buf_size);
- s->frames[VP56_FRAME_CURRENT].key_frame = !vp56_rac_get(c);
+ s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c);
vp56_rac_get(c);
vp56_init_dequant(s, vp56_rac_gets(c, 6));
- if (s->frames[VP56_FRAME_CURRENT].key_frame)
+ if (s->framep[VP56_FRAME_CURRENT]->key_frame)
{
vp56_rac_gets(c, 8);
if(vp56_rac_gets(c, 5) > 5)
@@ -145,7 +145,7 @@ static void vp5_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp5_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_dccv[pt][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_dccv[pt][node] = def_prob[node];
}
@@ -156,7 +156,7 @@ static void vp5_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp5_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
}
@@ -164,7 +164,7 @@ static void vp5_parse_coeff_models(vp56_context_t *s)
for (pt=0; pt<2; pt++)
for (ctx=0; ctx<36; ctx++)
for (node=0; node<5; node++)
- s->coeff_model_dcct[pt][ctx][node] = clip(((s->coeff_model_dccv[pt][node] * vp5_dccv_lc[node][ctx][0] + 128) >> 8) + vp5_dccv_lc[node][ctx][1], 1, 254);
+ s->coeff_model_dcct[pt][ctx][node] = av_clip(((s->coeff_model_dccv[pt][node] * vp5_dccv_lc[node][ctx][0] + 128) >> 8) + vp5_dccv_lc[node][ctx][1], 1, 254);
/* coeff_model_acct is a linear combination of coeff_model_ract */
for (ct=0; ct<3; ct++)
@@ -172,7 +172,7 @@ static void vp5_parse_coeff_models(vp56_context_t *s)
for (cg=0; cg<3; cg++)
for (ctx=0; ctx<6; ctx++)
for (node=0; node<5; node++)
- s->coeff_model_acct[pt][ct][cg][ctx][node] = clip(((s->coeff_model_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254);
+ s->coeff_model_acct[pt][ct][cg][ctx][node] = av_clip(((s->coeff_model_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254);
}
static void vp5_parse_coeff(vp56_context_t *s)
diff --git a/contrib/ffmpeg/libavcodec/vp56.c b/contrib/ffmpeg/libavcodec/vp56.c
index eb78d02e4..abd1b3a63 100644
--- a/contrib/ffmpeg/libavcodec/vp56.c
+++ b/contrib/ffmpeg/libavcodec/vp56.c
@@ -308,8 +308,8 @@ static void vp56_edge_filter(vp56_context_t *s, uint8_t *yuv,
for (i=0; i<12; i++) {
v = (yuv[-pix2_inc] + 3*(yuv[0]-yuv[-pix_inc]) - yuv[pix_inc] + 4) >>3;
v = s->adjust(v, t);
- yuv[-pix_inc] = clip_uint8(yuv[-pix_inc] + v);
- yuv[0] = clip_uint8(yuv[0] - v);
+ yuv[-pix_inc] = av_clip_uint8(yuv[-pix_inc] + v);
+ yuv[0] = av_clip_uint8(yuv[0] - v);
yuv += line_inc;
}
}
@@ -326,7 +326,7 @@ static void vp56_mc(vp56_context_t *s, int b, uint8_t *src,
int stride, int x, int y)
{
int plane = vp56_b6to3[b];
- uint8_t *dst= s->frames[VP56_FRAME_CURRENT].data[plane]+s->block_offset[b];
+ uint8_t *dst=s->framep[VP56_FRAME_CURRENT]->data[plane]+s->block_offset[b];
uint8_t *src_block;
int src_offset;
int overlap_offset = 0;
@@ -337,7 +337,7 @@ static void vp56_mc(vp56_context_t *s, int b, uint8_t *src,
if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY
- && !s->frames[VP56_FRAME_CURRENT].key_frame))
+ && !s->framep[VP56_FRAME_CURRENT]->key_frame))
deblock_filtering = 0;
dx = s->mv[b].x / s->vp56_coord_div[b];
@@ -400,7 +400,7 @@ static void vp56_decode_mb(vp56_context_t *s, int row, int col)
vp56_frame_t ref_frame;
int b, plan, off;
- if (s->frames[VP56_FRAME_CURRENT].key_frame)
+ if (s->framep[VP56_FRAME_CURRENT]->key_frame)
mb_type = VP56_MB_INTRA;
else
mb_type = vp56_decode_mv(s, row, col);
@@ -412,8 +412,8 @@ static void vp56_decode_mb(vp56_context_t *s, int row, int col)
vp56_add_predictors_dc(s, ref_frame);
- frame_current = &s->frames[VP56_FRAME_CURRENT];
- frame_ref = &s->frames[ref_frame];
+ frame_current = s->framep[VP56_FRAME_CURRENT];
+ frame_ref = s->framep[ref_frame];
switch (mb_type) {
case VP56_MB_INTRA:
@@ -459,7 +459,7 @@ static void vp56_decode_mb(vp56_context_t *s, int row, int col)
static int vp56_size_changed(AVCodecContext *avctx, vp56_context_t *s)
{
- int stride = s->frames[VP56_FRAME_CURRENT].linesize[0];
+ int stride = s->framep[VP56_FRAME_CURRENT]->linesize[0];
int i;
s->plane_width[0] = s->avctx->coded_width;
@@ -468,7 +468,7 @@ static int vp56_size_changed(AVCodecContext *avctx, vp56_context_t *s)
s->plane_height[1] = s->plane_height[2] = s->avctx->coded_height/2;
for (i=0; i<3; i++)
- s->stride[i] = s->flip * s->frames[VP56_FRAME_CURRENT].linesize[i];
+ s->stride[i] = s->flip * s->framep[VP56_FRAME_CURRENT]->linesize[i];
s->mb_width = (s->avctx->coded_width+15) / 16;
s->mb_height = (s->avctx->coded_height+15) / 16;
@@ -495,8 +495,7 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
uint8_t *buf, int buf_size)
{
vp56_context_t *s = avctx->priv_data;
- AVFrame *const p = &s->frames[VP56_FRAME_CURRENT];
- AVFrame *picture = data;
+ AVFrame *const p = s->framep[VP56_FRAME_CURRENT];
int mb_row, mb_col, mb_row_flip, mb_offset = 0;
int block, y, uv, stride_y, stride_uv;
int golden_frame = 0;
@@ -594,20 +593,21 @@ int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
- if (s->frames[VP56_FRAME_PREVIOUS].data[0]
- && (s->frames[VP56_FRAME_PREVIOUS].data[0]
- != s->frames[VP56_FRAME_GOLDEN].data[0])) {
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_PREVIOUS]);
- }
+ if (s->framep[VP56_FRAME_PREVIOUS] == s->framep[VP56_FRAME_GOLDEN])
+ FFSWAP(AVFrame *, s->framep[VP56_FRAME_PREVIOUS],
+ s->framep[VP56_FRAME_UNUSED]);
+ else if (s->framep[VP56_FRAME_PREVIOUS]->data[0])
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);
if (p->key_frame || golden_frame) {
- if (s->frames[VP56_FRAME_GOLDEN].data[0])
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_GOLDEN]);
- s->frames[VP56_FRAME_GOLDEN] = *p;
+ if (s->framep[VP56_FRAME_GOLDEN]->data[0])
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]);
+ s->framep[VP56_FRAME_GOLDEN] = p;
}
- s->frames[VP56_FRAME_PREVIOUS] = *p;
+ FFSWAP(AVFrame *, s->framep[VP56_FRAME_CURRENT],
+ s->framep[VP56_FRAME_PREVIOUS]);
- *picture = *p;
- *data_size = sizeof(AVPicture);
+ *(AVFrame*)data = *p;
+ *data_size = sizeof(AVFrame);
return buf_size;
}
@@ -627,7 +627,8 @@ void vp56_init(vp56_context_t *s, AVCodecContext *avctx, int flip)
avcodec_set_dimensions(s->avctx, 0, 0);
for (i=0; i<3; i++)
- s->frames[i].data[0] = NULL;
+ s->framep[i] = &s->frames[i];
+ s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN];
s->edge_emu_buffer_alloc = NULL;
s->above_blocks = NULL;
@@ -655,11 +656,10 @@ int vp56_free(AVCodecContext *avctx)
av_free(s->above_blocks);
av_free(s->macroblocks);
av_free(s->edge_emu_buffer_alloc);
- if (s->frames[VP56_FRAME_GOLDEN].data[0]
- && (s->frames[VP56_FRAME_PREVIOUS].data[0]
- != s->frames[VP56_FRAME_GOLDEN].data[0]))
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_GOLDEN]);
- if (s->frames[VP56_FRAME_PREVIOUS].data[0])
- avctx->release_buffer(avctx, &s->frames[VP56_FRAME_PREVIOUS]);
+ if (s->framep[VP56_FRAME_GOLDEN]->data[0]
+ && (s->framep[VP56_FRAME_PREVIOUS] != s->framep[VP56_FRAME_GOLDEN]))
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_GOLDEN]);
+ if (s->framep[VP56_FRAME_PREVIOUS]->data[0])
+ avctx->release_buffer(avctx, s->framep[VP56_FRAME_PREVIOUS]);
return 0;
}
diff --git a/contrib/ffmpeg/libavcodec/vp56.h b/contrib/ffmpeg/libavcodec/vp56.h
index d6808b1e5..fb8bbba6f 100644
--- a/contrib/ffmpeg/libavcodec/vp56.h
+++ b/contrib/ffmpeg/libavcodec/vp56.h
@@ -73,9 +73,13 @@ struct vp56_context {
DSPContext dsp;
ScanTable scantable;
AVFrame frames[3];
+ AVFrame *framep[4];
uint8_t *edge_emu_buffer_alloc;
uint8_t *edge_emu_buffer;
vp56_range_coder_t c;
+ vp56_range_coder_t cc;
+ vp56_range_coder_t *ccp;
+ int sub_version;
/* frame info */
int plane_width[3];
@@ -107,6 +111,7 @@ struct vp56_context {
int vector_candidate_pos;
/* filtering hints */
+ int filter_header; /* used in vp6 only */
int deblock_filtering;
int filter_selection;
int filter_mode;
diff --git a/contrib/ffmpeg/libavcodec/vp56data.h b/contrib/ffmpeg/libavcodec/vp56data.h
index dbf92dd68..d784b9803 100644
--- a/contrib/ffmpeg/libavcodec/vp56data.h
+++ b/contrib/ffmpeg/libavcodec/vp56data.h
@@ -30,6 +30,7 @@ typedef enum {
VP56_FRAME_CURRENT = 0,
VP56_FRAME_PREVIOUS = 1,
VP56_FRAME_GOLDEN = 2,
+ VP56_FRAME_UNUSED = 3,
} vp56_frame_t;
typedef enum {
diff --git a/contrib/ffmpeg/libavcodec/vp6.c b/contrib/ffmpeg/libavcodec/vp6.c
index b7ff004cc..2e904b7e0 100644
--- a/contrib/ffmpeg/libavcodec/vp6.c
+++ b/contrib/ffmpeg/libavcodec/vp6.c
@@ -42,23 +42,31 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
int *golden_frame)
{
vp56_range_coder_t *c = &s->c;
- int parse_filter_info;
+ int parse_filter_info = 0;
+ int coeff_offset = 0;
+ int vrt_shift = 0;
+ int sub_version;
int rows, cols;
int res = 1;
+ int separated_coeff = buf[0] & 1;
- if (buf[0] & 1)
- return 0;
-
- s->frames[VP56_FRAME_CURRENT].key_frame = !(buf[0] & 0x80);
+ s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80);
vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
- if (s->frames[VP56_FRAME_CURRENT].key_frame) {
- if ((buf[1] & 0xFE) != 0x46) /* would be 0x36 for VP61 */
+ if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
+ sub_version = buf[1] >> 3;
+ if (sub_version > 8)
return 0;
+ s->filter_header = buf[1] & 0x06;
if (buf[1] & 1) {
av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n");
return 0;
}
+ if (separated_coeff || !s->filter_header) {
+ coeff_offset = AV_RB16(buf+2) - 2;
+ buf += 2;
+ buf_size -= 2;
+ }
rows = buf[2]; /* number of stored macroblock rows */
cols = buf[3]; /* number of stored macroblock cols */
@@ -78,31 +86,57 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
vp56_init_range_decoder(c, buf+6, buf_size-6);
vp56_rac_gets(c, 2);
- parse_filter_info = 1;
+ parse_filter_info = s->filter_header;
+ if (sub_version < 8)
+ vrt_shift = 5;
+ s->sub_version = sub_version;
} else {
+ if (!s->sub_version)
+ return 0;
+
+ if (separated_coeff || !s->filter_header) {
+ coeff_offset = AV_RB16(buf+1) - 2;
+ buf += 2;
+ buf_size -= 2;
+ }
vp56_init_range_decoder(c, buf+1, buf_size-1);
*golden_frame = vp56_rac_get(c);
- s->deblock_filtering = vp56_rac_get(c);
- if (s->deblock_filtering)
- vp56_rac_get(c);
- parse_filter_info = vp56_rac_get(c);
+ if (s->filter_header) {
+ s->deblock_filtering = vp56_rac_get(c);
+ if (s->deblock_filtering)
+ vp56_rac_get(c);
+ if (s->sub_version > 7)
+ parse_filter_info = vp56_rac_get(c);
+ }
}
if (parse_filter_info) {
if (vp56_rac_get(c)) {
s->filter_mode = 2;
- s->sample_variance_threshold = vp56_rac_gets(c, 5);
+ s->sample_variance_threshold = vp56_rac_gets(c, 5) << vrt_shift;
s->max_vector_length = 2 << vp56_rac_gets(c, 3);
} else if (vp56_rac_get(c)) {
s->filter_mode = 1;
} else {
s->filter_mode = 0;
}
- s->filter_selection = vp56_rac_gets(c, 4);
+ if (s->sub_version > 7)
+ s->filter_selection = vp56_rac_gets(c, 4);
+ else
+ s->filter_selection = 16;
}
vp56_rac_get(c);
+
+ if (coeff_offset) {
+ vp56_init_range_decoder(&s->cc, buf+coeff_offset,
+ buf_size-coeff_offset);
+ s->ccp = &s->cc;
+ } else {
+ s->ccp = &s->c;
+ }
+
return res;
}
@@ -171,7 +205,7 @@ static void vp6_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp6_dccv_pct[pt][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_dccv[pt][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_dccv[pt][node] = def_prob[node];
}
@@ -194,7 +228,7 @@ static void vp6_parse_coeff_models(vp56_context_t *s)
if (vp56_rac_get_prob(c, vp6_ract_pct[ct][pt][cg][node])) {
def_prob[node] = vp56_rac_gets_nn(c, 7);
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
- } else if (s->frames[VP56_FRAME_CURRENT].key_frame) {
+ } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
s->coeff_model_ract[pt][ct][cg][node] = def_prob[node];
}
@@ -202,7 +236,7 @@ static void vp6_parse_coeff_models(vp56_context_t *s)
for (pt=0; pt<2; pt++)
for (ctx=0; ctx<3; ctx++)
for (node=0; node<5; node++)
- s->coeff_model_dcct[pt][ctx][node] = clip(((s->coeff_model_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255);
+ s->coeff_model_dcct[pt][ctx][node] = av_clip(((s->coeff_model_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255);
}
static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect)
@@ -244,7 +278,7 @@ static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect)
static void vp6_parse_coeff(vp56_context_t *s)
{
- vp56_range_coder_t *c = &s->c;
+ vp56_range_coder_t *c = s->ccp;
uint8_t *permute = s->scantable.permutated;
uint8_t *model, *model2, *model3;
int coeff, sign, coeff_idx;
@@ -343,7 +377,7 @@ static int vp6_block_variance(uint8_t *src, int stride)
}
src += 2*stride;
}
- return (16*square_sum - sum*sum) / (16*16);
+ return (16*square_sum - sum*sum) >> 8;
}
static void vp6_filter_hv2(vp56_context_t *s, uint8_t *dst, uint8_t *src,
@@ -361,7 +395,7 @@ static void vp6_filter_hv4(uint8_t *dst, uint8_t *src, int stride,
for (y=0; y<8; y++) {
for (x=0; x<8; x++) {
- dst[x] = clip_uint8(( src[x-delta ] * weights[0]
+ dst[x] = av_clip_uint8(( src[x-delta ] * weights[0]
+ src[x ] * weights[1]
+ src[x+delta ] * weights[2]
+ src[x+2*delta] * weights[3] + 64) >> 7);
@@ -400,7 +434,7 @@ static void vp6_filter_diag4(uint8_t *dst, uint8_t *src, int stride,
for (y=0; y<11; y++) {
for (x=0; x<8; x++) {
- t[x] = clip_uint8(( src[x-1] * h_weights[0]
+ t[x] = av_clip_uint8(( src[x-1] * h_weights[0]
+ src[x ] * h_weights[1]
+ src[x+1] * h_weights[2]
+ src[x+2] * h_weights[3] + 64) >> 7);
@@ -412,7 +446,7 @@ static void vp6_filter_diag4(uint8_t *dst, uint8_t *src, int stride,
t = tmp + 8;
for (y=0; y<8; y++) {
for (x=0; x<8; x++) {
- dst[x] = clip_uint8(( t[x-8 ] * v_weights[0]
+ dst[x] = av_clip_uint8(( t[x-8 ] * v_weights[0]
+ t[x ] * v_weights[1]
+ t[x+8 ] * v_weights[2]
+ t[x+16] * v_weights[3] + 64) >> 7);
@@ -439,8 +473,8 @@ static void vp6_filter(vp56_context_t *s, uint8_t *dst, uint8_t *src,
(FFABS(mv.x) > s->max_vector_length ||
FFABS(mv.y) > s->max_vector_length)) {
filter4 = 0;
- } else if (!s->sample_variance_threshold
- || (vp6_block_variance(src+offset1, stride)
+ } else if (s->sample_variance_threshold
+ && (vp6_block_variance(src+offset1, stride)
< s->sample_variance_threshold)) {
filter4 = 0;
}
diff --git a/contrib/ffmpeg/libavcodec/vp6data.h b/contrib/ffmpeg/libavcodec/vp6data.h
index ba4c7abf7..0545a9d66 100644
--- a/contrib/ffmpeg/libavcodec/vp6data.h
+++ b/contrib/ffmpeg/libavcodec/vp6data.h
@@ -144,7 +144,7 @@ static const uint8_t vp6_coeff_groups[] = {
5, 5, 5, 5, 5, 5, 5, 5,
};
-static const int16_t vp6_block_copy_filter[16][8][4] = {
+static const int16_t vp6_block_copy_filter[17][8][4] = {
{ { 0, 128, 0, 0 }, /* 0 */
{ -3, 122, 9, 0 },
{ -4, 109, 24, -1 },
@@ -273,6 +273,14 @@ static const int16_t vp6_block_copy_filter[16][8][4] = {
{ -11, 59, 99, -19 },
{ -6, 38, 114, -18 },
{ -2, 18, 124, -12 } },
+ { { 0, 128, 0, 0 }, /* 16 */
+ { -4, 118, 16, -2 },
+ { -7, 106, 34, -5 },
+ { -8, 90, 53, -7 },
+ { -8, 72, 72, -8 },
+ { -7, 53, 90, -8 },
+ { -5, 34, 106, -7 },
+ { -2, 16, 118, -4 } },
};
static const vp56_tree_t vp6_pcr_tree[] = {
diff --git a/contrib/ffmpeg/libavcodec/vqavideo.c b/contrib/ffmpeg/libavcodec/vqavideo.c
index 912ced0df..57fe6cf44 100644
--- a/contrib/ffmpeg/libavcodec/vqavideo.c
+++ b/contrib/ffmpeg/libavcodec/vqavideo.c
@@ -151,8 +151,8 @@ static int vqa_decode_init(AVCodecContext *avctx)
/* load up the VQA parameters from the header */
vqa_header = (unsigned char *)s->avctx->extradata;
s->vqa_version = vqa_header[0];
- s->width = LE_16(&vqa_header[6]);
- s->height = LE_16(&vqa_header[8]);
+ s->width = AV_RL16(&vqa_header[6]);
+ s->height = AV_RL16(&vqa_header[8]);
if(avcodec_check_dimensions(avctx, s->width, s->height)){
s->width= s->height= 0;
return -1;
@@ -232,9 +232,9 @@ static void decode_format80(unsigned char *src, int src_size,
if (src[src_index] == 0xFF) {
src_index++;
- count = LE_16(&src[src_index]);
+ count = AV_RL16(&src[src_index]);
src_index += 2;
- src_pos = LE_16(&src[src_index]);
+ src_pos = AV_RL16(&src[src_index]);
src_index += 2;
vqa_debug("(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
@@ -245,7 +245,7 @@ static void decode_format80(unsigned char *src, int src_size,
} else if (src[src_index] == 0xFE) {
src_index++;
- count = LE_16(&src[src_index]);
+ count = AV_RL16(&src[src_index]);
src_index += 2;
color = src[src_index++];
vqa_debug("(2) set %X bytes to %02X\n", count, color);
@@ -256,7 +256,7 @@ static void decode_format80(unsigned char *src, int src_size,
} else if ((src[src_index] & 0xC0) == 0xC0) {
count = (src[src_index++] & 0x3F) + 3;
- src_pos = LE_16(&src[src_index]);
+ src_pos = AV_RL16(&src[src_index]);
src_index += 2;
vqa_debug("(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
@@ -276,7 +276,7 @@ static void decode_format80(unsigned char *src, int src_size,
} else {
count = ((src[src_index] & 0x70) >> 4) + 3;
- src_pos = BE_16(&src[src_index]) & 0x0FFF;
+ src_pos = AV_RB16(&src[src_index]) & 0x0FFF;
src_index += 2;
vqa_debug("(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
@@ -326,8 +326,8 @@ static void vqa_decode_chunk(VqaContext *s)
/* first, traverse through the frame and find the subchunks */
while (index < s->size) {
- chunk_type = BE_32(&s->buf[index]);
- chunk_size = BE_32(&s->buf[index + 4]);
+ chunk_type = AV_RB32(&s->buf[index]);
+ chunk_size = AV_RB32(&s->buf[index + 4]);
switch (chunk_type) {
@@ -391,7 +391,7 @@ static void vqa_decode_chunk(VqaContext *s)
/* convert the RGB palette into the machine's endian format */
if (cpl0_chunk != -1) {
- chunk_size = BE_32(&s->buf[cpl0_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cpl0_chunk + 4]);
/* sanity check the palette size */
if (chunk_size / 3 > 256) {
av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: found a palette chunk with %d colors\n",
@@ -419,7 +419,7 @@ static void vqa_decode_chunk(VqaContext *s)
/* decompress the full codebook chunk */
if (cbfz_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbfz_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbfz_chunk + 4]);
cbfz_chunk += CHUNK_PREAMBLE_SIZE;
decode_format80(&s->buf[cbfz_chunk], chunk_size,
s->codebook, s->codebook_size, 0);
@@ -428,7 +428,7 @@ static void vqa_decode_chunk(VqaContext *s)
/* copy a full codebook */
if (cbf0_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbf0_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbf0_chunk + 4]);
/* sanity check the full codebook size */
if (chunk_size > MAX_CODEBOOK_SIZE) {
av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: CBF0 chunk too large (0x%X bytes)\n",
@@ -448,7 +448,7 @@ static void vqa_decode_chunk(VqaContext *s)
return;
}
- chunk_size = BE_32(&s->buf[vptz_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[vptz_chunk + 4]);
vptz_chunk += CHUNK_PREAMBLE_SIZE;
decode_format80(&s->buf[vptz_chunk], chunk_size,
s->decode_buffer, s->decode_buffer_size, 1);
@@ -522,7 +522,7 @@ static void vqa_decode_chunk(VqaContext *s)
if (cbp0_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbp0_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
cbp0_chunk += CHUNK_PREAMBLE_SIZE;
/* accumulate partial codebook */
@@ -545,7 +545,7 @@ static void vqa_decode_chunk(VqaContext *s)
if (cbpz_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbpz_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
cbpz_chunk += CHUNK_PREAMBLE_SIZE;
/* accumulate partial codebook */
diff --git a/contrib/ffmpeg/libavcodec/wavpack.c b/contrib/ffmpeg/libavcodec/wavpack.c
index 5a54f7d0e..e79d4a570 100644
--- a/contrib/ffmpeg/libavcodec/wavpack.c
+++ b/contrib/ffmpeg/libavcodec/wavpack.c
@@ -98,7 +98,7 @@ static const uint8_t wp_exp2_table [256] = {
0xea, 0xec, 0xed, 0xee, 0xf0, 0xf1, 0xf2, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfc, 0xfd, 0xff
};
-static always_inline int wp_exp2(int16_t val)
+static av_always_inline int wp_exp2(int16_t val)
{
int res, neg = 0;
@@ -137,12 +137,12 @@ static inline int get_unary(GetBitContext *gb){
}
-static always_inline int get_tail(GetBitContext *gb, int k)
+static av_always_inline int get_tail(GetBitContext *gb, int k)
{
int p, e, res;
- if(k<1 || k>65535)return 0;
- p = av_log2_16bit(k);
+ if(k<1)return 0;
+ p = av_log2(k);
e = (1 << (p + 1)) - k - 1;
res = p ? get_bits(gb, p) : 0;
if(res >= e){
@@ -383,19 +383,25 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
uint8_t* buf_end = buf + buf_size;
int i, j, id, size, ssize, weights, t;
- if (buf_size == 0) return 0;
+ if (buf_size == 0){
+ *data_size = 0;
+ return 0;
+ }
memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
- s->samples = LE_32(buf); buf += 4;
- if(!s->samples) return buf_size;
+ s->samples = AV_RL32(buf); buf += 4;
+ if(!s->samples){
+ *data_size = 0;
+ return buf_size;
+ }
/* should not happen but who knows */
- if(s->samples * 2 * avctx->channels > AVCODEC_MAX_AUDIO_FRAME_SIZE){
+ if(s->samples * 2 * avctx->channels > *data_size){
av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
return -1;
}
- s->joint = LE_32(buf) & WV_JOINT; buf += 4;
- s->CRC = LE_32(buf); buf += 4;
+ s->joint = AV_RL32(buf) & WV_JOINT; buf += 4;
+ s->CRC = AV_RL32(buf); buf += 4;
// parse metadata blocks
while(buf < buf_end){
id = *buf++;
@@ -467,23 +473,23 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
t = 0;
for(i = s->terms - 1; (i >= 0) && (t < size); i--) {
if(s->decorr[i].value > 8){
- s->decorr[i].samplesA[0] = wp_exp2(LE_16(buf)); buf += 2;
- s->decorr[i].samplesA[1] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
+ s->decorr[i].samplesA[1] = wp_exp2(AV_RL16(buf)); buf += 2;
if(s->stereo){
- s->decorr[i].samplesB[0] = wp_exp2(LE_16(buf)); buf += 2;
- s->decorr[i].samplesB[1] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
+ s->decorr[i].samplesB[1] = wp_exp2(AV_RL16(buf)); buf += 2;
t += 4;
}
t += 4;
}else if(s->decorr[i].value < 0){
- s->decorr[i].samplesA[0] = wp_exp2(LE_16(buf)); buf += 2;
- s->decorr[i].samplesB[0] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
+ s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
t += 4;
}else{
for(j = 0; j < s->decorr[i].value; j++){
- s->decorr[i].samplesA[j] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesA[j] = wp_exp2(AV_RL16(buf)); buf += 2;
if(s->stereo){
- s->decorr[i].samplesB[j] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesB[j] = wp_exp2(AV_RL16(buf)); buf += 2;
}
}
t += s->decorr[i].value * 2 * avctx->channels;
@@ -498,7 +504,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
continue;
}
for(i = 0; i < 3 * avctx->channels; i++){
- s->median[i] = wp_exp2(LE_16(buf));
+ s->median[i] = wp_exp2(AV_RL16(buf));
buf += 2;
}
got_entropy = 1;
diff --git a/contrib/ffmpeg/libavcodec/wma.c b/contrib/ffmpeg/libavcodec/wma.c
new file mode 100644
index 000000000..2241a07a0
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/wma.c
@@ -0,0 +1,386 @@
+/*
+ * WMA compatible codec
+ * Copyright (c) 2002-2007 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
+ */
+
+#include "avcodec.h"
+#include "wma.h"
+#include "wmadata.h"
+
+#undef NDEBUG
+#include <assert.h>
+
+/* XXX: use same run/length optimization as mpeg decoders */
+//FIXME maybe split decode / encode or pass flag
+static void init_coef_vlc(VLC *vlc,
+ uint16_t **prun_table, uint16_t **plevel_table, uint16_t **pint_table,
+ const CoefVLCTable *vlc_table)
+{
+ int n = vlc_table->n;
+ const uint8_t *table_bits = vlc_table->huffbits;
+ const uint32_t *table_codes = vlc_table->huffcodes;
+ const uint16_t *levels_table = vlc_table->levels;
+ uint16_t *run_table, *level_table, *int_table;
+ int i, l, j, k, level;
+
+ init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, 0);
+
+ run_table = av_malloc(n * sizeof(uint16_t));
+ level_table = av_malloc(n * sizeof(uint16_t));
+ int_table = av_malloc(n * sizeof(uint16_t));
+ i = 2;
+ level = 1;
+ k = 0;
+ while (i < n) {
+ int_table[k]= i;
+ l = levels_table[k++];
+ for(j=0;j<l;j++) {
+ run_table[i] = j;
+ level_table[i] = level;
+ i++;
+ }
+ level++;
+ }
+ *prun_table = run_table;
+ *plevel_table = level_table;
+ *pint_table= int_table;
+}
+
+int ff_wma_init(AVCodecContext * avctx, int flags2)
+{
+ WMACodecContext *s = avctx->priv_data;
+ int i;
+ float *window;
+ float bps1, high_freq;
+ volatile float bps;
+ int sample_rate1;
+ int coef_vlc_table;
+
+ s->sample_rate = avctx->sample_rate;
+ s->nb_channels = avctx->channels;
+ s->bit_rate = avctx->bit_rate;
+ s->block_align = avctx->block_align;
+
+ dsputil_init(&s->dsp, avctx);
+
+ if (avctx->codec->id == CODEC_ID_WMAV1) {
+ s->version = 1;
+ } else {
+ s->version = 2;
+ }
+
+ /* compute MDCT block size */
+ if (s->sample_rate <= 16000) {
+ s->frame_len_bits = 9;
+ } else if (s->sample_rate <= 22050 ||
+ (s->sample_rate <= 32000 && s->version == 1)) {
+ s->frame_len_bits = 10;
+ } else {
+ s->frame_len_bits = 11;
+ }
+ s->frame_len = 1 << s->frame_len_bits;
+ if (s->use_variable_block_len) {
+ int nb_max, nb;
+ nb = ((flags2 >> 3) & 3) + 1;
+ if ((s->bit_rate / s->nb_channels) >= 32000)
+ nb += 2;
+ nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
+ if (nb > nb_max)
+ nb = nb_max;
+ s->nb_block_sizes = nb + 1;
+ } else {
+ s->nb_block_sizes = 1;
+ }
+
+ /* init rate dependent parameters */
+ s->use_noise_coding = 1;
+ high_freq = s->sample_rate * 0.5;
+
+ /* if version 2, then the rates are normalized */
+ sample_rate1 = s->sample_rate;
+ if (s->version == 2) {
+ if (sample_rate1 >= 44100)
+ sample_rate1 = 44100;
+ else if (sample_rate1 >= 22050)
+ sample_rate1 = 22050;
+ else if (sample_rate1 >= 16000)
+ sample_rate1 = 16000;
+ else if (sample_rate1 >= 11025)
+ sample_rate1 = 11025;
+ else if (sample_rate1 >= 8000)
+ sample_rate1 = 8000;
+ }
+
+ bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
+ s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2;
+
+ /* compute high frequency value and choose if noise coding should
+ be activated */
+ bps1 = bps;
+ if (s->nb_channels == 2)
+ bps1 = bps * 1.6;
+ if (sample_rate1 == 44100) {
+ if (bps1 >= 0.61)
+ s->use_noise_coding = 0;
+ else
+ high_freq = high_freq * 0.4;
+ } else if (sample_rate1 == 22050) {
+ if (bps1 >= 1.16)
+ s->use_noise_coding = 0;
+ else if (bps1 >= 0.72)
+ high_freq = high_freq * 0.7;
+ else
+ high_freq = high_freq * 0.6;
+ } else if (sample_rate1 == 16000) {
+ if (bps > 0.5)
+ high_freq = high_freq * 0.5;
+ else
+ high_freq = high_freq * 0.3;
+ } else if (sample_rate1 == 11025) {
+ high_freq = high_freq * 0.7;
+ } else if (sample_rate1 == 8000) {
+ if (bps <= 0.625) {
+ high_freq = high_freq * 0.5;
+ } else if (bps > 0.75) {
+ s->use_noise_coding = 0;
+ } else {
+ high_freq = high_freq * 0.65;
+ }
+ } else {
+ if (bps >= 0.8) {
+ high_freq = high_freq * 0.75;
+ } else if (bps >= 0.6) {
+ high_freq = high_freq * 0.6;
+ } else {
+ 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",
+ 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",
+ bps, bps1, high_freq, s->byte_offset_bits);
+ dprintf(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 */
+ {
+ int a, b, pos, lpos, k, block_len, i, j, n;
+ const uint8_t *table;
+
+ if (s->version == 1) {
+ s->coefs_start = 3;
+ } else {
+ s->coefs_start = 0;
+ }
+ for(k = 0; k < s->nb_block_sizes; k++) {
+ block_len = s->frame_len >> k;
+
+ if (s->version == 1) {
+ lpos = 0;
+ for(i=0;i<25;i++) {
+ a = wma_critical_freqs[i];
+ b = s->sample_rate;
+ pos = ((block_len * 2 * a) + (b >> 1)) / b;
+ if (pos > block_len)
+ pos = block_len;
+ s->exponent_bands[0][i] = pos - lpos;
+ if (pos >= block_len) {
+ i++;
+ break;
+ }
+ lpos = pos;
+ }
+ s->exponent_sizes[0] = i;
+ } else {
+ /* hardcoded tables */
+ table = NULL;
+ a = s->frame_len_bits - BLOCK_MIN_BITS - k;
+ if (a < 3) {
+ if (s->sample_rate >= 44100)
+ table = exponent_band_44100[a];
+ else if (s->sample_rate >= 32000)
+ table = exponent_band_32000[a];
+ else if (s->sample_rate >= 22050)
+ table = exponent_band_22050[a];
+ }
+ if (table) {
+ n = *table++;
+ for(i=0;i<n;i++)
+ s->exponent_bands[k][i] = table[i];
+ s->exponent_sizes[k] = n;
+ } else {
+ j = 0;
+ lpos = 0;
+ for(i=0;i<25;i++) {
+ a = wma_critical_freqs[i];
+ b = s->sample_rate;
+ pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
+ pos <<= 2;
+ if (pos > block_len)
+ pos = block_len;
+ if (pos > lpos)
+ s->exponent_bands[k][j++] = pos - lpos;
+ if (pos >= block_len)
+ break;
+ lpos = pos;
+ }
+ s->exponent_sizes[k] = j;
+ }
+ }
+
+ /* max number of coefs */
+ s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
+ /* high freq computation */
+ s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
+ s->sample_rate + 0.5);
+ n = s->exponent_sizes[k];
+ j = 0;
+ pos = 0;
+ for(i=0;i<n;i++) {
+ int start, end;
+ start = pos;
+ pos += s->exponent_bands[k][i];
+ end = pos;
+ if (start < s->high_band_start[k])
+ start = s->high_band_start[k];
+ if (end > s->coefs_end[k])
+ end = s->coefs_end[k];
+ if (end > start)
+ s->exponent_high_bands[k][j++] = end - start;
+ }
+ s->exponent_high_sizes[k] = j;
+#if 0
+ tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
+ s->frame_len >> k,
+ s->coefs_end[k],
+ s->high_band_start[k],
+ s->exponent_high_sizes[k]);
+ for(j=0;j<s->exponent_high_sizes[k];j++)
+ tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
+ tprintf(s->avctx, "\n");
+#endif
+ }
+ }
+
+#ifdef TRACE
+ {
+ int i, j;
+ for(i = 0; i < s->nb_block_sizes; i++) {
+ tprintf(s->avctx, "%5d: n=%2d:",
+ s->frame_len >> i,
+ s->exponent_sizes[i]);
+ for(j=0;j<s->exponent_sizes[i];j++)
+ tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
+ tprintf(s->avctx, "\n");
+ }
+ }
+#endif
+
+ /* init MDCT windows : simple sinus window */
+ for(i = 0; i < s->nb_block_sizes; i++) {
+ int n, j;
+ float alpha;
+ n = 1 << (s->frame_len_bits - i);
+ window = av_malloc(sizeof(float) * n);
+ alpha = M_PI / (2.0 * n);
+ for(j=0;j<n;j++) {
+ window[j] = sin((j + 0.5) * alpha);
+ }
+ s->windows[i] = window;
+ }
+
+ s->reset_block_lengths = 1;
+
+ if (s->use_noise_coding) {
+
+ /* init the noise generator */
+ if (s->use_exp_vlc)
+ s->noise_mult = 0.02;
+ else
+ s->noise_mult = 0.04;
+
+#ifdef TRACE
+ for(i=0;i<NOISE_TAB_SIZE;i++)
+ s->noise_table[i] = 1.0 * s->noise_mult;
+#else
+ {
+ unsigned int seed;
+ float norm;
+ seed = 1;
+ norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
+ for(i=0;i<NOISE_TAB_SIZE;i++) {
+ seed = seed * 314159 + 1;
+ s->noise_table[i] = (float)((int)seed) * norm;
+ }
+ }
+#endif
+ }
+
+ /* choose the VLC tables for the coefficients */
+ coef_vlc_table = 2;
+ if (s->sample_rate >= 32000) {
+ if (bps1 < 0.72)
+ coef_vlc_table = 0;
+ else if (bps1 < 1.16)
+ coef_vlc_table = 1;
+ }
+ s->coef_vlcs[0]= &coef_vlcs[coef_vlc_table * 2 ];
+ s->coef_vlcs[1]= &coef_vlcs[coef_vlc_table * 2 + 1];
+ init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0], &s->int_table[0],
+ s->coef_vlcs[0]);
+ init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1], &s->int_table[1],
+ s->coef_vlcs[1]);
+
+ return 0;
+}
+
+int ff_wma_total_gain_to_bits(int total_gain){
+ if (total_gain < 15) return 13;
+ else if (total_gain < 32) return 12;
+ else if (total_gain < 40) return 11;
+ else if (total_gain < 45) return 10;
+ else return 9;
+}
+
+int ff_wma_end(AVCodecContext *avctx)
+{
+ WMACodecContext *s = avctx->priv_data;
+ int i;
+
+ for(i = 0; i < s->nb_block_sizes; i++)
+ ff_mdct_end(&s->mdct_ctx[i]);
+ for(i = 0; i < s->nb_block_sizes; i++)
+ av_free(s->windows[i]);
+
+ if (s->use_exp_vlc) {
+ free_vlc(&s->exp_vlc);
+ }
+ if (s->use_noise_coding) {
+ free_vlc(&s->hgain_vlc);
+ }
+ for(i = 0;i < 2; i++) {
+ free_vlc(&s->coef_vlc[i]);
+ av_free(s->run_table[i]);
+ av_free(s->level_table[i]);
+ }
+
+ return 0;
+}
diff --git a/contrib/ffmpeg/libavcodec/wma.h b/contrib/ffmpeg/libavcodec/wma.h
new file mode 100644
index 000000000..cd4daa7e5
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/wma.h
@@ -0,0 +1,149 @@
+/*
+ * WMA compatible codec
+ * Copyright (c) 2002-2007 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
+ */
+
+#ifndef WMA_H
+#define WMA_H
+
+#include "bitstream.h"
+#include "dsputil.h"
+
+/* size of blocks */
+#define BLOCK_MIN_BITS 7
+#define BLOCK_MAX_BITS 11
+#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
+
+#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
+
+/* XXX: find exact max size */
+#define HIGH_BAND_MAX_SIZE 16
+
+#define NB_LSP_COEFS 10
+
+/* XXX: is it a suitable value ? */
+#define MAX_CODED_SUPERFRAME_SIZE 16384
+
+#define MAX_CHANNELS 2
+
+#define NOISE_TAB_SIZE 8192
+
+#define LSP_POW_BITS 7
+
+//FIXME should be in wmadec
+#define VLCBITS 9
+#define VLCMAX ((22+VLCBITS-1)/VLCBITS)
+
+typedef struct CoefVLCTable {
+ int n; ///< total number of codes
+ int max_level;
+ const uint32_t *huffcodes; ///< VLC bit values
+ const uint8_t *huffbits; ///< VLC bit size
+ const uint16_t *levels; ///< table to build run/level tables
+} CoefVLCTable;
+
+typedef struct WMACodecContext {
+ AVCodecContext* avctx;
+ GetBitContext gb;
+ PutBitContext pb;
+ int sample_rate;
+ int nb_channels;
+ int bit_rate;
+ int version; ///< 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2)
+ int block_align;
+ int use_bit_reservoir;
+ int use_variable_block_len;
+ int use_exp_vlc; ///< exponent coding: 0 = lsp, 1 = vlc + delta
+ int use_noise_coding; ///< true if perceptual noise is added
+ int byte_offset_bits;
+ VLC exp_vlc;
+ int exponent_sizes[BLOCK_NB_SIZES];
+ uint16_t exponent_bands[BLOCK_NB_SIZES][25];
+ int high_band_start[BLOCK_NB_SIZES]; ///< index of first coef in high band
+ int coefs_start; ///< first coded coef
+ int coefs_end[BLOCK_NB_SIZES]; ///< max number of coded coefficients
+ int exponent_high_sizes[BLOCK_NB_SIZES];
+ int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
+ VLC hgain_vlc;
+
+ /* coded values in high bands */
+ int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
+ int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
+
+ /* there are two possible tables for spectral coefficients */
+//FIXME the following 3 tables should be shared between decoders
+ VLC coef_vlc[2];
+ uint16_t *run_table[2];
+ uint16_t *level_table[2];
+ uint16_t *int_table[2];
+ CoefVLCTable *coef_vlcs[2];
+ /* frame info */
+ int frame_len; ///< frame length in samples
+ int frame_len_bits; ///< frame_len = 1 << frame_len_bits
+ int nb_block_sizes; ///< number of block sizes
+ /* block info */
+ int reset_block_lengths;
+ int block_len_bits; ///< log2 of current block length
+ int next_block_len_bits; ///< log2 of next block length
+ int prev_block_len_bits; ///< log2 of prev block length
+ int block_len; ///< block length in samples
+ int block_num; ///< block number in current frame
+ int block_pos; ///< current position in frame
+ uint8_t ms_stereo; ///< true if mid/side stereo mode
+ uint8_t channel_coded[MAX_CHANNELS]; ///< true if channel is coded
+ DECLARE_ALIGNED_16(float, exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]);
+ float max_exponent[MAX_CHANNELS];
+ int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
+ DECLARE_ALIGNED_16(float, coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]);
+ DECLARE_ALIGNED_16(FFTSample, output[BLOCK_MAX_SIZE * 2]);
+ MDCTContext mdct_ctx[BLOCK_NB_SIZES];
+ float *windows[BLOCK_NB_SIZES];
+ DECLARE_ALIGNED_16(FFTSample, mdct_tmp[BLOCK_MAX_SIZE]); ///< temporary storage for imdct
+ /* output buffer for one frame and the last for IMDCT windowing */
+ DECLARE_ALIGNED_16(float, frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]);
+ /* last frame info */
+ uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
+ int last_bitoffset;
+ int last_superframe_len;
+ float noise_table[NOISE_TAB_SIZE];
+ int noise_index;
+ float noise_mult; /* XXX: suppress that and integrate it in the noise array */
+ /* lsp_to_curve tables */
+ float lsp_cos_table[BLOCK_MAX_SIZE];
+ float lsp_pow_e_table[256];
+ float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
+ float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
+ DSPContext dsp;
+
+#ifdef TRACE
+ int frame_count;
+#endif
+} WMACodecContext;
+
+extern const uint16_t ff_wma_hgain_huffcodes[37];
+extern const uint8_t ff_wma_hgain_huffbits[37];
+extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
+extern const uint32_t ff_wma_scale_huffcodes[121];
+extern const uint8_t ff_wma_scale_huffbits[121];
+
+int ff_wma_init(AVCodecContext * avctx, int flags2);
+int ff_wma_total_gain_to_bits(int total_gain);
+int ff_wma_end(AVCodecContext *avctx);
+
+#endif
diff --git a/contrib/ffmpeg/libavcodec/wmadata.h b/contrib/ffmpeg/libavcodec/wmadata.h
index 35e545ce6..31ed89bf0 100644
--- a/contrib/ffmpeg/libavcodec/wmadata.h
+++ b/contrib/ffmpeg/libavcodec/wmadata.h
@@ -50,7 +50,7 @@ static const uint8_t exponent_band_44100[3][25] = {
{ 17, 4, 8, 8, 4, 12, 12, 8, 8, 24, 16, 20, 24, 32, 40, 60, 80, 152, },
};
-static const uint16_t hgain_huffcodes[37] = {
+const uint16_t ff_wma_hgain_huffcodes[37] = {
0x00003, 0x002e7, 0x00001, 0x005cd, 0x0005d, 0x005c9, 0x0005e, 0x00003,
0x00016, 0x0000b, 0x00001, 0x00006, 0x00001, 0x00006, 0x00004, 0x00005,
0x00004, 0x00007, 0x00003, 0x00007, 0x00004, 0x0000a, 0x0000a, 0x00002,
@@ -58,7 +58,7 @@ static const uint16_t hgain_huffcodes[37] = {
0x005c8, 0x000b8, 0x005ca, 0x005cb, 0x005cc,
};
-static const uint8_t hgain_huffbits[37] = {
+const uint8_t ff_wma_hgain_huffbits[37] = {
10, 12, 10, 13, 9, 13, 9, 8,
7, 5, 5, 4, 4, 3, 3, 3,
4, 3, 4, 4, 5, 5, 6, 8,
@@ -66,7 +66,7 @@ static const uint8_t hgain_huffbits[37] = {
13, 10, 13, 13, 13,
};
-static const float lsp_codebook[NB_LSP_COEFS][16] = {
+const float ff_wma_lsp_codebook[NB_LSP_COEFS][16] = {
{ 1.98732877, 1.97944528, 1.97179088, 1.96260549, 1.95038374, 1.93336114, 1.90719232, 1.86191415, },
{ 1.97260000, 1.96083160, 1.94982586, 1.93806164, 1.92516608, 1.91010199, 1.89232331, 1.87149812,
1.84564818, 1.81358067, 1.77620070, 1.73265264, 1.67907855, 1.60959081, 1.50829650, 1.33120330, },
@@ -86,7 +86,7 @@ static const float lsp_codebook[NB_LSP_COEFS][16] = {
{ -1.56144989, -1.65944032, -1.72689685, -1.77857740, -1.82203011, -1.86220079, -1.90283983, -1.94820479, },
};
-static const uint32_t scale_huffcodes[121] = {
+const uint32_t ff_wma_scale_huffcodes[121] = {
0x3ffe8, 0x3ffe6, 0x3ffe7, 0x3ffe5, 0x7fff5, 0x7fff1, 0x7ffed, 0x7fff6,
0x7ffee, 0x7ffef, 0x7fff0, 0x7fffc, 0x7fffd, 0x7ffff, 0x7fffe, 0x7fff7,
0x7fff8, 0x7fffb, 0x7fff9, 0x3ffe4, 0x7fffa, 0x3ffe3, 0x1ffef, 0x1fff0,
@@ -105,7 +105,7 @@ static const uint32_t scale_huffcodes[121] = {
0x7fff3,
};
-static const uint8_t scale_huffbits[121] = {
+const uint8_t ff_wma_scale_huffbits[121] = {
18, 18, 18, 18, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 18, 19, 18, 17, 17,
@@ -1413,21 +1413,21 @@ static const uint16_t levels5[40] = {
static const CoefVLCTable coef_vlcs[6] = {
{
- sizeof(coef0_huffbits), coef0_huffcodes, coef0_huffbits, levels0,
+ sizeof(coef0_huffbits), sizeof(levels0)/2, coef0_huffcodes, coef0_huffbits, levels0,
},
{
- sizeof(coef1_huffbits), coef1_huffcodes, coef1_huffbits, levels1,
+ sizeof(coef1_huffbits), sizeof(levels1)/2, coef1_huffcodes, coef1_huffbits, levels1,
},
{
- sizeof(coef2_huffbits), coef2_huffcodes, coef2_huffbits, levels2,
+ sizeof(coef2_huffbits), sizeof(levels2)/2, coef2_huffcodes, coef2_huffbits, levels2,
},
{
- sizeof(coef3_huffbits), coef3_huffcodes, coef3_huffbits, levels3,
+ sizeof(coef3_huffbits), sizeof(levels3)/2, coef3_huffcodes, coef3_huffbits, levels3,
},
{
- sizeof(coef4_huffbits), coef4_huffcodes, coef4_huffbits, levels4,
+ sizeof(coef4_huffbits), sizeof(levels4)/2, coef4_huffcodes, coef4_huffbits, levels4,
},
{
- sizeof(coef5_huffbits), coef5_huffcodes, coef5_huffbits, levels5,
+ sizeof(coef5_huffbits), sizeof(levels5)/2, coef5_huffcodes, coef5_huffbits, levels5,
},
};
diff --git a/contrib/ffmpeg/libavcodec/wmadec.c b/contrib/ffmpeg/libavcodec/wmadec.c
index 684aea2c8..ef3cc7a33 100644
--- a/contrib/ffmpeg/libavcodec/wmadec.c
+++ b/contrib/ffmpeg/libavcodec/wmadec.c
@@ -34,32 +34,10 @@
*/
#include "avcodec.h"
-#include "bitstream.h"
-#include "dsputil.h"
+#include "wma.h"
-/* size of blocks */
-#define BLOCK_MIN_BITS 7
-#define BLOCK_MAX_BITS 11
-#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
-
-#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
-
-/* XXX: find exact max size */
-#define HIGH_BAND_MAX_SIZE 16
-
-#define NB_LSP_COEFS 10
-
-/* XXX: is it a suitable value ? */
-#define MAX_CODED_SUPERFRAME_SIZE 16384
-
-#define MAX_CHANNELS 2
-
-#define NOISE_TAB_SIZE 8192
-
-#define LSP_POW_BITS 7
-
-#define VLCBITS 9
-#define VLCMAX ((22+VLCBITS-1)/VLCBITS)
+#undef NDEBUG
+#include <assert.h>
#define EXPVLCBITS 8
#define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS)
@@ -67,476 +45,94 @@
#define HGAINVLCBITS 9
#define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS)
-typedef struct WMADecodeContext {
- GetBitContext gb;
- int sample_rate;
- int nb_channels;
- int bit_rate;
- int version; /* 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) */
- int block_align;
- int use_bit_reservoir;
- int use_variable_block_len;
- int use_exp_vlc; /* exponent coding: 0 = lsp, 1 = vlc + delta */
- int use_noise_coding; /* true if perceptual noise is added */
- int byte_offset_bits;
- VLC exp_vlc;
- int exponent_sizes[BLOCK_NB_SIZES];
- uint16_t exponent_bands[BLOCK_NB_SIZES][25];
- int high_band_start[BLOCK_NB_SIZES]; /* index of first coef in high band */
- int coefs_start; /* first coded coef */
- int coefs_end[BLOCK_NB_SIZES]; /* max number of coded coefficients */
- int exponent_high_sizes[BLOCK_NB_SIZES];
- int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
- VLC hgain_vlc;
-
- /* coded values in high bands */
- int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
- int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
-
- /* there are two possible tables for spectral coefficients */
- VLC coef_vlc[2];
- uint16_t *run_table[2];
- uint16_t *level_table[2];
- /* frame info */
- int frame_len; /* frame length in samples */
- int frame_len_bits; /* frame_len = 1 << frame_len_bits */
- int nb_block_sizes; /* number of block sizes */
- /* block info */
- int reset_block_lengths;
- int block_len_bits; /* log2 of current block length */
- int next_block_len_bits; /* log2 of next block length */
- int prev_block_len_bits; /* log2 of prev block length */
- int block_len; /* block length in samples */
- int block_num; /* block number in current frame */
- int block_pos; /* current position in frame */
- uint8_t ms_stereo; /* true if mid/side stereo mode */
- uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */
- DECLARE_ALIGNED_16(float, exponents[MAX_CHANNELS][BLOCK_MAX_SIZE]);
- float max_exponent[MAX_CHANNELS];
- int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
- DECLARE_ALIGNED_16(float, coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]);
- MDCTContext mdct_ctx[BLOCK_NB_SIZES];
- float *windows[BLOCK_NB_SIZES];
- DECLARE_ALIGNED_16(FFTSample, mdct_tmp[BLOCK_MAX_SIZE]); /* temporary storage for imdct */
- /* output buffer for one frame and the last for IMDCT windowing */
- DECLARE_ALIGNED_16(float, frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]);
- /* last frame info */
- uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
- int last_bitoffset;
- int last_superframe_len;
- float noise_table[NOISE_TAB_SIZE];
- int noise_index;
- float noise_mult; /* XXX: suppress that and integrate it in the noise array */
- /* lsp_to_curve tables */
- float lsp_cos_table[BLOCK_MAX_SIZE];
- float lsp_pow_e_table[256];
- float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
- float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
- DSPContext dsp;
+static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len);
#ifdef TRACE
- int frame_count;
-#endif
-} WMADecodeContext;
-
-typedef struct CoefVLCTable {
- int n; /* total number of codes */
- const uint32_t *huffcodes; /* VLC bit values */
- const uint8_t *huffbits; /* VLC bit size */
- const uint16_t *levels; /* table to build run/level tables */
-} CoefVLCTable;
-
-static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len);
-
-#include "wmadata.h"
-
-#ifdef TRACE
-static void dump_shorts(const char *name, const short *tab, int n)
+static void dump_shorts(WMADecodeContext *s, const char *name, const short *tab, int n)
{
int i;
- tprintf("%s[%d]:\n", name, n);
+ tprintf(s->avctx, "%s[%d]:\n", name, n);
for(i=0;i<n;i++) {
if ((i & 7) == 0)
- tprintf("%4d: ", i);
- tprintf(" %5d.0", tab[i]);
+ tprintf(s->avctx, "%4d: ", i);
+ tprintf(s->avctx, " %5d.0", tab[i]);
if ((i & 7) == 7)
- tprintf("\n");
+ tprintf(s->avctx, "\n");
}
}
-static void dump_floats(const char *name, int prec, const float *tab, int n)
+static void dump_floats(WMADecodeContext *s, const char *name, int prec, const float *tab, int n)
{
int i;
- tprintf("%s[%d]:\n", name, n);
+ tprintf(s->avctx, "%s[%d]:\n", name, n);
for(i=0;i<n;i++) {
if ((i & 7) == 0)
- tprintf("%4d: ", i);
- tprintf(" %8.*f", prec, tab[i]);
+ tprintf(s->avctx, "%4d: ", i);
+ tprintf(s->avctx, " %8.*f", prec, tab[i]);
if ((i & 7) == 7)
- tprintf("\n");
+ tprintf(s->avctx, "\n");
}
if ((i & 7) != 0)
- tprintf("\n");
+ tprintf(s->avctx, "\n");
}
#endif
-/* XXX: use same run/length optimization as mpeg decoders */
-static void init_coef_vlc(VLC *vlc,
- uint16_t **prun_table, uint16_t **plevel_table,
- const CoefVLCTable *vlc_table)
-{
- int n = vlc_table->n;
- const uint8_t *table_bits = vlc_table->huffbits;
- const uint32_t *table_codes = vlc_table->huffcodes;
- const uint16_t *levels_table = vlc_table->levels;
- uint16_t *run_table, *level_table;
- const uint16_t *p;
- int i, l, j, level;
-
- init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, 0);
-
- run_table = av_malloc(n * sizeof(uint16_t));
- level_table = av_malloc(n * sizeof(uint16_t));
- p = levels_table;
- i = 2;
- level = 1;
- while (i < n) {
- l = *p++;
- for(j=0;j<l;j++) {
- run_table[i] = j;
- level_table[i] = level;
- i++;
- }
- level++;
- }
- *prun_table = run_table;
- *plevel_table = level_table;
-}
-
static int wma_decode_init(AVCodecContext * avctx)
{
- WMADecodeContext *s = avctx->priv_data;
+ WMACodecContext *s = avctx->priv_data;
int i, flags1, flags2;
- float *window;
uint8_t *extradata;
- float bps1, high_freq;
- volatile float bps;
- int sample_rate1;
- int coef_vlc_table;
- s->sample_rate = avctx->sample_rate;
- s->nb_channels = avctx->channels;
- s->bit_rate = avctx->bit_rate;
- s->block_align = avctx->block_align;
-
- dsputil_init(&s->dsp, avctx);
-
- if (avctx->codec->id == CODEC_ID_WMAV1) {
- s->version = 1;
- } else {
- s->version = 2;
- }
+ s->avctx = avctx;
/* extract flag infos */
flags1 = 0;
flags2 = 0;
extradata = avctx->extradata;
- if (s->version == 1 && avctx->extradata_size >= 4) {
+ if (avctx->codec->id == CODEC_ID_WMAV1 && avctx->extradata_size >= 4) {
flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8);
- } else if (s->version == 2 && avctx->extradata_size >= 6) {
+ } else if (avctx->codec->id == CODEC_ID_WMAV2 && avctx->extradata_size >= 6) {
flags1 = extradata[0] | (extradata[1] << 8) |
(extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8);
}
+// for(i=0; i<avctx->extradata_size; i++)
+// av_log(NULL, AV_LOG_ERROR, "%02X ", extradata[i]);
+
s->use_exp_vlc = flags2 & 0x0001;
s->use_bit_reservoir = flags2 & 0x0002;
s->use_variable_block_len = flags2 & 0x0004;
- /* compute MDCT block size */
- if (s->sample_rate <= 16000) {
- s->frame_len_bits = 9;
- } else if (s->sample_rate <= 22050 ||
- (s->sample_rate <= 32000 && s->version == 1)) {
- s->frame_len_bits = 10;
- } else {
- s->frame_len_bits = 11;
- }
- s->frame_len = 1 << s->frame_len_bits;
- if (s->use_variable_block_len) {
- int nb_max, nb;
- nb = ((flags2 >> 3) & 3) + 1;
- if ((s->bit_rate / s->nb_channels) >= 32000)
- nb += 2;
- nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
- if (nb > nb_max)
- nb = nb_max;
- s->nb_block_sizes = nb + 1;
- } else {
- s->nb_block_sizes = 1;
- }
-
- /* init rate dependant parameters */
- s->use_noise_coding = 1;
- high_freq = s->sample_rate * 0.5;
-
- /* if version 2, then the rates are normalized */
- sample_rate1 = s->sample_rate;
- if (s->version == 2) {
- if (sample_rate1 >= 44100)
- sample_rate1 = 44100;
- else if (sample_rate1 >= 22050)
- sample_rate1 = 22050;
- else if (sample_rate1 >= 16000)
- sample_rate1 = 16000;
- else if (sample_rate1 >= 11025)
- sample_rate1 = 11025;
- else if (sample_rate1 >= 8000)
- sample_rate1 = 8000;
- }
-
- bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
- s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2;
-
- /* compute high frequency value and choose if noise coding should
- be activated */
- bps1 = bps;
- if (s->nb_channels == 2)
- bps1 = bps * 1.6;
- if (sample_rate1 == 44100) {
- if (bps1 >= 0.61)
- s->use_noise_coding = 0;
- else
- high_freq = high_freq * 0.4;
- } else if (sample_rate1 == 22050) {
- if (bps1 >= 1.16)
- s->use_noise_coding = 0;
- else if (bps1 >= 0.72)
- high_freq = high_freq * 0.7;
- else
- high_freq = high_freq * 0.6;
- } else if (sample_rate1 == 16000) {
- if (bps > 0.5)
- high_freq = high_freq * 0.5;
- else
- high_freq = high_freq * 0.3;
- } else if (sample_rate1 == 11025) {
- high_freq = high_freq * 0.7;
- } else if (sample_rate1 == 8000) {
- if (bps <= 0.625) {
- high_freq = high_freq * 0.5;
- } else if (bps > 0.75) {
- s->use_noise_coding = 0;
- } else {
- high_freq = high_freq * 0.65;
- }
- } else {
- if (bps >= 0.8) {
- high_freq = high_freq * 0.75;
- } else if (bps >= 0.6) {
- high_freq = high_freq * 0.6;
- } else {
- high_freq = high_freq * 0.5;
- }
- }
- dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
- dprintf("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("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
- bps, bps1, high_freq, s->byte_offset_bits);
- dprintf("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 */
- {
- int a, b, pos, lpos, k, block_len, i, j, n;
- const uint8_t *table;
-
- if (s->version == 1) {
- s->coefs_start = 3;
- } else {
- s->coefs_start = 0;
- }
- for(k = 0; k < s->nb_block_sizes; k++) {
- block_len = s->frame_len >> k;
-
- if (s->version == 1) {
- lpos = 0;
- for(i=0;i<25;i++) {
- a = wma_critical_freqs[i];
- b = s->sample_rate;
- pos = ((block_len * 2 * a) + (b >> 1)) / b;
- if (pos > block_len)
- pos = block_len;
- s->exponent_bands[0][i] = pos - lpos;
- if (pos >= block_len) {
- i++;
- break;
- }
- lpos = pos;
- }
- s->exponent_sizes[0] = i;
- } else {
- /* hardcoded tables */
- table = NULL;
- a = s->frame_len_bits - BLOCK_MIN_BITS - k;
- if (a < 3) {
- if (s->sample_rate >= 44100)
- table = exponent_band_44100[a];
- else if (s->sample_rate >= 32000)
- table = exponent_band_32000[a];
- else if (s->sample_rate >= 22050)
- table = exponent_band_22050[a];
- }
- if (table) {
- n = *table++;
- for(i=0;i<n;i++)
- s->exponent_bands[k][i] = table[i];
- s->exponent_sizes[k] = n;
- } else {
- j = 0;
- lpos = 0;
- for(i=0;i<25;i++) {
- a = wma_critical_freqs[i];
- b = s->sample_rate;
- pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
- pos <<= 2;
- if (pos > block_len)
- pos = block_len;
- if (pos > lpos)
- s->exponent_bands[k][j++] = pos - lpos;
- if (pos >= block_len)
- break;
- lpos = pos;
- }
- s->exponent_sizes[k] = j;
- }
- }
-
- /* max number of coefs */
- s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
- /* high freq computation */
- s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
- s->sample_rate + 0.5);
- n = s->exponent_sizes[k];
- j = 0;
- pos = 0;
- for(i=0;i<n;i++) {
- int start, end;
- start = pos;
- pos += s->exponent_bands[k][i];
- end = pos;
- if (start < s->high_band_start[k])
- start = s->high_band_start[k];
- if (end > s->coefs_end[k])
- end = s->coefs_end[k];
- if (end > start)
- s->exponent_high_bands[k][j++] = end - start;
- }
- s->exponent_high_sizes[k] = j;
-#if 0
- tprintf("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
- s->frame_len >> k,
- s->coefs_end[k],
- s->high_band_start[k],
- s->exponent_high_sizes[k]);
- for(j=0;j<s->exponent_high_sizes[k];j++)
- tprintf(" %d", s->exponent_high_bands[k][j]);
- tprintf("\n");
-#endif
- }
- }
-
-#ifdef TRACE
- {
- int i, j;
- for(i = 0; i < s->nb_block_sizes; i++) {
- tprintf("%5d: n=%2d:",
- s->frame_len >> i,
- s->exponent_sizes[i]);
- for(j=0;j<s->exponent_sizes[i];j++)
- tprintf(" %d", s->exponent_bands[i][j]);
- tprintf("\n");
- }
- }
-#endif
+ ff_wma_init(avctx, flags2);
/* init MDCT */
for(i = 0; i < s->nb_block_sizes; i++)
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
- /* init MDCT windows : simple sinus window */
- for(i = 0; i < s->nb_block_sizes; i++) {
- int n, j;
- float alpha;
- n = 1 << (s->frame_len_bits - i);
- window = av_malloc(sizeof(float) * n);
- alpha = M_PI / (2.0 * n);
- for(j=0;j<n;j++) {
- window[n - j - 1] = sin((j + 0.5) * alpha);
- }
- s->windows[i] = window;
- }
-
- s->reset_block_lengths = 1;
-
if (s->use_noise_coding) {
-
- /* init the noise generator */
- if (s->use_exp_vlc)
- s->noise_mult = 0.02;
- else
- s->noise_mult = 0.04;
-
-#ifdef TRACE
- for(i=0;i<NOISE_TAB_SIZE;i++)
- s->noise_table[i] = 1.0 * s->noise_mult;
-#else
- {
- unsigned int seed;
- float norm;
- seed = 1;
- norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
- for(i=0;i<NOISE_TAB_SIZE;i++) {
- seed = seed * 314159 + 1;
- s->noise_table[i] = (float)((int)seed) * norm;
- }
- }
-#endif
- init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(hgain_huffbits),
- hgain_huffbits, 1, 1,
- hgain_huffcodes, 2, 2, 0);
+ init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits),
+ ff_wma_hgain_huffbits, 1, 1,
+ ff_wma_hgain_huffcodes, 2, 2, 0);
}
if (s->use_exp_vlc) {
- init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(scale_huffbits),
- scale_huffbits, 1, 1,
- scale_huffcodes, 4, 4, 0);
+ init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_wma_scale_huffbits), //FIXME move out of context
+ ff_wma_scale_huffbits, 1, 1,
+ ff_wma_scale_huffcodes, 4, 4, 0);
} else {
wma_lsp_to_curve_init(s, s->frame_len);
}
- /* choose the VLC tables for the coefficients */
- coef_vlc_table = 2;
- if (s->sample_rate >= 32000) {
- if (bps1 < 0.72)
- coef_vlc_table = 0;
- else if (bps1 < 1.16)
- coef_vlc_table = 1;
- }
-
- init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
- &coef_vlcs[coef_vlc_table * 2]);
- init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
- &coef_vlcs[coef_vlc_table * 2 + 1]);
return 0;
}
-/* interpolate values for a bigger or smaller block. The block must
- have multiple sizes */
+/**
+ * interpolate values for a bigger or smaller block. The block must
+ * have multiple sizes
+ */
static void interpolate_array(float *scale, int old_size, int new_size)
{
int i, j, jincr, k;
@@ -562,11 +158,13 @@ static void interpolate_array(float *scale, int old_size, int new_size)
}
}
-/* compute x^-0.25 with an exponent and mantissa table. We use linear
- interpolation to reduce the mantissa table size at a small speed
- expense (linear interpolation approximately doubles the number of
- bits of precision). */
-static inline float pow_m1_4(WMADecodeContext *s, float x)
+/**
+ * compute x^-0.25 with an exponent and mantissa table. We use linear
+ * interpolation to reduce the mantissa table size at a small speed
+ * expense (linear interpolation approximately doubles the number of
+ * bits of precision).
+ */
+static inline float pow_m1_4(WMACodecContext *s, float x)
{
union {
float f;
@@ -585,7 +183,7 @@ static inline float pow_m1_4(WMADecodeContext *s, float x)
return s->lsp_pow_e_table[e] * (a + b * t.f);
}
-static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len)
+static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len)
{
float wdel, a, b;
int i, e, m;
@@ -622,9 +220,11 @@ static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len)
#endif
}
-/* NOTE: We use the same code as Vorbis here */
-/* XXX: optimize it further with SSE/3Dnow */
-static void wma_lsp_to_curve(WMADecodeContext *s,
+/**
+ * NOTE: We use the same code as Vorbis here
+ * @todo optimize it further with SSE/3Dnow
+ */
+static void wma_lsp_to_curve(WMACodecContext *s,
float *out, float *val_max_ptr,
int n, float *lsp)
{
@@ -651,8 +251,10 @@ static void wma_lsp_to_curve(WMADecodeContext *s,
*val_max_ptr = val_max;
}
-/* decode exponents coded with LSP coefficients (same idea as Vorbis) */
-static void decode_exp_lsp(WMADecodeContext *s, int ch)
+/**
+ * decode exponents coded with LSP coefficients (same idea as Vorbis)
+ */
+static void decode_exp_lsp(WMACodecContext *s, int ch)
{
float lsp_coefs[NB_LSP_COEFS];
int val, i;
@@ -662,15 +264,17 @@ static void decode_exp_lsp(WMADecodeContext *s, int ch)
val = get_bits(&s->gb, 3);
else
val = get_bits(&s->gb, 4);
- lsp_coefs[i] = lsp_codebook[i][val];
+ lsp_coefs[i] = ff_wma_lsp_codebook[i][val];
}
wma_lsp_to_curve(s, s->exponents[ch], &s->max_exponent[ch],
s->block_len, lsp_coefs);
}
-/* decode exponents coded with VLC codes */
-static int decode_exp_vlc(WMADecodeContext *s, int ch)
+/**
+ * decode exponents coded with VLC codes
+ */
+static int decode_exp_vlc(WMACodecContext *s, int ch)
{
int last_exp, n, code;
const uint16_t *ptr, *band_ptr;
@@ -690,8 +294,9 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
do {
*q++ = v;
} while (--n);
- }
- last_exp = 36;
+ }else
+ last_exp = 36;
+
while (q < q_end) {
code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX);
if (code < 0)
@@ -711,18 +316,74 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
return 0;
}
-/* return 0 if OK. return 1 if last block of frame. return -1 if
- unrecorrable error. */
-static int wma_decode_block(WMADecodeContext *s)
+
+/**
+ * Apply MDCT window and add into output.
+ *
+ * We ensure that when the windows overlap their squared sum
+ * is always 1 (MDCT reconstruction rule).
+ */
+static void wma_window(WMACodecContext *s, float *out)
+{
+ float *in = s->output;
+ int block_len, bsize, n;
+
+ /* left part */
+ if (s->block_len_bits <= s->prev_block_len_bits) {
+ block_len = s->block_len;
+ bsize = s->frame_len_bits - s->block_len_bits;
+
+ s->dsp.vector_fmul_add_add(out, in, s->windows[bsize],
+ out, 0, block_len, 1);
+
+ } else {
+ block_len = 1 << s->prev_block_len_bits;
+ n = (s->block_len - block_len) / 2;
+ bsize = s->frame_len_bits - s->prev_block_len_bits;
+
+ s->dsp.vector_fmul_add_add(out+n, in+n, s->windows[bsize],
+ out+n, 0, block_len, 1);
+
+ memcpy(out+n+block_len, in+n+block_len, n*sizeof(float));
+ }
+
+ out += s->block_len;
+ in += s->block_len;
+
+ /* right part */
+ if (s->block_len_bits <= s->next_block_len_bits) {
+ block_len = s->block_len;
+ bsize = s->frame_len_bits - s->block_len_bits;
+
+ s->dsp.vector_fmul_reverse(out, in, s->windows[bsize], block_len);
+
+ } else {
+ block_len = 1 << s->next_block_len_bits;
+ n = (s->block_len - block_len) / 2;
+ bsize = s->frame_len_bits - s->next_block_len_bits;
+
+ memcpy(out, in, n*sizeof(float));
+
+ s->dsp.vector_fmul_reverse(out+n, in+n, s->windows[bsize], block_len);
+
+ memset(out+n+block_len, 0, n*sizeof(float));
+ }
+}
+
+
+/**
+ * @return 0 if OK. 1 if last block of frame. return -1 if
+ * unrecorrable error.
+ */
+static int wma_decode_block(WMACodecContext *s)
{
int n, v, a, ch, code, bsize;
int coef_nb_bits, total_gain, parse_exponents;
- DECLARE_ALIGNED_16(float, window[BLOCK_MAX_SIZE * 2]);
int nb_coefs[MAX_CHANNELS];
float mdct_norm;
#ifdef TRACE
- tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
+ tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
#endif
/* compute current block length */
@@ -786,16 +447,7 @@ static int wma_decode_block(WMADecodeContext *s)
break;
}
- if (total_gain < 15)
- coef_nb_bits = 13;
- else if (total_gain < 32)
- coef_nb_bits = 12;
- else if (total_gain < 40)
- coef_nb_bits = 11;
- else if (total_gain < 45)
- coef_nb_bits = 10;
- else
- coef_nb_bits = 9;
+ coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
/* compute number of coefficients */
n = s->coefs_end[bsize] - s->coefs_start;
@@ -972,7 +624,7 @@ static int wma_decode_block(WMADecodeContext *s)
}
exp_power[j] = e2 / n;
last_high_band = j;
- tprintf("%d: power=%f (%d)\n", j, exp_power[j], n);
+ tprintf(s->avctx, "%d: power=%f (%d)\n", j, exp_power[j], n);
}
exp_ptr += n;
}
@@ -1033,8 +685,8 @@ static int wma_decode_block(WMADecodeContext *s)
#ifdef TRACE
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
- dump_floats("exponents", 3, s->exponents[ch], s->block_len);
- dump_floats("coefs", 1, s->coefs[ch], s->block_len);
+ dump_floats(s, "exponents", 3, s->exponents[ch], s->block_len);
+ dump_floats(s, "coefs", 1, s->coefs[ch], s->block_len);
}
}
#endif
@@ -1047,7 +699,7 @@ static int wma_decode_block(WMADecodeContext *s)
/* no need to optimize this case because it should almost
never happen */
if (!s->channel_coded[0]) {
- tprintf("rare ms-stereo case happened\n");
+ tprintf(s->avctx, "rare ms-stereo case happened\n");
memset(s->coefs[0], 0, sizeof(float) * s->block_len);
s->channel_coded[0] = 1;
}
@@ -1060,75 +712,23 @@ static int wma_decode_block(WMADecodeContext *s)
}
}
- /* build the window : we ensure that when the windows overlap
- their squared sum is always 1 (MDCT reconstruction rule) */
- /* XXX: merge with output */
- {
- int i, next_block_len, block_len, prev_block_len, n;
- float *wptr;
-
- block_len = s->block_len;
- prev_block_len = 1 << s->prev_block_len_bits;
- next_block_len = 1 << s->next_block_len_bits;
-
- /* right part */
- wptr = window + block_len;
- if (block_len <= next_block_len) {
- for(i=0;i<block_len;i++)
- *wptr++ = s->windows[bsize][i];
- } else {
- /* overlap */
- n = (block_len / 2) - (next_block_len / 2);
- for(i=0;i<n;i++)
- *wptr++ = 1.0;
- for(i=0;i<next_block_len;i++)
- *wptr++ = s->windows[s->frame_len_bits - s->next_block_len_bits][i];
- for(i=0;i<n;i++)
- *wptr++ = 0.0;
- }
-
- /* left part */
- wptr = window + block_len;
- if (block_len <= prev_block_len) {
- for(i=0;i<block_len;i++)
- *--wptr = s->windows[bsize][i];
- } else {
- /* overlap */
- n = (block_len / 2) - (prev_block_len / 2);
- for(i=0;i<n;i++)
- *--wptr = 1.0;
- for(i=0;i<prev_block_len;i++)
- *--wptr = s->windows[s->frame_len_bits - s->prev_block_len_bits][i];
- for(i=0;i<n;i++)
- *--wptr = 0.0;
- }
- }
-
-
for(ch = 0; ch < s->nb_channels; ch++) {
if (s->channel_coded[ch]) {
- DECLARE_ALIGNED_16(FFTSample, output[BLOCK_MAX_SIZE * 2]);
- float *ptr;
int n4, index, n;
n = s->block_len;
n4 = s->block_len / 2;
s->mdct_ctx[bsize].fft.imdct_calc(&s->mdct_ctx[bsize],
- output, s->coefs[ch], s->mdct_tmp);
-
- /* XXX: optimize all that by build the window and
- multipying/adding at the same time */
+ s->output, s->coefs[ch], s->mdct_tmp);
/* multiply by the window and add in the frame */
index = (s->frame_len / 2) + s->block_pos - n4;
- ptr = &s->frame_out[ch][index];
- s->dsp.vector_fmul_add_add(ptr,window,output,ptr,0,2*n,1);
+ wma_window(s, &s->frame_out[ch][index]);
/* specific fast case for ms-stereo : add to second
channel if it is not coded */
if (s->ms_stereo && !s->channel_coded[1]) {
- ptr = &s->frame_out[1][index];
- s->dsp.vector_fmul_add_add(ptr,window,output,ptr,0,2*n,1);
+ wma_window(s, &s->frame_out[1][index]);
}
}
}
@@ -1143,14 +743,14 @@ static int wma_decode_block(WMADecodeContext *s)
}
/* decode a frame of frame_len samples */
-static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
+static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
{
int ret, i, n, a, ch, incr;
int16_t *ptr;
float *iptr;
#ifdef TRACE
- tprintf("***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
+ tprintf(s->avctx, "***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
#endif
/* read each block */
@@ -1183,13 +783,10 @@ static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
/* prepare for next block */
memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
s->frame_len * sizeof(float));
- /* XXX: suppress this */
- memset(&s->frame_out[ch][s->frame_len], 0,
- s->frame_len * sizeof(float));
}
#ifdef TRACE
- dump_shorts("samples", samples, n * s->nb_channels);
+ dump_shorts(s, "samples", samples, n * s->nb_channels);
#endif
return 0;
}
@@ -1198,12 +795,12 @@ static int wma_decode_superframe(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
- WMADecodeContext *s = avctx->priv_data;
+ WMACodecContext *s = avctx->priv_data;
int nb_frames, bit_offset, i, pos, len;
uint8_t *q;
int16_t *samples;
- tprintf("***decode_superframe:\n");
+ tprintf(avctx, "***decode_superframe:\n");
if(buf_size==0){
s->last_superframe_len = 0;
@@ -1279,6 +876,9 @@ static int wma_decode_superframe(AVCodecContext *avctx,
goto fail;
samples += s->nb_channels * s->frame_len;
}
+
+//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d outbytes:%d eaten:%d\n", s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len, (int8_t *)samples - (int8_t *)data, s->block_align);
+
*data_size = (int8_t *)samples - (int8_t *)data;
return s->block_align;
fail:
@@ -1287,40 +887,15 @@ static int wma_decode_superframe(AVCodecContext *avctx,
return -1;
}
-static int wma_decode_end(AVCodecContext *avctx)
-{
- WMADecodeContext *s = avctx->priv_data;
- int i;
-
- for(i = 0; i < s->nb_block_sizes; i++)
- ff_mdct_end(&s->mdct_ctx[i]);
- for(i = 0; i < s->nb_block_sizes; i++)
- av_free(s->windows[i]);
-
- if (s->use_exp_vlc) {
- free_vlc(&s->exp_vlc);
- }
- if (s->use_noise_coding) {
- free_vlc(&s->hgain_vlc);
- }
- for(i = 0;i < 2; i++) {
- free_vlc(&s->coef_vlc[i]);
- av_free(s->run_table[i]);
- av_free(s->level_table[i]);
- }
-
- return 0;
-}
-
AVCodec wmav1_decoder =
{
"wmav1",
CODEC_TYPE_AUDIO,
CODEC_ID_WMAV1,
- sizeof(WMADecodeContext),
+ sizeof(WMACodecContext),
wma_decode_init,
NULL,
- wma_decode_end,
+ ff_wma_end,
wma_decode_superframe,
};
@@ -1329,9 +904,9 @@ AVCodec wmav2_decoder =
"wmav2",
CODEC_TYPE_AUDIO,
CODEC_ID_WMAV2,
- sizeof(WMADecodeContext),
+ sizeof(WMACodecContext),
wma_decode_init,
NULL,
- wma_decode_end,
+ ff_wma_end,
wma_decode_superframe,
};
diff --git a/contrib/ffmpeg/libavcodec/wmaenc.c b/contrib/ffmpeg/libavcodec/wmaenc.c
new file mode 100644
index 000000000..e902a6aff
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/wmaenc.c
@@ -0,0 +1,407 @@
+/*
+ * WMA compatible encoder
+ * Copyright (c) 2007 Michael Niedermayer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avcodec.h"
+#include "wma.h"
+
+#undef NDEBUG
+#include <assert.h>
+
+
+static int encode_init(AVCodecContext * avctx){
+ WMACodecContext *s = avctx->priv_data;
+ int i, flags1, flags2;
+ uint8_t *extradata;
+
+ s->avctx = avctx;
+
+ if(avctx->channels > MAX_CHANNELS)
+ return -1;
+
+ if(avctx->bit_rate < 24*1000)
+ return -1;
+
+ /* extract flag infos */
+ flags1 = 0;
+ flags2 = 1;
+ if (avctx->codec->id == CODEC_ID_WMAV1) {
+ extradata= av_malloc(4);
+ avctx->extradata_size= 4;
+ extradata[0] = flags1;
+ extradata[1] = flags1>>8;
+ extradata[2] = flags2;
+ extradata[3] = flags2>>8;
+ } else if (avctx->codec->id == CODEC_ID_WMAV2) {
+ extradata= av_mallocz(10);
+ avctx->extradata_size= 10;
+ extradata[0] = flags1;
+ extradata[1] = flags1>>8;
+ extradata[2] = flags1>>16;
+ extradata[3] = flags1>>24;
+ extradata[4] = flags2;
+ extradata[5] = flags2>>8;
+ }else
+ assert(0);
+ avctx->extradata= extradata;
+ s->use_exp_vlc = flags2 & 0x0001;
+ s->use_bit_reservoir = flags2 & 0x0002;
+ s->use_variable_block_len = flags2 & 0x0004;
+
+ ff_wma_init(avctx, flags2);
+
+ /* init MDCT */
+ for(i = 0; i < s->nb_block_sizes; i++)
+ ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0);
+
+ avctx->block_align=
+ s->block_align= avctx->bit_rate*(int64_t)s->frame_len / (avctx->sample_rate*8);
+//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", s->block_align, avctx->bit_rate, s->frame_len, avctx->sample_rate);
+ avctx->frame_size= s->frame_len;
+
+ return 0;
+}
+
+
+static void apply_window_and_mdct(AVCodecContext * avctx, 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;
+ const float * win = s->windows[window_index];
+ int window_len = 1 << s->block_len_bits;
+ float n = window_len/2;
+
+ for (channel = 0; channel < avctx->channels; channel++) {
+ memcpy(s->output, s->frame_out[channel], sizeof(float)*window_len);
+ j = channel;
+ for (i = 0; i < len; i++, j += avctx->channels){
+ s->output[i+window_len] = audio[j] / n * win[window_len - i - 1];
+ s->frame_out[channel][i] = audio[j] / n * win[i];
+ }
+ ff_mdct_calc(&s->mdct_ctx[window_index], s->coefs[channel], s->output, s->mdct_tmp);
+ }
+}
+
+//FIXME use for decoding too
+static void init_exp(WMACodecContext *s, int ch, int *exp_param){
+ int n;
+ const uint16_t *ptr;
+ float v, *q, max_scale, *q_end;
+
+ ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
+ q = s->exponents[ch];
+ q_end = q + s->block_len;
+ max_scale = 0;
+ while (q < q_end) {
+ /* XXX: use a table */
+ v = pow(10, *exp_param++ * (1.0 / 16.0));
+ max_scale= FFMAX(max_scale, v);
+ n = *ptr++;
+ do {
+ *q++ = v;
+ } while (--n);
+ }
+ s->max_exponent[ch] = max_scale;
+}
+
+static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param){
+ int last_exp;
+ const uint16_t *ptr;
+ float *q, *q_end;
+
+ ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
+ q = s->exponents[ch];
+ q_end = q + s->block_len;
+ if (s->version == 1) {
+ last_exp= *exp_param++;
+ assert(last_exp-10 >= 0 && last_exp-10 < 32);
+ put_bits(&s->pb, 5, last_exp - 10);
+ q+= *ptr++;
+ }else
+ last_exp = 36;
+ while (q < q_end) {
+ int exp = *exp_param++;
+ int code = exp - last_exp + 60;
+ assert(code >= 0 && code < 120);
+ put_bits(&s->pb, ff_wma_scale_huffbits[code], ff_wma_scale_huffcodes[code]);
+ /* XXX: use a table */
+ q+= *ptr++;
+ last_exp= exp;
+ }
+}
+
+static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], int total_gain){
+ int v, bsize, ch, coef_nb_bits, parse_exponents;
+ float mdct_norm;
+ int nb_coefs[MAX_CHANNELS];
+ static const int fixed_exp[25]={20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20};
+
+ //FIXME remove duplication relative to decoder
+ if (s->use_variable_block_len) {
+ assert(0); //FIXME not implemented
+ }else{
+ /* fixed block len */
+ s->next_block_len_bits = s->frame_len_bits;
+ s->prev_block_len_bits = s->frame_len_bits;
+ s->block_len_bits = s->frame_len_bits;
+ }
+
+ s->block_len = 1 << s->block_len_bits;
+// assert((s->block_pos + s->block_len) <= s->frame_len);
+ bsize = s->frame_len_bits - s->block_len_bits;
+
+ //FIXME factor
+ v = s->coefs_end[bsize] - s->coefs_start;
+ for(ch = 0; ch < s->nb_channels; ch++)
+ nb_coefs[ch] = v;
+ {
+ int n4 = s->block_len / 2;
+ mdct_norm = 1.0 / (float)n4;
+ if (s->version == 1) {
+ mdct_norm *= sqrt(n4);
+ }
+ }
+
+ if (s->nb_channels == 2) {
+ put_bits(&s->pb, 1, s->ms_stereo= 1);
+ }
+
+ for(ch = 0; ch < s->nb_channels; ch++) {
+ if (s->channel_coded[ch]= 1) { //FIXME
+ init_exp(s, ch, fixed_exp);
+ }
+ }
+
+ for(ch = 0; ch < s->nb_channels; ch++) {
+ if (s->channel_coded[ch]) {
+ int16_t *coefs1;
+ float *coefs, *exponents, mult;
+ int i, n;
+
+ coefs1 = s->coefs1[ch];
+ exponents = s->exponents[ch];
+ mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
+ mult *= mdct_norm;
+ coefs = src_coefs[ch];
+ if (s->use_noise_coding && 0) {
+ assert(0); //FIXME not implemented
+ } else {
+ coefs += s->coefs_start;
+ n = nb_coefs[ch];
+ for(i = 0;i < n; i++){
+ double t= *coefs++ / (exponents[i] * mult);
+ if(t<-32768 || t>32767)
+ return -1;
+
+ coefs1[i] = lrint(t);
+ }
+ }
+ }
+ }
+
+ v = 0;
+ for(ch = 0; ch < s->nb_channels; ch++) {
+ int a = s->channel_coded[ch];
+ put_bits(&s->pb, 1, a);
+ v |= a;
+ }
+
+ if (!v)
+ return 1;
+
+ for(v= total_gain-1; v>=127; v-= 127)
+ put_bits(&s->pb, 7, 127);
+ put_bits(&s->pb, 7, v);
+
+ coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
+
+ if (s->use_noise_coding) {
+ for(ch = 0; ch < s->nb_channels; ch++) {
+ if (s->channel_coded[ch]) {
+ int i, n;
+ n = s->exponent_high_sizes[bsize];
+ for(i=0;i<n;i++) {
+ put_bits(&s->pb, 1, s->high_band_coded[ch][i]= 0);
+ if (0)
+ nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
+ }
+ }
+ }
+ }
+
+ parse_exponents = 1;
+ if (s->block_len_bits != s->frame_len_bits) {
+ put_bits(&s->pb, 1, parse_exponents);
+ }
+
+ if (parse_exponents) {
+ for(ch = 0; ch < s->nb_channels; ch++) {
+ if (s->channel_coded[ch]) {
+ if (s->use_exp_vlc) {
+ encode_exp_vlc(s, ch, fixed_exp);
+ } else {
+ assert(0); //FIXME not implemented
+// encode_exp_lsp(s, ch);
+ }
+ }
+ }
+ } else {
+ assert(0); //FIXME not implemented
+ }
+
+ for(ch = 0; ch < s->nb_channels; ch++) {
+ if (s->channel_coded[ch]) {
+ int run, tindex;
+ int16_t *ptr, *eptr;
+ tindex = (ch == 1 && s->ms_stereo);
+ ptr = &s->coefs1[ch][0];
+ eptr = ptr + nb_coefs[ch];
+
+ run=0;
+ for(;ptr < eptr; ptr++){
+ if(*ptr){
+ int level= *ptr;
+ int abs_level= FFABS(level);
+ int code= 0;
+ if(abs_level <= s->coef_vlcs[tindex]->max_level){
+ if(run < s->coef_vlcs[tindex]->levels[abs_level-1])
+ code= run + s->int_table[tindex][abs_level-1];
+ }
+
+ assert(code < s->coef_vlcs[tindex]->n);
+ put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[code], s->coef_vlcs[tindex]->huffcodes[code]);
+
+ if(code == 0){
+ if(1<<coef_nb_bits <= abs_level)
+ return -1;
+
+ put_bits(&s->pb, coef_nb_bits, abs_level);
+ put_bits(&s->pb, s->frame_len_bits, run);
+ }
+ put_bits(&s->pb, 1, level < 0); //FIXME the sign is fliped somewhere
+ run=0;
+ }else{
+ run++;
+ }
+ }
+ if(run)
+ put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]);
+ }
+ if (s->version == 1 && s->nb_channels >= 2) {
+ align_put_bits(&s->pb);
+ }
+ }
+ return 0;
+}
+
+static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], uint8_t *buf, int buf_size, int total_gain){
+ init_put_bits(&s->pb, buf, buf_size);
+
+ if (s->use_bit_reservoir) {
+ assert(0);//FIXME not implemented
+ }else{
+ if(encode_block(s, src_coefs, total_gain) < 0)
+ return INT_MAX;
+ }
+
+ align_put_bits(&s->pb);
+
+ return put_bits_count(&s->pb)/8 - s->block_align;
+}
+
+static int encode_superframe(AVCodecContext *avctx,
+ unsigned char *buf, int buf_size, void *data){
+ WMACodecContext *s = avctx->priv_data;
+ short *samples = data;
+ int i, total_gain, best;
+
+ s->block_len_bits= s->frame_len_bits; //required by non variable block len
+ s->block_len = 1 << s->block_len_bits;
+
+ apply_window_and_mdct(avctx, samples, avctx->frame_size);
+
+ if (s->ms_stereo) {
+ float a, b;
+ int i;
+
+ for(i = 0; i < s->block_len; i++) {
+ a = s->coefs[0][i]*0.5;
+ b = s->coefs[1][i]*0.5;
+ s->coefs[0][i] = a + b;
+ s->coefs[1][i] = a - b;
+ }
+ }
+
+#if 1
+ total_gain= 128;
+ for(i=64; i; i>>=1){
+ int error= encode_frame(s, s->coefs, buf, buf_size, total_gain-i);
+ if(error<0)
+ total_gain-= i;
+ }
+#else
+ total_gain= 90;
+ best= encode_frame(s, s->coefs, buf, buf_size, total_gain);
+ for(i=32; i; i>>=1){
+ int scoreL= encode_frame(s, s->coefs, buf, buf_size, total_gain-i);
+ int scoreR= encode_frame(s, s->coefs, buf, buf_size, total_gain+i);
+ av_log(NULL, AV_LOG_ERROR, "%d %d %d (%d)\n", scoreL, best, scoreR, total_gain);
+ if(scoreL < FFMIN(best, scoreR)){
+ best = scoreL;
+ total_gain -= i;
+ }else if(scoreR < best){
+ best = scoreR;
+ total_gain += i;
+ }
+ }
+#endif
+
+ encode_frame(s, s->coefs, buf, buf_size, total_gain);
+ assert((put_bits_count(&s->pb) & 7) == 0);
+ i= s->block_align - (put_bits_count(&s->pb)+7)/8;
+ assert(i>=0);
+ while(i--)
+ put_bits(&s->pb, 8, 'N');
+
+ flush_put_bits(&s->pb);
+ return pbBufPtr(&s->pb) - s->pb.buf;
+}
+
+AVCodec wmav1_encoder =
+{
+ "wmav1",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_WMAV1,
+ sizeof(WMACodecContext),
+ encode_init,
+ encode_superframe,
+ ff_wma_end,
+};
+
+AVCodec wmav2_encoder =
+{
+ "wmav2",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_WMAV2,
+ sizeof(WMACodecContext),
+ encode_init,
+ encode_superframe,
+ ff_wma_end,
+};
diff --git a/contrib/ffmpeg/libavcodec/wmv2.c b/contrib/ffmpeg/libavcodec/wmv2.c
index 5abc51775..d57eaa5e4 100644
--- a/contrib/ffmpeg/libavcodec/wmv2.c
+++ b/contrib/ffmpeg/libavcodec/wmv2.c
@@ -641,8 +641,14 @@ void ff_mspel_motion(MpegEncContext *s,
/* WARNING: do no forget half pels */
v_edge_pos = s->v_edge_pos;
- src_x = clip(src_x, -16, s->width);
- src_y = clip(src_y, -16, s->height);
+ src_x = av_clip(src_x, -16, s->width);
+ src_y = av_clip(src_y, -16, s->height);
+
+ if(src_x<=-16 || src_x >= s->width)
+ dxy &= ~3;
+ if(src_y<=-16 || src_y >= s->height)
+ dxy &= ~4;
+
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0] + (src_y * linesize) + src_x;
@@ -682,10 +688,10 @@ void ff_mspel_motion(MpegEncContext *s,
src_x = s->mb_x * 8 + mx;
src_y = s->mb_y * 8 + my;
- src_x = clip(src_x, -8, s->width >> 1);
+ src_x = av_clip(src_x, -8, s->width >> 1);
if (src_x == (s->width >> 1))
dxy &= ~1;
- src_y = clip(src_y, -8, s->height >> 1);
+ src_y = av_clip(src_y, -8, s->height >> 1);
if (src_y == (s->height >> 1))
dxy &= ~2;
offset = (src_y * uvlinesize) + src_x;
diff --git a/contrib/ffmpeg/libavcodec/ws-snd1.c b/contrib/ffmpeg/libavcodec/ws-snd1.c
index eb4fe81d3..3624909a3 100644
--- a/contrib/ffmpeg/libavcodec/ws-snd1.c
+++ b/contrib/ffmpeg/libavcodec/ws-snd1.c
@@ -57,9 +57,9 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
if (!buf_size)
return 0;
- out_size = LE_16(&buf[0]);
+ out_size = AV_RL16(&buf[0]);
*data_size = out_size * 2;
- in_size = LE_16(&buf[2]);
+ in_size = AV_RL16(&buf[2]);
buf += 4;
if (in_size == out_size) {
diff --git a/contrib/ffmpeg/libavcodec/x264.c b/contrib/ffmpeg/libavcodec/x264.c
index b08678779..c9df820f5 100644
--- a/contrib/ffmpeg/libavcodec/x264.c
+++ b/contrib/ffmpeg/libavcodec/x264.c
@@ -225,6 +225,7 @@ X264_init(AVCodecContext *avctx)
x4->params.analyse.i_me_range = avctx->me_range;
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
+ x4->params.analyse.b_bidir_me = (avctx->bidir_refine > 0);
x4->params.analyse.b_bframe_rdo = (avctx->flags2 & CODEC_FLAG2_BRDO);
x4->params.analyse.b_mixed_references =
(avctx->flags2 & CODEC_FLAG2_MIXED_REFS);
diff --git a/contrib/ffmpeg/libavcodec/xan.c b/contrib/ffmpeg/libavcodec/xan.c
index 56ce87a95..f697514a0 100644
--- a/contrib/ffmpeg/libavcodec/xan.c
+++ b/contrib/ffmpeg/libavcodec/xan.c
@@ -296,10 +296,10 @@ static void xan_wc3_decode_frame(XanContext *s) {
unsigned char *vector_segment;
unsigned char *imagedata_segment;
- huffman_segment = s->buf + LE_16(&s->buf[0]);
- size_segment = s->buf + LE_16(&s->buf[2]);
- vector_segment = s->buf + LE_16(&s->buf[4]);
- imagedata_segment = s->buf + LE_16(&s->buf[6]);
+ huffman_segment = s->buf + AV_RL16(&s->buf[0]);
+ size_segment = s->buf + AV_RL16(&s->buf[2]);
+ vector_segment = s->buf + AV_RL16(&s->buf[4]);
+ imagedata_segment = s->buf + AV_RL16(&s->buf[6]);
xan_huffman_decode(opcode_buffer, huffman_segment, opcode_buffer_size);
@@ -350,7 +350,7 @@ static void xan_wc3_decode_frame(XanContext *s) {
case 10:
case 20:
- size = BE_16(&size_segment[0]);
+ size = AV_RB16(&size_segment[0]);
size_segment += 2;
break;
diff --git a/contrib/ffmpeg/libavcodec/xiph.c b/contrib/ffmpeg/libavcodec/xiph.c
new file mode 100644
index 000000000..65c9d5603
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/xiph.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2007 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
+ */
+
+#include "xiph.h"
+
+int ff_split_xiph_headers(uint8_t *extradata, int extradata_size,
+ int first_header_size, uint8_t *header_start[3],
+ int header_len[3])
+{
+ int i, j;
+
+ if (AV_RB16(extradata) == first_header_size) {
+ for (i=0; i<3; i++) {
+ header_len[i] = AV_RB16(extradata);
+ extradata += 2;
+ header_start[i] = extradata;
+ extradata += header_len[i];
+ }
+ } else if (extradata[0] == 2) {
+ for (i=0,j=1; i<2; i++,j++) {
+ header_len[i] = 0;
+ for (; j<extradata_size && extradata[j]==0xff; j++) {
+ header_len[i] += 0xff;
+ }
+ if (j >= extradata_size)
+ return -1;
+
+ header_len[i] += extradata[j];
+ }
+ header_len[2] = extradata_size - header_len[0] - header_len[1] - j;
+ extradata += j;
+ header_start[0] = extradata;
+ header_start[1] = header_start[0] + header_len[0];
+ header_start[2] = header_start[1] + header_len[1];
+ } else {
+ return -1;
+ }
+ return 0;
+}
diff --git a/contrib/ffmpeg/libavcodec/xiph.h b/contrib/ffmpeg/libavcodec/xiph.h
new file mode 100644
index 000000000..85cfeebaf
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/xiph.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2007 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
+ */
+
+#include "common.h"
+
+/**
+ * Splits a single extradata buffer into the three headers that most
+ * Xiph codecs use. (e.g. Theora and Vorbis)
+ * Works both with Matroska's packing and lavc's packing.
+ *
+ * @param[in] extradata The single chunk that combines all three headers
+ * @param[in] extradata_size The size of the extradata buffer
+ * @param[in] first_header_size The size of the first header, used to
+ * differentiate between the Matroska packing and lavc packing.
+ * @param[out] header_start Pointers to the start of the three separate headers.
+ * @param[out] header_len The sizes of each of the three headers.
+ * @return On error a negative value is returned, on success zero.
+ */
+int ff_split_xiph_headers(uint8_t *extradata, int extradata_size,
+ int first_header_size, uint8_t *header_start[3],
+ int header_len[3]);
diff --git a/contrib/ffmpeg/libavcodec/xl.c b/contrib/ffmpeg/libavcodec/xl.c
index 67ad237e1..8a011d887 100644
--- a/contrib/ffmpeg/libavcodec/xl.c
+++ b/contrib/ffmpeg/libavcodec/xl.c
@@ -73,7 +73,7 @@ static int decode_frame(AVCodecContext *avctx,
for (j = 0; j < avctx->width; j += 4) {
/* value is stored in LE dword with word swapped */
- val = LE_32(buf);
+ val = AV_RL32(buf);
buf -= 4;
val = ((val >> 16) & 0xFFFF) | ((val & 0xFFFF) << 16);
diff --git a/contrib/ffmpeg/xvmc_render.h b/contrib/ffmpeg/libavcodec/xvmc_render.h
index 82dfeb0b8..37b342294 100644
--- a/contrib/ffmpeg/xvmc_render.h
+++ b/contrib/ffmpeg/libavcodec/xvmc_render.h
@@ -10,6 +10,8 @@
#define MP_XVMC_STATE_DISPLAY_PENDING 1
//the surface is needed for prediction, codec manipulate this
#define MP_XVMC_STATE_PREDICTION 2
+//this surface is needed for subpicture rendering
+#define MP_XVMC_STATE_OSD_SOURCE 4
// 1337 IDCT MCo
#define MP_XVMC_RENDER_MAGIC 0x1DC711C0
@@ -25,7 +27,6 @@ typedef struct{
int idct;//does we use IDCT acceleration?
int chroma_format;//420,422,444
int unsigned_intra;//+-128 for intra pictures after clip
- int reserved1[13];//future extenstions (e.g. gmc,qpel)
XvMCSurface* p_surface;//pointer to rendered surface, never changed
//these are changed by decoder
@@ -43,5 +44,7 @@ typedef struct{
int filled_mv_blocks_num;//processed mv block in this slice,change by decoder
int next_free_data_block_num;//used in add_mv_block, pointer to next free block
+//extensions
+ void * p_osd_target_surface_render;//pointer to the surface where subpicture is rendered
} xvmc_render_state_t;
diff --git a/contrib/ffmpeg/libavcodec/zmbv.c b/contrib/ffmpeg/libavcodec/zmbv.c
index fe3745e09..89b8418c5 100644
--- a/contrib/ffmpeg/libavcodec/zmbv.c
+++ b/contrib/ffmpeg/libavcodec/zmbv.c
@@ -545,7 +545,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
case ZMBV_FMT_15BPP:
for(j = 0; j < c->height; j++) {
for(i = 0; i < c->width; i++) {
- uint16_t tmp = LE_16(src);
+ uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
@@ -557,7 +557,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
case ZMBV_FMT_16BPP:
for(j = 0; j < c->height; j++) {
for(i = 0; i < c->width; i++) {
- uint16_t tmp = LE_16(src);
+ uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0xF800) >> 8;
out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
@@ -578,7 +578,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
case ZMBV_FMT_32BPP:
for(j = 0; j < c->height; j++) {
for(i = 0; i < c->width; i++) {
- uint32_t tmp = LE_32(src);
+ uint32_t tmp = AV_RL32(src);
src += 4;
out[i * 3 + 0] = tmp >> 16;
out[i * 3 + 1] = tmp >> 8;
@@ -612,7 +612,6 @@ static int decode_init(AVCodecContext *avctx)
int zret; // Zlib return code
c->avctx = avctx;
- avctx->has_b_frames = 0;
c->pic.data[0] = NULL;
c->width = avctx->width;
diff --git a/contrib/ffmpeg/libavcodec/zmbvenc.c b/contrib/ffmpeg/libavcodec/zmbvenc.c
new file mode 100644
index 000000000..a79964449
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/zmbvenc.c
@@ -0,0 +1,328 @@
+/*
+ * Zip Motion Blocks Video (ZMBV) encoder
+ * Copyright (c) 2006 Konstantin Shishkov
+ *
+ * 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 zmbvenc.c
+ * Zip Motion Blocks Video encoder
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "common.h"
+#include "avcodec.h"
+
+#include <zlib.h>
+
+#define ZMBV_KEYFRAME 1
+#define ZMBV_DELTAPAL 2
+
+#define ZMBV_BLOCK 16
+
+/**
+ * Encoder context
+ */
+typedef struct ZmbvEncContext {
+ AVCodecContext *avctx;
+ AVFrame pic;
+
+ int range;
+ uint8_t *comp_buf, *work_buf;
+ uint8_t pal[768];
+ uint32_t pal2[256]; //for quick comparisons
+ uint8_t *prev;
+ int pstride;
+ int comp_size;
+ int keyint, curfrm;
+ z_stream zstream;
+} ZmbvEncContext;
+
+/** Block comparing function
+ * XXX should be optimized and moved to DSPContext
+ * TODO handle out of edge ME
+ */
+static inline int block_cmp(uint8_t *src, int stride, uint8_t *src2, int stride2, int bw, int bh)
+{
+ int sum = 0;
+ int i, j;
+
+ for(j = 0; j < bh; j++){
+ for(i = 0; i < bw; i++)
+ sum += src[i] ^ src2[i];
+ src += stride;
+ src2 += stride2;
+ }
+ return sum;
+}
+
+/** Motion estimation function
+ * TODO make better ME decisions
+ */
+static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev, int pstride,
+ int x, int y, int *mx, int *my)
+{
+ int dx, dy, tx, ty, tv, bv, bw, bh;
+
+ *mx = *my = 0;
+ bw = FFMIN(ZMBV_BLOCK, c->avctx->width - x);
+ bh = FFMIN(ZMBV_BLOCK, c->avctx->height - y);
+ bv = block_cmp(src, sstride, prev, pstride, bw, bh);
+ if(!bv) return 0;
+ for(ty = FFMAX(y - c->range, 0); ty < FFMIN(y + c->range, c->avctx->height - bh); ty++){
+ for(tx = FFMAX(x - c->range, 0); tx < FFMIN(x + c->range, c->avctx->width - bw); tx++){
+ if(tx == x && ty == y) continue; // we already tested this block
+ dx = tx - x;
+ dy = ty - y;
+ tv = block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh);
+ if(tv < bv){
+ bv = tv;
+ *mx = dx;
+ *my = dy;
+ if(!bv) return 0;
+ }
+ }
+ }
+ return bv;
+}
+
+static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data)
+{
+ ZmbvEncContext * const c = (ZmbvEncContext *)avctx->priv_data;
+ AVFrame *pict = data;
+ AVFrame * const p = &c->pic;
+ uint8_t *src, *prev;
+ uint32_t *palptr;
+ int zret = Z_OK;
+ int len = 0;
+ int keyframe, chpal;
+ int fl;
+ int work_size = 0;
+ int bw, bh;
+ int i, j;
+
+ keyframe = !c->curfrm;
+ c->curfrm++;
+ if(c->curfrm == c->keyint)
+ c->curfrm = 0;
+ *p = *pict;
+ p->pict_type= keyframe ? FF_I_TYPE : FF_P_TYPE;
+ p->key_frame= keyframe;
+ chpal = !keyframe && memcmp(p->data[1], c->pal2, 1024);
+
+ fl = (keyframe ? ZMBV_KEYFRAME : 0) | (chpal ? ZMBV_DELTAPAL : 0);
+ *buf++ = fl; len++;
+ if(keyframe){
+ deflateReset(&c->zstream);
+ *buf++ = 0; len++; // hi ver
+ *buf++ = 1; len++; // lo ver
+ *buf++ = 1; len++; // comp
+ *buf++ = 4; len++; // format - 8bpp
+ *buf++ = ZMBV_BLOCK; len++; // block width
+ *buf++ = ZMBV_BLOCK; len++; // block height
+ }
+ palptr = (uint32_t*)p->data[1];
+ src = p->data[0];
+ prev = c->prev;
+ if(chpal){
+ uint8_t tpal[3];
+ for(i = 0; i < 256; i++){
+ tpal[0] = palptr[i] >> 16;
+ tpal[1] = palptr[i] >> 8;
+ tpal[2] = palptr[i];
+ c->work_buf[work_size++] = tpal[0] ^ c->pal[i * 3 + 0];
+ c->work_buf[work_size++] = tpal[1] ^ c->pal[i * 3 + 1];
+ c->work_buf[work_size++] = tpal[2] ^ c->pal[i * 3 + 2];
+ c->pal[i * 3 + 0] = tpal[0];
+ c->pal[i * 3 + 1] = tpal[1];
+ c->pal[i * 3 + 2] = tpal[2];
+ }
+ memcpy(c->pal2, p->data[1], 1024);
+ }
+ if(keyframe){
+ for(i = 0; i < 256; i++){
+ c->pal[i*3 + 0] = palptr[i] >> 16;
+ c->pal[i*3 + 1] = palptr[i] >> 8;
+ c->pal[i*3 + 2] = palptr[i];
+ }
+ memcpy(c->work_buf, c->pal, 768);
+ memcpy(c->pal2, p->data[1], 1024);
+ work_size = 768;
+ for(i = 0; i < avctx->height; i++){
+ memcpy(c->work_buf + work_size, src, avctx->width);
+ src += p->linesize[0];
+ work_size += avctx->width;
+ }
+ }else{
+ int x, y, bh2, bw2;
+ uint8_t *tsrc, *tprev;
+ uint8_t *mv;
+ int mx, my, bv;
+
+ bw = (avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK;
+ bh = (avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK;
+ mv = c->work_buf + work_size;
+ memset(c->work_buf + work_size, 0, (bw * bh * 2 + 3) & ~3);
+ work_size += (bw * bh * 2 + 3) & ~3;
+ /* for now just XOR'ing */
+ for(y = 0; y < avctx->height; y += ZMBV_BLOCK) {
+ bh2 = FFMIN(avctx->height - y, ZMBV_BLOCK);
+ for(x = 0; x < avctx->width; x += ZMBV_BLOCK, mv += 2) {
+ bw2 = FFMIN(avctx->width - x, ZMBV_BLOCK);
+
+ tsrc = src + x;
+ tprev = prev + x;
+
+ bv = zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my);
+ mv[0] = (mx << 1) | !!bv;
+ mv[1] = my << 1;
+ tprev += mx + my * c->pstride;
+ if(bv){
+ for(j = 0; j < bh2; j++){
+ for(i = 0; i < bw2; i++)
+ c->work_buf[work_size++] = tsrc[i] ^ tprev[i];
+ tsrc += p->linesize[0];
+ tprev += c->pstride;
+ }
+ }
+ }
+ src += p->linesize[0] * ZMBV_BLOCK;
+ prev += c->pstride * ZMBV_BLOCK;
+ }
+ }
+ /* save the previous frame */
+ src = p->data[0];
+ prev = c->prev;
+ for(i = 0; i < avctx->height; i++){
+ memcpy(prev, src, avctx->width);
+ prev += c->pstride;
+ src += p->linesize[0];
+ }
+
+ c->zstream.next_in = c->work_buf;
+ c->zstream.avail_in = work_size;
+ c->zstream.total_in = 0;
+
+ c->zstream.next_out = c->comp_buf;
+ c->zstream.avail_out = c->comp_size;
+ c->zstream.total_out = 0;
+ if((zret = deflate(&c->zstream, Z_SYNC_FLUSH)) != Z_OK){
+ av_log(avctx, AV_LOG_ERROR, "Error compressing data\n");
+ return -1;
+ }
+
+ memcpy(buf, c->comp_buf, c->zstream.total_out);
+ return len + c->zstream.total_out;
+}
+
+
+/**
+ * Init zmbv encoder
+ */
+static int encode_init(AVCodecContext *avctx)
+{
+ ZmbvEncContext * const c = (ZmbvEncContext *)avctx->priv_data;
+ int zret; // Zlib return code
+ int lvl = 9;
+
+ c->avctx = avctx;
+
+ c->pic.data[0] = NULL;
+ c->curfrm = 0;
+ c->keyint = avctx->keyint_min;
+ c->range = 8;
+ if(avctx->me_range > 0)
+ c->range = FFMIN(avctx->me_range, 127);
+
+ if(avctx->compression_level >= 0)
+ lvl = avctx->compression_level;
+ if(lvl < 0 || lvl > 9){
+ av_log(avctx, AV_LOG_ERROR, "Compression level should be 0-9, not %i\n", lvl);
+ return -1;
+ }
+
+ if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
+ return -1;
+ }
+
+ // Needed if zlib unused or init aborted before deflateInit
+ memset(&(c->zstream), 0, sizeof(z_stream));
+ c->comp_size = avctx->width * avctx->height + 1024 +
+ ((avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4;
+ if ((c->work_buf = av_malloc(c->comp_size)) == NULL) {
+ av_log(avctx, AV_LOG_ERROR, "Can't allocate work buffer.\n");
+ return -1;
+ }
+ /* Conservative upper bound taken from zlib v1.2.1 source via lcl.c */
+ c->comp_size = c->comp_size + ((c->comp_size + 7) >> 3) +
+ ((c->comp_size + 63) >> 6) + 11;
+
+ /* Allocate compression buffer */
+ if ((c->comp_buf = av_malloc(c->comp_size)) == NULL) {
+ av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n");
+ return -1;
+ }
+ c->pstride = (avctx->width + 15) & ~15;
+ if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) {
+ av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n");
+ return -1;
+ }
+
+ c->zstream.zalloc = Z_NULL;
+ c->zstream.zfree = Z_NULL;
+ c->zstream.opaque = Z_NULL;
+ zret = deflateInit(&(c->zstream), lvl);
+ if (zret != Z_OK) {
+ av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
+/**
+ * Uninit zmbv encoder
+ */
+static int encode_end(AVCodecContext *avctx)
+{
+ ZmbvEncContext * const c = (ZmbvEncContext *)avctx->priv_data;
+
+ av_freep(&c->comp_buf);
+ av_freep(&c->work_buf);
+
+ deflateEnd(&(c->zstream));
+ av_freep(&c->prev);
+
+ return 0;
+}
+
+AVCodec zmbv_encoder = {
+ "zmbv",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_ZMBV,
+ sizeof(ZmbvEncContext),
+ encode_init,
+ encode_frame,
+ encode_end,
+ .pix_fmts = (enum PixelFormat[]){PIX_FMT_PAL8, -1},
+};
diff --git a/contrib/ffmpeg/libavformat/4xm.c b/contrib/ffmpeg/libavformat/4xm.c
index 12e7d9ee4..bf10b9e82 100644
--- a/contrib/ffmpeg/libavformat/4xm.c
+++ b/contrib/ffmpeg/libavformat/4xm.c
@@ -82,8 +82,8 @@ static int fourxm_probe(AVProbeData *p)
if (p->buf_size < 12)
return 0;
- if ((LE_32(&p->buf[0]) != RIFF_TAG) ||
- (LE_32(&p->buf[8]) != _4XMV_TAG))
+ if ((AV_RL32(&p->buf[0]) != RIFF_TAG) ||
+ (AV_RL32(&p->buf[8]) != _4XMV_TAG))
return 0;
return AVPROBE_SCORE_MAX;
@@ -125,19 +125,19 @@ static int fourxm_read_header(AVFormatContext *s,
/* take the lazy approach and search for any and all vtrk and strk chunks */
for (i = 0; i < header_size - 8; i++) {
- fourcc_tag = LE_32(&header[i]);
- size = LE_32(&header[i + 4]);
+ fourcc_tag = AV_RL32(&header[i]);
+ size = AV_RL32(&header[i + 4]);
if (fourcc_tag == std__TAG) {
- fourxm->fps = av_int2flt(LE_32(&header[i + 12]));
+ fourxm->fps = av_int2flt(AV_RL32(&header[i + 12]));
} else if (fourcc_tag == vtrk_TAG) {
/* check that there is enough data */
if (size != vtrk_SIZE) {
av_free(header);
return AVERROR_INVALIDDATA;
}
- fourxm->width = LE_32(&header[i + 36]);
- fourxm->height = LE_32(&header[i + 40]);
+ fourxm->width = AV_RL32(&header[i + 36]);
+ fourxm->height = AV_RL32(&header[i + 40]);
i += 8 + size;
/* allocate a new AVStream */
@@ -160,7 +160,7 @@ static int fourxm_read_header(AVFormatContext *s,
av_free(header);
return AVERROR_INVALIDDATA;
}
- current_track = LE_32(&header[i + 8]);
+ current_track = AV_RL32(&header[i + 8]);
if (current_track + 1 > fourxm->track_count) {
fourxm->track_count = current_track + 1;
if((unsigned)fourxm->track_count >= UINT_MAX / sizeof(AudioTrack))
@@ -172,10 +172,10 @@ static int fourxm_read_header(AVFormatContext *s,
return AVERROR_NOMEM;
}
}
- fourxm->tracks[current_track].adpcm = LE_32(&header[i + 12]);
- fourxm->tracks[current_track].channels = LE_32(&header[i + 36]);
- fourxm->tracks[current_track].sample_rate = LE_32(&header[i + 40]);
- fourxm->tracks[current_track].bits = LE_32(&header[i + 44]);
+ fourxm->tracks[current_track].adpcm = AV_RL32(&header[i + 12]);
+ fourxm->tracks[current_track].channels = AV_RL32(&header[i + 36]);
+ fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]);
+ fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]);
i += 8 + size;
/* allocate a new AVStream */
@@ -235,8 +235,8 @@ static int fourxm_read_packet(AVFormatContext *s,
if ((ret = get_buffer(&s->pb, header, 8)) < 0)
return ret;
- fourcc_tag = LE_32(&header[0]);
- size = LE_32(&header[4]);
+ fourcc_tag = AV_RL32(&header[0]);
+ size = AV_RL32(&header[4]);
if (url_feof(pb))
return AVERROR_IO;
switch (fourcc_tag) {
diff --git a/contrib/ffmpeg/libavformat/Makefile b/contrib/ffmpeg/libavformat/Makefile
index fd2ac2a29..f1339bd9d 100644
--- a/contrib/ffmpeg/libavformat/Makefile
+++ b/contrib/ffmpeg/libavformat/Makefile
@@ -29,9 +29,12 @@ OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o riff.o
OBJS-$(CONFIG_CRC_MUXER) += crc.o
OBJS-$(CONFIG_FRAMECRC_MUXER) += crc.o
OBJS-$(CONFIG_DAUD_DEMUXER) += daud.o
+OBJS-$(CONFIG_DC1394_DEMUXER) += dc1394.o
OBJS-$(CONFIG_DSICIN_DEMUXER) += dsicin.o
OBJS-$(CONFIG_DV_DEMUXER) += dv.o
OBJS-$(CONFIG_DV_MUXER) += dvenc.o
+OBJS-$(CONFIG_DV1394_DEMUXER) += dv1394.o
+OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o
OBJS-$(CONFIG_EA_DEMUXER) += electronicarts.o
OBJS-$(CONFIG_FFM_DEMUXER) += ffm.o
OBJS-$(CONFIG_FFM_MUXER) += ffm.o
@@ -41,6 +44,7 @@ OBJS-$(CONFIG_FLV_MUXER) += flvenc.o
OBJS-$(CONFIG_GIF_MUXER) += gif.o
OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o
OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o
+OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o
OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o
OBJS-$(CONFIG_ROQ_DEMUXER) += idroq.o
OBJS-$(CONFIG_IMAGE2_DEMUXER) += img2.o
@@ -54,7 +58,6 @@ OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o riff.o
OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o
OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o
OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o
-OBJS-$(CONFIG_MTV_DEMUXER) += mtv.o
OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o isom.o
OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o isom.o
OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o isom.o
@@ -62,6 +65,7 @@ OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o isom.o
OBJS-$(CONFIG_MP3_DEMUXER) += mp3.o
OBJS-$(CONFIG_MP2_MUXER) += mp3.o
OBJS-$(CONFIG_MP3_MUXER) += mp3.o
+OBJS-$(CONFIG_MPC_DEMUXER) += mpc.o
OBJS-$(CONFIG_MPEG1SYSTEM_MUXER) += mpeg.o
OBJS-$(CONFIG_MPEG1VCD_MUXER) += mpeg.o
OBJS-$(CONFIG_MPEG2VOB_MUXER) += mpeg.o
@@ -71,6 +75,7 @@ OBJS-$(CONFIG_MPEGPS_DEMUXER) += mpeg.o
OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpegts.o
OBJS-$(CONFIG_MPEGTS_MUXER) += mpegtsenc.o
OBJS-$(CONFIG_MPJPEG_MUXER) += mpjpeg.o
+OBJS-$(CONFIG_MTV_DEMUXER) += mtv.o
OBJS-$(CONFIG_MXF_DEMUXER) += mxf.o
OBJS-$(CONFIG_NSV_DEMUXER) += nsvdec.o riff.o
OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o riff.o
@@ -80,6 +85,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += ogg2.o \
oggparseflac.o \
oggparseogm.o \
riff.o
+OBJS-$(CONFIG_OGG_MUXER) += ogg.o
OBJS-$(CONFIG_STR_DEMUXER) += psxstr.o
OBJS-$(CONFIG_SHORTEN_DEMUXER) += raw.o
OBJS-$(CONFIG_FLAC_DEMUXER) += raw.o
@@ -105,6 +111,7 @@ OBJS-$(CONFIG_MJPEG_MUXER) += raw.o
OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += raw.o
OBJS-$(CONFIG_RAWVIDEO_MUXER) += raw.o
OBJS-$(CONFIG_NULL_MUXER) += raw.o
+OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o riff.o
OBJS-$(CONFIG_RM_DEMUXER) += rm.o
OBJS-$(CONFIG_RM_MUXER) += rm.o
OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o
@@ -113,8 +120,10 @@ OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o
OBJS-$(CONFIG_SOL_DEMUXER) += sol.o
OBJS-$(CONFIG_SWF_DEMUXER) += swf.o
OBJS-$(CONFIG_SWF_MUXER) += swf.o
+OBJS-$(CONFIG_THP_DEMUXER) += thp.o
OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER) += tiertexseq.o
OBJS-$(CONFIG_TTA_DEMUXER) += tta.o
+OBJS-$(CONFIG_V4L2_DEMUXER) += v4l2.o
OBJS-$(CONFIG_VOC_DEMUXER) += vocdec.o voc.o riff.o
OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o riff.o
OBJS-$(CONFIG_WAV_DEMUXER) += wav.o riff.o
@@ -123,31 +132,24 @@ OBJS-$(CONFIG_WC3_DEMUXER) += wc3movie.o
OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o
OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o
OBJS-$(CONFIG_WV_DEMUXER) += wv.o
+OBJS-$(CONFIG_X11_GRAB_DEVICE_DEMUXER) += x11grab.o
OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o
OBJS-$(CONFIG_YUV4MPEGPIPE_DEMUXER) += yuv4mpeg.o
+# external libraries
+OBJS-$(CONFIG_LIBNUT_DEMUXER) += libnut.o riff.o
+OBJS-$(CONFIG_LIBNUT_MUXER) += libnut.o riff.o
+
OBJS+= framehook.o
-ifeq ($(CONFIG_VIDEO4LINUX),yes)
+ifeq ($(CONFIG_V4L),yes)
OBJS-$(CONFIG_VIDEO_GRAB_DEVICE_DEMUXER) += grab.o
endif
-ifeq ($(CONFIG_VIDEO4LINUX2),yes)
-OBJS-$(CONFIG_V4L2_DEMUXER) += v4l2.o
-endif
-
ifeq ($(CONFIG_BKTR),yes)
OBJS-$(CONFIG_VIDEO_GRAB_DEVICE_DEMUXER) += grab_bktr.o
endif
-ifeq ($(CONFIG_DV1394),yes)
-OBJS-$(CONFIG_DV1394_DEMUXER) += dv1394.o
-endif
-
-ifeq ($(CONFIG_DC1394),yes)
-OBJS-$(CONFIG_DC1394_DEMUXER) += dc1394.o
-endif
-
ifeq ($(CONFIG_AUDIO_OSS),yes)
OBJS-$(CONFIG_AUDIO_DEMUXER) += audio.o
OBJS-$(CONFIG_AUDIO_MUXER) += audio.o
@@ -166,32 +168,12 @@ OBJS+= avio.o aviobuf.o
ifeq ($(CONFIG_PROTOCOLS),yes)
OBJS+= file.o
ifeq ($(CONFIG_NETWORK),yes)
-OBJS+= udp.o tcp.o http.o rtsp.o rtp.o rtpproto.o mpegts.o base64.o rtp_h264.o
-endif
-endif
-
-ifeq ($(CONFIG_LIBNUT),yes)
-OBJS-$(CONFIG_NUT_DEMUXER) += libnut.o riff.o
-OBJS-$(CONFIG_NUT_MUXER) += libnut.o riff.o
-else
-OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o riff.o
-#OBJS-$(CONFIG_NUT_MUXER) += nutenc.o riff.o
+OBJS+= udp.o tcp.o http.o rtsp.o rtp.o rtpproto.o mpegts.o rtp_h264.o
endif
-
-ifeq ($(CONFIG_LIBOGG),yes)
-OBJS-$(CONFIG_OGG_MUXER) += ogg.o
endif
-ifeq ($(CONFIG_GPL),yes)
-OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o
-endif
-
-OBJS += $(OBJS-yes)
-
NAME=avformat
-ifeq ($(BUILD_SHARED),yes)
LIBVERSION=$(LAVFVERSION)
LIBMAJOR=$(LAVFMAJOR)
-endif
include ../common.mak
diff --git a/contrib/ffmpeg/libavformat/aiff.c b/contrib/ffmpeg/libavformat/aiff.c
index e4cf66c3b..868d55219 100644
--- a/contrib/ffmpeg/libavformat/aiff.c
+++ b/contrib/ffmpeg/libavformat/aiff.c
@@ -23,7 +23,7 @@
#include "riff.h"
#include "intfloat_readwrite.h"
-static const CodecTag codec_aiff_tags[] = {
+static const AVCodecTag codec_aiff_tags[] = {
{ CODEC_ID_PCM_S16BE, MKTAG('N','O','N','E') },
{ CODEC_ID_PCM_S8, MKTAG('N','O','N','E') },
{ CODEC_ID_PCM_S24BE, MKTAG('N','O','N','E') },
@@ -91,7 +91,7 @@ static void get_meta(ByteIOContext *pb, char * str, int strsize, int size)
if (size & 1)
size++;
size -= res;
- if (size);
+ if (size)
url_fskip(pb, size);
}
@@ -163,28 +163,32 @@ static int aiff_write_header(AVFormatContext *s)
ByteIOContext *pb = &s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVExtFloat sample_rate;
+ int aifc = 0;
/* First verify if format is ok */
- enc->codec_tag = codec_get_tag(codec_aiff_tags, enc->codec_id);
if (!enc->codec_tag) {
- av_free(aiff);
return -1;
}
+ if (enc->codec_tag != MKTAG('N','O','N','E'))
+ aifc = 1;
+
/* FORM AIFF header */
put_tag(pb, "FORM");
aiff->form = url_ftell(pb);
put_be32(pb, 0); /* file length */
- put_tag(pb, "AIFC");
+ put_tag(pb, aifc ? "AIFC" : "AIFF");
- /* Version chunk */
- put_tag(pb, "FVER");
- put_be32(pb, 4);
- put_be32(pb, 0xA2805140);
+ if (aifc) {
+ /* Version chunk */
+ put_tag(pb, "FVER");
+ put_be32(pb, 4);
+ put_be32(pb, 0xA2805140);
+ }
/* Common chunk */
put_tag(pb, "COMM");
- put_be32(pb, 24); /* size */
+ put_be32(pb, aifc ? 24 : 18); /* size */
put_be16(pb, enc->channels); /* Number of channels */
aiff->frames = url_ftell(pb);
@@ -204,8 +208,10 @@ static int aiff_write_header(AVFormatContext *s)
sample_rate = av_dbl2ext((double)enc->sample_rate);
put_buffer(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
- put_le32(pb, enc->codec_tag);
- put_be16(pb, 0);
+ if (aifc) {
+ put_le32(pb, enc->codec_tag);
+ put_be16(pb, 0);
+ }
/* Sound data chunk */
put_tag(pb, "SSND");
@@ -417,6 +423,7 @@ AVInputFormat aiff_demuxer = {
aiff_read_packet,
aiff_read_close,
aiff_read_seek,
+ .codec_tag= (const AVCodecTag*[]){codec_aiff_tags, 0},
};
#endif
@@ -432,5 +439,6 @@ AVOutputFormat aiff_muxer = {
aiff_write_header,
aiff_write_packet,
aiff_write_trailer,
+ .codec_tag= (const AVCodecTag*[]){codec_aiff_tags, 0},
};
#endif
diff --git a/contrib/ffmpeg/libavformat/allformats.c b/contrib/ffmpeg/libavformat/allformats.c
index f4b16adff..8534a18f6 100644
--- a/contrib/ffmpeg/libavformat/allformats.c
+++ b/contrib/ffmpeg/libavformat/allformats.c
@@ -31,7 +31,7 @@
formats you want to support */
/**
- * Initialize libavcodec and register all the codecs and formats.
+ * Initialize libavformat and register all the (de)muxers and protocols.
*/
void av_register_all(void)
{
@@ -52,9 +52,7 @@ void av_register_all(void)
REGISTER_MUXDEMUX(ASF, asf);
REGISTER_MUXER (ASF_STREAM, asf_stream);
REGISTER_MUXDEMUX(AU, au);
-#if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_BEOS)
REGISTER_MUXDEMUX(AUDIO, audio);
-#endif
REGISTER_MUXDEMUX(AVI, avi);
#ifdef CONFIG_AVISYNTH
av_register_input_format(&avisynth_demuxer);
@@ -62,15 +60,12 @@ void av_register_all(void)
REGISTER_DEMUXER (AVS, avs);
REGISTER_MUXER (CRC, crc);
REGISTER_DEMUXER (DAUD, daud);
-#ifdef CONFIG_DC1394
REGISTER_DEMUXER (DC1394, dc1394);
-#endif
REGISTER_DEMUXER (DSICIN, dsicin);
REGISTER_DEMUXER (DTS, dts);
REGISTER_MUXDEMUX(DV, dv);
-#ifdef CONFIG_DV1394
REGISTER_DEMUXER (DV1394, dv1394);
-#endif
+ REGISTER_DEMUXER (DXA, dxa);
REGISTER_DEMUXER (EA, ea);
REGISTER_MUXDEMUX(FFM, ffm);
REGISTER_MUXDEMUX(FLAC, flac);
@@ -80,9 +75,7 @@ void av_register_all(void)
REGISTER_MUXER (FRAMECRC, framecrc);
REGISTER_MUXDEMUX(GIF, gif);
REGISTER_DEMUXER (GXF, gxf);
-#ifdef CONFIG_GPL
REGISTER_MUXER (GXF, gxf);
-#endif
REGISTER_MUXDEMUX(H261, h261);
REGISTER_MUXDEMUX(H263, h263);
REGISTER_MUXDEMUX(H264, h264);
@@ -91,6 +84,8 @@ void av_register_all(void)
REGISTER_MUXDEMUX(IMAGE2PIPE, image2pipe);
REGISTER_DEMUXER (INGENIENT, ingenient);
REGISTER_DEMUXER (IPMOVIE, ipmovie);
+ if (!ENABLE_NUT_DEMUXER) REGISTER_DEMUXER (LIBNUT, libnut);
+ REGISTER_MUXER (LIBNUT, libnut);
REGISTER_MUXDEMUX(M4V, m4v);
REGISTER_DEMUXER (MATROSKA, matroska);
REGISTER_MUXDEMUX(MJPEG, mjpeg);
@@ -100,6 +95,7 @@ void av_register_all(void)
REGISTER_MUXER (MP2, mp2);
REGISTER_MUXDEMUX(MP3, mp3);
REGISTER_MUXER (MP4, mp4);
+ REGISTER_DEMUXER (MPC, mpc);
REGISTER_MUXER (MPEG1SYSTEM, mpeg1system);
REGISTER_MUXER (MPEG1VCD, mpeg1vcd);
REGISTER_MUXER (MPEG1VIDEO, mpeg1video);
@@ -116,14 +112,9 @@ void av_register_all(void)
REGISTER_DEMUXER (NSV, nsv);
REGISTER_MUXER (NULL, null);
REGISTER_DEMUXER (NUT, nut);
-#ifdef CONFIG_LIBNUT
- REGISTER_MUXER (NUT, nut);
-#endif
REGISTER_DEMUXER (NUV, nuv);
REGISTER_DEMUXER (OGG, ogg);
-#ifdef CONFIG_LIBOGG
REGISTER_MUXER (OGG, ogg);
-#endif
REGISTER_MUXDEMUX(PCM_ALAW, pcm_alaw);
REGISTER_MUXDEMUX(PCM_MULAW, pcm_mulaw);
REGISTER_MUXDEMUX(PCM_S16BE, pcm_s16be);
@@ -136,11 +127,11 @@ void av_register_all(void)
REGISTER_MUXDEMUX(RAWVIDEO, rawvideo);
REGISTER_MUXDEMUX(RM, rm);
REGISTER_DEMUXER (ROQ, roq);
-#ifdef CONFIG_NETWORK
REGISTER_DEMUXER (REDIR, redir);
REGISTER_MUXER (RTP, rtp);
REGISTER_DEMUXER (RTSP, rtsp);
REGISTER_DEMUXER (SDP, sdp);
+#ifdef CONFIG_NETWORK
av_register_rtp_dynamic_payload_handlers();
#endif
REGISTER_DEMUXER (SEGAFILM, segafilm);
@@ -151,14 +142,12 @@ void av_register_all(void)
REGISTER_MUXDEMUX(SWF, swf);
REGISTER_MUXER (TG2, tg2);
REGISTER_MUXER (TGP, tgp);
+ REGISTER_DEMUXER (THP, thp);
REGISTER_DEMUXER (TIERTEXSEQ, tiertexseq);
REGISTER_DEMUXER (TTA, tta);
-#ifdef CONFIG_VIDEO4LINUX2
REGISTER_DEMUXER (V4L2, v4l2);
-#endif
-#if defined(CONFIG_VIDEO4LINUX) || defined(CONFIG_BKTR)
+ REGISTER_DEMUXER (VC1, vc1);
REGISTER_DEMUXER (VIDEO_GRAB_DEVICE, video_grab_device);
-#endif
REGISTER_DEMUXER (VMD, vmd);
REGISTER_MUXDEMUX(VOC, voc);
REGISTER_MUXDEMUX(WAV, wav);
@@ -166,6 +155,7 @@ void av_register_all(void)
REGISTER_DEMUXER (WSAUD, wsaud);
REGISTER_DEMUXER (WSVQA, wsvqa);
REGISTER_DEMUXER (WV, wv);
+ REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device);
REGISTER_MUXDEMUX(YUV4MPEGPIPE, yuv4mpegpipe);
#ifdef CONFIG_PROTOCOLS
diff --git a/contrib/ffmpeg/libavformat/allformats.h b/contrib/ffmpeg/libavformat/allformats.h
index a138841c9..9734940d3 100644
--- a/contrib/ffmpeg/libavformat/allformats.h
+++ b/contrib/ffmpeg/libavformat/allformats.h
@@ -47,6 +47,7 @@ extern AVInputFormat dsicin_demuxer;
extern AVInputFormat dv1394_demuxer;
extern AVInputFormat dv_demuxer;
extern AVOutputFormat dv_muxer;
+extern AVInputFormat dxa_demuxer;
extern AVInputFormat ea_demuxer;
extern AVInputFormat ffm_demuxer;
extern AVOutputFormat ffm_muxer;
@@ -69,6 +70,8 @@ extern AVInputFormat imagepipe_demuxer;
extern AVOutputFormat image_muxer;
extern AVOutputFormat imagepipe_muxer;
extern AVInputFormat ipmovie_demuxer;
+extern AVInputFormat libnut_demuxer;
+extern AVOutputFormat libnut_muxer;
extern AVInputFormat matroska_demuxer;
extern AVInputFormat mm_demuxer;
extern AVInputFormat mmf_demuxer;
@@ -82,6 +85,7 @@ extern AVOutputFormat tg2_muxer;
extern AVInputFormat mp3_demuxer;
extern AVOutputFormat mp2_muxer;
extern AVOutputFormat mp3_muxer;
+extern AVInputFormat mpc_demuxer;
extern AVOutputFormat mpeg1system_muxer;
extern AVOutputFormat mpeg1vcd_muxer;
extern AVOutputFormat mpeg2vob_muxer;
@@ -95,7 +99,6 @@ extern AVInputFormat mtv_demuxer;
extern AVInputFormat mxf_demuxer;
extern AVInputFormat nsv_demuxer;
extern AVInputFormat nut_demuxer;
-extern AVOutputFormat nut_muxer;
extern AVInputFormat nuv_demuxer;
extern AVInputFormat ogg_demuxer;
extern AVOutputFormat ogg_muxer;
@@ -152,6 +155,7 @@ extern AVInputFormat swf_demuxer;
extern AVOutputFormat swf_muxer;
extern AVInputFormat tta_demuxer;
extern AVInputFormat v4l2_demuxer;
+extern AVInputFormat vc1_demuxer;
extern AVInputFormat voc_demuxer;
extern AVOutputFormat voc_muxer;
extern AVInputFormat wav_demuxer;
@@ -163,6 +167,8 @@ extern AVInputFormat wv_demuxer;
extern AVOutputFormat yuv4mpegpipe_muxer;
extern AVInputFormat yuv4mpegpipe_demuxer;
extern AVInputFormat tiertexseq_demuxer;
+extern AVInputFormat x11_grab_device_demuxer;
+extern AVInputFormat thp_demuxer;
/* raw.c */
int pcm_read_seek(AVFormatContext *s,
diff --git a/contrib/ffmpeg/libavformat/asf-enc.c b/contrib/ffmpeg/libavformat/asf-enc.c
index 3ef67507f..f1d9c6903 100644
--- a/contrib/ffmpeg/libavformat/asf-enc.c
+++ b/contrib/ffmpeg/libavformat/asf-enc.c
@@ -187,44 +187,36 @@
2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
)
-static int preroll_time = 2000;
+static const AVCodecTag codec_asf_bmp_tags[] = {
+ { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
+ { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
+ { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
+ { CODEC_ID_NONE, 0 },
+};
-static const uint8_t error_spread_ADPCM_G726[] = { 0x01, 0x90, 0x01, 0x90, 0x01, 0x01, 0x00, 0x00 };
+#define PREROLL_TIME 3100
static void put_guid(ByteIOContext *s, const GUID *g)
{
- int i;
-
- put_le32(s, g->v1);
- put_le16(s, g->v2);
- put_le16(s, g->v3);
- for(i=0;i<8;i++)
- put_byte(s, g->v4[i]);
+ assert(sizeof(*g) == 16);
+ put_buffer(s, g, sizeof(*g));
}
+static void put_str16_nolen(ByteIOContext *s, const char *tag);
static void put_str16(ByteIOContext *s, const char *tag)
{
- int c;
-
put_le16(s,strlen(tag) + 1);
- for(;;) {
- c = (uint8_t)*tag++;
- put_le16(s, c);
- if (c == '\0')
- break;
- }
+ put_str16_nolen(s, tag);
}
static void put_str16_nolen(ByteIOContext *s, const char *tag)
{
int c;
- for(;;) {
+ do{
c = (uint8_t)*tag++;
put_le16(s, c);
- if (c == '\0')
- break;
- }
+ }while(c);
}
static int64_t put_header(ByteIOContext *pb, const GUID *g)
@@ -269,8 +261,8 @@ static int64_t unix_to_file_time(int ti)
{
int64_t t;
- t = ti * int64_t_C(10000000);
- t += int64_t_C(116444736000000000);
+ t = ti * INT64_C(10000000);
+ t += INT64_C(116444736000000000);
return t;
}
@@ -286,7 +278,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
int bit_rate;
int64_t duration;
- duration = asf->duration + preroll_time * 10000;
+ duration = asf->duration + PREROLL_TIME * 10000;
has_title = (s->title[0] || s->author[0] || s->copyright[0] || s->comment[0]);
bit_rate = 0;
@@ -317,10 +309,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
put_le64(pb, unix_to_file_time(file_time));
put_le64(pb, asf->nb_packets); /* number of packets */
put_le64(pb, duration); /* end time stamp (in 100ns units) */
- put_le64(pb, duration); /* duration (in 100ns units) */
- put_le32(pb, preroll_time); /* start time stamp */
- put_le32(pb, 0); /* ??? */
- put_le32(pb, asf->is_streamed ? 1 : 0); /* ??? */
+ put_le64(pb, asf->duration); /* duration (in 100ns units) */
+ put_le64(pb, PREROLL_TIME); /* start time stamp */
+ put_le32(pb, (asf->is_streamed || url_is_streamed(pb)) ? 3 : 2); /* ??? */
put_le32(pb, asf->packet_size); /* packet size */
put_le32(pb, asf->packet_size); /* packet size */
put_le32(pb, bit_rate); /* Nominal data rate in bps */
@@ -351,8 +342,6 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
/* stream headers */
for(n=0;n<s->nb_streams;n++) {
int64_t es_pos;
- const uint8_t *er_spr = NULL;
- int er_spr_len = 0;
// ASFStream *stream = &asf->streams[n];
enc = s->streams[n]->codec;
@@ -360,18 +349,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
asf->streams[n].seq = 0;
- if (enc->codec_type == CODEC_TYPE_AUDIO) {
- if (enc->codec_id == CODEC_ID_ADPCM_G726) {
- er_spr = error_spread_ADPCM_G726;
- er_spr_len = sizeof(error_spread_ADPCM_G726);
- }
- }
-
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
- extra_size2 = er_spr_len;
+ extra_size2 = 8;
break;
default:
case CODEC_TYPE_VIDEO:
@@ -384,11 +366,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
hpos = put_header(pb, &stream_header);
if (enc->codec_type == CODEC_TYPE_AUDIO) {
put_guid(pb, &audio_stream);
- if ((er_spr != NULL) && (er_spr_len != 0)) {
- put_guid(pb, &audio_conceal_spread);
- } else {
- put_guid(pb, &video_conceal_none);
- }
+ put_guid(pb, &audio_conceal_spread);
} else {
put_guid(pb, &video_stream);
put_guid(pb, &video_conceal_none);
@@ -417,8 +395,16 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
url_fseek(pb, cur_pos, SEEK_SET);
}
/* ERROR Correction */
- if ((er_spr != NULL) && (er_spr_len != 0))
- put_buffer(pb, er_spr, er_spr_len);
+ put_byte(pb, 0x01);
+ if(enc->codec_id == CODEC_ID_ADPCM_G726 || !enc->block_align){
+ put_le16(pb, 0x0190);
+ put_le16(pb, 0x0190);
+ }else{
+ put_le16(pb, enc->block_align);
+ put_le16(pb, enc->block_align);
+ }
+ put_le16(pb, 0x01);
+ put_byte(pb, 0x00);
} else {
put_le32(pb, enc->width);
put_le32(pb, enc->height);
@@ -442,27 +428,30 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
enc = s->streams[n]->codec;
p = avcodec_find_encoder(enc->codec_id);
- put_le16(pb, asf->streams[n].num);
- put_str16(pb, p ? p->name : enc->codec_name);
+ if(enc->codec_type == CODEC_TYPE_AUDIO)
+ put_le16(pb, 2);
+ else if(enc->codec_type == CODEC_TYPE_VIDEO)
+ put_le16(pb, 1);
+ else
+ put_le16(pb, -1);
+
+ if(enc->codec_id == CODEC_ID_WMAV2)
+ put_str16(pb, "Windows Media Audio V8");
+ else
+ put_str16(pb, p ? p->name : enc->codec_name);
put_le16(pb, 0); /* no parameters */
/* id */
if (enc->codec_type == CODEC_TYPE_AUDIO) {
put_le16(pb, 2);
- if(!enc->codec_tag)
- enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id);
- if(!enc->codec_tag)
- return -1;
put_le16(pb, enc->codec_tag);
} else {
put_le16(pb, 4);
- if(!enc->codec_tag)
- enc->codec_tag = codec_get_tag(codec_bmp_tags, enc->codec_id);
- if(!enc->codec_tag)
- return -1;
put_le32(pb, enc->codec_tag);
}
+ if(!enc->codec_tag)
+ return -1;
}
end_header(pb, hpos);
@@ -509,7 +498,7 @@ static int asf_write_header(AVFormatContext *s)
asf->nb_index_count = 0;
asf->maximum_packet = 0;
- if (asf_write_header1(s, 0, 50) < 0) {
+ if (asf_write_header1(s, 0, 0) < 0) {
//av_free(asf);
return -1;
}
@@ -517,7 +506,6 @@ static int asf_write_header(AVFormatContext *s)
put_flush_packet(&s->pb);
asf->packet_nb_payloads = 0;
- asf->prev_packet_sent_time = 0;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1,
@@ -546,10 +534,15 @@ static int put_payload_parsing_info(
ASFContext *asf = s->priv_data;
ByteIOContext *pb = &s->pb;
int ppi_size, i;
- unsigned char *start_ppi_ptr = pb->buf_ptr;
+ int64_t start= url_ftell(pb);
int iLengthTypeFlags = ASF_PPI_LENGTH_TYPE_FLAGS;
+ padsize -= PACKET_HEADER_MIN_SIZE;
+ if(asf->multi_payloads_present)
+ padsize--;
+ assert(padsize>=0);
+
put_byte(pb, ASF_PACKET_ERROR_CORRECTION_FLAGS);
for (i = 0; i < ASF_PACKET_ERROR_CORRECTION_DATA_SIZE; i++){
put_byte(pb, 0x0);
@@ -578,7 +571,7 @@ static int put_payload_parsing_info(
if (asf->multi_payloads_present)
put_byte(pb, nb_payloads | ASF_PAYLOAD_FLAGS);
- ppi_size = pb->buf_ptr - start_ppi_ptr;
+ ppi_size = url_ftell(pb) - start;
return ppi_size;
}
@@ -600,7 +593,8 @@ static void flush_packet(AVFormatContext *s)
asf->packet_size_left
);
- packet_filled_size = PACKET_SIZE - packet_hdr_size - asf->packet_size_left;
+ packet_filled_size = PACKET_SIZE - asf->packet_size_left;
+ assert(packet_hdr_size <= asf->packet_size_left);
memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left);
put_buffer(&s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size);
@@ -608,7 +602,6 @@ static void flush_packet(AVFormatContext *s)
put_flush_packet(&s->pb);
asf->nb_packets++;
asf->packet_nb_payloads = 0;
- asf->prev_packet_sent_time = asf->packet_timestamp_start;
asf->packet_timestamp_start = -1;
asf->packet_timestamp_end = -1;
init_put_byte(&asf->pb, asf->packet_buf, asf->packet_size, 1,
@@ -655,6 +648,7 @@ static void put_payload_header(
static void put_frame(
AVFormatContext *s,
ASFStream *stream,
+ AVStream *avst,
int timestamp,
const uint8_t *buf,
int m_obj_size,
@@ -670,28 +664,25 @@ static void put_frame(
if (asf->packet_timestamp_start == -1) {
asf->multi_payloads_present = (payload_len < MULTI_PAYLOAD_CONSTANT);
+ asf->packet_size_left = PACKET_SIZE;
if (asf->multi_payloads_present){
- asf->packet_size_left = PACKET_SIZE; //For debug
- asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE - 1;
frag_len1 = MULTI_PAYLOAD_CONSTANT - 1;
}
else {
- asf->packet_size_left = PACKET_SIZE - PACKET_HEADER_MIN_SIZE;
frag_len1 = SINGLE_PAYLOAD_DATA_LENGTH;
}
- if (asf->prev_packet_sent_time > timestamp)
- asf->packet_timestamp_start = asf->prev_packet_sent_time;
- else
- asf->packet_timestamp_start = timestamp;
+ asf->packet_timestamp_start = timestamp;
}
else {
// multi payloads
- frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS;
+ frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS - PACKET_HEADER_MIN_SIZE - 1;
- if (asf->prev_packet_sent_time > timestamp)
- asf->packet_timestamp_start = asf->prev_packet_sent_time;
- else if (asf->packet_timestamp_start >= timestamp)
- asf->packet_timestamp_start = timestamp;
+ asf->packet_timestamp_start = timestamp;
+
+ if(frag_len1 < payload_len && avst->codec->codec_type == CODEC_TYPE_AUDIO){
+ flush_packet(s);
+ continue;
+ }
}
if (frag_len1 > 0) {
if (payload_len > frag_len1)
@@ -699,7 +690,7 @@ static void put_frame(
else if (payload_len == (frag_len1 - 1))
payload_len = frag_len1 - 2; //additional byte need to put padding length
- put_payload_header(s, stream, timestamp+preroll_time, m_obj_size, m_obj_offset, payload_len, flags);
+ put_payload_header(s, stream, timestamp+PREROLL_TIME, m_obj_size, m_obj_offset, payload_len, flags);
put_buffer(&asf->pb, buf, payload_len);
if (asf->multi_payloads_present)
@@ -717,7 +708,7 @@ static void put_frame(
if (!asf->multi_payloads_present)
flush_packet(s);
- else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + 1))
+ else if (asf->packet_size_left <= (PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS + PACKET_HEADER_MIN_SIZE + 1))
flush_packet(s);
}
stream->seq++;
@@ -731,32 +722,27 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecContext *codec;
int64_t packet_st,pts;
int start_sec,i;
+ int flags= pkt->flags;
codec = s->streams[pkt->stream_index]->codec;
stream = &asf->streams[pkt->stream_index];
+ if(codec->codec_type == CODEC_TYPE_AUDIO)
+ flags &= ~PKT_FLAG_KEY;
+
//XXX /FIXME use duration from AVPacket (quick hack by)
pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
- if (pts == AV_NOPTS_VALUE) {
- if (codec->codec_type == CODEC_TYPE_AUDIO) {
- duration = (codec->frame_number * (int64_t)codec->frame_size * int64_t_C(10000000)) /
- codec->sample_rate;
- } else {
- duration = av_rescale(codec->frame_number * (int64_t)codec->time_base.num, 10000000, codec->time_base.den);
- }
- } else {
- duration = pts * 10000;
- }
- if (duration > asf->duration)
- asf->duration = duration;
+ assert(pts != AV_NOPTS_VALUE);
+ duration = pts * 10000;
+ asf->duration= FFMAX(asf->duration, duration);
packet_st = asf->nb_packets;
- put_frame(s, stream, pkt->pts, pkt->data, pkt->size, pkt->flags);
+ put_frame(s, stream, s->streams[pkt->stream_index], pkt->dts, pkt->data, pkt->size, flags);
/* check index */
- if ((!asf->is_streamed) && (codec->codec_type == CODEC_TYPE_VIDEO) && (pkt->flags & PKT_FLAG_KEY)) {
- start_sec = (int)(duration / int64_t_C(10000000));
- if (start_sec != (int)(asf->last_indexed_pts / int64_t_C(10000000))) {
+ if ((!asf->is_streamed) && (flags & PKT_FLAG_KEY)) {
+ start_sec = (int)(duration / INT64_C(10000000));
+ if (start_sec != (int)(asf->last_indexed_pts / INT64_C(10000000))) {
for(i=asf->nb_index_count;i<start_sec;i++) {
if (i>=asf->nb_index_memory_alloc) {
asf->nb_index_memory_alloc += ASF_INDEX_BLOCK;
@@ -765,8 +751,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
// store
asf->index_ptr[i].packet_number = (uint32_t)packet_st;
asf->index_ptr[i].packet_count = (uint16_t)(asf->nb_packets-packet_st);
- if (asf->maximum_packet < (uint16_t)(asf->nb_packets-packet_st))
- asf->maximum_packet = (uint16_t)(asf->nb_packets-packet_st);
+ asf->maximum_packet = FFMAX(asf->maximum_packet, (uint16_t)(asf->nb_packets-packet_st));
}
asf->nb_index_count = start_sec;
asf->last_indexed_pts = duration;
@@ -811,7 +796,7 @@ static int asf_write_trailer(AVFormatContext *s)
}
put_flush_packet(&s->pb);
- if (asf->is_streamed) {
+ if (asf->is_streamed || url_is_streamed(&s->pb)) {
put_chunk(s, 0x4524, 0, 0); /* end of stream */
} else {
/* rewrite an updated header */
@@ -832,7 +817,7 @@ AVOutputFormat asf_muxer = {
"video/x-ms-asf",
"asf,wmv,wma",
sizeof(ASFContext),
-#ifdef CONFIG_MP3LAME
+#ifdef CONFIG_LIBMP3LAME
CODEC_ID_MP3,
#else
CODEC_ID_MP2,
@@ -842,6 +827,7 @@ AVOutputFormat asf_muxer = {
asf_write_packet,
asf_write_trailer,
.flags = AVFMT_GLOBALHEADER,
+ .codec_tag= (const AVCodecTag*[]){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0},
};
#endif
@@ -852,7 +838,7 @@ AVOutputFormat asf_stream_muxer = {
"video/x-ms-asf",
"asf,wmv,wma",
sizeof(ASFContext),
-#ifdef CONFIG_MP3LAME
+#ifdef CONFIG_LIBMP3LAME
CODEC_ID_MP3,
#else
CODEC_ID_MP2,
@@ -862,5 +848,6 @@ AVOutputFormat asf_stream_muxer = {
asf_write_packet,
asf_write_trailer,
.flags = AVFMT_GLOBALHEADER,
+ .codec_tag= (const AVCodecTag*[]){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0},
};
#endif //CONFIG_ASF_STREAM_MUXER
diff --git a/contrib/ffmpeg/libavformat/asf.c b/contrib/ffmpeg/libavformat/asf.c
index f63e4b695..498f6e79e 100644
--- a/contrib/ffmpeg/libavformat/asf.c
+++ b/contrib/ffmpeg/libavformat/asf.c
@@ -31,9 +31,12 @@
// Fix Me! FRAME_HEADER_SIZE may be different.
static const GUID index_guid = {
- 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb },
+ 0x90, 0x08, 0x00, 0x33, 0xb1, 0xe5, 0xcf, 0x11, 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb
};
+static const GUID stream_bitrate_guid = { /* (http://get.to/sdp) */
+ 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
+};
/**********************************/
/* decoding */
@@ -67,11 +70,12 @@ static void print_guid(const GUID *g)
else PRINT_IF_GUID(g, extended_content_header);
else PRINT_IF_GUID(g, ext_stream_embed_stream_header);
else PRINT_IF_GUID(g, ext_stream_audio_stream);
+ else PRINT_IF_GUID(g, metadata_header);
+ else PRINT_IF_GUID(g, stream_bitrate_guid);
else
printf("(GUID: unknown) ");
- printf("0x%08x, 0x%04x, 0x%04x, {", g->v1, g->v2, g->v3);
- for(i=0;i<8;i++)
- printf(" 0x%02x,", g->v4[i]);
+ for(i=0;i<16;i++)
+ printf(" 0x%02x,", (*g)[i]);
printf("}\n");
}
#undef PRINT_IF_GUID
@@ -79,13 +83,8 @@ static void print_guid(const GUID *g)
static void get_guid(ByteIOContext *s, GUID *g)
{
- int i;
-
- g->v1 = get_le32(s);
- g->v2 = get_le16(s);
- g->v3 = get_le16(s);
- for(i=0;i<8;i++)
- g->v4[i] = get_byte(s);
+ assert(sizeof(*g) == 16);
+ get_buffer(s, g, sizeof(*g));
}
#if 0
@@ -119,29 +118,26 @@ static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size)
static int asf_probe(AVProbeData *pd)
{
- GUID g;
- const unsigned char *p;
- int i;
-
/* check file header */
if (pd->buf_size <= 32)
return 0;
- p = pd->buf;
- g.v1 = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
- p += 4;
- g.v2 = p[0] | (p[1] << 8);
- p += 2;
- g.v3 = p[0] | (p[1] << 8);
- p += 2;
- for(i=0;i<8;i++)
- g.v4[i] = *p++;
-
- if (!memcmp(&g, &asf_header, sizeof(GUID)))
+
+ if (!memcmp(pd->buf, &asf_header, sizeof(GUID)))
return AVPROBE_SCORE_MAX;
else
return 0;
}
+static int get_value(ByteIOContext *pb, int type){
+ switch(type){
+ case 2: return get_le32(pb);
+ case 3: return get_le32(pb);
+ case 4: return get_le64(pb);
+ case 5: return get_le16(pb);
+ default:return INT_MIN;
+ }
+}
+
static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
ASFContext *asf = s->priv_data;
@@ -151,6 +147,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
ASFStream *asf_st;
int size, i;
int64_t gsize;
+ AVRational dar[128];
+
+ memset(dar, 0, sizeof(dar));
get_guid(pb, &g);
if (memcmp(&g, &asf_header, sizeof(GUID)))
@@ -168,13 +167,23 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
print_guid(&g);
printf(" size=0x%"PRIx64"\n", gsize);
#endif
+ if (!memcmp(&g, &data_header, sizeof(GUID))) {
+ asf->data_object_offset = url_ftell(pb);
+ // if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
+ if (!(asf->hdr.flags & 0x01) && gsize >= 100) {
+ asf->data_object_size = gsize - 24;
+ } else {
+ asf->data_object_size = (uint64_t)-1;
+ }
+ break;
+ }
if (gsize < 24)
goto fail;
if (!memcmp(&g, &file_header, sizeof(GUID))) {
get_guid(pb, &asf->hdr.guid);
asf->hdr.file_size = get_le64(pb);
asf->hdr.create_time = get_le64(pb);
- asf->hdr.packets_count = get_le64(pb);
+ asf->nb_packets = get_le64(pb);
asf->hdr.send_time = get_le64(pb);
asf->hdr.play_time = get_le64(pb);
asf->hdr.preroll = get_le32(pb);
@@ -184,7 +193,6 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
asf->hdr.max_pktsize = get_le32(pb);
asf->hdr.max_bitrate = get_le32(pb);
asf->packet_size = asf->hdr.max_pktsize;
- asf->nb_packets = asf->hdr.packets_count;
} else if (!memcmp(&g, &stream_header, sizeof(GUID))) {
int type, type_specific_size, sizeX;
uint64_t total_size;
@@ -203,8 +211,10 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto fail;
st->priv_data = asf_st;
st->start_time = asf->hdr.preroll;
- st->duration = asf->hdr.send_time /
- (10000000 / 1000) - st->start_time;
+ if(!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
+ st->duration = asf->hdr.send_time /
+ (10000000 / 1000) - st->start_time;
+ }
get_guid(pb, &g);
test_for_ext_stream_audio = 0;
@@ -249,19 +259,20 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->need_parsing = 1;
/* We have to init the frame size at some point .... */
pos2 = url_ftell(pb);
- if (gsize > (pos2 + 8 - pos1 + 24)) {
+ if (gsize >= (pos2 + 8 - pos1 + 24)) {
asf_st->ds_span = get_byte(pb);
asf_st->ds_packet_size = get_le16(pb);
asf_st->ds_chunk_size = get_le16(pb);
- asf_st->ds_data_size = get_le16(pb);
- asf_st->ds_silence_data = get_byte(pb);
+ get_le16(pb); //ds_data_size
+ get_byte(pb); //ds_silence_data
}
//printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n",
// asf_st->ds_packet_size, asf_st->ds_chunk_size,
// asf_st->ds_data_size, asf_st->ds_span, asf_st->ds_silence_data);
if (asf_st->ds_span > 1) {
if (!asf_st->ds_chunk_size
- || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1))
+ || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)
+ || asf_st->ds_packet_size % asf_st->ds_chunk_size)
asf_st->ds_span = 0; // disable descrambling
}
switch (st->codec->codec_id) {
@@ -326,14 +337,6 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
pos2 = url_ftell(pb);
url_fskip(pb, gsize - (pos2 - pos1 + 24));
- } else if (!memcmp(&g, &data_header, sizeof(GUID))) {
- asf->data_object_offset = url_ftell(pb);
- if (gsize != (uint64_t)-1 && gsize >= 24) {
- asf->data_object_size = gsize - 24;
- } else {
- asf->data_object_size = (uint64_t)-1;
- }
- break;
} else if (!memcmp(&g, &comment_header, sizeof(GUID))) {
int len1, len2, len3, len4, len5;
@@ -342,11 +345,26 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
len3 = get_le16(pb);
len4 = get_le16(pb);
len5 = get_le16(pb);
- get_str16_nolen(pb, len1, s->title, sizeof(s->title));
- get_str16_nolen(pb, len2, s->author, sizeof(s->author));
+ get_str16_nolen(pb, len1, s->title , sizeof(s->title));
+ get_str16_nolen(pb, len2, s->author , sizeof(s->author));
get_str16_nolen(pb, len3, s->copyright, sizeof(s->copyright));
- get_str16_nolen(pb, len4, s->comment, sizeof(s->comment));
+ get_str16_nolen(pb, len4, s->comment , sizeof(s->comment));
url_fskip(pb, len5);
+ } else if (!memcmp(&g, &stream_bitrate_guid, sizeof(GUID))) {
+ int stream_count = get_le16(pb);
+ int j;
+
+// av_log(NULL, AV_LOG_ERROR, "stream bitrate properties\n");
+// av_log(NULL, AV_LOG_ERROR, "streams %d\n", streams);
+ for(j = 0; j < stream_count; j++) {
+ int flags, bitrate, stream_id;
+
+ flags= get_le16(pb);
+ bitrate= get_le32(pb);
+ stream_id= (flags & 0x7f);
+// av_log(NULL, AV_LOG_ERROR, "flags: 0x%x stream id %d, bitrate %d\n", flags, stream_id, bitrate);
+ asf->stream_bitrates[stream_id-1]= bitrate;
+ }
} else if (!memcmp(&g, &extended_content_header, sizeof(GUID))) {
int desc_count, i;
@@ -355,53 +373,69 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
int name_len,value_type,value_len;
uint64_t value_num = 0;
- char *name, *value;
+ char name[1024];
name_len = get_le16(pb);
- name = (char *)av_malloc(name_len * 2);
- get_str16_nolen(pb, name_len, name, name_len * 2);
+ get_str16_nolen(pb, name_len, name, sizeof(name));
value_type = get_le16(pb);
value_len = get_le16(pb);
if ((value_type == 0) || (value_type == 1)) // unicode or byte
{
- value = (char *)av_malloc(value_len * 2);
- get_str16_nolen(pb, value_len, value,
- value_len * 2);
- if (strcmp(name,"WM/AlbumTitle")==0) { pstrcpy(s->album, sizeof(s->album), value); }
- av_free(value);
+ if (!strcmp(name,"WM/AlbumTitle")) get_str16_nolen(pb, value_len, s->album, sizeof(s->album));
+ else if(!strcmp(name,"WM/Genre" )) get_str16_nolen(pb, value_len, s->genre, sizeof(s->genre));
+ else url_fskip(pb, value_len);
}
if ((value_type >= 2) && (value_type <= 5)) // boolean or DWORD or QWORD or WORD
{
- if (value_type==2) value_num = get_le32(pb);
- if (value_type==3) value_num = get_le32(pb);
- if (value_type==4) value_num = get_le64(pb);
- if (value_type==5) value_num = get_le16(pb);
- if (strcmp(name,"WM/Track")==0) s->track = value_num + 1;
- if (strcmp(name,"WM/TrackNumber")==0) s->track = value_num;
+ value_num= get_value(pb, value_type);
+ if (!strcmp(name,"WM/Track" )) s->track = value_num + 1;
+ if (!strcmp(name,"WM/TrackNumber")) s->track = value_num;
}
- av_free(name);
}
+ } else if (!memcmp(&g, &metadata_header, sizeof(GUID))) {
+ int n, stream_num, name_len, value_len, value_type, value_num;
+ n = get_le16(pb);
+
+ for(i=0;i<n;i++) {
+ char name[1024];
+
+ get_le16(pb); //lang_list_index
+ stream_num= get_le16(pb);
+ name_len= get_le16(pb);
+ value_type= get_le16(pb);
+ value_len= get_le32(pb);
+
+ get_str16_nolen(pb, name_len, name, sizeof(name));
+//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d <%s>\n", i, stream_num, name_len, value_type, value_len, name);
+ value_num= get_le16(pb);//we should use get_value() here but it doesnt work 2 is le16 here but le32 elsewhere
+ url_fskip(pb, value_len - 2);
+
+ if(stream_num<128){
+ if (!strcmp(name, "AspectRatioX")) dar[stream_num].num= value_num;
+ else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num;
+ }
+ }
} else if (!memcmp(&g, &ext_stream_header, sizeof(GUID))) {
int ext_len, payload_ext_ct, stream_ct;
uint32_t ext_d;
int64_t pos_ex_st;
pos_ex_st = url_ftell(pb);
- get_le64(pb);
- get_le64(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le32(pb);
- get_le16(pb);
- get_le16(pb);
- get_le64(pb);
- stream_ct = get_le16(pb);
- payload_ext_ct = get_le16(pb);
+ get_le64(pb); // starttime
+ get_le64(pb); // endtime
+ get_le32(pb); // leak-datarate
+ get_le32(pb); // bucket-datasize
+ get_le32(pb); // init-bucket-fullness
+ get_le32(pb); // alt-leak-datarate
+ get_le32(pb); // alt-bucket-datasize
+ get_le32(pb); // alt-init-bucket-fullness
+ get_le32(pb); // max-object-size
+ get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
+ get_le16(pb); // stream-num
+ get_le16(pb); // stream-language-id-index
+ get_le64(pb); // avg frametime in 100ns units
+ stream_ct = get_le16(pb); //stream-name-count
+ payload_ext_ct = get_le16(pb); //payload-extension-system-count
for (i=0; i<stream_ct; i++){
get_le16(pb);
@@ -463,6 +497,18 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
asf->data_offset = url_ftell(pb);
asf->packet_size_left = 0;
+
+ for(i=0; i<128; i++){
+ int stream_num= asf->asfid2avid[i];
+ if(stream_num>=0 && dar[i].num>0 && dar[i].den>0){
+ AVCodecContext *codec= s->streams[stream_num]->codec;
+ av_reduce(&codec->sample_aspect_ratio.num,
+ &codec->sample_aspect_ratio.den,
+ dar[i].num, dar[i].den, INT_MAX);
+//av_log(NULL, AV_LOG_ERROR, "dar %d:%d sar=%d:%d\n", dar[i].num, dar[i].den, codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den);
+ }
+ }
+
return 0;
fail:
@@ -486,36 +532,47 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
default: var = defval; break; \
}
+/**
+ *
+ * @return <0 in case of an error
+ */
static int asf_get_packet(AVFormatContext *s)
{
ASFContext *asf = s->priv_data;
ByteIOContext *pb = &s->pb;
uint32_t packet_length, padsize;
- int rsize = 9;
- int c;
+ int rsize = 8;
+ int c, d, e, off;
+
+ off= (url_ftell(&s->pb) - s->data_offset) % asf->packet_size + 3;
- assert((url_ftell(&s->pb) - s->data_offset) % asf->packet_size == 0);
+ c=d=e=-1;
+ while(off-- > 0){
+ c=d; d=e;
+ e= get_byte(pb);
+ if(c == 0x82 && !d && !e)
+ break;
+ }
- c = get_byte(pb);
if (c != 0x82) {
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, url_ftell(pb));
}
- if ((c & 0x0f) == 2) { // always true for now
- if (get_le16(pb) != 0) {
+ if ((c & 0x8f) == 0x82) {
+ if (d || e) {
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
- return AVERROR_IO;
+ return -1;
}
- rsize+=2;
-/* }else{
- if (!url_feof(pb))
- printf("ff asf bad header %x at:%"PRId64"\n", c, url_ftell(pb));
- return AVERROR_IO;*/
+ c= get_byte(pb);
+ d= get_byte(pb);
+ rsize+=3;
+ }else{
+ url_fseek(pb, -1, SEEK_CUR); //FIXME
}
- asf->packet_flags = get_byte(pb);
- asf->packet_property = get_byte(pb);
+ asf->packet_flags = c;
+ asf->packet_property = d;
DO_2BITS(asf->packet_flags >> 5, packet_length, asf->packet_size);
DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored
@@ -524,11 +581,11 @@ static int asf_get_packet(AVFormatContext *s)
//the following checks prevent overflows and infinite loops
if(packet_length >= (1U<<29)){
av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, url_ftell(pb));
- return 0; // FIXME this should be -1
+ return -1;
}
- if(padsize >= (1U<<29)){
+ if(padsize >= packet_length){
av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, url_ftell(pb));
- return 0; // FIXME this should be -1
+ return -1;
}
asf->packet_timestamp = get_le32(pb);
@@ -552,6 +609,81 @@ static int asf_get_packet(AVFormatContext *s)
return 0;
}
+/**
+ *
+ * @return <0 if error
+ */
+static int asf_read_frame_header(AVFormatContext *s){
+ ASFContext *asf = s->priv_data;
+ ByteIOContext *pb = &s->pb;
+ int rsize = 1;
+ int num = get_byte(pb);
+ int64_t ts0, ts1;
+
+ asf->packet_segments--;
+ asf->packet_key_frame = num >> 7;
+ asf->stream_index = asf->asfid2avid[num & 0x7f];
+ // sequence should be ignored!
+ DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0);
+ DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0);
+ DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
+//printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size);
+ if (asf->packet_replic_size >= 8) {
+ asf->packet_obj_size = get_le32(pb);
+ if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){
+ av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n");
+ return -1;
+ }
+ asf->packet_frag_timestamp = get_le32(pb); // timestamp
+ if(asf->packet_replic_size >= 8+38+4){
+// for(i=0; i<asf->packet_replic_size-8; i++)
+// av_log(s, AV_LOG_DEBUG, "%02X ",get_byte(pb));
+// av_log(s, AV_LOG_DEBUG, "\n");
+ url_fskip(pb, 10);
+ ts0= get_le64(pb);
+ ts1= get_le64(pb);
+ url_fskip(pb, 12);
+ get_le32(pb);
+ url_fskip(pb, asf->packet_replic_size - 8 - 38 - 4);
+ if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000;
+ else asf->packet_frag_timestamp= AV_NOPTS_VALUE;
+ }else
+ url_fskip(pb, asf->packet_replic_size - 8);
+ rsize += asf->packet_replic_size; // FIXME - check validity
+ } else if (asf->packet_replic_size==1){
+ // multipacket - frag_offset is begining timestamp
+ asf->packet_time_start = asf->packet_frag_offset;
+ asf->packet_frag_offset = 0;
+ asf->packet_frag_timestamp = asf->packet_timestamp;
+
+ asf->packet_time_delta = get_byte(pb);
+ rsize++;
+ }else if(asf->packet_replic_size!=0){
+ av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", asf->packet_replic_size);
+ return -1;
+ }
+ if (asf->packet_flags & 0x01) {
+ DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal
+ if(asf->packet_frag_size > asf->packet_size_left - rsize){
+ av_log(s, AV_LOG_ERROR, "packet_frag_size is invalid\n");
+ return -1;
+ }
+ //printf("Fragsize %d\n", asf->packet_frag_size);
+ } else {
+ asf->packet_frag_size = asf->packet_size_left - rsize;
+ //printf("Using rest %d %d %d\n", asf->packet_frag_size, asf->packet_size_left, rsize);
+ }
+ if (asf->packet_replic_size == 1) {
+ asf->packet_multi_size = asf->packet_frag_size;
+ if (asf->packet_multi_size > asf->packet_size_left)
+ return -1;
+ }
+ asf->packet_size_left -= rsize;
+ //printf("___objsize____ %d %d rs:%d\n", asf->packet_obj_size, asf->packet_frag_offset, rsize);
+
+ return 0;
+}
+
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
ASFContext *asf = s->priv_data;
@@ -559,77 +691,33 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
ByteIOContext *pb = &s->pb;
//static int pc = 0;
for (;;) {
- int rsize = 0;
+ if(url_feof(pb))
+ return AVERROR_IO;
if (asf->packet_size_left < FRAME_HEADER_SIZE
|| asf->packet_segments < 1) {
//asf->packet_size_left <= asf->packet_padsize) {
int ret = asf->packet_size_left + asf->packet_padsize;
//printf("PacketLeftSize:%d Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, url_ftell(pb));
- if((url_ftell(&s->pb) + ret - s->data_offset) % asf->packet_size)
- ret += asf->packet_size - ((url_ftell(&s->pb) + ret - s->data_offset) % asf->packet_size);
assert(ret>=0);
/* fail safe */
url_fskip(pb, ret);
+
asf->packet_pos= url_ftell(&s->pb);
if (asf->data_object_size != (uint64_t)-1 &&
(asf->packet_pos - asf->data_object_offset >= asf->data_object_size))
return AVERROR_IO; /* Do not exceed the size of the data object */
ret = asf_get_packet(s);
//printf("READ ASF PACKET %d r:%d c:%d\n", ret, asf->packet_size_left, pc++);
- if (ret < 0 || url_feof(pb))
- return AVERROR_IO;
+ if (ret < 0)
+ assert(asf->packet_size_left < FRAME_HEADER_SIZE || asf->packet_segments < 1);
asf->packet_time_start = 0;
continue;
}
if (asf->packet_time_start == 0) {
- /* read frame header */
- int num = get_byte(pb);
- asf->packet_segments--;
- rsize++;
- asf->packet_key_frame = (num & 0x80) >> 7;
- asf->stream_index = asf->asfid2avid[num & 0x7f];
- // sequence should be ignored!
- DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0);
- DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0);
- DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
-//printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size);
- if (asf->packet_replic_size > 1) {
- assert(asf->packet_replic_size >= 8);
- // it should be always at least 8 bytes - FIXME validate
- asf->packet_obj_size = get_le32(pb);
- asf->packet_frag_timestamp = get_le32(pb); // timestamp
- if (asf->packet_replic_size > 8)
- url_fskip(pb, asf->packet_replic_size - 8);
- rsize += asf->packet_replic_size; // FIXME - check validity
- } else if (asf->packet_replic_size==1){
- // multipacket - frag_offset is begining timestamp
- asf->packet_time_start = asf->packet_frag_offset;
- asf->packet_frag_offset = 0;
- asf->packet_frag_timestamp = asf->packet_timestamp;
-
- asf->packet_time_delta = get_byte(pb);
- rsize++;
- }else{
- assert(asf->packet_replic_size==0);
- }
- if (asf->packet_flags & 0x01) {
- DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal
-#undef DO_2BITS
- //printf("Fragsize %d\n", asf->packet_frag_size);
- } else {
- asf->packet_frag_size = asf->packet_size_left - rsize;
- //printf("Using rest %d %d %d\n", asf->packet_frag_size, asf->packet_size_left, rsize);
- }
- if (asf->packet_replic_size == 1) {
- asf->packet_multi_size = asf->packet_frag_size;
- if (asf->packet_multi_size > asf->packet_size_left) {
- asf->packet_segments = 0;
- continue;
- }
+ if(asf_read_frame_header(s) < 0){
+ asf->packet_segments= 0;
+ continue;
}
- asf->packet_size_left -= rsize;
- //printf("___objsize____ %d %d rs:%d\n", asf->packet_obj_size, asf->packet_frag_offset, rsize);
-
if (asf->stream_index < 0
|| s->streams[asf->stream_index]->discard >= AVDISCARD_ALL
|| (!asf->packet_key_frame && s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY)
@@ -639,34 +727,13 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
url_fskip(pb, asf->packet_frag_size);
asf->packet_size_left -= asf->packet_frag_size;
if(asf->stream_index < 0)
- av_log(s, AV_LOG_ERROR, "ff asf skip %d %d\n", asf->packet_frag_size, num & 0x7f);
+ av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n", asf->packet_frag_size);
continue;
}
asf->asf_st = s->streams[asf->stream_index]->priv_data;
}
asf_st = asf->asf_st;
- if ((asf->packet_frag_offset != asf_st->frag_offset
- || (asf->packet_frag_offset
- && asf->packet_seq != asf_st->seq)) // seq should be ignored
- ) {
- /* cannot continue current packet: free it */
- // FIXME better check if packet was already allocated
- av_log(s, AV_LOG_INFO, "ff asf parser skips: %d - %d o:%d - %d %d %d fl:%d\n",
- asf_st->pkt.size,
- asf->packet_obj_size,
- asf->packet_frag_offset, asf_st->frag_offset,
- asf->packet_seq, asf_st->seq, asf->packet_frag_size);
- if (asf_st->pkt.size)
- av_free_packet(&asf_st->pkt);
- asf_st->frag_offset = 0;
- if (asf->packet_frag_offset != 0) {
- url_fskip(pb, asf->packet_frag_size);
- av_log(s, AV_LOG_INFO, "ff asf parser skipping %db\n", asf->packet_frag_size);
- asf->packet_size_left -= asf->packet_frag_size;
- continue;
- }
- }
if (asf->packet_replic_size == 1) {
// frag_offset is here used as the begining timestamp
asf->packet_frag_timestamp = asf->packet_time_start;
@@ -684,7 +751,13 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
asf->packet_multi_size -= asf->packet_obj_size;
//printf("COMPRESS size %d %d %d ms:%d\n", asf->packet_obj_size, asf->packet_frag_timestamp, asf->packet_size_left, asf->packet_multi_size);
}
- if (asf_st->frag_offset == 0) {
+ if ( asf_st->pkt.size != asf->packet_obj_size
+ || asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) { //FIXME is this condition sufficient?
+ if(asf_st->pkt.data){
+ av_log(s, AV_LOG_INFO, "freeing incomplete packet size %d, new %d\n", asf_st->pkt.size, asf->packet_obj_size);
+ asf_st->frag_offset = 0;
+ av_free_packet(&asf_st->pkt);
+ }
/* new packet */
av_new_packet(&asf_st->pkt, asf->packet_obj_size);
asf_st->seq = asf->packet_seq;
@@ -708,6 +781,14 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
asf->packet_size_left -= asf->packet_frag_size;
if (asf->packet_size_left < 0)
continue;
+
+ if( asf->packet_frag_offset >= asf_st->pkt.size
+ || asf->packet_frag_size > asf_st->pkt.size - asf->packet_frag_offset){
+ av_log(s, AV_LOG_ERROR, "packet fragment position invalid %u,%u not in %u\n",
+ asf->packet_frag_offset, asf->packet_frag_size, asf_st->pkt.size);
+ continue;
+ }
+
get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset,
asf->packet_frag_size);
asf_st->frag_offset += asf->packet_frag_size;
@@ -715,6 +796,9 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (asf_st->frag_offset == asf_st->pkt.size) {
/* return packet */
if (asf_st->ds_span > 1) {
+ if(asf_st->pkt.size != asf_st->ds_packet_size * asf_st->ds_span){
+ av_log(s, AV_LOG_ERROR, "pkt.size != ds_packet_size * ds_span\n");
+ }else{
/* packet descrambling */
uint8_t *newdata = av_malloc(asf_st->pkt.size);
if (newdata) {
@@ -725,6 +809,9 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
int col = off % asf_st->ds_span;
int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size;
//printf("off:%d row:%d col:%d idx:%d\n", off, row, col, idx);
+
+ assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size);
+ assert(idx+1 <= asf_st->pkt.size / asf_st->ds_chunk_size);
memcpy(newdata + offset,
asf_st->pkt.data + idx * asf_st->ds_chunk_size,
asf_st->ds_chunk_size);
@@ -733,9 +820,10 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
av_free(asf_st->pkt.data);
asf_st->pkt.data = newdata;
}
+ }
}
asf_st->frag_offset = 0;
- memcpy(pkt, &asf_st->pkt, sizeof(AVPacket));
+ *pkt= asf_st->pkt;
//printf("packet %d %d\n", asf_st->pkt.size, asf->packet_frag_size);
asf_st->pkt.size = 0;
asf_st->pkt.data = 0;
@@ -752,7 +840,7 @@ static int asf_read_close(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
av_free(st->priv_data);
- av_free(st->codec->palctrl);
+ av_free(st->codec->palctrl);
}
return 0;
}
@@ -767,8 +855,6 @@ static void asf_reset_header(AVFormatContext *s)
int i;
asf->packet_nb_frames = 0;
- asf->packet_timestamp_start = -1;
- asf->packet_timestamp_end = -1;
asf->packet_size_left = 0;
asf->packet_segments = 0;
asf->packet_flags = 0;
@@ -819,7 +905,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
asf_reset_header(s);
for(;;){
if (av_read_frame(s, pkt) < 0){
- av_log(s, AV_LOG_INFO, "seek failed\n");
+ av_log(s, AV_LOG_INFO, "asf_read_pts failed\n");
return AV_NOPTS_VALUE;
}
@@ -831,7 +917,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos,
asf_st= s->streams[i]->priv_data;
- assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0);
+// assert((asf_st->packet_pos - s->data_offset) % asf->packet_size == 0);
pos= asf_st->packet_pos;
av_add_index_entry(s->streams[i], pos, pts, pkt->size, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
diff --git a/contrib/ffmpeg/libavformat/asf.h b/contrib/ffmpeg/libavformat/asf.h
index bbe88801a..6d76ebecb 100644
--- a/contrib/ffmpeg/libavformat/asf.h
+++ b/contrib/ffmpeg/libavformat/asf.h
@@ -31,45 +31,36 @@ typedef struct {
int ds_span; /* descrambling */
int ds_packet_size;
int ds_chunk_size;
- int ds_data_size;
- int ds_silence_data;
int64_t packet_pos;
} ASFStream;
-typedef struct {
- uint32_t v1;
- uint16_t v2;
- uint16_t v3;
- uint8_t v4[8];
-} GUID;
+typedef uint8_t GUID[16];
typedef struct {
- GUID guid; // generated by client computer
- uint64_t file_size; // in bytes
- // invalid if broadcasting
- uint64_t create_time; // time of creation, in 100-nanosecond units since 1.1.1601
- // invalid if broadcasting
- uint64_t packets_count; // how many packets are there in the file
- // invalid if broadcasting
- uint64_t play_time; // play time, in 100-nanosecond units
- // invalid if broadcasting
- uint64_t send_time; // time to send file, in 100-nanosecond units
- // invalid if broadcasting (could be ignored)
- uint32_t preroll; // timestamp of the first packet, in milliseconds
- // if nonzero - substract from time
- uint32_t ignore; // preroll is 64bit - but let's just ignore it
- uint32_t flags; // 0x01 - broadcast
- // 0x02 - seekable
- // rest is reserved should be 0
- uint32_t min_pktsize; // size of a data packet
- // invalid if broadcasting
- uint32_t max_pktsize; // shall be the same as for min_pktsize
- // invalid if broadcasting
- uint32_t max_bitrate; // bandwith of stream in bps
- // should be the sum of bitrates of the
- // individual media streams
+ GUID guid; ///< generated by client computer
+ uint64_t file_size; /**< in bytes
+ * invalid if broadcasting */
+ uint64_t create_time; /**< time of creation, in 100-nanosecond units since 1.1.1601
+ * invalid if broadcasting */
+ uint64_t play_time; /**< play time, in 100-nanosecond units
+ * invalid if broadcasting */
+ uint64_t send_time; /**< time to send file, in 100-nanosecond units
+ * invalid if broadcasting (could be ignored) */
+ uint32_t preroll; /**< timestamp of the first packet, in milliseconds
+ * if nonzero - substract from time */
+ uint32_t ignore; ///< preroll is 64bit - but let's just ignore it
+ uint32_t flags; /**< 0x01 - broadcast
+ * 0x02 - seekable
+ * rest is reserved should be 0 */
+ uint32_t min_pktsize; /**< size of a data packet
+ * invalid if broadcasting */
+ uint32_t max_pktsize; /**< shall be the same as for min_pktsize
+ * invalid if broadcasting */
+ uint32_t max_bitrate; /**< bandwith of stream in bps
+ * should be the sum of bitrates of the
+ * individual media streams */
} ASFMainHeader;
@@ -83,15 +74,15 @@ typedef struct {
uint32_t seqno;
unsigned int packet_size;
int is_streamed;
- int asfid2avid[128]; /* conversion table from asf ID 2 AVStream ID */
- ASFStream streams[128]; /* it's max number and it's not that big */
+ int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID
+ ASFStream streams[128]; ///< it's max number and it's not that big
+ uint32_t stream_bitrates[128]; ///< max number of streams, bitrate for each (for streaming)
/* non streamed additonnal info */
- int64_t nb_packets;
- int64_t duration; /* in 100ns units */
+ uint64_t nb_packets; ///< how many packets are there in the file, invalid if broadcasting
+ int64_t duration; ///< in 100ns units
/* packet filling */
unsigned char multi_payloads_present;
int packet_size_left;
- int prev_packet_sent_time;
int packet_timestamp_start;
int packet_timestamp_end;
unsigned int packet_nb_payloads;
@@ -99,9 +90,9 @@ typedef struct {
uint8_t packet_buf[PACKET_SIZE];
ByteIOContext pb;
/* only for reading */
- uint64_t data_offset; /* begining of the first data packet */
- uint64_t data_object_offset; /* data object offset (excl. GUID & size)*/
- uint64_t data_object_size; /* size of the data object */
+ uint64_t data_offset; ///< begining of the first data packet
+ uint64_t data_object_offset; ///< data object offset (excl. GUID & size)
+ uint64_t data_object_size; ///< size of the data object
int index_read;
ASFMainHeader hdr;
@@ -115,9 +106,9 @@ typedef struct {
int packet_replic_size;
int packet_key_frame;
int packet_padsize;
- int packet_frag_offset;
- int packet_frag_size;
- int packet_frag_timestamp;
+ unsigned int packet_frag_offset;
+ unsigned int packet_frag_size;
+ int64_t packet_frag_timestamp;
int packet_multi_size;
int packet_obj_size;
int packet_time_delta;
@@ -133,94 +124,98 @@ typedef struct {
uint32_t nb_index_memory_alloc;
uint16_t maximum_packet;
- ASFStream* asf_st; /* currently decoded stream */
+ ASFStream* asf_st; ///< currently decoded stream
} ASFContext;
static const GUID asf_header = {
- 0x75B22630, 0x668E, 0x11CF, { 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C },
+ 0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C
};
static const GUID file_header = {
- 0x8CABDCA1, 0xA947, 0x11CF, { 0x8E, 0xE4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 },
+ 0xA1, 0xDC, 0xAB, 0x8C, 0x47, 0xA9, 0xCF, 0x11, 0x8E, 0xE4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65
};
static const GUID stream_header = {
- 0xB7DC0791, 0xA9B7, 0x11CF, { 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65 },
+ 0x91, 0x07, 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65
};
static const GUID ext_stream_header = {
- 0x14E6A5CB, 0xC672, 0x4332, { 0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A },
+ 0xCB, 0xA5, 0xE6, 0x14, 0x72, 0xC6, 0x32, 0x43, 0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A
};
static const GUID audio_stream = {
- 0xF8699E40, 0x5B4D, 0x11CF, { 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B },
+ 0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
};
static const GUID audio_conceal_none = {
- // 0x49f1a440, 0x4ece, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 },
+ // 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
// New value lifted from avifile
- 0x20fb5700, 0x5b55, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b },
+ 0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
};
static const GUID audio_conceal_spread = {
- 0xBFC3CD50, 0x618F, 0x11CF, { 0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20 },
+ 0x50, 0xCD, 0xC3, 0xBF, 0x8F, 0x61, 0xCF, 0x11, 0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20
};
static const GUID video_stream = {
- 0xBC19EFC0, 0x5B4D, 0x11CF, { 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B },
+ 0xC0, 0xEF, 0x19, 0xBC, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
};
static const GUID video_conceal_none = {
- 0x20FB5700, 0x5B55, 0x11CF, { 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B },
+ 0x00, 0x57, 0xFB, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
};
static const GUID command_stream = {
- 0x59DACFC0, 0x59E6, 0x11D0, { 0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 },
+ 0xC0, 0xCF, 0xDA, 0x59, 0xE6, 0x59, 0xD0, 0x11, 0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6
};
static const GUID comment_header = {
- 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c },
+ 0x33, 0x26, 0xb2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
};
static const GUID codec_comment_header = {
- 0x86D15240, 0x311D, 0x11D0, { 0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 },
+ 0x40, 0x52, 0xD1, 0x86, 0x1D, 0x31, 0xD0, 0x11, 0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6
};
static const GUID codec_comment1_header = {
- 0x86d15241, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 },
+ 0x41, 0x52, 0xd1, 0x86, 0x1D, 0x31, 0xD0, 0x11, 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
};
static const GUID data_header = {
- 0x75b22636, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c },
+ 0x36, 0x26, 0xb2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
};
static const GUID head1_guid = {
- 0x5fbf03b5, 0xa92e, 0x11cf, { 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 },
+ 0xb5, 0x03, 0xbf, 0x5f, 0x2E, 0xA9, 0xCF, 0x11, 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
};
static const GUID head2_guid = {
- 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 },
+ 0x11, 0xd2, 0xd3, 0xab, 0xBA, 0xA9, 0xCF, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
};
static const GUID extended_content_header = {
- 0xD2D0A440, 0xE307, 0x11D2, { 0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50 },
+ 0x40, 0xA4, 0xD0, 0xD2, 0x07, 0xE3, 0xD2, 0x11, 0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50
};
static const GUID simple_index_header = {
- 0x33000890, 0xE5B1, 0x11CF, { 0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB },
+ 0x90, 0x08, 0x00, 0x33, 0xB1, 0xE5, 0xCF, 0x11, 0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB
};
static const GUID ext_stream_embed_stream_header = {
- 0x3afb65e2, 0x47ef, 0x40f2, { 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43}
+ 0xe2, 0x65, 0xfb, 0x3a, 0xEF, 0x47, 0xF2, 0x40, 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43
};
static const GUID ext_stream_audio_stream = {
- 0x31178c9d, 0x03e1, 0x4528, { 0xb5, 0x82, 0x3d, 0xf9, 0xdb, 0x22, 0xf5, 0x03}
+ 0x9d, 0x8c, 0x17, 0x31, 0xE1, 0x03, 0x28, 0x45, 0xb5, 0x82, 0x3d, 0xf9, 0xdb, 0x22, 0xf5, 0x03
+};
+
+static const GUID metadata_header = {
+ 0xea, 0xcb, 0xf8, 0xc5, 0xaf, 0x5b, 0x77, 0x48, 0x84, 0x67, 0xaa, 0x8c, 0x44, 0xfa, 0x4c, 0xca
};
/* I am not a number !!! This GUID is the one found on the PC used to
generate the stream */
static const GUID my_guid = {
- 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 },
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
#define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 0000
diff --git a/contrib/ffmpeg/libavformat/au.c b/contrib/ffmpeg/libavformat/au.c
index 27c7cdc85..9e84c9d31 100644
--- a/contrib/ffmpeg/libavformat/au.c
+++ b/contrib/ffmpeg/libavformat/au.c
@@ -32,10 +32,10 @@
#include "riff.h"
/* if we don't know the size in advance */
-#define AU_UNKOWN_SIZE ((uint32_t)(~0))
+#define AU_UNKNOWN_SIZE ((uint32_t)(~0))
/* The ffmpeg codecs we support, and the IDs they have in the file */
-static const CodecTag codec_au_tags[] = {
+static const AVCodecTag codec_au_tags[] = {
{ CODEC_ID_PCM_MULAW, 1 },
{ CODEC_ID_PCM_S16BE, 3 },
{ CODEC_ID_PCM_ALAW, 27 },
@@ -47,12 +47,10 @@ static const CodecTag codec_au_tags[] = {
static int put_au_header(ByteIOContext *pb, AVCodecContext *enc)
{
if(!enc->codec_tag)
- enc->codec_tag = codec_get_tag(codec_au_tags, enc->codec_id);
- if(!enc->codec_tag)
return -1;
put_tag(pb, ".snd"); /* magic number */
put_be32(pb, 24); /* header size */
- put_be32(pb, AU_UNKOWN_SIZE); /* data size */
+ put_be32(pb, AU_UNKNOWN_SIZE); /* data size */
put_be32(pb, (uint32_t)enc->codec_tag); /* codec ID */
put_be32(pb, enc->sample_rate);
put_be32(pb, (uint32_t)enc->channels);
@@ -190,6 +188,7 @@ AVInputFormat au_demuxer = {
au_read_packet,
au_read_close,
pcm_read_seek,
+ .codec_tag= (const AVCodecTag*[]){codec_au_tags, 0},
};
#endif
@@ -205,5 +204,6 @@ AVOutputFormat au_muxer = {
au_write_header,
au_write_packet,
au_write_trailer,
+ .codec_tag= (const AVCodecTag*[]){codec_au_tags, 0},
};
#endif //CONFIG_AU_MUXER
diff --git a/contrib/ffmpeg/libavformat/audio.c b/contrib/ffmpeg/libavformat/audio.c
index 1dfccccb8..a9e5bffd5 100644
--- a/contrib/ffmpeg/libavformat/audio.c
+++ b/contrib/ffmpeg/libavformat/audio.c
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#ifdef __OpenBSD__
+#ifdef HAVE_SOUNDCARD_H
#include <soundcard.h>
#else
#include <sys/soundcard.h>
@@ -53,14 +53,6 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
int tmp, err;
char *flip = getenv("AUDIO_FLIP_LEFT");
- /* open linux audio device */
- if (!audio_device)
-#ifdef __OpenBSD__
- audio_device = "/dev/sound";
-#else
- audio_device = "/dev/dsp";
-#endif
-
if (is_output)
audio_fd = open(audio_device, O_WRONLY);
else
@@ -224,12 +216,12 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0);
if (!st) {
- return -ENOMEM;
+ return AVERROR(ENOMEM);
}
s->sample_rate = ap->sample_rate;
s->channels = ap->channels;
- ret = audio_open(s, 0, ap->device);
+ ret = audio_open(s, 0, s1->filename);
if (ret < 0) {
av_free(st);
return AVERROR_IO;
diff --git a/contrib/ffmpeg/libavformat/avformat.h b/contrib/ffmpeg/libavformat/avformat.h
index 5dc41d273..eb8c4e153 100644
--- a/contrib/ffmpeg/libavformat/avformat.h
+++ b/contrib/ffmpeg/libavformat/avformat.h
@@ -25,8 +25,8 @@
extern "C" {
#endif
-#define LIBAVFORMAT_VERSION_INT ((51<<16)+(6<<8)+0)
-#define LIBAVFORMAT_VERSION 51.6.0
+#define LIBAVFORMAT_VERSION_INT ((51<<16)+(11<<8)+0)
+#define LIBAVFORMAT_VERSION 51.11.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
@@ -39,14 +39,6 @@ extern "C" {
/* packet functions */
-#ifndef MAXINT64
-#define MAXINT64 int64_t_C(0x7fffffffffffffff)
-#endif
-
-#ifndef MININT64
-#define MININT64 int64_t_C(0x8000000000000000)
-#endif
-
typedef struct AVPacket {
int64_t pts; ///< presentation time stamp in time_base units
int64_t dts; ///< decompression time stamp in time_base units
@@ -62,6 +54,10 @@ typedef struct AVPacket {
#define PKT_FLAG_KEY 0x0001
void av_destruct_packet_nofree(AVPacket *pkt);
+
+/**
+ * Default packet destructor.
+ */
void av_destruct_packet(AVPacket *pkt);
/* initialize optional fields of a packet */
@@ -76,8 +72,28 @@ static inline void av_init_packet(AVPacket *pkt)
pkt->destruct= av_destruct_packet_nofree;
}
+/**
+ * Allocate the payload of a packet and intialized its fields to default values.
+ *
+ * @param pkt packet
+ * @param size wanted payload size
+ * @return 0 if OK. AVERROR_xxx otherwise.
+ */
int av_new_packet(AVPacket *pkt, int size);
+
+/**
+ * Allocate and read the payload of a packet and intialized its fields to default values.
+ *
+ * @param pkt packet
+ * @param size wanted payload size
+ * @return >0 (read size) if OK. AVERROR_xxx otherwise.
+ */
int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
+
+/**
+ * @warning This is a hack - the packet memory allocation stuff is broken. The
+ * packet is allocated if it was not really allocated
+ */
int av_dup_packet(AVPacket *pkt);
/**
@@ -104,9 +120,11 @@ typedef struct AVFrac {
/*************************************************/
/* input/output formats */
+struct AVCodecTag;
+
struct AVFormatContext;
-/* this structure contains the data a format has to probe a file */
+/** this structure contains the data a format has to probe a file */
typedef struct AVProbeData {
const char *filename;
unsigned char *buf;
@@ -122,46 +140,57 @@ typedef struct AVFormatParameters {
int width;
int height;
enum PixelFormat pix_fmt;
- int channel; /* used to select dv channel */
- const char *device; /* video, audio or DV device */
- const char *standard; /* tv standard, NTSC, PAL, SECAM */
- int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
- int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
+ int channel; /**< used to select dv channel */
+#if LIBAVFORMAT_VERSION_INT < (52<<16)
+ const char *device; /**< video, audio or DV device */
+#endif
+ const char *standard; /**< tv standard, NTSC, PAL, SECAM */
+ int mpeg2ts_raw:1; /**< force raw MPEG2 transport stream output, if possible */
+ int mpeg2ts_compute_pcr:1; /**< compute exact PCR for each transport
stream packet (only meaningful if
mpeg2ts_raw is TRUE */
- int initial_pause:1; /* do not begin to play the stream
+ int initial_pause:1; /**< do not begin to play the stream
immediately (RTSP only) */
int prealloced_context:1;
enum CodecID video_codec_id;
enum CodecID audio_codec_id;
} AVFormatParameters;
-#define AVFMT_NOFILE 0x0001 /* no file should be opened */
-#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
-#define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
-#define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
+//! demuxer will use url_fopen, no opened file should be provided by the caller
+#define AVFMT_NOFILE 0x0001
+#define AVFMT_NEEDNUMBER 0x0002 /**< needs '%d' in filename */
+#define AVFMT_SHOW_IDS 0x0008 /**< show format stream IDs numbers */
+#define AVFMT_RAWPICTURE 0x0020 /**< format wants AVPicture structure for
raw picture data */
-#define AVFMT_GLOBALHEADER 0x0040 /* format wants global header */
-#define AVFMT_NOTIMESTAMPS 0x0080 /* format doesnt need / has any timestamps */
+#define AVFMT_GLOBALHEADER 0x0040 /**< format wants global header */
+#define AVFMT_NOTIMESTAMPS 0x0080 /**< format doesnt need / has any timestamps */
+#define AVFMT_GENERIC_INDEX 0x0100 /**< use generic index building code */
typedef struct AVOutputFormat {
const char *name;
const char *long_name;
const char *mime_type;
- const char *extensions; /* comma separated extensions */
- /* size of private data so that it can be allocated in the wrapper */
+ const char *extensions; /**< comma separated filename extensions */
+ /** size of private data so that it can be allocated in the wrapper */
int priv_data_size;
/* output support */
- enum CodecID audio_codec; /* default audio codec */
- enum CodecID video_codec; /* default video codec */
+ enum CodecID audio_codec; /**< default audio codec */
+ enum CodecID video_codec; /**< default video codec */
int (*write_header)(struct AVFormatContext *);
int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
int (*write_trailer)(struct AVFormatContext *);
- /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
+ /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
int flags;
- /* currently only used to set pixel format if not YUV420P */
+ /** currently only used to set pixel format if not YUV420P */
int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
+
+ /**
+ * list of supported codec_id-codec_tag pairs, ordered by "better choice first"
+ * the arrays are all CODEC_ID_NONE terminated
+ */
+ const struct AVCodecTag **codec_tag;
+
/* private fields */
struct AVOutputFormat *next;
} AVOutputFormat;
@@ -169,21 +198,21 @@ typedef struct AVOutputFormat {
typedef struct AVInputFormat {
const char *name;
const char *long_name;
- /* size of private data so that it can be allocated in the wrapper */
+ /** size of private data so that it can be allocated in the wrapper */
int priv_data_size;
- /* tell if a given file has a chance of being parsing by this format */
+ /** tell if a given file has a chance of being parsing by this format */
int (*read_probe)(AVProbeData *);
- /* read the format header and initialize the AVFormatContext
+ /** read the format header and initialize the AVFormatContext
structure. Return 0 if OK. 'ap' if non NULL contains
additionnal paramters. Only used in raw format right
now. 'av_new_stream' should be called to create new streams. */
int (*read_header)(struct AVFormatContext *,
AVFormatParameters *ap);
- /* read one packet and put it in 'pkt'. pts and flags are also
+ /** read one packet and put it in 'pkt'. pts and flags are also
set. 'av_new_stream' can be called only if the flag
AVFMTCTX_NOHEADER is used. */
int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
- /* close the stream. The AVFormatContext and AVStreams are not
+ /** close the stream. The AVFormatContext and AVStreams are not
freed by this function */
int (*read_close)(struct AVFormatContext *);
/**
@@ -200,23 +229,25 @@ typedef struct AVInputFormat {
*/
int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit);
- /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
+ /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
int flags;
- /* if extensions are defined, then no probe is done. You should
+ /** if extensions are defined, then no probe is done. You should
usually not use extension format guessing because it is not
reliable enough */
const char *extensions;
- /* general purpose read only value that the format can use */
+ /** general purpose read only value that the format can use */
int value;
- /* start/resume playing - only meaningful if using a network based format
+ /** start/resume playing - only meaningful if using a network based format
(RTSP) */
int (*read_play)(struct AVFormatContext *);
- /* pause playing - only meaningful if using a network based format
+ /** pause playing - only meaningful if using a network based format
(RTSP) */
int (*read_pause)(struct AVFormatContext *);
+ const struct AVCodecTag **codec_tag;
+
/* private fields */
struct AVInputFormat *next;
} AVInputFormat;
@@ -227,13 +258,13 @@ typedef struct AVIndexEntry {
#define AVINDEX_KEYFRAME 0x0001
int flags:2;
int size:30; //yeah trying to keep the size of this small to reduce memory requirements (its 24 vs 32 byte due to possible 8byte align)
- int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
+ int min_distance; /**< min distance between this and the previous keyframe, used to avoid unneeded searching */
} AVIndexEntry;
typedef struct AVStream {
- int index; /* stream index in AVFormatContext */
- int id; /* format specific stream id */
- AVCodecContext *codec; /* codec context */
+ int index; /**< stream index in AVFormatContext */
+ int id; /**< format specific stream id */
+ AVCodecContext *codec; /**< codec context */
/**
* real base frame rate of the stream.
* this is the lowest framerate with which all timestamps can be
@@ -244,10 +275,12 @@ typedef struct AVStream {
*/
AVRational r_frame_rate;
void *priv_data;
+#if LIBAVFORMAT_VERSION_INT < (52<<16)
/* internal data used in av_find_stream_info() */
int64_t codec_info_duration;
int codec_info_nb_frames;
- /* encoding: PTS generation when outputing stream */
+#endif
+ /** encoding: PTS generation when outputing stream */
AVFrac pts;
/**
@@ -257,22 +290,22 @@ typedef struct AVStream {
* identically 1.
*/
AVRational time_base;
- int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
+ int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
/* ffmpeg.c private use */
- int stream_copy; /* if TRUE, just copy stream */
+ int stream_copy; /**< if set, just copy stream */
enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
//FIXME move stuff to a flags field?
- /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
+ /** quality, as it has been removed from AVCodecContext and put in AVVideoFrame
* MN:dunno if thats the right place, for it */
float quality;
- /* decoding: position of the first frame of the component, in
+ /** decoding: position of the first frame of the component, in
AV_TIME_BASE fractional seconds. */
int64_t start_time;
- /* decoding: duration of the stream, in AV_TIME_BASE fractional
+ /** decoding: duration of the stream, in AV_TIME_BASE fractional
seconds. */
int64_t duration;
- char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
+ char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
/* av_read_frame() support */
int need_parsing; ///< 1->full parsing needed, 2->only parse headers dont repack
@@ -282,7 +315,7 @@ typedef struct AVStream {
int last_IP_duration;
int64_t last_IP_pts;
/* av_seek_frame() support */
- AVIndexEntry *index_entries; /* only used if the format does not
+ AVIndexEntry *index_entries; /**< only used if the format does not
support seeking natively */
int nb_index_entries;
unsigned int index_entries_allocated_size;
@@ -293,22 +326,22 @@ typedef struct AVStream {
int64_t pts_buffer[MAX_REORDER_DELAY+1];
} AVStream;
-#define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
+#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
(streams are added dynamically) */
#define MAX_STREAMS 20
/* format I/O context */
typedef struct AVFormatContext {
- const AVClass *av_class; /* set by av_alloc_format_context */
+ const AVClass *av_class; /**< set by av_alloc_format_context */
/* can only be iformat or oformat, not both at the same time */
struct AVInputFormat *iformat;
struct AVOutputFormat *oformat;
void *priv_data;
ByteIOContext pb;
- int nb_streams;
+ unsigned int nb_streams;
AVStream *streams[MAX_STREAMS];
- char filename[1024]; /* input or output filename */
+ char filename[1024]; /**< input or output filename */
/* stream info */
int64_t timestamp;
char title[512];
@@ -316,28 +349,28 @@ typedef struct AVFormatContext {
char copyright[512];
char comment[512];
char album[512];
- int year; /* ID3 year, 0 if none */
- int track; /* track number, 0 if none */
- char genre[32]; /* ID3 genre */
+ int year; /**< ID3 year, 0 if none */
+ int track; /**< track number, 0 if none */
+ char genre[32]; /**< ID3 genre */
- int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
+ int ctx_flags; /**< format specific flags, see AVFMTCTX_xx */
/* private data for pts handling (do not modify directly) */
- /* This buffer is only needed when packets were already buffered but
+ /** This buffer is only needed when packets were already buffered but
not decoded, for example to get the codec parameters in mpeg
streams */
struct AVPacketList *packet_buffer;
- /* decoding: position of the first frame of the component, in
+ /** decoding: position of the first frame of the component, in
AV_TIME_BASE fractional seconds. NEVER set this value directly:
it is deduced from the AVStream values. */
int64_t start_time;
- /* decoding: duration of the stream, in AV_TIME_BASE fractional
+ /** decoding: duration of the stream, in AV_TIME_BASE fractional
seconds. NEVER set this value directly: it is deduced from the
AVStream values. */
int64_t duration;
- /* decoding: total file size. 0 if unknown */
+ /** decoding: total file size. 0 if unknown */
int64_t file_size;
- /* decoding: total stream bitrate in bit/s, 0 if not
+ /** decoding: total stream bitrate in bit/s, 0 if not
available. Never set it directly if the file_size and the
duration are known as ffmpeg can compute it automatically. */
int bit_rate;
@@ -349,7 +382,7 @@ typedef struct AVFormatContext {
AVPacket cur_pkt;
/* av_seek_frame() support */
- int64_t data_offset; /* offset of the first packet */
+ int64_t data_offset; /** offset of the first packet */
int index_built;
int mux_rate;
@@ -359,7 +392,7 @@ typedef struct AVFormatContext {
#define AVFMT_NOOUTPUTLOOP -1
#define AVFMT_INFINITEOUTPUTLOOP 0
- /* number of times to loop output in formats that support it */
+ /** number of times to loop output in formats that support it */
int loop_output;
int flags;
@@ -367,8 +400,16 @@ typedef struct AVFormatContext {
#define AVFMT_FLAG_IGNIDX 0x0002 ///< ignore index
int loop_input;
- /* decoding: size of data to probe; encoding unused */
+ /** decoding: size of data to probe; encoding unused */
unsigned int probesize;
+
+ /**
+ * maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info()
+ */
+ int max_analyze_duration;
+
+ const uint8_t *key;
+ int keylen;
} AVFormatContext;
typedef struct AVPacketList {
@@ -395,43 +436,207 @@ AVOutputFormat *guess_stream_format(const char *short_name,
const char *filename, const char *mime_type);
AVOutputFormat *guess_format(const char *short_name,
const char *filename, const char *mime_type);
+
+/**
+ * Guesses the codec id based upon muxer and filename.
+ */
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
const char *filename, const char *mime_type, enum CodecType type);
+/**
+ * Send a nice hexadecimal dump of a buffer to the specified file stream.
+ *
+ * @param f The file stream pointer where the dump should be sent to.
+ * @param buf buffer
+ * @param size buffer size
+ *
+ * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
+ */
void av_hex_dump(FILE *f, uint8_t *buf, int size);
+
+/**
+ * Send a nice hexadecimal dump of a buffer to the log.
+ *
+ * @param avcl A pointer to an arbitrary struct of which the first field is a
+ * pointer to an AVClass struct.
+ * @param level The importance level of the message, lower values signifying
+ * higher importance.
+ * @param buf buffer
+ * @param size buffer size
+ *
+ * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
+ */
+void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
+
+/**
+ * Send a nice dump of a packet to the specified file stream.
+ *
+ * @param f The file stream pointer where the dump should be sent to.
+ * @param pkt packet to dump
+ * @param dump_payload true if the payload must be displayed too
+ */
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
+/**
+ * Send a nice dump of a packet to the log.
+ *
+ * @param avcl A pointer to an arbitrary struct of which the first field is a
+ * pointer to an AVClass struct.
+ * @param level The importance level of the message, lower values signifying
+ * higher importance.
+ * @param pkt packet to dump
+ * @param dump_payload true if the payload must be displayed too
+ */
+void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
+
void av_register_all(void);
+/** codec tag <-> codec id */
+enum CodecID av_codec_get_id(const struct AVCodecTag **tags, unsigned int tag);
+unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id);
+
/* media file input */
+
+/**
+ * finds AVInputFormat based on input format's short name.
+ */
AVInputFormat *av_find_input_format(const char *short_name);
+
+/**
+ * Guess file format.
+ *
+ * @param is_opened whether the file is already opened, determines whether
+ * demuxers with or without AVFMT_NOFILE are probed
+ */
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
+
+/**
+ * Allocates all the structures needed to read an input stream.
+ * This does not open the needed codecs for decoding the stream[s].
+ */
int av_open_input_stream(AVFormatContext **ic_ptr,
ByteIOContext *pb, const char *filename,
AVInputFormat *fmt, AVFormatParameters *ap);
+
+/**
+ * Open a media file as input. The codec are not opened. Only the file
+ * header (if present) is read.
+ *
+ * @param ic_ptr the opened media file handle is put here
+ * @param filename filename to open.
+ * @param fmt if non NULL, force the file format to use
+ * @param buf_size optional buffer size (zero if default is OK)
+ * @param ap additionnal parameters needed when opening the file (NULL if default)
+ * @return 0 if OK. AVERROR_xxx otherwise.
+ */
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap);
-/* no av_open for output, so applications will need this: */
+/** no av_open for output, so applications will need this: */
AVFormatContext *av_alloc_format_context(void);
-#define AVERROR_UNKNOWN (-1) /* unknown error */
-#define AVERROR_IO (-2) /* i/o error */
-#define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
-#define AVERROR_INVALIDDATA (-4) /* invalid data found */
-#define AVERROR_NOMEM (-5) /* not enough memory */
-#define AVERROR_NOFMT (-6) /* unknown format */
-#define AVERROR_NOTSUPP (-7) /* operation not supported */
-
+/**
+ * Read packets of a media file to get stream information. This
+ * is useful for file formats with no headers such as MPEG. This
+ * function also computes the real frame rate in case of mpeg2 repeat
+ * frame mode.
+ * The logical file position is not changed by this function;
+ * examined packets may be buffered for later processing.
+ *
+ * @param ic media file handle
+ * @return >=0 if OK. AVERROR_xxx if error.
+ * @todo let user decide somehow what information is needed so we dont waste time geting stuff the user doesnt need
+ */
int av_find_stream_info(AVFormatContext *ic);
+
+/**
+ * Read a transport packet from a media file.
+ *
+ * This function is absolete and should never be used.
+ * Use av_read_frame() instead.
+ *
+ * @param s media file handle
+ * @param pkt is filled
+ * @return 0 if OK. AVERROR_xxx if error.
+ */
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
+
+/**
+ * Return the next frame of a stream.
+ *
+ * The returned packet is valid
+ * until the next av_read_frame() or until av_close_input_file() and
+ * must be freed with av_free_packet. For video, the packet contains
+ * exactly one frame. For audio, it contains an integer number of
+ * frames if each frame has a known fixed size (e.g. PCM or ADPCM
+ * data). If the audio frames have a variable size (e.g. MPEG audio),
+ * then it contains one frame.
+ *
+ * pkt->pts, pkt->dts and pkt->duration are always set to correct
+ * values in AVStream.timebase units (and guessed if the format cannot
+ * provided them). pkt->pts can be AV_NOPTS_VALUE if the video format
+ * has B frames, so it is better to rely on pkt->dts if you do not
+ * decompress the payload.
+ *
+ * @return 0 if OK, < 0 if error or end of file.
+ */
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
+
+/**
+ * Seek to the key frame at timestamp.
+ * 'timestamp' in 'stream_index'.
+ * @param stream_index If stream_index is (-1), a default
+ * stream is selected, and timestamp is automatically converted
+ * from AV_TIME_BASE units to the stream specific time_base.
+ * @param timestamp timestamp in AVStream.time_base units
+ * or if there is no stream specified then in AV_TIME_BASE units
+ * @param flags flags which select direction and seeking mode
+ * @return >= 0 on success
+ */
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
+
+/**
+ * start playing a network based stream (e.g. RTSP stream) at the
+ * current position
+ */
int av_read_play(AVFormatContext *s);
+
+/**
+ * Pause a network based stream (e.g. RTSP stream).
+ *
+ * Use av_read_play() to resume it.
+ */
int av_read_pause(AVFormatContext *s);
+
+/**
+ * Close a media file (but not its codecs).
+ *
+ * @param s media file handle
+ */
void av_close_input_file(AVFormatContext *s);
+
+/**
+ * Add a new stream to a media file.
+ *
+ * Can only be called in the read_header() function. If the flag
+ * AVFMTCTX_NOHEADER is in the format context, then new streams
+ * can be added in read_packet too.
+ *
+ * @param s media file handle
+ * @param id file format dependent stream id
+ */
AVStream *av_new_stream(AVFormatContext *s, int id);
+
+/**
+ * Set the pts for a given stream.
+ *
+ * @param s stream
+ * @param pts_wrap_bits number of bits effectively used by the pts
+ * (used for wrap control, 33 is the value for MPEG)
+ * @param pts_num numerator to convert to seconds (MPEG: 1)
+ * @param pts_den denominator to convert to seconds (MPEG: 90000)
+ */
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
int pts_num, int pts_den);
@@ -440,28 +645,147 @@ void av_set_pts_info(AVStream *s, int pts_wrap_bits,
#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non keyframes
int av_find_default_stream_index(AVFormatContext *s);
+
+/**
+ * Gets the index for a specific timestamp.
+ * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to
+ * the timestamp which is <= the requested one, if backward is 0
+ * then it will be >=
+ * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
+ * @return < 0 if no such timestamp could be found
+ */
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
+
+/**
+ * Add a index entry into a sorted list updateing if it is already there.
+ *
+ * @param timestamp timestamp in the timebase of the given stream
+ */
int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int size, int distance, int flags);
+
+/**
+ * Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp().
+ * this isnt supposed to be called directly by a user application, but by demuxers
+ * @param target_ts target timestamp in the time base of the given stream
+ * @param stream_index stream number
+ */
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
+
+/**
+ * Updates cur_dts of all streams based on given timestamp and AVStream.
+ *
+ * Stream ref_st unchanged, others set cur_dts in their native timebase
+ * only needed for timestamp wrapping or if (dts not set and pts!=dts)
+ * @param timestamp new dts expressed in time_base of param ref_st
+ * @param ref_st reference stream giving time_base of param timestamp
+ */
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
+
+/**
+ * Does a binary search using read_timestamp().
+ * this isnt supposed to be called directly by a user application, but by demuxers
+ * @param target_ts target timestamp in the time base of the given stream
+ * @param stream_index stream number
+ */
int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
-/* media file output */
+/** media file output */
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
+
+/**
+ * allocate the stream private data and write the stream header to an
+ * output media file
+ *
+ * @param s media file handle
+ * @return 0 if OK. AVERROR_xxx if error.
+ */
int av_write_header(AVFormatContext *s);
+
+/**
+ * Write a packet to an output media file.
+ *
+ * The packet shall contain one audio or video frame.
+ * The packet must be correctly interleaved according to the container specification,
+ * if not then av_interleaved_write_frame must be used
+ *
+ * @param s media file handle
+ * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
+ * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
+ */
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
+
+/**
+ * Writes a packet to an output media file ensuring correct interleaving.
+ *
+ * The packet must contain one audio or video frame.
+ * If the packets are already correctly interleaved the application should
+ * call av_write_frame() instead as its slightly faster, its also important
+ * to keep in mind that completly non interleaved input will need huge amounts
+ * of memory to interleave with this, so its prefereable to interleave at the
+ * demuxer level
+ *
+ * @param s media file handle
+ * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
+ * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
+ */
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
+
+/**
+ * Interleave a packet per DTS in an output media file.
+ *
+ * Packets with pkt->destruct == av_destruct_packet will be freed inside this function,
+ * so they cannot be used after it, note calling av_free_packet() on them is still safe.
+ *
+ * @param s media file handle
+ * @param out the interleaved packet will be output here
+ * @param in the input packet
+ * @param flush 1 if no further packets are available as input and all
+ * remaining packets should be output
+ * @return 1 if a packet was output, 0 if no packet could be output,
+ * < 0 if an error occured
+ */
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush);
+/**
+ * @brief Write the stream trailer to an output media file and
+ * free the file private data.
+ *
+ * @param s media file handle
+ * @return 0 if OK. AVERROR_xxx if error.
+ */
int av_write_trailer(AVFormatContext *s);
void dump_format(AVFormatContext *ic,
int index,
const char *url,
int is_output);
+
+/**
+ * parses width and height out of string str.
+ */
int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
+
+/**
+ * Converts frame rate from string to a fraction.
+ */
int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
+
+/**
+ * Converts date string to number of seconds since Jan 1st, 1970.
+ *
+ * @code
+ * Syntax:
+ * - If not a duration:
+ * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
+ * Time is localtime unless Z is suffixed to the end. In this case GMT
+ * Return the date in micro seconds since 1970
+ *
+ * - If a duration:
+ * HH[:MM[:SS[.m...]]]
+ * S+[.m...]
+ * @endcode
+ */
int64_t parse_date(const char *datestr, int duration);
int64_t av_gettime(void);
@@ -472,10 +796,35 @@ offset_t ffm_read_write_index(int fd);
void ffm_write_write_index(int fd, offset_t pos);
void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
+/**
+ * Attempts to find a specific tag in a URL.
+ *
+ * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
+ * Return 1 if found.
+ */
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
+/**
+ * Returns in 'buf' the path with '%d' replaced by number.
+
+ * Also handles the '%0nd' format where 'n' is the total number
+ * of digits and '%%'.
+ *
+ * @param buf destination buffer
+ * @param buf_size destination buffer size
+ * @param path numbered sequence string
+ * @number frame number
+ * @return 0 if OK, -1 if format error.
+ */
int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number);
+
+/**
+ * Check whether filename actually is a numbered sequence generator.
+ *
+ * @param filename possible numbered sequence string
+ * @return 1 if a valid numbered sequence string, 0 otherwise.
+ */
int av_filename_number_test(const char *filename);
/* grab specific */
diff --git a/contrib/ffmpeg/libavformat/avidec.c b/contrib/ffmpeg/libavformat/avidec.c
index d1af79fa3..23c130ab7 100644
--- a/contrib/ffmpeg/libavformat/avidec.c
+++ b/contrib/ffmpeg/libavformat/avidec.c
@@ -82,6 +82,9 @@ static int get_riff(AVIContext *avi, ByteIOContext *pb)
avi->riff_end = get_le32(pb); /* RIFF chunk size */
avi->riff_end += url_ftell(pb); /* RIFF chunk end */
tag = get_le32(pb);
+ if(tag == MKTAG('A', 'V', 'I', 0x19))
+ av_log(NULL, AV_LOG_INFO, "file has been generated with a totally broken muxer\n");
+ else
if (tag != MKTAG('A', 'V', 'I', ' ') && tag != MKTAG('A', 'V', 'I', 'X'))
return -1;
@@ -213,7 +216,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
uint32_t tag, tag1, handler;
int codec_type, stream_index, frame_period, bit_rate;
unsigned int size, nb_frames;
- int i, n;
+ int i;
AVStream *st;
AVIStream *ast = NULL;
char str_track[4];
@@ -266,10 +269,22 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
avi->non_interleaved |= get_le32(pb) & AVIF_MUSTUSEINDEX;
url_fskip(pb, 2 * 4);
- n = get_le32(pb);
- for(i=0;i<n;i++) {
- AVIStream *ast;
- st = av_new_stream(s, i);
+ get_le32(pb);
+
+ url_fskip(pb, size - 7 * 4);
+ break;
+ case MKTAG('s', 't', 'r', 'h'):
+ /* stream header */
+
+ tag1 = get_le32(pb);
+ handler = get_le32(pb); /* codec tag */
+
+ if(tag1 == MKTAG('p', 'a', 'd', 's')){
+ url_fskip(pb, size - 8);
+ break;
+ }else{
+ stream_index++;
+ st = av_new_stream(s, stream_index);
if (!st)
goto fail;
@@ -278,17 +293,13 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto fail;
st->priv_data = ast;
}
- url_fskip(pb, size - 7 * 4);
- break;
- case MKTAG('s', 't', 'r', 'h'):
- /* stream header */
- stream_index++;
- tag1 = get_le32(pb);
- handler = get_le32(pb); /* codec tag */
+
#ifdef DEBUG
print_tag("strh", tag1, -1);
#endif
if(tag1 == MKTAG('i', 'a', 'v', 's') || tag1 == MKTAG('i', 'v', 'a', 's')){
+ int64_t dv_dur;
+
/*
* After some consideration -- I don't think we
* have to support anything but DV in a type1 AVIs.
@@ -314,20 +325,24 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(pb, 3 * 4);
ast->scale = get_le32(pb);
ast->rate = get_le32(pb);
+ url_fskip(pb, 4); /* start time */
+
+ dv_dur = get_le32(pb);
+ if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
+ dv_dur *= AV_TIME_BASE;
+ s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
+ }
+ /*
+ * else, leave duration alone; timing estimation in utils.c
+ * will make a guess based on bit rate.
+ */
+
stream_index = s->nb_streams - 1;
- url_fskip(pb, size - 7*4);
+ url_fskip(pb, size - 9*4);
break;
}
- if (stream_index >= s->nb_streams) {
- url_fskip(pb, size - 8);
- /* ignore padding stream */
- if (tag1 == MKTAG('p', 'a', 'd', 's'))
- stream_index--;
- break;
- }
- st = s->streams[stream_index];
- ast = st->priv_data;
+ assert(stream_index < s->nb_streams);
st->codec->stream_codec_tag= handler;
get_le32(pb); /* flags */
@@ -370,10 +385,6 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
//FIXME
codec_type = CODEC_TYPE_DATA; //CODEC_TYPE_SUB ? FIXME
break;
- case MKTAG('p', 'a', 'd', 's'):
- codec_type = CODEC_TYPE_UNKNOWN;
- stream_index--;
- break;
default:
av_log(s, AV_LOG_ERROR, "unknown stream type %X\n", tag1);
goto fail;
@@ -383,7 +394,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
break;
case MKTAG('s', 't', 'r', 'f'):
/* stream header */
- if (stream_index >= s->nb_streams || avi->dv_demux) {
+ if (stream_index >= (unsigned)s->nb_streams || avi->dv_demux) {
url_fskip(pb, size);
} else {
st = s->streams[stream_index];
@@ -492,6 +503,13 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
sscanf(str_track, "%d", &s->track);
break;
default:
+ if(size > 1000000){
+ av_log(s, AV_LOG_ERROR, "well something went wrong during header parsing, "
+ "ill ignore it and try to continue anyway\n");
+ avi->movi_list = url_ftell(pb) - 4;
+ avi->movi_end = url_fsize(pb);
+ goto end_of_header;
+ }
/* skip tag */
size += (size & 1);
url_fskip(pb, size);
@@ -612,21 +630,16 @@ resync:
pkt->stream_index = avi->stream_index;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
- if(st->index_entries){
- AVIndexEntry *e;
- int index;
+ AVIndexEntry *e;
+ int index;
+ assert(st->index_entries);
- index= av_index_search_timestamp(st, pkt->dts, 0);
- e= &st->index_entries[index];
+ index= av_index_search_timestamp(st, pkt->dts, 0);
+ e= &st->index_entries[index];
- if(index >= 0 && e->timestamp == ast->frame_offset){
- if (e->flags & AVINDEX_KEYFRAME)
- pkt->flags |= PKT_FLAG_KEY;
- }
- } else {
- /* if no index, better to say that all frames
- are key frames */
- pkt->flags |= PKT_FLAG_KEY;
+ if(index >= 0 && e->timestamp == ast->frame_offset){
+ if (e->flags & AVINDEX_KEYFRAME)
+ pkt->flags |= PKT_FLAG_KEY;
}
} else {
pkt->flags |= PKT_FLAG_KEY;
@@ -640,10 +653,6 @@ resync:
if(!ast->remaining){
avi->stream_index= -1;
ast->packet_size= 0;
- if (size & 1) {
- get_byte(pb);
- size++;
- }
}
return size;
@@ -725,6 +734,13 @@ resync:
avi->stream_index= n;
ast->packet_size= size + 8;
ast->remaining= size;
+
+ {
+ uint64_t pos= url_ftell(pb) - 8;
+ if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){
+ av_add_index_entry(st, pos, ast->frame_offset / FFMAX(1, ast->sample_size), size, 0, AVINDEX_KEYFRAME);
+ }
+ }
goto resync;
}
}
@@ -903,6 +919,21 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
// av_log(NULL, AV_LOG_DEBUG, "XX %"PRId64" %d %"PRId64"\n", timestamp, index, st->index_entries[index].timestamp);
+ if (ENABLE_DV_DEMUXER && avi->dv_demux) {
+ /* One and only one real stream for DV in AVI, and it has video */
+ /* offsets. Calling with other stream indices should have failed */
+ /* the av_index_search_timestamp call above. */
+ assert(stream_index == 0);
+
+ /* Feed the DV video stream version of the timestamp to the */
+ /* DV demux so it can synth correct timestamps */
+ dv_offset_reset(avi->dv_demux, timestamp);
+
+ url_fseek(&s->pb, pos, SEEK_SET);
+ avi->stream_index= -1;
+ return 0;
+ }
+
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
@@ -937,8 +968,6 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
ast2->frame_offset *=ast2->sample_size;
}
- if (ENABLE_DV_DEMUXER && avi->dv_demux)
- dv_flush_audio_packets(avi->dv_demux);
/* do the seek */
url_fseek(&s->pb, pos, SEEK_SET);
avi->stream_index= -1;
@@ -971,7 +1000,7 @@ static int avi_probe(AVProbeData *p)
if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
p->buf[2] == 'F' && p->buf[3] == 'F' &&
p->buf[8] == 'A' && p->buf[9] == 'V' &&
- p->buf[10] == 'I' && p->buf[11] == ' ')
+ p->buf[10] == 'I' && (p->buf[11] == ' ' || p->buf[11] == 0x19))
return AVPROBE_SCORE_MAX;
else
return 0;
diff --git a/contrib/ffmpeg/libavformat/avienc.c b/contrib/ffmpeg/libavformat/avienc.c
index 296608704..ac8b2670d 100644
--- a/contrib/ffmpeg/libavformat/avienc.c
+++ b/contrib/ffmpeg/libavformat/avienc.c
@@ -163,7 +163,7 @@ static int avi_write_header(AVFormatContext *s)
nb_frames = 0;
if(video_enc){
- put_le32(pb, (uint32_t)(int64_t_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
+ put_le32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
} else {
put_le32(pb, 0);
}
@@ -519,38 +519,37 @@ static int avi_write_trailer(AVFormatContext *s)
int i, j, n, nb_frames;
offset_t file_size;
- if (!url_is_streamed(pb))
- {
- if (avi->riff_id == 1) {
- end_tag(pb, avi->movi_list);
- res = avi_write_idx1(s);
- end_tag(pb, avi->riff_start);
- } else {
- avi_write_ix(s);
- end_tag(pb, avi->movi_list);
- end_tag(pb, avi->riff_start);
-
- file_size = url_ftell(pb);
- url_fseek(pb, avi->odml_list - 8, SEEK_SET);
- put_tag(pb, "LIST"); /* Making this AVI OpenDML one */
- url_fskip(pb, 16);
-
- for (n=nb_frames=0;n<s->nb_streams;n++) {
- AVCodecContext *stream = s->streams[n]->codec;
- if (stream->codec_type == CODEC_TYPE_VIDEO) {
- if (nb_frames < avi->packet_count[n])
- nb_frames = avi->packet_count[n];
- } else {
- if (stream->codec_id == CODEC_ID_MP2 || stream->codec_id == CODEC_ID_MP3) {
- nb_frames += avi->packet_count[n];
+ if (!url_is_streamed(pb)){
+ if (avi->riff_id == 1) {
+ end_tag(pb, avi->movi_list);
+ res = avi_write_idx1(s);
+ end_tag(pb, avi->riff_start);
+ } else {
+ avi_write_ix(s);
+ end_tag(pb, avi->movi_list);
+ end_tag(pb, avi->riff_start);
+
+ file_size = url_ftell(pb);
+ url_fseek(pb, avi->odml_list - 8, SEEK_SET);
+ put_tag(pb, "LIST"); /* Making this AVI OpenDML one */
+ url_fskip(pb, 16);
+
+ for (n=nb_frames=0;n<s->nb_streams;n++) {
+ AVCodecContext *stream = s->streams[n]->codec;
+ if (stream->codec_type == CODEC_TYPE_VIDEO) {
+ if (nb_frames < avi->packet_count[n])
+ nb_frames = avi->packet_count[n];
+ } else {
+ if (stream->codec_id == CODEC_ID_MP2 || stream->codec_id == CODEC_ID_MP3) {
+ nb_frames += avi->packet_count[n];
+ }
}
}
- }
- put_le32(pb, nb_frames);
- url_fseek(pb, file_size, SEEK_SET);
+ put_le32(pb, nb_frames);
+ url_fseek(pb, file_size, SEEK_SET);
- avi_write_counters(s, avi->riff_id);
- }
+ avi_write_counters(s, avi->riff_id);
+ }
}
put_flush_packet(pb);
@@ -576,5 +575,6 @@ AVOutputFormat avi_muxer = {
avi_write_header,
avi_write_packet,
avi_write_trailer,
+ .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0},
};
#endif //CONFIG_AVI_MUXER
diff --git a/contrib/ffmpeg/libavformat/avio.c b/contrib/ffmpeg/libavformat/avio.c
index a2b8a8325..a22bd22f3 100644
--- a/contrib/ffmpeg/libavformat/avio.c
+++ b/contrib/ffmpeg/libavformat/avio.c
@@ -67,14 +67,17 @@ int url_open(URLContext **puc, const char *filename, int flags)
goto found;
up = up->next;
}
- err = -ENOENT;
+ err = AVERROR(ENOENT);
goto fail;
found:
- uc = av_malloc(sizeof(URLContext) + strlen(filename));
+ uc = av_malloc(sizeof(URLContext) + strlen(filename) + 1);
if (!uc) {
- err = -ENOMEM;
+ err = AVERROR(ENOMEM);
goto fail;
}
+#if LIBAVFORMAT_VERSION_INT >= (52<<16)
+ uc->filename = (char *) &uc[1];
+#endif
strcpy(uc->filename, filename);
uc->prot = up;
uc->flags = flags;
@@ -121,7 +124,7 @@ offset_t url_seek(URLContext *h, offset_t pos, int whence)
offset_t ret;
if (!h->prot->url_seek)
- return -EPIPE;
+ return AVERROR(EPIPE);
ret = h->prot->url_seek(h, pos, whence);
return ret;
}
@@ -148,20 +151,17 @@ offset_t url_filesize(URLContext *h)
{
offset_t pos, size;
- pos = url_seek(h, 0, SEEK_CUR);
- size = url_seek(h, -1, SEEK_END)+1;
- url_seek(h, pos, SEEK_SET);
+ size= url_seek(h, 0, AVSEEK_SIZE);
+ if(size<0){
+ pos = url_seek(h, 0, SEEK_CUR);
+ if ((size = url_seek(h, -1, SEEK_END)) < 0)
+ return size;
+ size++;
+ url_seek(h, pos, SEEK_SET);
+ }
return size;
}
-/*
- * Return the maximum packet size associated to packetized file
- * handle. If the file is not packetized (stream like http or file on
- * disk), then 0 is returned.
- *
- * @param h file handle
- * @return maximum packet size in bytes
- */
int url_get_max_packet_size(URLContext *h)
{
return h->max_packet_size;
@@ -178,12 +178,6 @@ static int default_interrupt_cb(void)
return 0;
}
-/**
- * The callback is called in blocking functions to test regulary if
- * asynchronous interruption is needed. -EINTR is returned in this
- * case by the interrupted function. 'NULL' means no interrupt
- * callback is given.
- */
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
{
if (!interrupt_cb)
diff --git a/contrib/ffmpeg/libavformat/avio.h b/contrib/ffmpeg/libavformat/avio.h
index f0fd1a85c..be78c9a7b 100644
--- a/contrib/ffmpeg/libavformat/avio.h
+++ b/contrib/ffmpeg/libavformat/avio.h
@@ -30,10 +30,14 @@ typedef int64_t offset_t;
struct URLContext {
struct URLProtocol *prot;
int flags;
- int is_streamed; /* true if streamed (no seek possible), default = false */
- int max_packet_size; /* if non zero, the stream is packetized with this max packet size */
+ int is_streamed; /**< true if streamed (no seek possible), default = false */
+ int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */
void *priv_data;
- char filename[1]; /* specified filename */
+#if LIBAVFORMAT_VERSION_INT >= (52<<16)
+ char *filename; /**< specified filename */
+#else
+ char filename[1]; /**< specified filename */
+#endif
};
typedef struct URLContext URLContext;
@@ -57,18 +61,36 @@ offset_t url_seek(URLContext *h, offset_t pos, int whence);
int url_close(URLContext *h);
int url_exist(const char *filename);
offset_t url_filesize(URLContext *h);
+
+/**
+ * Return the maximum packet size associated to packetized file
+ * handle. If the file is not packetized (stream like http or file on
+ * disk), then 0 is returned.
+ *
+ * @param h file handle
+ * @return maximum packet size in bytes
+ */
int url_get_max_packet_size(URLContext *h);
void url_get_filename(URLContext *h, char *buf, int buf_size);
-/* the callback is called in blocking functions to test regulary if
- asynchronous interruption is needed. -EINTR is returned in this
- case by the interrupted function. 'NULL' means no interrupt
- callback is given. */
+/**
+ * the callback is called in blocking functions to test regulary if
+ * asynchronous interruption is needed. AVERROR(EINTR) is returned
+ * in this case by the interrupted function. 'NULL' means no interrupt
+ * callback is given. i
+ */
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
/* not implemented */
int url_poll(URLPollEntry *poll_table, int n, int timeout);
+/**
+ * passing this as the "whence" parameter to a seek function causes it to
+ * return the filesize without seeking anywhere, supporting this is optional
+ * if its not supprted then the seek function will return <0
+ */
+#define AVSEEK_SIZE 0x10000
+
typedef struct URLProtocol {
const char *name;
int (*url_open)(URLContext *h, const char *filename, int flags);
@@ -92,10 +114,10 @@ typedef struct {
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
offset_t (*seek)(void *opaque, offset_t offset, int whence);
- offset_t pos; /* position in the file of the current buffer */
- int must_flush; /* true if the next seek should flush */
- int eof_reached; /* true if eof reached */
- int write_flag; /* true if open for writing */
+ offset_t pos; /**< position in the file of the current buffer */
+ int must_flush; /**< true if the next seek should flush */
+ int eof_reached; /**< true if eof reached */
+ int write_flag; /**< true if open for writing */
int is_streamed;
int max_packet_size;
unsigned long checksum;
@@ -135,18 +157,27 @@ int url_feof(ByteIOContext *s);
int url_ferror(ByteIOContext *s);
#define URL_EOF (-1)
+/** @note return URL_EOF (-1) if EOF */
int url_fgetc(ByteIOContext *s);
+
+/** @warning currently size is limited */
#ifdef __GNUC__
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
#else
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
#endif
+
+/** @note unlike fgets, the EOL character is not returned and a whole
+ line is parsed. return NULL if first char read was EOF */
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
void put_flush_packet(ByteIOContext *s);
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
+
+/** @note return 0 if EOF, so you cannot use it if EOF handling is
+ necessary */
int get_byte(ByteIOContext *s);
unsigned int get_le24(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s);
@@ -165,17 +196,57 @@ static inline int url_is_streamed(ByteIOContext *s)
}
int url_fdopen(ByteIOContext *s, URLContext *h);
+
+/** @warning must be called before any I/O */
int url_setbufsize(ByteIOContext *s, int buf_size);
+
+/** @note when opened as read/write, the buffers are only used for
+ reading */
int url_fopen(ByteIOContext *s, const char *filename, int flags);
int url_fclose(ByteIOContext *s);
URLContext *url_fileno(ByteIOContext *s);
+
+/**
+ * Return the maximum packet size associated to packetized buffered file
+ * handle. If the file is not packetized (stream like http or file on
+ * disk), then 0 is returned.
+ *
+ * @param h buffered file handle
+ * @return maximum packet size in bytes
+ */
int url_fget_max_packet_size(ByteIOContext *s);
int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
+
+/** return the written or read size */
int url_close_buf(ByteIOContext *s);
+/**
+ * Open a write only memory stream.
+ *
+ * @param s new IO context
+ * @return zero if no error.
+ */
int url_open_dyn_buf(ByteIOContext *s);
+
+/**
+ * Open a write only packetized memory stream with a maximum packet
+ * size of 'max_packet_size'. The stream is stored in a memory buffer
+ * with a big endian 4 byte header giving the packet size in bytes.
+ *
+ * @param s new IO context
+ * @param max_packet_size maximum packet size (must be > 0)
+ * @return zero if no error.
+ */
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
+
+/**
+ * Return the written size and a pointer to the buffer. The buffer
+ * must be freed with av_free().
+ * @param s IO context
+ * @param pointer to a byte buffer
+ * @return the length of the byte buffer
+ */
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
unsigned long get_checksum(ByteIOContext *s);
diff --git a/contrib/ffmpeg/libavformat/aviobuf.c b/contrib/ffmpeg/libavformat/aviobuf.c
index 866641ad0..2cc247b62 100644
--- a/contrib/ffmpeg/libavformat/aviobuf.c
+++ b/contrib/ffmpeg/libavformat/aviobuf.c
@@ -117,7 +117,7 @@ offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));
if (whence != SEEK_CUR && whence != SEEK_SET)
- return -EINVAL;
+ return AVERROR(EINVAL);
if (whence == SEEK_CUR) {
offset1 = pos + (s->buf_ptr - s->buffer);
@@ -136,6 +136,8 @@ offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
fill_buffer(s);
s->buf_ptr = s->buf_end + offset - s->pos;
} else {
+ offset_t res = AVERROR(EPIPE);
+
#if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK)
if (s->write_flag) {
flush_buffer(s);
@@ -146,8 +148,8 @@ offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
s->buf_end = s->buffer;
}
s->buf_ptr = s->buffer;
- if (!s->seek || s->seek(s->opaque, offset, SEEK_SET) == (offset_t)-EPIPE)
- return -EPIPE;
+ if (!s->seek || (res = s->seek(s->opaque, offset, SEEK_SET)) < 0)
+ return res;
s->pos = offset;
}
s->eof_reached = 0;
@@ -169,9 +171,14 @@ offset_t url_fsize(ByteIOContext *s)
offset_t size;
if (!s->seek)
- return -EPIPE;
- size = s->seek(s->opaque, -1, SEEK_END) + 1;
- s->seek(s->opaque, s->pos, SEEK_SET);
+ return AVERROR(EPIPE);
+ size = s->seek(s->opaque, 0, AVSEEK_SIZE);
+ if(size<0){
+ if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0)
+ return size;
+ size++;
+ s->seek(s->opaque, s->pos, SEEK_SET);
+ }
return size;
}
@@ -185,7 +192,6 @@ int url_ferror(ByteIOContext *s)
return s->error;
}
-#if defined(CONFIG_MUXERS) || defined(CONFIG_PROTOCOLS)
void put_le32(ByteIOContext *s, unsigned int val)
{
put_byte(s, val);
@@ -252,7 +258,6 @@ void put_tag(ByteIOContext *s, const char *tag)
put_byte(s, *tag++);
}
}
-#endif //CONFIG_MUXERS || CONFIG_PROTOCOLS
/* Input stream */
@@ -298,8 +303,6 @@ void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned l
}
}
-/* NOTE: return 0 if EOF, so you cannot use it if EOF handling is
- necessary */
/* XXX: put an inline version */
int get_byte(ByteIOContext *s)
{
@@ -314,7 +317,6 @@ int get_byte(ByteIOContext *s)
}
}
-/* NOTE: return URL_EOF (-1) if EOF */
int url_fgetc(ByteIOContext *s)
{
if (s->buf_ptr < s->buf_end) {
@@ -506,7 +508,7 @@ int url_fdopen(ByteIOContext *s, URLContext *h)
}
buffer = av_malloc(buffer_size);
if (!buffer)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
if (init_put_byte(s, buffer, buffer_size,
(h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
@@ -519,13 +521,12 @@ int url_fdopen(ByteIOContext *s, URLContext *h)
return 0;
}
-/* XXX: must be called before any I/O */
int url_setbufsize(ByteIOContext *s, int buf_size)
{
uint8_t *buffer;
buffer = av_malloc(buf_size);
if (!buffer)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
av_free(s->buffer);
s->buffer = buffer;
@@ -538,8 +539,6 @@ int url_setbufsize(ByteIOContext *s, int buf_size)
return 0;
}
-/* NOTE: when opened as read/write, the buffers are only used for
- reading */
int url_fopen(ByteIOContext *s, const char *filename, int flags)
{
URLContext *h;
@@ -571,7 +570,6 @@ URLContext *url_fileno(ByteIOContext *s)
}
#ifdef CONFIG_MUXERS
-/* XXX: currently size is limited */
int url_fprintf(ByteIOContext *s, const char *fmt, ...)
{
va_list ap;
@@ -586,8 +584,6 @@ int url_fprintf(ByteIOContext *s, const char *fmt, ...)
}
#endif //CONFIG_MUXERS
-/* note: unlike fgets, the EOL character is not returned and a whole
- line is parsed. return NULL if first char read was EOF */
char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
{
int c;
@@ -609,14 +605,6 @@ char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
return buf;
}
-/*
- * Return the maximum packet size associated to packetized buffered file
- * handle. If the file is not packetized (stream like http or file on
- * disk), then 0 is returned.
- *
- * @param h buffered file handle
- * @return maximum packet size in bytes
- */
int url_fget_max_packet_size(ByteIOContext *s)
{
return s->max_packet_size;
@@ -633,7 +621,6 @@ int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags)
NULL, NULL, NULL, NULL);
}
-/* return the written or read size */
int url_close_buf(ByteIOContext *s)
{
put_flush_packet(s);
@@ -741,26 +728,11 @@ static int url_open_dyn_buf_internal(ByteIOContext *s, int max_packet_size)
return ret;
}
-/*
- * Open a write only memory stream.
- *
- * @param s new IO context
- * @return zero if no error.
- */
int url_open_dyn_buf(ByteIOContext *s)
{
return url_open_dyn_buf_internal(s, 0);
}
-/*
- * Open a write only packetized memory stream with a maximum packet
- * size of 'max_packet_size'. The stream is stored in a memory buffer
- * with a big endian 4 byte header giving the packet size in bytes.
- *
- * @param s new IO context
- * @param max_packet_size maximum packet size (must be > 0)
- * @return zero if no error.
- */
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size)
{
if (max_packet_size <= 0)
@@ -768,13 +740,6 @@ int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size)
return url_open_dyn_buf_internal(s, max_packet_size);
}
-/*
- * Return the written size and a pointer to the buffer. The buffer
- * must be freed with av_free().
- * @param s IO context
- * @param pointer to a byte buffer
- * @return the length of the byte buffer
- */
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
{
DynBuffer *d = s->opaque;
diff --git a/contrib/ffmpeg/libavformat/beosaudio.cpp b/contrib/ffmpeg/libavformat/beosaudio.cpp
index 6ac45ebb2..6c16f0048 100644
--- a/contrib/ffmpeg/libavformat/beosaudio.cpp
+++ b/contrib/ffmpeg/libavformat/beosaudio.cpp
@@ -194,15 +194,15 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
#ifndef HAVE_BSOUNDRECORDER
if (!is_output)
- return -EIO; /* not for now */
+ return AVERROR(EIO); /* not for now */
#endif
s->input_sem = create_sem(AUDIO_BUFFER_SIZE, "ffmpeg_ringbuffer_input");
if (s->input_sem < B_OK)
- return -EIO;
+ return AVERROR(EIO);
s->output_sem = create_sem(0, "ffmpeg_ringbuffer_output");
if (s->output_sem < B_OK) {
delete_sem(s->input_sem);
- return -EIO;
+ return AVERROR(EIO);
}
s->input_index = 0;
s->output_index = 0;
@@ -226,7 +226,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
delete_sem(s->input_sem);
if (s->output_sem)
delete_sem(s->output_sem);
- return -EIO;
+ return AVERROR(EIO);
}
s->codec_id = (iformat.byte_order == B_MEDIA_LITTLE_ENDIAN)?CODEC_ID_PCM_S16LE:CODEC_ID_PCM_S16BE;
s->channels = iformat.channel_count;
@@ -252,7 +252,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
delete_sem(s->input_sem);
if (s->output_sem)
delete_sem(s->output_sem);
- return -EIO;
+ return AVERROR(EIO);
}
s->player->SetCookie(s);
s->player->SetVolume(1.0);
@@ -293,7 +293,7 @@ static int audio_write_header(AVFormatContext *s1)
s->channels = st->codec->channels;
ret = audio_open(s, 1, NULL);
if (ret < 0)
- return -EIO;
+ return AVERROR(EIO);
return 0;
}
@@ -315,7 +315,7 @@ lat1 = s->player->Latency();
int amount;
len = MIN(size, AUDIO_BLOCK_SIZE);
if (acquire_sem_etc(s->input_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK)
- return -EIO;
+ return AVERROR(EIO);
amount = MIN(len, (AUDIO_BUFFER_SIZE - s->input_index));
memcpy(&s->buffer[s->input_index], buf, amount);
s->input_index += amount;
@@ -356,15 +356,15 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0);
if (!st) {
- return -ENOMEM;
+ return AVERROR(ENOMEM);
}
s->sample_rate = ap->sample_rate;
s->channels = ap->channels;
- ret = audio_open(s, 0, ap->device);
+ ret = audio_open(s, 0, s1->filename);
if (ret < 0) {
av_free(st);
- return -EIO;
+ return AVERROR(EIO);
}
/* take real parameters */
st->codec->codec_type = CODEC_TYPE_AUDIO;
@@ -384,7 +384,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
status_t err;
if (av_new_packet(pkt, s->frame_size) < 0)
- return -EIO;
+ return AVERROR(EIO);
buf = (unsigned char *)pkt->data;
size = pkt->size;
while (size > 0) {
@@ -393,7 +393,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
while ((err=acquire_sem_etc(s->output_sem, len, B_CAN_INTERRUPT, 0LL)) == B_INTERRUPTED);
if (err < B_OK) {
av_free_packet(pkt);
- return -EIO;
+ return AVERROR(EIO);
}
amount = MIN(len, (AUDIO_BUFFER_SIZE - s->output_index));
memcpy(buf, &s->buffer[s->output_index], amount);
diff --git a/contrib/ffmpeg/libavformat/dc1394.c b/contrib/ffmpeg/libavformat/dc1394.c
index 5098c0fdf..bf140c466 100644
--- a/contrib/ffmpeg/libavformat/dc1394.c
+++ b/contrib/ffmpeg/libavformat/dc1394.c
@@ -42,7 +42,7 @@ struct dc1394_frame_format {
int frame_size_id;
} dc1394_frame_formats[] = {
{ 320, 240, PIX_FMT_UYVY422, MODE_320x240_YUV422 },
- { 640, 480, PIX_FMT_UYVY411, MODE_640x480_YUV411 },
+ { 640, 480, PIX_FMT_UYYVYY411, MODE_640x480_YUV411 },
{ 640, 480, PIX_FMT_UYVY422, MODE_640x480_YUV422 },
{ 0, 0, 0, MODE_320x240_YUV422 } /* default -- gotta be the last one */
};
@@ -118,7 +118,7 @@ static int dc1394_read_header(AVFormatContext *c, AVFormatParameters * ap)
fmt->frame_size_id,
SPEED_400,
fps->frame_rate_id, 8, 1,
- ap->device,
+ c->filename,
&dc1394->camera);
dc1394_free_camera_nodes(camera_nodes);
if (res != DC1394_SUCCESS) {
diff --git a/contrib/ffmpeg/libavformat/dsicin.c b/contrib/ffmpeg/libavformat/dsicin.c
index f274eadf8..fb9cb50df 100644
--- a/contrib/ffmpeg/libavformat/dsicin.c
+++ b/contrib/ffmpeg/libavformat/dsicin.c
@@ -62,11 +62,11 @@ static int cin_probe(AVProbeData *p)
return 0;
/* header starts with this special marker */
- if (LE_32(&p->buf[0]) != 0x55AA0000)
+ if (AV_RL32(&p->buf[0]) != 0x55AA0000)
return 0;
/* for accuracy, check some header field values */
- if (LE_32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)
+ if (AV_RL32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)
return 0;
return AVPROBE_SCORE_MAX;
diff --git a/contrib/ffmpeg/libavformat/dv.c b/contrib/ffmpeg/libavformat/dv.c
index 3ff8a3fe2..10a306260 100644
--- a/contrib/ffmpeg/libavformat/dv.c
+++ b/contrib/ffmpeg/libavformat/dv.c
@@ -358,8 +358,13 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
return offset;
}
-void dv_flush_audio_packets(DVDemuxContext *c)
+void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
+ c->frames= frame_offset;
+ if (c->ach)
+ c->abytes= av_rescale(c->frames,
+ c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
+ 8*c->sys->frame_rate);
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
}
@@ -419,13 +424,8 @@ static int dv_read_seek(AVFormatContext *s, int stream_index,
DVDemuxContext *c = r->dv_demux;
int64_t offset= dv_frame_offset(s, c, timestamp, flags);
- c->frames= offset / c->sys->frame_size;
- if (c->ach)
- c->abytes= av_rescale(c->frames,
- c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
- 8*c->sys->frame_rate);
+ dv_offset_reset(c, offset / c->sys->frame_size);
- dv_flush_audio_packets(c);
return url_fseek(&s->pb, offset, SEEK_SET);
}
diff --git a/contrib/ffmpeg/libavformat/dv.h b/contrib/ffmpeg/libavformat/dv.h
index f39d22c9f..2fa30036c 100644
--- a/contrib/ffmpeg/libavformat/dv.h
+++ b/contrib/ffmpeg/libavformat/dv.h
@@ -29,7 +29,7 @@ typedef struct DVDemuxContext DVDemuxContext;
DVDemuxContext* dv_init_demux(AVFormatContext* s);
int dv_get_packet(DVDemuxContext*, AVPacket *);
int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int);
-void dv_flush_audio_packets(DVDemuxContext*);
+void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
typedef struct DVMuxContext DVMuxContext;
DVMuxContext* dv_init_mux(AVFormatContext* s);
diff --git a/contrib/ffmpeg/libavformat/dv1394.c b/contrib/ffmpeg/libavformat/dv1394.c
index f00d47435..3a5f479c8 100644
--- a/contrib/ffmpeg/libavformat/dv1394.c
+++ b/contrib/ffmpeg/libavformat/dv1394.c
@@ -40,7 +40,7 @@ struct dv1394_data {
int channel;
int format;
- void *ring; /* Ring buffer */
+ uint8_t *ring; /* Ring buffer */
int index; /* Current frame index */
int avail; /* Number of frames available for reading */
int done; /* Number of completed frames */
@@ -83,7 +83,6 @@ static int dv1394_start(struct dv1394_data *dv)
static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap)
{
struct dv1394_data *dv = context->priv_data;
- const char *video_device;
dv->dv_demux = dv_init_demux(context);
if (!dv->dv_demux)
@@ -100,10 +99,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
dv->channel = DV1394_DEFAULT_CHANNEL;
/* Open and initialize DV1394 device */
- video_device = ap->device;
- if (!video_device)
- video_device = "/dev/dv1394/0";
- dv->fd = open(video_device, O_RDONLY);
+ dv->fd = open(context->filename, O_RDONLY);
if (dv->fd < 0) {
perror("Failed to open DV interface");
goto failed;
diff --git a/contrib/ffmpeg/libavformat/dvenc.c b/contrib/ffmpeg/libavformat/dvenc.c
index 79cee7af6..bdac43784 100644
--- a/contrib/ffmpeg/libavformat/dvenc.c
+++ b/contrib/ffmpeg/libavformat/dvenc.c
@@ -28,6 +28,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <time.h>
+#include <stdarg.h>
#include "avformat.h"
#include "dvdata.h"
#include "dv.h"
@@ -66,11 +67,12 @@ static int dv_audio_frame_size(const DVprofile* sys, int frame)
sizeof(sys->audio_samples_dist[0]))];
}
-static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* buf)
+static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* buf, ...)
{
struct tm tc;
time_t ct;
int ltc_frame;
+ va_list ap;
buf[0] = (uint8_t)pack_id;
switch (pack_id) {
@@ -99,7 +101,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
(tc.tm_hour % 10); /* Units of hours */
break;
case dv_audio_source: /* AAUX source pack */
- buf[1] = (0 << 7) | /* locked mode */
+ va_start(ap, buf);
+ buf[1] = (1 << 7) | /* locked mode -- SMPTE only supports locked mode */
(1 << 6) | /* reserved -- always 1 */
(dv_audio_frame_size(c->sys, c->frames) -
c->sys->audio_min_samples[0]);
@@ -107,7 +110,7 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
buf[2] = (0 << 7) | /* multi-stereo */
(0 << 5) | /* #of audio channels per block: 0 -- 1 channel */
(0 << 4) | /* pair bit: 0 -- one pair of channels */
- 0; /* audio mode */
+ !!va_arg(ap, int); /* audio mode */
buf[3] = (1 << 7) | /* res */
(1 << 6) | /* multi-language flag */
(c->sys->dsf << 5) | /* system: 60fields/50fields */
@@ -116,6 +119,7 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
(0 << 6) | /* emphasis time constant: 0 -- reserved */
(0 << 3) | /* frequency: 0 -- 48Khz, 1 -- 44,1Khz, 2 -- 32Khz */
0; /* quantization: 0 -- 16bit linear, 1 -- 12bit nonlinear */
+ va_end(ap);
break;
case dv_audio_control:
buf[1] = (0 << 6) | /* copy protection: 0 -- unrestricted */
@@ -179,7 +183,7 @@ static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr)
for (i = 0; i < c->sys->difseg_size; i++) {
frame_ptr += 6 * 80; /* skip DIF segment header */
for (j = 0; j < 9; j++) {
- dv_write_pack(dv_aaux_packs_dist[i][j], c, &frame_ptr[3]);
+ dv_write_pack(dv_aaux_packs_dist[i][j], c, &frame_ptr[3], i >= c->sys->difseg_size/2);
for (d = 8; d < 80; d+=2) {
of = c->sys->audio_shuffle[i][j] + (d - 8)/2 * c->sys->audio_stride;
if (of*2 >= size)
diff --git a/contrib/ffmpeg/libavformat/dxa.c b/contrib/ffmpeg/libavformat/dxa.c
new file mode 100644
index 000000000..f49d3d4ac
--- /dev/null
+++ b/contrib/ffmpeg/libavformat/dxa.c
@@ -0,0 +1,214 @@
+/*
+ * DXA demuxer
+ * Copyright (c) 2007 Konstantin Shishkov.
+ *
+ * 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 "avformat.h"
+#include "riff.h"
+
+#define DXA_EXTRA_SIZE 9
+
+typedef struct{
+ int frames;
+ int has_sound;
+ int bpc;
+ uint32_t bytes_left;
+ int64_t wavpos, vidpos;
+ int readvid;
+}DXAContext;
+
+static int dxa_probe(AVProbeData *p)
+{
+ /* check file header */
+ if (p->buf_size <= 4)
+ return 0;
+ if (p->buf[0] == 'D' && p->buf[1] == 'E' &&
+ p->buf[2] == 'X' && p->buf[3] == 'A')
+ return AVPROBE_SCORE_MAX;
+ else
+ return 0;
+}
+
+static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+ ByteIOContext *pb = &s->pb;
+ DXAContext *c = s->priv_data;
+ AVStream *st, *ast;
+ uint32_t tag;
+ int32_t fps;
+ int w, h;
+ int num, den;
+ int flags;
+
+ tag = get_le32(pb);
+ if (tag != MKTAG('D', 'E', 'X', 'A'))
+ return -1;
+ flags = get_byte(pb);
+ c->frames = get_be16(pb);
+ if(!c->frames){
+ av_log(s, AV_LOG_ERROR, "File contains no frames ???\n");
+ return -1;
+ }
+
+ fps = get_be32(pb);
+ if(fps > 0){
+ den = 1000;
+ num = fps;
+ }else if (fps < 0){
+ den = 100000;
+ num = -fps;
+ }else{
+ den = 10;
+ num = 1;
+ }
+ w = get_be16(pb);
+ h = get_be16(pb);
+ c->has_sound = 0;
+
+ st = av_new_stream(s, 0);
+ if (!st)
+ return -1;
+
+ // Parse WAV data header
+ if(get_le32(pb) == MKTAG('W', 'A', 'V', 'E')){
+ uint32_t size, fsize;
+ c->has_sound = 1;
+ size = get_be32(pb);
+ c->vidpos = url_ftell(pb) + size;
+ url_fskip(pb, 16);
+ fsize = get_le32(pb);
+
+ ast = av_new_stream(s, 0);
+ if (!ast)
+ return -1;
+ get_wav_header(pb, ast->codec, fsize);
+ // find 'data' chunk
+ while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
+ tag = get_le32(pb);
+ fsize = get_le32(pb);
+ if(tag == MKTAG('d', 'a', 't', 'a')) break;
+ url_fskip(pb, fsize);
+ }
+ c->bpc = (fsize + c->frames - 1) / c->frames;
+ if(ast->codec->block_align)
+ c->bpc = ((c->bpc + ast->codec->block_align - 1) / ast->codec->block_align) * ast->codec->block_align;
+ c->bytes_left = fsize;
+ c->wavpos = url_ftell(pb);
+ url_fseek(pb, c->vidpos, SEEK_SET);
+ }
+
+ /* now we are ready: build format streams */
+ st->codec->codec_type = CODEC_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_DXA;
+ st->codec->width = w;
+ st->codec->height = h;
+ av_reduce(&den, &num, den, num, (1UL<<31)-1);
+ av_set_pts_info(st, 33, num, den);
+ /* flags & 0x80 means that image is interlaced,
+ * flags & 0x40 means that image has double height
+ * either way set true height
+ */
+ if(flags & 0xC0){
+ st->codec->height >>= 1;
+ }
+ c->readvid = !c->has_sound;
+ c->vidpos = url_ftell(pb);
+ s->start_time = 0;
+ s->duration = (int64_t)c->frames * AV_TIME_BASE * num / den;
+ av_log(s, AV_LOG_DEBUG, "%d frame(s)\n",c->frames);
+
+ return 0;
+}
+
+static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ DXAContext *c = s->priv_data;
+ int ret;
+ uint32_t size;
+ uint8_t buf[DXA_EXTRA_SIZE], pal[768+4];
+ int pal_size = 0;
+
+ if(!c->readvid && c->has_sound && c->bytes_left){
+ c->readvid = 1;
+ url_fseek(&s->pb, c->wavpos, SEEK_SET);
+ size = FFMIN(c->bytes_left, c->bpc);
+ ret = av_get_packet(&s->pb, pkt, size);
+ pkt->stream_index = 1;
+ if(ret != size)
+ return AVERROR_IO;
+ c->bytes_left -= size;
+ c->wavpos = url_ftell(&s->pb);
+ return 0;
+ }
+ url_fseek(&s->pb, c->vidpos, SEEK_SET);
+ while(!url_feof(&s->pb) && c->frames){
+ get_buffer(&s->pb, buf, 4);
+ switch(AV_RL32(buf)){
+ case MKTAG('N', 'U', 'L', 'L'):
+ if(av_new_packet(pkt, 4 + pal_size) < 0)
+ return AVERROR_NOMEM;
+ pkt->stream_index = 0;
+ if(pal_size) memcpy(pkt->data, pal, pal_size);
+ memcpy(pkt->data + pal_size, buf, 4);
+ c->frames--;
+ c->vidpos = url_ftell(&s->pb);
+ c->readvid = 0;
+ return 0;
+ case MKTAG('C', 'M', 'A', 'P'):
+ pal_size = 768+4;
+ memcpy(pal, buf, 4);
+ get_buffer(&s->pb, pal + 4, 768);
+ break;
+ case MKTAG('F', 'R', 'A', 'M'):
+ get_buffer(&s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
+ size = AV_RB32(buf + 5);
+ if(size > 0xFFFFFF){
+ av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
+ return -1;
+ }
+ if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
+ return AVERROR_NOMEM;
+ memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
+ ret = get_buffer(&s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
+ if(ret != size){
+ av_free_packet(pkt);
+ return AVERROR_IO;
+ }
+ if(pal_size) memcpy(pkt->data, pal, pal_size);
+ pkt->stream_index = 0;
+ c->frames--;
+ c->vidpos = url_ftell(&s->pb);
+ c->readvid = 0;
+ return 0;
+ default:
+ av_log(s, AV_LOG_ERROR, "Unknown tag %c%c%c%c\n", buf[0], buf[1], buf[2], buf[3]);
+ return -1;
+ }
+ }
+ return AVERROR(EIO);
+}
+
+AVInputFormat dxa_demuxer = {
+ "dxa",
+ "dxa",
+ sizeof(DXAContext),
+ dxa_probe,
+ dxa_read_header,
+ dxa_read_packet,
+};
diff --git a/contrib/ffmpeg/libavformat/electronicarts.c b/contrib/ffmpeg/libavformat/electronicarts.c
index 943f75b42..762d658ab 100644
--- a/contrib/ffmpeg/libavformat/electronicarts.c
+++ b/contrib/ffmpeg/libavformat/electronicarts.c
@@ -168,7 +168,7 @@ static int ea_probe(AVProbeData *p)
if (p->buf_size < 4)
return 0;
- if (LE_32(&p->buf[0]) != SCHl_TAG)
+ if (AV_RL32(&p->buf[0]) != SCHl_TAG)
return 0;
return AVPROBE_SCORE_MAX;
@@ -230,8 +230,8 @@ static int ea_read_packet(AVFormatContext *s,
if (get_buffer(pb, preamble, EA_PREAMBLE_SIZE) != EA_PREAMBLE_SIZE)
return AVERROR_IO;
- chunk_type = LE_32(&preamble[0]);
- chunk_size = LE_32(&preamble[4]) - EA_PREAMBLE_SIZE;
+ chunk_type = AV_RL32(&preamble[0]);
+ chunk_size = AV_RL32(&preamble[4]) - EA_PREAMBLE_SIZE;
switch (chunk_type) {
/* audio data */
diff --git a/contrib/ffmpeg/libavformat/ffm.c b/contrib/ffmpeg/libavformat/ffm.c
index 539b45d5f..a2970ae42 100644
--- a/contrib/ffmpeg/libavformat/ffm.c
+++ b/contrib/ffmpeg/libavformat/ffm.c
@@ -201,6 +201,7 @@ static int ffm_write_header(AVFormatContext *s)
put_be32(pb, codec->nsse_weight);
put_be32(pb, codec->frame_skip_cmp);
put_be64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
+ put_be32(pb, codec->codec_tag);
break;
case CODEC_TYPE_AUDIO:
put_be32(pb, codec->sample_rate);
@@ -469,7 +470,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
ffm->file_size = url_fsize(pb);
adjust_write_index(s);
} else {
- ffm->file_size = (uint64_t_C(1) << 63) - 1;
+ ffm->file_size = (UINT64_C(1) << 63) - 1;
}
nb_streams = get_be32(pb);
@@ -534,6 +535,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec->nsse_weight = get_be32(pb);
codec->frame_skip_cmp = get_be32(pb);
codec->rc_buffer_aggressivity = av_int2dbl(get_be64(pb));
+ codec->codec_tag = get_be32(pb);
break;
case CODEC_TYPE_AUDIO:
codec->sample_rate = get_be32(pb);
@@ -579,7 +581,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
switch(ffm->read_state) {
case READ_HEADER:
if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) {
- return -EAGAIN;
+ return AVERROR(EAGAIN);
}
#if 0
printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
@@ -587,7 +589,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
#endif
if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
FRAME_HEADER_SIZE)
- return -EAGAIN;
+ return AVERROR(EAGAIN);
#if 0
{
int i;
@@ -601,7 +603,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
case READ_DATA:
size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4];
if (!ffm_is_avail_data(s, size)) {
- return -EAGAIN;
+ return AVERROR(EAGAIN);
}
duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7];
@@ -616,7 +618,7 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
if (ffm_read_data(s, pkt->data, size, 0) != size) {
/* bad case: desynchronized packet. we cancel all the packet loading */
av_free_packet(pkt);
- return -EAGAIN;
+ return AVERROR(EAGAIN);
}
if (ffm->first_frame_in_packet)
{
diff --git a/contrib/ffmpeg/libavformat/file.c b/contrib/ffmpeg/libavformat/file.c
index db671698f..3caf80a61 100644
--- a/contrib/ffmpeg/libavformat/file.c
+++ b/contrib/ffmpeg/libavformat/file.c
@@ -20,14 +20,8 @@
*/
#include "avformat.h"
#include <fcntl.h>
-#ifndef __MINGW32__
#include <unistd.h>
-#include <sys/ioctl.h>
#include <sys/time.h>
-#else
-#include <io.h>
-#define open(fname,oflag,pmode) _open(fname,oflag,pmode)
-#endif /* __MINGW32__ */
/* standard file protocol */
@@ -51,7 +45,7 @@ static int file_open(URLContext *h, const char *filename, int flags)
#endif
fd = open(filename, access, 0666);
if (fd < 0)
- return -ENOENT;
+ return AVERROR(ENOENT);
h->priv_data = (void *)(size_t)fd;
return 0;
}
@@ -72,11 +66,7 @@ static int file_write(URLContext *h, unsigned char *buf, int size)
static offset_t file_seek(URLContext *h, offset_t pos, int whence)
{
int fd = (size_t)h->priv_data;
-#if defined(__MINGW32__)
- return _lseeki64(fd, pos, whence);
-#else
return lseek(fd, pos, whence);
-#endif
}
static int file_close(URLContext *h)
diff --git a/contrib/ffmpeg/libavformat/flic.c b/contrib/ffmpeg/libavformat/flic.c
index ac32e7392..0c3a7f01f 100644
--- a/contrib/ffmpeg/libavformat/flic.c
+++ b/contrib/ffmpeg/libavformat/flic.c
@@ -58,7 +58,7 @@ static int flic_probe(AVProbeData *p)
if (p->buf_size < 6)
return 0;
- magic_number = LE_16(&p->buf[4]);
+ magic_number = AV_RL16(&p->buf[4]);
if ((magic_number != FLIC_FILE_MAGIC_1) &&
(magic_number != FLIC_FILE_MAGIC_2) &&
(magic_number != FLIC_FILE_MAGIC_3))
@@ -83,8 +83,8 @@ static int flic_read_header(AVFormatContext *s,
if (get_buffer(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
return AVERROR_IO;
- magic_number = LE_16(&header[4]);
- speed = LE_32(&header[0x10]);
+ magic_number = AV_RL16(&header[4]);
+ speed = AV_RL32(&header[0x10]);
/* initialize the decoder streams */
st = av_new_stream(s, 0);
@@ -94,8 +94,8 @@ static int flic_read_header(AVFormatContext *s,
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_FLIC;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = LE_16(&header[0x08]);
- st->codec->height = LE_16(&header[0x0A]);
+ st->codec->width = AV_RL16(&header[0x08]);
+ st->codec->height = AV_RL16(&header[0x0A]);
if (!st->codec->width || !st->codec->height)
return AVERROR_INVALIDDATA;
@@ -110,7 +110,7 @@ static int flic_read_header(AVFormatContext *s,
/* Time to figure out the framerate: If there is a FLIC chunk magic
* number at offset 0x10, assume this is from the Bullfrog game,
* Magic Carpet. */
- if (LE_16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) {
+ if (AV_RL16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) {
flic->frame_pts_inc = FLIC_MC_PTS_INC;
@@ -146,8 +146,10 @@ static int flic_read_header(AVFormatContext *s,
* therefore, the frame pts increment = n * 90
*/
flic->frame_pts_inc = speed * 90;
- } else
+ } else {
+ av_log(s, AV_LOG_INFO, "Invalid or unsupported magic chunk in file\n");
return AVERROR_INVALIDDATA;
+ }
if (flic->frame_pts_inc == 0)
flic->frame_pts_inc = FLIC_DEFAULT_PTS_INC;
@@ -174,8 +176,8 @@ static int flic_read_packet(AVFormatContext *s,
break;
}
- size = LE_32(&preamble[0]);
- magic = LE_16(&preamble[4]);
+ size = AV_RL32(&preamble[0]);
+ magic = AV_RL16(&preamble[4]);
if (((magic == FLIC_CHUNK_MAGIC_1) || (magic == FLIC_CHUNK_MAGIC_2)) && size > FLIC_PREAMBLE_SIZE) {
if (av_new_packet(pkt, size)) {
diff --git a/contrib/ffmpeg/libavformat/flv.h b/contrib/ffmpeg/libavformat/flv.h
new file mode 100644
index 000000000..1484ac15d
--- /dev/null
+++ b/contrib/ffmpeg/libavformat/flv.h
@@ -0,0 +1,110 @@
+/**
+ * @file flv.h
+ * FLV common header
+ *
+ * Copyright (c) 2006 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
+ */
+
+#ifndef FLV_H
+#define FLV_H
+
+/* offsets for packed values */
+#define FLV_AUDIO_SAMPLESSIZE_OFFSET 1
+#define FLV_AUDIO_SAMPLERATE_OFFSET 2
+#define FLV_AUDIO_CODECID_OFFSET 4
+
+#define FLV_VIDEO_FRAMETYPE_OFFSET 4
+
+/* bitmasks to isolate specific values */
+#define FLV_AUDIO_CHANNEL_MASK 0x01
+#define FLV_AUDIO_SAMPLESIZE_MASK 0x02
+#define FLV_AUDIO_SAMPLERATE_MASK 0x0c
+#define FLV_AUDIO_CODECID_MASK 0xf0
+
+#define FLV_VIDEO_CODECID_MASK 0x0f
+#define FLV_VIDEO_FRAMETYPE_MASK 0xf0
+
+#define AMF_END_OF_OBJECT 0x09
+
+enum {
+ FLV_HEADER_FLAG_HASVIDEO = 1,
+ FLV_HEADER_FLAG_HASAUDIO = 4,
+};
+
+enum {
+ FLV_TAG_TYPE_AUDIO = 0x08,
+ FLV_TAG_TYPE_VIDEO = 0x09,
+ FLV_TAG_TYPE_META = 0x12,
+};
+
+enum {
+ FLV_MONO = 0,
+ FLV_STEREO = 1,
+};
+
+enum {
+ FLV_SAMPLESSIZE_8BIT = 0,
+ FLV_SAMPLESSIZE_16BIT = 1 << FLV_AUDIO_SAMPLESSIZE_OFFSET,
+};
+
+enum {
+ FLV_SAMPLERATE_SPECIAL = 0, /**< signifies 5512Hz and 8000Hz in the case of NELLYMOSER */
+ FLV_SAMPLERATE_11025HZ = 1 << FLV_AUDIO_SAMPLERATE_OFFSET,
+ FLV_SAMPLERATE_22050HZ = 2 << FLV_AUDIO_SAMPLERATE_OFFSET,
+ FLV_SAMPLERATE_44100HZ = 3 << FLV_AUDIO_SAMPLERATE_OFFSET,
+};
+
+enum {
+ FLV_CODECID_PCM_BE = 0,
+ FLV_CODECID_ADPCM = 1 << FLV_AUDIO_CODECID_OFFSET,
+ FLV_CODECID_MP3 = 2 << FLV_AUDIO_CODECID_OFFSET,
+ FLV_CODECID_PCM_LE = 3 << FLV_AUDIO_CODECID_OFFSET,
+ FLV_CODECID_NELLYMOSER_8HZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
+ FLV_CODECID_NELLYMOSER = 6 << FLV_AUDIO_CODECID_OFFSET,
+};
+
+enum {
+ FLV_CODECID_H263 = 2,
+ FLV_CODECID_SCREEN = 3,
+ FLV_CODECID_VP6 = 4,
+ FLV_CODECID_VP6A = 5,
+ FLV_CODECID_SCREEN2 = 6,
+};
+
+enum {
+ FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET,
+ FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET,
+ FLV_FRAME_DISP_INTER = 3 << FLV_VIDEO_FRAMETYPE_OFFSET,
+};
+
+typedef enum {
+ AMF_DATA_TYPE_NUMBER = 0x00,
+ AMF_DATA_TYPE_BOOL = 0x01,
+ AMF_DATA_TYPE_STRING = 0x02,
+ AMF_DATA_TYPE_OBJECT = 0x03,
+ AMF_DATA_TYPE_NULL = 0x05,
+ AMF_DATA_TYPE_UNDEFINED = 0x06,
+ AMF_DATA_TYPE_REFERENCE = 0x07,
+ AMF_DATA_TYPE_MIXEDARRAY = 0x08,
+ AMF_DATA_TYPE_ARRAY = 0x0a,
+ AMF_DATA_TYPE_DATE = 0x0b,
+ AMF_DATA_TYPE_UNSUPPORTED = 0x0d,
+} AMFDataType;
+
+#endif /* FLV_H */
diff --git a/contrib/ffmpeg/libavformat/flvdec.c b/contrib/ffmpeg/libavformat/flvdec.c
index a1c2aa4eb..bf91fbbc7 100644
--- a/contrib/ffmpeg/libavformat/flvdec.c
+++ b/contrib/ffmpeg/libavformat/flvdec.c
@@ -25,6 +25,7 @@
* - lower 4bits: difference between encoded height and visible height
*/
#include "avformat.h"
+#include "flv.h"
static int flv_probe(AVProbeData *p)
{
@@ -33,34 +34,225 @@ static int flv_probe(AVProbeData *p)
if (p->buf_size < 6)
return 0;
d = p->buf;
- if (d[0] == 'F' && d[1] == 'L' && d[2] == 'V') {
- return 50;
+ if (d[0] == 'F' && d[1] == 'L' && d[2] == 'V' && d[3] < 5 && d[5]==0) {
+ return AVPROBE_SCORE_MAX;
}
return 0;
}
+static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, int flv_codecid) {
+ AVCodecContext *acodec = astream->codec;
+ switch(flv_codecid) {
+ //no distinction between S16 and S8 PCM codec flags
+ case FLV_CODECID_PCM_BE:
+ acodec->codec_id = acodec->bits_per_sample == 8 ? CODEC_ID_PCM_S8 : CODEC_ID_PCM_S16BE; break;
+ case FLV_CODECID_PCM_LE:
+ acodec->codec_id = acodec->bits_per_sample == 8 ? CODEC_ID_PCM_S8 : CODEC_ID_PCM_S16LE; break;
+ case FLV_CODECID_ADPCM: acodec->codec_id = CODEC_ID_ADPCM_SWF; break;
+ case FLV_CODECID_MP3 : acodec->codec_id = CODEC_ID_MP3 ; astream->need_parsing = 1 ; break;
+ case FLV_CODECID_NELLYMOSER_8HZ_MONO:
+ acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate
+ case FLV_CODECID_NELLYMOSER:
+ default:
+ av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n", flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
+ acodec->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
+ }
+}
+
+static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid) {
+ AVCodecContext *vcodec = vstream->codec;
+ switch(flv_codecid) {
+ case FLV_CODECID_H263 : vcodec->codec_id = CODEC_ID_FLV1 ; break;
+ case FLV_CODECID_SCREEN: vcodec->codec_id = CODEC_ID_FLASHSV; break;
+ case FLV_CODECID_VP6 : vcodec->codec_id = CODEC_ID_VP6F ;
+ if(vcodec->extradata_size != 1) {
+ vcodec->extradata_size = 1;
+ vcodec->extradata = av_malloc(1);
+ }
+ vcodec->extradata[0] = get_byte(&s->pb);
+ return 1; // 1 byte body size adjustment for flv_read_packet()
+ default:
+ av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
+ vcodec->codec_tag = flv_codecid;
+ }
+
+ return 0;
+}
+
+static int amf_get_string(ByteIOContext *ioc, char *buffer, int buffsize) {
+ int length = get_be16(ioc);
+ if(length >= buffsize) {
+ url_fskip(ioc, length);
+ return -1;
+ }
+
+ get_buffer(ioc, buffer, length);
+
+ buffer[length] = '\0';
+
+ return length;
+}
+
+static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, unsigned int max_pos, int depth) {
+ AVCodecContext *acodec, *vcodec;
+ ByteIOContext *ioc;
+ AMFDataType amf_type;
+ char str_val[256];
+ double num_val;
+
+ num_val = 0;
+ ioc = &s->pb;
+
+ amf_type = get_byte(ioc);
+
+ switch(amf_type) {
+ case AMF_DATA_TYPE_NUMBER:
+ num_val = av_int2dbl(get_be64(ioc)); break;
+ case AMF_DATA_TYPE_BOOL:
+ num_val = get_byte(ioc); break;
+ case AMF_DATA_TYPE_STRING:
+ if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
+ return -1;
+ break;
+ case AMF_DATA_TYPE_OBJECT: {
+ unsigned int keylen;
+
+ while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
+ url_fskip(ioc, keylen); //skip key string
+ if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
+ return -1; //if we couldn't skip, bomb out.
+ }
+ if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ return -1;
+ }
+ break;
+ case AMF_DATA_TYPE_NULL:
+ case AMF_DATA_TYPE_UNDEFINED:
+ case AMF_DATA_TYPE_UNSUPPORTED:
+ break; //these take up no additional space
+ case AMF_DATA_TYPE_MIXEDARRAY:
+ url_fskip(ioc, 4); //skip 32-bit max array index
+ while(url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
+ //this is the only case in which we would want a nested parse to not skip over the object
+ if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
+ return -1;
+ }
+ if(get_byte(ioc) != AMF_END_OF_OBJECT)
+ return -1;
+ break;
+ case AMF_DATA_TYPE_ARRAY: {
+ unsigned int arraylen, i;
+
+ arraylen = get_be32(ioc);
+ for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
+ if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
+ return -1; //if we couldn't skip, bomb out.
+ }
+ }
+ break;
+ case AMF_DATA_TYPE_DATE:
+ url_fskip(ioc, 8 + 2); //timestamp (double) and UTC offset (int16)
+ break;
+ default: //unsupported type, we couldn't skip
+ return -1;
+ }
+
+ if(depth == 1 && key) { //only look for metadata values when we are not nested and key != NULL
+ acodec = astream ? astream->codec : NULL;
+ vcodec = vstream ? vstream->codec : NULL;
+
+ if(amf_type == AMF_DATA_TYPE_BOOL) {
+ if(!strcmp(key, "stereo") && acodec) acodec->channels = num_val > 0 ? 2 : 1;
+ } else if(amf_type == AMF_DATA_TYPE_NUMBER) {
+ if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
+// else if(!strcmp(key, "width") && vcodec && num_val > 0) vcodec->width = num_val;
+// else if(!strcmp(key, "height") && vcodec && num_val > 0) vcodec->height = num_val;
+ else if(!strcmp(key, "audiocodecid") && acodec) flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
+ else if(!strcmp(key, "videocodecid") && vcodec) flv_set_video_codec(s, vstream, (int)num_val);
+ else if(!strcmp(key, "audiosamplesize") && acodec && num_val >= 0) {
+ acodec->bits_per_sample = num_val;
+ //we may have to rewrite a previously read codecid because FLV only marks PCM endianness.
+ if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
+ acodec->codec_id = CODEC_ID_PCM_S8;
+ }
+ else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) {
+ //some tools, like FLVTool2, write consistently approximate metadata sample rates
+ switch((int)num_val) {
+ case 44000: acodec->sample_rate = 44100 ; break;
+ case 22000: acodec->sample_rate = 22050 ; break;
+ case 11000: acodec->sample_rate = 11025 ; break;
+ case 5000 : acodec->sample_rate = 5512 ; break;
+ default : acodec->sample_rate = num_val;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int flv_read_metabody(AVFormatContext *s, unsigned int next_pos) {
+ AMFDataType type;
+ AVStream *stream, *astream, *vstream;
+ ByteIOContext *ioc;
+ int i, keylen;
+ char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want.
+
+ astream = NULL;
+ vstream = NULL;
+ keylen = 0;
+ ioc = &s->pb;
+
+ //first object needs to be "onMetaData" string
+ type = get_byte(ioc);
+ if(type != AMF_DATA_TYPE_STRING || amf_get_string(ioc, buffer, sizeof(buffer)) < 0 || strcmp(buffer, "onMetaData"))
+ return -1;
+
+ //find the streams now so that amf_parse_object doesn't need to do the lookup every time it is called.
+ for(i = 0; i < s->nb_streams; i++) {
+ stream = s->streams[i];
+ if (stream->codec->codec_type == CODEC_TYPE_AUDIO) astream = stream;
+ else if(stream->codec->codec_type == CODEC_TYPE_VIDEO) vstream = stream;
+ }
+
+ //parse the second object (we want a mixed array)
+ if(amf_parse_object(s, astream, vstream, buffer, next_pos, 0) < 0)
+ return -1;
+
+ return 0;
+}
+
static int flv_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- int offset, flags, size;
-
- s->ctx_flags |= AVFMTCTX_NOHEADER; //ok we have a header but theres no fps, codec type, sample_rate, ...
+ int offset, flags;
+ AVStream *st;
url_fskip(&s->pb, 4);
flags = get_byte(&s->pb);
+ /* old flvtool cleared this field */
+ /* FIXME: better fix needed */
+ if (!flags) {
+ flags = FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO;
+ av_log(s, AV_LOG_WARNING, "Broken FLV file, which says no streams present, this might fail\n");
+ }
- offset = get_be32(&s->pb);
-
- if(!url_is_streamed(&s->pb)){
- const int fsize= url_fsize(&s->pb);
- url_fseek(&s->pb, fsize-4, SEEK_SET);
- size= get_be32(&s->pb);
- url_fseek(&s->pb, fsize-3-size, SEEK_SET);
- if(size == get_be24(&s->pb) + 11){
- s->duration= get_be24(&s->pb) * (int64_t)AV_TIME_BASE / 1000;
- }
+ if(flags & FLV_HEADER_FLAG_HASVIDEO){
+ st = av_new_stream(s, 0);
+ if (!st)
+ return AVERROR_NOMEM;
+ st->codec->codec_type = CODEC_TYPE_VIDEO;
+ av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
+ }
+ if(flags & FLV_HEADER_FLAG_HASAUDIO){
+ st = av_new_stream(s, 1);
+ if (!st)
+ return AVERROR_NOMEM;
+ st->codec->codec_type = CODEC_TYPE_AUDIO;
+ av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
}
+ offset = get_be32(&s->pb);
url_fseek(&s->pb, offset, SEEK_SET);
s->start_time = 0;
@@ -90,55 +282,17 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
next= size + url_ftell(&s->pb);
- if (type == 8) {
+ if (type == FLV_TAG_TYPE_AUDIO) {
is_audio=1;
flags = get_byte(&s->pb);
- } else if (type == 9) {
+ } else if (type == FLV_TAG_TYPE_VIDEO) {
is_audio=0;
flags = get_byte(&s->pb);
- } else if (type == 18 && size > 13+1+4) {
- url_fskip(&s->pb, 13); //onMetaData blah
- if(get_byte(&s->pb) == 8){
- url_fskip(&s->pb, 4);
- }
- while(url_ftell(&s->pb) + 5 < next){
- char tmp[128];
- int type, len;
- double d= 0;
-
- len= get_be16(&s->pb);
- if(len >= sizeof(tmp) || !len)
- break;
- get_buffer(&s->pb, tmp, len);
- tmp[len]=0;
-
- type= get_byte(&s->pb);
- if(type==0){
- d= av_int2dbl(get_be64(&s->pb));
- }else if(type==2){
- len= get_be16(&s->pb);
- if(len >= sizeof(tmp))
- break;
- url_fskip(&s->pb, len);
- }else if(type==8){
- //array
- break;
- }else if(type==11){
- d= av_int2dbl(get_be64(&s->pb));
- get_be16(&s->pb);
- }
-
- if(!strcmp(tmp, "duration")){
- s->duration = d*AV_TIME_BASE;
- }else if(!strcmp(tmp, "videodatarate")){
- }else if(!strcmp(tmp, "audiodatarate")){
- }
- }
- url_fseek(&s->pb, next, SEEK_SET);
- continue;
} else {
- /* skip packet */
- av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
+ if (type == FLV_TAG_TYPE_META && size > 13+1+4)
+ flv_read_metabody(s, next);
+ else /* skip packet */
+ av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
url_fseek(&s->pb, next, SEEK_SET);
continue;
}
@@ -150,67 +304,49 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
break;
}
if(i == s->nb_streams){
- st = av_new_stream(s, is_audio);
- if (!st)
- return AVERROR_NOMEM;
-
- av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
- st->codec->time_base= (AVRational){1,1000};
+ av_log(NULL, AV_LOG_ERROR, "invalid stream\n");
+ url_fseek(&s->pb, next, SEEK_SET);
+ continue;
}
// av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard);
- if( (st->discard >= AVDISCARD_NONKEY && !((flags >> 4)==1 || is_audio))
- ||(st->discard >= AVDISCARD_BIDIR && ((flags >> 4)==3 && !is_audio))
+ if( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || is_audio))
+ ||(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && !is_audio))
|| st->discard >= AVDISCARD_ALL
){
url_fseek(&s->pb, next, SEEK_SET);
continue;
}
- if ((flags >> 4)==1)
+ if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY)
av_add_index_entry(st, pos, pts, size, 0, AVINDEX_KEYFRAME);
break;
}
+ // if not streamed and no duration from metadata then seek to end to find the duration from the timestamps
+ if(!url_is_streamed(&s->pb) && s->duration==AV_NOPTS_VALUE){
+ int size;
+ const int pos= url_ftell(&s->pb);
+ const int fsize= url_fsize(&s->pb);
+ url_fseek(&s->pb, fsize-4, SEEK_SET);
+ size= get_be32(&s->pb);
+ url_fseek(&s->pb, fsize-3-size, SEEK_SET);
+ if(size == get_be24(&s->pb) + 11){
+ s->duration= get_be24(&s->pb) * (int64_t)AV_TIME_BASE / 1000;
+ }
+ url_fseek(&s->pb, pos, SEEK_SET);
+ }
+
if(is_audio){
- if(st->codec->sample_rate == 0){
- st->codec->codec_type = CODEC_TYPE_AUDIO;
- st->codec->channels = (flags&1)+1;
- if((flags >> 4) == 5)
+ if(!st->codec->sample_rate || !st->codec->bits_per_sample || (!st->codec->codec_id && !st->codec->codec_tag)) {
+ st->codec->channels = (flags & FLV_AUDIO_CHANNEL_MASK) == FLV_STEREO ? 2 : 1;
+ if((flags & FLV_AUDIO_CODECID_MASK) == FLV_CODECID_NELLYMOSER_8HZ_MONO)
st->codec->sample_rate= 8000;
else
- st->codec->sample_rate = (44100<<((flags>>2)&3))>>3;
- switch(flags >> 4){/* 0: uncompressed 1: ADPCM 2: mp3 5: Nellymoser 8kHz mono 6: Nellymoser*/
- case 0: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16BE;
- else st->codec->codec_id = CODEC_ID_PCM_S8; break;
- case 1: st->codec->codec_id = CODEC_ID_ADPCM_SWF; break;
- case 2: st->codec->codec_id = CODEC_ID_MP3; st->need_parsing = 1; break;
- // this is not listed at FLV but at SWF, strange...
- case 3: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16LE;
- else st->codec->codec_id = CODEC_ID_PCM_S8; break;
- default:
- av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n", flags >> 4);
- st->codec->codec_tag= (flags >> 4);
- }
- st->codec->bits_per_sample = (flags & 2) ? 16 : 8;
+ st->codec->sample_rate = (44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >> FLV_AUDIO_SAMPLERATE_OFFSET) >> 3);
+ st->codec->bits_per_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
+ flv_set_audio_codec(s, st, flags & FLV_AUDIO_CODECID_MASK);
}
}else{
- st->codec->codec_type = CODEC_TYPE_VIDEO;
- switch(flags & 0xF){
- case 2: st->codec->codec_id = CODEC_ID_FLV1; break;
- case 3: st->codec->codec_id = CODEC_ID_FLASHSV; break;
- case 4:
- st->codec->codec_id = CODEC_ID_VP6F;
- if (st->codec->extradata_size != 1) {
- st->codec->extradata_size = 1;
- st->codec->extradata = av_malloc(1);
- }
- /* width and height adjustment */
- st->codec->extradata[0] = get_byte(&s->pb);
- size--;
- break;
- default:
- av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flags & 0xf);
- st->codec->codec_tag= flags & 0xF;
- }
+ size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK);
}
ret= av_get_packet(&s->pb, pkt, size - 1);
@@ -223,7 +359,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pts = pts;
pkt->stream_index = st->index;
- if (is_audio || ((flags >> 4)==1))
+ if (is_audio || ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY))
pkt->flags |= PKT_FLAG_KEY;
return ret;
diff --git a/contrib/ffmpeg/libavformat/flvenc.c b/contrib/ffmpeg/libavformat/flvenc.c
index 0b09d9830..ece585d77 100644
--- a/contrib/ffmpeg/libavformat/flvenc.c
+++ b/contrib/ffmpeg/libavformat/flvenc.c
@@ -19,10 +19,29 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "flv.h"
+#include "riff.h"
#undef NDEBUG
#include <assert.h>
+static const AVCodecTag flv_video_codec_ids[] = {
+ {CODEC_ID_FLV1, FLV_CODECID_H263 },
+ {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
+ {CODEC_ID_VP6F, FLV_CODECID_VP6 },
+ {CODEC_ID_VP6, FLV_CODECID_VP6 },
+ {CODEC_ID_NONE, 0}
+};
+
+static const AVCodecTag flv_audio_codec_ids[] = {
+ {CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_PCM_S8, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_PCM_S16LE, FLV_CODECID_PCM_LE >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_ADPCM_SWF, FLV_CODECID_ADPCM >> FLV_AUDIO_CODECID_OFFSET},
+ {CODEC_ID_NONE, 0}
+};
+
typedef struct FLVContext {
int hasAudio;
int hasVideo;
@@ -33,21 +52,21 @@ typedef struct FLVContext {
} FLVContext;
static int get_audio_flags(AVCodecContext *enc){
- int flags = (enc->bits_per_sample == 16) ? 0x2 : 0x0;
+ int flags = (enc->bits_per_sample == 16) ? FLV_SAMPLESSIZE_16BIT : FLV_SAMPLESSIZE_8BIT;
switch (enc->sample_rate) {
case 44100:
- flags |= 0x0C;
+ flags |= FLV_SAMPLERATE_44100HZ;
break;
case 22050:
- flags |= 0x08;
+ flags |= FLV_SAMPLERATE_22050HZ;
break;
case 11025:
- flags |= 0x04;
+ flags |= FLV_SAMPLERATE_11025HZ;
break;
case 8000: //nellymoser only
case 5512: //not mp3
- flags |= 0x00;
+ flags |= FLV_SAMPLERATE_SPECIAL;
break;
default:
av_log(enc, AV_LOG_ERROR, "flv doesnt support that sample rate, choose from (44100, 22050, 11025)\n");
@@ -55,23 +74,24 @@ static int get_audio_flags(AVCodecContext *enc){
}
if (enc->channels > 1) {
- flags |= 0x01;
+ flags |= FLV_STEREO;
}
switch(enc->codec_id){
case CODEC_ID_MP3:
- flags |= 0x20 | 0x2;
+ flags |= FLV_CODECID_MP3 | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_PCM_S8:
+ flags |= FLV_CODECID_PCM_BE | FLV_SAMPLESSIZE_8BIT;
break;
case CODEC_ID_PCM_S16BE:
- flags |= 0x2;
+ flags |= FLV_CODECID_PCM_BE | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_PCM_S16LE:
- flags |= 0x30 | 0x2;
+ flags |= FLV_CODECID_PCM_LE | FLV_SAMPLESSIZE_16BIT;
break;
case CODEC_ID_ADPCM_SWF:
- flags |= 0x10;
+ flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
break;
case 0:
flags |= enc->codec_tag<<4;
@@ -84,14 +104,6 @@ static int get_audio_flags(AVCodecContext *enc){
return flags;
}
-#define AMF_DOUBLE 0
-#define AMF_BOOLEAN 1
-#define AMF_STRING 2
-#define AMF_OBJECT 3
-#define AMF_MIXED_ARRAY 8
-#define AMF_ARRAY 10
-#define AMF_DATE 11
-
static void put_amf_string(ByteIOContext *pb, const char *str)
{
size_t len = strlen(str);
@@ -101,27 +113,26 @@ static void put_amf_string(ByteIOContext *pb, const char *str)
static void put_amf_double(ByteIOContext *pb, double d)
{
- put_byte(pb, AMF_DOUBLE);
+ put_byte(pb, AMF_DATA_TYPE_NUMBER);
put_be64(pb, av_dbl2int(d));
}
+static void put_amf_bool(ByteIOContext *pb, int b) {
+ put_byte(pb, AMF_DATA_TYPE_BOOL);
+ put_byte(pb, !!b);
+}
+
static int flv_write_header(AVFormatContext *s)
{
ByteIOContext *pb = &s->pb;
FLVContext *flv = s->priv_data;
- int i, width, height, samplerate;
+ int i, width, height, samplerate, samplesize, channels, audiocodecid, videocodecid;
double framerate = 0.0;
int metadata_size_pos, data_size;
flv->hasAudio = 0;
flv->hasVideo = 0;
- put_tag(pb,"FLV");
- put_byte(pb,1);
- put_byte(pb,0); // delayed write
- put_be32(pb,9);
- put_be32(pb,0);
-
for(i=0; i<s->nb_streams; i++){
AVCodecContext *enc = s->streams[i]->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO) {
@@ -133,12 +144,34 @@ static int flv_write_header(AVFormatContext *s)
framerate = 1/av_q2d(s->streams[i]->codec->time_base);
}
flv->hasVideo=1;
+
+ videocodecid = enc->codec_tag;
+ if(videocodecid == 0) {
+ av_log(enc, AV_LOG_ERROR, "video codec not compatible with flv\n");
+ return -1;
+ }
} else {
flv->hasAudio=1;
samplerate = enc->sample_rate;
+ channels = enc->channels;
+
+ audiocodecid = enc->codec_tag;
+ samplesize = (enc->codec_id == CODEC_ID_PCM_S8) ? 8 : 16;
+
+ if(get_audio_flags(enc)<0)
+ return -1;
}
av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */
- if(enc->codec_tag == 5){
+ }
+ put_tag(pb,"FLV");
+ put_byte(pb,1);
+ put_byte(pb, FLV_HEADER_FLAG_HASAUDIO * flv->hasAudio
+ + FLV_HEADER_FLAG_HASVIDEO * flv->hasVideo);
+ put_be32(pb,9);
+ put_be32(pb,0);
+
+ for(i=0; i<s->nb_streams; i++){
+ if(s->streams[i]->codec->codec_tag == 5){
put_byte(pb,8); // message type
put_be24(pb,0); // include flags
put_be24(pb,0); // time stamp
@@ -146,8 +179,6 @@ static int flv_write_header(AVFormatContext *s)
put_be32(pb,11); // size
flv->reserved=5;
}
- if(enc->codec_type == CODEC_TYPE_AUDIO && get_audio_flags(enc)<0)
- return -1;
}
/* write meta_tag */
@@ -160,12 +191,12 @@ static int flv_write_header(AVFormatContext *s)
/* now data of data_size size */
/* first event name as a string */
- put_byte(pb, AMF_STRING); // 1 byte
+ put_byte(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onMetaData"); // 12 bytes
/* mixed array (hash) with size and string/type/data tuples */
- put_byte(pb, AMF_MIXED_ARRAY);
- put_be32(pb, 4*flv->hasVideo + flv->hasAudio + 2); // +2 for duration and file size
+ put_byte(pb, AMF_DATA_TYPE_MIXEDARRAY);
+ put_be32(pb, 5*flv->hasVideo + 4*flv->hasAudio + 2); // +2 for duration and file size
put_amf_string(pb, "duration");
flv->duration_offset= url_ftell(pb);
@@ -183,11 +214,23 @@ static int flv_write_header(AVFormatContext *s)
put_amf_string(pb, "framerate");
put_amf_double(pb, framerate);
+
+ put_amf_string(pb, "videocodecid");
+ put_amf_double(pb, videocodecid);
}
if(flv->hasAudio){
put_amf_string(pb, "audiosamplerate");
put_amf_double(pb, samplerate);
+
+ put_amf_string(pb, "audiosamplesize");
+ put_amf_double(pb, samplesize);
+
+ put_amf_string(pb, "stereo");
+ put_amf_bool(pb, (channels == 2));
+
+ put_amf_string(pb, "audiocodecid");
+ put_amf_double(pb, audiocodecid);
}
put_amf_string(pb, "filesize");
@@ -195,7 +238,7 @@ static int flv_write_header(AVFormatContext *s)
put_amf_double(pb, 0); // delayed write
put_amf_string(pb, "");
- put_byte(pb, 9); // end marker 1 byte
+ put_byte(pb, AMF_END_OF_OBJECT);
/* write total size of tag */
data_size= url_ftell(pb) - metadata_size_pos - 10;
@@ -210,16 +253,11 @@ static int flv_write_header(AVFormatContext *s)
static int flv_write_trailer(AVFormatContext *s)
{
int64_t file_size;
- int flags = 0;
ByteIOContext *pb = &s->pb;
FLVContext *flv = s->priv_data;
file_size = url_ftell(pb);
- flags |= flv->hasAudio ? 4 : 0;
- flags |= flv->hasVideo ? 1 : 0;
- url_fseek(pb, 4, SEEK_SET);
- put_byte(pb,flags);
/* update informations */
url_fseek(pb, flv->duration_offset, SEEK_SET);
@@ -242,22 +280,35 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
// av_log(s, AV_LOG_DEBUG, "type:%d pts: %"PRId64" size:%d\n", enc->codec_type, timestamp, size);
if (enc->codec_type == CODEC_TYPE_VIDEO) {
- put_byte(pb, 9);
- flags = 2; // choose h263
- flags |= pkt->flags & PKT_FLAG_KEY ? 0x10 : 0x20; // add keyframe indicator
+ put_byte(pb, FLV_TAG_TYPE_VIDEO);
+
+ flags = enc->codec_tag;
+ if(flags == 0) {
+ av_log(enc, AV_LOG_ERROR, "video codec %X not compatible with flv\n",enc->codec_id);
+ return -1;
+ }
+
+ flags |= pkt->flags & PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
} else {
assert(enc->codec_type == CODEC_TYPE_AUDIO);
flags = get_audio_flags(enc);
assert(size);
- put_byte(pb, 8);
+ put_byte(pb, FLV_TAG_TYPE_AUDIO);
}
- put_be24(pb,size+1); // include flags
+ if ((enc->codec_id == CODEC_ID_VP6) || (enc->codec_id == CODEC_ID_VP6F))
+ put_be24(pb,size+2); // include the extra byte needed for VP6 in flv and flags
+ else
+ put_be24(pb,size+1); // include flags
put_be24(pb,pkt->pts);
put_be32(pb,flv->reserved);
put_byte(pb,flags);
+ if (enc->codec_id == CODEC_ID_VP6)
+ put_byte(pb,0);
+ if (enc->codec_id == CODEC_ID_VP6F)
+ put_byte(pb, enc->extradata_size ? enc->extradata[0] : 0);
put_buffer(pb, pkt->data, size);
put_be32(pb,size+1+11); // previous tag size
flv->duration = pkt->pts + pkt->duration;
@@ -272,13 +323,14 @@ AVOutputFormat flv_muxer = {
"video/x-flv",
"flv",
sizeof(FLVContext),
-#ifdef CONFIG_MP3LAME
+#ifdef CONFIG_LIBMP3LAME
CODEC_ID_MP3,
-#else // CONFIG_MP3LAME
+#else // CONFIG_LIBMP3LAME
CODEC_ID_NONE,
-#endif // CONFIG_MP3LAME
+#endif // CONFIG_LIBMP3LAME
CODEC_ID_FLV1,
flv_write_header,
flv_write_packet,
flv_write_trailer,
+ .codec_tag= (const AVCodecTag*[]){flv_video_codec_ids, flv_audio_codec_ids, 0},
};
diff --git a/contrib/ffmpeg/libavformat/framehook.c b/contrib/ffmpeg/libavformat/framehook.c
index 03bbc95f6..8738f8030 100644
--- a/contrib/ffmpeg/libavformat/framehook.c
+++ b/contrib/ffmpeg/libavformat/framehook.c
@@ -57,7 +57,7 @@ int frame_hook_add(int argc, char *argv[])
fhe = av_mallocz(sizeof(*fhe));
if (!fhe) {
- return errno;
+ return AVERROR(ENOMEM);
}
fhe->Configure = dlsym(loaded, "Configure");
@@ -66,18 +66,18 @@ int frame_hook_add(int argc, char *argv[])
if (!fhe->Process) {
av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]);
- return -1;
+ return AVERROR(ENOENT);
}
if (!fhe->Configure && argc > 1) {
av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]);
- return -1;
+ return AVERROR(ENOENT);
}
if (argc > 1 || fhe->Configure) {
if (fhe->Configure(&fhe->ctx, argc, argv)) {
av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]);
- return -1;
+ return AVERROR(EINVAL);
}
}
@@ -93,11 +93,10 @@ int frame_hook_add(int argc, char *argv[])
#endif
}
-void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height)
+void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
{
if (first_hook) {
FrameHookEntry *fhe;
- int64_t pts = av_gettime();
for (fhe = first_hook; fhe; fhe = fhe->next) {
fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
diff --git a/contrib/ffmpeg/libavformat/framehook.h b/contrib/ffmpeg/libavformat/framehook.h
index d843ddb85..06ed4f889 100644
--- a/contrib/ffmpeg/libavformat/framehook.h
+++ b/contrib/ffmpeg/libavformat/framehook.h
@@ -22,6 +22,8 @@
#ifndef _FRAMEHOOK_H
#define _FRAMEHOOK_H
+#warning VHOOK is deprecated please help porting libmpcodecs or a better filter system to ffmpeg instead of wasting your time writing new fiters for this crappy one
+
/*
* Prototypes for interface to .so that implement a video processing hook
*/
@@ -44,7 +46,7 @@ typedef FrameHookRelease *FrameHookReleaseFn;
extern FrameHookRelease Release;
extern int frame_hook_add(int argc, char *argv[]);
-extern void frame_hook_process(struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height);
+extern void frame_hook_process(struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts);
extern void frame_hook_release(void);
#endif
diff --git a/contrib/ffmpeg/libavformat/gifdec.c b/contrib/ffmpeg/libavformat/gifdec.c
index 692ca6466..1d31211f6 100644
--- a/contrib/ffmpeg/libavformat/gifdec.c
+++ b/contrib/ffmpeg/libavformat/gifdec.c
@@ -305,13 +305,13 @@ static int gif_read_image(GifState *s)
/* verify that all the image is inside the screen dimensions */
if (left + width > s->screen_width ||
top + height > s->screen_height)
- return -EINVAL;
+ return AVERROR(EINVAL);
/* build the palette */
if (s->pix_fmt == PIX_FMT_RGB24) {
line = av_malloc(width);
if (!line)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
} else {
n = (1 << bits_per_pixel);
spal = palette;
@@ -537,7 +537,7 @@ static int gif_read_header(AVFormatContext * s1,
s->image_linesize = s->screen_width * 3;
s->image_buf = av_malloc(s->screen_height * s->image_linesize);
if (!s->image_buf)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
s->pix_fmt = PIX_FMT_RGB24;
/* now we are ready: build format streams */
st = av_new_stream(s1, 0);
diff --git a/contrib/ffmpeg/libavformat/grab.c b/contrib/ffmpeg/libavformat/grab.c
index 4e85772e5..5e778ecc0 100644
--- a/contrib/ffmpeg/libavformat/grab.c
+++ b/contrib/ffmpeg/libavformat/grab.c
@@ -68,7 +68,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
struct video_tuner tuner;
struct video_audio audio;
struct video_picture pict;
- const char *video_device;
int j;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
@@ -92,7 +91,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0);
if (!st)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
s->width = width;
@@ -100,12 +99,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
- video_device = ap->device;
- if (!video_device)
- video_device = "/dev/video";
- video_fd = open(video_device, O_RDWR);
+ video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) {
- perror(video_device);
+ perror(s1->filename);
goto fail;
}
@@ -124,7 +120,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (ap->pix_fmt == PIX_FMT_YUV420P) {
desired_palette = VIDEO_PALETTE_YUV420P;
desired_depth = 12;
- } else if (ap->pix_fmt == PIX_FMT_YUV422) {
+ } else if (ap->pix_fmt == PIX_FMT_YUYV422) {
desired_palette = VIDEO_PALETTE_YUV422;
desired_depth = 16;
} else if (ap->pix_fmt == PIX_FMT_BGR24) {
@@ -174,12 +170,13 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
pict.palette=VIDEO_PALETTE_RGB24;
pict.depth=24;
ret = ioctl(video_fd, VIDIOCSPICT, &pict);
- if (ret < 0)
+ if (ret < 0) {
pict.palette=VIDEO_PALETTE_GREY;
pict.depth=8;
ret = ioctl(video_fd, VIDIOCSPICT, &pict);
if (ret < 0)
goto fail1;
+ }
}
}
}
@@ -219,8 +216,11 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
} else {
s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_SHARED,video_fd,0);
if ((unsigned char*)-1 == s->video_buf) {
- perror("mmap");
- goto fail;
+ s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_PRIVATE,video_fd,0);
+ if ((unsigned char*)-1 == s->video_buf) {
+ perror("mmap");
+ goto fail;
+ }
}
s->gb_frame = 0;
s->time_frame = av_gettime() * s->frame_rate / s->frame_rate_base;
@@ -256,7 +256,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
break;
case VIDEO_PALETTE_YUV422:
frame_size = width * height * 2;
- st->codec->pix_fmt = PIX_FMT_YUV422;
+ st->codec->pix_fmt = PIX_FMT_YUYV422;
break;
case VIDEO_PALETTE_RGB24:
frame_size = width * height * 3;
@@ -321,16 +321,16 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
struct timespec ts;
/* Calculate the time of the next frame */
- s->time_frame += int64_t_C(1000000);
+ s->time_frame += INT64_C(1000000);
/* wait based on the frame rate */
for(;;) {
curtime = av_gettime();
delay = s->time_frame * s->frame_rate_base / s->frame_rate - curtime;
if (delay <= 0) {
- if (delay < int64_t_C(-1000000) * s->frame_rate_base / s->frame_rate) {
+ if (delay < INT64_C(-1000000) * s->frame_rate_base / s->frame_rate) {
/* printf("grabbing is %d frames late (dropping)\n", (int) -(delay / 16666)); */
- s->time_frame += int64_t_C(1000000);
+ s->time_frame += INT64_C(1000000);
}
break;
}
diff --git a/contrib/ffmpeg/libavformat/grab_bktr.c b/contrib/ffmpeg/libavformat/grab_bktr.c
index 214599490..100653db7 100644
--- a/contrib/ffmpeg/libavformat/grab_bktr.c
+++ b/contrib/ffmpeg/libavformat/grab_bktr.c
@@ -24,21 +24,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
-#if defined(__FreeBSD__)
-# if __FreeBSD__ >= 502100
-# include <dev/bktr/ioctl_meteor.h>
-# include <dev/bktr/ioctl_bt848.h>
-# else
-# include <machine/ioctl_meteor.h>
-# include <machine/ioctl_bt848.h>
-# endif
-#elif defined(__FreeBSD_kernel__)
+#if defined (HAVE_DEV_BKTR_IOCTL_METEOR_H) && defined (HAVE_DEV_BKTR_IOCTL_BT848_H)
# include <dev/bktr/ioctl_meteor.h>
# include <dev/bktr/ioctl_bt848.h>
-#elif defined(__DragonFly__)
+#elif defined (HAVE_MACHINE_IOCTL_METEOR_H) && defined (HAVE_MACHINE_IOCTL_BT848_H)
+# include <machine/ioctl_meteor.h>
+# include <machine/ioctl_bt848.h>
+#elif defined (HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H) && defined (HAVE_DEV_VIDEO_METEOR_IOCTL_BT848_H)
# include <dev/video/meteor/ioctl_meteor.h>
# include <dev/video/bktr/ioctl_bt848.h>
-#else
+#elif HAVE_DEV_IC_BT8XX_H
# include <dev/ic/bt8xx.h>
#endif
#include <unistd.h>
@@ -230,7 +225,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
VideoData *s = s1->priv_data;
if (av_new_packet(pkt, video_buf_size) < 0)
- return -EIO;
+ return AVERROR(EIO);
bktr_getframe(s->per_frame);
@@ -248,7 +243,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int frame_rate;
int frame_rate_base;
int format = -1;
- const char *video_device;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
return -1;
@@ -258,13 +252,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
frame_rate = ap->time_base.den;
frame_rate_base = ap->time_base.num;
- video_device = ap->device;
- if (!video_device)
- video_device = "/dev/bktr0";
-
st = av_new_stream(s1, 0);
if (!st)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */
s->width = width;
@@ -290,9 +280,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
format = NTSC;
}
- if (bktr_init(video_device, width, height, format,
+ if (bktr_init(s1->filename, width, height, format,
&(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0)
- return -EIO;
+ return AVERROR(EIO);
nsignals = 0;
last_frame_time = 0;
diff --git a/contrib/ffmpeg/libavformat/gxf.c b/contrib/ffmpeg/libavformat/gxf.c
index 897cdade0..ba2463ead 100644
--- a/contrib/ffmpeg/libavformat/gxf.c
+++ b/contrib/ffmpeg/libavformat/gxf.c
@@ -360,10 +360,11 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
}
}
if (pkt_type == PKT_UMF) {
- if (len >= 9) {
+ if (len >= 0x39) {
AVRational fps;
- len -= 9;
- url_fskip(pb, 5);
+ len -= 0x39;
+ url_fskip(pb, 5); // preamble
+ url_fskip(pb, 0x30); // payload description
fps = fps_umf2avr(get_le32(pb));
if (!main_timebase.num || !main_timebase.den) {
// this may not always be correct, but simply the best we can get
@@ -375,13 +376,11 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
} else
av_log(s, AV_LOG_INFO, "GXF: UMF packet missing\n");
url_fskip(pb, len);
+ if (!main_timebase.num || !main_timebase.den)
+ main_timebase = (AVRational){1, 50}; // set some arbitrary fallback
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (main_timebase.num && main_timebase.den)
- st->time_base = main_timebase;
- else {
- st->start_time = st->duration = AV_NOPTS_VALUE;
- }
+ av_set_pts_info(st, 32, main_timebase.num, main_timebase.den);
}
return 0;
}
diff --git a/contrib/ffmpeg/libavformat/gxfenc.c b/contrib/ffmpeg/libavformat/gxfenc.c
index fef5ec104..39b9ed3e1 100644
--- a/contrib/ffmpeg/libavformat/gxfenc.c
+++ b/contrib/ffmpeg/libavformat/gxfenc.c
@@ -15,7 +15,7 @@
* 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
+ * along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -85,7 +85,7 @@ static const GXF_Lines gxf_lines_tab[] = {
{ 720, 6 },
};
-static const CodecTag gxf_media_types[] = {
+static const AVCodecTag gxf_media_types[] = {
{ CODEC_ID_MJPEG , 3 }, /* NTSC */
{ CODEC_ID_MJPEG , 4 }, /* PAL */
{ CODEC_ID_PCM_S24LE , 9 },
@@ -572,6 +572,8 @@ static int gxf_write_umf_packet(ByteIOContext *pb, GXFContext *ctx)
return updatePacketSize(pb, pos);
}
+#define GXF_NODELAY -5000
+
static int gxf_write_header(AVFormatContext *s)
{
ByteIOContext *pb = &s->pb;
@@ -623,7 +625,8 @@ static int gxf_write_header(AVFormatContext *s)
gxf->flags |= 0x00000040;
}
gxf->sample_rate = sc->sample_rate;
- av_set_pts_info(st, 64, 1, sc->sample_rate);
+ av_set_pts_info(st, 64, 1, st->codec->time_base.den);
+ sc->dts_delay = GXF_NODELAY;
if (gxf_find_lines_index(sc) < 0)
sc->lines_index = -1;
sc->sample_size = st->codec->bit_rate;
@@ -707,7 +710,7 @@ static int gxf_parse_mpeg_frame(GXFStreamContext *sc, const uint8_t *buf, int si
static int gxf_write_media_preamble(ByteIOContext *pb, GXFContext *ctx, AVPacket *pkt, int size)
{
GXFStreamContext *sc = &ctx->streams[pkt->stream_index];
- int64_t dts = av_rescale(pkt->dts, ctx->sample_rate, sc->sample_rate);
+ int64_t dts = av_rescale(pkt->dts, ctx->sample_rate, sc->codec->time_base.den);
put_byte(pb, sc->media_type);
put_byte(pb, sc->index);
@@ -799,13 +802,9 @@ static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pk
break; /* add pkt right now into list */
}
}
- } else if (pkt) {
- /* adjust dts if negative */
- if (pkt->dts < 0 && !sc->dts_delay) {
- /* XXX: rescale if codec time base is different from stream time base */
- sc->dts_delay = av_rescale_q(pkt->dts, st->codec->time_base, st->time_base);
- pkt->dts = sc->dts_delay; /* set to 0 */
- }
+ } else if (pkt && pkt->stream_index == i) {
+ if (sc->dts_delay == GXF_NODELAY) /* adjust dts if needed */
+ sc->dts_delay = pkt->dts;
pkt->dts -= sc->dts_delay;
}
}
diff --git a/contrib/ffmpeg/libavformat/http.c b/contrib/ffmpeg/libavformat/http.c
index 34dd5031a..e057d6efe 100644
--- a/contrib/ffmpeg/libavformat/http.c
+++ b/contrib/ffmpeg/libavformat/http.c
@@ -20,15 +20,7 @@
*/
#include "avformat.h"
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
-#include <netdb.h>
+#include "network.h"
#include "base64.h"
@@ -40,40 +32,34 @@
/* used for protocol handling */
#define BUFFER_SIZE 1024
#define URL_SIZE 4096
+#define MAX_REDIRECTS 8
typedef struct {
URLContext *hd;
unsigned char buffer[BUFFER_SIZE], *buf_ptr, *buf_end;
int line_count;
int http_code;
+ offset_t off, filesize;
char location[URL_SIZE];
} HTTPContext;
static int http_connect(URLContext *h, const char *path, const char *hoststr,
- const char *auth);
+ const char *auth, int *new_location);
static int http_write(URLContext *h, uint8_t *buf, int size);
/* return non zero if error */
-static int http_open(URLContext *h, const char *uri, int flags)
+static int http_open_cnx(URLContext *h)
{
const char *path, *proxy_path;
char hostname[1024], hoststr[1024];
char auth[1024];
char path1[1024];
char buf[1024];
- int port, use_proxy, err;
- HTTPContext *s;
+ int port, use_proxy, err, location_changed = 0, redirects = 0;
+ HTTPContext *s = h->priv_data;
URLContext *hd = NULL;
- h->is_streamed = 1;
-
- s = av_malloc(sizeof(HTTPContext));
- if (!s) {
- return -ENOMEM;
- }
- h->priv_data = s;
-
proxy_path = getenv("http_proxy");
use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
strstart(proxy_path, "http://", NULL);
@@ -82,7 +68,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
redo:
/* needed in any case to build the host string */
url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
- path1, sizeof(path1), uri);
+ path1, sizeof(path1), s->location);
if (port > 0) {
snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);
} else {
@@ -92,7 +78,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
if (use_proxy) {
url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
NULL, 0, proxy_path);
- path = uri;
+ path = s->location;
} else {
if (path1[0] == '\0')
path = "/";
@@ -108,22 +94,44 @@ static int http_open(URLContext *h, const char *uri, int flags)
goto fail;
s->hd = hd;
- if (http_connect(h, path, hoststr, auth) < 0)
+ if (http_connect(h, path, hoststr, auth, &location_changed) < 0)
goto fail;
- if (s->http_code == 303 && s->location[0] != '\0') {
+ if ((s->http_code == 302 || s->http_code == 303) && location_changed == 1) {
/* url moved, get next */
- uri = s->location;
url_close(hd);
+ if (redirects++ >= MAX_REDIRECTS)
+ return AVERROR_IO;
+ location_changed = 0;
goto redo;
}
return 0;
fail:
if (hd)
url_close(hd);
- av_free(s);
return AVERROR_IO;
}
+static int http_open(URLContext *h, const char *uri, int flags)
+{
+ HTTPContext *s;
+ int ret;
+
+ h->is_streamed = 1;
+
+ s = av_malloc(sizeof(HTTPContext));
+ if (!s) {
+ return AVERROR(ENOMEM);
+ }
+ h->priv_data = s;
+ s->filesize = -1;
+ s->off = 0;
+ pstrcpy (s->location, URL_SIZE, uri);
+
+ ret = http_open_cnx(h);
+ if (ret != 0)
+ av_free (s);
+ return ret;
+}
static int http_getc(HTTPContext *s)
{
int len;
@@ -141,8 +149,10 @@ static int http_getc(HTTPContext *s)
return *s->buf_ptr++;
}
-static int process_line(HTTPContext *s, char *line, int line_count)
+static int process_line(URLContext *h, char *line, int line_count,
+ int *new_location)
{
+ HTTPContext *s = h->priv_data;
char *tag, *p;
/* end of header */
@@ -159,6 +169,9 @@ static int process_line(HTTPContext *s, char *line, int line_count)
#ifdef DEBUG
printf("http_code=%d\n", s->http_code);
#endif
+ /* error codes are 4xx and 5xx */
+ if (s->http_code >= 400 && s->http_code < 600)
+ return -1;
} else {
while (*p != '\0' && *p != ':')
p++;
@@ -172,34 +185,52 @@ static int process_line(HTTPContext *s, char *line, int line_count)
p++;
if (!strcmp(tag, "Location")) {
strcpy(s->location, p);
+ *new_location = 1;
+ } else if (!strcmp (tag, "Content-Length") && s->filesize == -1) {
+ s->filesize = atoll(p);
+ } else if (!strcmp (tag, "Content-Range")) {
+ /* "bytes $from-$to/$document_size" */
+ const char *slash;
+ if (!strncmp (p, "bytes ", 6)) {
+ p += 6;
+ s->off = atoll(p);
+ if ((slash = strchr(p, '/')) && strlen(slash) > 0)
+ s->filesize = atoll(slash+1);
+ }
+ h->is_streamed = 0; /* we _can_ in fact seek */
}
}
return 1;
}
static int http_connect(URLContext *h, const char *path, const char *hoststr,
- const char *auth)
+ const char *auth, int *new_location)
{
HTTPContext *s = h->priv_data;
int post, err, ch;
char line[1024], *q;
char *auth_b64;
+ int auth_b64_len = strlen(auth)* 4 / 3 + 12;
+ offset_t off = s->off;
/* send http header */
post = h->flags & URL_WRONLY;
-
- auth_b64 = av_base64_encode((uint8_t *)auth, strlen(auth));
+ auth_b64 = av_malloc(auth_b64_len);
+ av_base64_encode(auth_b64, auth_b64_len, (uint8_t *)auth, strlen(auth));
snprintf(s->buffer, sizeof(s->buffer),
- "%s %s HTTP/1.0\r\n"
+ "%s %s HTTP/1.1\r\n"
"User-Agent: %s\r\n"
"Accept: */*\r\n"
+ "Range: bytes=%"PRId64"-\r\n"
"Host: %s\r\n"
"Authorization: Basic %s\r\n"
+ "Connection: close\r\n"
"\r\n",
post ? "POST" : "GET",
path,
LIBAVFORMAT_IDENT,
+ s->off,
hoststr,
auth_b64);
@@ -211,7 +242,8 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
s->buf_ptr = s->buffer;
s->buf_end = s->buffer;
s->line_count = 0;
- s->location[0] = '\0';
+ s->off = 0;
+ s->filesize = -1;
if (post) {
sleep(1);
return 0;
@@ -231,11 +263,11 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
#ifdef DEBUG
printf("header='%s'\n", line);
#endif
- err = process_line(s, line, s->line_count);
+ err = process_line(h, line, s->line_count, new_location);
if (err < 0)
return err;
if (err == 0)
- return 0;
+ break;
s->line_count++;
q = line;
} else {
@@ -243,6 +275,8 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
*q++ = ch;
}
}
+
+ return (off == s->off) ? 0 : -1;
}
@@ -261,6 +295,8 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
} else {
len = url_read(s->hd, buf, size);
}
+ if (len > 0)
+ s->off += len;
return len;
}
@@ -279,11 +315,40 @@ static int http_close(URLContext *h)
return 0;
}
+static offset_t http_seek(URLContext *h, offset_t off, int whence)
+{
+ HTTPContext *s = h->priv_data;
+ URLContext *old_hd = s->hd;
+ offset_t old_off = s->off;
+
+ if (whence == AVSEEK_SIZE)
+ return s->filesize;
+ else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
+ return -1;
+
+ /* we save the old context in case the seek fails */
+ s->hd = NULL;
+ if (whence == SEEK_CUR)
+ off += s->off;
+ else if (whence == SEEK_END)
+ off += s->filesize;
+ s->off = off;
+
+ /* if it fails, continue on old connection */
+ if (http_open_cnx(h) < 0) {
+ s->hd = old_hd;
+ s->off = old_off;
+ return -1;
+ }
+ url_close(old_hd);
+ return off;
+}
+
URLProtocol http_protocol = {
"http",
http_open,
http_read,
http_write,
- NULL, /* seek */
+ http_seek,
http_close,
};
diff --git a/contrib/ffmpeg/libavformat/idcin.c b/contrib/ffmpeg/libavformat/idcin.c
index 48d1e250d..e2c92f3b4 100644
--- a/contrib/ffmpeg/libavformat/idcin.c
+++ b/contrib/ffmpeg/libavformat/idcin.c
@@ -109,27 +109,27 @@ static int idcin_probe(AVProbeData *p)
return 0;
/* check the video width */
- number = LE_32(&p->buf[0]);
+ number = AV_RL32(&p->buf[0]);
if ((number == 0) || (number > 1024))
return 0;
/* check the video height */
- number = LE_32(&p->buf[4]);
+ number = AV_RL32(&p->buf[4]);
if ((number == 0) || (number > 1024))
return 0;
/* check the audio sample rate */
- number = LE_32(&p->buf[8]);
+ number = AV_RL32(&p->buf[8]);
if ((number != 0) && ((number < 8000) | (number > 48000)))
return 0;
/* check the audio bytes/sample */
- number = LE_32(&p->buf[12]);
+ number = AV_RL32(&p->buf[12]);
if (number > 2)
return 0;
/* check the audio channels */
- number = LE_32(&p->buf[16]);
+ number = AV_RL32(&p->buf[16]);
if (number > 2)
return 0;
diff --git a/contrib/ffmpeg/libavformat/idroq.c b/contrib/ffmpeg/libavformat/idroq.c
index 419696c9a..b8ee176ab 100644
--- a/contrib/ffmpeg/libavformat/idroq.c
+++ b/contrib/ffmpeg/libavformat/idroq.c
@@ -61,8 +61,8 @@ static int roq_probe(AVProbeData *p)
if (p->buf_size < 6)
return 0;
- if ((LE_16(&p->buf[0]) != RoQ_MAGIC_NUMBER) ||
- (LE_32(&p->buf[2]) != 0xFFFFFFFF))
+ if ((AV_RL16(&p->buf[0]) != RoQ_MAGIC_NUMBER) ||
+ (AV_RL32(&p->buf[2]) != 0xFFFFFFFF))
return 0;
return AVPROBE_SCORE_MAX;
@@ -83,7 +83,7 @@ static int roq_read_header(AVFormatContext *s,
if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR_IO;
- roq->framerate = LE_16(&preamble[6]);
+ roq->framerate = AV_RL16(&preamble[6]);
roq->frame_pts_inc = 90000 / roq->framerate;
/* init private context parameters */
@@ -96,8 +96,8 @@ static int roq_read_header(AVFormatContext *s,
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR_IO;
- chunk_type = LE_16(&preamble[0]);
- chunk_size = LE_32(&preamble[2]);
+ chunk_type = AV_RL16(&preamble[0]);
+ chunk_size = AV_RL32(&preamble[2]);
switch (chunk_type) {
@@ -106,8 +106,8 @@ static int roq_read_header(AVFormatContext *s,
if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR_IO;
- roq->width = LE_16(&preamble[0]);
- roq->height = LE_16(&preamble[2]);
+ roq->width = AV_RL16(&preamble[0]);
+ roq->height = AV_RL16(&preamble[2]);
break;
case RoQ_QUAD_CODEBOOK:
@@ -127,7 +127,7 @@ static int roq_read_header(AVFormatContext *s,
break;
default:
- av_log(s, AV_LOG_ERROR, " unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
+ av_log(s, AV_LOG_ERROR, " unknown RoQ chunk type (%04X)\n", AV_RL16(&preamble[0]));
return AVERROR_INVALIDDATA;
break;
}
@@ -196,8 +196,8 @@ static int roq_read_packet(AVFormatContext *s,
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR_IO;
- chunk_type = LE_16(&preamble[0]);
- chunk_size = LE_32(&preamble[2]);
+ chunk_type = AV_RL16(&preamble[0]);
+ chunk_size = AV_RL32(&preamble[2]);
if(chunk_size > INT_MAX)
return AVERROR_INVALIDDATA;
@@ -216,7 +216,7 @@ static int roq_read_packet(AVFormatContext *s,
if (get_buffer(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
RoQ_CHUNK_PREAMBLE_SIZE)
return AVERROR_IO;
- chunk_size = LE_32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
+ chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
codebook_size;
/* rewind */
diff --git a/contrib/ffmpeg/libavformat/img.c b/contrib/ffmpeg/libavformat/img.c
deleted file mode 100644
index 5223c691e..000000000
--- a/contrib/ffmpeg/libavformat/img.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Image format
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include "avformat.h"
-
-typedef struct {
- int width;
- int height;
- int img_first;
- int img_last;
- int img_number;
- int img_count;
- int img_size;
- AVImageFormat *img_fmt;
- int pix_fmt;
- int is_pipe;
- char path[1024];
- /* temporary usage */
- void *ptr;
-} VideoData;
-
-
-/* return -1 if no image found */
-static int find_image_range(int *pfirst_index, int *plast_index,
- const char *path)
-{
- char buf[1024];
- int range, last_index, range1, first_index;
-
- /* find the first image */
- for(first_index = 0; first_index < 5; first_index++) {
- if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0)
- goto fail;
- if (url_exist(buf))
- break;
- }
- if (first_index == 5)
- goto fail;
-
- /* find the last image */
- last_index = first_index;
- for(;;) {
- range = 0;
- for(;;) {
- if (!range)
- range1 = 1;
- else
- range1 = 2 * range;
- if (av_get_frame_filename(buf, sizeof(buf), path,
- last_index + range1) < 0)
- goto fail;
- if (!url_exist(buf))
- break;
- range = range1;
- /* just in case... */
- if (range >= (1 << 30))
- goto fail;
- }
- /* we are sure than image last_index + range exists */
- if (!range)
- break;
- last_index += range;
- }
- *pfirst_index = first_index;
- *plast_index = last_index;
- return 0;
- fail:
- return -1;
-}
-
-
-static int image_probe(AVProbeData *p)
-{
- if (av_filename_number_test(p->filename) && guess_image_format(p->filename))
- return AVPROBE_SCORE_MAX-1;
- else
- return 0;
-}
-
-static int read_header_alloc_cb(void *opaque, AVImageInfo *info)
-{
- VideoData *s = opaque;
-
- s->width = info->width;
- s->height = info->height;
- s->pix_fmt = info->pix_fmt;
- /* stop image reading but no error */
- return 1;
-}
-
-static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
-{
- VideoData *s = s1->priv_data;
- int ret, first_index, last_index;
- char buf[1024];
- ByteIOContext pb1, *f = &pb1;
- AVStream *st;
-
- st = av_new_stream(s1, 0);
- if (!st) {
- return -ENOMEM;
- }
-
- if (ap->image_format)
- s->img_fmt = ap->image_format;
-
- pstrcpy(s->path, sizeof(s->path), s1->filename);
- s->img_number = 0;
- s->img_count = 0;
-
- /* find format */
- if (s1->iformat->flags & AVFMT_NOFILE)
- s->is_pipe = 0;
- else
- s->is_pipe = 1;
-
- if (!ap->time_base.num) {
- st->codec->time_base= (AVRational){1,25};
- } else {
- st->codec->time_base= ap->time_base;
- }
-
- if (!s->is_pipe) {
- if (find_image_range(&first_index, &last_index, s->path) < 0)
- goto fail;
- s->img_first = first_index;
- s->img_last = last_index;
- s->img_number = first_index;
- /* compute duration */
- st->start_time = 0;
- st->duration = last_index - first_index + 1;
- if (av_get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0)
- goto fail;
- if (url_fopen(f, buf, URL_RDONLY) < 0)
- goto fail;
- } else {
- f = &s1->pb;
- }
-
- ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s);
- if (ret < 0)
- goto fail1;
-
- if (!s->is_pipe) {
- url_fclose(f);
- } else {
- url_fseek(f, 0, SEEK_SET);
- }
-
- st->codec->codec_type = CODEC_TYPE_VIDEO;
- st->codec->codec_id = CODEC_ID_RAWVIDEO;
- st->codec->width = s->width;
- st->codec->height = s->height;
- st->codec->pix_fmt = s->pix_fmt;
- s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15));
-
- return 0;
- fail1:
- if (!s->is_pipe)
- url_fclose(f);
- fail:
- return AVERROR_IO;
-}
-
-static int read_packet_alloc_cb(void *opaque, AVImageInfo *info)
-{
- VideoData *s = opaque;
-
- if (info->width != s->width ||
- info->height != s->height)
- return -1;
- avpicture_fill(&info->pict, s->ptr, info->pix_fmt, (info->width+15)&(~15), (info->height+15)&(~15));
- return 0;
-}
-
-static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
-{
- VideoData *s = s1->priv_data;
- char filename[1024];
- int ret;
- ByteIOContext f1, *f;
-
- if (!s->is_pipe) {
- /* loop over input */
- if (s1->loop_input && s->img_number > s->img_last) {
- s->img_number = s->img_first;
- }
- if (av_get_frame_filename(filename, sizeof(filename),
- s->path, s->img_number) < 0)
- return AVERROR_IO;
- f = &f1;
- if (url_fopen(f, filename, URL_RDONLY) < 0)
- return AVERROR_IO;
- } else {
- f = &s1->pb;
- if (url_feof(f))
- return AVERROR_IO;
- }
-
- av_new_packet(pkt, s->img_size);
- pkt->stream_index = 0;
-
- s->ptr = pkt->data;
- ret = av_read_image(f, filename, s->img_fmt, read_packet_alloc_cb, s);
- if (!s->is_pipe) {
- url_fclose(f);
- }
-
- if (ret < 0) {
- av_free_packet(pkt);
- return AVERROR_IO; /* signal EOF */
- } else {
- /* XXX: computing this pts is not necessary as it is done in
- the generic code too */
- pkt->pts = av_rescale((int64_t)s->img_count * s1->streams[0]->codec->time_base.num, s1->streams[0]->time_base.den, s1->streams[0]->codec->time_base.den) / s1->streams[0]->time_base.num;
- s->img_count++;
- s->img_number++;
- return 0;
- }
-}
-
-static int img_read_close(AVFormatContext *s1)
-{
- return 0;
-}
-
-/******************************************************/
-/* image output */
-
-static int img_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
-{
- VideoData *img = s->priv_data;
- AVStream *st;
- AVImageFormat *img_fmt;
- int i;
-
- /* find output image format */
- if (ap->image_format) {
- img_fmt = ap->image_format;
- } else {
- img_fmt = guess_image_format(s->filename);
- }
- if (!img_fmt)
- return -1;
-
- if (s->nb_streams != 1)
- return -1;
-
- st = s->streams[0];
- /* we select the first matching format */
- for(i=0;i<PIX_FMT_NB;i++) {
- if (img_fmt->supported_pixel_formats & (1 << i))
- break;
- }
- if (i >= PIX_FMT_NB)
- return -1;
- img->img_fmt = img_fmt;
- img->pix_fmt = i;
- st->codec->pix_fmt = img->pix_fmt;
- return 0;
-}
-
-static int img_write_header(AVFormatContext *s)
-{
- VideoData *img = s->priv_data;
-
- img->img_number = 1;
- pstrcpy(img->path, sizeof(img->path), s->filename);
-
- /* find format */
- if (s->oformat->flags & AVFMT_NOFILE)
- img->is_pipe = 0;
- else
- img->is_pipe = 1;
-
- return 0;
-}
-
-static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
-{
- VideoData *img = s->priv_data;
- AVStream *st = s->streams[pkt->stream_index];
- ByteIOContext pb1, *pb;
- AVPicture *picture;
- int width, height, ret;
- char filename[1024];
- AVImageInfo info;
-
- width = st->codec->width;
- height = st->codec->height;
-
- picture = (AVPicture *)pkt->data;
-
- if (!img->is_pipe) {
- if (av_get_frame_filename(filename, sizeof(filename),
- img->path, img->img_number) < 0)
- return AVERROR_IO;
- pb = &pb1;
- if (url_fopen(pb, filename, URL_WRONLY) < 0)
- return AVERROR_IO;
- } else {
- pb = &s->pb;
- }
- info.width = width;
- info.height = height;
- info.pix_fmt = st->codec->pix_fmt;
- info.interleaved = 0; /* FIXME: there should be a way to set it right */
- info.pict = *picture;
- ret = av_write_image(pb, img->img_fmt, &info);
- if (!img->is_pipe) {
- url_fclose(pb);
- }
-
- img->img_number++;
- return 0;
-}
-
-static int img_write_trailer(AVFormatContext *s)
-{
- return 0;
-}
-
-/* input */
-#ifdef CONFIG_IMAGE_DEMUXER
-AVInputFormat image_demuxer = {
- "image",
- "image sequence",
- sizeof(VideoData),
- image_probe,
- img_read_header,
- img_read_packet,
- img_read_close,
- NULL,
- NULL,
- AVFMT_NOFILE | AVFMT_NEEDNUMBER,
-};
-#endif
-#ifdef CONFIG_IMAGEPIPE_DEMUXER
-AVInputFormat imagepipe_demuxer = {
- "imagepipe",
- "piped image sequence",
- sizeof(VideoData),
- NULL, /* no probe */
- img_read_header,
- img_read_packet,
- img_read_close,
- NULL,
-};
-#endif
-
-/* output */
-#ifdef CONFIG_IMAGE_MUXER
-AVOutputFormat image_muxer = {
- "image",
- "image sequence",
- "",
- "",
- sizeof(VideoData),
- CODEC_ID_NONE,
- CODEC_ID_RAWVIDEO,
- img_write_header,
- img_write_packet,
- img_write_trailer,
- AVFMT_NOFILE | AVFMT_NEEDNUMBER | AVFMT_RAWPICTURE,
- img_set_parameters,
-};
-#endif
-#ifdef CONFIG_IMAGEPIPE_MUXER
-AVOutputFormat imagepipe_muxer = {
- "imagepipe",
- "piped image sequence",
- "",
- "",
- sizeof(VideoData),
- CODEC_ID_NONE,
- CODEC_ID_RAWVIDEO,
- img_write_header,
- img_write_packet,
- img_write_trailer,
- AVFMT_RAWPICTURE,
- img_set_parameters,
-};
-#endif
diff --git a/contrib/ffmpeg/libavformat/img2.c b/contrib/ffmpeg/libavformat/img2.c
index 303190ad2..fa67ee742 100644
--- a/contrib/ffmpeg/libavformat/img2.c
+++ b/contrib/ffmpeg/libavformat/img2.c
@@ -154,10 +154,13 @@ static int find_image_range(int *pfirst_index, int *plast_index,
static int image_probe(AVProbeData *p)
{
- if (av_filename_number_test(p->filename) && av_str2id(img_tags, p->filename))
- return AVPROBE_SCORE_MAX;
- else
- return 0;
+ if (p->filename && av_str2id(img_tags, p->filename)) {
+ if (av_filename_number_test(p->filename))
+ return AVPROBE_SCORE_MAX;
+ else
+ return AVPROBE_SCORE_MAX/2;
+ }
+ return 0;
}
enum CodecID av_guess_image2_codec(const char *filename){
@@ -174,7 +177,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0);
if (!st) {
- return -ENOMEM;
+ return AVERROR(ENOMEM);
}
pstrcpy(s->path, sizeof(s->path), s1->filename);
diff --git a/contrib/ffmpeg/libavformat/ipmovie.c b/contrib/ffmpeg/libavformat/ipmovie.c
index 3c0459938..975bfd36b 100644
--- a/contrib/ffmpeg/libavformat/ipmovie.c
+++ b/contrib/ffmpeg/libavformat/ipmovie.c
@@ -227,7 +227,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
/* see if there are any pending packets */
chunk_type = load_ipmovie_packet(s, pb, pkt);
- if ((chunk_type == CHUNK_VIDEO) && (chunk_type != CHUNK_DONE))
+ if (chunk_type != CHUNK_DONE)
return chunk_type;
/* read the next chunk, wherever the file happens to be pointing */
@@ -236,8 +236,8 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return CHUNK_BAD;
- chunk_size = LE_16(&chunk_preamble[0]);
- chunk_type = LE_16(&chunk_preamble[2]);
+ chunk_size = AV_RL16(&chunk_preamble[0]);
+ chunk_type = AV_RL16(&chunk_preamble[2]);
debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
@@ -287,7 +287,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
break;
}
- opcode_size = LE_16(&opcode_preamble[0]);
+ opcode_size = AV_RL16(&opcode_preamble[0]);
opcode_type = opcode_preamble[2];
opcode_version = opcode_preamble[3];
@@ -325,10 +325,10 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- s->fps = 1000000.0 / (LE_32(&scratch[0]) * LE_16(&scratch[4]));
+ s->fps = 1000000.0 / (AV_RL32(&scratch[0]) * AV_RL16(&scratch[4]));
s->frame_pts_inc = 90000 / s->fps;
debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n",
- s->fps, LE_32(&scratch[0]), LE_16(&scratch[4]));
+ s->fps, AV_RL32(&scratch[0]), AV_RL16(&scratch[4]));
break;
case OPCODE_INIT_AUDIO_BUFFERS:
@@ -343,8 +343,8 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- s->audio_sample_rate = LE_16(&scratch[4]);
- audio_flags = LE_16(&scratch[2]);
+ s->audio_sample_rate = AV_RL16(&scratch[4]);
+ audio_flags = AV_RL16(&scratch[2]);
/* bit 0 of the flags: 0 = mono, 1 = stereo */
s->audio_channels = (audio_flags & 1) + 1;
/* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
@@ -381,8 +381,8 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
chunk_type = CHUNK_BAD;
break;
}
- s->video_width = LE_16(&scratch[0]) * 8;
- s->video_height = LE_16(&scratch[2]) * 8;
+ s->video_width = AV_RL16(&scratch[0]) * 8;
+ s->video_height = AV_RL16(&scratch[2]) * 8;
debug_ipmovie("video resolution: %d x %d\n",
s->video_width, s->video_height);
break;
@@ -442,8 +442,8 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
}
/* load the palette into internal data structure */
- first_color = LE_16(&scratch[0]);
- last_color = first_color + LE_16(&scratch[2]) - 1;
+ first_color = AV_RL16(&scratch[0]);
+ last_color = first_color + AV_RL16(&scratch[2]) - 1;
/* sanity check (since they are 16 bit values) */
if ((first_color > 0xFF) || (last_color > 0xFF)) {
debug_ipmovie("demux_ipmovie: set_palette indices out of range (%d -> %d)\n",
@@ -542,7 +542,7 @@ static int ipmovie_read_header(AVFormatContext *s,
if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
CHUNK_PREAMBLE_SIZE)
return AVERROR_IO;
- chunk_type = LE_16(&chunk_preamble[2]);
+ chunk_type = AV_RL16(&chunk_preamble[2]);
url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
if (chunk_type == CHUNK_VIDEO)
@@ -601,8 +601,10 @@ static int ipmovie_read_packet(AVFormatContext *s,
ret = AVERROR_IO;
else if (ret == CHUNK_NOMEM)
ret = AVERROR_NOMEM;
- else
+ else if (ret == CHUNK_VIDEO)
ret = 0;
+ else
+ ret = -1;
return ret;
}
diff --git a/contrib/ffmpeg/libavformat/isom.c b/contrib/ffmpeg/libavformat/isom.c
index d4e923853..f913bc0a9 100644
--- a/contrib/ffmpeg/libavformat/isom.c
+++ b/contrib/ffmpeg/libavformat/isom.c
@@ -25,8 +25,8 @@
#include "riff.h"
#include "isom.h"
-/* http://gpac.sourceforge.net/tutorial/mediatypes.htm */
-const CodecTag ff_mov_obj_type[] = {
+/* http://www.mp4ra.org */
+const AVCodecTag ff_mp4_obj_type[] = {
{ CODEC_ID_MPEG4 , 32 },
{ CODEC_ID_H264 , 33 },
{ CODEC_ID_AAC , 64 },
@@ -39,12 +39,15 @@ const CodecTag ff_mov_obj_type[] = {
{ CODEC_ID_AAC , 102 }, /* MPEG2 AAC Main */
{ CODEC_ID_AAC , 103 }, /* MPEG2 AAC Low */
{ CODEC_ID_AAC , 104 }, /* MPEG2 AAC SSR */
- { CODEC_ID_MP3 , 105 },
- { CODEC_ID_MPEG1VIDEO, 106 },
- { CODEC_ID_MP2 , 107 },
- { CODEC_ID_MJPEG , 108 },
- { CODEC_ID_PCM_S16LE , 224 },
+ { CODEC_ID_MP3 , 105 }, /* 13818-3 */
+ { CODEC_ID_MPEG1VIDEO, 106 }, /* 11172-2 */
+ { CODEC_ID_MP3 , 107 }, /* 11172-3 */
+ { CODEC_ID_MJPEG , 108 }, /* 10918-1 */
+ { CODEC_ID_PNG , 109 },
+ { CODEC_ID_JPEG2000 , 110 }, /* 15444-1 */
+ { CODEC_ID_VC1 , 163 },
{ CODEC_ID_VORBIS , 221 },
+ { CODEC_ID_PCM_S16LE , 224 },
{ CODEC_ID_QCELP , 225 },
{ CODEC_ID_AC3 , 226 },
{ CODEC_ID_PCM_ALAW , 227 },
@@ -55,6 +58,119 @@ const CodecTag ff_mov_obj_type[] = {
{ 0, 0 },
};
+const AVCodecTag codec_movvideo_tags[] = {
+/* { CODEC_ID_, MKTAG('I', 'V', '5', '0') }, *//* Indeo 5.0 */
+
+ { CODEC_ID_RAWVIDEO, MKTAG('r', 'a', 'w', ' ') }, /* Uncompressed RGB */
+/* { CODEC_ID_RAWVIDEO, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */
+ { CODEC_ID_RAWVIDEO, MKTAG('A', 'V', 'U', 'I') }, /* YUV with alpha-channel (AVID Uncompressed) */
+ { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, /* UNCOMPRESSED 8BIT 4:2:2 */
+
+ { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */
+ { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */
+ { CODEC_ID_MJPEG, MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */
+/* { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, *//* MJPEG with alpha-channel (AVID ABVB/Truevision NuVista) */
+ { CODEC_ID_MJPEGB, MKTAG('m', 'j', 'p', 'b') }, /* Motion-JPEG (format B) */
+
+ { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, /* Sorenson Video v1 */
+ { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, /* Sorenson Video v1 */
+ { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', 'i') }, /* Sorenson Video v1 (from QT specs)*/
+ { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, /* Sorenson Video v3 */
+
+ { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
+ { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, /* OpenDiVX *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
+ { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
+ { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') }, /* experimental: 3IVX files before ivx D4 4.5.1 */
+
+ { CODEC_ID_H263, MKTAG('h', '2', '6', '3') }, /* H263 */
+ { CODEC_ID_H263, MKTAG('s', '2', '6', '3') }, /* H263 ?? works */
+
+ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
+ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
+ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL produced by FCP */
+ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL produced by FCP */
+ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC produced by FCP */
+ { CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, /* AVID DV */
+ //{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '5') }, /* DVCPRO HD 50i produced by FCP */
+ //{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '6') }, /* DVCPRO HD 60i produced by FCP */
+
+ { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */
+ { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') }, /* Apple Video (RPZA) */
+ { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, /* Cinepak */
+ { CODEC_ID_8BPS, MKTAG('8', 'B', 'P', 'S') }, /* Planar RGB (8BPS) */
+ { CODEC_ID_SMC, MKTAG('s', 'm', 'c', ' ') }, /* Apple Graphics (SMC) */
+ { CODEC_ID_QTRLE, MKTAG('r', 'l', 'e', ' ') }, /* Apple Animation (RLE) */
+ { CODEC_ID_MSRLE, MKTAG('W', 'R', 'L', 'E') },
+ { CODEC_ID_QDRAW, MKTAG('q', 'd', 'r', 'w') }, /* QuickDraw */
+
+ { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
+
+ { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '1') }, /* HDV 720p30 */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '2') }, /* MPEG2 produced by Sony HD camera */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '3') }, /* HDV produced by FCP */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'n') }, /* MPEG2 IMX NTSC 525/60 50mb/s produced by FCP */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'p') }, /* MPEG2 IMX PAL 625/50 50mb/s produced by FCP */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'n') }, /* MPEG2 IMX NTSC 525/60 30mb/s produced by FCP */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'p') }, /* MPEG2 IMX PAL 625/50 30mb/s produced by FCP */
+ { CODEC_ID_MPEG2VIDEO, MKTAG('A', 'V', 'm', 'p') }, /* AVID IMX PAL */
+
+ //{ CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */
+
+ { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, /* Truevision Targa */
+ { CODEC_ID_TIFF, MKTAG('t', 'i', 'f', 'f') }, /* TIFF embedded in MOV */
+ { CODEC_ID_GIF, MKTAG('g', 'i', 'f', ' ') }, /* embedded gif files as frames (usually one "click to play movie" frame) */
+ { CODEC_ID_PNG, MKTAG('p', 'n', 'g', ' ') },
+
+ { CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
+
+ { CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */
+
+ { CODEC_ID_NONE, 0 },
+};
+
+const AVCodecTag codec_movaudio_tags[] = {
+ { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') },
+ { CODEC_ID_PCM_S32LE, MKTAG('i', 'n', '3', '2') },
+ { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
+ { CODEC_ID_PCM_S24LE, MKTAG('i', 'n', '2', '4') },
+ { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') }, /* 16 bits */
+ { CODEC_ID_PCM_S16BE, MKTAG('N', 'O', 'N', 'E') }, /* uncompressed */
+ { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') }, /* */
+ { CODEC_ID_PCM_S16LE, MKTAG('l', 'p', 'c', 'm') },
+ { CODEC_ID_PCM_S8, MKTAG('s', 'o', 'w', 't') },
+ { CODEC_ID_PCM_U8, MKTAG('r', 'a', 'w', ' ') }, /* 8 bits unsigned */
+ { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') }, /* */
+ { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') }, /* */
+
+ { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') }, /* IMA-4 ADPCM */
+ { CODEC_ID_ADPCM_MS, MKTAG('m', 's', 0x00, 0x02) }, /* MS ADPCM */
+
+ { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') }, /* Macintosh Audio Compression and Expansion 3:1 */
+ { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') }, /* Macintosh Audio Compression and Expansion 6:1 */
+
+ { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') }, /* MPEG layer 3 */ /* sample files at http://www.3ivx.com/showcase.html use this tag */
+ { CODEC_ID_MP3, 0x6D730055 }, /* MPEG layer 3 */
+ { CODEC_ID_MP3, MKTAG('m', 's', 0x00, 0x55) }, /* MPEG layer 3 *//* XXX: check endianness */
+
+/* { CODEC_ID_OGG_VORBIS, MKTAG('O', 'g', 'g', 'S') }, *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
+
+ { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, /* MPEG-4 AAC */
+
+ { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */
+ { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */
+
+ { CODEC_ID_AC3, MKTAG('m', 's', 0x20, 0x00) }, /* Dolby AC-3 */
+
+ { CODEC_ID_ALAC, MKTAG('a', 'l', 'a', 'c') }, /* Apple Lossless */
+ { CODEC_ID_QDM2, MKTAG('Q', 'D', 'M', '2') }, /* QDM2 */
+
+ { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
+ { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
+
+ { CODEC_ID_NONE, 0 },
+};
+
/* map numeric codes from mdhd atom to ISO 639 */
/* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
/* http://developer.apple.com/documentation/mac/Text/Text-368.html */
diff --git a/contrib/ffmpeg/libavformat/isom.h b/contrib/ffmpeg/libavformat/isom.h
index 85cbbdc6c..efcb1fc42 100644
--- a/contrib/ffmpeg/libavformat/isom.h
+++ b/contrib/ffmpeg/libavformat/isom.h
@@ -25,7 +25,9 @@
#define FFMPEG_ISOM_H
/* isom.c */
-extern const CodecTag ff_mov_obj_type[];
+extern const AVCodecTag ff_mp4_obj_type[];
+extern const AVCodecTag codec_movvideo_tags[];
+extern const AVCodecTag codec_movaudio_tags[];
int ff_mov_iso639_to_lang(const char *lang, int mp4);
int ff_mov_lang_to_iso639(int code, char *to);
diff --git a/contrib/ffmpeg/libavformat/jpeg.c b/contrib/ffmpeg/libavformat/jpeg.c
deleted file mode 100644
index b5fc043c9..000000000
--- a/contrib/ffmpeg/libavformat/jpeg.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * JPEG image format
- * Copyright (c) 2003 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 "avformat.h"
-
-static int jpeg_probe(AVProbeData *pd)
-{
- if (pd->buf_size >= 64 &&
- pd->buf[0] == 0xff && pd->buf[1] == 0xd8 && pd->buf[2] == 0xff)
- return AVPROBE_SCORE_MAX;
- else
- return 0;
-}
-
-typedef struct JpegOpaque {
- int (*alloc_cb)(void *opaque, AVImageInfo *info);
- void *opaque;
- int ret_code;
-} JpegOpaque;
-
-/* called by the codec to allocate the image */
-static int jpeg_get_buffer(AVCodecContext *c, AVFrame *picture)
-{
- JpegOpaque *jctx = c->opaque;
- AVImageInfo info1, *info = &info1;
- int ret, i;
-
- info->width = c->width;
- info->height = c->height;
- switch(c->pix_fmt) {
- case PIX_FMT_YUV420P:
- info->pix_fmt = PIX_FMT_YUVJ420P;
- break;
- case PIX_FMT_YUV422P:
- info->pix_fmt = PIX_FMT_YUVJ422P;
- break;
- case PIX_FMT_YUV444P:
- info->pix_fmt = PIX_FMT_YUVJ444P;
- break;
- default:
- return -1;
- }
- ret = jctx->alloc_cb(jctx->opaque, info);
- if (ret) {
- jctx->ret_code = ret;
- return -1;
- } else {
- for(i=0;i<3;i++) {
- picture->data[i] = info->pict.data[i];
- picture->linesize[i] = info->pict.linesize[i];
- }
- return 0;
- }
-}
-
-static void jpeg_img_copy(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
- int width, int height)
-{
- for(;height > 0; height--) {
- memcpy(dst, src, width);
- dst += dst_wrap;
- src += src_wrap;
- }
-}
-
-/* XXX: libavcodec is broken for truncated jpegs! */
-#define IO_BUF_SIZE (1024*1024)
-
-static int jpeg_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- AVCodecContext *c;
- AVFrame *picture, picture1;
- int len, size, got_picture, i;
- uint8_t *inbuf_ptr, inbuf[IO_BUF_SIZE];
- JpegOpaque jctx;
-
- jctx.alloc_cb = alloc_cb;
- jctx.opaque = opaque;
- jctx.ret_code = -1; /* default return code is error */
-
- c = avcodec_alloc_context();
- if (!c)
- return -1;
- picture= avcodec_alloc_frame();
- if (!picture) {
- av_free(c);
- return -1;
- }
- c->opaque = &jctx;
- c->get_buffer = jpeg_get_buffer;
- c->flags |= CODEC_FLAG_TRUNCATED; /* we dont send complete frames */
- if (avcodec_open(c, &mjpeg_decoder) < 0)
- goto fail1;
- for(;;) {
- size = get_buffer(f, inbuf, sizeof(inbuf));
- if (size == 0)
- break;
- inbuf_ptr = inbuf;
- while (size > 0) {
- len = avcodec_decode_video(c, &picture1, &got_picture,
- inbuf_ptr, size);
- if (len < 0)
- goto fail;
- if (got_picture)
- goto the_end;
- size -= len;
- inbuf_ptr += len;
- }
- }
- the_end:
- /* XXX: currently, the mjpeg decoder does not use AVFrame, so we
- must do it by hand */
- if (jpeg_get_buffer(c, picture) < 0)
- goto fail;
- for(i=0;i<3;i++) {
- int w, h;
- w = c->width;
- h = c->height;
- if (i >= 1) {
- switch(c->pix_fmt) {
- default:
- case PIX_FMT_YUV420P:
- w = (w + 1) >> 1;
- h = (h + 1) >> 1;
- break;
- case PIX_FMT_YUV422P:
- w = (w + 1) >> 1;
- break;
- case PIX_FMT_YUV444P:
- break;
- }
- }
- jpeg_img_copy(picture->data[i], picture->linesize[i],
- picture1.data[i], picture1.linesize[i],
- w, h);
- }
- jctx.ret_code = 0;
- fail:
- avcodec_close(c);
- fail1:
- av_free(picture);
- av_free(c);
- return jctx.ret_code;
-}
-
-#if defined(CONFIG_MUXERS) && defined(CONFIG_MJPEG_ENCODER)
-static int jpeg_write(ByteIOContext *pb, AVImageInfo *info)
-{
- AVCodecContext *c;
- uint8_t *outbuf = NULL;
- int outbuf_size, ret, size, i;
- AVFrame *picture;
-
- ret = -1;
- c = avcodec_alloc_context();
- if (!c)
- return -1;
- picture = avcodec_alloc_frame();
- if (!picture)
- goto fail2;
- c->width = info->width;
- c->height = info->height;
- /* XXX: currently move that to the codec ? */
- switch(info->pix_fmt) {
- case PIX_FMT_YUVJ420P:
- c->pix_fmt = PIX_FMT_YUV420P;
- break;
- case PIX_FMT_YUVJ422P:
- c->pix_fmt = PIX_FMT_YUV422P;
- break;
- case PIX_FMT_YUVJ444P:
- c->pix_fmt = PIX_FMT_YUV444P;
- break;
- default:
- goto fail1;
- }
- for(i=0;i<3;i++) {
- picture->data[i] = info->pict.data[i];
- picture->linesize[i] = info->pict.linesize[i];
- }
- /* set the quality */
- picture->quality = 3; /* XXX: a parameter should be used */
- c->flags |= CODEC_FLAG_QSCALE;
-
- if (avcodec_open(c, &mjpeg_encoder) < 0)
- goto fail1;
-
- /* XXX: needs to sort out that size problem */
- outbuf_size = 1000000;
- outbuf = av_malloc(outbuf_size);
-
- size = avcodec_encode_video(c, outbuf, outbuf_size, picture);
- if (size < 0)
- goto fail;
- put_buffer(pb, outbuf, size);
- put_flush_packet(pb);
- ret = 0;
-
- fail:
- avcodec_close(c);
- av_free(outbuf);
- fail1:
- av_free(picture);
- fail2:
- av_free(c);
- return ret;
-}
-#endif //CONFIG_MUXERS
-
-AVImageFormat jpeg_image_format = {
- "jpeg",
- "jpg,jpeg",
- jpeg_probe,
- jpeg_read,
- (1 << PIX_FMT_YUVJ420P) | (1 << PIX_FMT_YUVJ422P) | (1 << PIX_FMT_YUVJ444P),
-#if defined(CONFIG_MUXERS) && defined(CONFIG_MJPEG_ENCODER)
- jpeg_write,
-#else
- NULL,
-#endif //CONFIG_MUXERS
-};
diff --git a/contrib/ffmpeg/libavformat/libnut.c b/contrib/ffmpeg/libavformat/libnut.c
index d4e7201ab..0f7b879a9 100644
--- a/contrib/ffmpeg/libavformat/libnut.c
+++ b/contrib/ffmpeg/libavformat/libnut.c
@@ -1,3 +1,30 @@
+/*
+ * NUT (de)muxing via libnut
+ * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.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 libnut.c
+ * NUT demuxing and muxing via libnut.
+ * @author Oded Shimon <ods15@ods15.dyndns.org>
+ */
+
#include "avformat.h"
#include "riff.h"
#include <libnut.h>
@@ -10,7 +37,7 @@ typedef struct {
nut_stream_header_t * s;
} NUTContext;
-static const CodecTag nut_tags[] = {
+static const AVCodecTag nut_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
{ CODEC_ID_MP3, MKTAG('m', 'p', '3', ' ') },
{ CODEC_ID_VORBIS, MKTAG('v', 'r', 'b', 's') },
@@ -48,7 +75,7 @@ static int nut_write_header(AVFormatContext * avf) {
AVCodecContext * codec = avf->streams[i]->codec;
int j;
int fourcc = 0;
- int nom, denom, ssize;
+ int num, denom, ssize;
s[i].type = codec->codec_type == CODEC_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS;
@@ -56,19 +83,19 @@ static int nut_write_header(AVFormatContext * avf) {
else fourcc = codec_get_tag(nut_tags, codec->codec_id);
if (!fourcc) {
- if (codec->codec_type == CODEC_TYPE_VIDEO) fourcc = codec_get_bmp_tag(codec->codec_id);
- if (codec->codec_type == CODEC_TYPE_AUDIO) fourcc = codec_get_wav_tag(codec->codec_id);
+ if (codec->codec_type == CODEC_TYPE_VIDEO) fourcc = codec_get_tag(codec_bmp_tags, codec->codec_id);
+ if (codec->codec_type == CODEC_TYPE_AUDIO) fourcc = codec_get_tag(codec_wav_tags, codec->codec_id);
}
s[i].fourcc_len = 4;
s[i].fourcc = av_malloc(s[i].fourcc_len);
for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF;
- ff_parse_specific_params(codec, &nom, &ssize, &denom);
- av_set_pts_info(avf->streams[i], 60, denom, nom);
+ ff_parse_specific_params(codec, &num, &ssize, &denom);
+ av_set_pts_info(avf->streams[i], 60, denom, num);
- s[i].time_base.nom = denom;
- s[i].time_base.den = nom;
+ s[i].time_base.num = denom;
+ s[i].time_base.den = num;
s[i].fixed_fps = 0;
s[i].decode_delay = codec->has_b_frames;
@@ -82,7 +109,7 @@ static int nut_write_header(AVFormatContext * avf) {
s[i].sample_height = 0;
s[i].colorspace_type = 0;
} else {
- s[i].samplerate_nom = codec->sample_rate;
+ s[i].samplerate_num = codec->sample_rate;
s[i].samplerate_denom = 1;
s[i].channel_count = codec->channels;
}
@@ -123,7 +150,7 @@ static int nut_write_trailer(AVFormatContext * avf) {
return 0;
}
-AVOutputFormat nut_muxer = {
+AVOutputFormat libnut_muxer = {
"nut",
"nut format",
"video/x-nut",
@@ -199,7 +226,7 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);
}
- av_set_pts_info(avf->streams[i], 60, s[i].time_base.nom, s[i].time_base.den);
+ av_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den);
st->start_time = 0;
st->duration = s[i].max_pts;
@@ -208,14 +235,14 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
switch(s[i].type) {
case NUT_AUDIO_CLASS:
st->codec->codec_type = CODEC_TYPE_AUDIO;
- if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_wav_id(st->codec->codec_tag);
+ if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_id(codec_wav_tags, st->codec->codec_tag);
st->codec->channels = s[i].channel_count;
- st->codec->sample_rate = s[i].samplerate_nom / s[i].samplerate_denom;
+ st->codec->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;
break;
case NUT_VIDEO_CLASS:
st->codec->codec_type = CODEC_TYPE_VIDEO;
- if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_bmp_id(st->codec->codec_tag);
+ if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_id(codec_bmp_tags, st->codec->codec_tag);
st->codec->width = s[i].width;
st->codec->height = s[i].height;
@@ -255,7 +282,7 @@ static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) {
static int nut_read_seek(AVFormatContext * avf, int stream_index, int64_t target_ts, int flags) {
NUTContext * priv = avf->priv_data;
int active_streams[] = { stream_index, -1 };
- double time_pos = target_ts * priv->s[stream_index].time_base.nom / (double)priv->s[stream_index].time_base.den;
+ double time_pos = target_ts * priv->s[stream_index].time_base.num / (double)priv->s[stream_index].time_base.den;
if (nut_seek(priv->nut, time_pos, 2*!(flags & AVSEEK_FLAG_BACKWARD), active_streams)) return -1;
@@ -270,7 +297,7 @@ static int nut_read_close(AVFormatContext *s) {
return 0;
}
-AVInputFormat nut_demuxer = {
+AVInputFormat libnut_demuxer = {
"nut",
"nut format",
sizeof(NUTContext),
diff --git a/contrib/ffmpeg/libavformat/matroska.c b/contrib/ffmpeg/libavformat/matroska.c
index 0cd119e71..591530490 100644
--- a/contrib/ffmpeg/libavformat/matroska.c
+++ b/contrib/ffmpeg/libavformat/matroska.c
@@ -29,7 +29,7 @@
*/
#include "avformat.h"
-/* For codec_get_bmp_id and codec_get_wav_id. */
+/* For codec_get_id(). */
#include "riff.h"
#include "intfloat_readwrite.h"
@@ -139,6 +139,7 @@
/* IDs in the cluster master */
#define MATROSKA_ID_CLUSTERTIMECODE 0xE7
#define MATROSKA_ID_BLOCKGROUP 0xA0
+#define MATROSKA_ID_SIMPLEBLOCK 0xA3
/* IDs in the blockgroup master */
#define MATROSKA_ID_BLOCK 0xA1
@@ -177,6 +178,7 @@ typedef enum {
MATROSKA_TRACK_DEFAULT = (1<<1),
MATROSKA_TRACK_LACING = (1<<2),
MATROSKA_TRACK_REAL_V = (1<<4),
+ MATROSKA_TRACK_REORDER = (1<<8),
MATROSKA_TRACK_SHIFT = (1<<16)
} MatroskaTrackFlags;
@@ -211,6 +213,7 @@ static CodecTags codec_tags[]={
{"V_REAL/RV20" , CODEC_ID_RV20},
{"V_REAL/RV30" , CODEC_ID_RV30},
{"V_REAL/RV40" , CODEC_ID_RV40},
+ {"V_THEORA" , CODEC_ID_THEORA},
/* TODO: Real/Quicktime */
// {"A_MS/ACM" , CODEC_ID_NONE},
@@ -252,7 +255,7 @@ typedef struct Track {
unsigned char *codec_priv;
int codec_priv_size;
- int64_t default_duration;
+ uint64_t default_duration;
MatroskaTrackFlags flags;
} MatroskaTrack;
@@ -288,6 +291,10 @@ typedef struct MatroskaSubtitleTrack {
//..
} MatroskaSubtitleTrack;
+#define MAX_TRACK_SIZE (FFMAX(FFMAX(sizeof(MatroskaVideoTrack), \
+ sizeof(MatroskaAudioTrack)), \
+ sizeof(MatroskaSubtitleTrack)))
+
typedef struct MatroskaLevel {
uint64_t start, length;
} MatroskaLevel;
@@ -331,6 +338,10 @@ typedef struct MatroskaDemuxContext {
/* The packet queue. */
AVPacket **packets;
int num_packets;
+ /* Second packet queue used to reorder pts of some video track. */
+ AVPacket **packets_reorder;
+ int num_packets_reorder;
+ uint64_t reorder_max_pts;
/* have we already parse metadata/cues/clusters? */
int metadata_parsed,
@@ -602,7 +613,6 @@ ebml_read_sint (MatroskaDemuxContext *matroska,
negative = 1;
*num &= ~0x80;
}
- *num = 0;
while (n++ < size)
*num = (*num << 8) | get_byte(pb);
@@ -1017,6 +1027,43 @@ matroska_queue_packet (MatroskaDemuxContext *matroska,
}
/*
+ * Put a packet into our internal reordering queue. Will be moved to the
+ * main packet queue when enough packets are available to reorder pts.
+ */
+
+static void
+matroska_queue_packet_reordered (MatroskaDemuxContext *matroska,
+ AVPacket *pkt,
+ int is_bframe)
+{
+ if (matroska->num_packets_reorder && !is_bframe
+ && pkt->pts > matroska->reorder_max_pts) {
+ /* reorder pts */
+ int i, j, k = 1;
+ for (j=matroska->num_packets_reorder-1; j && k; j--) {
+ k = 0;
+ for (i=0; i<j; i++) {
+ if (matroska->packets_reorder[i]->pts > matroska->packets_reorder[i+1]->pts) {
+ FFSWAP(uint64_t, matroska->packets_reorder[i]->pts, matroska->packets_reorder[i+1]->pts);
+ k = 1;
+ }
+ }
+ }
+ /* then really queue the packets */
+ for (i=0; i<matroska->num_packets_reorder; i++)
+ matroska_queue_packet (matroska, matroska->packets_reorder[i]);
+ matroska->num_packets_reorder = 0;
+ }
+ matroska->packets_reorder =
+ av_realloc(matroska->packets_reorder,
+ (matroska->num_packets_reorder + 1) * sizeof(AVPacket *));
+ matroska->packets_reorder[matroska->num_packets_reorder++] = pkt;
+ if (pkt->pts > matroska->reorder_max_pts)
+ matroska->reorder_max_pts = pkt->pts;
+}
+
+
+/*
* Autodetecting...
*/
@@ -1055,7 +1102,7 @@ matroska_probe (AVProbeData *p)
* we don't parse the whole header but simply check for the
* availability of that array of characters inside the header.
* Not fully fool-proof, but good enough. */
- for (n = 4 + size; n < 4 + size + total - sizeof(probe_data); n++)
+ for (n = 4 + size; n <= 4 + size + total - sizeof(probe_data); n++)
if (!memcmp (&p->buf[n], probe_data, sizeof(probe_data)))
return AVPROBE_SCORE_MAX;
@@ -1164,7 +1211,7 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
av_log(matroska->ctx, AV_LOG_DEBUG, "parsing track, adding stream..,\n");
/* Allocate a generic track. As soon as we know its type we'll realloc. */
- track = av_mallocz(sizeof(MatroskaTrack));
+ track = av_mallocz(MAX_TRACK_SIZE);
matroska->num_tracks++;
/* start with the master */
@@ -1203,30 +1250,19 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
/* track type (video, audio, combined, subtitle, etc.) */
case MATROSKA_ID_TRACKTYPE: {
uint64_t num;
- if (track->type != 0) {
+ if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
+ break;
+ if (track->type && track->type != num) {
av_log(matroska->ctx, AV_LOG_INFO,
"More than one tracktype in an entry - skip\n");
break;
}
- if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
- break;
track->type = num;
- /* ok, so we're actually going to reallocate this thing */
switch (track->type) {
case MATROSKA_TRACK_TYPE_VIDEO:
- track = (MatroskaTrack *)
- av_realloc(track, sizeof(MatroskaVideoTrack));
- break;
case MATROSKA_TRACK_TYPE_AUDIO:
- track = (MatroskaTrack *)
- av_realloc(track, sizeof(MatroskaAudioTrack));
- ((MatroskaAudioTrack *)track)->channels = 1;
- ((MatroskaAudioTrack *)track)->samplerate = 8000;
- break;
case MATROSKA_TRACK_TYPE_SUBTITLE:
- track = (MatroskaTrack *)
- av_realloc(track, sizeof(MatroskaSubtitleTrack));
break;
case MATROSKA_TRACK_TYPE_COMPLEX:
case MATROSKA_TRACK_TYPE_LOGO:
@@ -1245,6 +1281,8 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
/* tracktype specific stuff for video */
case MATROSKA_ID_TRACKVIDEO: {
MatroskaVideoTrack *videotrack;
+ if (!track->type)
+ track->type = MATROSKA_TRACK_TYPE_VIDEO;
if (track->type != MATROSKA_TRACK_TYPE_VIDEO) {
av_log(matroska->ctx, AV_LOG_INFO,
"video data in non-video track - ignoring\n");
@@ -1270,7 +1308,7 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
if ((res = ebml_read_uint (matroska, &id,
&num)) < 0)
break;
- track->default_duration = num;
+ track->default_duration = num/matroska->time_scale;
break;
}
@@ -1280,7 +1318,7 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
if ((res = ebml_read_float(matroska, &id,
&num)) < 0)
break;
- track->default_duration = 1000000000 * (1. / num);
+ track->default_duration = 1000000000/(matroska->time_scale*num);
break;
}
@@ -1412,6 +1450,8 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
/* tracktype specific stuff for audio */
case MATROSKA_ID_TRACKAUDIO: {
MatroskaAudioTrack *audiotrack;
+ if (!track->type)
+ track->type = MATROSKA_TRACK_TYPE_AUDIO;
if (track->type != MATROSKA_TRACK_TYPE_AUDIO) {
av_log(matroska->ctx, AV_LOG_INFO,
"audio data in non-audio track - ignoring\n");
@@ -1420,6 +1460,8 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
} else if ((res = ebml_read_master(matroska, &id)) < 0)
break;
audiotrack = (MatroskaAudioTrack *)track;
+ audiotrack->channels = 1;
+ audiotrack->samplerate = 8000;
while (res == 0) {
if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
@@ -1579,7 +1621,7 @@ matroska_add_stream (MatroskaDemuxContext *matroska)
uint64_t num;
if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
break;
- track->default_duration = num;
+ track->default_duration = num / matroska->time_scale;
break;
}
@@ -2076,9 +2118,9 @@ matroska_read_header (AVFormatContext *s,
return AVERROR_NOFMT;
}
av_free(doctype);
- if (version != 1) {
+ if (version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
- "Matroska demuxer version 1 too old for file version %d\n",
+ "Matroska demuxer version 2 too old for file version %d\n",
version);
return AVERROR_NOFMT;
}
@@ -2226,7 +2268,7 @@ matroska_read_header (AVFormatContext *s,
p = (unsigned char *)track->codec_priv + 16;
((MatroskaVideoTrack *)track)->fourcc = (p[3] << 24) |
(p[2] << 16) | (p[1] << 8) | p[0];
- codec_id = codec_get_bmp_id(((MatroskaVideoTrack *)track)->fourcc);
+ codec_id = codec_get_id(codec_bmp_tags, ((MatroskaVideoTrack *)track)->fourcc);
}
@@ -2242,7 +2284,7 @@ matroska_read_header (AVFormatContext *s,
/* Offset of wFormatTag. Stored in LE. */
p = (unsigned char *)track->codec_priv;
tag = (p[1] << 8) | p[0];
- codec_id = codec_get_wav_id(tag);
+ codec_id = codec_get_id(codec_wav_tags, tag);
}
@@ -2264,6 +2306,7 @@ matroska_read_header (AVFormatContext *s,
} else {
extradata_size = 2;
}
+ track->default_duration = 1024*1000 / audiotrack->internal_samplerate;
}
else if (codec_id == CODEC_ID_TTA) {
@@ -2308,7 +2351,7 @@ matroska_read_header (AVFormatContext *s,
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
- track->default_duration, 1000000000, 30000);
+ track->default_duration, 1000, 30000);
if(extradata){
st->codec->extradata = extradata;
@@ -2338,6 +2381,7 @@ matroska_read_header (AVFormatContext *s,
st->codec->height * videotrack->display_width,
st->codec-> width * videotrack->display_height,
255);
+ st->need_parsing = 2;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
@@ -2372,7 +2416,190 @@ matroska_find_track_by_num (MatroskaDemuxContext *matroska,
static inline int
rv_offset(uint8_t *data, int slice, int slices)
{
- return LE_32(data+8*slice+4) + 8*slices;
+ return AV_RL32(data+8*slice+4) + 8*slices;
+}
+
+static int
+matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
+ int64_t pos, uint64_t cluster_time, uint64_t duration,
+ int is_keyframe, int is_bframe)
+{
+ int res = 0;
+ int track;
+ AVPacket *pkt;
+ uint8_t *origdata = data;
+ int16_t block_time;
+ uint32_t *lace_size = NULL;
+ int n, flags, laces = 0;
+ uint64_t num;
+
+ /* first byte(s): tracknum */
+ if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) {
+ av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n");
+ av_free(origdata);
+ return res;
+ }
+ data += n;
+ size -= n;
+
+ /* fetch track from num */
+ track = matroska_find_track_by_num(matroska, num);
+ if (size <= 3 || track < 0 || track >= matroska->num_tracks) {
+ av_log(matroska->ctx, AV_LOG_INFO,
+ "Invalid stream %d or size %u\n", track, size);
+ av_free(origdata);
+ return res;
+ }
+ if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard >= AVDISCARD_ALL){
+ av_free(origdata);
+ return res;
+ }
+ if (duration == AV_NOPTS_VALUE)
+ duration = matroska->tracks[track]->default_duration;
+
+ /* block_time (relative to cluster time) */
+ block_time = (data[0] << 8) | data[1];
+ data += 2;
+ size -= 2;
+ flags = *data;
+ data += 1;
+ size -= 1;
+ if (is_keyframe == -1)
+ is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0;
+ switch ((flags & 0x06) >> 1) {
+ case 0x0: /* no lacing */
+ laces = 1;
+ lace_size = av_mallocz(sizeof(int));
+ lace_size[0] = size;
+ break;
+
+ case 0x1: /* xiph lacing */
+ case 0x2: /* fixed-size lacing */
+ case 0x3: /* EBML lacing */
+ if (size == 0) {
+ res = -1;
+ break;
+ }
+ laces = (*data) + 1;
+ data += 1;
+ size -= 1;
+ lace_size = av_mallocz(laces * sizeof(int));
+
+ switch ((flags & 0x06) >> 1) {
+ case 0x1: /* xiph lacing */ {
+ uint8_t temp;
+ uint32_t total = 0;
+ for (n = 0; res == 0 && n < laces - 1; n++) {
+ while (1) {
+ if (size == 0) {
+ res = -1;
+ break;
+ }
+ temp = *data;
+ lace_size[n] += temp;
+ data += 1;
+ size -= 1;
+ if (temp != 0xff)
+ break;
+ }
+ total += lace_size[n];
+ }
+ lace_size[n] = size - total;
+ break;
+ }
+
+ case 0x2: /* fixed-size lacing */
+ for (n = 0; n < laces; n++)
+ lace_size[n] = size / laces;
+ break;
+
+ case 0x3: /* EBML lacing */ {
+ uint32_t total;
+ n = matroska_ebmlnum_uint(data, size, &num);
+ if (n < 0) {
+ av_log(matroska->ctx, AV_LOG_INFO,
+ "EBML block data error\n");
+ break;
+ }
+ data += n;
+ size -= n;
+ total = lace_size[0] = num;
+ for (n = 1; res == 0 && n < laces - 1; n++) {
+ int64_t snum;
+ int r;
+ r = matroska_ebmlnum_sint (data, size, &snum);
+ if (r < 0) {
+ av_log(matroska->ctx, AV_LOG_INFO,
+ "EBML block data error\n");
+ break;
+ }
+ data += r;
+ size -= r;
+ lace_size[n] = lace_size[n - 1] + snum;
+ total += lace_size[n];
+ }
+ lace_size[n] = size - total;
+ break;
+ }
+ }
+ break;
+ }
+
+ if (res == 0) {
+ int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V;
+ uint64_t timecode = AV_NOPTS_VALUE;
+
+ if (cluster_time != (uint64_t)-1 && cluster_time + block_time >= 0)
+ timecode = cluster_time + block_time;
+
+ for (n = 0; n < laces; n++) {
+ int slice, slices = 1;
+
+ if (real_v) {
+ slices = *data++ + 1;
+ lace_size[n]--;
+ }
+
+ for (slice=0; slice<slices; slice++) {
+ int slice_size, slice_offset = 0;
+ if (real_v)
+ slice_offset = rv_offset(data, slice, slices);
+ if (slice+1 == slices)
+ slice_size = lace_size[n] - slice_offset;
+ else
+ slice_size = rv_offset(data, slice+1, slices) - slice_offset;
+ pkt = av_mallocz(sizeof(AVPacket));
+ /* XXX: prevent data copy... */
+ if (av_new_packet(pkt, slice_size) < 0) {
+ res = AVERROR_NOMEM;
+ n = laces-1;
+ break;
+ }
+ memcpy (pkt->data, data+slice_offset, slice_size);
+
+ if (n == 0)
+ pkt->flags = is_keyframe;
+ pkt->stream_index = matroska->tracks[track]->stream_index;
+
+ pkt->pts = timecode;
+ pkt->pos = pos;
+ pkt->duration = duration;
+
+ if (matroska->tracks[track]->flags & MATROSKA_TRACK_REORDER)
+ matroska_queue_packet_reordered(matroska, pkt, is_bframe);
+ else
+ matroska_queue_packet(matroska, pkt);
+
+ if (timecode != AV_NOPTS_VALUE)
+ timecode = duration ? timecode + duration : AV_NOPTS_VALUE;
+ }
+ data += lace_size[n];
+ }
+ }
+
+ av_free(lace_size);
+ av_free(origdata);
+ return res;
}
static int
@@ -2381,10 +2608,12 @@ matroska_parse_blockgroup (MatroskaDemuxContext *matroska,
{
int res = 0;
uint32_t id;
- AVPacket *pkt = NULL;
+ int is_bframe = 0;
int is_keyframe = PKT_FLAG_KEY, last_num_packets = matroska->num_packets;
uint64_t duration = AV_NOPTS_VALUE;
- int track = -1;
+ uint8_t *data;
+ int size = 0;
+ int64_t pos = 0;
av_log(matroska->ctx, AV_LOG_DEBUG, "parsing blockgroup...\n");
@@ -2402,194 +2631,31 @@ matroska_parse_blockgroup (MatroskaDemuxContext *matroska,
* of the harder things, so this code is a bit complicated.
* See http://www.matroska.org/ for documentation. */
case MATROSKA_ID_BLOCK: {
- uint8_t *data, *origdata;
- int size;
- int16_t block_time;
- uint32_t *lace_size = NULL;
- int n, flags, laces = 0;
- uint64_t num;
- int64_t pos= url_ftell(&matroska->ctx->pb);
-
- if ((res = ebml_read_binary(matroska, &id, &data, &size)) < 0)
- break;
- origdata = data;
-
- /* first byte(s): tracknum */
- if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) {
- av_log(matroska->ctx, AV_LOG_ERROR,
- "EBML block data error\n");
- av_free(origdata);
- break;
- }
- data += n;
- size -= n;
-
- /* fetch track from num */
- track = matroska_find_track_by_num(matroska, num);
- if (size <= 3 || track < 0 || track >= matroska->num_tracks) {
- av_log(matroska->ctx, AV_LOG_INFO,
- "Invalid stream %d or size %u\n", track, size);
- av_free(origdata);
- break;
- }
- if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard >= AVDISCARD_ALL){
- av_free(origdata);
- break;
- }
-
- /* block_time (relative to cluster time) */
- block_time = (data[0] << 8) | data[1];
- data += 2;
- size -= 2;
- flags = *data;
- data += 1;
- size -= 1;
- switch ((flags & 0x06) >> 1) {
- case 0x0: /* no lacing */
- laces = 1;
- lace_size = av_mallocz(sizeof(int));
- lace_size[0] = size;
- break;
-
- case 0x1: /* xiph lacing */
- case 0x2: /* fixed-size lacing */
- case 0x3: /* EBML lacing */
- if (size == 0) {
- res = -1;
- break;
- }
- laces = (*data) + 1;
- data += 1;
- size -= 1;
- lace_size = av_mallocz(laces * sizeof(int));
-
- switch ((flags & 0x06) >> 1) {
- case 0x1: /* xiph lacing */ {
- uint8_t temp;
- uint32_t total = 0;
- for (n = 0; res == 0 && n < laces - 1; n++) {
- while (1) {
- if (size == 0) {
- res = -1;
- break;
- }
- temp = *data;
- lace_size[n] += temp;
- data += 1;
- size -= 1;
- if (temp != 0xff)
- break;
- }
- total += lace_size[n];
- }
- lace_size[n] = size - total;
- break;
- }
-
- case 0x2: /* fixed-size lacing */
- for (n = 0; n < laces; n++)
- lace_size[n] = size / laces;
- break;
-
- case 0x3: /* EBML lacing */ {
- uint32_t total;
- n = matroska_ebmlnum_uint(data, size, &num);
- if (n < 0) {
- av_log(matroska->ctx, AV_LOG_INFO,
- "EBML block data error\n");
- break;
- }
- data += n;
- size -= n;
- total = lace_size[0] = num;
- for (n = 1; res == 0 && n < laces - 1; n++) {
- int64_t snum;
- int r;
- r = matroska_ebmlnum_sint (data, size,
- &snum);
- if (r < 0) {
- av_log(matroska->ctx, AV_LOG_INFO,
- "EBML block data error\n");
- break;
- }
- data += r;
- size -= r;
- lace_size[n] = lace_size[n - 1] + snum;
- total += lace_size[n];
- }
- lace_size[n] = size - total;
- break;
- }
- }
- break;
- }
-
- if (res == 0) {
- int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V;
- for (n = 0; n < laces; n++) {
- uint64_t timecode = AV_NOPTS_VALUE;
- int slice, slices = 1;
-
- if (real_v) {
- slices = *data++ + 1;
- lace_size[n]--;
- }
- if (cluster_time != (uint64_t)-1 && n == 0) {
- if (cluster_time + block_time >= 0)
- timecode = (cluster_time + block_time) * matroska->time_scale;
- }
- /* FIXME: duration */
-
- for (slice=0; slice<slices; slice++) {
- int slice_size, slice_offset = 0;
- if (real_v)
- slice_offset = rv_offset(data, slice, slices);
- if (slice+1 == slices)
- slice_size = lace_size[n] - slice_offset;
- else
- slice_size = rv_offset(data, slice+1, slices) - slice_offset;
- pkt = av_mallocz(sizeof(AVPacket));
- /* XXX: prevent data copy... */
- if (av_new_packet(pkt, slice_size) < 0) {
- res = AVERROR_NOMEM;
- n = laces-1;
- break;
- }
- memcpy (pkt->data, data+slice_offset, slice_size);
-
- if (n == 0)
- pkt->flags = is_keyframe;
- pkt->stream_index =
- matroska->tracks[track]->stream_index;
-
- pkt->pts = timecode;
- pkt->pos = pos;
-
- matroska_queue_packet(matroska, pkt);
- }
- data += lace_size[n];
- }
- }
-
- av_free(lace_size);
- av_free(origdata);
+ pos = url_ftell(&matroska->ctx->pb);
+ res = ebml_read_binary(matroska, &id, &data, &size);
break;
}
case MATROSKA_ID_BLOCKDURATION: {
if ((res = ebml_read_uint(matroska, &id, &duration)) < 0)
break;
+ duration /= matroska->time_scale;
break;
}
- case MATROSKA_ID_BLOCKREFERENCE:
+ case MATROSKA_ID_BLOCKREFERENCE: {
+ int64_t num;
/* We've found a reference, so not even the first frame in
* the lace is a key frame. */
is_keyframe = 0;
if (last_num_packets != matroska->num_packets)
matroska->packets[last_num_packets]->flags = 0;
- res = ebml_read_skip(matroska);
+ if ((res = ebml_read_sint(matroska, &id, &num)) < 0)
+ break;
+ if (num > 0)
+ is_bframe = 1;
break;
+ }
default:
av_log(matroska->ctx, AV_LOG_INFO,
@@ -2607,13 +2673,12 @@ matroska_parse_blockgroup (MatroskaDemuxContext *matroska,
}
}
- if (pkt)
- {
- if (duration != AV_NOPTS_VALUE)
- pkt->duration = duration;
- else if (track >= 0 && track < matroska->num_tracks)
- pkt->duration = matroska->tracks[track]->default_duration / matroska->time_scale;
- }
+ if (res)
+ return res;
+
+ if (size > 0)
+ res = matroska_parse_block(matroska, data, size, pos, cluster_time,
+ duration, is_keyframe, is_bframe);
return res;
}
@@ -2624,6 +2689,9 @@ matroska_parse_cluster (MatroskaDemuxContext *matroska)
int res = 0;
uint32_t id;
uint64_t cluster_time = 0;
+ uint8_t *data;
+ int64_t pos;
+ int size;
av_log(matroska->ctx, AV_LOG_DEBUG,
"parsing cluster at %"PRId64"\n", url_ftell(&matroska->ctx->pb));
@@ -2654,6 +2722,15 @@ matroska_parse_cluster (MatroskaDemuxContext *matroska)
res = matroska_parse_blockgroup(matroska, cluster_time);
break;
+ case MATROSKA_ID_SIMPLEBLOCK:
+ pos = url_ftell(&matroska->ctx->pb);
+ res = ebml_read_binary(matroska, &id, &data, &size);
+ if (res == 0)
+ res = matroska_parse_block(matroska, data, size, pos,
+ cluster_time, AV_NOPTS_VALUE,
+ -1, 0);
+ break;
+
default:
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown entry 0x%x in cluster data\n", id);
@@ -2681,47 +2758,46 @@ matroska_read_packet (AVFormatContext *s,
int res = 0;
uint32_t id;
- /* Do we still have a packet queued? */
- if (matroska_deliver_packet(matroska, pkt) == 0)
- return 0;
+ /* Read stream until we have a packet queued. */
+ while (matroska_deliver_packet(matroska, pkt)) {
- /* Have we already reached the end? */
- if (matroska->done)
- return AVERROR_IO;
+ /* Have we already reached the end? */
+ if (matroska->done)
+ return AVERROR_IO;
- while (res == 0) {
- if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
- res = AVERROR_IO;
- break;
- } else if (matroska->level_up) {
- matroska->level_up--;
- break;
- }
+ while (res == 0) {
+ if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
+ return AVERROR_IO;
+ } else if (matroska->level_up) {
+ matroska->level_up--;
+ break;
+ }
- switch (id) {
- case MATROSKA_ID_CLUSTER:
- if ((res = ebml_read_master(matroska, &id)) < 0)
+ switch (id) {
+ case MATROSKA_ID_CLUSTER:
+ if ((res = ebml_read_master(matroska, &id)) < 0)
+ break;
+ if ((res = matroska_parse_cluster(matroska)) == 0)
+ res = 1; /* Parsed one cluster, let's get out. */
break;
- if ((res = matroska_parse_cluster(matroska)) == 0)
- res = 1; /* Parsed one cluster, let's get out. */
- break;
- default:
- case EBML_ID_VOID:
- res = ebml_read_skip(matroska);
+ default:
+ case EBML_ID_VOID:
+ res = ebml_read_skip(matroska);
+ break;
+ }
+
+ if (matroska->level_up) {
+ matroska->level_up--;
break;
+ }
}
- if (matroska->level_up) {
- matroska->level_up--;
- break;
- }
+ if (res == -1)
+ matroska->done = 1;
}
- if (res == -1)
- matroska->done = 1;
-
- return matroska_deliver_packet(matroska, pkt);
+ return 0;
}
static int
@@ -2741,6 +2817,13 @@ matroska_read_close (AVFormatContext *s)
}
av_free(matroska->packets);
}
+ if (matroska->packets_reorder) {
+ for (n = 0; n < matroska->num_packets_reorder; n++) {
+ av_free_packet(matroska->packets_reorder[n]);
+ av_free(matroska->packets_reorder[n]);
+ }
+ av_free(matroska->packets_reorder);
+ }
for (n = 0; n < matroska->num_tracks; n++) {
MatroskaTrack *track = matroska->tracks[n];
diff --git a/contrib/ffmpeg/libavformat/mm.c b/contrib/ffmpeg/libavformat/mm.c
index a3c637fb2..443b70929 100644
--- a/contrib/ffmpeg/libavformat/mm.c
+++ b/contrib/ffmpeg/libavformat/mm.c
@@ -61,9 +61,9 @@ static int mm_probe(AVProbeData *p)
/* the first chunk is always the header */
if (p->buf_size < MM_PREAMBLE_SIZE)
return 0;
- if (LE_16(&p->buf[0]) != MM_TYPE_HEADER)
+ if (AV_RL16(&p->buf[0]) != MM_TYPE_HEADER)
return 0;
- if (LE_32(&p->buf[2]) != MM_HEADER_LEN_V && LE_32(&p->buf[2]) != MM_HEADER_LEN_AV)
+ if (AV_RL32(&p->buf[2]) != MM_HEADER_LEN_V && AV_RL32(&p->buf[2]) != MM_HEADER_LEN_AV)
return 0;
/* only return half certainty since this check is a bit sketchy */
@@ -141,8 +141,8 @@ static int mm_read_packet(AVFormatContext *s,
return AVERROR_IO;
}
- type = LE_16(&preamble[0]);
- length = LE_16(&preamble[2]);
+ type = AV_RL16(&preamble[0]);
+ length = AV_RL16(&preamble[2]);
switch(type) {
case MM_TYPE_PALETTE :
diff --git a/contrib/ffmpeg/libavformat/mov.c b/contrib/ffmpeg/libavformat/mov.c
index 3ceac64b1..e9b577576 100644
--- a/contrib/ffmpeg/libavformat/mov.c
+++ b/contrib/ffmpeg/libavformat/mov.c
@@ -66,95 +66,6 @@
#undef NDEBUG
#include <assert.h>
-static const CodecTag mov_video_tags[] = {
-/* { CODEC_ID_, MKTAG('c', 'v', 'i', 'd') }, *//* Cinepak */
-/* { CODEC_ID_H263, MKTAG('r', 'a', 'w', ' ') }, *//* Uncompressed RGB */
-/* { CODEC_ID_H263, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */
-/* { CODEC_ID_RAWVIDEO, MKTAG('A', 'V', 'U', 'I') }, *//* YUV with alpha-channel (AVID Uncompressed) */
-/* Graphics */
-/* Animation */
-/* Apple video */
-/* Kodak Photo CD */
- { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */
- { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
- { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */
- { CODEC_ID_MJPEGB, MKTAG('m', 'j', 'p', 'b') }, /* Motion-JPEG (format B) */
- { CODEC_ID_MJPEG, MKTAG('A', 'V', 'D', 'J') }, /* MJPEG with alpha-channel (AVID JFIF meridien compressed) */
-/* { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') }, *//* MJPEG with alpha-channel (AVID ABVB/Truevision NuVista) */
- { CODEC_ID_GIF, MKTAG('g', 'i', 'f', ' ') }, /* embedded gif files as frames (usually one "click to play movie" frame) */
-/* Sorenson video */
- { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, /* Sorenson Video v1 */
- { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') }, /* Sorenson Video v1 */
- { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', 'i') }, /* Sorenson Video v1 (from QT specs)*/
- { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, /* Sorenson Video v3 */
- { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
- { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') }, /* OpenDiVX *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
- { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
- { CODEC_ID_MPEG4, MKTAG('3', 'I', 'V', '2') }, /* experimental: 3IVX files before ivx D4 4.5.1 */
-/* { CODEC_ID_, MKTAG('I', 'V', '5', '0') }, *//* Indeo 5.0 */
- { CODEC_ID_H263, MKTAG('h', '2', '6', '3') }, /* H263 */
- { CODEC_ID_H263, MKTAG('s', '2', '6', '3') }, /* H263 ?? works */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
- { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */
- { CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') }, /* Apple Video (RPZA) */
- { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, /* Cinepak */
- { CODEC_ID_8BPS, MKTAG('8', 'B', 'P', 'S') }, /* Planar RGB (8BPS) */
- { CODEC_ID_SMC, MKTAG('s', 'm', 'c', ' ') }, /* Apple Graphics (SMC) */
- { CODEC_ID_QTRLE, MKTAG('r', 'l', 'e', ' ') }, /* Apple Animation (RLE) */
- { CODEC_ID_QDRAW, MKTAG('q', 'd', 'r', 'w') }, /* QuickDraw */
- { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
- { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '2') }, /* MPEG2 produced by Sony HD camera */
- { CODEC_ID_MPEG2VIDEO, MKTAG('h', 'd', 'v', '3') }, /* HDV produced by FCP */
- { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'n') }, /* MPEG2 IMX NTSC 525/60 50mb/s produced by FCP */
- { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '5', 'p') }, /* MPEG2 IMX PAL 625/50 50mb/s produced by FCP */
- { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'n') }, /* MPEG2 IMX NTSC 525/60 30mb/s produced by FCP */
- { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'p') }, /* MPEG2 IMX PAL 625/50 30mb/s produced by FCP */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL produced by FCP */
- //{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '5') }, /* DVCPRO HD 50i produced by FCP */
- //{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '6') }, /* DVCPRO HD 60i produced by FCP */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL produced by FCP */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC produced by FCP */
- { CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, /* AVID DV */
- //{ CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */
- { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') }, /* Truevision Targa */
- { CODEC_ID_TIFF, MKTAG('t', 'i', 'f', 'f') }, /* TIFF embedded in MOV */
- { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, /* UNCOMPRESSED 8BIT 4:2:2 */
- { CODEC_ID_NONE, 0 },
-};
-
-static const CodecTag mov_audio_tags[] = {
- { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') },
- { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
- { CODEC_ID_PCM_S16BE, MKTAG('N', 'O', 'N', 'E') }, /* uncompressed */
- { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') }, /* 16 bits */
- { CODEC_ID_PCM_U8, MKTAG('r', 'a', 'w', ' ') }, /* 8 bits unsigned */
- { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') }, /* */
- { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') }, /* */
- { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') }, /* */
- { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') }, /* IMA-4 ADPCM */
- { CODEC_ID_ADPCM_MS, MKTAG('m', 's', 0x00, 0x02) }, /* MS ADPCM */
- { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') }, /* Macintosh Audio Compression and Expansion 3:1 */
- { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') }, /* Macintosh Audio Compression and Expansion 6:1 */
-
- { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') }, /* MPEG layer 3 */ /* sample files at http://www.3ivx.com/showcase.html use this tag */
- { CODEC_ID_MP2, 0x6D730055 }, /* MPEG layer 3 */
- { CODEC_ID_MP2, 0x5500736D }, /* MPEG layer 3 *//* XXX: check endianness */
-/* { CODEC_ID_OGG_VORBIS, MKTAG('O', 'g', 'g', 'S') }, *//* sample files at http://heroinewarrior.com/xmovie.php3 use this tag */
-/* MP4 tags */
- { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, /* MPEG-4 AAC */
- /* The standard for mpeg4 audio is still not normalised AFAIK anyway */
- { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */
- { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */
- { CODEC_ID_AC3, MKTAG('m', 's', 0x20, 0x00) }, /* Dolby AC-3 */
- { CODEC_ID_ALAC,MKTAG('a', 'l', 'a', 'c') }, /* Apple Lossless */
- { CODEC_ID_QDM2,MKTAG('Q', 'D', 'M', '2') }, /* QDM2 */
- { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
- { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
- { CODEC_ID_PCM_S16LE, MKTAG('l', 'p', 'c', 'm') },
- { CODEC_ID_NONE, 0 },
-};
-
/* the QuickTime file format is quite convoluted...
* it has lots of index tables, each indexing something in another one...
* Here we just use what is needed to read the chunks
@@ -237,27 +148,28 @@ struct MOVParseTableEntry;
typedef struct MOVStreamContext {
int ffindex; /* the ffmpeg stream id */
long next_chunk;
- long chunk_count;
+ unsigned int chunk_count;
int64_t *chunk_offsets;
- int stts_count;
+ unsigned int stts_count;
Time2Sample *stts_data;
- int ctts_count;
+ unsigned int ctts_count;
Time2Sample *ctts_data;
- int edit_count; /* number of 'edit' (elst atom) */
- long sample_to_chunk_sz;
+ unsigned int edit_count; /* number of 'edit' (elst atom) */
+ unsigned int sample_to_chunk_sz;
MOV_sample_to_chunk_tbl *sample_to_chunk;
int sample_to_ctime_index;
int sample_to_ctime_sample;
- long sample_size;
- long sample_count;
+ unsigned int sample_size;
+ unsigned int sample_count;
long *sample_sizes;
- long keyframe_count;
+ unsigned int keyframe_count;
long *keyframes;
int time_scale;
int time_rate;
long current_sample;
MOV_esds_t esds;
- AVRational sample_size_v1;
+ unsigned int bytes_per_frame;
+ unsigned int samples_per_frame;
int dv_audio_container;
} MOVStreamContext;
@@ -267,12 +179,8 @@ typedef struct MOVContext {
int64_t duration; /* duration of the longest track */
int found_moov; /* when both 'moov' and 'mdat' sections has been found */
int found_mdat; /* we suppose we have enough data to read the file */
- int64_t mdat_size;
int64_t mdat_offset;
int total_streams;
- /* some streams listed here aren't presented to the ffmpeg API, since they aren't either video nor audio
- * but we need the info to be able to skip data from those streams in the 'mdat' section
- */
MOVStreamContext *streams[MAX_STREAMS];
int ctab_size;
@@ -325,7 +233,7 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
}
total_size += 8;
a.offset += 8;
- dprintf("type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size);
+ dprintf(c->fc, "type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size);
if (a.size == 1) { /* 64 bit extended size */
a.size = get_be64(pb) - 8;
a.offset += 8;
@@ -336,15 +244,14 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
if (a.size <= 8)
break;
}
+ a.size -= 8;
+ if(a.size < 0 || a.size > atom.size - total_size)
+ break;
+
for (i = 0; c->parse_table[i].type != 0L
&& c->parse_table[i].type != a.type; i++)
/* empty */;
- a.size -= 8;
-
- if(a.size < 0)
- break;
-
if (c->parse_table[i].type == 0) { /* skip leaf atoms data */
url_fskip(pb, a.size);
} else {
@@ -404,8 +311,8 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
ctype = get_le32(pb);
type = get_le32(pb); /* component subtype */
- dprintf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype);
- dprintf("stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
+ dprintf(c->fc, "ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype);
+ dprintf(c->fc, "stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]);
if(!ctype)
c->isom = 1;
if(type == MKTAG('v', 'i', 'd', 'e'))
@@ -442,12 +349,12 @@ static int mov_mp4_read_descr_len(ByteIOContext *pb)
return len;
}
-static int mov_mp4_read_descr(ByteIOContext *pb, int *tag)
+static int mov_mp4_read_descr(MOVContext *c, ByteIOContext *pb, int *tag)
{
int len;
*tag = get_byte(pb);
len = mov_mp4_read_descr_len(pb);
- dprintf("MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
+ dprintf(c->fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len);
return len;
}
@@ -459,14 +366,14 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
/* Well, broken but suffisant for some MP4 streams */
get_be32(pb); /* version + flags */
- len = mov_mp4_read_descr(pb, &tag);
+ len = mov_mp4_read_descr(c, pb, &tag);
if (tag == MP4ESDescrTag) {
get_be16(pb); /* ID */
get_byte(pb); /* priority */
} else
get_be16(pb); /* ID */
- len = mov_mp4_read_descr(pb, &tag);
+ len = mov_mp4_read_descr(c, pb, &tag);
if (tag == MP4DecConfigDescrTag) {
sc->esds.object_type_id = get_byte(pb);
sc->esds.stream_type = get_byte(pb);
@@ -474,11 +381,11 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
sc->esds.max_bitrate = get_be32(pb);
sc->esds.avg_bitrate = get_be32(pb);
- st->codec->codec_id= codec_get_id(ff_mov_obj_type, sc->esds.object_type_id);
- dprintf("esds object type id %d\n", sc->esds.object_type_id);
- len = mov_mp4_read_descr(pb, &tag);
+ st->codec->codec_id= codec_get_id(ff_mp4_obj_type, sc->esds.object_type_id);
+ dprintf(c->fc, "esds object type id %d\n", sc->esds.object_type_id);
+ len = mov_mp4_read_descr(c, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
- dprintf("Specific MPEG4 header len=%d\n", len);
+ dprintf(c->fc, "Specific MPEG4 header len=%d\n", len);
st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) {
get_buffer(pb, st->codec->extradata, len);
@@ -504,7 +411,6 @@ static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
c->mdat_count++;
c->found_mdat=1;
c->mdat_offset = atom.offset;
- c->mdat_size = atom.size;
if(c->found_moov)
return 1; /* found both, just go */
url_fskip(pb, atom.size);
@@ -619,9 +525,9 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) {
- strcpy(st->codec->extradata, "SVQ3"); // fake
+ memcpy(st->codec->extradata, "SVQ3", 4); // fake
get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
- dprintf("Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
+ dprintf(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
} else
url_fskip(pb, atom.size);
@@ -648,21 +554,18 @@ static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
return 0;
}
-static int mov_read_alac(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
+/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
+static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
-
- // currently ALAC decoder expect full atom header - so let's fake it
- // this should be fixed and just ALAC header should be passed
-
+ if((uint64_t)atom.size > (1<<30))
+ return -1;
av_free(st->codec->extradata);
- st->codec->extradata_size = 36;
+ st->codec->extradata_size = atom.size + 8;
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
-
if (st->codec->extradata) {
- strcpy(st->codec->extradata + 4, "alac"); // fake
- get_buffer(pb, st->codec->extradata + 8, 36 - 8);
- dprintf("Reading alac %d %s\n", st->codec->extradata_size, st->codec->extradata);
+ AV_WL32(st->codec->extradata + 4, atom.type);
+ get_buffer(pb, st->codec->extradata + 8, atom.size);
} else
url_fskip(pb, atom.size);
return 0;
@@ -692,27 +595,6 @@ static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
return 0;
}
-static int mov_read_jp2h(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
-{
- AVStream *st = c->fc->streams[c->fc->nb_streams-1];
-
- if((uint64_t)atom.size > (1<<30))
- return -1;
-
- av_free(st->codec->extradata);
-
- st->codec->extradata_size = atom.size + 8;
- st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
-
- /* pass all jp2h atom to codec */
- if (st->codec->extradata) {
- strcpy(st->codec->extradata + 4, "jp2h");
- get_buffer(pb, st->codec->extradata + 8, atom.size);
- } else
- url_fskip(pb, atom.size);
- return 0;
-}
-
static int mov_read_avcC(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
@@ -808,19 +690,19 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
}
st->codec->codec_tag = format;
- id = codec_get_id(mov_audio_tags, format);
+ id = codec_get_id(codec_movaudio_tags, format);
if (st->codec->codec_type != CODEC_TYPE_VIDEO && id > 0) {
st->codec->codec_type = CODEC_TYPE_AUDIO;
} else if (st->codec->codec_type != CODEC_TYPE_AUDIO && /* do not overwrite codec type */
format && format != MKTAG('m', 'p', '4', 's')) { /* skip old asf mpeg4 tag */
- id = codec_get_id(mov_video_tags, format);
+ id = codec_get_id(codec_movvideo_tags, format);
if (id <= 0)
id = codec_get_id(codec_bmp_tags, format);
if (id > 0)
st->codec->codec_type = CODEC_TYPE_VIDEO;
}
- dprintf("size=%d 4CC= %c%c%c%c codec_type=%d\n",
+ dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n",
size,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff,
st->codec->codec_type);
@@ -930,7 +812,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
get_be32(pb); /* vendor */
st->codec->channels = get_be16(pb); /* channel count */
- dprintf("audio channels %d\n", st->codec->channels);
+ dprintf(c->fc, "audio channels %d\n", st->codec->channels);
st->codec->bits_per_sample = get_be16(pb); /* sample size */
/* do we need to force to 16 for AMR ? */
@@ -958,12 +840,12 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
}
//Read QT version 1 fields. In version 0 theese dont exist
- dprintf("version =%d, isom =%d\n",version,c->isom);
+ dprintf(c->fc, "version =%d, isom =%d\n",version,c->isom);
if(!c->isom) {
if(version==1) {
- sc->sample_size_v1.den = get_be32(pb); /* samples per packet */
+ sc->samples_per_frame = get_be32(pb);
get_be32(pb); /* bytes per packet */
- sc->sample_size_v1.num = get_be32(pb); /* bytes per frame */
+ sc->bytes_per_frame = get_be32(pb);
get_be32(pb); /* bytes per sample */
} else if(version==2) {
get_be32(pb); /* sizeof struct only */
@@ -1012,7 +894,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
st->codec->width= 0; /* let decoder init width/height */
st->codec->height= 0;
break;
-#ifdef CONFIG_FAAD
+#ifdef CONFIG_LIBFAAD
case CODEC_ID_AAC:
#endif
#ifdef CONFIG_VORBIS_DECODER
@@ -1043,6 +925,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
st->codec->channels= 1; /* really needed */
break;
case CODEC_ID_MP2:
+ case CODEC_ID_MP3:
st->codec->codec_type = CODEC_TYPE_AUDIO; /* force type after stsd for m1a hdlr */
st->need_parsing = 1;
break;
@@ -1098,7 +981,7 @@ static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
sc->keyframe_count = entries;
#ifdef DEBUG
- av_log(NULL, AV_LOG_DEBUG, "keyframe_count = %ld\n", sc->keyframe_count);
+ av_log(NULL, AV_LOG_DEBUG, "keyframe_count = %d\n", sc->keyframe_count);
#endif
sc->keyframes = av_malloc(entries * sizeof(long));
if (!sc->keyframes)
@@ -1133,7 +1016,7 @@ static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
return 0;
#ifdef DEBUG
- av_log(NULL, AV_LOG_DEBUG, "sample_size = %ld sample_count = %ld\n", sc->sample_size, sc->sample_count);
+ av_log(NULL, AV_LOG_DEBUG, "sample_size = %d sample_count = %d\n", sc->sample_size, sc->sample_count);
#endif
sc->sample_sizes = av_malloc(entries * sizeof(long));
if (!sc->sample_sizes)
@@ -1181,7 +1064,7 @@ av_log(NULL, AV_LOG_DEBUG, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1,
sc->time_rate= ff_gcd(sc->time_rate, sample_duration);
- dprintf("sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
+ dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
duration+=(int64_t)sample_duration*sample_count;
total_sample_count+=sample_count;
@@ -1208,7 +1091,7 @@ static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
sc->ctts_count = entries;
sc->ctts_data = av_malloc(entries * sizeof(Time2Sample));
- dprintf("track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
+ dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
for(i=0; i<entries; i++) {
int count =get_be32(pb);
@@ -1380,7 +1263,7 @@ static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
get_be32(pb); /* Media time */
get_be32(pb); /* Media rate */
}
- dprintf("track[%i].edit_count = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count);
+ dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count);
return 0;
}
@@ -1391,9 +1274,10 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG( 'e', 'd', 't', 's' ), mov_read_default },
{ MKTAG( 'e', 'l', 's', 't' ), mov_read_elst },
{ MKTAG( 'e', 'n', 'd', 'a' ), mov_read_enda },
+{ MKTAG( 'f', 'i', 'e', 'l' ), mov_read_extradata },
{ MKTAG( 'f', 't', 'y', 'p' ), mov_read_ftyp },
{ MKTAG( 'h', 'd', 'l', 'r' ), mov_read_hdlr },
-{ MKTAG( 'j', 'p', '2', 'h' ), mov_read_jp2h },
+{ MKTAG( 'j', 'p', '2', 'h' ), mov_read_extradata },
{ MKTAG( 'm', 'd', 'a', 't' ), mov_read_mdat },
{ MKTAG( 'm', 'd', 'h', 'd' ), mov_read_mdhd },
{ MKTAG( 'm', 'd', 'i', 'a' ), mov_read_default },
@@ -1401,7 +1285,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG( 'm', 'o', 'o', 'v' ), mov_read_moov },
{ MKTAG( 'm', 'v', 'h', 'd' ), mov_read_mvhd },
{ MKTAG( 'S', 'M', 'I', ' ' ), mov_read_smi }, /* Sorenson extension ??? */
-{ MKTAG( 'a', 'l', 'a', 'c' ), mov_read_alac }, /* alac specific atom */
+{ MKTAG( 'a', 'l', 'a', 'c' ), mov_read_extradata }, /* alac specific atom */
{ MKTAG( 'a', 'v', 'c', 'C' ), mov_read_avcC },
{ MKTAG( 's', 't', 'b', 'l' ), mov_read_default },
{ MKTAG( 's', 't', 'c', 'o' ), mov_read_stco },
@@ -1443,7 +1327,7 @@ static int mov_probe(AVProbeData *p)
/* ignore invalid offset */
if ((offset + 8) > (unsigned int)p->buf_size)
return score;
- tag = LE_32(p->buf + offset + 4);
+ tag = AV_RL32(p->buf + offset + 4);
switch(tag) {
/* check for obvious tags */
case MKTAG( 'j', 'P', ' ', ' ' ): /* jpeg 2000 signature */
@@ -1461,7 +1345,7 @@ static int mov_probe(AVProbeData *p)
case MKTAG( 'f', 't', 'y', 'p' ):
case MKTAG( 's', 'k', 'i', 'p' ):
case MKTAG( 'u', 'u', 'i', 'd' ):
- offset = BE_32(p->buf+offset) + offset;
+ offset = AV_RB32(p->buf+offset) + offset;
/* if we only find those cause probedata is too small at least rate them */
score = AVPROBE_SCORE_MAX - 50;
break;
@@ -1478,16 +1362,16 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
MOVStreamContext *sc = st->priv_data;
offset_t current_offset;
int64_t current_dts = 0;
- int stts_index = 0;
- int stsc_index = 0;
- int stss_index = 0;
- int i, j, k;
+ unsigned int stts_index = 0;
+ unsigned int stsc_index = 0;
+ unsigned int stss_index = 0;
+ unsigned int i, j, k;
if (sc->sample_sizes || st->codec->codec_type == CODEC_TYPE_VIDEO || sc->dv_audio_container) {
- int keyframe, sample_size;
- int current_sample = 0;
- int stts_sample = 0;
- int distance = 0;
+ unsigned int current_sample = 0;
+ unsigned int stts_sample = 0;
+ unsigned int keyframe, sample_size;
+ unsigned int distance = 0;
st->nb_frames = sc->sample_count;
for (i = 0; i < sc->chunk_count; i++) {
@@ -1495,6 +1379,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
if (stsc_index + 1 < sc->sample_to_chunk_sz && i + 1 == sc->sample_to_chunk[stsc_index + 1].first)
stsc_index++;
for (j = 0; j < sc->sample_to_chunk[stsc_index].count; j++) {
+ if (current_sample >= sc->sample_count) {
+ av_log(mov->fc, AV_LOG_ERROR, "wrong sample count\n");
+ goto out;
+ }
keyframe = !sc->keyframe_count || current_sample + 1 == sc->keyframes[stss_index];
if (keyframe) {
distance = 0;
@@ -1502,7 +1390,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
stss_index++;
}
sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample];
- dprintf("AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n",
+ dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n",
st->index, current_sample, current_offset, current_dts, sample_size, distance, keyframe);
av_add_index_entry(st, current_offset, current_dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0);
current_offset += sample_size;
@@ -1510,8 +1398,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
current_dts += sc->stts_data[stts_index].duration / sc->time_rate;
distance++;
stts_sample++;
- if (current_sample + 1 < sc->sample_count)
- current_sample++;
+ current_sample++;
if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) {
stts_sample = 0;
stts_index++;
@@ -1519,7 +1406,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
}
} else { /* read whole chunk */
- int chunk_samples, chunk_size, chunk_duration;
+ unsigned int chunk_samples, chunk_size, chunk_duration;
for (i = 0; i < sc->chunk_count; i++) {
current_offset = sc->chunk_offsets[i];
@@ -1529,8 +1416,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
/* get chunk size */
if (sc->sample_size > 1 || st->codec->codec_id == CODEC_ID_PCM_U8 || st->codec->codec_id == CODEC_ID_PCM_S8)
chunk_size = chunk_samples * sc->sample_size;
- else if (sc->sample_size_v1.den > 0 && (chunk_samples * sc->sample_size_v1.num % sc->sample_size_v1.den == 0))
- chunk_size = chunk_samples * sc->sample_size_v1.num / sc->sample_size_v1.den;
+ else if (sc->samples_per_frame > 0 && (chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0))
+ chunk_size = chunk_samples * sc->bytes_per_frame / sc->samples_per_frame;
else { /* workaround to find nearest next chunk offset */
chunk_size = INT_MAX;
for (j = 0; j < mov->total_streams; j++) {
@@ -1547,7 +1434,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
/* check for last chunk */
if (chunk_size == INT_MAX)
for (j = 0; j < mov->mdat_count; j++) {
- dprintf("mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n",
+ dprintf(mov->fc, "mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n",
j, mov->mdat_list[j].offset, mov->mdat_list[j].size, current_offset);
if (mov->mdat_list[j].offset <= current_offset && mov->mdat_list[j].offset + mov->mdat_list[j].size > current_offset)
chunk_size = mov->mdat_list[j].offset + mov->mdat_list[j].size - current_offset;
@@ -1573,12 +1460,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
}
}
- dprintf("AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n",
+ dprintf(mov->fc, "AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n",
st->index, i, current_offset, current_dts, chunk_size, chunk_duration);
assert(chunk_duration % sc->time_rate == 0);
current_dts += chunk_duration / sc->time_rate;
}
}
+ out:
/* adjust sample count to avindex entries */
sc->sample_count = st->nb_index_entries;
}
@@ -1605,7 +1493,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
err, mov->found_moov, mov->found_mdat, url_ftell(pb));
return -1;
}
- dprintf("on_parse_exit_offset=%d\n", (int) url_ftell(pb));
+ dprintf(mov->fc, "on_parse_exit_offset=%d\n", (int) url_ftell(pb));
/* some cleanup : make sure we are on the mdat atom */
if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset))
@@ -1615,19 +1503,29 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
for(i=0; i<mov->total_streams; i++) {
MOVStreamContext *sc = mov->streams[i];
-
+ AVStream *st = s->streams[i];
+ /* sanity checks */
+ if(!sc->stts_count || !sc->chunk_count || !sc->sample_to_chunk_sz ||
+ (!sc->sample_size && !sc->sample_count)){
+ av_log(s, AV_LOG_ERROR, "missing mandatory atoms, broken header\n");
+ sc->sample_count = 0; //ignore track
+ continue;
+ }
if(!sc->time_rate)
sc->time_rate=1;
if(!sc->time_scale)
sc->time_scale= mov->time_scale;
- av_set_pts_info(s->streams[i], 64, sc->time_rate, sc->time_scale);
+ av_set_pts_info(st, 64, sc->time_rate, sc->time_scale);
+
+ if (st->codec->codec_type == CODEC_TYPE_AUDIO && sc->stts_count == 1)
+ st->codec->frame_size = sc->stts_data[0].duration;
- if(s->streams[i]->duration != AV_NOPTS_VALUE){
- assert(s->streams[i]->duration % sc->time_rate == 0);
- s->streams[i]->duration /= sc->time_rate;
+ if(st->duration != AV_NOPTS_VALUE){
+ assert(st->duration % sc->time_rate == 0);
+ st->duration /= sc->time_rate;
}
sc->ffindex = i;
- mov_build_index(mov, s->streams[i]);
+ mov_build_index(mov, st);
}
for(i=0; i<mov->total_streams; i++) {
@@ -1657,7 +1555,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
AVIndexEntry *current_sample = &s->streams[i]->index_entries[msc->current_sample];
int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, AV_TIME_BASE, msc->time_scale);
- dprintf("stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts);
+ dprintf(s, "stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts);
if (dts < best_dts) {
sample = current_sample;
best_dts = dts;
@@ -1676,7 +1574,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
#ifdef CONFIG_DV_DEMUXER
if (sc->dv_audio_container) {
dv_get_packet(mov->dv_demux, pkt);
- dprintf("dv audio pkt size %d\n", pkt->size);
+ dprintf(s, "dv audio pkt size %d\n", pkt->size);
} else {
#endif
url_fseek(&s->pb, sample->pos, SEEK_SET);
@@ -1705,7 +1603,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
}
pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0;
pkt->pos = sample->pos;
- dprintf("stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
+ dprintf(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
return 0;
}
@@ -1716,11 +1614,11 @@ static int mov_seek_stream(AVStream *st, int64_t timestamp, int flags)
int i;
sample = av_index_search_timestamp(st, timestamp, flags);
- dprintf("stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
+ dprintf(st->codec, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
if (sample < 0) /* not sure what to do */
return -1;
sc->current_sample = sample;
- dprintf("stream %d, found sample %ld\n", st->index, sc->current_sample);
+ dprintf(st->codec, "stream %d, found sample %ld\n", st->index, sc->current_sample);
/* adjust ctts index */
if (sc->ctts_data) {
time_sample = 0;
diff --git a/contrib/ffmpeg/libavformat/movenc.c b/contrib/ffmpeg/libavformat/movenc.c
index 736d1594a..e93416914 100644
--- a/contrib/ffmpeg/libavformat/movenc.c
+++ b/contrib/ffmpeg/libavformat/movenc.c
@@ -54,7 +54,6 @@ typedef struct MOVIndex {
long time;
int64_t trackDuration;
long sampleCount;
- long sampleDuration;
long sampleSize;
int hasKeyframes;
int hasBframes;
@@ -261,7 +260,7 @@ static int mov_write_esds_tag(ByteIOContext *pb, MOVTrack* track) // Basic
putDescr(pb, 0x04, 13 + decoderSpecificInfoLen);
// Object type indication
- put_byte(pb, codec_get_tag(ff_mov_obj_type, track->enc->codec_id));
+ put_byte(pb, codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
// the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio)
// plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
@@ -323,25 +322,6 @@ static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack* track)
return updateSize (pb, pos);
}
-static const CodecTag codec_movaudio_tags[] = {
- { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') },
- { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') },
- { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') },
- { CODEC_ID_MACE3, MKTAG('M', 'A', 'C', '3') },
- { CODEC_ID_MACE6, MKTAG('M', 'A', 'C', '6') },
- { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') },
- { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') },
- { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') },
- { CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's') },
- { CODEC_ID_PCM_S16LE, MKTAG('s', 'o', 'w', 't') },
- { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
- { CODEC_ID_PCM_S24LE, MKTAG('i', 'n', '2', '4') },
- { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') },
- { CODEC_ID_PCM_S32LE, MKTAG('i', 'n', '3', '2') },
- { CODEC_ID_MP3, MKTAG('.', 'm', 'p', '3') },
- { CODEC_ID_NONE, 0 },
-};
-
static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track)
{
offset_t pos = url_ftell(pb);
@@ -361,11 +341,20 @@ static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track)
put_be16(pb, 0); /* Revision level */
put_be32(pb, 0); /* Reserved */
- put_be16(pb, track->mode == MODE_MOV ? track->enc->channels : 2); /* Number of channels */
- /* FIXME 8 bit for 'raw ' in mov */
- put_be16(pb, 16); /* Reserved */
+ if (track->mode == MODE_MOV) {
+ put_be16(pb, track->enc->channels);
+ if (track->enc->codec_id == CODEC_ID_PCM_U8 ||
+ track->enc->codec_id == CODEC_ID_PCM_S8)
+ put_be16(pb, 8); /* bits per sample */
+ else
+ put_be16(pb, 16);
+ put_be16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
+ } else { /* reserved for mp4/3gp */
+ put_be16(pb, 2);
+ put_be16(pb, 16);
+ put_be16(pb, 0);
+ }
- put_be16(pb, track->mode == MODE_MOV && track->audio_vbr ? -2 : 0); /* compression ID */
put_be16(pb, 0); /* packet size (= 0) */
put_be16(pb, track->timescale); /* Time scale */
put_be16(pb, 0); /* Reserved */
@@ -481,7 +470,7 @@ static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track)
put_tag(pb, "avcC");
if (track->vosLen > 6) {
/* check for h264 start code */
- if (BE_32(track->vosData) == 0x00000001) {
+ if (AV_RB32(track->vosData) == 0x00000001) {
uint8_t *buf, *end;
uint32_t sps_size=0, pps_size=0;
uint8_t *sps=0, *pps=0;
@@ -494,7 +483,7 @@ static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track)
while (buf < end) {
unsigned int size;
uint8_t nal_type;
- size = BE_32(buf);
+ size = AV_RB32(buf);
nal_type = buf[4] & 0x1f;
if (nal_type == 7) { /* SPS */
sps = buf + 4;
@@ -527,22 +516,6 @@ static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos);
}
-static const CodecTag codec_movvideo_tags[] = {
- { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') },
- { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') },
- { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
- { CODEC_ID_H263, MKTAG('h', '2', '6', '3') },
- { CODEC_ID_H263, MKTAG('s', '2', '6', '3') },
- { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
- /* special handling in mov_find_video_codec_tag */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, /* DV NTSC */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'p', 'p') }, /* DVCPRO PAL */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'n') }, /* DVCPRO50 NTSC */
- { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', 'p') }, /* DVCPRO50 PAL */
- { CODEC_ID_NONE, 0 },
-};
-
static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->enc->codec_tag;
@@ -1501,28 +1474,20 @@ static int mov_write_header(AVFormatContext *s)
if(st->codec->codec_type == CODEC_TYPE_VIDEO){
track->tag = mov_find_video_codec_tag(s, track);
track->timescale = st->codec->time_base.den;
- track->sampleDuration = st->codec->time_base.num;
av_set_pts_info(st, 64, 1, st->codec->time_base.den);
}else if(st->codec->codec_type == CODEC_TYPE_AUDIO){
track->tag = mov_find_audio_codec_tag(s, track);
track->timescale = st->codec->sample_rate;
- track->sampleDuration = st->codec->frame_size;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
- switch(track->enc->codec_id){
- case CODEC_ID_MP3:
- case CODEC_ID_AAC:
- case CODEC_ID_AMR_NB:
- case CODEC_ID_AMR_WB:
+ if(!st->codec->frame_size){
+ av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
+ return -1;
+ }else if(st->codec->frame_size > 1){ /* assume compressed audio */
track->audio_vbr = 1;
- break;
- default:
+ }else{
track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
}
}
- if (!track->sampleDuration) {
- av_log(s, AV_LOG_ERROR, "track %d: sample duration is not set\n", i);
- return -1;
- }
}
mov_write_mdat_tag(pb, mov);
diff --git a/contrib/ffmpeg/libavformat/mp3.c b/contrib/ffmpeg/libavformat/mp3.c
index 723980c83..e86ea14c8 100644
--- a/contrib/ffmpeg/libavformat/mp3.c
+++ b/contrib/ffmpeg/libavformat/mp3.c
@@ -393,6 +393,7 @@ AVInputFormat mp3_demuxer = {
mp3_read_header,
mp3_read_packet,
mp3_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "mp2,mp3,m2a", /* XXX: use probe */
};
#endif
@@ -401,7 +402,7 @@ AVOutputFormat mp2_muxer = {
"mp2",
"MPEG audio layer 2",
"audio/x-mpeg",
-#ifdef CONFIG_MP3LAME
+#ifdef CONFIG_LIBMP3LAME
"mp2,m2a",
#else
"mp2,mp3,m2a",
diff --git a/contrib/ffmpeg/libavformat/mpc.c b/contrib/ffmpeg/libavformat/mpc.c
new file mode 100644
index 000000000..a28efb16d
--- /dev/null
+++ b/contrib/ffmpeg/libavformat/mpc.c
@@ -0,0 +1,231 @@
+/*
+ * Musepack demuxer
+ * Copyright (c) 2006 Konstantin Shishkov
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avformat.h"
+#include "bitstream.h"
+
+#define MPC_FRAMESIZE 1152
+#define DELAY_FRAMES 32
+
+static const int mpc_rate[4] = { 44100, 48000, 37800, 32000 };
+typedef struct {
+ int64_t pos;
+ int size, skip;
+}MPCFrame;
+
+typedef struct {
+ int ver;
+ uint32_t curframe, lastframe;
+ uint32_t fcount;
+ MPCFrame *frames;
+ int curbits;
+ int frames_noted;
+} MPCContext;
+
+static int mpc_probe(AVProbeData *p)
+{
+ const uint8_t *d = p->buf;
+ if (p->buf_size < 32)
+ return 0;
+ if (d[0] == 'M' && d[1] == 'P' && d[2] == '+' && (d[3] == 0x17 || d[3] == 0x7))
+ return AVPROBE_SCORE_MAX;
+ if (d[0] == 'I' && d[1] == 'D' && d[2] == '3')
+ return AVPROBE_SCORE_MAX / 2;
+ return 0;
+}
+
+static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+ MPCContext *c = s->priv_data;
+ AVStream *st;
+ int t;
+
+ t = get_le24(&s->pb);
+ if(t != MKTAG('M', 'P', '+', 0)){
+ if(t != MKTAG('I', 'D', '3', 0)){
+ av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
+ return -1;
+ }
+ /* skip ID3 tags and try again */
+ url_fskip(&s->pb, 3);
+ t = get_byte(&s->pb) << 21;
+ t |= get_byte(&s->pb) << 14;
+ t |= get_byte(&s->pb) << 7;
+ t |= get_byte(&s->pb);
+ av_log(s, AV_LOG_DEBUG, "Skipping %d(%X) bytes of ID3 data\n", t, t);
+ url_fskip(&s->pb, t);
+ if(get_le24(&s->pb) != MKTAG('M', 'P', '+', 0)){
+ av_log(s, AV_LOG_ERROR, "Not a Musepack file\n");
+ return -1;
+ }
+ }
+ c->ver = get_byte(&s->pb);
+ if(c->ver != 0x07 && c->ver != 0x17){
+ av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver);
+ return -1;
+ }
+ c->fcount = get_le32(&s->pb);
+ if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){
+ av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n");
+ return -1;
+ }
+ c->frames = av_malloc(c->fcount * sizeof(MPCFrame));
+ c->curframe = 0;
+ c->lastframe = -1;
+ c->curbits = 8;
+ c->frames_noted = 0;
+
+ st = av_new_stream(s, 0);
+ if (!st)
+ return AVERROR_NOMEM;
+ st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_id = CODEC_ID_MUSEPACK7;
+ st->codec->channels = 2;
+ st->codec->bits_per_sample = 16;
+
+ st->codec->extradata_size = 16;
+ st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
+ get_buffer(&s->pb, st->codec->extradata, 16);
+ st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
+ av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);
+ /* scan for seekpoints */
+ s->start_time = 0;
+ s->duration = (int64_t)c->fcount * MPC_FRAMESIZE * AV_TIME_BASE / st->codec->sample_rate;
+
+ return 0;
+}
+
+static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ MPCContext *c = s->priv_data;
+ int ret, size, size2, curbits, cur = c->curframe;
+ int64_t tmp, pos;
+
+ if (c->curframe >= c->fcount)
+ return -1;
+
+ if(c->curframe != c->lastframe + 1){
+ url_fseek(&s->pb, c->frames[c->curframe].pos, SEEK_SET);
+ c->curbits = c->frames[c->curframe].skip;
+ }
+ c->lastframe = c->curframe;
+ c->curframe++;
+ curbits = c->curbits;
+ pos = url_ftell(&s->pb);
+ tmp = get_le32(&s->pb);
+ if(curbits <= 12){
+ size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
+ }else{
+ tmp = (tmp << 32) | get_le32(&s->pb);
+ size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
+ }
+ curbits += 20;
+ url_fseek(&s->pb, pos, SEEK_SET);
+
+ size = ((size2 + curbits + 31) & ~31) >> 3;
+ if(cur == c->frames_noted){
+ c->frames[cur].pos = pos;
+ c->frames[cur].size = size;
+ c->frames[cur].skip = curbits - 20;
+ av_add_index_entry(s->streams[0], cur, cur, size, 0, AVINDEX_KEYFRAME);
+ c->frames_noted++;
+ }
+ c->curbits = (curbits + size2) & 0x1F;
+
+ if (av_new_packet(pkt, size) < 0)
+ return AVERROR_IO;
+
+ pkt->data[0] = curbits;
+ pkt->data[1] = (c->curframe > c->fcount);
+
+ pkt->stream_index = 0;
+ pkt->pts = cur;
+ ret = get_buffer(&s->pb, pkt->data + 4, size);
+ if(c->curbits)
+ url_fseek(&s->pb, -4, SEEK_CUR);
+ if(ret < size){
+ av_free_packet(pkt);
+ return AVERROR_IO;
+ }
+ pkt->size = ret + 4;
+
+ return 0;
+}
+
+static int mpc_read_close(AVFormatContext *s)
+{
+ MPCContext *c = s->priv_data;
+
+ av_freep(&c->frames);
+ return 0;
+}
+
+/**
+ * Seek to the given position
+ * If position is unknown but is within the limits of file
+ * then packets are skipped unless desired position is reached
+ *
+ * Also this function makes use of the fact that timestamp == frameno
+ */
+static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+{
+ AVStream *st = s->streams[stream_index];
+ MPCContext *c = s->priv_data;
+ AVPacket pkt1, *pkt = &pkt1;
+ int ret;
+ int index = av_index_search_timestamp(st, timestamp - DELAY_FRAMES, flags);
+ uint32_t lastframe;
+
+ /* if found, seek there */
+ if (index >= 0){
+ c->curframe = st->index_entries[index].pos;
+ return 0;
+ }
+ /* if timestamp is out of bounds, return error */
+ if(timestamp < 0 || timestamp >= c->fcount)
+ return -1;
+ timestamp -= DELAY_FRAMES;
+ /* seek to the furthest known position and read packets until
+ we reach desired position */
+ lastframe = c->curframe;
+ if(c->frames_noted) c->curframe = c->frames_noted - 1;
+ while(c->curframe < timestamp){
+ ret = av_read_frame(s, pkt);
+ if (ret < 0){
+ c->curframe = lastframe;
+ return -1;
+ }
+ av_free_packet(pkt);
+ }
+ return 0;
+}
+
+
+AVInputFormat mpc_demuxer = {
+ "mpc",
+ "musepack",
+ sizeof(MPCContext),
+ mpc_probe,
+ mpc_read_header,
+ mpc_read_packet,
+ mpc_read_close,
+ mpc_read_seek,
+ .extensions = "mpc",
+};
diff --git a/contrib/ffmpeg/libavformat/mpeg.c b/contrib/ffmpeg/libavformat/mpeg.c
index 709ce16f1..ae47fa60a 100644
--- a/contrib/ffmpeg/libavformat/mpeg.c
+++ b/contrib/ffmpeg/libavformat/mpeg.c
@@ -513,7 +513,7 @@ static int mpeg_mux_init(AVFormatContext *ctx)
for(i=0;i<ctx->nb_streams;i++) {
av_free(ctx->streams[i]->priv_data);
}
- return -ENOMEM;
+ return AVERROR(ENOMEM);
}
static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)
@@ -1445,14 +1445,18 @@ static int mpegps_read_pes_header(AVFormatContext *s,
{
MpegDemuxContext *m = s->priv_data;
int len, size, startcode, c, flags, header_len;
- int64_t pts, dts, last_pos;
+ int pes_ext, ext2_len, id_ext, skip;
+ int64_t pts, dts;
+ int64_t last_sync= url_ftell(&s->pb);
- last_pos = -1;
+ error_redo:
+ url_fseek(&s->pb, last_sync, SEEK_SET);
redo:
/* next start code (should be immediately after) */
m->header_state = 0xff;
size = MAX_SYNC_SIZE;
startcode = find_next_start_code(&s->pb, &size, &m->header_state);
+ last_sync = url_ftell(&s->pb);
//printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(&s->pb));
if (startcode < 0)
return AVERROR_IO;
@@ -1475,18 +1479,18 @@ static int mpegps_read_pes_header(AVFormatContext *s,
/* find matching stream */
if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
(startcode >= 0x1e0 && startcode <= 0x1ef) ||
- (startcode == 0x1bd)))
+ (startcode == 0x1bd) || (startcode == 0x1fd)))
goto redo;
if (ppos) {
*ppos = url_ftell(&s->pb) - 4;
}
len = get_be16(&s->pb);
- pts = AV_NOPTS_VALUE;
+ pts =
dts = AV_NOPTS_VALUE;
/* stuffing */
for(;;) {
if (len < 1)
- goto redo;
+ goto error_redo;
c = get_byte(&s->pb);
len--;
/* XXX: for mpeg1, should test only bit 7 */
@@ -1495,23 +1499,17 @@ static int mpegps_read_pes_header(AVFormatContext *s,
}
if ((c & 0xc0) == 0x40) {
/* buffer scale & size */
- if (len < 2)
- goto redo;
get_byte(&s->pb);
c = get_byte(&s->pb);
len -= 2;
}
- if ((c & 0xf0) == 0x20) {
- if (len < 4)
- goto redo;
+ if ((c & 0xe0) == 0x20) {
dts = pts = get_pts(&s->pb, c);
len -= 4;
- } else if ((c & 0xf0) == 0x30) {
- if (len < 9)
- goto redo;
- pts = get_pts(&s->pb, c);
- dts = get_pts(&s->pb, -1);
- len -= 9;
+ if (c & 0x10){
+ dts = get_pts(&s->pb, -1);
+ len -= 5;
+ }
} else if ((c & 0xc0) == 0x80) {
/* mpeg 2 PES */
#if 0 /* some streams have this field set for no apparent reason */
@@ -1524,45 +1522,64 @@ static int mpegps_read_pes_header(AVFormatContext *s,
header_len = get_byte(&s->pb);
len -= 2;
if (header_len > len)
- goto redo;
- if ((flags & 0xc0) == 0x80) {
+ goto error_redo;
+ len -= header_len;
+ if (flags & 0x80) {
dts = pts = get_pts(&s->pb, -1);
- if (header_len < 5)
- goto redo;
header_len -= 5;
- len -= 5;
- } if ((flags & 0xc0) == 0xc0) {
- pts = get_pts(&s->pb, -1);
- dts = get_pts(&s->pb, -1);
- if (header_len < 10)
- goto redo;
- header_len -= 10;
- len -= 10;
+ if (flags & 0x40) {
+ dts = get_pts(&s->pb, -1);
+ header_len -= 5;
+ }
}
- len -= header_len;
- while (header_len > 0) {
- get_byte(&s->pb);
+ if (flags & 0x01) { /* PES extension */
+ pes_ext = get_byte(&s->pb);
header_len--;
+ if (pes_ext & 0x40) { /* pack header - should be zero in PS */
+ goto error_redo;
+ }
+ /* Skip PES private data, program packet sequence counter and P-STD buffer */
+ skip = (pes_ext >> 4) & 0xb;
+ skip += skip & 0x9;
+ url_fskip(&s->pb, skip);
+ header_len -= skip;
+
+ if (pes_ext & 0x01) { /* PES extension 2 */
+ ext2_len = get_byte(&s->pb);
+ header_len--;
+ if ((ext2_len & 0x7f) > 0) {
+ id_ext = get_byte(&s->pb);
+ if ((id_ext & 0x80) == 0)
+ startcode = ((startcode & 0xff) << 8) | id_ext;
+ header_len--;
+ }
+ }
}
+ if(header_len < 0)
+ goto error_redo;
+ url_fskip(&s->pb, header_len);
}
else if( c!= 0xf )
goto redo;
if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
- if (len < 1)
- goto redo;
startcode = get_byte(&s->pb);
len--;
- if (startcode >= 0x80 && startcode <= 0xbf) {
+ if (startcode >= 0x80 && startcode <= 0xcf) {
/* audio: skip header */
- if (len < 3)
- goto redo;
get_byte(&s->pb);
get_byte(&s->pb);
get_byte(&s->pb);
len -= 3;
+ if (startcode >= 0xb0 && startcode <= 0xbf) {
+ /* MLP/TrueHD audio has a 4-byte header */
+ get_byte(&s->pb);
+ len--;
+ }
}
}
+ if(len<0)
+ goto error_redo;
if(dts != AV_NOPTS_VALUE && ppos){
int i;
for(i=0; i<s->nb_streams; i++){
@@ -1641,15 +1658,27 @@ static int mpegps_read_packet(AVFormatContext *s,
} else if (startcode >= 0x80 && startcode <= 0x87) {
type = CODEC_TYPE_AUDIO;
codec_id = CODEC_ID_AC3;
- } else if (startcode >= 0x88 && startcode <= 0x9f) {
+ } else if ((startcode >= 0x88 && startcode <= 0x8f)
+ ||( startcode >= 0x98 && startcode <= 0x9f)) {
+ /* 0x90 - 0x97 is reserved for SDDS in DVD specs */
type = CODEC_TYPE_AUDIO;
codec_id = CODEC_ID_DTS;
- } else if (startcode >= 0xa0 && startcode <= 0xbf) {
+ } else if (startcode >= 0xa0 && startcode <= 0xaf) {
type = CODEC_TYPE_AUDIO;
codec_id = CODEC_ID_PCM_S16BE;
+ } else if (startcode >= 0xb0 && startcode <= 0xbf) {
+ type = CODEC_TYPE_AUDIO;
+ codec_id = CODEC_ID_MLP;
+ } else if (startcode >= 0xc0 && startcode <= 0xcf) {
+ /* Used for both AC-3 and E-AC-3 in EVOB files */
+ type = CODEC_TYPE_AUDIO;
+ codec_id = CODEC_ID_AC3;
} else if (startcode >= 0x20 && startcode <= 0x3f) {
type = CODEC_TYPE_SUBTITLE;
codec_id = CODEC_ID_DVD_SUBTITLE;
+ } else if (startcode >= 0xfd55 && startcode <= 0xfd5f) {
+ type = CODEC_TYPE_VIDEO;
+ codec_id = CODEC_ID_VC1;
} else {
skip:
/* skip packet */
@@ -1667,7 +1696,7 @@ static int mpegps_read_packet(AVFormatContext *s,
found:
if(st->discard >= AVDISCARD_ALL)
goto skip;
- if (startcode >= 0xa0 && startcode <= 0xbf) {
+ if (startcode >= 0xa0 && startcode <= 0xaf) {
int b1, freq;
/* for LPCM, we just skip the header and consider it is raw
diff --git a/contrib/ffmpeg/libavformat/mpegts.c b/contrib/ffmpeg/libavformat/mpegts.c
index dd5f0adca..c466710ee 100644
--- a/contrib/ffmpeg/libavformat/mpegts.c
+++ b/contrib/ffmpeg/libavformat/mpegts.c
@@ -75,47 +75,62 @@ typedef struct MpegTSFilter {
typedef struct MpegTSService {
int running:1;
- int sid;
- char *provider_name;
- char *name;
+ int sid; /**< MPEG Program Number of stream */
+ char *provider_name; /**< DVB Network name, "" if not DVB stream */
+ char *name; /**< DVB Service name, "MPEG Program [sid]" if not DVB stream*/
} MpegTSService;
struct MpegTSContext {
/* user data */
AVFormatContext *stream;
- int raw_packet_size; /* raw packet size, including FEC if present */
- int auto_guess; /* if true, all pids are analized to find streams */
+ /** raw packet size, including FEC if present */
+ int raw_packet_size;
+ /** if true, all pids are analyzed to find streams */
+ int auto_guess;
int set_service_ret;
- int mpeg2ts_raw; /* force raw MPEG2 transport stream output, if possible */
- int mpeg2ts_compute_pcr; /* compute exact PCR for each transport stream packet */
+ /** force raw MPEG2 transport stream output, if possible */
+ int mpeg2ts_raw;
+ /** compute exact PCR for each transport stream packet */
+ int mpeg2ts_compute_pcr;
- /* used to estimate the exact PCR */
- int64_t cur_pcr;
- int pcr_incr;
- int pcr_pid;
+ int64_t cur_pcr; /**< used to estimate the exact PCR */
+ int pcr_incr; /**< used to estimate the exact PCR */
+ int pcr_pid; /**< used to estimate the exact PCR */
/* data needed to handle file based ts */
- int stop_parse; /* stop parsing loop */
- AVPacket *pkt; /* packet containing av data */
+ /** stop parsing loop */
+ int stop_parse;
+ /** packet containing Audio/Video data */
+ AVPacket *pkt;
/******************************************/
/* private mpegts data */
/* scan context */
MpegTSFilter *sdt_filter;
+ /** number of PMTs in the last PAT seen */
int nb_services;
+ /** list of PMTs in the last PAT seen */
MpegTSService **services;
/* set service context (XXX: allocated it ?) */
SetServiceCallback *set_service_cb;
void *set_service_opaque;
+ /** filter for the PAT */
MpegTSFilter *pat_filter;
+ /** filter for the PMT for the MPEG program number specified by req_sid */
MpegTSFilter *pmt_filter;
+ /** MPEG program number of stream we want to decode */
int req_sid;
+ /** filters for various streams specified by PMT + for the PAT and PMT */
MpegTSFilter *pids[NB_PID_MAX];
};
+/**
+ * Assembles PES packets out of TS packets, and then calls the "section_cb"
+ * function when they are complete.
+ */
static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
{
@@ -162,7 +177,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int
MpegTSSectionFilter *sec;
#ifdef DEBUG_SI
- printf("Filter: pid=0x%x\n", pid);
+ av_log(ts->stream, AV_LOG_DEBUG, "Filter: pid=0x%x\n", pid);
#endif
if (pid >= NB_PID_MAX || ts->pids[pid])
return NULL;
@@ -357,7 +372,8 @@ static MpegTSService *new_service(MpegTSContext *ts, int sid,
MpegTSService *service;
#ifdef DEBUG_SI
- printf("new_service: sid=0x%04x provider='%s' name='%s'\n",
+ av_log(ts->stream, AV_LOG_DEBUG, "new_service: "
+ "sid=0x%04x provider='%s' name='%s'\n",
sid, provider_name, name);
#endif
@@ -384,15 +400,16 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
char language[4];
#ifdef DEBUG_SI
- printf("PMT:\n");
- av_hex_dump(stdout, (uint8_t *)section, section_len);
+ av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len);
+ av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len);
#endif
p_end = section + section_len - 4;
p = section;
if (parse_section_header(h, &p, p_end) < 0)
return;
#ifdef DEBUG_SI
- printf("sid=0x%x sec_num=%d/%d\n", h->id, h->sec_num, h->last_sec_num);
+ av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n",
+ h->id, h->sec_num, h->last_sec_num);
#endif
if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) )
return;
@@ -402,7 +419,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
return;
ts->pcr_pid = pcr_pid;
#ifdef DEBUG_SI
- printf("pcr_pid=0x%x\n", pcr_pid);
+ av_log(ts->stream, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid);
#endif
program_info_length = get16(&p, p_end) & 0xfff;
if (program_info_length < 0)
@@ -443,7 +460,8 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
if (desc_end > desc_list_end)
break;
#ifdef DEBUG_SI
- printf("tag: 0x%02x len=%d\n", desc_tag, desc_len);
+ av_log(ts->stream, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
+ desc_tag, desc_len);
#endif
switch(desc_tag) {
case DVB_SUBT_DESCID:
@@ -473,7 +491,8 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
p = desc_list_end;
#ifdef DEBUG_SI
- printf("stream_type=%d pid=0x%x\n", stream_type, pid);
+ av_log(ts->stream, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n",
+ stream_type, pid);
#endif
/* now create ffmpeg stream */
@@ -484,6 +503,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
case STREAM_TYPE_VIDEO_MPEG2:
case STREAM_TYPE_VIDEO_MPEG4:
case STREAM_TYPE_VIDEO_H264:
+ case STREAM_TYPE_VIDEO_VC1:
case STREAM_TYPE_AUDIO_AAC:
case STREAM_TYPE_AUDIO_AC3:
case STREAM_TYPE_AUDIO_DTS:
@@ -524,8 +544,8 @@ static void pat_cb(void *opaque, const uint8_t *section, int section_len)
int sid, pmt_pid;
#ifdef DEBUG_SI
- printf("PAT:\n");
- av_hex_dump(stdout, (uint8_t *)section, section_len);
+ av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n");
+ av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len);
#endif
p_end = section + section_len - 4;
p = section;
@@ -542,7 +562,7 @@ static void pat_cb(void *opaque, const uint8_t *section, int section_len)
if (pmt_pid < 0)
break;
#ifdef DEBUG_SI
- printf("sid=0x%x pid=0x%x\n", sid, pmt_pid);
+ av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
#endif
if (sid == 0x0000) {
/* NIT info */
@@ -573,8 +593,8 @@ static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len)
char buf[256];
#ifdef DEBUG_SI
- printf("PAT:\n");
- av_hex_dump(stdout, (uint8_t *)section, section_len);
+ av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n");
+ av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len);
#endif
p_end = section + section_len - 4;
p = section;
@@ -591,7 +611,7 @@ static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len)
if (pmt_pid < 0)
break;
#ifdef DEBUG_SI
- printf("sid=0x%x pid=0x%x\n", sid, pmt_pid);
+ av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
#endif
if (sid == 0x0000) {
/* NIT info */
@@ -634,8 +654,8 @@ static void sdt_cb(void *opaque, const uint8_t *section, int section_len)
char *name, *provider_name;
#ifdef DEBUG_SI
- printf("SDT:\n");
- av_hex_dump(stdout, (uint8_t *)section, section_len);
+ av_log(ts->stream, AV_LOG_DEBUG, "SDT:\n");
+ av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len);
#endif
p_end = section + section_len - 4;
@@ -672,7 +692,8 @@ static void sdt_cb(void *opaque, const uint8_t *section, int section_len)
if (desc_end > desc_list_end)
break;
#ifdef DEBUG_SI
- printf("tag: 0x%02x len=%d\n", desc_tag, desc_len);
+ av_log(ts->stream, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
+ desc_tag, desc_len);
#endif
switch(desc_tag) {
case 0x48:
@@ -785,7 +806,7 @@ static void mpegts_push_data(void *opaque,
/* we got all the PES or section header. We can now
decide */
#if 0
- av_hex_dump(pes->header, pes->data_index);
+ av_hex_dump_log(pes->stream, AV_LOG_DEBUG, pes->header, pes->data_index);
#endif
if (pes->header[0] == 0x00 && pes->header[1] == 0x00 &&
pes->header[2] == 0x01) {
@@ -793,7 +814,7 @@ static void mpegts_push_data(void *opaque,
code = pes->header[3] | 0x100;
if (!((code >= 0x1c0 && code <= 0x1df) ||
(code >= 0x1e0 && code <= 0x1ef) ||
- (code == 0x1bd)))
+ (code == 0x1bd) || (code == 0x1fd)))
goto skip;
if (!pes->st) {
/* allocate stream */
@@ -901,6 +922,10 @@ static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code)
codec_type = CODEC_TYPE_VIDEO;
codec_id = CODEC_ID_H264;
break;
+ case STREAM_TYPE_VIDEO_VC1:
+ codec_type = CODEC_TYPE_VIDEO;
+ codec_id = CODEC_ID_VC1;
+ break;
case STREAM_TYPE_AUDIO_AAC:
codec_type = CODEC_TYPE_AUDIO;
codec_id = CODEC_ID_AAC;
@@ -1234,7 +1259,7 @@ goto_auto_guess:
service = ts->services[i];
sid = service->sid;
#ifdef DEBUG_SI
- printf("tuning to '%s'\n", service->name);
+ av_log(ts->stream, AV_LOG_DEBUG, "tuning to '%s'\n", service->name);
#endif
/* now find the info for the first service if we found any,
@@ -1258,7 +1283,7 @@ goto_auto_guess:
}
#ifdef DEBUG_SI
- printf("tuning done\n");
+ av_log(ts->stream, AV_LOG_DEBUG, "tuning done\n");
#endif
}
s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -1309,7 +1334,7 @@ goto_auto_guess:
st->codec->bit_rate = s->bit_rate;
st->start_time = ts->cur_pcr;
#if 0
- printf("start=%0.3f pcr=%0.3f incr=%d\n",
+ av_log(ts->stream, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n",
st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
#endif
}
@@ -1332,7 +1357,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s,
uint8_t pcr_buf[12];
if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
pkt->pos= url_ftell(&s->pb);
ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size);
if (ret < 0) {
diff --git a/contrib/ffmpeg/libavformat/mpegts.h b/contrib/ffmpeg/libavformat/mpegts.h
index b3eb3cda7..771becbd4 100644
--- a/contrib/ffmpeg/libavformat/mpegts.h
+++ b/contrib/ffmpeg/libavformat/mpegts.h
@@ -46,13 +46,13 @@
#define STREAM_TYPE_AUDIO_AAC 0x0f
#define STREAM_TYPE_VIDEO_MPEG4 0x10
#define STREAM_TYPE_VIDEO_H264 0x1b
+#define STREAM_TYPE_VIDEO_VC1 0xea
#define STREAM_TYPE_AUDIO_AC3 0x81
#define STREAM_TYPE_AUDIO_DTS 0x8a
#define STREAM_TYPE_SUBTITLE_DVB 0x100
-unsigned int mpegts_crc32(const uint8_t *data, int len);
extern AVOutputFormat mpegts_muxer;
typedef struct MpegTSContext MpegTSContext;
diff --git a/contrib/ffmpeg/libavformat/mpegtsenc.c b/contrib/ffmpeg/libavformat/mpegtsenc.c
index 39868bea4..c521b68b8 100644
--- a/contrib/ffmpeg/libavformat/mpegtsenc.c
+++ b/contrib/ffmpeg/libavformat/mpegtsenc.c
@@ -143,6 +143,7 @@ typedef struct MpegTSWriteStream {
int cc;
int payload_index;
int64_t payload_pts;
+ int64_t payload_dts;
uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE];
} MpegTSWriteStream;
@@ -396,6 +397,7 @@ static int mpegts_write_header(AVFormatContext *s)
ts_st->service = service;
ts_st->pid = DEFAULT_START_PID + i;
ts_st->payload_pts = AV_NOPTS_VALUE;
+ ts_st->payload_dts = AV_NOPTS_VALUE;
/* update PCR pid by using the first video stream */
if (st->codec->codec_type == CODEC_TYPE_VIDEO &&
service->pcr_pid == 0x1fff)
@@ -460,15 +462,29 @@ static void retransmit_si_info(AVFormatContext *s)
}
}
+static void write_pts(uint8_t *q, int fourbits, int64_t pts)
+{
+ int val;
+
+ val = fourbits << 4 | (((pts >> 30) & 0x07) << 1) | 1;
+ *q++ = val;
+ val = (((pts >> 15) & 0x7fff) << 1) | 1;
+ *q++ = val >> 8;
+ *q++ = val;
+ val = (((pts) & 0x7fff) << 1) | 1;
+ *q++ = val >> 8;
+ *q++ = val;
+}
+
/* NOTE: pes_data contains all the PES packet */
static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
const uint8_t *payload, int payload_size,
- int64_t pts)
+ int64_t pts, int64_t dts)
{
MpegTSWriteStream *ts_st = st->priv_data;
uint8_t buf[TS_PACKET_SIZE];
uint8_t *q;
- int val, is_start, len, header_len, write_pcr, private_code;
+ int val, is_start, len, header_len, write_pcr, private_code, flags;
int afc_len, stuffing_len;
int64_t pcr = -1; /* avoid warning */
@@ -527,13 +543,19 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
private_code = 0x20;
}
}
- if (pts != AV_NOPTS_VALUE)
- header_len = 8;
- else
- header_len = 3;
+ header_len = 0;
+ flags = 0;
+ if (pts != AV_NOPTS_VALUE) {
+ header_len += 5;
+ flags |= 0x80;
+ }
+ if (dts != AV_NOPTS_VALUE) {
+ header_len += 5;
+ flags |= 0x40;
+ }
+ len = payload_size + header_len + 3;
if (private_code != 0)
- header_len++;
- len = payload_size + header_len;
+ len++;
*q++ = len >> 8;
*q++ = len;
val = 0x80;
@@ -541,21 +563,15 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
if (st->codec->codec_type == CODEC_TYPE_SUBTITLE)
val |= 0x04;
*q++ = val;
+ *q++ = flags;
+ *q++ = header_len;
if (pts != AV_NOPTS_VALUE) {
- *q++ = 0x80; /* PTS only */
- *q++ = 0x05; /* header len */
- val = (0x02 << 4) |
- (((pts >> 30) & 0x07) << 1) | 1;
- *q++ = val;
- val = (((pts >> 15) & 0x7fff) << 1) | 1;
- *q++ = val >> 8;
- *q++ = val;
- val = (((pts) & 0x7fff) << 1) | 1;
- *q++ = val >> 8;
- *q++ = val;
- } else {
- *q++ = 0x00;
- *q++ = 0x00;
+ write_pts(q, flags >> 6, pts);
+ q += 5;
+ }
+ if (dts != AV_NOPTS_VALUE) {
+ write_pts(q, 1, dts);
+ q += 5;
}
if (private_code != 0)
*q++ = private_code;
@@ -607,7 +623,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
/* for subtitle, a single PES packet must be generated */
- mpegts_write_pes(s, st, buf, size, pkt->pts);
+ mpegts_write_pes(s, st, buf, size, pkt->pts, AV_NOPTS_VALUE);
return 0;
}
@@ -622,10 +638,13 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
ts_st->payload_index += len;
if (ts_st->payload_pts == AV_NOPTS_VALUE)
ts_st->payload_pts = pkt->pts;
+ if (ts_st->payload_dts == AV_NOPTS_VALUE)
+ ts_st->payload_dts = pkt->dts;
if (ts_st->payload_index >= max_payload_size) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
- ts_st->payload_pts);
+ ts_st->payload_pts, ts_st->payload_dts);
ts_st->payload_pts = AV_NOPTS_VALUE;
+ ts_st->payload_dts = AV_NOPTS_VALUE;
ts_st->payload_index = 0;
}
}
@@ -646,7 +665,7 @@ static int mpegts_write_end(AVFormatContext *s)
ts_st = st->priv_data;
if (ts_st->payload_index > 0) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
- ts_st->payload_pts);
+ ts_st->payload_pts, ts_st->payload_dts);
}
}
put_flush_packet(&s->pb);
diff --git a/contrib/ffmpeg/libavformat/mxf.c b/contrib/ffmpeg/libavformat/mxf.c
index b20679943..677e023f0 100644
--- a/contrib/ffmpeg/libavformat/mxf.c
+++ b/contrib/ffmpeg/libavformat/mxf.c
@@ -46,10 +46,12 @@
//#define DEBUG
#include "avformat.h"
+#include "aes.h"
typedef uint8_t UID[16];
enum MXFMetadataSetType {
+ AnyType,
MaterialPackage,
SourcePackage,
SourceClip,
@@ -59,8 +61,16 @@ enum MXFMetadataSetType {
Descriptor,
Track,
EssenceContainerData,
+ CryptoContext,
};
+typedef struct MXFCryptoContext {
+ UID uid;
+ enum MXFMetadataSetType type;
+ UID context_uid;
+ UID source_container_ul;
+} MXFCryptoContext;
+
typedef struct MXFStructuralComponent {
UID uid;
enum MXFMetadataSetType type;
@@ -132,15 +142,11 @@ typedef struct {
typedef struct MXFContext {
UID *packages_refs;
int packages_count;
- UID *essence_container_data_sets_refs;
- int essence_container_data_sets_count;
- UID *essence_containers_uls; /* Universal Labels SMPTE RP224 */
- int essence_containers_uls_count;
- UID operational_pattern_ul;
- UID content_storage_uid;
MXFMetadataSet **metadata_sets;
int metadata_sets_count;
+ const uint8_t *sync_key;
AVFormatContext *fc;
+ struct AVAES *aesc;
} MXFContext;
typedef struct KLVPacket {
@@ -167,33 +173,34 @@ typedef struct MXFDataDefinitionUL {
typedef struct MXFMetadataReadTableEntry {
const UID key;
- int (*read)(MXFContext *mxf, KLVPacket *klv);
+ int (*read)();
+ int ctx_size;
+ enum MXFMetadataSetType type;
} MXFMetadataReadTableEntry;
/* partial keys to match */
static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
+/* complete keys to match */
+static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
+static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
-#define PRINT_KEY(s, x) dprintf("%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \
+#define PRINT_KEY(pc, s, x) dprintf(pc, "%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \
(x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15])
static int64_t klv_decode_ber_length(ByteIOContext *pb)
{
- int64_t size = 0;
- uint8_t length = get_byte(pb);
- int type = length >> 7;
-
- if (type) { /* long form */
- int bytes_num = length & 0x7f;
+ uint64_t size = get_byte(pb);
+ if (size & 0x80) { /* long form */
+ int bytes_num = size & 0x7f;
/* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
if (bytes_num > 8)
return -1;
+ size = 0;
while (bytes_num--)
size = size << 8 | get_byte(pb);
- } else {
- size = length & 0x7f;
}
return size;
}
@@ -212,7 +219,7 @@ static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
for (i = 0; i < s->nb_streams; i++) {
MXFTrack *track = s->streams[i]->priv_data;
- /* SMPTE 379M 7.3 */
+ /* SMPTE 379M 7.3 */
if (!memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
return i;
}
@@ -249,8 +256,66 @@ static int mxf_get_d10_aes3_packet(ByteIOContext *pb, AVStream *st, AVPacket *pk
return 0;
}
+static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
+{
+ static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
+ MXFContext *mxf = s->priv_data;
+ ByteIOContext *pb = &s->pb;
+ offset_t end = url_ftell(pb) + klv->length;
+ uint64_t size;
+ uint64_t orig_size;
+ uint64_t plaintext_size;
+ uint8_t ivec[16];
+ uint8_t tmpbuf[16];
+ int index;
+
+ if (!mxf->aesc && s->key && s->keylen == 16) {
+ mxf->aesc = av_malloc(av_aes_size);
+ av_aes_init(mxf->aesc, s->key, 128, 1);
+ }
+ // crypto context
+ url_fskip(pb, klv_decode_ber_length(pb));
+ // plaintext offset
+ klv_decode_ber_length(pb);
+ plaintext_size = get_be64(pb);
+ // source klv key
+ klv_decode_ber_length(pb);
+ get_buffer(pb, klv->key, 16);
+ if (!IS_KLV_KEY(klv, mxf_essence_element_key)) goto err_out;
+ index = mxf_get_stream_index(s, klv);
+ if (index < 0) goto err_out;
+ // source size
+ klv_decode_ber_length(pb);
+ orig_size = get_be64(pb);
+ if (orig_size < plaintext_size) goto err_out;
+ // enc. code
+ size = klv_decode_ber_length(pb);
+ if (size < 32 || size - 32 < orig_size) goto err_out;
+ get_buffer(pb, ivec, 16);
+ get_buffer(pb, tmpbuf, 16);
+ if (mxf->aesc)
+ av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
+ if (memcmp(tmpbuf, checkv, 16))
+ av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n");
+ size -= 32;
+ av_get_packet(pb, pkt, size);
+ size -= plaintext_size;
+ if (mxf->aesc)
+ av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size],
+ &pkt->data[plaintext_size], size >> 4, ivec, 1);
+ pkt->size = orig_size;
+ pkt->stream_index = index;
+ url_fskip(pb, end - url_ftell(pb));
+ return 0;
+
+err_out:
+ url_fskip(pb, end - url_ftell(pb));
+ return -1;
+}
+
static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ MXFContext *mxf = s->priv_data;
KLVPacket klv;
while (!url_feof(&s->pb)) {
@@ -259,8 +324,17 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
return -1;
}
#ifdef DEBUG
- PRINT_KEY("read packet", klv.key);
+ PRINT_KEY(s, "read packet", klv.key);
#endif
+ if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
+ int res = mxf_decrypt_triplet(s, pkt, &klv);
+ mxf->sync_key = mxf_encrypted_triplet_key;
+ if (res < 0) {
+ av_log(s, AV_LOG_ERROR, "invalid encoded triplet\n");
+ return -1;
+ }
+ return 0;
+ }
if (IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
int index = mxf_get_stream_index(s, &klv);
if (index < 0) {
@@ -292,291 +366,132 @@ static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
return 0;
}
-static int mxf_read_metadata_preface(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_cryptographic_context(MXFCryptoContext *cryptocontext, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* SMPTE 336M Table 8 KLV specified length, 0x53 */
-
- switch (tag) {
- case 0x3B03:
- get_buffer(pb, mxf->content_storage_uid, 16);
- break;
- case 0x3B09:
- get_buffer(pb, mxf->operational_pattern_ul, 16);
- break;
- case 0x3B0A:
- mxf->essence_containers_uls_count = get_be32(pb);
- if (mxf->essence_containers_uls_count >= UINT_MAX / sizeof(UID))
- return -1;
- mxf->essence_containers_uls = av_malloc(mxf->essence_containers_uls_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)mxf->essence_containers_uls, mxf->essence_containers_uls_count * sizeof(UID));
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0xFFFE:
+ get_buffer(pb, cryptocontext->context_uid, 16);
+ break;
+ case 0xFFFD:
+ get_buffer(pb, cryptocontext->source_container_ul, 16);
+ break;
}
return 0;
}
-static int mxf_read_metadata_content_storage(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_content_storage(MXFContext *mxf, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* SMPTE 336M Table 8 KLV specified length, 0x53 */
-
- dprintf("tag 0x%04X, size %d\n", tag, size);
- switch (tag) {
- case 0x1901:
- mxf->packages_count = get_be32(pb);
- if (mxf->packages_count >= UINT_MAX / sizeof(UID))
- return -1;
- mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
- break;
- case 0x1902:
- mxf->essence_container_data_sets_count = get_be32(pb);
- if (mxf->essence_container_data_sets_count >= UINT_MAX / sizeof(UID))
- return -1;
- mxf->essence_container_data_sets_refs = av_malloc(mxf->essence_container_data_sets_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)mxf->essence_container_data_sets_refs, mxf->essence_container_data_sets_count * sizeof(UID));
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch (tag) {
+ case 0x1901:
+ mxf->packages_count = get_be32(pb);
+ if (mxf->packages_count >= UINT_MAX / sizeof(UID))
+ return -1;
+ mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID));
+ url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
+ get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID));
+ break;
}
return 0;
}
-static int mxf_read_metadata_source_clip(MXFContext *mxf, KLVPacket *klv)
-{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFStructuralComponent *source_clip = av_mallocz(sizeof(*source_clip));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* SMPTE 336M Table 8 KLV specified length, 0x53 */
-
- bytes_read += size + 4;
- dprintf("tag 0x%04X, size %d\n", tag, size);
- if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */
- av_log(mxf->fc, AV_LOG_ERROR, "local tag 0x%04X with 0 size\n", tag);
- continue;
- }
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, source_clip->uid, 16);
- break;
- case 0x0202:
- source_clip->duration = get_be64(pb);
- break;
- case 0x1201:
- source_clip->start_position = get_be64(pb);
- break;
- case 0x1101:
- /* UMID, only get last 16 bytes */
- url_fskip(pb, 16);
- get_buffer(pb, source_clip->source_package_uid, 16);
- break;
- case 0x1102:
- source_clip->source_track_id = get_be32(pb);
- break;
- default:
- url_fskip(pb, size);
- }
- }
- source_clip->type = SourceClip;
- return mxf_add_metadata_set(mxf, source_clip);
-}
-
-static int mxf_read_metadata_material_package(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFPackage *package = av_mallocz(sizeof(*package));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
-
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, package->uid, 16);
- break;
- case 0x4403:
- package->tracks_count = get_be32(pb);
- if (package->tracks_count >= UINT_MAX / sizeof(UID))
- return -1;
- package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0x0202:
+ source_clip->duration = get_be64(pb);
+ break;
+ case 0x1201:
+ source_clip->start_position = get_be64(pb);
+ break;
+ case 0x1101:
+ /* UMID, only get last 16 bytes */
+ url_fskip(pb, 16);
+ get_buffer(pb, source_clip->source_package_uid, 16);
+ break;
+ case 0x1102:
+ source_clip->source_track_id = get_be32(pb);
+ break;
}
- package->type = MaterialPackage;
- return mxf_add_metadata_set(mxf, package);
+ return 0;
}
-static int mxf_read_metadata_track(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_material_package(MXFPackage *package, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFTrack *track = av_mallocz(sizeof(*track));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
-
- dprintf("tag 0x%04X, size %d\n", tag, size);
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, track->uid, 16);
- break;
- case 0x4801:
- track->track_id = get_be32(pb);
- break;
- case 0x4804:
- get_buffer(pb, track->track_number, 4);
- break;
- case 0x4B01:
- track->edit_rate.den = get_be32(pb);
- track->edit_rate.num = get_be32(pb);
- break;
- case 0x4803:
- get_buffer(pb, track->sequence_ref, 16);
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0x4403:
+ package->tracks_count = get_be32(pb);
+ if (package->tracks_count >= UINT_MAX / sizeof(UID))
+ return -1;
+ package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
+ url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
+ get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ break;
}
- track->type = Track;
- return mxf_add_metadata_set(mxf, track);
+ return 0;
}
-static int mxf_read_metadata_sequence(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_track(MXFTrack *track, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFSequence *sequence = av_mallocz(sizeof(*sequence));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
-
- dprintf("tag 0x%04X, size %d\n", tag, size);
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, sequence->uid, 16);
- break;
- case 0x0202:
- sequence->duration = get_be64(pb);
- break;
- case 0x0201:
- get_buffer(pb, sequence->data_definition_ul, 16);
- break;
- case 0x1001:
- sequence->structural_components_count = get_be32(pb);
- if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
- return -1;
- sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0x4801:
+ track->track_id = get_be32(pb);
+ break;
+ case 0x4804:
+ get_buffer(pb, track->track_number, 4);
+ break;
+ case 0x4B01:
+ track->edit_rate.den = get_be32(pb);
+ track->edit_rate.num = get_be32(pb);
+ break;
+ case 0x4803:
+ get_buffer(pb, track->sequence_ref, 16);
+ break;
}
- sequence->type = Sequence;
- return mxf_add_metadata_set(mxf, sequence);
+ return 0;
}
-static int mxf_read_metadata_source_package(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFPackage *package = av_mallocz(sizeof(*package));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
-
- dprintf("tag 0x%04X, size %d\n", tag, size);
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, package->uid, 16);
- break;
- case 0x4403:
- package->tracks_count = get_be32(pb);
- if (package->tracks_count >= UINT_MAX / sizeof(UID))
- return -1;
- package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
- break;
- case 0x4401:
- /* UMID, only get last 16 bytes */
- url_fskip(pb, 16);
- get_buffer(pb, package->package_uid, 16);
- break;
- case 0x4701:
- get_buffer(pb, package->descriptor_ref, 16);
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0x0202:
+ sequence->duration = get_be64(pb);
+ break;
+ case 0x0201:
+ get_buffer(pb, sequence->data_definition_ul, 16);
+ break;
+ case 0x1001:
+ sequence->structural_components_count = get_be32(pb);
+ if (sequence->structural_components_count >= UINT_MAX / sizeof(UID))
+ return -1;
+ sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID));
+ url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
+ get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID));
+ break;
}
- package->type = SourcePackage;
- return mxf_add_metadata_set(mxf, package);
+ return 0;
}
-static int mxf_read_metadata_multiple_descriptor(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_source_package(MXFPackage *package, ByteIOContext *pb, int tag)
{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFDescriptor *descriptor = av_mallocz(sizeof(*descriptor));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
-
- dprintf("tag 0x%04X, size %d\n", tag, size);
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, descriptor->uid, 16);
- break;
- case 0x3F01:
- descriptor->sub_descriptors_count = get_be32(pb);
- if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
- return -1;
- descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
- url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
- get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0x4403:
+ package->tracks_count = get_be32(pb);
+ if (package->tracks_count >= UINT_MAX / sizeof(UID))
+ return -1;
+ package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
+ url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
+ get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
+ break;
+ case 0x4401:
+ /* UMID, only get last 16 bytes */
+ url_fskip(pb, 16);
+ get_buffer(pb, package->package_uid, 16);
+ break;
+ case 0x4701:
+ get_buffer(pb, package->descriptor_ref, 16);
+ break;
}
- descriptor->type = MultipleDescriptor;
- return mxf_add_metadata_set(mxf, descriptor);
+ return 0;
}
static void mxf_read_metadata_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor)
@@ -585,7 +500,7 @@ static void mxf_read_metadata_pixel_layout(ByteIOContext *pb, MXFDescriptor *des
do {
code = get_byte(pb);
- dprintf("pixel layout: code 0x%x\n", code);
+ dprintf(NULL, "pixel layout: code 0x%x\n", code);
switch (code) {
case 0x52: /* R */
descriptor->bits_per_sample += get_byte(pb);
@@ -602,68 +517,59 @@ static void mxf_read_metadata_pixel_layout(ByteIOContext *pb, MXFDescriptor *des
} while (code != 0); /* SMPTE 377M E.2.46 */
}
-static int mxf_read_metadata_generic_descriptor(MXFContext *mxf, KLVPacket *klv)
+static int mxf_read_metadata_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size)
{
- ByteIOContext *pb = &mxf->fc->pb;
- MXFDescriptor *descriptor = av_mallocz(sizeof(*descriptor));
- int bytes_read = 0;
-
- while (bytes_read < klv->length) {
- int tag = get_be16(pb);
- int size = get_be16(pb); /* KLV specified by 0x53 */
-
- dprintf("tag 0x%04X, size %d\n", tag, size);
- switch (tag) {
- case 0x3C0A:
- get_buffer(pb, descriptor->uid, 16);
- break;
- case 0x3004:
- get_buffer(pb, descriptor->essence_container_ul, 16);
- break;
- case 0x3006:
- descriptor->linked_track_id = get_be32(pb);
- break;
- case 0x3201: /* PictureEssenceCoding */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
- break;
- case 0x3203:
- descriptor->width = get_be32(pb);
- break;
- case 0x3202:
- descriptor->height = get_be32(pb);
- break;
- case 0x320E:
- descriptor->aspect_ratio.num = get_be32(pb);
- descriptor->aspect_ratio.den = get_be32(pb);
- break;
- case 0x3D03:
- descriptor->sample_rate.num = get_be32(pb);
- descriptor->sample_rate.den = get_be32(pb);
- break;
- case 0x3D06: /* SoundEssenceCompression */
- get_buffer(pb, descriptor->essence_codec_ul, 16);
- break;
- case 0x3D07:
- descriptor->channels = get_be32(pb);
- break;
- case 0x3D01:
- descriptor->bits_per_sample = get_be32(pb);
- break;
- case 0x3401:
- mxf_read_metadata_pixel_layout(pb, descriptor);
- break;
- case 0x8201: /* Private tag used by SONY C0023S01.mxf */
- descriptor->extradata = av_malloc(size);
- descriptor->extradata_size = size;
- get_buffer(pb, descriptor->extradata, size);
- break;
- default:
- url_fskip(pb, size);
- }
- bytes_read += size + 4;
+ switch(tag) {
+ case 0x3F01:
+ descriptor->sub_descriptors_count = get_be32(pb);
+ if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID))
+ return -1;
+ descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID));
+ url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */
+ get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID));
+ break;
+ case 0x3004:
+ get_buffer(pb, descriptor->essence_container_ul, 16);
+ break;
+ case 0x3006:
+ descriptor->linked_track_id = get_be32(pb);
+ break;
+ case 0x3201: /* PictureEssenceCoding */
+ get_buffer(pb, descriptor->essence_codec_ul, 16);
+ break;
+ case 0x3203:
+ descriptor->width = get_be32(pb);
+ break;
+ case 0x3202:
+ descriptor->height = get_be32(pb);
+ break;
+ case 0x320E:
+ descriptor->aspect_ratio.num = get_be32(pb);
+ descriptor->aspect_ratio.den = get_be32(pb);
+ break;
+ case 0x3D03:
+ descriptor->sample_rate.num = get_be32(pb);
+ descriptor->sample_rate.den = get_be32(pb);
+ break;
+ case 0x3D06: /* SoundEssenceCompression */
+ get_buffer(pb, descriptor->essence_codec_ul, 16);
+ break;
+ case 0x3D07:
+ descriptor->channels = get_be32(pb);
+ break;
+ case 0x3D01:
+ descriptor->bits_per_sample = get_be32(pb);
+ break;
+ case 0x3401:
+ mxf_read_metadata_pixel_layout(pb, descriptor);
+ break;
+ case 0x8201: /* Private tag used by SONY C0023S01.mxf */
+ descriptor->extradata = av_malloc(size);
+ descriptor->extradata_size = size;
+ get_buffer(pb, descriptor->extradata, size);
+ break;
}
- descriptor->type = Descriptor;
- return mxf_add_metadata_set(mxf, descriptor);
+ return 0;
}
/* SMPTE RP224 http://www.smpte-ra.org/mdd/index.html */
@@ -741,14 +647,15 @@ static enum CodecType mxf_get_codec_type(const MXFDataDefinitionUL *uls, UID *ui
return uls->type;
}
-static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref)
+static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum MXFMetadataSetType type)
{
int i;
if (!strong_ref)
return NULL;
for (i = 0; i < mxf->metadata_sets_count; i++) {
- if (!memcmp(*strong_ref, mxf->metadata_sets[i]->uid, 16)) {
+ if (!memcmp(*strong_ref, mxf->metadata_sets[i]->uid, 16) &&
+ (type == AnyType || mxf->metadata_sets[i]->type == type)) {
return mxf->metadata_sets[i];
}
}
@@ -761,17 +668,11 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
MXFPackage *temp_package = NULL;
int i, j, k;
- dprintf("metadata sets count %d\n", mxf->metadata_sets_count);
+ dprintf(mxf->fc, "metadata sets count %d\n", mxf->metadata_sets_count);
/* TODO: handle multiple material packages (OP3x) */
for (i = 0; i < mxf->packages_count; i++) {
- if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i]))) {
- av_log(mxf->fc, AV_LOG_ERROR, "could not resolve package strong ref\n");
- return -1;
- }
- if (temp_package->type == MaterialPackage) {
- material_package = temp_package;
- break;
- }
+ material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage);
+ if (material_package) break;
}
if (!material_package) {
av_log(mxf->fc, AV_LOG_ERROR, "no material package found\n");
@@ -785,16 +686,17 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
MXFTrack *temp_track = NULL;
MXFDescriptor *descriptor = NULL;
MXFStructuralComponent *component = NULL;
+ UID *essence_container_ul = NULL;
const MXFCodecUL *codec_ul = NULL;
const MXFCodecUL *container_ul = NULL;
AVStream *st;
- if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i]))) {
+ if (!(material_track = mxf_resolve_strong_ref(mxf, &material_package->tracks_refs[i], Track))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track strong ref\n");
continue;
}
- if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref))) {
+ if (!(material_track->sequence = mxf_resolve_strong_ref(mxf, &material_track->sequence_ref, Sequence))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve material track sequence strong ref\n");
return -1;
}
@@ -802,15 +704,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
/* TODO: handle multiple source clips */
for (j = 0; j < material_track->sequence->structural_components_count; j++) {
/* TODO: handle timecode component */
- component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j]);
- if (!component || component->type != SourceClip)
+ component = mxf_resolve_strong_ref(mxf, &material_track->sequence->structural_components_refs[j], SourceClip);
+ if (!component)
continue;
for (k = 0; k < mxf->packages_count; k++) {
- if (!(temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[k]))) {
- av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
- return -1;
- }
+ temp_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[k], SourcePackage);
+ if (!temp_package)
+ continue;
if (!memcmp(temp_package->package_uid, component->source_package_uid, 16)) {
source_package = temp_package;
break;
@@ -821,7 +722,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
break;
}
for (k = 0; k < source_package->tracks_count; k++) {
- if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k]))) {
+ if (!(temp_track = mxf_resolve_strong_ref(mxf, &source_package->tracks_refs[k], Track))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track strong ref\n");
return -1;
}
@@ -846,21 +747,21 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->start_time = component->start_position;
av_set_pts_info(st, 64, material_track->edit_rate.num, material_track->edit_rate.den);
- if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref))) {
+ if (!(source_track->sequence = mxf_resolve_strong_ref(mxf, &source_track->sequence_ref, Sequence))) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve source track sequence strong ref\n");
return -1;
}
#ifdef DEBUG
- PRINT_KEY("data definition ul", source_track->sequence->data_definition_ul);
+ PRINT_KEY(mxf->fc, "data definition ul", source_track->sequence->data_definition_ul);
#endif
st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
- source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref);
+ source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref, AnyType);
if (source_package->descriptor) {
if (source_package->descriptor->type == MultipleDescriptor) {
for (j = 0; j < source_package->descriptor->sub_descriptors_count; j++) {
- MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor->sub_descriptors_refs[j]);
+ MXFDescriptor *sub_descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor->sub_descriptors_refs[j], Descriptor);
if (!sub_descriptor) {
av_log(mxf->fc, AV_LOG_ERROR, "could not resolve sub descriptor strong ref\n");
@@ -871,7 +772,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
break;
}
}
- } else
+ } else if (source_package->descriptor->type == Descriptor)
descriptor = source_package->descriptor;
}
if (!descriptor) {
@@ -879,9 +780,22 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
continue;
}
#ifdef DEBUG
- PRINT_KEY("essence codec ul", descriptor->essence_codec_ul);
- PRINT_KEY("essence container ul", descriptor->essence_container_ul);
+ PRINT_KEY(mxf->fc, "essence codec ul", descriptor->essence_codec_ul);
+ PRINT_KEY(mxf->fc, "essence container ul", descriptor->essence_container_ul);
#endif
+ essence_container_ul = &descriptor->essence_container_ul;
+ /* HACK: replacing the original key with mxf_encrypted_essence_container
+ * is not allowed according to s429-6, try to find correct information anyway */
+ if (IS_KLV_KEY(essence_container_ul, mxf_encrypted_essence_container)) {
+ av_log(mxf->fc, AV_LOG_INFO, "broken encrypted mxf file\n");
+ for (k = 0; k < mxf->metadata_sets_count; k++) {
+ MXFMetadataSet *metadata = mxf->metadata_sets[k];
+ if (metadata->type == CryptoContext) {
+ essence_container_ul = &((MXFCryptoContext *)metadata)->source_container_ul;
+ break;
+ }
+ }
+ }
/* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */
codec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->essence_codec_ul);
st->codec->codec_id = codec_ul->id;
@@ -890,7 +804,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->codec->extradata_size = descriptor->extradata_size;
}
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
- container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, &descriptor->essence_container_ul);
+ container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->width = descriptor->width;
@@ -898,7 +812,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->codec->bits_per_sample = descriptor->bits_per_sample; /* Uncompressed */
st->need_parsing = 2; /* only parse headers */
} else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
- container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, &descriptor->essence_container_ul);
+ container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
if (st->codec->codec_id == CODEC_ID_NONE)
st->codec->codec_id = container_ul->id;
st->codec->channels = descriptor->channels;
@@ -922,7 +836,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
}
if (container_ul && container_ul->wrapping == Clip) {
- dprintf("stream %d: clip wrapped essence\n", st->index);
+ dprintf(mxf->fc, "stream %d: clip wrapped essence\n", st->index);
st->need_parsing = 1;
}
}
@@ -930,22 +844,22 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2F,0x00 }, mxf_read_metadata_preface },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_metadata_content_storage },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 }, mxf_read_metadata_source_package },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 }, mxf_read_metadata_material_package },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0F,0x00 }, mxf_read_metadata_sequence },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 }, mxf_read_metadata_source_clip },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 }, mxf_read_metadata_multiple_descriptor },
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 }, mxf_read_metadata_generic_descriptor }, /* Generic Sound */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 }, mxf_read_metadata_generic_descriptor }, /* CDCI */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 }, mxf_read_metadata_generic_descriptor }, /* RGBA */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 }, mxf_read_metadata_generic_descriptor }, /* MPEG 2 Video */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 }, mxf_read_metadata_generic_descriptor }, /* Wave */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 }, mxf_read_metadata_generic_descriptor }, /* AES3 */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_metadata_track }, /* Static Track */
- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_metadata_track }, /* Generic Track */
- { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_metadata_content_storage, 0, AnyType },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 }, mxf_read_metadata_source_package, sizeof(MXFPackage), SourcePackage },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 }, mxf_read_metadata_material_package, sizeof(MXFPackage), MaterialPackage },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0F,0x00 }, mxf_read_metadata_sequence, sizeof(MXFSequence), Sequence },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 }, mxf_read_metadata_source_clip, sizeof(MXFStructuralComponent), SourceClip },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), MultipleDescriptor },
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Generic Sound */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* CDCI */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* RGBA */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* MPEG 2 Video */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Wave */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* AES3 */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_metadata_track, sizeof(MXFTrack), Track }, /* Static Track */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_metadata_track, sizeof(MXFTrack), Track }, /* Generic Track */
+ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 }, mxf_read_metadata_cryptographic_context, sizeof(MXFCryptoContext), CryptoContext },
+ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0, AnyType },
};
static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size)
@@ -961,11 +875,38 @@ static int mxf_read_sync(ByteIOContext *pb, const uint8_t *key, unsigned size)
return i == size;
}
+static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type)
+{
+ ByteIOContext *pb = &mxf->fc->pb;
+ MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;
+ uint64_t klv_end= url_ftell(pb) + klv->length;
+
+ while (url_ftell(pb) + 4 < klv_end) {
+ int tag = get_be16(pb);
+ int size = get_be16(pb); /* KLV specified by 0x53 */
+ uint64_t next= url_ftell(pb) + size;
+
+ if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */
+ av_log(mxf->fc, AV_LOG_ERROR, "local tag 0x%04X with 0 size\n", tag);
+ continue;
+ }
+ if(ctx_size && tag == 0x3C0A)
+ get_buffer(pb, ctx->uid, 16);
+ else
+ read_child(ctx, pb, tag, size);
+
+ url_fseek(pb, next, SEEK_SET);
+ }
+ if (ctx_size) ctx->type = type;
+ return ctx_size ? mxf_add_metadata_set(mxf, ctx) : 0;
+}
+
static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
MXFContext *mxf = s->priv_data;
KLVPacket klv;
+ mxf->sync_key = mxf_essence_element_key;
if (!mxf_read_sync(&s->pb, mxf_header_partition_pack_key, 14)) {
av_log(s, AV_LOG_ERROR, "could not find header partition pack key\n");
return -1;
@@ -973,31 +914,32 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fseek(&s->pb, -14, SEEK_CUR);
mxf->fc = s;
while (!url_feof(&s->pb)) {
- const MXFMetadataReadTableEntry *function;
+ const MXFMetadataReadTableEntry *metadata;
if (klv_read_packet(&klv, &s->pb) < 0) {
av_log(s, AV_LOG_ERROR, "error reading KLV packet\n");
return -1;
}
#ifdef DEBUG
- PRINT_KEY("read header", klv.key);
+ PRINT_KEY(s, "read header", klv.key);
#endif
- if (IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
+ if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
+ IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
/* FIXME avoid seek */
url_fseek(&s->pb, klv.offset, SEEK_SET);
break;
}
- for (function = mxf_metadata_read_table; function->read; function++) {
- if (IS_KLV_KEY(klv.key, function->key)) {
- if (function->read(mxf, &klv) < 0) {
+ for (metadata = mxf_metadata_read_table; metadata->read; metadata++) {
+ if (IS_KLV_KEY(klv.key, metadata->key)) {
+ if (mxf_read_local_tags(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type) < 0) {
av_log(s, AV_LOG_ERROR, "error reading header metadata\n");
return -1;
}
break;
}
}
- if (!function->read)
+ if (!metadata->read)
url_fskip(&s->pb, klv.length);
}
return mxf_parse_structural_metadata(mxf);
@@ -1009,8 +951,6 @@ static int mxf_read_close(AVFormatContext *s)
int i;
av_freep(&mxf->packages_refs);
- av_freep(&mxf->essence_container_data_sets_refs);
- av_freep(&mxf->essence_containers_uls);
for (i = 0; i < mxf->metadata_sets_count; i++) {
switch (mxf->metadata_sets[i]->type) {
case MultipleDescriptor:
@@ -1029,6 +969,7 @@ static int mxf_read_close(AVFormatContext *s)
av_freep(&mxf->metadata_sets[i]);
}
av_freep(&mxf->metadata_sets);
+ av_freep(&mxf->aesc);
return 0;
}
@@ -1052,6 +993,7 @@ static int mxf_probe(AVProbeData *p) {
/* XXX: use MXF Index */
static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
{
+ MXFContext *mxf = s->priv_data;
AVStream *st = s->streams[stream_index];
int64_t seconds;
@@ -1061,7 +1003,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
sample_time = 0;
seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den);
url_fseek(&s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET);
- if (!mxf_read_sync(&s->pb, mxf_essence_element_key, 12))
+ if (!mxf_read_sync(&s->pb, mxf->sync_key, 12))
return -1;
/* found KLV key */
diff --git a/contrib/ffmpeg/libavformat/barpainet.h b/contrib/ffmpeg/libavformat/network.h
index b50bf82b6..3aa8ba836 100644
--- a/contrib/ffmpeg/libavformat/barpainet.h
+++ b/contrib/ffmpeg/libavformat/network.h
@@ -1,5 +1,5 @@
/*
- * copyright (c) 2002 Francois Revol
+ * Copyright (c) 2007 The FFmpeg Project.
*
* This file is part of FFmpeg.
*
@@ -18,28 +18,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef BARPA_INET_H
-#define BARPA_INET_H
-
-#include "config.h"
-
-#ifdef CONFIG_BEOS_NETSERVER
-
-# include <socket.h>
-int inet_aton (const char * str, struct in_addr * add);
-# define PF_INET AF_INET
-# define SO_SNDBUF 0x40000001
-
-/* fake */
-struct ip_mreq {
- struct in_addr imr_multiaddr; /* IP multicast address of group */
- struct in_addr imr_interface; /* local IP address of interface */
-};
+#ifndef NETWORK_H
+#define NETWORK_H
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
#include <netdb.h>
-#else
-# include <arpa/inet.h>
+#if !defined(HAVE_INET_ATON)
+/* in os_support.c */
+int inet_aton (const char * str, struct in_addr * add);
#endif
-#endif /* BARPA_INET_H */
+#endif
diff --git a/contrib/ffmpeg/libavformat/nsvdec.c b/contrib/ffmpeg/libavformat/nsvdec.c
index 9a5fe97f8..2753edbd9 100644
--- a/contrib/ffmpeg/libavformat/nsvdec.c
+++ b/contrib/ffmpeg/libavformat/nsvdec.c
@@ -183,26 +183,26 @@ typedef struct {
//DVDemuxContext* dv_demux;
} NSVContext;
-static const CodecTag nsv_codec_video_tags[] = {
+static const AVCodecTag nsv_codec_video_tags[] = {
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', ' ') },
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
{ CODEC_ID_VP5, MKTAG('V', 'P', '5', ' ') },
{ CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
+ { CODEC_ID_VP6, MKTAG('V', 'P', '6', ' ') },
+ { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
+ { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
{ CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
/*
{ CODEC_ID_VP4, MKTAG('V', 'P', '4', ' ') },
{ CODEC_ID_VP4, MKTAG('V', 'P', '4', '0') },
- { CODEC_ID_VP6, MKTAG('V', 'P', '6', ' ') },
- { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
- { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
*/
{ CODEC_ID_XVID, MKTAG('X', 'V', 'I', 'D') }, /* cf sample xvid decoder from nsv_codec_sdk.zip */
{ CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', '3') },
{ 0, 0 },
};
-static const CodecTag nsv_codec_audio_tags[] = {
+static const AVCodecTag nsv_codec_audio_tags[] = {
{ CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
{ CODEC_ID_AAC, MKTAG('A', 'A', 'C', ' ') },
{ CODEC_ID_AAC, MKTAG('A', 'A', 'C', 'P') }, /* _CUTTED__MUXED_2 Heads - Out Of The City.nsv */
@@ -602,13 +602,15 @@ null_chunk_retry:
pkt = &nsv->ahead[NSV_ST_VIDEO];
av_get_packet(pb, pkt, vsize);
pkt->stream_index = st[NSV_ST_VIDEO]->index;//NSV_ST_VIDEO;
- pkt->dts = nst->frame_offset++;
+ pkt->dts = nst->frame_offset;
pkt->flags |= nsv->state == NSV_HAS_READ_NSVS ? PKT_FLAG_KEY : 0; /* keyframe only likely on a sync frame */
/*
for (i = 0; i < MIN(8, vsize); i++)
PRINT(("NSV video: [%d] = %02x\n", i, pkt->data[i]));
*/
}
+ ((NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++;
+
if (asize/*st[NSV_ST_AUDIO]*/) {
nst = st[NSV_ST_AUDIO]->priv_data;
pkt = &nsv->ahead[NSV_ST_AUDIO];
diff --git a/contrib/ffmpeg/libavformat/nut.c b/contrib/ffmpeg/libavformat/nut.c
index df64caf15..995149951 100644
--- a/contrib/ffmpeg/libavformat/nut.c
+++ b/contrib/ffmpeg/libavformat/nut.c
@@ -1443,7 +1443,7 @@ AVOutputFormat nut_muxer = {
sizeof(NUTContext),
#ifdef CONFIG_LIBVORBIS
CODEC_ID_VORBIS,
-#elif defined(CONFIG_MP3LAME)
+#elif defined(CONFIG_LIBMP3LAME)
CODEC_ID_MP3,
#else
CODEC_ID_MP2, /* AC3 needs liba52 decoder */
diff --git a/contrib/ffmpeg/libavformat/nutdec.c b/contrib/ffmpeg/libavformat/nutdec.c
index 7e0f8cd93..c0f331c27 100644
--- a/contrib/ffmpeg/libavformat/nutdec.c
+++ b/contrib/ffmpeg/libavformat/nutdec.c
@@ -29,18 +29,13 @@
static uint64_t get_v(ByteIOContext *bc){
uint64_t val = 0;
+ int tmp;
- for(;;)
- {
- int tmp = get_byte(bc);
-
- if (tmp&0x80)
- val= (val<<7) + tmp - 0x80;
- else{
- return (val<<7) + tmp;
- }
- }
- return -1;
+ do{
+ tmp = get_byte(bc);
+ val= (val<<7) + (tmp&127);
+ }while(tmp&128);
+ return val;
}
static int get_str(ByteIOContext *bc, char *string, unsigned int maxlen){
@@ -109,6 +104,8 @@ static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_ch
// start= url_ftell(bc) - 8;
size= get_v(bc);
+ if(size > 4096)
+ get_be32(bc); //FIXME check this
init_checksum(bc, calculate_checksum ? av_crc04C11DB7_update : NULL, 0);
@@ -740,13 +737,12 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
uint64_t tmp= nut->next_startcode;
nut->next_startcode=0;
- if (url_feof(bc))
- return -1;
-
if(tmp){
pos-=8;
}else{
frame_code = get_byte(bc);
+ if(url_feof(bc))
+ return -1;
if(frame_code == 'N'){
tmp= frame_code;
for(i=1; i<8; i++)
diff --git a/contrib/ffmpeg/libavformat/nuv.c b/contrib/ffmpeg/libavformat/nuv.c
index 3b96eb940..7e04222ee 100644
--- a/contrib/ffmpeg/libavformat/nuv.c
+++ b/contrib/ffmpeg/libavformat/nuv.c
@@ -154,7 +154,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
vst->codec->height = height;
vst->codec->bits_per_sample = 10;
vst->codec->sample_aspect_ratio = av_d2q(aspect, 10000);
- vst->r_frame_rate = av_d2q(1.0 / fps, 10000);
+ vst->r_frame_rate = av_d2q(fps, 60000);
av_set_pts_info(vst, 32, 1, 1000);
} else
ctx->v_id = -1;
@@ -190,7 +190,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
if (ret <= 0)
return ret ? ret : -1;
frametype = hdr[0];
- size = PKTSIZE(LE_32(&hdr[8]));
+ size = PKTSIZE(AV_RL32(&hdr[8]));
switch (frametype) {
case NUV_VIDEO:
case NUV_EXTRADATA:
@@ -203,7 +203,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
if (ret < 0)
return ret;
pkt->pos = url_ftell(pb);
- pkt->pts = LE_32(&hdr[4]);
+ pkt->pts = AV_RL32(&hdr[4]);
pkt->stream_index = ctx->v_id;
memcpy(pkt->data, hdr, HDRSIZE);
ret = get_buffer(pb, pkt->data + HDRSIZE, size);
@@ -215,7 +215,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
break;
}
ret = av_get_packet(pb, pkt, size);
- pkt->pts = LE_32(&hdr[4]);
+ pkt->pts = AV_RL32(&hdr[4]);
pkt->stream_index = ctx->a_id;
return ret;
case NUV_SEEKP:
diff --git a/contrib/ffmpeg/libavformat/ogg.c b/contrib/ffmpeg/libavformat/ogg.c
index 369fa4639..c98bb2273 100644
--- a/contrib/ffmpeg/libavformat/ogg.c
+++ b/contrib/ffmpeg/libavformat/ogg.c
@@ -155,8 +155,8 @@ static int ogg_write_trailer(AVFormatContext *avfcontext) {
AVOutputFormat ogg_muxer = {
"ogg",
- "Ogg Vorbis",
- "audio/x-vorbis",
+ "Ogg format",
+ "application/ogg",
"ogg",
sizeof(OggContext),
CODEC_ID_VORBIS,
diff --git a/contrib/ffmpeg/libavformat/ogg2.c b/contrib/ffmpeg/libavformat/ogg2.c
index 1e5d38620..8ca7b2d13 100644
--- a/contrib/ffmpeg/libavformat/ogg2.c
+++ b/contrib/ffmpeg/libavformat/ogg2.c
@@ -67,8 +67,8 @@ ogg_write_trailer (AVFormatContext * avfcontext)
AVOutputFormat ogg_muxer = {
"ogg",
- "Ogg Vorbis",
- "audio/x-vorbis",
+ "Ogg format",
+ "application/ogg",
"ogg",
sizeof (OggContext),
CODEC_ID_VORBIS,
@@ -90,6 +90,7 @@ ogg_save (AVFormatContext * s)
ost->pos = url_ftell (&s->pb);;
ost->curidx = ogg->curidx;
ost->next = ogg->state;
+ ost->nstreams = ogg->nstreams;
memcpy(ost->streams, ogg->streams, ogg->nstreams * sizeof(*ogg->streams));
for (i = 0; i < ogg->nstreams; i++){
@@ -123,8 +124,9 @@ ogg_restore (AVFormatContext * s, int discard)
url_fseek (bc, ost->pos, SEEK_SET);
ogg->curidx = ost->curidx;
- memcpy (ogg->streams, ost->streams,
- ogg->nstreams * sizeof (*ogg->streams));
+ ogg->nstreams = ost->nstreams;
+ memcpy(ogg->streams, ost->streams,
+ ost->nstreams * sizeof(*ogg->streams));
}
av_free (ost);
@@ -482,7 +484,8 @@ ogg_get_length (AVFormatContext * s)
url_fseek (&s->pb, end, SEEK_SET);
while (!ogg_read_page (s, &i)){
- if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0)
+ if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
+ ogg->streams[i].codec)
idx = i;
}
diff --git a/contrib/ffmpeg/libavformat/ogg2.h b/contrib/ffmpeg/libavformat/ogg2.h
index dd6f24aab..6b7c6b22e 100644
--- a/contrib/ffmpeg/libavformat/ogg2.h
+++ b/contrib/ffmpeg/libavformat/ogg2.h
@@ -57,6 +57,7 @@ typedef struct ogg_state {
uint64_t pos;
int curidx;
struct ogg_state *next;
+ int nstreams;
ogg_stream_t streams[1];
} ogg_state_t;
diff --git a/contrib/ffmpeg/libavformat/os_support.c b/contrib/ffmpeg/libavformat/os_support.c
index a66c867f0..7a4be8fa7 100644
--- a/contrib/ffmpeg/libavformat/os_support.c
+++ b/contrib/ffmpeg/libavformat/os_support.c
@@ -36,17 +36,25 @@
#endif
#include <time.h>
+#ifndef HAVE_SYS_POLL_H
+#if defined(__MINGW32__)
+#include <winsock2.h>
+#else
+#include <sys/select.h>
+#endif
+#endif
+
/**
* gets the current time in micro seconds.
*/
int64_t av_gettime(void)
{
#if defined(CONFIG_WINCE)
- return timeGetTime() * int64_t_C(1000);
+ return timeGetTime() * INT64_C(1000);
#elif defined(__MINGW32__)
struct timeb tb;
_ftime(&tb);
- return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
+ return ((int64_t)tb.time * INT64_C(1000) + (int64_t)tb.millitm) * INT64_C(1000);
#else
struct timeval tv;
gettimeofday(&tv,NULL);
@@ -70,7 +78,7 @@ struct tm *localtime_r(const time_t *t, struct tm *tp)
#if !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK)
#include <stdlib.h>
#include <strings.h>
-#include "barpainet.h"
+#include "network.h"
int inet_aton (const char * str, struct in_addr * add)
{
@@ -94,3 +102,66 @@ done:
return 1;
}
#endif /* !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK) */
+
+#ifdef CONFIG_FFSERVER
+#ifndef HAVE_SYS_POLL_H
+int poll(struct pollfd *fds, nfds_t numfds, int timeout)
+{
+ fd_set read_set;
+ fd_set write_set;
+ fd_set exception_set;
+ nfds_t i;
+ int n;
+ int rc;
+
+ FD_ZERO(&read_set);
+ FD_ZERO(&write_set);
+ FD_ZERO(&exception_set);
+
+ n = -1;
+ for(i = 0; i < numfds; i++) {
+ if (fds[i].fd < 0)
+ continue;
+ if (fds[i].fd >= FD_SETSIZE) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (fds[i].events & POLLIN) FD_SET(fds[i].fd, &read_set);
+ if (fds[i].events & POLLOUT) FD_SET(fds[i].fd, &write_set);
+ if (fds[i].events & POLLERR) FD_SET(fds[i].fd, &exception_set);
+
+ if (fds[i].fd > n)
+ n = fds[i].fd;
+ };
+
+ if (n == -1)
+ /* Hey!? Nothing to poll, in fact!!! */
+ return 0;
+
+ if (timeout < 0)
+ rc = select(n+1, &read_set, &write_set, &exception_set, NULL);
+ else {
+ struct timeval tv;
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = 1000 * (timeout % 1000);
+ rc = select(n+1, &read_set, &write_set, &exception_set, &tv);
+ };
+
+ if (rc < 0)
+ return rc;
+
+ for(i = 0; i < (nfds_t) n; i++) {
+ fds[i].revents = 0;
+
+ if (FD_ISSET(fds[i].fd, &read_set)) fds[i].revents |= POLLIN;
+ if (FD_ISSET(fds[i].fd, &write_set)) fds[i].revents |= POLLOUT;
+ if (FD_ISSET(fds[i].fd, &exception_set)) fds[i].revents |= POLLERR;
+ };
+
+ return rc;
+}
+#endif /* HAVE_SYS_POLL_H */
+#endif /* CONFIG_FFSERVER */
+
diff --git a/contrib/ffmpeg/libavformat/os_support.h b/contrib/ffmpeg/libavformat/os_support.h
index e76a9aaaf..424d6dabd 100644
--- a/contrib/ffmpeg/libavformat/os_support.h
+++ b/contrib/ffmpeg/libavformat/os_support.h
@@ -26,22 +26,46 @@
* @file os_support.h
* miscellaneous OS support macros and functions.
*
+ * - socklen_t typedef (BeOS, Innotek libc)
* - usleep() (Win32, BeOS, OS/2)
+ * - lseek() (Win32)
* - floatf() (OS/2)
* - strcasecmp() (OS/2)
+ * - closesocket()
+ * - poll() (BeOS, MinGW)
*/
+#if defined(__BEOS__) || defined(__INNOTEK_LIBC__)
+typedef int socklen_t;
+#endif
+
#ifdef __MINGW32__
__declspec(dllimport) void __stdcall Sleep(unsigned long dwMilliseconds);
// # include <windows.h>
# define usleep(t) Sleep((t) / 1000)
+# include <fcntl.h>
+# define lseek(f,p,w) _lseeki64((f), (p), (w))
+# define HAVE_CLOSESOCKET 1
#endif
#ifdef __BEOS__
-# ifndef usleep
+# include <sys/socket.h>
+# include <netinet/in.h>
+ /* not net_server ? */
+# if IPPROTO_TCP != 6
+# define HAVE_CLOSESOCKET 1
+# endif
+# include <BeBuild.h>
+ /* R5 didn't have usleep, fake it. Haiku and Zeta has it now. */
+# if B_BEOS_VERSION <= B_BEOS_VERSION_5
# include <OS.h>
+ /* doesn't set errno but that's enough */
# define usleep(t) snooze((bigtime_t)(t))
# endif
+# ifndef SA_RESTART
+# warning SA_RESTART not implemented; ffserver might misbehave.
+# define SA_RESTART 0
+# endif
#endif
#if defined(CONFIG_OS2)
@@ -50,4 +74,38 @@ static inline int usleep(unsigned int t) { return _sleep2(t / 1000); }
static inline int strcasecmp(const char* s1, const char* s2) { return stricmp(s1,s2); }
#endif
+/* most of the time closing a socket is just closing an fd */
+#if HAVE_CLOSESOCKET != 1
+#define closesocket close
+#endif
+
+#ifdef CONFIG_FFSERVER
+#ifndef HAVE_SYS_POLL_H
+typedef unsigned long nfds_t;
+
+struct pollfd {
+ int fd;
+ short events; /* events to look for */
+ short revents; /* events that occured */
+};
+
+/* events & revents */
+#define POLLIN 0x0001 /* any readable data available */
+#define POLLOUT 0x0002 /* file descriptor is writeable */
+#define POLLRDNORM POLLIN
+#define POLLWRNORM POLLOUT
+#define POLLRDBAND 0x0008 /* priority readable data */
+#define POLLWRBAND 0x0010 /* priority data can be written */
+#define POLLPRI 0x0020 /* high priority readable data */
+
+/* revents only */
+#define POLLERR 0x0004 /* errors pending */
+#define POLLHUP 0x0080 /* disconnected */
+#define POLLNVAL 0x1000 /* invalid file descriptor */
+
+
+extern int poll(struct pollfd *fds, nfds_t numfds, int timeout);
+#endif /* HAVE_SYS_POLL_H */
+#endif /* CONFIG_FFSERVER */
+
#endif /* _OS_SUPPORT_H */
diff --git a/contrib/ffmpeg/libavformat/png.c b/contrib/ffmpeg/libavformat/png.c
deleted file mode 100644
index d62bf540a..000000000
--- a/contrib/ffmpeg/libavformat/png.c
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- * PNG image format
- * Copyright (c) 2003 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 "avformat.h"
-
-/* TODO:
- * - add 2, 4 and 16 bit depth support
- * - use filters when generating a png (better compression)
- */
-
-#ifdef CONFIG_ZLIB
-#include <zlib.h>
-
-//#define DEBUG
-
-#define PNG_COLOR_MASK_PALETTE 1
-#define PNG_COLOR_MASK_COLOR 2
-#define PNG_COLOR_MASK_ALPHA 4
-
-#define PNG_COLOR_TYPE_GRAY 0
-#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
-#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
-#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
-#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
-
-#define PNG_FILTER_VALUE_NONE 0
-#define PNG_FILTER_VALUE_SUB 1
-#define PNG_FILTER_VALUE_UP 2
-#define PNG_FILTER_VALUE_AVG 3
-#define PNG_FILTER_VALUE_PAETH 4
-
-#define PNG_IHDR 0x0001
-#define PNG_IDAT 0x0002
-#define PNG_ALLIMAGE 0x0004
-#define PNG_PLTE 0x0008
-
-#define NB_PASSES 7
-
-#define IOBUF_SIZE 4096
-
-typedef struct PNGDecodeState {
- int state;
- int width, height;
- int bit_depth;
- int color_type;
- int compression_type;
- int interlace_type;
- int filter_type;
- int channels;
- int bits_per_pixel;
- int bpp;
-
- uint8_t *image_buf;
- int image_linesize;
- uint32_t palette[256];
- uint8_t *crow_buf;
- uint8_t *last_row;
- uint8_t *tmp_row;
- int pass;
- int crow_size; /* compressed row size (include filter type) */
- int row_size; /* decompressed row size */
- int pass_row_size; /* decompress row size of the current pass */
- int y;
- z_stream zstream;
-} PNGDecodeState;
-
-static const uint8_t pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-
-/* Mask to determine which y pixels are valid in a pass */
-static const uint8_t png_pass_ymask[NB_PASSES] = {
- 0x80, 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55,
-};
-
-/* Mask to determine which y pixels can be written in a pass */
-static const uint8_t png_pass_dsp_ymask[NB_PASSES] = {
- 0xff, 0xff, 0x0f, 0xcc, 0x33, 0xff, 0x55,
-};
-
-/* minimum x value */
-static const uint8_t png_pass_xmin[NB_PASSES] = {
- 0, 4, 0, 2, 0, 1, 0
-};
-
-/* x shift to get row width */
-static const uint8_t png_pass_xshift[NB_PASSES] = {
- 3, 3, 2, 2, 1, 1, 0
-};
-
-/* Mask to determine which pixels are valid in a pass */
-static const uint8_t png_pass_mask[NB_PASSES] = {
- 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff
-};
-
-/* Mask to determine which pixels to overwrite while displaying */
-static const uint8_t png_pass_dsp_mask[NB_PASSES] = {
- 0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff
-};
-
-static int png_probe(AVProbeData *pd)
-{
- if (pd->buf_size >= 8 &&
- memcmp(pd->buf, pngsig, 8) == 0)
- return AVPROBE_SCORE_MAX;
- else
- return 0;
-}
-
-static void *png_zalloc(void *opaque, unsigned int items, unsigned int size)
-{
- return av_malloc(items * size);
-}
-
-static void png_zfree(void *opaque, void *ptr)
-{
- av_free(ptr);
-}
-
-static int png_get_nb_channels(int color_type)
-{
- int channels;
- channels = 1;
- if ((color_type & (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)) ==
- PNG_COLOR_MASK_COLOR)
- channels = 3;
- if (color_type & PNG_COLOR_MASK_ALPHA)
- channels++;
- return channels;
-}
-
-/* compute the row size of an interleaved pass */
-static int png_pass_row_size(int pass, int bits_per_pixel, int width)
-{
- int shift, xmin, pass_width;
-
- xmin = png_pass_xmin[pass];
- if (width <= xmin)
- return 0;
- shift = png_pass_xshift[pass];
- pass_width = (width - xmin + (1 << shift) - 1) >> shift;
- return (pass_width * bits_per_pixel + 7) >> 3;
-}
-
-/* NOTE: we try to construct a good looking image at each pass. width
- is the original image width. We also do pixel format convertion at
- this stage */
-static void png_put_interlaced_row(uint8_t *dst, int width,
- int bits_per_pixel, int pass,
- int color_type, const uint8_t *src)
-{
- int x, mask, dsp_mask, j, src_x, b, bpp;
- uint8_t *d;
- const uint8_t *s;
-
- mask = png_pass_mask[pass];
- dsp_mask = png_pass_dsp_mask[pass];
- switch(bits_per_pixel) {
- case 1:
- /* we must intialize the line to zero before writing to it */
- if (pass == 0)
- memset(dst, 0, (width + 7) >> 3);
- src_x = 0;
- for(x = 0; x < width; x++) {
- j = (x & 7);
- if ((dsp_mask << j) & 0x80) {
- b = (src[src_x >> 3] >> (7 - (src_x & 7))) & 1;
- dst[x >> 3] |= b << (7 - j);
- }
- if ((mask << j) & 0x80)
- src_x++;
- }
- break;
- default:
- bpp = bits_per_pixel >> 3;
- d = dst;
- s = src;
- if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- for(x = 0; x < width; x++) {
- j = x & 7;
- if ((dsp_mask << j) & 0x80) {
- *(uint32_t *)d = (s[3] << 24) | (s[0] << 16) | (s[1] << 8) | s[2];
- }
- d += bpp;
- if ((mask << j) & 0x80)
- s += bpp;
- }
- } else {
- for(x = 0; x < width; x++) {
- j = x & 7;
- if ((dsp_mask << j) & 0x80) {
- memcpy(d, s, bpp);
- }
- d += bpp;
- if ((mask << j) & 0x80)
- s += bpp;
- }
- }
- break;
- }
-}
-
-static void png_get_interlaced_row(uint8_t *dst, int row_size,
- int bits_per_pixel, int pass,
- const uint8_t *src, int width)
-{
- int x, mask, dst_x, j, b, bpp;
- uint8_t *d;
- const uint8_t *s;
-
- mask = png_pass_mask[pass];
- switch(bits_per_pixel) {
- case 1:
- memset(dst, 0, row_size);
- dst_x = 0;
- for(x = 0; x < width; x++) {
- j = (x & 7);
- if ((mask << j) & 0x80) {
- b = (src[x >> 3] >> (7 - j)) & 1;
- dst[dst_x >> 3] |= b << (7 - (dst_x & 7));
- dst_x++;
- }
- }
- break;
- default:
- bpp = bits_per_pixel >> 3;
- d = dst;
- s = src;
- for(x = 0; x < width; x++) {
- j = x & 7;
- if ((mask << j) & 0x80) {
- memcpy(d, s, bpp);
- d += bpp;
- }
- s += bpp;
- }
- break;
- }
-}
-
-/* XXX: optimize */
-/* NOTE: 'dst' can be equal to 'last' */
-static void png_filter_row(uint8_t *dst, int filter_type,
- uint8_t *src, uint8_t *last, int size, int bpp)
-{
- int i, p;
-
- switch(filter_type) {
- case PNG_FILTER_VALUE_NONE:
- memcpy(dst, src, size);
- break;
- case PNG_FILTER_VALUE_SUB:
- for(i = 0; i < bpp; i++) {
- dst[i] = src[i];
- }
- for(i = bpp; i < size; i++) {
- p = dst[i - bpp];
- dst[i] = p + src[i];
- }
- break;
- case PNG_FILTER_VALUE_UP:
- for(i = 0; i < size; i++) {
- p = last[i];
- dst[i] = p + src[i];
- }
- break;
- case PNG_FILTER_VALUE_AVG:
- for(i = 0; i < bpp; i++) {
- p = (last[i] >> 1);
- dst[i] = p + src[i];
- }
- for(i = bpp; i < size; i++) {
- p = ((dst[i - bpp] + last[i]) >> 1);
- dst[i] = p + src[i];
- }
- break;
- case PNG_FILTER_VALUE_PAETH:
- for(i = 0; i < bpp; i++) {
- p = last[i];
- dst[i] = p + src[i];
- }
- for(i = bpp; i < size; i++) {
- int a, b, c, pa, pb, pc;
-
- a = dst[i - bpp];
- b = last[i];
- c = last[i - bpp];
-
- p = b - c;
- pc = a - c;
-
- pa = abs(p);
- pb = abs(pc);
- pc = abs(p + pc);
-
- if (pa <= pb && pa <= pc)
- p = a;
- else if (pb <= pc)
- p = b;
- else
- p = c;
- dst[i] = p + src[i];
- }
- break;
- }
-}
-
-static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width)
-{
- uint8_t *d;
- int j;
- unsigned int v;
-
- d = dst;
- for(j = 0; j < width; j++) {
- v = ((const uint32_t *)src)[j];
- d[0] = v >> 16;
- d[1] = v >> 8;
- d[2] = v;
- d[3] = v >> 24;
- d += 4;
- }
-}
-
-static void convert_to_rgba32(uint8_t *dst, const uint8_t *src, int width)
-{
- int j;
- unsigned int r, g, b, a;
-
- for(j = 0;j < width; j++) {
- r = src[0];
- g = src[1];
- b = src[2];
- a = src[3];
- *(uint32_t *)dst = (a << 24) | (r << 16) | (g << 8) | b;
- dst += 4;
- src += 4;
- }
-}
-
-/* process exactly one decompressed row */
-static void png_handle_row(PNGDecodeState *s)
-{
- uint8_t *ptr, *last_row;
- int got_line;
-
- if (!s->interlace_type) {
- ptr = s->image_buf + s->image_linesize * s->y;
- /* need to swap bytes correctly for RGB_ALPHA */
- if (s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
- s->last_row, s->row_size, s->bpp);
- memcpy(s->last_row, s->tmp_row, s->row_size);
- convert_to_rgba32(ptr, s->tmp_row, s->width);
- } else {
- /* in normal case, we avoid one copy */
- if (s->y == 0)
- last_row = s->last_row;
- else
- last_row = ptr - s->image_linesize;
-
- png_filter_row(ptr, s->crow_buf[0], s->crow_buf + 1,
- last_row, s->row_size, s->bpp);
- }
- s->y++;
- if (s->y == s->height) {
- s->state |= PNG_ALLIMAGE;
- }
- } else {
- got_line = 0;
- for(;;) {
- ptr = s->image_buf + s->image_linesize * s->y;
- if ((png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
- /* if we already read one row, it is time to stop to
- wait for the next one */
- if (got_line)
- break;
- png_filter_row(s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
- s->last_row, s->pass_row_size, s->bpp);
- memcpy(s->last_row, s->tmp_row, s->pass_row_size);
- got_line = 1;
- }
- if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
- /* NOTE: rgba32 is handled directly in png_put_interlaced_row */
- png_put_interlaced_row(ptr, s->width, s->bits_per_pixel, s->pass,
- s->color_type, s->last_row);
- }
- s->y++;
- if (s->y == s->height) {
- for(;;) {
- if (s->pass == NB_PASSES - 1) {
- s->state |= PNG_ALLIMAGE;
- goto the_end;
- } else {
- s->pass++;
- s->y = 0;
- s->pass_row_size = png_pass_row_size(s->pass,
- s->bits_per_pixel,
- s->width);
- s->crow_size = s->pass_row_size + 1;
- if (s->pass_row_size != 0)
- break;
- /* skip pass if empty row */
- }
- }
- }
- }
- the_end: ;
- }
-}
-
-static int png_decode_idat(PNGDecodeState *s, ByteIOContext *f, int length)
-{
- uint8_t buf[IOBUF_SIZE];
- int buf_size;
- int ret;
- while (length > 0) {
- /* read the buffer */
- buf_size = IOBUF_SIZE;
- if (buf_size > length)
- buf_size = length;
- ret = get_buffer(f, buf, buf_size);
- if (ret != buf_size)
- return -1;
- s->zstream.avail_in = buf_size;
- s->zstream.next_in = buf;
- /* decode one line if possible */
- while (s->zstream.avail_in > 0) {
- ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
- if (ret != Z_OK && ret != Z_STREAM_END) {
- return -1;
- }
- if (s->zstream.avail_out == 0) {
- if (!(s->state & PNG_ALLIMAGE)) {
- png_handle_row(s);
- }
- s->zstream.avail_out = s->crow_size;
- s->zstream.next_out = s->crow_buf;
- }
- }
- length -= buf_size;
- }
- return 0;
-}
-
-static int png_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- AVImageInfo info1, *info = &info1;
- PNGDecodeState s1, *s = &s1;
- uint32_t tag, length;
- int ret, crc;
- uint8_t buf[8];
-
- /* check signature */
- ret = get_buffer(f, buf, 8);
- if (ret != 8)
- return -1;
- if (memcmp(buf, pngsig, 8) != 0)
- return -1;
- memset(s, 0, sizeof(PNGDecodeState));
- /* init the zlib */
- s->zstream.zalloc = png_zalloc;
- s->zstream.zfree = png_zfree;
- s->zstream.opaque = NULL;
- ret = inflateInit(&s->zstream);
- if (ret != Z_OK)
- return -1;
- for(;;) {
- if (url_feof(f))
- goto fail;
- length = get_be32(f);
- if (length > 0x7fffffff)
- goto fail;
- tag = get_le32(f);
-#ifdef DEBUG
- printf("png: tag=%c%c%c%c length=%u\n",
- (tag & 0xff),
- ((tag >> 8) & 0xff),
- ((tag >> 16) & 0xff),
- ((tag >> 24) & 0xff), length);
-#endif
- switch(tag) {
- case MKTAG('I', 'H', 'D', 'R'):
- if (length != 13)
- goto fail;
- s->width = get_be32(f);
- s->height = get_be32(f);
- s->bit_depth = get_byte(f);
- s->color_type = get_byte(f);
- s->compression_type = get_byte(f);
- s->filter_type = get_byte(f);
- s->interlace_type = get_byte(f);
- crc = get_be32(f);
- s->state |= PNG_IHDR;
-#ifdef DEBUG
- printf("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);
-#endif
- break;
- case MKTAG('I', 'D', 'A', 'T'):
- if (!(s->state & PNG_IHDR))
- goto fail;
- if (!(s->state & PNG_IDAT)) {
- /* init image info */
- info->width = s->width;
- info->height = s->height;
- info->interleaved = (s->interlace_type != 0);
-
- s->channels = png_get_nb_channels(s->color_type);
- s->bits_per_pixel = s->bit_depth * s->channels;
- s->bpp = (s->bits_per_pixel + 7) >> 3;
- s->row_size = (info->width * s->bits_per_pixel + 7) >> 3;
-
- if (s->bit_depth == 8 &&
- s->color_type == PNG_COLOR_TYPE_RGB) {
- info->pix_fmt = PIX_FMT_RGB24;
- } else if (s->bit_depth == 8 &&
- s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- info->pix_fmt = PIX_FMT_RGBA32;
- } else if (s->bit_depth == 8 &&
- s->color_type == PNG_COLOR_TYPE_GRAY) {
- info->pix_fmt = PIX_FMT_GRAY8;
- } else if (s->bit_depth == 1 &&
- s->color_type == PNG_COLOR_TYPE_GRAY) {
- info->pix_fmt = PIX_FMT_MONOBLACK;
- } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
- info->pix_fmt = PIX_FMT_PAL8;
- } else {
- goto fail;
- }
- ret = alloc_cb(opaque, info);
- if (ret)
- goto the_end;
-
- /* compute the compressed row size */
- if (!s->interlace_type) {
- s->crow_size = s->row_size + 1;
- } else {
- s->pass = 0;
- s->pass_row_size = png_pass_row_size(s->pass,
- s->bits_per_pixel,
- s->width);
- s->crow_size = s->pass_row_size + 1;
- }
-#ifdef DEBUG
- printf("row_size=%d crow_size =%d\n",
- s->row_size, s->crow_size);
-#endif
- s->image_buf = info->pict.data[0];
- s->image_linesize = info->pict.linesize[0];
- /* copy the palette if needed */
- if (s->color_type == PNG_COLOR_TYPE_PALETTE)
- memcpy(info->pict.data[1], s->palette, 256 * sizeof(uint32_t));
- /* empty row is used if differencing to the first row */
- s->last_row = av_mallocz(s->row_size);
- if (!s->last_row)
- goto fail;
- if (s->interlace_type ||
- s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- s->tmp_row = av_malloc(s->row_size);
- if (!s->tmp_row)
- goto fail;
- }
- /* compressed row */
- s->crow_buf = av_malloc(s->row_size + 1);
- if (!s->crow_buf)
- goto fail;
- s->zstream.avail_out = s->crow_size;
- s->zstream.next_out = s->crow_buf;
- }
- s->state |= PNG_IDAT;
- if (png_decode_idat(s, f, length) < 0)
- goto fail;
- /* skip crc */
- crc = get_be32(f);
- break;
- case MKTAG('P', 'L', 'T', 'E'):
- {
- int n, i, r, g, b;
-
- if ((length % 3) != 0 || length > 256 * 3)
- goto skip_tag;
- /* read the palette */
- n = length / 3;
- for(i=0;i<n;i++) {
- r = get_byte(f);
- g = get_byte(f);
- b = get_byte(f);
- s->palette[i] = (0xff << 24) | (r << 16) | (g << 8) | b;
- }
- for(;i<256;i++) {
- s->palette[i] = (0xff << 24);
- }
- s->state |= PNG_PLTE;
- crc = get_be32(f);
- }
- break;
- case MKTAG('t', 'R', 'N', 'S'):
- {
- int v, i;
-
- /* read the transparency. XXX: Only palette mode supported */
- if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
- length > 256 ||
- !(s->state & PNG_PLTE))
- goto skip_tag;
- for(i=0;i<length;i++) {
- v = get_byte(f);
- s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
- }
- crc = get_be32(f);
- }
- break;
- case MKTAG('I', 'E', 'N', 'D'):
- if (!(s->state & PNG_ALLIMAGE))
- goto fail;
- crc = get_be32(f);
- goto exit_loop;
- default:
- /* skip tag */
- skip_tag:
- url_fskip(f, length + 4);
- break;
- }
- }
- exit_loop:
- ret = 0;
- the_end:
- inflateEnd(&s->zstream);
- av_free(s->crow_buf);
- av_free(s->last_row);
- av_free(s->tmp_row);
- return ret;
- fail:
- ret = -1;
- goto the_end;
-}
-
-static void png_write_chunk(ByteIOContext *f, uint32_t tag,
- const uint8_t *buf, int length)
-{
- uint32_t crc;
- uint8_t tagbuf[4];
-
- put_be32(f, length);
- crc = crc32(0, Z_NULL, 0);
- tagbuf[0] = tag;
- tagbuf[1] = tag >> 8;
- tagbuf[2] = tag >> 16;
- tagbuf[3] = tag >> 24;
- crc = crc32(crc, tagbuf, 4);
- put_le32(f, tag);
- if (length > 0) {
- crc = crc32(crc, buf, length);
- put_buffer(f, buf, length);
- }
- put_be32(f, crc);
-}
-
-/* XXX: use avcodec generic function ? */
-static void to_be32(uint8_t *p, uint32_t v)
-{
- p[0] = v >> 24;
- p[1] = v >> 16;
- p[2] = v >> 8;
- p[3] = v;
-}
-
-typedef struct PNGEncodeState {
- ByteIOContext *f;
- z_stream zstream;
- uint8_t buf[IOBUF_SIZE];
-} PNGEncodeState;
-
-
-/* XXX: do filtering */
-static int png_write_row(PNGEncodeState *s, const uint8_t *data, int size)
-{
- int ret;
-
- s->zstream.avail_in = size;
- s->zstream.next_in = (uint8_t *)data;
- while (s->zstream.avail_in > 0) {
- ret = deflate(&s->zstream, Z_NO_FLUSH);
- if (ret != Z_OK)
- return -1;
- if (s->zstream.avail_out == 0) {
- png_write_chunk(s->f, MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE);
- s->zstream.avail_out = IOBUF_SIZE;
- s->zstream.next_out = s->buf;
- }
- }
- return 0;
-}
-
-static int png_write(ByteIOContext *f, AVImageInfo *info)
-{
- PNGEncodeState s1, *s = &s1;
- int bit_depth, color_type, y, len, row_size, ret, is_progressive;
- int bits_per_pixel, pass_row_size;
- uint8_t *ptr;
- uint8_t *crow_buf = NULL;
- uint8_t *tmp_buf = NULL;
-
- s->f = f;
- is_progressive = info->interleaved;
- switch(info->pix_fmt) {
- case PIX_FMT_RGBA32:
- bit_depth = 8;
- color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- break;
- case PIX_FMT_RGB24:
- bit_depth = 8;
- color_type = PNG_COLOR_TYPE_RGB;
- break;
- case PIX_FMT_GRAY8:
- bit_depth = 8;
- color_type = PNG_COLOR_TYPE_GRAY;
- break;
- case PIX_FMT_MONOBLACK:
- bit_depth = 1;
- color_type = PNG_COLOR_TYPE_GRAY;
- break;
- case PIX_FMT_PAL8:
- bit_depth = 8;
- color_type = PNG_COLOR_TYPE_PALETTE;
- break;
- default:
- return -1;
- }
- bits_per_pixel = png_get_nb_channels(color_type) * bit_depth;
- row_size = (info->width * bits_per_pixel + 7) >> 3;
-
- s->zstream.zalloc = png_zalloc;
- s->zstream.zfree = png_zfree;
- s->zstream.opaque = NULL;
- ret = deflateInit2(&s->zstream, Z_DEFAULT_COMPRESSION,
- Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
- if (ret != Z_OK)
- return -1;
- crow_buf = av_malloc(row_size + 1);
- if (!crow_buf)
- goto fail;
- if (is_progressive) {
- tmp_buf = av_malloc(row_size + 1);
- if (!tmp_buf)
- goto fail;
- }
-
- /* write png header */
- put_buffer(f, pngsig, 8);
-
- to_be32(s->buf, info->width);
- to_be32(s->buf + 4, info->height);
- s->buf[8] = bit_depth;
- s->buf[9] = color_type;
- s->buf[10] = 0; /* compression type */
- s->buf[11] = 0; /* filter type */
- s->buf[12] = is_progressive; /* interlace type */
-
- png_write_chunk(f, MKTAG('I', 'H', 'D', 'R'), s->buf, 13);
-
- /* put the palette if needed */
- if (color_type == PNG_COLOR_TYPE_PALETTE) {
- int has_alpha, alpha, i;
- unsigned int v;
- uint32_t *palette;
- uint8_t *alpha_ptr;
-
- palette = (uint32_t *)info->pict.data[1];
- ptr = s->buf;
- alpha_ptr = s->buf + 256 * 3;
- has_alpha = 0;
- for(i = 0; i < 256; i++) {
- v = palette[i];
- alpha = v >> 24;
- if (alpha != 0xff)
- has_alpha = 1;
- *alpha_ptr++ = alpha;
- ptr[0] = v >> 16;
- ptr[1] = v >> 8;
- ptr[2] = v;
- ptr += 3;
- }
- png_write_chunk(f, MKTAG('P', 'L', 'T', 'E'), s->buf, 256 * 3);
- if (has_alpha) {
- png_write_chunk(f, MKTAG('t', 'R', 'N', 'S'), s->buf + 256 * 3, 256);
- }
- }
-
- /* now put each row */
- s->zstream.avail_out = IOBUF_SIZE;
- s->zstream.next_out = s->buf;
- if (is_progressive) {
- uint8_t *ptr1;
- int pass;
-
- for(pass = 0; pass < NB_PASSES; pass++) {
- /* NOTE: a pass is completely omited if no pixels would be
- output */
- pass_row_size = png_pass_row_size(pass, bits_per_pixel, info->width);
- if (pass_row_size > 0) {
- for(y = 0; y < info->height; y++) {
- if ((png_pass_ymask[pass] << (y & 7)) & 0x80) {
- ptr = info->pict.data[0] + y * info->pict.linesize[0];
- if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
- convert_from_rgba32(tmp_buf, ptr, info->width);
- ptr1 = tmp_buf;
- } else {
- ptr1 = ptr;
- }
- png_get_interlaced_row(crow_buf + 1, pass_row_size,
- bits_per_pixel, pass,
- ptr1, info->width);
- crow_buf[0] = PNG_FILTER_VALUE_NONE;
- png_write_row(s, crow_buf, pass_row_size + 1);
- }
- }
- }
- }
- } else {
- for(y = 0; y < info->height; y++) {
- ptr = info->pict.data[0] + y * info->pict.linesize[0];
- if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- convert_from_rgba32(crow_buf + 1, ptr, info->width);
- else
- memcpy(crow_buf + 1, ptr, row_size);
- crow_buf[0] = PNG_FILTER_VALUE_NONE;
- png_write_row(s, crow_buf, row_size + 1);
- }
- }
- /* compress last bytes */
- for(;;) {
- ret = deflate(&s->zstream, Z_FINISH);
- if (ret == Z_OK || ret == Z_STREAM_END) {
- len = IOBUF_SIZE - s->zstream.avail_out;
- if (len > 0) {
- png_write_chunk(f, MKTAG('I', 'D', 'A', 'T'), s->buf, len);
- }
- s->zstream.avail_out = IOBUF_SIZE;
- s->zstream.next_out = s->buf;
- if (ret == Z_STREAM_END)
- break;
- } else {
- goto fail;
- }
- }
- png_write_chunk(f, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
-
- put_flush_packet(f);
- ret = 0;
- the_end:
- av_free(crow_buf);
- av_free(tmp_buf);
- deflateEnd(&s->zstream);
- return ret;
- fail:
- ret = -1;
- goto the_end;
-}
-
-AVImageFormat png_image_format = {
- "png",
- "png",
- png_probe,
- png_read,
- (1 << PIX_FMT_RGBA32) | (1 << PIX_FMT_RGB24) | (1 << PIX_FMT_GRAY8) |
- (1 << PIX_FMT_MONOBLACK) | (1 << PIX_FMT_PAL8),
- png_write,
- AVIMAGE_INTERLEAVED,
-};
-#endif
diff --git a/contrib/ffmpeg/libavformat/pnm.c b/contrib/ffmpeg/libavformat/pnm.c
deleted file mode 100644
index ade5d7c5d..000000000
--- a/contrib/ffmpeg/libavformat/pnm.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * PNM image format
- * Copyright (c) 2002, 2003 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 "avformat.h"
-
-static inline int pnm_space(int c)
-{
- return (c == ' ' || c == '\n' || c == '\r' || c == '\t');
-}
-
-static void pnm_get(ByteIOContext *f, char *str, int buf_size)
-{
- char *s;
- int c;
-
- /* skip spaces and comments */
- for(;;) {
- c = url_fgetc(f);
- if (c == '#') {
- do {
- c = url_fgetc(f);
- } while (c != '\n' && c != URL_EOF);
- } else if (!pnm_space(c)) {
- break;
- }
- }
-
- s = str;
- while (c != URL_EOF && !pnm_space(c)) {
- if ((s - str) < buf_size - 1)
- *s++ = c;
- c = url_fgetc(f);
- }
- *s = '\0';
-}
-
-static int pnm_read1(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque,
- int allow_yuv)
-{
- int i, n, linesize, h;
- char buf1[32];
- unsigned char *ptr;
- AVImageInfo info1, *info = &info1;
- int ret;
-
- pnm_get(f, buf1, sizeof(buf1));
- if (!strcmp(buf1, "P4")) {
- info->pix_fmt = PIX_FMT_MONOWHITE;
- } else if (!strcmp(buf1, "P5")) {
- if (allow_yuv)
- info->pix_fmt = PIX_FMT_YUV420P;
- else
- info->pix_fmt = PIX_FMT_GRAY8;
- } else if (!strcmp(buf1, "P6")) {
- info->pix_fmt = PIX_FMT_RGB24;
- } else {
- return AVERROR_INVALIDDATA;
- }
- pnm_get(f, buf1, sizeof(buf1));
- info->width = atoi(buf1);
- if (info->width <= 0)
- return AVERROR_INVALIDDATA;
- pnm_get(f, buf1, sizeof(buf1));
- info->height = atoi(buf1);
- if (info->height <= 0)
- return AVERROR_INVALIDDATA;
- if (info->pix_fmt != PIX_FMT_MONOWHITE) {
- pnm_get(f, buf1, sizeof(buf1));
- }
-
- /* more check if YUV420 */
- if (info->pix_fmt == PIX_FMT_YUV420P) {
- if ((info->width & 1) != 0)
- return AVERROR_INVALIDDATA;
- h = (info->height * 2);
- if ((h % 3) != 0)
- return AVERROR_INVALIDDATA;
- h /= 3;
- info->height = h;
- }
-
- ret = alloc_cb(opaque, info);
- if (ret)
- return ret;
-
- switch(info->pix_fmt) {
- default:
- return AVERROR_INVALIDDATA;
- case PIX_FMT_RGB24:
- n = info->width * 3;
- goto do_read;
- case PIX_FMT_GRAY8:
- n = info->width;
- goto do_read;
- case PIX_FMT_MONOWHITE:
- n = (info->width + 7) >> 3;
- do_read:
- ptr = info->pict.data[0];
- linesize = info->pict.linesize[0];
- for(i = 0; i < info->height; i++) {
- get_buffer(f, ptr, n);
- ptr += linesize;
- }
- break;
- case PIX_FMT_YUV420P:
- {
- unsigned char *ptr1, *ptr2;
-
- n = info->width;
- ptr = info->pict.data[0];
- linesize = info->pict.linesize[0];
- for(i = 0; i < info->height; i++) {
- get_buffer(f, ptr, n);
- ptr += linesize;
- }
- ptr1 = info->pict.data[1];
- ptr2 = info->pict.data[2];
- n >>= 1;
- h = info->height >> 1;
- for(i = 0; i < h; i++) {
- get_buffer(f, ptr1, n);
- get_buffer(f, ptr2, n);
- ptr1 += info->pict.linesize[1];
- ptr2 += info->pict.linesize[2];
- }
- }
- break;
- }
- return 0;
-}
-
-static int pnm_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- return pnm_read1(f, alloc_cb, opaque, 0);
-}
-
-static int pgmyuv_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- return pnm_read1(f, alloc_cb, opaque, 1);
-}
-
-static int pnm_write(ByteIOContext *pb, AVImageInfo *info)
-{
- int i, h, h1, c, n, linesize;
- char buf[100];
- uint8_t *ptr, *ptr1, *ptr2;
-
- h = info->height;
- h1 = h;
- switch(info->pix_fmt) {
- case PIX_FMT_MONOWHITE:
- c = '4';
- n = (info->width + 7) >> 3;
- break;
- case PIX_FMT_GRAY8:
- c = '5';
- n = info->width;
- break;
- case PIX_FMT_RGB24:
- c = '6';
- n = info->width * 3;
- break;
- case PIX_FMT_YUV420P:
- c = '5';
- n = info->width;
- h1 = (h * 3) / 2;
- break;
- default:
- return AVERROR_INVALIDDATA;
- }
- snprintf(buf, sizeof(buf),
- "P%c\n%d %d\n",
- c, info->width, h1);
- put_buffer(pb, buf, strlen(buf));
- if (info->pix_fmt != PIX_FMT_MONOWHITE) {
- snprintf(buf, sizeof(buf),
- "%d\n", 255);
- put_buffer(pb, buf, strlen(buf));
- }
-
- ptr = info->pict.data[0];
- linesize = info->pict.linesize[0];
- for(i=0;i<h;i++) {
- put_buffer(pb, ptr, n);
- ptr += linesize;
- }
-
- if (info->pix_fmt == PIX_FMT_YUV420P) {
- h >>= 1;
- n >>= 1;
- ptr1 = info->pict.data[1];
- ptr2 = info->pict.data[2];
- for(i=0;i<h;i++) {
- put_buffer(pb, ptr1, n);
- put_buffer(pb, ptr2, n);
- ptr1 += info->pict.linesize[1];
- ptr2 += info->pict.linesize[2];
- }
- }
- put_flush_packet(pb);
- return 0;
-}
-
-static int pam_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- int i, n, linesize, h, w, depth, maxval;
- char buf1[32], tuple_type[32];
- unsigned char *ptr;
- AVImageInfo info1, *info = &info1;
- int ret;
-
- pnm_get(f, buf1, sizeof(buf1));
- if (strcmp(buf1, "P7") != 0)
- return AVERROR_INVALIDDATA;
- w = -1;
- h = -1;
- maxval = -1;
- depth = -1;
- tuple_type[0] = '\0';
- for(;;) {
- pnm_get(f, buf1, sizeof(buf1));
- if (!strcmp(buf1, "WIDTH")) {
- pnm_get(f, buf1, sizeof(buf1));
- w = strtol(buf1, NULL, 10);
- } else if (!strcmp(buf1, "HEIGHT")) {
- pnm_get(f, buf1, sizeof(buf1));
- h = strtol(buf1, NULL, 10);
- } else if (!strcmp(buf1, "DEPTH")) {
- pnm_get(f, buf1, sizeof(buf1));
- depth = strtol(buf1, NULL, 10);
- } else if (!strcmp(buf1, "MAXVAL")) {
- pnm_get(f, buf1, sizeof(buf1));
- maxval = strtol(buf1, NULL, 10);
- } else if (!strcmp(buf1, "TUPLETYPE")) {
- pnm_get(f, buf1, sizeof(buf1));
- pstrcpy(tuple_type, sizeof(tuple_type), buf1);
- } else if (!strcmp(buf1, "ENDHDR")) {
- break;
- } else {
- return AVERROR_INVALIDDATA;
- }
- }
- /* check that all tags are present */
- if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0')
- return AVERROR_INVALIDDATA;
- info->width = w;
- info->height = h;
- if (depth == 1) {
- if (maxval == 1)
- info->pix_fmt = PIX_FMT_MONOWHITE;
- else
- info->pix_fmt = PIX_FMT_GRAY8;
- } else if (depth == 3) {
- info->pix_fmt = PIX_FMT_RGB24;
- } else if (depth == 4) {
- info->pix_fmt = PIX_FMT_RGBA32;
- } else {
- return AVERROR_INVALIDDATA;
- }
- ret = alloc_cb(opaque, info);
- if (ret)
- return ret;
-
- switch(info->pix_fmt) {
- default:
- return AVERROR_INVALIDDATA;
- case PIX_FMT_RGB24:
- n = info->width * 3;
- goto do_read;
- case PIX_FMT_GRAY8:
- n = info->width;
- goto do_read;
- case PIX_FMT_MONOWHITE:
- n = (info->width + 7) >> 3;
- do_read:
- ptr = info->pict.data[0];
- linesize = info->pict.linesize[0];
- for(i = 0; i < info->height; i++) {
- get_buffer(f, ptr, n);
- ptr += linesize;
- }
- break;
- case PIX_FMT_RGBA32:
- ptr = info->pict.data[0];
- linesize = info->pict.linesize[0];
- for(i = 0; i < info->height; i++) {
- int j, r, g, b, a;
-
- for(j = 0;j < w; j++) {
- r = get_byte(f);
- g = get_byte(f);
- b = get_byte(f);
- a = get_byte(f);
- ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
- }
- ptr += linesize;
- }
- break;
- }
- return 0;
-}
-
-static int pam_write(ByteIOContext *pb, AVImageInfo *info)
-{
- int i, h, w, n, linesize, depth, maxval;
- const char *tuple_type;
- char buf[100];
- uint8_t *ptr;
-
- h = info->height;
- w = info->width;
- switch(info->pix_fmt) {
- case PIX_FMT_MONOWHITE:
- n = (info->width + 7) >> 3;
- depth = 1;
- maxval = 1;
- tuple_type = "BLACKANDWHITE";
- break;
- case PIX_FMT_GRAY8:
- n = info->width;
- depth = 1;
- maxval = 255;
- tuple_type = "GRAYSCALE";
- break;
- case PIX_FMT_RGB24:
- n = info->width * 3;
- depth = 3;
- maxval = 255;
- tuple_type = "RGB";
- break;
- case PIX_FMT_RGBA32:
- n = info->width * 4;
- depth = 4;
- maxval = 255;
- tuple_type = "RGB_ALPHA";
- break;
- default:
- return AVERROR_INVALIDDATA;
- }
- snprintf(buf, sizeof(buf),
- "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n",
- w, h, depth, maxval, tuple_type);
- put_buffer(pb, buf, strlen(buf));
-
- ptr = info->pict.data[0];
- linesize = info->pict.linesize[0];
-
- if (info->pix_fmt == PIX_FMT_RGBA32) {
- int j;
- unsigned int v;
-
- for(i=0;i<h;i++) {
- for(j=0;j<w;j++) {
- v = ((uint32_t *)ptr)[j];
- put_byte(pb, (v >> 16) & 0xff);
- put_byte(pb, (v >> 8) & 0xff);
- put_byte(pb, (v) & 0xff);
- put_byte(pb, (v >> 24) & 0xff);
- }
- ptr += linesize;
- }
- } else {
- for(i=0;i<h;i++) {
- put_buffer(pb, ptr, n);
- ptr += linesize;
- }
- }
- put_flush_packet(pb);
- return 0;
-}
-
-static int pnm_probe(AVProbeData *pd)
-{
- const char *p = pd->buf;
- if (pd->buf_size >= 8 &&
- p[0] == 'P' &&
- p[1] >= '4' && p[1] <= '6' &&
- pnm_space(p[2]) )
- return AVPROBE_SCORE_MAX - 1; /* to permit pgmyuv probe */
- else
- return 0;
-}
-
-static int pgmyuv_probe(AVProbeData *pd)
-{
- if (match_ext(pd->filename, "pgmyuv"))
- return AVPROBE_SCORE_MAX;
- else
- return 0;
-}
-
-static int pam_probe(AVProbeData *pd)
-{
- const char *p = pd->buf;
- if (pd->buf_size >= 8 &&
- p[0] == 'P' &&
- p[1] == '7' &&
- p[2] == '\n')
- return AVPROBE_SCORE_MAX;
- else
- return 0;
-}
-
-AVImageFormat pnm_image_format = {
- "pnm",
- NULL,
- pnm_probe,
- pnm_read,
- 0,
- NULL,
-};
-
-AVImageFormat pbm_image_format = {
- "pbm",
- "pbm",
- NULL,
- NULL,
- (1 << PIX_FMT_MONOWHITE),
- pnm_write,
-};
-
-AVImageFormat pgm_image_format = {
- "pgm",
- "pgm",
- NULL,
- NULL,
- (1 << PIX_FMT_GRAY8),
- pnm_write,
-};
-
-AVImageFormat ppm_image_format = {
- "ppm",
- "ppm",
- NULL,
- NULL,
- (1 << PIX_FMT_RGB24),
- pnm_write,
-};
-
-AVImageFormat pam_image_format = {
- "pam",
- "pam",
- pam_probe,
- pam_read,
- (1 << PIX_FMT_MONOWHITE) | (1 << PIX_FMT_GRAY8) | (1 << PIX_FMT_RGB24) |
- (1 << PIX_FMT_RGBA32),
- pam_write,
-};
-
-AVImageFormat pgmyuv_image_format = {
- "pgmyuv",
- "pgmyuv",
- pgmyuv_probe,
- pgmyuv_read,
- (1 << PIX_FMT_YUV420P),
- pnm_write,
-};
diff --git a/contrib/ffmpeg/libavformat/psxstr.c b/contrib/ffmpeg/libavformat/psxstr.c
index b03f65750..2f1a3dc73 100644
--- a/contrib/ffmpeg/libavformat/psxstr.c
+++ b/contrib/ffmpeg/libavformat/psxstr.c
@@ -92,8 +92,8 @@ static int str_probe(AVProbeData *p)
if (p->buf_size < 0x38)
return 0;
- if ((LE_32(&p->buf[0]) == RIFF_TAG) &&
- (LE_32(&p->buf[8]) == CDXA_TAG)) {
+ if ((AV_RL32(&p->buf[0]) == RIFF_TAG) &&
+ (AV_RL32(&p->buf[8]) == CDXA_TAG)) {
/* RIFF header seen; skip 0x2C bytes */
start = RIFF_HEADER_SIZE;
@@ -143,7 +143,7 @@ static int str_read_header(AVFormatContext *s,
/* skip over any RIFF header */
if (get_buffer(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
return AVERROR_IO;
- if (LE_32(&sector[0]) == RIFF_TAG)
+ if (AV_RL32(&sector[0]) == RIFF_TAG)
start = RIFF_HEADER_SIZE;
else
start = 0;
@@ -168,12 +168,12 @@ static int str_read_header(AVFormatContext *s,
/* check if this channel gets to be the dominant video channel */
if (str->video_channel == -1) {
/* qualify the magic number */
- if (LE_32(&sector[0x18]) != STR_MAGIC)
+ if (AV_RL32(&sector[0x18]) != STR_MAGIC)
break;
str->video_channel = channel;
str->channels[channel].type = STR_VIDEO;
- str->channels[channel].width = LE_16(&sector[0x28]);
- str->channels[channel].height = LE_16(&sector[0x2A]);
+ str->channels[channel].width = AV_RL16(&sector[0x28]);
+ str->channels[channel].height = AV_RL16(&sector[0x2A]);
/* allocate a new AVStream */
st = av_new_stream(s, 0);
@@ -273,9 +273,9 @@ static int str_read_packet(AVFormatContext *s,
/* check if this the video channel we care about */
if (channel == str->video_channel) {
- int current_sector = LE_16(&sector[0x1C]);
- int sector_count = LE_16(&sector[0x1E]);
- int frame_size = LE_32(&sector[0x24]);
+ int current_sector = AV_RL16(&sector[0x1C]);
+ int sector_count = AV_RL16(&sector[0x1E]);
+ int frame_size = AV_RL32(&sector[0x24]);
int bytes_to_copy;
// printf("%d %d %d\n",current_sector,sector_count,frame_size);
/* if this is the first sector of the frame, allocate a pkt */
diff --git a/contrib/ffmpeg/libavformat/qtpalette.h b/contrib/ffmpeg/libavformat/qtpalette.h
index ef4ccfa91..183600fde 100644
--- a/contrib/ffmpeg/libavformat/qtpalette.h
+++ b/contrib/ffmpeg/libavformat/qtpalette.h
@@ -2,6 +2,22 @@
* Default Palettes for Quicktime Files
* Automatically generated from a utility derived from XAnim:
* http://xanim.va.pubnix.com/home.html
+ *
+ * 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 QTPALETTE_H
diff --git a/contrib/ffmpeg/libavformat/raw.c b/contrib/ffmpeg/libavformat/raw.c
index e1ccbcd6d..73a20379a 100644
--- a/contrib/ffmpeg/libavformat/raw.c
+++ b/contrib/ffmpeg/libavformat/raw.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "ac3.h"
#ifdef CONFIG_MUXERS
/* simple formats */
@@ -336,9 +337,9 @@ static int mpegvideo_probe(AVProbeData *p)
case PICTURE_START_CODE: pic++; break;
case SLICE_START_CODE: slice++; break;
case PACK_START_CODE: pspack++; break;
- case VIDEO_ID:
- case AUDIO_ID: pes++; break;
}
+ if ((code & 0x1f0) == VIDEO_ID) pes++;
+ else if((code & 0x1e0) == AUDIO_ID) pes++;
}
}
if(seq && seq*9<=pic*10 && pic*9<=slice*10 && !pspack && !pes)
@@ -406,6 +407,37 @@ static int h261_probe(AVProbeData *p)
return 0;
}
+static int ac3_probe(AVProbeData *p)
+{
+ int max_frames, first_frames, frames;
+ uint8_t *buf, *buf2, *end;
+ AC3HeaderInfo hdr;
+
+ if(p->buf_size < 7)
+ return 0;
+
+ max_frames = 0;
+ buf = p->buf;
+ end = buf + FFMIN(4096, p->buf_size - 7);
+
+ for(; buf < end; buf++) {
+ buf2 = buf;
+
+ for(frames = 0; buf2 < end; frames++) {
+ if(ff_ac3_parse_header(buf2, &hdr) < 0)
+ break;
+ buf2 += hdr.frame_size;
+ }
+ max_frames = FFMAX(max_frames, frames);
+ if(buf == p->buf)
+ first_frames = frames;
+ }
+ if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
+ else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
+ else if(max_frames>=1) return 1;
+ else return 0;
+}
+
AVInputFormat shorten_demuxer = {
"shn",
"raw shorten",
@@ -414,6 +446,7 @@ AVInputFormat shorten_demuxer = {
shorten_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "shn",
};
@@ -425,6 +458,7 @@ AVInputFormat flac_demuxer = {
flac_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "flac",
};
@@ -448,10 +482,11 @@ AVInputFormat ac3_demuxer = {
"ac3",
"raw ac3",
0,
- NULL,
+ ac3_probe,
ac3_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "ac3",
};
@@ -479,6 +514,7 @@ AVInputFormat dts_demuxer = {
dts_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "dts",
};
@@ -490,6 +526,7 @@ AVInputFormat aac_demuxer = {
aac_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "aac",
};
@@ -501,6 +538,7 @@ AVInputFormat h261_demuxer = {
video_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "h261",
.value = CODEC_ID_H261,
};
@@ -529,6 +567,7 @@ AVInputFormat h263_demuxer = {
video_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
// .extensions = "h263", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_H263,
};
@@ -557,6 +596,7 @@ AVInputFormat m4v_demuxer = {
video_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "m4v", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_MPEG4,
};
@@ -585,6 +625,7 @@ AVInputFormat h264_demuxer = {
video_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe
.value = CODEC_ID_H264,
};
@@ -613,6 +654,7 @@ AVInputFormat mpegvideo_demuxer = {
video_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.value = CODEC_ID_MPEG1VIDEO,
};
@@ -656,6 +698,7 @@ AVInputFormat mjpeg_demuxer = {
video_read_header,
raw_read_partial_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "mjpg,mjpeg",
.value = CODEC_ID_MJPEG,
};
@@ -668,6 +711,7 @@ AVInputFormat ingenient_demuxer = {
video_read_header,
ingenient_read_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "cgi", // FIXME
.value = CODEC_ID_MJPEG,
};
@@ -688,6 +732,18 @@ AVOutputFormat mjpeg_muxer = {
};
#endif //CONFIG_MUXERS
+AVInputFormat vc1_demuxer = {
+ "vc1",
+ "raw vc1",
+ 0,
+ NULL /* vc1_probe */,
+ video_read_header,
+ raw_read_partial_packet,
+ raw_read_close,
+ .extensions = "vc1",
+ .value = CODEC_ID_VC1,
+};
+
/* pcm formats */
#define PCMINPUTDEF(name, long_name, ext, codec) \
@@ -700,6 +756,7 @@ AVInputFormat pcm_ ## name ## _demuxer = {\
raw_read_packet,\
raw_read_close,\
pcm_read_seek,\
+ .flags= AVFMT_GENERIC_INDEX,\
.extensions = ext,\
.value = codec,\
};
@@ -797,6 +854,7 @@ AVInputFormat rawvideo_demuxer = {
raw_read_header,
rawvideo_read_packet,
raw_read_close,
+ .flags= AVFMT_GENERIC_INDEX,
.extensions = "yuv,cif,qcif",
.value = CODEC_ID_RAWVIDEO,
};
diff --git a/contrib/ffmpeg/libavformat/riff.c b/contrib/ffmpeg/libavformat/riff.c
index d315c66af..4a5553fa4 100644
--- a/contrib/ffmpeg/libavformat/riff.c
+++ b/contrib/ffmpeg/libavformat/riff.c
@@ -22,10 +22,11 @@
#include "avformat.h"
#include "avcodec.h"
#include "riff.h"
+#include "allformats.h" // for asf_muxer
/* Note: when encoding, the first matching tag is used, so order is
important if multiple tags possible for a given codec. */
-const CodecTag codec_bmp_tags[] = {
+const AVCodecTag codec_bmp_tags[] = {
{ CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
{ CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
{ CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
@@ -42,10 +43,10 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
{ CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
- { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4')},
- { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X'), .invalid_asf = 1 },
- { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0'), .invalid_asf = 1 },
- { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D'), .invalid_asf = 1 },
+ { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
+ { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
+ { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
+ { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
{ CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
{ CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
{ CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */
@@ -60,7 +61,7 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
- { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3'), .invalid_asf = 1 }, /* default signature when using MSMPEG4 */
+ { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
{ CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
/* added based on MPlayer */
@@ -101,6 +102,9 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
{ CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */
{ CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */
+ { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
+ { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
+ { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') },
{ CODEC_ID_JPEGLS, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */
{ CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
{ CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
@@ -118,6 +122,8 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
{ CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
+ { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
+ { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
{ CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
{ CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
{ CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
@@ -150,6 +156,7 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
{ CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
{ CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
+ { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
{ CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
{ CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
{ CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
@@ -163,10 +170,11 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_CAVS, MKTAG('C', 'A', 'V', 'S') },
{ CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
{ CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
+ { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
{ CODEC_ID_NONE, 0 },
};
-const CodecTag codec_wav_tags[] = {
+const AVCodecTag codec_wav_tags[] = {
{ CODEC_ID_MP2, 0x50 },
{ CODEC_ID_MP3, 0x55 },
{ CODEC_ID_AC3, 0x2000 },
@@ -195,6 +203,7 @@ const CodecTag codec_wav_tags[] = {
{ CODEC_ID_TRUESPEECH, 0x22 },
{ CODEC_ID_FLAC, 0xF1AC },
{ CODEC_ID_IMC, 0x401 },
+ { CODEC_ID_GSM_MS, 0x31 },
/* FIXME: All of the IDs below are not 16 bit and thus illegal. */
// for NuppelVideo (nuv.c)
@@ -204,7 +213,7 @@ const CodecTag codec_wav_tags[] = {
{ 0, 0 },
};
-unsigned int codec_get_tag(const CodecTag *tags, int id)
+unsigned int codec_get_tag(const AVCodecTag *tags, int id)
{
while (tags->id != CODEC_ID_NONE) {
if (tags->id == id)
@@ -214,17 +223,7 @@ unsigned int codec_get_tag(const CodecTag *tags, int id)
return 0;
}
-unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id)
-{
- while (tags->id != CODEC_ID_NONE) {
- if (!tags->invalid_asf && tags->id == id)
- return tags->tag;
- tags++;
- }
- return 0;
-}
-
-enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
+enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
{
while (tags->id != CODEC_ID_NONE) {
if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
@@ -237,6 +236,26 @@ enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
return CODEC_ID_NONE;
}
+unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
+{
+ int i;
+ for(i=0; tags && tags[i]; i++){
+ int tag= codec_get_tag(tags[i], id);
+ if(tag) return tag;
+ }
+ return 0;
+}
+
+enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
+{
+ int i;
+ for(i=0; tags && tags[i]; i++){
+ enum CodecID id= codec_get_id(tags[i], tag);
+ if(id!=CODEC_ID_NONE) return id;
+ }
+ return CODEC_ID_NONE;
+}
+
unsigned int codec_get_bmp_tag(int id)
{
return codec_get_tag(codec_bmp_tags, id);
@@ -283,8 +302,6 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
int hdrsize = 18;
if(!enc->codec_tag || enc->codec_tag > 0xffff)
- enc->codec_tag = codec_get_tag(codec_wav_tags, enc->codec_id);
- if(!enc->codec_tag || enc->codec_tag > 0xffff)
return -1;
put_le16(pb, enc->codec_tag);
@@ -294,7 +311,7 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
enc->codec_id == CODEC_ID_PCM_ALAW ||
enc->codec_id == CODEC_ID_PCM_MULAW) {
bps = 8;
- } else if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
+ } else if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) {
bps = 0;
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV || enc->codec_id == CODEC_ID_ADPCM_MS || enc->codec_id == CODEC_ID_ADPCM_G726 || enc->codec_id == CODEC_ID_ADPCM_YAMAHA) { //
bps = 4;
@@ -305,8 +322,11 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
} else {
bps = 16;
}
+ if(bps != enc->bits_per_sample && enc->bits_per_sample){
+ av_log(enc, AV_LOG_WARNING, "requested bits_per_sample (%d) and actually stored (%d) differ\n", enc->bits_per_sample, bps);
+ }
- if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) {
+ if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) {
blkalign = enc->frame_size; //this is wrong, but seems many demuxers dont work if this is set correctly
//blkalign = 144 * enc->bit_rate/enc->sample_rate;
} else if (enc->codec_id == CODEC_ID_ADPCM_G726) { //
@@ -345,10 +365,14 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
put_le16(pb, 16); /* fwHeadFlags */
put_le32(pb, 0); /* dwPTSLow */
put_le32(pb, 0); /* dwPTSHigh */
+ } else if (enc->codec_id == CODEC_ID_GSM_MS) {
+ put_le16(pb, 2); /* wav_extra_size */
+ hdrsize += 2;
+ put_le16(pb, enc->frame_size); /* wSamplesPerBlock */
} else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
put_le16(pb, 2); /* wav_extra_size */
hdrsize += 2;
- put_le16(pb, ((enc->block_align - 4 * enc->channels) / (4 * enc->channels)) * 8 + 1); /* wSamplesPerBlock */
+ put_le16(pb, enc->frame_size); /* wSamplesPerBlock */
} else if(enc->extradata_size){
put_le16(pb, enc->extradata_size);
put_buffer(pb, enc->extradata, enc->extradata_size);
@@ -365,7 +389,7 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
}
/* BITMAPINFOHEADER header */
-void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf)
+void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
{
put_le32(pb, 40 + enc->extradata_size); /* size */
put_le32(pb, enc->width);
@@ -374,7 +398,7 @@ void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags
put_le16(pb, enc->bits_per_sample ? enc->bits_per_sample : 24); /* depth */
/* compression type */
- put_le32(pb, for_asf ? (enc->codec_tag ? enc->codec_tag : codec_get_asf_tag(tags, enc->codec_id)) : enc->codec_tag); //
+ put_le32(pb, enc->codec_tag);
put_le32(pb, enc->width * enc->height * 3);
put_le32(pb, 0);
put_le32(pb, 0);
@@ -411,22 +435,30 @@ void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size)
codec->bits_per_sample = 8;
}else
codec->bits_per_sample = get_le16(pb);
- codec->codec_id = wav_codec_get_id(id, codec->bits_per_sample);
-
- if (size > 16) { /* We're obviously dealing with WAVEFORMATEX */
- codec->extradata_size = get_le16(pb);
- if (codec->extradata_size > 0) {
- if (codec->extradata_size > size - 18)
- codec->extradata_size = size - 18;
+ if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */
+ int cbSize = get_le16(pb); /* cbSize */
+ size -= 18;
+ cbSize = FFMIN(size, cbSize);
+ if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
+ codec->bits_per_sample = get_le16(pb);
+ get_le32(pb); /* dwChannelMask */
+ id = get_le32(pb); /* 4 first bytes of GUID */
+ url_fskip(pb, 12); /* skip end of GUID */
+ cbSize -= 22;
+ size -= 22;
+ }
+ codec->extradata_size = cbSize;
+ if (cbSize > 0) {
codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, codec->extradata, codec->extradata_size);
- } else
- codec->extradata_size = 0;
+ size -= cbSize;
+ }
/* It is possible for the chunk to contain garbage at the end */
- if (size - codec->extradata_size - 18 > 0)
- url_fskip(pb, size - codec->extradata_size - 18);
+ if (size > 0)
+ url_fskip(pb, size);
}
+ codec->codec_id = wav_codec_get_id(id, codec->bits_per_sample);
}
diff --git a/contrib/ffmpeg/libavformat/riff.h b/contrib/ffmpeg/libavformat/riff.h
index 240855a8b..45c72dde6 100644
--- a/contrib/ffmpeg/libavformat/riff.h
+++ b/contrib/ffmpeg/libavformat/riff.h
@@ -19,33 +19,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * @file riff.h
+ * internal header for RIFF based (de)muxers
+ * do NOT include this in end user applications
+ */
+
#ifndef FF_RIFF_H
#define FF_RIFF_H
offset_t start_tag(ByteIOContext *pb, const char *tag);
void end_tag(ByteIOContext *pb, offset_t start);
-typedef struct CodecTag {
+typedef struct AVCodecTag {
int id;
unsigned int tag;
- unsigned int invalid_asf : 1;
-} CodecTag;
+} AVCodecTag;
-void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf);
+void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
int put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
int wav_codec_get_id(unsigned int tag, int bps);
void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size);
-extern const CodecTag codec_bmp_tags[];
-extern const CodecTag codec_wav_tags[];
+extern const AVCodecTag codec_bmp_tags[];
+extern const AVCodecTag codec_wav_tags[];
-unsigned int codec_get_tag(const CodecTag *tags, int id);
-enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag);
-unsigned int codec_get_bmp_tag(int id);
-unsigned int codec_get_wav_tag(int id);
-enum CodecID codec_get_bmp_id(unsigned int tag);
-enum CodecID codec_get_wav_id(unsigned int tag);
-unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id);
+unsigned int codec_get_tag(const AVCodecTag *tags, int id);
+enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag);
+unsigned int codec_get_bmp_tag(int id) attribute_deprecated; //use av_codec_get_tag
+unsigned int codec_get_wav_tag(int id) attribute_deprecated; //use av_codec_get_tag
+enum CodecID codec_get_bmp_id(unsigned int tag) attribute_deprecated; //use av_codec_get_id
+enum CodecID codec_get_wav_id(unsigned int tag) attribute_deprecated; //use av_codec_get_id
void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale);
#endif
diff --git a/contrib/ffmpeg/libavformat/rm.c b/contrib/ffmpeg/libavformat/rm.c
index b4ddf1b02..ad2f5ff27 100644
--- a/contrib/ffmpeg/libavformat/rm.c
+++ b/contrib/ffmpeg/libavformat/rm.c
@@ -954,9 +954,8 @@ resync:
len=len2;
rm->remaining_len-= len;
av_get_packet(pb, pkt, len);
- }
- if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+ } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
if ((st->codec->codec_id == CODEC_ID_RA_288) ||
(st->codec->codec_id == CODEC_ID_COOK)) {
int x;
@@ -1008,7 +1007,9 @@ resync:
}
} else
av_get_packet(pb, pkt, len);
- }
+
+ } else
+ av_get_packet(pb, pkt, len);
if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))
|| st->discard >= AVDISCARD_ALL){
diff --git a/contrib/ffmpeg/libavformat/rtp.c b/contrib/ffmpeg/libavformat/rtp.c
index 37a286289..493a89cf3 100644
--- a/contrib/ffmpeg/libavformat/rtp.c
+++ b/contrib/ffmpeg/libavformat/rtp.c
@@ -23,15 +23,7 @@
#include "bitstream.h"
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
-#include <netdb.h>
+#include "network.h"
#include "rtp_internal.h"
#include "rtp_h264.h"
@@ -215,7 +207,6 @@ int rtp_get_codec_info(AVCodecContext *codec, int payload_type)
return -1;
}
-/* return < 0 if unknown payload type */
int rtp_get_payload_type(AVCodecContext *codec)
{
int i, payload_type;
@@ -344,11 +335,6 @@ static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp, uint32
}
#endif
-/**
- * some rtp servers assume client is dead if they don't hear from them...
- * so we send a Receiver Report to the provided ByteIO context
- * (we don't have access to the rtcp handle from here)
- */
int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
{
ByteIOContext pb;
@@ -508,7 +494,7 @@ static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf)
/* decode the first 2 bytes where are stored the AUHeader sections
length in bits */
- au_headers_length = BE_16(buf);
+ au_headers_length = AV_RB16(buf);
if (au_headers_length > RTP_MAX_PACKET_LENGTH)
return -1;
diff --git a/contrib/ffmpeg/libavformat/rtp.h b/contrib/ffmpeg/libavformat/rtp.h
index 60ccc50ee..fec763051 100644
--- a/contrib/ffmpeg/libavformat/rtp.h
+++ b/contrib/ffmpeg/libavformat/rtp.h
@@ -26,6 +26,8 @@
int rtp_init(void);
int rtp_get_codec_info(AVCodecContext *codec, int payload_type);
+
+/** return < 0 if unknown payload type */
int rtp_get_payload_type(AVCodecContext *codec);
typedef struct RTPDemuxContext RTPDemuxContext;
@@ -42,17 +44,24 @@ int rtp_get_local_port(URLContext *h);
int rtp_set_remote_url(URLContext *h, const char *uri);
void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
+/**
+ * some rtp servers assume client is dead if they don't hear from them...
+ * so we send a Receiver Report to the provided ByteIO context
+ * (we don't have access to the rtcp handle from here)
+ */
+int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
+
extern URLProtocol rtp_protocol;
#define RTP_PT_PRIVATE 96
#define RTP_VERSION 2
-#define RTP_MAX_SDES 256 /* maximum text length for SDES */
+#define RTP_MAX_SDES 256 /**< maximum text length for SDES */
/* RTCP paquets use 0.5 % of the bandwidth */
#define RTCP_TX_RATIO_NUM 5
#define RTCP_TX_RATIO_DEN 1000
-/* Structure listing usefull vars to parse RTP packet payload*/
+/** Structure listing useful vars to parse RTP packet payload*/
typedef struct rtp_payload_data_s
{
int sizelength;
@@ -63,7 +72,7 @@ typedef struct rtp_payload_data_s
int objecttype;
char *mode;
- /* mpeg 4 AU headers */
+ /** mpeg 4 AU headers */
struct AUHeaders {
int size;
int index;
diff --git a/contrib/ffmpeg/libavformat/rtp_h264.c b/contrib/ffmpeg/libavformat/rtp_h264.c
index 2568e9ea5..d38e8780d 100644
--- a/contrib/ffmpeg/libavformat/rtp_h264.c
+++ b/contrib/ffmpeg/libavformat/rtp_h264.c
@@ -41,16 +41,8 @@
#include "bitstream.h"
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include "network.h"
#include <assert.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
-#include <netdb.h>
#include "rtp_internal.h"
#include "rtp_h264.h"
@@ -172,7 +164,9 @@ static int h264_handle_packet(RTPDemuxContext * s,
const uint8_t * buf,
int len)
{
-// h264_rtp_extra_data *data = s->dynamic_protocol_context;
+#ifdef DEBUG
+ h264_rtp_extra_data *data = s->dynamic_protocol_context;
+#endif
uint8_t nal = buf[0];
uint8_t type = (nal & 0x1f);
int result= 0;
@@ -213,7 +207,7 @@ static int h264_handle_packet(RTPDemuxContext * s,
int src_len= len;
do {
- uint16_t nal_size = BE_16(src); // this going to be a problem if unaligned (can it be?)
+ uint16_t nal_size = AV_RB16(src); // this going to be a problem if unaligned (can it be?)
// consume the length of the aggregate...
src += 2;
diff --git a/contrib/ffmpeg/libavformat/rtpproto.c b/contrib/ffmpeg/libavformat/rtpproto.c
index d31c509c2..4d32e667d 100644
--- a/contrib/ffmpeg/libavformat/rtpproto.c
+++ b/contrib/ffmpeg/libavformat/rtpproto.c
@@ -22,15 +22,7 @@
#include <unistd.h>
#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
-#include <netdb.h>
+#include "network.h"
#include <fcntl.h>
#define RTP_TX_BUF_SIZE (64 * 1024)
@@ -96,7 +88,7 @@ static void build_udp_url(char *buf, int buf_size,
if (local_port >= 0)
url_add_option(buf, buf_size, "localport=%d", local_port);
if (multicast)
- url_add_option(buf, buf_size, "multicast=1", multicast);
+ url_add_option(buf, buf_size, "multicast=1");
if (ttl >= 0)
url_add_option(buf, buf_size, "ttl=%d", ttl);
}
@@ -121,7 +113,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
s = av_mallocz(sizeof(RTPContext));
if (!s)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
h->priv_data = s;
url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
diff --git a/contrib/ffmpeg/libavformat/rtsp.c b/contrib/ffmpeg/libavformat/rtsp.c
index 787cdd685..7d4c6bf78 100644
--- a/contrib/ffmpeg/libavformat/rtsp.c
+++ b/contrib/ffmpeg/libavformat/rtsp.c
@@ -20,15 +20,9 @@
*/
#include "avformat.h"
-#include <unistd.h> /* for select() prototype */
#include <sys/time.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
+#include <unistd.h> /* for select() prototype */
+#include "network.h"
#include "rtp_internal.h"
@@ -823,7 +817,6 @@ static void rtsp_send_cmd(AVFormatContext *s,
*content_ptr = content;
}
-/* useful for modules: set RTSP callback function */
void rtsp_set_callback(FFRTSPCallback *rtsp_cb)
{
diff --git a/contrib/ffmpeg/libavformat/rtsp.h b/contrib/ffmpeg/libavformat/rtsp.h
index c08aaa6ac..481e2ba49 100644
--- a/contrib/ffmpeg/libavformat/rtsp.h
+++ b/contrib/ffmpeg/libavformat/rtsp.h
@@ -21,12 +21,7 @@
#ifndef RTSP_H
#define RTSP_H
-/* RTSP handling */
-enum RTSPStatusCode {
-#define DEF(n, c, s) c = n,
#include "rtspcodes.h"
-#undef DEF
-};
enum RTSPProtocol {
RTSP_PROTOCOL_RTP_UDP = 0,
@@ -43,27 +38,27 @@ enum RTSPProtocol {
#define RTSP_RTP_PORT_MAX 10000
typedef struct RTSPTransportField {
- int interleaved_min, interleaved_max; /* interleave ids, if TCP transport */
- int port_min, port_max; /* RTP ports */
- int client_port_min, client_port_max; /* RTP ports */
- int server_port_min, server_port_max; /* RTP ports */
- int ttl; /* ttl value */
- uint32_t destination; /* destination IP address */
+ int interleaved_min, interleaved_max; /**< interleave ids, if TCP transport */
+ int port_min, port_max; /**< RTP ports */
+ int client_port_min, client_port_max; /**< RTP ports */
+ int server_port_min, server_port_max; /**< RTP ports */
+ int ttl; /**< ttl value */
+ uint32_t destination; /**< destination IP address */
enum RTSPProtocol protocol;
} RTSPTransportField;
typedef struct RTSPHeader {
int content_length;
- enum RTSPStatusCode status_code; /* response code from server */
+ enum RTSPStatusCode status_code; /**< response code from server */
int nb_transports;
- /* in AV_TIME_BASE unit, AV_NOPTS_VALUE if not used */
+ /** in AV_TIME_BASE unit, AV_NOPTS_VALUE if not used */
int64_t range_start, range_end;
RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
- int seq; /* sequence number */
+ int seq; /**< sequence number */
char session_id[512];
} RTSPHeader;
-/* the callback can be used to extend the connection setup/teardown step */
+/** the callback can be used to extend the connection setup/teardown step */
enum RTSPCallbackAction {
RTSP_ACTION_SERVER_SETUP,
RTSP_ACTION_SERVER_TEARDOWN,
@@ -81,6 +76,7 @@ typedef int FFRTSPCallback(enum RTSPCallbackAction action,
char *buf, int buf_size,
void *arg);
+/** useful for modules: set RTSP callback function */
void rtsp_set_callback(FFRTSPCallback *rtsp_cb);
int rtsp_init(void);
diff --git a/contrib/ffmpeg/libavformat/rtspcodes.h b/contrib/ffmpeg/libavformat/rtspcodes.h
index f7aab31c9..74cfb5d5b 100644
--- a/contrib/ffmpeg/libavformat/rtspcodes.h
+++ b/contrib/ffmpeg/libavformat/rtspcodes.h
@@ -18,14 +18,19 @@
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-DEF(200, RTSP_STATUS_OK, "OK")
-DEF(405, RTSP_STATUS_METHOD, "Method Not Allowed")
-DEF(453, RTSP_STATUS_BANDWIDTH, "Not Enough Bandwidth")
-DEF(454, RTSP_STATUS_SESSION, "Session Not Found")
-DEF(455, RTSP_STATUS_STATE, "Method Not Valid in This State")
-DEF(459, RTSP_STATUS_AGGREGATE, "Aggregate operation not allowed")
-DEF(460, RTSP_STATUS_ONLY_AGGREGATE, "Only aggregate operation allowed")
-DEF(461, RTSP_STATUS_TRANSPORT, "Unsupported transport")
-DEF(500, RTSP_STATUS_INTERNAL, "Internal Server Error")
-DEF(503, RTSP_STATUS_SERVICE, "Service Unavailable")
-DEF(505, RTSP_STATUS_VERSION, "RTSP Version not supported")
+
+/** RTSP handling */
+enum RTSPStatusCode {
+RTSP_STATUS_OK =200, /**< OK */
+RTSP_STATUS_METHOD =405, /**< Method Not Allowed */
+RTSP_STATUS_BANDWIDTH =453, /**< Not Enough Bandwidth */
+RTSP_STATUS_SESSION =454, /**< Session Not Found */
+RTSP_STATUS_STATE =455, /**< Method Not Valid in This State */
+RTSP_STATUS_AGGREGATE =459, /**< Aggregate operation not allowed */
+RTSP_STATUS_ONLY_AGGREGATE =460, /**< Only aggregate operation allowed */
+RTSP_STATUS_TRANSPORT =461, /**< Unsupported transport */
+RTSP_STATUS_INTERNAL =500, /**< Internal Server Error */
+RTSP_STATUS_SERVICE =503, /**< Service Unavailable */
+RTSP_STATUS_VERSION =505, /**< RTSP Version not supported */
+};
+
diff --git a/contrib/ffmpeg/libavformat/segafilm.c b/contrib/ffmpeg/libavformat/segafilm.c
index 4feb97262..b5375ccf7 100644
--- a/contrib/ffmpeg/libavformat/segafilm.c
+++ b/contrib/ffmpeg/libavformat/segafilm.c
@@ -58,8 +58,6 @@ typedef struct FilmDemuxContext {
unsigned int base_clock;
unsigned int version;
- int cvid_extra_bytes; /* the number of bytes thrown into the Cinepak
- * chunk header to throw off decoders */
/* buffer used for interleaving stereo PCM data */
unsigned char *stereo_buffer;
@@ -71,7 +69,7 @@ static int film_probe(AVProbeData *p)
if (p->buf_size < 4)
return 0;
- if (BE_32(&p->buf[0]) != FILM_TAG)
+ if (AV_RB32(&p->buf[0]) != FILM_TAG)
return 0;
return AVPROBE_SCORE_MAX;
@@ -95,8 +93,8 @@ static int film_read_header(AVFormatContext *s,
/* load the main FILM header */
if (get_buffer(pb, scratch, 16) != 16)
return AVERROR_IO;
- data_offset = BE_32(&scratch[4]);
- film->version = BE_32(&scratch[8]);
+ data_offset = AV_RB32(&scratch[4]);
+ film->version = AV_RB32(&scratch[8]);
/* load the FDSC chunk */
if (film->version == 0) {
@@ -112,7 +110,7 @@ static int film_read_header(AVFormatContext *s,
/* normal Saturn .cpk files; 32-byte header */
if (get_buffer(pb, scratch, 32) != 32)
return AVERROR_IO;
- film->audio_samplerate = BE_16(&scratch[24]);;
+ film->audio_samplerate = AV_RB16(&scratch[24]);;
film->audio_channels = scratch[21];
film->audio_bits = scratch[22];
if (film->audio_bits == 8)
@@ -123,16 +121,11 @@ static int film_read_header(AVFormatContext *s,
film->audio_type = 0;
}
- if (BE_32(&scratch[0]) != FDSC_TAG)
+ if (AV_RB32(&scratch[0]) != FDSC_TAG)
return AVERROR_INVALIDDATA;
- film->cvid_extra_bytes = 0;
- if (BE_32(&scratch[8]) == CVID_TAG) {
+ if (AV_RB32(&scratch[8]) == CVID_TAG) {
film->video_type = CODEC_ID_CINEPAK;
- if (film->version)
- film->cvid_extra_bytes = 2;
- else
- film->cvid_extra_bytes = 6; /* Lemmings 3DO case */
} else
film->video_type = 0;
@@ -145,8 +138,8 @@ static int film_read_header(AVFormatContext *s,
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = film->video_type;
st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = BE_32(&scratch[16]);
- st->codec->height = BE_32(&scratch[12]);
+ st->codec->width = AV_RB32(&scratch[16]);
+ st->codec->height = AV_RB32(&scratch[12]);
}
if (film->audio_type) {
@@ -169,10 +162,10 @@ static int film_read_header(AVFormatContext *s,
/* load the sample table */
if (get_buffer(pb, scratch, 16) != 16)
return AVERROR_IO;
- if (BE_32(&scratch[0]) != STAB_TAG)
+ if (AV_RB32(&scratch[0]) != STAB_TAG)
return AVERROR_INVALIDDATA;
- film->base_clock = BE_32(&scratch[8]);
- film->sample_count = BE_32(&scratch[12]);
+ film->base_clock = AV_RB32(&scratch[8]);
+ film->sample_count = AV_RB32(&scratch[12]);
if(film->sample_count >= UINT_MAX / sizeof(film_sample_t))
return -1;
film->sample_table = av_malloc(film->sample_count * sizeof(film_sample_t));
@@ -188,9 +181,9 @@ static int film_read_header(AVFormatContext *s,
return AVERROR_IO;
}
film->sample_table[i].sample_offset =
- data_offset + BE_32(&scratch[0]);
- film->sample_table[i].sample_size = BE_32(&scratch[4]);
- if (BE_32(&scratch[8]) == 0xFFFFFFFF) {
+ data_offset + AV_RB32(&scratch[0]);
+ film->sample_table[i].sample_size = AV_RB32(&scratch[4]);
+ if (AV_RB32(&scratch[8]) == 0xFFFFFFFF) {
film->sample_table[i].stream = film->audio_stream_index;
film->sample_table[i].pts = audio_frame_counter;
film->sample_table[i].pts *= film->base_clock;
@@ -200,7 +193,7 @@ static int film_read_header(AVFormatContext *s,
(film->audio_channels * film->audio_bits / 8));
} else {
film->sample_table[i].stream = film->video_stream_index;
- film->sample_table[i].pts = BE_32(&scratch[8]) & 0x7FFFFFFF;
+ film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
}
}
@@ -231,18 +224,10 @@ static int film_read_packet(AVFormatContext *s,
/* do a special song and dance when loading FILM Cinepak chunks */
if ((sample->stream == film->video_stream_index) &&
(film->video_type == CODEC_ID_CINEPAK)) {
- if (av_new_packet(pkt, sample->sample_size - film->cvid_extra_bytes))
- return AVERROR_NOMEM;
- if(pkt->size < 10)
- return -1;
pkt->pos= url_ftell(pb);
- ret = get_buffer(pb, pkt->data, 10);
- /* skip the non-spec CVID bytes */
- url_fseek(pb, film->cvid_extra_bytes, SEEK_CUR);
- ret += get_buffer(pb, pkt->data + 10,
- sample->sample_size - 10 - film->cvid_extra_bytes);
- if (ret != sample->sample_size - film->cvid_extra_bytes)
- ret = AVERROR_IO;
+ if (av_new_packet(pkt, sample->sample_size))
+ return AVERROR_NOMEM;
+ get_buffer(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2)) {
/* stereo PCM needs to be interleaved */
diff --git a/contrib/ffmpeg/libavformat/sgi.c b/contrib/ffmpeg/libavformat/sgi.c
deleted file mode 100644
index bf0297e81..000000000
--- a/contrib/ffmpeg/libavformat/sgi.c
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * SGI image format
- * Todd Kirby <doubleshot@pacbell.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 "avformat.h"
-#include "avio.h"
-
-/* #define DEBUG */
-
-/* sgi image file signature */
-#define SGI_MAGIC 474
-
-#define SGI_HEADER_SIZE 512
-
-#define SGI_GRAYSCALE 1
-#define SGI_RGB 3
-#define SGI_RGBA 4
-
-#define SGI_SINGLE_CHAN 2
-#define SGI_MULTI_CHAN 3
-
-typedef struct SGIInfo{
- short magic;
- char rle;
- char bytes_per_channel;
- unsigned short dimension;
- unsigned short xsize;
- unsigned short ysize;
- unsigned short zsize;
-} SGIInfo;
-
-
-static int sgi_probe(AVProbeData *pd)
-{
- /* test for sgi magic */
- if (pd->buf_size >= 2 && BE_16(&pd->buf[0]) == SGI_MAGIC) {
- return AVPROBE_SCORE_MAX;
- } else {
- return 0;
- }
-}
-
-/* read sgi header fields */
-static void read_sgi_header(ByteIOContext *f, SGIInfo *info)
-{
- info->magic = (unsigned short) get_be16(f);
- info->rle = get_byte(f);
- info->bytes_per_channel = get_byte(f);
- info->dimension = (unsigned short)get_be16(f);
- info->xsize = (unsigned short) get_be16(f);
- info->ysize = (unsigned short) get_be16(f);
- info->zsize = (unsigned short) get_be16(f);
-
- if(info->zsize > 4096)
- info->zsize= 0;
-
-#ifdef DEBUG
- printf("sgi header fields:\n");
- printf(" magic: %d\n", info->magic);
- printf(" rle: %d\n", info->rle);
- printf(" bpc: %d\n", info->bytes_per_channel);
- printf(" dim: %d\n", info->dimension);
- printf(" xsize: %d\n", info->xsize);
- printf(" ysize: %d\n", info->ysize);
- printf(" zsize: %d\n", info->zsize);
-#endif
-
- return;
-}
-
-
-/* read an uncompressed sgi image */
-static int read_uncompressed_sgi(const SGIInfo *si,
- AVPicture *pict, ByteIOContext *f)
-{
- int x, y, z, chan_offset, ret = 0;
- uint8_t *dest_row;
-
- /* skip header */
- url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);
-
- pict->linesize[0] = si->xsize;
-
- for (z = 0; z < si->zsize; z++) {
-
-#ifndef WORDS_BIGENDIAN
- /* rgba -> bgra for rgba32 on little endian cpus */
- if (si->zsize == 4 && z != 3)
- chan_offset = 2 - z;
- else
-#endif
- chan_offset = z;
-
- for (y = si->ysize - 1; y >= 0; y--) {
- dest_row = pict->data[0] + (y * si->xsize * si->zsize);
-
- for (x = 0; x < si->xsize; x++) {
- dest_row[chan_offset] = get_byte(f);
- dest_row += si->zsize;
- }
- }
- }
-
- return ret;
-}
-
-
-/* expand an rle row into a channel */
-static int expand_rle_row(ByteIOContext *f, unsigned char *optr,
- int chan_offset, int pixelstride)
-{
- unsigned char pixel, count;
- int length = 0;
-
-#ifndef WORDS_BIGENDIAN
- /* rgba -> bgra for rgba32 on little endian cpus */
- if (pixelstride == 4 && chan_offset != 3) {
- chan_offset = 2 - chan_offset;
- }
-#endif
-
- optr += chan_offset;
-
- while (1) {
- pixel = get_byte(f);
-
- if (!(count = (pixel & 0x7f))) {
- return length;
- }
- if (pixel & 0x80) {
- while (count--) {
- *optr = get_byte(f);
- length++;
- optr += pixelstride;
- }
- } else {
- pixel = get_byte(f);
-
- while (count--) {
- *optr = pixel;
- length++;
- optr += pixelstride;
- }
- }
- }
-}
-
-
-/* read a run length encoded sgi image */
-static int read_rle_sgi(const SGIInfo *sgi_info,
- AVPicture *pict, ByteIOContext *f)
-{
- uint8_t *dest_row;
- unsigned long *start_table;
- int y, z, xsize, ysize, zsize, tablen;
- long start_offset;
- int ret = 0;
-
- xsize = sgi_info->xsize;
- ysize = sgi_info->ysize;
- zsize = sgi_info->zsize;
-
- /* skip header */
- url_fseek(f, SGI_HEADER_SIZE, SEEK_SET);
-
- /* size of rle offset and length tables */
- tablen = ysize * zsize * sizeof(long);
-
- start_table = (unsigned long *)av_malloc(tablen);
-
- if (!get_buffer(f, (uint8_t *)start_table, tablen)) {
- ret = AVERROR_IO;
- goto fail;
- }
-
- /* skip run length table */
- url_fseek(f, tablen, SEEK_CUR);
-
- for (z = 0; z < zsize; z++) {
- for (y = 0; y < ysize; y++) {
- dest_row = pict->data[0] + (ysize - 1 - y) * (xsize * zsize);
-
- start_offset = BE_32(&start_table[y + z * ysize]);
-
- /* don't seek if already at the next rle start offset */
- if (url_ftell(f) != start_offset) {
- url_fseek(f, start_offset, SEEK_SET);
- }
-
- if (expand_rle_row(f, dest_row, z, zsize) != xsize) {
- ret = AVERROR_INVALIDDATA;
- goto fail;
- }
- }
- }
-
-fail:
- av_free(start_table);
-
- return ret;
-}
-
-
-static int sgi_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- SGIInfo sgi_info, *s = &sgi_info;
- AVImageInfo info1, *info = &info1;
- int ret;
-
- read_sgi_header(f, s);
-
- if (s->bytes_per_channel != 1) {
- return AVERROR_INVALIDDATA;
- }
-
- /* check for supported image dimensions */
- if (s->dimension != 2 && s->dimension != 3) {
- return AVERROR_INVALIDDATA;
- }
-
- if (s->zsize == SGI_GRAYSCALE) {
- info->pix_fmt = PIX_FMT_GRAY8;
- } else if (s->zsize == SGI_RGB) {
- info->pix_fmt = PIX_FMT_RGB24;
- } else if (s->zsize == SGI_RGBA) {
- info->pix_fmt = PIX_FMT_RGBA32;
- } else {
- return AVERROR_INVALIDDATA;
- }
-
- info->width = s->xsize;
- info->height = s->ysize;
-
- ret = alloc_cb(opaque, info);
- if (ret)
- return ret;
-
- if (s->rle) {
- return read_rle_sgi(s, &info->pict, f);
- } else {
- return read_uncompressed_sgi(s, &info->pict, f);
- }
-
- return 0; /* not reached */
-}
-
-#ifdef CONFIG_MUXERS
-static void write_sgi_header(ByteIOContext *f, const SGIInfo *info)
-{
- int i;
-
- put_be16(f, SGI_MAGIC);
- put_byte(f, info->rle);
- put_byte(f, info->bytes_per_channel);
- put_be16(f, info->dimension);
- put_be16(f, info->xsize);
- put_be16(f, info->ysize);
- put_be16(f, info->zsize);
-
- /* The rest are constant in this implementation */
- put_be32(f, 0L); /* pixmin */
- put_be32(f, 255L); /* pixmax */
- put_be32(f, 0L); /* dummy */
-
- /* name */
- for (i = 0; i < 80; i++) {
- put_byte(f, 0);
- }
-
- put_be32(f, 0L); /* colormap */
-
- /* The rest of the 512 byte header is unused. */
- for (i = 0; i < 404; i++) {
- put_byte(f, 0);
- }
-}
-
-
-static int rle_row(ByteIOContext *f, char *row, int stride, int rowsize)
-{
- int length, count, i, x;
- char *start, repeat = 0;
-
- for (x = rowsize, length = 0; x > 0;) {
- start = row;
- row += (2 * stride);
- x -= 2;
-
- while (x > 0 && (row[-2 * stride] != row[-1 * stride] ||
- row[-1 * stride] != row[0])) {
- row += stride;
- x--;
- };
-
- row -= (2 * stride);
- x += 2;
-
- count = (row - start) / stride;
- while (count > 0) {
- i = count > 126 ? 126 : count;
- count -= i;
-
- put_byte(f, 0x80 | i);
- length++;
-
- while (i > 0) {
- put_byte(f, *start);
- start += stride;
- i--;
- length++;
- };
- };
-
- if (x <= 0) {
- break;
- }
-
- start = row;
- repeat = row[0];
-
- row += stride;
- x--;
-
- while (x > 0 && *row == repeat) {
- row += stride;
- x--;
- };
-
- count = (row - start) / stride;
- while (count > 0) {
- i = count > 126 ? 126 : count;
- count -= i;
-
- put_byte(f, i);
- length++;
-
- put_byte(f, repeat);
- length++;
- };
- };
-
- length++;
-
- put_byte(f, 0);
- return (length);
-}
-
-
-static int sgi_write(ByteIOContext *pb, AVImageInfo *info)
-{
- SGIInfo sgi_info, *si = &sgi_info;
- long *offsettab, *lengthtab;
- int i, y, z;
- int tablesize, chan_offset;
- uint8_t *srcrow;
-
- si->xsize = info->width;
- si->ysize = info->height;
- si->rle = 1;
- si->bytes_per_channel = 1;
-
- switch(info->pix_fmt) {
- case PIX_FMT_GRAY8:
- si->dimension = SGI_SINGLE_CHAN;
- si->zsize = SGI_GRAYSCALE;
- break;
- case PIX_FMT_RGB24:
- si->dimension = SGI_MULTI_CHAN;
- si->zsize = SGI_RGB;
- break;
- case PIX_FMT_RGBA32:
- si->dimension = SGI_MULTI_CHAN;
- si->zsize = SGI_RGBA;
- break;
- default:
- return AVERROR_INVALIDDATA;
- }
-
- write_sgi_header(pb, si);
-
- tablesize = si->zsize * si->ysize * sizeof(long);
-
- /* skip rle offset and length tables, write them at the end. */
- url_fseek(pb, tablesize * 2, SEEK_CUR);
- put_flush_packet(pb);
-
- lengthtab = av_malloc(tablesize);
- offsettab = av_malloc(tablesize);
-
- for (z = 0; z < si->zsize; z++) {
-
-#ifndef WORDS_BIGENDIAN
- /* rgba -> bgra for rgba32 on little endian cpus */
- if (si->zsize == 4 && z != 3)
- chan_offset = 2 - z;
- else
-#endif
- chan_offset = z;
-
- srcrow = info->pict.data[0] + chan_offset;
-
- for (y = si->ysize -1; y >= 0; y--) {
- offsettab[(z * si->ysize) + y] = url_ftell(pb);
- lengthtab[(z * si->ysize) + y] = rle_row(pb, srcrow,
- si->zsize, si->xsize);
- srcrow += info->pict.linesize[0];
- }
- }
-
- url_fseek(pb, 512, SEEK_SET);
-
- /* write offset table */
- for (i = 0; i < (si->ysize * si->zsize); i++) {
- put_be32(pb, offsettab[i]);
- }
-
- /* write length table */
- for (i = 0; i < (si->ysize * si->zsize); i++) {
- put_be32(pb, lengthtab[i]);
- }
-
- put_flush_packet(pb);
-
- av_free(lengthtab);
- av_free(offsettab);
-
- return 0;
-}
-#endif // CONFIG_MUXERS
-
-AVImageFormat sgi_image_format = {
- "sgi",
- "sgi,rgb,rgba,bw",
- sgi_probe,
- sgi_read,
- (1 << PIX_FMT_GRAY8) | (1 << PIX_FMT_RGB24) | (1 << PIX_FMT_RGBA32),
-#ifdef CONFIG_MUXERS
- sgi_write,
-#else
- NULL,
-#endif // CONFIG_MUXERS
-};
diff --git a/contrib/ffmpeg/libavformat/sierravmd.c b/contrib/ffmpeg/libavformat/sierravmd.c
index 92dbce91d..3e1c8597d 100644
--- a/contrib/ffmpeg/libavformat/sierravmd.c
+++ b/contrib/ffmpeg/libavformat/sierravmd.c
@@ -64,7 +64,7 @@ static int vmd_probe(AVProbeData *p)
/* check if the first 2 bytes of the file contain the appropriate size
* of a VMD header chunk */
- if (LE_16(&p->buf[0]) != VMD_HEADER_SIZE - 2)
+ if (AV_RL16(&p->buf[0]) != VMD_HEADER_SIZE - 2)
return 0;
/* only return half certainty since this check is a bit sketchy */
@@ -103,14 +103,14 @@ static int vmd_read_header(AVFormatContext *s,
vst->codec->codec_type = CODEC_TYPE_VIDEO;
vst->codec->codec_id = CODEC_ID_VMDVIDEO;
vst->codec->codec_tag = 0; /* no fourcc */
- vst->codec->width = LE_16(&vmd->vmd_header[12]);
- vst->codec->height = LE_16(&vmd->vmd_header[14]);
+ vst->codec->width = AV_RL16(&vmd->vmd_header[12]);
+ vst->codec->height = AV_RL16(&vmd->vmd_header[14]);
vst->codec->extradata_size = VMD_HEADER_SIZE;
vst->codec->extradata = av_mallocz(VMD_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(vst->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
/* if sample rate is 0, assume no audio */
- vmd->sample_rate = LE_16(&vmd->vmd_header[804]);
+ vmd->sample_rate = AV_RL16(&vmd->vmd_header[804]);
if (vmd->sample_rate) {
st = av_new_stream(s, 0);
if (!st)
@@ -121,7 +121,7 @@ static int vmd_read_header(AVFormatContext *s,
st->codec->codec_tag = 0; /* no fourcc */
st->codec->channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1;
st->codec->sample_rate = vmd->sample_rate;
- st->codec->block_align = LE_16(&vmd->vmd_header[806]);
+ st->codec->block_align = AV_RL16(&vmd->vmd_header[806]);
if (st->codec->block_align & 0x8000) {
st->codec->bits_per_sample = 16;
st->codec->block_align = -(st->codec->block_align - 0x10000);
@@ -140,14 +140,14 @@ static int vmd_read_header(AVFormatContext *s,
pts_inc = num;
}
- toc_offset = LE_32(&vmd->vmd_header[812]);
- vmd->frame_count = LE_16(&vmd->vmd_header[6]);
- vmd->frames_per_block = LE_16(&vmd->vmd_header[18]);
+ toc_offset = AV_RL32(&vmd->vmd_header[812]);
+ vmd->frame_count = AV_RL16(&vmd->vmd_header[6]);
+ vmd->frames_per_block = AV_RL16(&vmd->vmd_header[18]);
url_fseek(pb, toc_offset, SEEK_SET);
raw_frame_table = NULL;
vmd->frame_table = NULL;
- sound_buffers = LE_16(&vmd->vmd_header[808]);
+ sound_buffers = AV_RL16(&vmd->vmd_header[808]);
raw_frame_table_size = vmd->frame_count * 6;
raw_frame_table = av_malloc(raw_frame_table_size);
if(vmd->frame_count * vmd->frames_per_block >= UINT_MAX / sizeof(vmd_frame_t)){
@@ -170,7 +170,7 @@ static int vmd_read_header(AVFormatContext *s,
total_frames = 0;
for (i = 0; i < vmd->frame_count; i++) {
- current_offset = LE_32(&raw_frame_table[6 * i + 2]);
+ current_offset = AV_RL32(&raw_frame_table[6 * i + 2]);
/* handle each entry in index block */
for (j = 0; j < vmd->frames_per_block; j++) {
@@ -179,7 +179,7 @@ static int vmd_read_header(AVFormatContext *s,
get_buffer(pb, chunk, BYTES_PER_FRAME_RECORD);
type = chunk[0];
- size = LE_32(&chunk[2]);
+ size = AV_RL32(&chunk[2]);
if(!size)
continue;
switch(type) {
diff --git a/contrib/ffmpeg/libavformat/smacker.c b/contrib/ffmpeg/libavformat/smacker.c
index a08bd2d9f..04fde3d03 100644
--- a/contrib/ffmpeg/libavformat/smacker.c
+++ b/contrib/ffmpeg/libavformat/smacker.c
@@ -226,7 +226,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
int pos;
if (url_feof(&s->pb) || smk->cur_frame >= smk->frames)
- return -EIO;
+ return AVERROR(EIO);
/* if we demuxed all streams, pass another frame */
if(smk->curstream < 0) {
@@ -311,7 +311,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->size = smk->buf_sizes[smk->curstream];
pkt->stream_index = smk->stream_id[smk->curstream];
pkt->pts = smk->aud_pts[smk->curstream];
- smk->aud_pts[smk->curstream] += LE_32(pkt->data);
+ smk->aud_pts[smk->curstream] += AV_RL32(pkt->data);
smk->curstream--;
}
diff --git a/contrib/ffmpeg/libavformat/sol.c b/contrib/ffmpeg/libavformat/sol.c
index 20e45f75d..951ec6eb9 100644
--- a/contrib/ffmpeg/libavformat/sol.c
+++ b/contrib/ffmpeg/libavformat/sol.c
@@ -29,7 +29,7 @@
#include "bswap.h"
/* if we don't know the size in advance */
-#define AU_UNKOWN_SIZE ((uint32_t)(~0))
+#define AU_UNKNOWN_SIZE ((uint32_t)(~0))
static int sol_probe(AVProbeData *p)
{
@@ -133,7 +133,7 @@ static int sol_read_packet(AVFormatContext *s,
int ret;
if (url_feof(&s->pb))
- return -EIO;
+ return AVERROR(EIO);
ret= av_get_packet(&s->pb, pkt, MAX_SIZE);
pkt->stream_index = 0;
diff --git a/contrib/ffmpeg/libavformat/swf.c b/contrib/ffmpeg/libavformat/swf.c
index 6029e3678..7d889af7d 100644
--- a/contrib/ffmpeg/libavformat/swf.c
+++ b/contrib/ffmpeg/libavformat/swf.c
@@ -59,102 +59,39 @@
#include <assert.h>
typedef struct {
-
+ int audio_stream_index;
offset_t duration_pos;
offset_t tag_pos;
int samples_per_frame;
int sound_samples;
- int video_samples;
int swf_frame_number;
int video_frame_number;
- int ms_per_frame;
- int ch_id;
+ int frame_rate;
int tag;
- uint8_t *audio_fifo;
+ uint8_t audio_fifo[AUDIO_FIFO_SIZE];
int audio_in_pos;
- int audio_out_pos;
- int audio_size;
int video_type;
int audio_type;
} SWFContext;
-static const CodecTag swf_codec_tags[] = {
+static const AVCodecTag swf_codec_tags[] = {
{CODEC_ID_FLV1, 0x02},
{CODEC_ID_VP6F, 0x04},
{0, 0},
};
-static const int sSampleRates[3][4] = {
- {44100, 48000, 32000, 0},
- {22050, 24000, 16000, 0},
- {11025, 12000, 8000, 0},
-};
-
-static const int sBitRates[2][3][15] = {
- { { 0, 32, 64, 96,128,160,192,224,256,288,320,352,384,416,448},
- { 0, 32, 48, 56, 64, 80, 96,112,128,160,192,224,256,320,384},
- { 0, 32, 40, 48, 56, 64, 80, 96,112,128,160,192,224,256,320}
- },
- { { 0, 32, 48, 56, 64, 80, 96,112,128,144,160,176,192,224,256},
- { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160},
- { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}
- },
-};
-
-static const int sSamplesPerFrame[3][3] =
-{
- { 384, 1152, 1152 },
- { 384, 1152, 576 },
- { 384, 1152, 576 }
-};
-
-static const int sBitsPerSlot[3] = {
- 32,
- 8,
- 8
+static const AVCodecTag swf_audio_codec_tags[] = {
+ {CODEC_ID_PCM_S16LE, 0x00},
+ {CODEC_ID_ADPCM_SWF, 0x01},
+ {CODEC_ID_MP3, 0x02},
+ {CODEC_ID_PCM_S16LE, 0x03},
+ //{CODEC_ID_NELLYMOSER, 0x06},
+ {0, 0},
};
-static int swf_mp3_info(void *data, int *byteSize, int *samplesPerFrame, int *sampleRate, int *isMono )
-{
- uint8_t *dataTmp = (uint8_t *)data;
- uint32_t header = ( (uint32_t)dataTmp[0] << 24 ) | ( (uint32_t)dataTmp[1] << 16 ) | ( (uint32_t)dataTmp[2] << 8 ) | (uint32_t)dataTmp[3];
- int layerID = 3 - ((header >> 17) & 0x03);
- int bitRateID = ((header >> 12) & 0x0f);
- int sampleRateID = ((header >> 10) & 0x03);
- int bitRate = 0;
- int bitsPerSlot = sBitsPerSlot[layerID];
- int isPadded = ((header >> 9) & 0x01);
-
- if ( (( header >> 21 ) & 0x7ff) != 0x7ff ) {
- return 0;
- }
-
- *isMono = ((header >> 6) & 0x03) == 0x03;
-
- if ( (header >> 19 ) & 0x01 ) {
- *sampleRate = sSampleRates[0][sampleRateID];
- bitRate = sBitRates[0][layerID][bitRateID] * 1000;
- *samplesPerFrame = sSamplesPerFrame[0][layerID];
- } else {
- if ( (header >> 20) & 0x01 ) {
- *sampleRate = sSampleRates[1][sampleRateID];
- bitRate = sBitRates[1][layerID][bitRateID] * 1000;
- *samplesPerFrame = sSamplesPerFrame[1][layerID];
- } else {
- *sampleRate = sSampleRates[2][sampleRateID];
- bitRate = sBitRates[1][layerID][bitRateID] * 1000;
- *samplesPerFrame = sSamplesPerFrame[2][layerID];
- }
- }
-
- *byteSize = ( ( ( ( *samplesPerFrame * (bitRate / bitsPerSlot) ) / *sampleRate ) + isPadded ) );
-
- return 1;
-}
-
#ifdef CONFIG_MUXERS
static void put_swf_tag(AVFormatContext *s, int tag)
{
@@ -306,25 +243,15 @@ static void put_swf_matrix(ByteIOContext *pb,
/* */
static int swf_write_header(AVFormatContext *s)
{
- SWFContext *swf;
+ SWFContext *swf = s->priv_data;
ByteIOContext *pb = &s->pb;
AVCodecContext *enc, *audio_enc, *video_enc;
PutBitContext p;
uint8_t buf1[256];
int i, width, height, rate, rate_base;
- swf = av_malloc(sizeof(SWFContext));
- if (!swf)
- return -1;
- s->priv_data = swf;
-
- swf->ch_id = -1;
swf->audio_in_pos = 0;
- swf->audio_out_pos = 0;
- swf->audio_size = 0;
- swf->audio_fifo = av_malloc(AUDIO_FIFO_SIZE);
swf->sound_samples = 0;
- swf->video_samples = 0;
swf->swf_frame_number = 0;
swf->video_frame_number = 0;
@@ -332,15 +259,24 @@ static int swf_write_header(AVFormatContext *s)
audio_enc = NULL;
for(i=0;i<s->nb_streams;i++) {
enc = s->streams[i]->codec;
- if (enc->codec_type == CODEC_TYPE_AUDIO)
- audio_enc = enc;
- else {
+ if (enc->codec_type == CODEC_TYPE_AUDIO) {
+ if (enc->codec_id == CODEC_ID_MP3) {
+ if (!enc->frame_size) {
+ av_log(s, AV_LOG_ERROR, "audio frame size not set\n");
+ return -1;
+ }
+ audio_enc = enc;
+ } else {
+ av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
+ return -1;
+ }
+ } else {
if ( enc->codec_id == CODEC_ID_VP6F ||
enc->codec_id == CODEC_ID_FLV1 ||
enc->codec_id == CODEC_ID_MJPEG ) {
video_enc = enc;
} else {
- av_log(enc, AV_LOG_ERROR, "SWF only supports VP6, FLV1 and MJPEG\n");
+ av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n");
return -1;
}
}
@@ -451,8 +387,6 @@ static int swf_write_header(AVFormatContext *s)
default:
/* not supported */
av_log(s, AV_LOG_ERROR, "swf doesnt support that sample rate, choose from (44100, 22050, 11025)\n");
- av_free(swf->audio_fifo);
- av_free(swf);
return -1;
}
v |= 0x02; /* 16 bit playback */
@@ -476,55 +410,12 @@ static int swf_write_video(AVFormatContext *s,
{
SWFContext *swf = s->priv_data;
ByteIOContext *pb = &s->pb;
- int c = 0;
- int outSize = 0;
- int outSamples = 0;
/* Flash Player limit */
if ( swf->swf_frame_number == 16000 ) {
av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
}
- if ( swf->audio_type ) {
- /* Prescan audio data for this swf frame */
-retry_swf_audio_packet:
- if ( ( swf->audio_size-outSize ) >= 4 ) {
- int mp3FrameSize = 0;
- int mp3SampleRate = 0;
- int mp3IsMono = 0;
- int mp3SamplesPerFrame = 0;
-
- /* copy out mp3 header from ring buffer */
- uint8_t header[4];
- for (c=0; c<4; c++) {
- header[c] = swf->audio_fifo[(swf->audio_in_pos+outSize+c) % AUDIO_FIFO_SIZE];
- }
-
- if ( swf_mp3_info(header,&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {
- if ( ( swf->audio_size-outSize ) >= mp3FrameSize ) {
- outSize += mp3FrameSize;
- outSamples += mp3SamplesPerFrame;
- if ( ( swf->sound_samples + outSamples + swf->samples_per_frame ) < swf->video_samples ) {
- goto retry_swf_audio_packet;
- }
- }
- } else {
- /* invalid mp3 data, skip forward
- we need to do this since the Flash Player
- does not like custom headers */
- swf->audio_in_pos ++;
- swf->audio_size --;
- swf->audio_in_pos %= AUDIO_FIFO_SIZE;
- goto retry_swf_audio_packet;
- }
- }
-
- /* audio stream is behind video stream, bail */
- if ( ( swf->sound_samples + outSamples + swf->samples_per_frame ) < swf->video_samples ) {
- return 0;
- }
- }
-
if ( swf->video_type == CODEC_ID_VP6F ||
swf->video_type == CODEC_ID_FLV1 ) {
if ( swf->video_frame_number == 0 ) {
@@ -608,23 +499,17 @@ retry_swf_audio_packet:
swf->swf_frame_number ++;
- swf->video_samples += swf->samples_per_frame;
-
/* streaming sound always should be placed just before showframe tags */
- if ( outSize > 0 ) {
+ if (swf->audio_type && swf->audio_in_pos) {
put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
- put_le16(pb, outSamples);
- put_le16(pb, 0);
- for (c=0; c<outSize; c++) {
- put_byte(pb,swf->audio_fifo[(swf->audio_in_pos+c) % AUDIO_FIFO_SIZE]);
- }
+ put_le16(pb, swf->sound_samples);
+ put_le16(pb, 0); // seek samples
+ put_buffer(pb, swf->audio_fifo, swf->audio_in_pos);
put_swf_end_tag(s);
/* update FIFO */
- swf->sound_samples += outSamples;
- swf->audio_in_pos += outSize;
- swf->audio_size -= outSize;
- swf->audio_in_pos %= AUDIO_FIFO_SIZE;
+ swf->sound_samples = 0;
+ swf->audio_in_pos = 0;
}
/* output the frame */
@@ -640,22 +525,21 @@ static int swf_write_audio(AVFormatContext *s,
AVCodecContext *enc, const uint8_t *buf, int size)
{
SWFContext *swf = s->priv_data;
- int c = 0;
/* Flash Player limit */
if ( swf->swf_frame_number == 16000 ) {
av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
}
- if (enc->codec_id == CODEC_ID_MP3 ) {
- for (c=0; c<size; c++) {
- swf->audio_fifo[(swf->audio_out_pos+c)%AUDIO_FIFO_SIZE] = buf[c];
- }
- swf->audio_size += size;
- swf->audio_out_pos += size;
- swf->audio_out_pos %= AUDIO_FIFO_SIZE;
+ if (swf->audio_in_pos + size >= AUDIO_FIFO_SIZE) {
+ av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
+ return -1;
}
+ memcpy(swf->audio_fifo + swf->audio_in_pos, buf, size);
+ swf->audio_in_pos += size;
+ swf->sound_samples += enc->frame_size;
+
/* if audio only stream make sure we add swf frames */
if ( swf->video_type == 0 ) {
swf_write_video(s, enc, 0, 0);
@@ -699,10 +583,8 @@ static int swf_write_trailer(AVFormatContext *s)
put_le32(pb, file_size);
url_fseek(pb, swf->duration_pos, SEEK_SET);
put_le16(pb, video_enc->frame_number);
+ url_fseek(pb, file_size, SEEK_SET);
}
-
- av_free(swf->audio_fifo);
-
return 0;
}
#endif //CONFIG_MUXERS
@@ -747,18 +629,13 @@ static int swf_probe(AVProbeData *p)
static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
- SWFContext *swf = 0;
+ SWFContext *swf = s->priv_data;
ByteIOContext *pb = &s->pb;
- int nbits, len, frame_rate, tag, v;
- offset_t firstTagOff;
+ int nbits, len, tag, v;
+ offset_t frame_offset = -1;
AVStream *ast = 0;
AVStream *vst = 0;
- swf = av_malloc(sizeof(SWFContext));
- if (!swf)
- return -1;
- s->priv_data = swf;
-
tag = get_be32(pb) & 0xffffff00;
if (tag == MKBETAG('C', 'W', 'S', 0))
@@ -773,96 +650,60 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
nbits = get_byte(pb) >> 3;
len = (4 * nbits - 3 + 7) / 8;
url_fskip(pb, len);
- frame_rate = get_le16(pb);
+ swf->frame_rate = get_le16(pb); /* 8.8 fixed */
get_le16(pb); /* frame count */
- /* The Flash Player converts 8.8 frame rates
- to milliseconds internally. Do the same to get
- a correct framerate */
- swf->ms_per_frame = ( 1000 * 256 ) / frame_rate;
swf->samples_per_frame = 0;
- swf->ch_id = -1;
- firstTagOff = url_ftell(pb);
for(;;) {
+ offset_t tag_offset = url_ftell(pb);
tag = get_swf_tag(pb, &len);
- if (tag < 0) {
- if ( ast || vst ) {
- if ( vst && ast ) {
- vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame;
- vst->codec->time_base.num = 1;
- }
- break;
- }
- av_log(s, AV_LOG_ERROR, "No media found in SWF\n");
- return AVERROR_IO;
+ if (tag < 0 || tag == TAG_VIDEOFRAME || tag == TAG_STREAMBLOCK) {
+ url_fseek(pb, frame_offset == -1 ? tag_offset : frame_offset, SEEK_SET);
+ break;
}
if ( tag == TAG_VIDEOSTREAM && !vst) {
- int codec_id;
- swf->ch_id = get_le16(pb);
+ int ch_id = get_le16(pb);
get_le16(pb);
get_le16(pb);
get_le16(pb);
get_byte(pb);
/* Check for FLV1 */
- codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
- if ( codec_id ) {
- vst = av_new_stream(s, 0);
- av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */
-
- vst->codec->codec_type = CODEC_TYPE_VIDEO;
- vst->codec->codec_id = codec_id;
- if ( swf->samples_per_frame ) {
- vst->codec->time_base.den = 1000. / swf->ms_per_frame;
- vst->codec->time_base.num = 1;
- }
- }
+ vst = av_new_stream(s, ch_id);
+ vst->codec->codec_type = CODEC_TYPE_VIDEO;
+ vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
} else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) {
/* streaming found */
+ int sample_rate_code;
get_byte(pb);
v = get_byte(pb);
swf->samples_per_frame = get_le16(pb);
- if (len!=4)
+ ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */
+ swf->audio_stream_index = ast->index;
+ ast->codec->channels = 1 + (v&1);
+ ast->codec->codec_type = CODEC_TYPE_AUDIO;
+ ast->codec->codec_id = codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
+ ast->need_parsing = 1;
+ sample_rate_code= (v>>2) & 3;
+ if (!sample_rate_code)
+ return AVERROR_IO;
+ ast->codec->sample_rate = 11025 << (sample_rate_code-1);
+ av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+ if (len > 4)
url_fskip(pb,len-4);
- /* if mp3 streaming found, OK */
- if ((v & 0x20) != 0) {
- if ( tag == TAG_STREAMHEAD2 ) {
- get_le16(pb);
- }
- ast = av_new_stream(s, 1);
- if (!ast)
- return -ENOMEM;
- av_set_pts_info(ast, 24, 1, 1000); /* 24 bit pts in ms */
-
- if (v & 0x01)
- ast->codec->channels = 2;
- else
- ast->codec->channels = 1;
-
- switch((v>> 2) & 0x03) {
- case 1:
- ast->codec->sample_rate = 11025;
- break;
- case 2:
- ast->codec->sample_rate = 22050;
- break;
- case 3:
- ast->codec->sample_rate = 44100;
- break;
- default:
- av_free(ast);
- return AVERROR_IO;
- }
- ast->codec->codec_type = CODEC_TYPE_AUDIO;
- ast->codec->codec_id = CODEC_ID_MP3;
- ast->need_parsing = 1;
- }
+
+ } else if (tag == TAG_JPEG2 && !vst) {
+ vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */
+ vst->codec->codec_type = CODEC_TYPE_VIDEO;
+ vst->codec->codec_id = CODEC_ID_MJPEG;
+ url_fskip(pb, len);
+ frame_offset = tag_offset;
} else {
url_fskip(pb, len);
}
}
- url_fseek(pb, firstTagOff, SEEK_SET);
-
+ if (vst)
+ av_set_pts_info(vst, 64, 256, swf->frame_rate);
return 0;
}
@@ -878,36 +719,48 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (tag < 0)
return AVERROR_IO;
if (tag == TAG_VIDEOFRAME) {
+ int ch_id = get_le16(pb);
+ len -= 2;
for( i=0; i<s->nb_streams; i++ ) {
st = s->streams[i];
- if (st->id == 0) {
- if ( get_le16(pb) == swf->ch_id ) {
- frame = get_le16(pb);
- av_get_packet(pb, pkt, len-4);
- pkt->pts = frame * swf->ms_per_frame;
- pkt->stream_index = st->index;
- return pkt->size;
- } else {
- url_fskip(pb, len-2);
- continue;
- }
+ if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id) {
+ frame = get_le16(pb);
+ av_get_packet(pb, pkt, len-2);
+ pkt->pts = frame;
+ pkt->stream_index = st->index;
+ return pkt->size;
}
}
- url_fskip(pb, len);
} else if (tag == TAG_STREAMBLOCK) {
- for( i=0; i<s->nb_streams; i++ ) {
+ st = s->streams[swf->audio_stream_index];
+ if (st->codec->codec_id == CODEC_ID_MP3) {
+ url_fskip(pb, 4);
+ av_get_packet(pb, pkt, len-4);
+ } else { // ADPCM, PCM
+ av_get_packet(pb, pkt, len);
+ }
+ pkt->stream_index = st->index;
+ return pkt->size;
+ } else if (tag == TAG_JPEG2) {
+ for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
- if (st->id == 1) {
- url_fskip(pb, 4);
- av_get_packet(pb, pkt, len-4);
+ if (st->id == -2) {
+ get_le16(pb); /* BITMAP_ID */
+ av_new_packet(pkt, len-2);
+ get_buffer(pb, pkt->data, 4);
+ if (AV_RB32(pkt->data) == 0xffd8ffd9) {
+ /* old SWF files containing SOI/EOI as data start */
+ pkt->size -= 4;
+ get_buffer(pb, pkt->data, pkt->size);
+ } else {
+ get_buffer(pb, pkt->data + 4, pkt->size - 4);
+ }
pkt->stream_index = st->index;
return pkt->size;
}
}
- url_fskip(pb, len);
- } else {
- url_fskip(pb, len);
}
+ url_fskip(pb, len);
}
return 0;
}
diff --git a/contrib/ffmpeg/libavformat/tcp.c b/contrib/ffmpeg/libavformat/tcp.c
index 93755c497..a5539be4c 100644
--- a/contrib/ffmpeg/libavformat/tcp.c
+++ b/contrib/ffmpeg/libavformat/tcp.c
@@ -20,18 +20,7 @@
*/
#include "avformat.h"
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#if defined(__BEOS__) || defined(__INNOTEK_LIBC__)
-typedef int socklen_t;
-#endif
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
-#include <netdb.h>
+#include "network.h"
#include <sys/time.h>
#include <fcntl.h>
@@ -73,7 +62,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
s = av_malloc(sizeof(TCPContext));
if (!s)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
h->priv_data = s;
if (port <= 0 || port >= 65536)
@@ -84,7 +73,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
goto fail;
- fd = socket(PF_INET, SOCK_STREAM, 0);
+ fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
goto fail;
fcntl(fd, F_SETFL, O_NONBLOCK);
@@ -101,7 +90,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
/* wait until we are connected or until abort */
for(;;) {
if (url_interrupt_cb()) {
- ret = -EINTR;
+ ret = AVERROR(EINTR);
goto fail1;
}
fd_max = fd;
@@ -127,7 +116,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
ret = AVERROR_IO;
fail1:
if (fd >= 0)
- close(fd);
+ closesocket(fd);
av_free(s);
return ret;
}
@@ -141,7 +130,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
for (;;) {
if (url_interrupt_cb())
- return -EINTR;
+ return AVERROR(EINTR);
fd_max = s->fd;
FD_ZERO(&rfds);
FD_SET(s->fd, &rfds);
@@ -149,18 +138,10 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size)
tv.tv_usec = 100 * 1000;
ret = select(fd_max + 1, &rfds, NULL, NULL, &tv);
if (ret > 0 && FD_ISSET(s->fd, &rfds)) {
-#ifdef __BEOS__
len = recv(s->fd, buf, size, 0);
-#else
- len = read(s->fd, buf, size);
-#endif
if (len < 0) {
if (errno != EINTR && errno != EAGAIN)
-#ifdef __BEOS__
- return errno;
-#else
- return -errno;
-#endif
+ return AVERROR(errno);
} else return len;
} else if (ret < 0) {
return -1;
@@ -178,7 +159,7 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size)
size1 = size;
while (size > 0) {
if (url_interrupt_cb())
- return -EINTR;
+ return AVERROR(EINTR);
fd_max = s->fd;
FD_ZERO(&wfds);
FD_SET(s->fd, &wfds);
@@ -186,19 +167,10 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size)
tv.tv_usec = 100 * 1000;
ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
if (ret > 0 && FD_ISSET(s->fd, &wfds)) {
-#ifdef __BEOS__
len = send(s->fd, buf, size, 0);
-#else
- len = write(s->fd, buf, size);
-#endif
if (len < 0) {
- if (errno != EINTR && errno != EAGAIN) {
-#ifdef __BEOS__
- return errno;
-#else
- return -errno;
-#endif
- }
+ if (errno != EINTR && errno != EAGAIN)
+ return AVERROR(errno);
continue;
}
size -= len;
@@ -213,11 +185,7 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size)
static int tcp_close(URLContext *h)
{
TCPContext *s = h->priv_data;
-#ifdef CONFIG_BEOS_NETSERVER
closesocket(s->fd);
-#else
- close(s->fd);
-#endif
av_free(s);
return 0;
}
diff --git a/contrib/ffmpeg/libavformat/thp.c b/contrib/ffmpeg/libavformat/thp.c
new file mode 100644
index 000000000..d0d80428c
--- /dev/null
+++ b/contrib/ffmpeg/libavformat/thp.c
@@ -0,0 +1,170 @@
+/*
+ * THP Demuxer
+ * Copyright (c) 2007 Marco Gerards.
+ *
+ * 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 "avformat.h"
+#include "allformats.h"
+
+typedef struct ThpDemuxContext {
+ int version;
+ int first_frame;
+ int first_framesz;
+ int last_frame;
+ int compoff;
+ int framecnt;
+ AVRational fps;
+ int frame;
+ int next_frame;
+ int next_framesz;
+ int video_stream_index;
+ int compcount;
+ unsigned char components[16];
+ AVStream* vst;
+ int has_audio;
+} ThpDemuxContext;
+
+
+static int thp_probe(AVProbeData *p)
+{
+ /* check file header */
+ if (p->buf_size < 4)
+ return 0;
+
+ if (AV_RL32(p->buf) == MKTAG('T', 'H', 'P', '\0'))
+ return AVPROBE_SCORE_MAX;
+ else
+ return 0;
+}
+
+static int thp_read_header(AVFormatContext *s,
+ AVFormatParameters *ap)
+{
+ ThpDemuxContext *thp = s->priv_data;
+ AVStream *st;
+ ByteIOContext *pb = &s->pb;
+ int i;
+
+ /* Read the file header. */
+
+ get_be32(pb); /* Skip Magic. */
+ thp->version = get_be32(pb);
+
+ get_be32(pb); /* Max buf size. */
+ get_be32(pb); /* Max samples. */
+
+ thp->fps = av_d2q(av_int2flt(get_be32(pb)), INT_MAX);
+ thp->framecnt = get_be32(pb);
+ thp->first_framesz = get_be32(pb);
+ get_be32(pb); /* Data size. */
+
+ thp->compoff = get_be32(pb);
+ get_be32(pb); /* offsetDataOffset. */
+ thp->first_frame = get_be32(pb);
+ thp->last_frame = get_be32(pb);
+
+ thp->next_framesz = thp->first_framesz;
+ thp->next_frame = thp->first_frame;
+
+ /* Read the component structure. */
+ url_fseek (pb, thp->compoff, SEEK_SET);
+ thp->compcount = get_be32(pb);
+
+ /* Read the list of component types. */
+ get_buffer(pb, thp->components, 16);
+
+ for (i = 0; i < thp->compcount; i++) {
+ if (thp->components[i] == 0) {
+ if (thp->vst != 0)
+ break;
+
+ /* Video component. */
+ st = av_new_stream(s, 0);
+ if (!st)
+ return AVERROR_NOMEM;
+
+ /* The denominator and numerator are switched because 1/fps
+ is required. */
+ av_set_pts_info(st, 64, thp->fps.den, thp->fps.num);
+ st->codec->codec_type = CODEC_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_THP;
+ st->codec->codec_tag = 0; /* no fourcc */
+ st->codec->width = get_be32(pb);
+ st->codec->height = get_be32(pb);
+ st->codec->sample_rate = av_q2d(thp->fps);
+ thp->vst = st;
+ thp->video_stream_index = st->index;
+
+ if (thp->version == 0x11000)
+ get_be32(pb); /* Unknown. */
+ }
+ else if (thp->components[i] == 1) {
+ /* XXX: Required for audio playback. */
+ thp->has_audio = 1;
+ }
+ }
+
+ return 0;
+}
+
+static int thp_read_packet(AVFormatContext *s,
+ AVPacket *pkt)
+{
+ ThpDemuxContext *thp = s->priv_data;
+ ByteIOContext *pb = &s->pb;
+ int size;
+ int ret;
+
+ /* Terminate when last frame is reached. */
+ if (thp->frame >= thp->framecnt)
+ return AVERROR_IO;
+
+ url_fseek(pb, thp->next_frame, SEEK_SET);
+
+ /* Locate the next frame and read out its size. */
+ thp->next_frame += thp->next_framesz;
+ thp->next_framesz = get_be32(pb);
+
+ get_be32(pb); /* Previous total size. */
+ size = get_be32(pb); /* Total size of this frame. */
+
+ if (thp->has_audio)
+ get_be32(pb); /* Audio size. */
+
+ ret = av_get_packet(pb, pkt, size);
+ if (ret != size) {
+ av_free_packet(pkt);
+ return AVERROR_IO;
+ }
+
+ pkt->stream_index = thp->video_stream_index;
+ thp->frame++;
+
+ return 0;
+}
+
+AVInputFormat thp_demuxer = {
+ "thp",
+ "THP",
+ sizeof(ThpDemuxContext),
+ thp_probe,
+ thp_read_header,
+ thp_read_packet
+};
diff --git a/contrib/ffmpeg/libavformat/tiertexseq.c b/contrib/ffmpeg/libavformat/tiertexseq.c
index b1a39bf76..8f565824a 100644
--- a/contrib/ffmpeg/libavformat/tiertexseq.c
+++ b/contrib/ffmpeg/libavformat/tiertexseq.c
@@ -62,7 +62,7 @@ static int seq_probe(AVProbeData *p)
{
int i;
- if (p->buf_size < 256)
+ if (p->buf_size < 258)
return 0;
/* there's no real header in a .seq file, the only thing they have in common */
@@ -71,6 +71,9 @@ static int seq_probe(AVProbeData *p)
if (p->buf[i] != 0)
return 0;
+ if(p->buf[256]==0 && p->buf[257]==0)
+ return 0;
+
/* only one fourth of the score since the previous check is too naive */
return AVPROBE_SCORE_MAX / 4;
}
diff --git a/contrib/ffmpeg/libavformat/tta.c b/contrib/ffmpeg/libavformat/tta.c
index a513d9d38..a3709437e 100644
--- a/contrib/ffmpeg/libavformat/tta.c
+++ b/contrib/ffmpeg/libavformat/tta.c
@@ -40,9 +40,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
TTAContext *c = s->priv_data;
AVStream *st;
- int i, channels, bps, samplerate, datalen, framelen, start;
-
- start = url_ftell(&s->pb);
+ int i, channels, bps, samplerate, datalen, framelen;
if (get_le32(&s->pb) != ff_get_fourcc("TTA1"))
return -1; // not tta file
@@ -64,7 +62,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(&s->pb, 4); // header crc
- framelen = 1.04489795918367346939 * samplerate;
+ framelen = samplerate*256/245;
c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0);
c->currentframe = 0;
@@ -77,7 +75,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
return AVERROR_NOMEM;
for (i = 0; i < c->totalframes; i++)
- c->seektable[i] = get_le32(&s->pb);
+ c->seektable[i] = get_le32(&s->pb);
url_fskip(&s->pb, 4); // seektable crc
st = av_new_stream(s, 0);
@@ -90,14 +88,14 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec->sample_rate = samplerate;
st->codec->bits_per_sample = bps;
- st->codec->extradata_size = url_ftell(&s->pb) - start;
+ st->codec->extradata_size = url_ftell(&s->pb);
if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
//this check is redundant as get_buffer should fail
av_log(s, AV_LOG_ERROR, "extradata_size too large\n");
return -1;
}
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
- url_fseek(&s->pb, start, SEEK_SET); // or SEEK_CUR and -size ? :)
+ url_fseek(&s->pb, 0, SEEK_SET);
get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
diff --git a/contrib/ffmpeg/libavformat/udp.c b/contrib/ffmpeg/libavformat/udp.c
index 96fa4e152..bbf8ca2ec 100644
--- a/contrib/ffmpeg/libavformat/udp.c
+++ b/contrib/ffmpeg/libavformat/udp.c
@@ -20,15 +20,7 @@
*/
#include "avformat.h"
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#else
-# include "barpainet.h"
-#endif
-#include <netdb.h>
+#include "network.h"
#ifndef IPV6_ADD_MEMBERSHIP
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
@@ -214,11 +206,7 @@ static int udp_ipv6_set_local(URLContext *h) {
fail:
if (udp_fd >= 0)
-#ifdef CONFIG_BEOS_NETSERVER
closesocket(udp_fd);
-#else
- close(udp_fd);
-#endif
if(res0)
freeaddrinfo(res0);
return -1;
@@ -307,7 +295,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
s = av_malloc(sizeof(UDPContext));
if (!s)
- return -ENOMEM;
+ return AVERROR(ENOMEM);
h->priv_data = s;
s->ttl = 16;
@@ -342,7 +330,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
}
#ifndef CONFIG_IPV6
- udp_fd = socket(PF_INET, SOCK_DGRAM, 0);
+ udp_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (udp_fd < 0)
goto fail;
@@ -367,7 +355,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
getsockname(udp_fd, (struct sockaddr *)&my_addr1, &len);
s->local_port = ntohs(my_addr1.sin_port);
-#ifndef CONFIG_BEOS_NETSERVER
+#ifdef IP_MULTICAST_TTL
if (s->is_multicast) {
if (h->flags & URL_WRONLY) {
/* output */
@@ -395,7 +383,6 @@ static int udp_open(URLContext *h, const char *uri, int flags)
udp_fd = udp_ipv6_set_local(h);
if (udp_fd < 0)
goto fail;
-#ifndef CONFIG_BEOS_NETSERVER
if (s->is_multicast) {
if (h->flags & URL_WRONLY) {
if (udp_ipv6_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
@@ -406,7 +393,6 @@ static int udp_open(URLContext *h, const char *uri, int flags)
}
}
#endif
-#endif
if (is_output) {
/* limit the tx buf size to limit latency */
@@ -421,11 +407,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
return 0;
fail:
if (udp_fd >= 0)
-#ifdef CONFIG_BEOS_NETSERVER
closesocket(udp_fd);
-#else
- close(udp_fd);
-#endif
av_free(s);
return AVERROR_IO;
}
@@ -482,22 +464,20 @@ static int udp_close(URLContext *h)
{
UDPContext *s = h->priv_data;
-#ifndef CONFIG_BEOS_NETSERVER
#ifndef CONFIG_IPV6
+#ifdef IP_DROP_MEMBERSHIP
if (s->is_multicast && !(h->flags & URL_WRONLY)) {
if (setsockopt(s->udp_fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
&s->mreq, sizeof(s->mreq)) < 0) {
perror("IP_DROP_MEMBERSHIP");
}
}
+#endif
#else
if (s->is_multicast && !(h->flags & URL_WRONLY))
udp_ipv6_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
#endif
- close(s->udp_fd);
-#else
closesocket(s->udp_fd);
-#endif
av_free(s);
return 0;
}
diff --git a/contrib/ffmpeg/libavformat/utils.c b/contrib/ffmpeg/libavformat/utils.c
index eaeeb7c16..36cb269b5 100644
--- a/contrib/ffmpeg/libavformat/utils.c
+++ b/contrib/ffmpeg/libavformat/utils.c
@@ -32,7 +32,6 @@
static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
static void av_frac_add(AVFrac *f, int64_t incr);
-static void av_frac_set(AVFrac *f, int64_t val);
/** head of registered input format linked list. */
AVInputFormat *first_iformat = NULL;
@@ -140,9 +139,6 @@ AVOutputFormat *guess_stream_format(const char *short_name, const char *filename
return fmt;
}
-/**
- * Guesses the codec id based upon muxer and filename.
- */
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
const char *filename, const char *mime_type, enum CodecType type){
if(type == CODEC_TYPE_VIDEO){
@@ -162,9 +158,6 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
return CODEC_ID_NONE;
}
-/**
- * finds AVInputFormat based on input format's short name.
- */
AVInputFormat *av_find_input_format(const char *short_name)
{
AVInputFormat *fmt;
@@ -177,22 +170,12 @@ AVInputFormat *av_find_input_format(const char *short_name)
/* memory handling */
-/**
- * Default packet destructor.
- */
void av_destruct_packet(AVPacket *pkt)
{
av_free(pkt->data);
pkt->data = NULL; pkt->size = 0;
}
-/**
- * Allocate the payload of a packet and intialized its fields to default values.
- *
- * @param pkt packet
- * @param size wanted payload size
- * @return 0 if OK. AVERROR_xxx otherwise.
- */
int av_new_packet(AVPacket *pkt, int size)
{
uint8_t *data;
@@ -210,13 +193,6 @@ int av_new_packet(AVPacket *pkt, int size)
return 0;
}
-/**
- * Allocate and read the payload of a packet and intialized its fields to default values.
- *
- * @param pkt packet
- * @param size wanted payload size
- * @return >0 (read size) if OK. AVERROR_xxx otherwise.
- */
int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
{
int ret= av_new_packet(pkt, size);
@@ -235,8 +211,6 @@ int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
return ret;
}
-/* This is a hack - the packet memory allocation stuff is broken. The
- packet is allocated if it was not really allocated */
int av_dup_packet(AVPacket *pkt)
{
if (pkt->destruct != av_destruct_packet) {
@@ -257,30 +231,20 @@ int av_dup_packet(AVPacket *pkt)
return 0;
}
-/**
- * Allocate the payload of a packet and intialized its fields to default values.
- *
- * @param filename possible numbered sequence string
- * @return 1 if a valid numbered sequence string, 0 otherwise.
- */
int av_filename_number_test(const char *filename)
{
char buf[1024];
return filename && (av_get_frame_filename(buf, sizeof(buf), filename, 1)>=0);
}
-/**
- * Guess file format.
- */
-AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)
+static AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)
{
AVInputFormat *fmt1, *fmt;
- int score, score_max;
+ int score;
fmt = NULL;
- score_max = 0;
for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) {
- if (!is_opened && !(fmt1->flags & AVFMT_NOFILE))
+ if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
continue;
score = 0;
if (fmt1->read_probe) {
@@ -290,14 +254,19 @@ AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)
score = 50;
}
}
- if (score > score_max) {
- score_max = score;
+ if (score > *score_max) {
+ *score_max = score;
fmt = fmt1;
}
}
return fmt;
}
+AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened){
+ int score=0;
+ return av_probe_input_format2(pd, is_opened, &score);
+}
+
/************************************************************/
/* input media file */
@@ -327,6 +296,7 @@ static const AVOption options[]={
{"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"},
{"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
{"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
+{"analyzeduration", NULL, OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 3*AV_TIME_BASE, 0, INT_MAX, D},
{NULL},
};
@@ -336,10 +306,8 @@ static const AVOption options[]={
static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options };
-#if LIBAVFORMAT_VERSION_INT >= ((51<<16)+(0<<8)+0)
-static
-#endif
-void avformat_get_context_defaults(AVFormatContext *s){
+static void avformat_get_context_defaults(AVFormatContext *s)
+{
memset(s, 0, sizeof(AVFormatContext));
s->av_class = &av_format_context_class;
@@ -357,10 +325,6 @@ AVFormatContext *av_alloc_format_context(void)
return ic;
}
-/**
- * Allocates all the structures needed to read an input stream.
- * This does not open the needed codecs for decoding the stream[s].
- */
int av_open_input_stream(AVFormatContext **ic_ptr,
ByteIOContext *pb, const char *filename,
AVInputFormat *fmt, AVFormatParameters *ap)
@@ -422,17 +386,6 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
#define PROBE_BUF_MIN 2048
#define PROBE_BUF_MAX (1<<20)
-/**
- * Open a media file as input. The codec are not opened. Only the file
- * header (if present) is read.
- *
- * @param ic_ptr the opened media file handle is put here
- * @param filename filename to open.
- * @param fmt if non NULL, force the file format to use
- * @param buf_size optional buffer size (zero if default is OK)
- * @param ap additionnal parameters needed when opening the file (NULL if default)
- * @return 0 if OK. AVERROR_xxx otherwise.
- */
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
@@ -474,10 +427,11 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
}
for(probe_size= PROBE_BUF_MIN; probe_size<=PROBE_BUF_MAX && !fmt; probe_size<<=1){
+ int score= probe_size < PROBE_BUF_MAX ? AVPROBE_SCORE_MAX/4 : 0;
/* read probe data */
pd->buf= av_realloc(pd->buf, probe_size);
pd->buf_size = get_buffer(pb, pd->buf, probe_size);
- if (url_fseek(pb, 0, SEEK_SET) == (offset_t)-EPIPE) {
+ if (url_fseek(pb, 0, SEEK_SET) < 0) {
url_fclose(pb);
if (url_fopen(pb, filename, URL_RDONLY) < 0) {
file_opened = 0;
@@ -486,7 +440,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
}
}
/* guess file format */
- fmt = av_probe_input_format(pd, 1);
+ fmt = av_probe_input_format2(pd, 1, &score);
}
av_freep(&pd->buf);
}
@@ -528,16 +482,6 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
/*******************************************************/
-/**
- * Read a transport packet from a media file.
- *
- * This function is absolete and should never be used.
- * Use av_read_frame() instead.
- *
- * @param s media file handle
- * @param pkt is filled
- * @return 0 if OK. AVERROR_xxx if error.
- */
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
return s->iformat->read_packet(s, pkt);
@@ -639,7 +583,7 @@ static int64_t lsb2full(int64_t lsb, int64_t last_ts, int lsb_bits){
static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
- int num, den, presentation_delayed;
+ int num, den, presentation_delayed, delay, i;
/* handle wrapping */
if(st->cur_dts != AV_NOPTS_VALUE){
if(pkt->pts != AV_NOPTS_VALUE)
@@ -659,91 +603,81 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
pkt->flags |= PKT_FLAG_KEY;
/* do we have a video B frame ? */
+ delay= st->codec->has_b_frames;
presentation_delayed = 0;
- if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
- /* XXX: need has_b_frame, but cannot get it if the codec is
- not initialized */
- if (( st->codec->codec_id == CODEC_ID_H264
- || st->codec->has_b_frames) &&
- pc && pc->pict_type != FF_B_TYPE)
- presentation_delayed = 1;
- /* this may be redundant, but it shouldnt hurt */
- if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
- presentation_delayed = 1;
- }
+ /* XXX: need has_b_frame, but cannot get it if the codec is
+ not initialized */
+ if (delay &&
+ pc && pc->pict_type != FF_B_TYPE)
+ presentation_delayed = 1;
+ /* this may be redundant, but it shouldnt hurt */
+ if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
+ presentation_delayed = 1;
if(st->cur_dts == AV_NOPTS_VALUE){
- if(presentation_delayed) st->cur_dts = -pkt->duration;
- else st->cur_dts = 0;
+ st->cur_dts = -delay * pkt->duration;
}
// av_log(NULL, AV_LOG_DEBUG, "IN delayed:%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64" st:%d pc:%p\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts, pkt->stream_index, pc);
/* interpolate PTS and DTS if they are not present */
- if (presentation_delayed) {
- /* DTS = decompression time stamp */
- /* PTS = presentation time stamp */
- if (pkt->dts == AV_NOPTS_VALUE) {
- /* if we know the last pts, use it */
- if(st->last_IP_pts != AV_NOPTS_VALUE)
- st->cur_dts = pkt->dts = st->last_IP_pts;
- else
+ if(delay <=1){
+ if (presentation_delayed) {
+ /* DTS = decompression time stamp */
+ /* PTS = presentation time stamp */
+ if (pkt->dts == AV_NOPTS_VALUE)
+ pkt->dts = st->last_IP_pts;
+ if (pkt->dts == AV_NOPTS_VALUE)
pkt->dts = st->cur_dts;
- } else {
- st->cur_dts = pkt->dts;
- }
- /* this is tricky: the dts must be incremented by the duration
- of the frame we are displaying, i.e. the last I or P frame */
- if (st->last_IP_duration == 0)
- st->cur_dts += pkt->duration;
- else
- st->cur_dts += st->last_IP_duration;
- st->last_IP_duration = pkt->duration;
- st->last_IP_pts= pkt->pts;
- /* cannot compute PTS if not present (we can compute it only
- by knowing the futur */
- } else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){
- if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){
- int64_t old_diff= FFABS(st->cur_dts - pkt->duration - pkt->pts);
- int64_t new_diff= FFABS(st->cur_dts - pkt->pts);
- if(old_diff < new_diff && old_diff < (pkt->duration>>3)){
- pkt->pts += pkt->duration;
-// av_log(NULL, AV_LOG_DEBUG, "id:%d old:%"PRId64" new:%"PRId64" dur:%d cur:%"PRId64" size:%d\n", pkt->stream_index, old_diff, new_diff, pkt->duration, st->cur_dts, pkt->size);
- }
- }
- /* presentation is not delayed : PTS and DTS are the same */
- if (pkt->pts == AV_NOPTS_VALUE) {
- if (pkt->dts == AV_NOPTS_VALUE) {
- pkt->pts = st->cur_dts;
- pkt->dts = st->cur_dts;
+ /* this is tricky: the dts must be incremented by the duration
+ of the frame we are displaying, i.e. the last I or P frame */
+ if (st->last_IP_duration == 0)
+ st->last_IP_duration = pkt->duration;
+ st->cur_dts = pkt->dts + st->last_IP_duration;
+ st->last_IP_duration = pkt->duration;
+ st->last_IP_pts= pkt->pts;
+ /* cannot compute PTS if not present (we can compute it only
+ by knowing the futur */
+ } else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){
+ if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){
+ int64_t old_diff= FFABS(st->cur_dts - pkt->duration - pkt->pts);
+ int64_t new_diff= FFABS(st->cur_dts - pkt->pts);
+ if(old_diff < new_diff && old_diff < (pkt->duration>>3)){
+ pkt->pts += pkt->duration;
+ // av_log(NULL, AV_LOG_DEBUG, "id:%d old:%"PRId64" new:%"PRId64" dur:%d cur:%"PRId64" size:%d\n", pkt->stream_index, old_diff, new_diff, pkt->duration, st->cur_dts, pkt->size);
+ }
}
- else {
- st->cur_dts = pkt->dts;
+
+ /* presentation is not delayed : PTS and DTS are the same */
+ if(pkt->pts == AV_NOPTS_VALUE)
pkt->pts = pkt->dts;
- }
- } else {
- st->cur_dts = pkt->pts;
+ if(pkt->pts == AV_NOPTS_VALUE)
+ pkt->pts = st->cur_dts;
pkt->dts = pkt->pts;
+ st->cur_dts = pkt->pts + pkt->duration;
}
- st->cur_dts += pkt->duration;
}
-// av_log(NULL, AV_LOG_DEBUG, "OUTdelayed:%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts);
+
+ if(pkt->pts != AV_NOPTS_VALUE){
+ st->pts_buffer[0]= pkt->pts;
+ for(i=1; i<delay+1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
+ st->pts_buffer[i]= (i-delay-1) * pkt->duration;
+ for(i=0; i<delay && st->pts_buffer[i] > st->pts_buffer[i+1]; i++)
+ FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i+1]);
+ if(pkt->dts == AV_NOPTS_VALUE)
+ pkt->dts= st->pts_buffer[0];
+ if(pkt->dts > st->cur_dts)
+ st->cur_dts = pkt->dts;
+ }
+
+// av_log(NULL, AV_LOG_ERROR, "OUTdelayed:%d/%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, delay, pkt->pts, pkt->dts, st->cur_dts);
/* update flags */
if (pc) {
pkt->flags = 0;
/* key frame computation */
- switch(st->codec->codec_type) {
- case CODEC_TYPE_VIDEO:
if (pc->pict_type == FF_I_TYPE)
pkt->flags |= PKT_FLAG_KEY;
- break;
- case CODEC_TYPE_AUDIO:
- pkt->flags |= PKT_FLAG_KEY;
- break;
- default:
- break;
- }
}
}
@@ -787,6 +721,12 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
pkt->dts = st->parser->dts;
pkt->destruct = av_destruct_packet_nofree;
compute_pkt_fields(s, st, st->parser, pkt);
+
+ if((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & PKT_FLAG_KEY){
+ av_add_index_entry(st, st->parser->frame_offset, pkt->dts,
+ 0, 0, AVINDEX_KEYFRAME);
+ }
+
break;
}
} else {
@@ -798,7 +738,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
/* read next packet */
ret = av_read_packet(s, &s->cur_pkt);
if (ret < 0) {
- if (ret == -EAGAIN)
+ if (ret == AVERROR(EAGAIN))
return ret;
/* return the last frames, if any */
for(i = 0; i < s->nb_streams; i++) {
@@ -835,6 +775,10 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
}else if(st->need_parsing == 2){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
+ if(st->parser && (s->iformat->flags & AVFMT_GENERIC_INDEX)){
+ st->parser->last_frame_offset=
+ st->parser->cur_offset= s->cur_pkt.pos;
+ }
}
}
}
@@ -848,25 +792,6 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
return 0;
}
-/**
- * Return the next frame of a stream.
- *
- * The returned packet is valid
- * until the next av_read_frame() or until av_close_input_file() and
- * must be freed with av_free_packet. For video, the packet contains
- * exactly one frame. For audio, it contains an integer number of
- * frames if each frame has a known fixed size (e.g. PCM or ADPCM
- * data). If the audio frames have a variable size (e.g. MPEG audio),
- * then it contains one frame.
- *
- * pkt->pts, pkt->dts and pkt->duration are always set to correct
- * values in AV_TIME_BASE unit (and guessed if the format cannot
- * provided them). pkt->pts can be AV_NOPTS_VALUE if the video format
- * has B frames, so it is better to rely on pkt->dts if you do not
- * decompress the payload.
- *
- * @return 0 if OK, < 0 if error or end of file.
- */
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
{
AVPacketList *pktl;
@@ -905,7 +830,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
AVPacketList **plast_pktl= &s->packet_buffer;
int ret= av_read_frame_internal(s, pkt);
if(ret<0){
- if(pktl && ret != -EAGAIN){
+ if(pktl && ret != AVERROR(EAGAIN)){
eof=1;
continue;
}else
@@ -995,18 +920,10 @@ static void av_read_frame_flush(AVFormatContext *s)
st->parser = NULL;
}
st->last_IP_pts = AV_NOPTS_VALUE;
- st->cur_dts = 0; /* we set the current DTS to an unspecified origin */
+ st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
}
}
-/**
- * Updates cur_dts of all streams based on given timestamp and AVStream.
- *
- * Stream ref_st unchanged, others set cur_dts in their native timebase
- * only needed for timestamp wrapping or if (dts not set and pts!=dts)
- * @param timestamp new dts expressed in time_base of param ref_st
- * @param ref_st reference stream giving time_base of param timestamp
- */
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){
int i;
@@ -1019,11 +936,6 @@ void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){
}
}
-/**
- * Add a index entry into a sorted list updateing if it is already there.
- *
- * @param timestamp timestamp in the timebase of the given stream
- */
int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int size, int distance, int flags)
{
@@ -1111,14 +1023,6 @@ static int is_raw_stream(AVFormatContext *s)
return 1;
}
-/**
- * Gets the index for a specific timestamp.
- * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to
- * the timestamp which is <= the requested one, if backward is 0
- * then it will be >=
- * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
- * @return < 0 if no such timestamp could be found
- */
int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
int flags)
{
@@ -1153,12 +1057,6 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
#define DEBUG_SEEK
-/**
- * Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp().
- * this isnt supposed to be called directly by a user application, but by demuxers
- * @param target_ts target timestamp in the time base of the given stream
- * @param stream_index stream number
- */
int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
AVInputFormat *avif= s->iformat;
int64_t pos_min, pos_max, pos, pos_limit;
@@ -1223,12 +1121,6 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts
return 0;
}
-/**
- * Does a binary search using read_timestamp().
- * this isnt supposed to be called directly by a user application, but by demuxers
- * @param target_ts target timestamp in the time base of the given stream
- * @param stream_index stream number
- */
int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )){
int64_t pos, ts;
int64_t start_pos, filesize;
@@ -1369,23 +1261,42 @@ static int av_seek_frame_generic(AVFormatContext *s,
AVStream *st;
AVIndexEntry *ie;
- if (!s->index_built) {
- if (is_raw_stream(s)) {
- av_build_index_raw(s);
- } else {
- return -1;
- }
- s->index_built = 1;
- }
-
st = s->streams[stream_index];
+
index = av_index_search_timestamp(st, timestamp, flags);
+
+ if(index < 0){
+ int i;
+ AVPacket pkt;
+
+ if(st->index_entries && st->nb_index_entries){
+ ie= &st->index_entries[st->nb_index_entries-1];
+ url_fseek(&s->pb, ie->pos, SEEK_SET);
+ av_update_cur_dts(s, st, ie->timestamp);
+ }else
+ url_fseek(&s->pb, 0, SEEK_SET);
+
+ for(i=0;; i++) {
+ int ret = av_read_frame(s, &pkt);
+ if(ret<0)
+ break;
+ av_free_packet(&pkt);
+ if(stream_index == pkt.stream_index){
+ if((pkt.flags & PKT_FLAG_KEY) && pkt.dts > timestamp)
+ break;
+ }
+ }
+ index = av_index_search_timestamp(st, timestamp, flags);
+ }
if (index < 0)
return -1;
- /* now we have found the index, we can seek */
- ie = &st->index_entries[index];
av_read_frame_flush(s);
+ if (s->iformat->read_seek){
+ if(s->iformat->read_seek(s, stream_index, timestamp, flags) >= 0)
+ return 0;
+ }
+ ie = &st->index_entries[index];
url_fseek(&s->pb, ie->pos, SEEK_SET);
av_update_cur_dts(s, st, ie->timestamp);
@@ -1393,17 +1304,6 @@ static int av_seek_frame_generic(AVFormatContext *s,
return 0;
}
-/**
- * Seek to the key frame at timestamp.
- * 'timestamp' in 'stream_index'.
- * @param stream_index If stream_index is (-1), a default
- * stream is selected, and timestamp is automatically converted
- * from AV_TIME_BASE units to the stream specific time_base.
- * @param timestamp timestamp in AVStream.time_base units
- * or if there is no stream specified then in AV_TIME_BASE units
- * @param flags flags which select direction and seeking mode
- * @return >= 0 on success
- */
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
int ret;
@@ -1472,8 +1372,8 @@ static void av_update_stream_timings(AVFormatContext *ic)
int i;
AVStream *st;
- start_time = MAXINT64;
- end_time = MININT64;
+ start_time = INT64_MAX;
+ end_time = INT64_MIN;
for(i = 0;i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->start_time != AV_NOPTS_VALUE) {
@@ -1488,9 +1388,9 @@ static void av_update_stream_timings(AVFormatContext *ic)
}
}
}
- if (start_time != MAXINT64) {
+ if (start_time != INT64_MAX) {
ic->start_time = start_time;
- if (end_time != MININT64) {
+ if (end_time != INT64_MIN) {
ic->duration = end_time - start_time;
if (ic->file_size > 0) {
/* compute the bit rate */
@@ -1557,7 +1457,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic)
#define DURATION_MAX_READ_SIZE 250000
/* only usable for MPEG-PS streams */
-static void av_estimate_timings_from_pts(AVFormatContext *ic)
+static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset)
{
AVPacket pkt1, *pkt = &pkt1;
AVStream *st;
@@ -1565,21 +1465,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic)
int64_t end_time;
int64_t filesize, offset, duration;
- /* free previous packet */
- if (ic->cur_st && ic->cur_st->parser)
- av_free_packet(&ic->cur_pkt);
- ic->cur_st = NULL;
-
- /* flush packet queue */
- flush_packet_queue(ic);
-
- for(i=0;i<ic->nb_streams;i++) {
- st = ic->streams[i];
- if (st->parser) {
- av_parser_close(st->parser);
- st->parser= NULL;
- }
- }
+ av_read_frame_flush(ic);
/* we read the first packets to get the first PTS (not fully
accurate, but it is enough now) */
@@ -1649,10 +1535,10 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic)
fill_all_stream_timings(ic);
- url_fseek(&ic->pb, 0, SEEK_SET);
+ url_fseek(&ic->pb, old_offset, SEEK_SET);
}
-static void av_estimate_timings(AVFormatContext *ic)
+static void av_estimate_timings(AVFormatContext *ic, offset_t old_offset)
{
int64_t file_size;
@@ -1670,7 +1556,7 @@ static void av_estimate_timings(AVFormatContext *ic)
!strcmp(ic->iformat->name, "mpegts")) &&
file_size && !ic->pb.is_streamed) {
/* get accurate estimate from the PTSes */
- av_estimate_timings_from_pts(ic);
+ av_estimate_timings_from_pts(ic, old_offset);
} else if (av_has_timings(ic)) {
/* at least one components has timings - we use them for all
the components */
@@ -1720,7 +1606,7 @@ static int try_decode_frame(AVStream *st, const uint8_t *data, int size)
{
int16_t *samples;
AVCodec *codec;
- int got_picture, ret=0;
+ int got_picture, data_size, ret=0;
AVFrame picture;
if(!st->codec->codec){
@@ -1739,11 +1625,12 @@ static int try_decode_frame(AVStream *st, const uint8_t *data, int size)
&got_picture, (uint8_t *)data, size);
break;
case CODEC_TYPE_AUDIO:
- samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ data_size = FFMAX(size, AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ samples = av_malloc(data_size);
if (!samples)
goto fail;
- ret = avcodec_decode_audio(st->codec, samples,
- &got_picture, (uint8_t *)data, size);
+ ret = avcodec_decode_audio2(st->codec, samples,
+ &data_size, (uint8_t *)data, size);
av_free(samples);
break;
default:
@@ -1757,19 +1644,12 @@ static int try_decode_frame(AVStream *st, const uint8_t *data, int size)
/* absolute maximum size we read until we abort */
#define MAX_READ_SIZE 5000000
-/* maximum duration until we stop analysing the stream */
-#define MAX_STREAM_DURATION ((int)(AV_TIME_BASE * 3.0))
+#define MAX_STD_TIMEBASES (60*12+5)
+static int get_std_framerate(int i){
+ if(i<60*12) return i*1001;
+ else return ((int[]){24,30,60,12,15})[i-60*12]*1000*12;
+}
-/**
- * Read the beginning of a media file to get stream information. This
- * is useful for file formats with no headers such as MPEG. This
- * function also compute the real frame rate in case of mpeg2 repeat
- * frame mode.
- *
- * @param ic media file handle
- * @return >=0 if OK. AVERROR_xxx if error.
- * @todo let user decide somehow what information is needed so we dont waste time geting stuff the user doesnt need
- */
int av_find_stream_info(AVFormatContext *ic)
{
int i, count, ret, read_size, j;
@@ -1777,8 +1657,14 @@ int av_find_stream_info(AVFormatContext *ic)
AVPacket pkt1, *pkt;
AVPacketList *pktl=NULL, **ppktl;
int64_t last_dts[MAX_STREAMS];
- int64_t duration_sum[MAX_STREAMS];
int duration_count[MAX_STREAMS]={0};
+ double (*duration_error)[MAX_STD_TIMEBASES];
+ offset_t old_offset = url_ftell(&ic->pb);
+ int64_t codec_info_duration[MAX_STREAMS]={0};
+ int codec_info_nb_frames[MAX_STREAMS]={0};
+
+ duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error));
+ if (!duration_error) return AVERROR_NOMEM;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
@@ -1799,7 +1685,6 @@ int av_find_stream_info(AVFormatContext *ic)
for(i=0;i<MAX_STREAMS;i++){
last_dts[i]= AV_NOPTS_VALUE;
- duration_sum[i]= INT64_MAX;
}
count = 0;
@@ -1812,7 +1697,7 @@ int av_find_stream_info(AVFormatContext *ic)
if (!has_codec_parameters(st->codec))
break;
/* variable fps and no guess at the real fps */
- if( st->codec->time_base.den >= 101LL*st->codec->time_base.num
+ if( (st->codec->time_base.den >= 101LL*st->codec->time_base.num || st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
&& duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO)
break;
if(st->parser && st->parser->parser->split && !st->codec->extradata)
@@ -1875,9 +1760,10 @@ int av_find_stream_info(AVFormatContext *ic)
read_size += pkt->size;
st = ic->streams[pkt->stream_index];
- st->codec_info_duration += pkt->duration;
+ if(codec_info_nb_frames[st->index]>1)
+ codec_info_duration[st->index] += pkt->duration;
if (pkt->duration != 0)
- st->codec_info_nb_frames++;
+ codec_info_nb_frames[st->index]++;
{
int index= pkt->stream_index;
@@ -1885,21 +1771,22 @@ int av_find_stream_info(AVFormatContext *ic)
int64_t duration= pkt->dts - last;
if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){
- if(duration*duration_count[index]*10/9 < duration_sum[index]){
- duration_sum[index]= duration;
- duration_count[index]=1;
- }else{
- int factor= av_rescale(2*duration, duration_count[index], duration_sum[index]);
- if(factor==3)
- duration_count[index] *= 2;
- factor= av_rescale(duration, duration_count[index], duration_sum[index]);
- duration_sum[index] += duration;
- duration_count[index]+= factor;
+ double dur= duration * av_q2d(st->time_base);
+
+// if(st->codec->codec_type == CODEC_TYPE_VIDEO)
+// av_log(NULL, AV_LOG_ERROR, "%f\n", dur);
+ if(duration_count[index] < 2)
+ memset(duration_error, 0, MAX_STREAMS * sizeof(*duration_error));
+ for(i=1; i<MAX_STD_TIMEBASES; i++){
+ int framerate= get_std_framerate(i);
+ int ticks= lrintf(dur*framerate/(1001*12));
+ double error= dur - ticks*1001*12/(double)framerate;
+ duration_error[index][i] += error*error;
}
- if(st->codec_info_nb_frames == 0 && 0)
- st->codec_info_duration += duration;
+ duration_count[index]++;
}
- last_dts[pkt->stream_index]= pkt->dts;
+ if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
+ last_dts[pkt->stream_index]= pkt->dts;
}
if(st->parser && st->parser->parser->split && !st->codec->extradata){
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
@@ -1932,7 +1819,7 @@ int av_find_stream_info(AVFormatContext *ic)
(st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/)
try_decode_frame(st, pkt->data, pkt->size);
- if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION) {
+ if (av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
break;
}
count++;
@@ -1951,28 +1838,19 @@ int av_find_stream_info(AVFormatContext *ic)
st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
if(duration_count[i]
- && (st->codec->time_base.num*101LL <= st->codec->time_base.den || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) &&
+ && (st->codec->time_base.num*101LL <= st->codec->time_base.den || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) /*&&
//FIXME we should not special case mpeg2, but this needs testing with non mpeg2 ...
- st->time_base.num*duration_sum[i]/duration_count[i]*101LL > st->time_base.den){
- int64_t num, den, error, best_error;
-
- num= st->time_base.den*duration_count[i];
- den= st->time_base.num*duration_sum[i];
-
- best_error= INT64_MAX;
- for(j=1; j<60*12; j++){
- error= FFABS(1001*12*num - 1001*j*den);
+ st->time_base.num*duration_sum[i]/duration_count[i]*101LL > st->time_base.den*/){
+ double best_error= 2*av_q2d(st->time_base);
+ best_error= best_error*best_error*duration_count[i]*1000*12*30;
+
+ for(j=1; j<MAX_STD_TIMEBASES; j++){
+ double error= duration_error[i][j] * get_std_framerate(j);
+// if(st->codec->codec_type == CODEC_TYPE_VIDEO)
+// av_log(NULL, AV_LOG_ERROR, "%f %f\n", get_std_framerate(j) / 12.0/1001, error);
if(error < best_error){
best_error= error;
- av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, j, 12, INT_MAX);
- }
- }
- for(j=0; j<3; j++){
- static const int ticks[]= {24,30,60};
- error= FFABS(1001*12*num - 1000*12*den * ticks[j]);
- if(error < best_error){
- best_error= error;
- av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, ticks[j]*1000, 1001, INT_MAX);
+ av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, get_std_framerate(j), 12*1001, INT_MAX);
}
}
}
@@ -1987,10 +1865,13 @@ int av_find_stream_info(AVFormatContext *ic)
st->r_frame_rate.den = st->time_base.num;
}
}
+ }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) {
+ if(!st->codec->bits_per_sample)
+ st->codec->bits_per_sample= av_get_bits_per_sample(st->codec->codec_id);
}
}
- av_estimate_timings(ic);
+ av_estimate_timings(ic, old_offset);
#if 0
/* correct DTS for b frame streams with no timestamps */
for(i=0;i<ic->nb_streams;i++) {
@@ -2015,15 +1896,14 @@ int av_find_stream_info(AVFormatContext *ic)
}
}
#endif
+
+ av_free(duration_error);
+
return ret;
}
/*******************************************************/
-/**
- * start playing a network based stream (e.g. RTSP stream) at the
- * current position
- */
int av_read_play(AVFormatContext *s)
{
if (!s->iformat->read_play)
@@ -2031,11 +1911,6 @@ int av_read_play(AVFormatContext *s)
return s->iformat->read_play(s);
}
-/**
- * Pause a network based stream (e.g. RTSP stream).
- *
- * Use av_read_play() to resume it.
- */
int av_read_pause(AVFormatContext *s)
{
if (!s->iformat->read_pause)
@@ -2043,11 +1918,6 @@ int av_read_pause(AVFormatContext *s)
return s->iformat->read_pause(s);
}
-/**
- * Close a media file (but not its codecs).
- *
- * @param s media file handle
- */
void av_close_input_file(AVFormatContext *s)
{
int i, must_open_file;
@@ -2082,16 +1952,6 @@ void av_close_input_file(AVFormatContext *s)
av_free(s);
}
-/**
- * Add a new stream to a media file.
- *
- * Can only be called in the read_header() function. If the flag
- * AVFMTCTX_NOHEADER is in the format context, then new streams
- * can be added in read_packet too.
- *
- * @param s media file handle
- * @param id file format dependent stream id
- */
AVStream *av_new_stream(AVFormatContext *s, int id)
{
AVStream *st;
@@ -2147,13 +2007,6 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
return 0;
}
-/**
- * allocate the stream private data and write the stream header to an
- * output media file
- *
- * @param s media file handle
- * @return 0 if OK. AVERROR_xxx if error.
- */
int av_write_header(AVFormatContext *s)
{
int ret, i;
@@ -2181,6 +2034,23 @@ int av_write_header(AVFormatContext *s)
}
break;
}
+
+ if(s->oformat->codec_tag){
+ if(st->codec->codec_tag){
+ //FIXME
+ //check that tag + id is in the table
+ //if neither is in the table -> ok
+ //if tag is in the table with another id -> FAIL
+ //if id is in the table with another tag -> FAIL unless strict < ?
+ }else
+ st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id);
+ }
+ }
+
+ if (!s->priv_data && s->oformat->priv_data_size > 0) {
+ s->priv_data = av_mallocz(s->oformat->priv_data_size);
+ if (!s->priv_data)
+ return AVERROR_NOMEM;
}
if(s->oformat->write_header){
@@ -2250,11 +2120,12 @@ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){
}
if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){
- av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64"\n", st->cur_dts, pkt->dts);
+ av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64" st:%d\n", st->cur_dts, pkt->dts, st->index);
return -1;
}
if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){
- av_log(NULL, AV_LOG_ERROR, "error, pts < dts\n");
+ av_log(NULL, AV_LOG_ERROR, "error, pts < dts (%"PRId64" < %"PRId64")\n",
+ pkt->pts, pkt->dts);
return -1;
}
@@ -2288,19 +2159,12 @@ static void truncate_ts(AVStream *st, AVPacket *pkt){
// if(pkt->dts < 0)
// pkt->dts= 0; //this happens for low_delay=0 and b frames, FIXME, needs further invstigation about what we should do here
- pkt->pts &= pts_mask;
- pkt->dts &= pts_mask;
+ if (pkt->pts != AV_NOPTS_VALUE)
+ pkt->pts &= pts_mask;
+ if (pkt->dts != AV_NOPTS_VALUE)
+ pkt->dts &= pts_mask;
}
-/**
- * Write a packet to an output media file.
- *
- * The packet shall contain one audio or video frame.
- *
- * @param s media file handle
- * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
- * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
- */
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
{
int ret;
@@ -2317,20 +2181,6 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
return ret;
}
-/**
- * Interleave a packet per DTS in an output media file.
- *
- * Packets with pkt->destruct == av_destruct_packet will be freed inside this function,
- * so they cannot be used after it, note calling av_free_packet() on them is still safe.
- *
- * @param s media file handle
- * @param out the interleaved packet will be output here
- * @param in the input packet
- * @param flush 1 if no further packets are available as input and all
- * remaining packets should be output
- * @return 1 if a packet was output, 0 if no packet could be output,
- * < 0 if an error occured
- */
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){
AVPacketList *pktl, **next_point, *this_pktl;
int stream_count=0;
@@ -2400,20 +2250,6 @@ static int av_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in,
return av_interleave_packet_per_dts(s, out, in, flush);
}
-/**
- * Writes a packet to an output media file ensuring correct interleaving.
- *
- * The packet must contain one audio or video frame.
- * If the packets are already correctly interleaved the application should
- * call av_write_frame() instead as its slightly faster, its also important
- * to keep in mind that completly non interleaved input will need huge amounts
- * of memory to interleave with this, so its prefereable to interleave at the
- * demuxer level
- *
- * @param s media file handle
- * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
- * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
- */
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
AVStream *st= s->streams[ pkt->stream_index];
@@ -2447,13 +2283,6 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
}
}
-/**
- * @brief Write the stream trailer to an output media file and
- * free the file private data.
- *
- * @param s media file handle
- * @return 0 if OK. AVERROR_xxx if error.
- */
int av_write_trailer(AVFormatContext *s)
{
int ret, i;
@@ -2586,9 +2415,6 @@ static AbvEntry frame_abvs[] = {
{ "4cif", 704, 576, 0, 0 },
};
-/**
- * parses width and height out of string str.
- */
int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
{
int i;
@@ -2617,13 +2443,6 @@ int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
return 0;
}
-/**
- * Converts frame rate from string to a fraction.
- *
- * First we try to get an exact integer or fractional frame rate.
- * If this fails we convert the frame rate to a double and return
- * an approximate fraction using the DEFAULT_FRAME_RATE_BASE.
- */
int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg)
{
int i;
@@ -2661,21 +2480,6 @@ int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg)
return 0;
}
-/**
- * Converts date string to number of seconds since Jan 1st, 1970.
- *
- * @code
- * Syntax:
- * - If not a duration:
- * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
- * Time is localtime unless Z is suffixed to the end. In this case GMT
- * Return the date in micro seconds since 1970
- *
- * - If a duration:
- * HH[:MM[:SS[.m...]]]
- * S+[.m...]
- * @endcode
- */
#ifndef CONFIG_WINCE
int64_t parse_date(const char *datestr, int duration)
{
@@ -2756,7 +2560,7 @@ int64_t parse_date(const char *datestr, int duration)
if (duration)
return 0;
else
- return now * int64_t_C(1000000);
+ return now * INT64_C(1000000);
}
if (duration) {
@@ -2786,12 +2590,6 @@ int64_t parse_date(const char *datestr, int duration)
}
#endif /* CONFIG_WINCE */
-/**
- * Attempts to find a specific tag in a URL.
- *
- * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
- * Return 1 if found.
- */
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
{
const char *p;
@@ -2831,18 +2629,6 @@ int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
return 0;
}
-/**
- * Returns in 'buf' the path with '%d' replaced by number.
-
- * Also handles the '%0nd' format where 'n' is the total number
- * of digits and '%%'.
- *
- * @param buf destination buffer
- * @param buf_size destination buffer size
- * @param path numbered sequence string
- * @number frame number
- * @return 0 if OK, -1 if format error.
- */
int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number)
{
@@ -2898,68 +2684,80 @@ int av_get_frame_filename(char *buf, int buf_size,
return -1;
}
-/**
- * Print nice hexa dump of a buffer
- * @param f stream for output
- * @param buf buffer
- * @param size buffer size
- */
-void av_hex_dump(FILE *f, uint8_t *buf, int size)
+static void hex_dump_internal(void *avcl, FILE *f, int level, uint8_t *buf, int size)
{
int len, i, j, c;
+#define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
for(i=0;i<size;i+=16) {
len = size - i;
if (len > 16)
len = 16;
- fprintf(f, "%08x ", i);
+ PRINT("%08x ", i);
for(j=0;j<16;j++) {
if (j < len)
- fprintf(f, " %02x", buf[i+j]);
+ PRINT(" %02x", buf[i+j]);
else
- fprintf(f, " ");
+ PRINT(" ");
}
- fprintf(f, " ");
+ PRINT(" ");
for(j=0;j<len;j++) {
c = buf[i+j];
if (c < ' ' || c > '~')
c = '.';
- fprintf(f, "%c", c);
+ PRINT("%c", c);
}
- fprintf(f, "\n");
+ PRINT("\n");
}
+#undef PRINT
+}
+
+void av_hex_dump(FILE *f, uint8_t *buf, int size)
+{
+ hex_dump_internal(NULL, f, 0, buf, size);
+}
+
+void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size)
+{
+ hex_dump_internal(avcl, NULL, level, buf, size);
}
-/**
- * Print on 'f' a nice dump of a packet
- * @param f stream for output
- * @param pkt packet to dump
- * @param dump_payload true if the payload must be displayed too
- */
//FIXME needs to know the time_base
-void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload)
+static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int dump_payload)
{
- fprintf(f, "stream #%d:\n", pkt->stream_index);
- fprintf(f, " keyframe=%d\n", ((pkt->flags & PKT_FLAG_KEY) != 0));
- fprintf(f, " duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE);
+#define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0)
+ PRINT("stream #%d:\n", pkt->stream_index);
+ PRINT(" keyframe=%d\n", ((pkt->flags & PKT_FLAG_KEY) != 0));
+ PRINT(" duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE);
/* DTS is _always_ valid after av_read_frame() */
- fprintf(f, " dts=");
+ PRINT(" dts=");
if (pkt->dts == AV_NOPTS_VALUE)
- fprintf(f, "N/A");
+ PRINT("N/A");
else
- fprintf(f, "%0.3f", (double)pkt->dts / AV_TIME_BASE);
+ PRINT("%0.3f", (double)pkt->dts / AV_TIME_BASE);
/* PTS may be not known if B frames are present */
- fprintf(f, " pts=");
+ PRINT(" pts=");
if (pkt->pts == AV_NOPTS_VALUE)
- fprintf(f, "N/A");
+ PRINT("N/A");
else
- fprintf(f, "%0.3f", (double)pkt->pts / AV_TIME_BASE);
- fprintf(f, "\n");
- fprintf(f, " size=%d\n", pkt->size);
+ PRINT("%0.3f", (double)pkt->pts / AV_TIME_BASE);
+ PRINT("\n");
+ PRINT(" size=%d\n", pkt->size);
+#undef PRINT
if (dump_payload)
av_hex_dump(f, pkt->data, pkt->size);
}
+void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload)
+{
+ pkt_dump_internal(NULL, f, 0, pkt, dump_payload);
+}
+
+void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload)
+{
+ pkt_dump_internal(avcl, NULL, level, pkt, dump_payload);
+}
+
void url_split(char *proto, int proto_size,
char *authorization, int authorization_size,
char *hostname, int hostname_size,
@@ -3031,15 +2829,6 @@ void url_split(char *proto, int proto_size,
pstrcpy(path, path_size, p);
}
-/**
- * Set the pts for a given stream.
- *
- * @param s stream
- * @param pts_wrap_bits number of bits effectively used by the pts
- * (used for wrap control, 33 is the value for MPEG)
- * @param pts_num numerator to convert to seconds (MPEG: 1)
- * @param pts_den denominator to convert to seconds (MPEG: 90000)
- */
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
int pts_num, int pts_den)
{
@@ -3073,15 +2862,6 @@ static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den)
}
/**
- * Set f to (val + 0.5).
- */
-static void av_frac_set(AVFrac *f, int64_t val)
-{
- f->val = val;
- f->num = f->den >> 1;
-}
-
-/**
* Fractionnal addition to f: f = f + (incr / f->den).
*
* @param f fractional number
diff --git a/contrib/ffmpeg/libavformat/v4l2.c b/contrib/ffmpeg/libavformat/v4l2.c
index 00adccaa8..aeaac3347 100644
--- a/contrib/ffmpeg/libavformat/v4l2.c
+++ b/contrib/ffmpeg/libavformat/v4l2.c
@@ -59,6 +59,11 @@ struct video_data {
unsigned int *buf_len;
};
+struct buff_data {
+ int index;
+ int fd;
+};
+
struct fmt_map {
enum PixelFormat ff_fmt;
int32_t v4l2_fmt;
@@ -74,7 +79,7 @@ static struct fmt_map fmt_conversion_table[] = {
.v4l2_fmt = V4L2_PIX_FMT_YUV422P,
},
{
- .ff_fmt = PIX_FMT_YUV422,
+ .ff_fmt = PIX_FMT_YUYV422,
.v4l2_fmt = V4L2_PIX_FMT_YUYV,
},
{
@@ -99,7 +104,7 @@ static struct fmt_map fmt_conversion_table[] = {
},
/*
{
- .ff_fmt = PIX_FMT_RGBA32,
+ .ff_fmt = PIX_FMT_RGB32,
.v4l2_fmt = V4L2_PIX_FMT_BGR32,
},
*/
@@ -109,16 +114,16 @@ static struct fmt_map fmt_conversion_table[] = {
},
};
-static int device_open(const char *devname, uint32_t *capabilities)
+static int device_open(AVFormatContext *ctx, uint32_t *capabilities)
{
struct v4l2_capability cap;
int fd;
int res;
- fd = open(devname, O_RDWR /*| O_NONBLOCK*/, 0);
+ fd = open(ctx->filename, O_RDWR /*| O_NONBLOCK*/, 0);
if (fd < 0) {
- av_log(NULL, AV_LOG_ERROR, "Cannot open video device %s : %s\n",
- devname, strerror(errno));
+ av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n",
+ ctx->filename, strerror(errno));
return -1;
}
@@ -127,20 +132,20 @@ static int device_open(const char *devname, uint32_t *capabilities)
// ENOIOCTLCMD definition only availble on __KERNEL__
if (res < 0 && errno == 515)
{
- av_log(NULL, AV_LOG_ERROR, "QUERYCAP not implemented, probably V4L device but not supporting V4L2\n");
+ av_log(ctx, AV_LOG_ERROR, "QUERYCAP not implemented, probably V4L device but not supporting V4L2\n");
close(fd);
return -1;
}
if (res < 0) {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n",
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n",
strerror(errno));
close(fd);
return -1;
}
if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
- av_log(NULL, AV_LOG_ERROR, "Not a video capture device\n");
+ av_log(ctx, AV_LOG_ERROR, "Not a video capture device\n");
close(fd);
return -1;
@@ -150,8 +155,10 @@ static int device_open(const char *devname, uint32_t *capabilities)
return fd;
}
-static int device_init(int fd, int *width, int *height, int pix_fmt)
+static int device_init(AVFormatContext *ctx, int *width, int *height, int pix_fmt)
{
+ struct video_data *s = ctx->priv_data;
+ int fd = s->fd;
struct v4l2_format fmt;
int res;
@@ -163,7 +170,7 @@ static int device_init(int fd, int *width, int *height, int pix_fmt)
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
res = ioctl(fd, VIDIOC_S_FMT, &fmt);
if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) {
- av_log(NULL, AV_LOG_INFO, "The V4L2 driver changed the video from %dx%d to %dx%d\n", *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height);
+ av_log(ctx, AV_LOG_INFO, "The V4L2 driver changed the video from %dx%d to %dx%d\n", *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height);
*width = fmt.fmt.pix.width;
*height = fmt.fmt.pix.height;
}
@@ -213,8 +220,9 @@ static enum PixelFormat fmt_v4l2ff(uint32_t pix_fmt)
return -1;
}
-static int mmap_init(struct video_data *s)
+static int mmap_init(AVFormatContext *ctx)
{
+ struct video_data *s = ctx->priv_data;
struct v4l2_requestbuffers req;
int i, res;
@@ -225,29 +233,29 @@ static int mmap_init(struct video_data *s)
res = ioctl (s->fd, VIDIOC_REQBUFS, &req);
if (res < 0) {
if (errno == EINVAL) {
- av_log(NULL, AV_LOG_ERROR, "Device does not support mmap\n");
+ av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
} else {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
}
return -1;
}
if (req.count < 2) {
- av_log(NULL, AV_LOG_ERROR, "Insufficient buffer memory\n");
+ av_log(ctx, AV_LOG_ERROR, "Insufficient buffer memory\n");
return -1;
}
s->buffers = req.count;
s->buf_start = av_malloc(sizeof(void *) * s->buffers);
if (s->buf_start == NULL) {
- av_log(NULL, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
+ av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
return -1;
}
s->buf_len = av_malloc(sizeof(unsigned int) * s->buffers);
if (s->buf_len == NULL) {
- av_log(NULL, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
+ av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
av_free(s->buf_start);
return -1;
@@ -262,21 +270,21 @@ static int mmap_init(struct video_data *s)
buf.index = i;
res = ioctl (s->fd, VIDIOC_QUERYBUF, &buf);
if (res < 0) {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
return -1;
}
s->buf_len[i] = buf.length;
if (s->buf_len[i] < s->frame_size) {
- av_log(NULL, AV_LOG_ERROR, "Buffer len [%d] = %d != %d\n", i, s->buf_len[i], s->frame_size);
+ av_log(ctx, AV_LOG_ERROR, "Buffer len [%d] = %d != %d\n", i, s->buf_len[i], s->frame_size);
return -1;
}
s->buf_start[i] = mmap (NULL, buf.length,
PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, buf.m.offset);
if (s->buf_start[i] == MAP_FAILED) {
- av_log(NULL, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
+ av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return -1;
}
@@ -285,14 +293,37 @@ static int mmap_init(struct video_data *s)
return 0;
}
-static int read_init(struct video_data *s)
+static int read_init(AVFormatContext *ctx)
{
return -1;
}
-static int mmap_read_frame(struct video_data *s, void *frame, int64_t *ts)
+static void mmap_release_buffer(AVPacket *pkt)
{
struct v4l2_buffer buf;
+ int res, fd;
+ struct buff_data *buf_descriptor = pkt->priv;
+
+ memset(&buf, 0, sizeof(struct v4l2_buffer));
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = buf_descriptor->index;
+ fd = buf_descriptor->fd;
+ av_free(buf_descriptor);
+
+ res = ioctl (fd, VIDIOC_QBUF, &buf);
+ if (res < 0) {
+ av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
+ }
+ pkt->data = NULL;
+ pkt->size = 0;
+}
+
+static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
+{
+ struct video_data *s = ctx->priv_data;
+ struct v4l2_buffer buf;
+ struct buff_data *buf_descriptor;
int res;
memset(&buf, 0, sizeof(struct v4l2_buffer));
@@ -303,38 +334,47 @@ static int mmap_read_frame(struct video_data *s, void *frame, int64_t *ts)
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 &&
((errno == EAGAIN) || (errno == EINTR)));
if (res < 0) {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno));
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno));
return -1;
}
assert (buf.index < s->buffers);
if (buf.bytesused != s->frame_size) {
- av_log(NULL, AV_LOG_ERROR, "The v4l2 frame is %d bytes, but %d bytes are expected\n", buf.bytesused, s->frame_size);
+ av_log(ctx, AV_LOG_ERROR, "The v4l2 frame is %d bytes, but %d bytes are expected\n", buf.bytesused, s->frame_size);
return -1;
}
/* Image is at s->buff_start[buf.index] */
- memcpy(frame, s->buf_start[buf.index], buf.bytesused);
- *ts = buf.timestamp.tv_sec * int64_t_C(1000000) + buf.timestamp.tv_usec;
-
- res = ioctl (s->fd, VIDIOC_QBUF, &buf);
- if (res < 0) {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
+ pkt->data= s->buf_start[buf.index];
+ pkt->size = buf.bytesused;
+ pkt->pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec;
+ pkt->destruct = mmap_release_buffer;
+ buf_descriptor = av_malloc(sizeof(struct buff_data));
+ if (buf_descriptor == NULL) {
+ /* Something went wrong... Since av_malloc() failed, we cannot even
+ * allocate a buffer for memcopying into it
+ */
+ av_log(ctx, AV_LOG_ERROR, "Failed to allocate a buffer descriptor\n");
+ res = ioctl (s->fd, VIDIOC_QBUF, &buf);
return -1;
}
+ buf_descriptor->fd = s->fd;
+ buf_descriptor->index = buf.index;
+ pkt->priv = buf_descriptor;
return s->buf_len[buf.index];
}
-static int read_frame(struct video_data *s, void *frame, int64_t *ts)
+static int read_frame(AVFormatContext *ctx, AVPacket *pkt)
{
return -1;
}
-static int mmap_start(struct video_data *s)
+static int mmap_start(AVFormatContext *ctx)
{
+ struct video_data *s = ctx->priv_data;
enum v4l2_buf_type type;
int i, res;
@@ -348,7 +388,7 @@ static int mmap_start(struct video_data *s)
res = ioctl (s->fd, VIDIOC_QBUF, &buf);
if (res < 0) {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", strerror(errno));
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", strerror(errno));
return -1;
}
@@ -357,7 +397,7 @@ static int mmap_start(struct video_data *s)
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
res = ioctl (s->fd, VIDIOC_STREAMON, &type);
if (res < 0) {
- av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_STREAMON): %s\n", strerror(errno));
+ av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_STREAMON): %s\n", strerror(errno));
return -1;
}
@@ -382,6 +422,57 @@ static void mmap_close(struct video_data *s)
av_free(s->buf_len);
}
+static int v4l2_set_parameters( AVFormatContext *s1, AVFormatParameters *ap )
+{
+ struct video_data *s = s1->priv_data;
+ struct v4l2_input input;
+ struct v4l2_standard standard;
+ int i;
+
+ /* set tv video input */
+ memset (&input, 0, sizeof (input));
+ input.index = ap->channel;
+ if(ioctl (s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
+ av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
+ return AVERROR_IO;
+ }
+
+ av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set input_id: %d, input: %s\n",
+ ap->channel, input.name);
+ if(ioctl (s->fd, VIDIOC_S_INPUT, &input.index) < 0 ) {
+ av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set input(%d) failed\n",
+ ap->channel);
+ return AVERROR_IO;
+ }
+
+ av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n",
+ ap->standard );
+ /* set tv standard */
+ memset (&standard, 0, sizeof (standard));
+ for(i=0;;i++) {
+ standard.index = i;
+ if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
+ av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
+ ap->standard);
+ return AVERROR_IO;
+ }
+
+ if(!strcasecmp(standard.name, ap->standard)) {
+ break;
+ }
+ }
+
+ av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",
+ ap->standard, standard.id);
+ if (ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) {
+ av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
+ ap->standard);
+ return AVERROR_IO;
+ }
+
+ return 0;
+}
+
static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
struct video_data *s = s1->priv_data;
@@ -389,7 +480,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
int width, height;
int res, frame_rate, frame_rate_base;
uint32_t desired_format, capabilities;
- const char *video_device;
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "Missing/Wrong parameters\n");
@@ -410,7 +500,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0);
if (!st) {
- return -ENOMEM;
+ return AVERROR(ENOMEM);
}
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
@@ -419,12 +509,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->frame_rate = frame_rate;
s->frame_rate_base = frame_rate_base;
- video_device = ap->device;
- if (!video_device) {
- video_device = "/dev/video";
- }
capabilities = 0;
- s->fd = device_open(video_device, &capabilities);
+ s->fd = device_open(s1, &capabilities);
if (s->fd < 0) {
av_free(st);
@@ -433,13 +519,13 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
av_log(s1, AV_LOG_INFO, "[%d]Capabilities: %x\n", s->fd, capabilities);
desired_format = fmt_ff2v4l(ap->pix_fmt);
- if (desired_format == 0 || (device_init(s->fd, &width, &height, desired_format) < 0)) {
+ if (desired_format == 0 || (device_init(s1, &width, &height, desired_format) < 0)) {
int i, done;
done = 0; i = 0;
while (!done) {
desired_format = fmt_conversion_table[i].v4l2_fmt;
- if (device_init(s->fd, &width, &height, desired_format) < 0) {
+ if (device_init(s1, &width, &height, desired_format) < 0) {
desired_format = 0;
i++;
} else {
@@ -459,17 +545,20 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
s->frame_format = desired_format;
+ if( v4l2_set_parameters( s1, ap ) < 0 )
+ return AVERROR_IO;
+
st->codec->pix_fmt = fmt_v4l2ff(desired_format);
s->frame_size = avpicture_get_size(st->codec->pix_fmt, width, height);
if (capabilities & V4L2_CAP_STREAMING) {
s->io_method = io_mmap;
- res = mmap_init(s);
+ res = mmap_init(s1);
if (res == 0) {
- res = mmap_start(s);
+ res = mmap_start(s1);
}
} else {
s->io_method = io_read;
- res = read_init(s);
+ res = read_init(s1);
}
if (res < 0) {
close(s->fd);
@@ -495,13 +584,14 @@ static int v4l2_read_packet(AVFormatContext *s1, AVPacket *pkt)
struct video_data *s = s1->priv_data;
int res;
- if (av_new_packet(pkt, s->frame_size) < 0)
- return AVERROR_IO;
-
if (s->io_method == io_mmap) {
- res = mmap_read_frame(s, pkt->data, &pkt->pts);
+ av_init_packet(pkt);
+ res = mmap_read_frame(s1, pkt);
} else if (s->io_method == io_read) {
- res = read_frame(s, pkt->data, &pkt->pts);
+ if (av_new_packet(pkt, s->frame_size) < 0)
+ return AVERROR_IO;
+
+ res = read_frame(s1, pkt);
} else {
return AVERROR_IO;
}
diff --git a/contrib/ffmpeg/libavformat/voc.c b/contrib/ffmpeg/libavformat/voc.c
index 329f07739..97b73d163 100644
--- a/contrib/ffmpeg/libavformat/voc.c
+++ b/contrib/ffmpeg/libavformat/voc.c
@@ -23,7 +23,7 @@
const unsigned char voc_magic[21] = "Creative Voice File\x1A";
-const CodecTag voc_codec_tags[] = {
+const AVCodecTag voc_codec_tags[] = {
{CODEC_ID_PCM_U8, 0x00},
{CODEC_ID_ADPCM_SBPRO_4, 0x01},
{CODEC_ID_ADPCM_SBPRO_3, 0x02},
diff --git a/contrib/ffmpeg/libavformat/voc.h b/contrib/ffmpeg/libavformat/voc.h
index 16adb0078..9b2bb8cce 100644
--- a/contrib/ffmpeg/libavformat/voc.h
+++ b/contrib/ffmpeg/libavformat/voc.h
@@ -43,7 +43,7 @@ typedef enum voc_type {
} voc_type_t;
extern const unsigned char voc_magic[21];
-extern const CodecTag voc_codec_tags[];
+extern const AVCodecTag voc_codec_tags[];
int voc_get_packet(AVFormatContext *s, AVPacket *pkt,
AVStream *st, int max_size);
diff --git a/contrib/ffmpeg/libavformat/vocdec.c b/contrib/ffmpeg/libavformat/vocdec.c
index 6a7869227..85d304dff 100644
--- a/contrib/ffmpeg/libavformat/vocdec.c
+++ b/contrib/ffmpeg/libavformat/vocdec.c
@@ -22,7 +22,6 @@
#include "voc.h"
-static const int voc_max_pkt_size = 2048;
static int voc_probe(AVProbeData *p)
@@ -51,7 +50,7 @@ static int voc_read_header(AVFormatContext *s, AVFormatParameters *ap)
url_fskip(pb, 20);
header_size = get_le16(pb) - 22;
if (header_size != 4) {
- av_log(s, AV_LOG_ERROR, "unkown header size: %d\n", header_size);
+ av_log(s, AV_LOG_ERROR, "unknown header size: %d\n", header_size);
return AVERROR_NOTSUPP;
}
url_fskip(pb, header_size);
@@ -128,7 +127,7 @@ voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
dec->bit_rate = dec->sample_rate * dec->bits_per_sample;
if (max_size <= 0)
- max_size = voc_max_pkt_size;
+ max_size = 2048;
size = FFMIN(voc->remaining_size, max_size);
voc->remaining_size -= size;
return av_get_packet(pb, pkt, size);
@@ -152,4 +151,5 @@ AVInputFormat voc_demuxer = {
voc_read_header,
voc_read_packet,
voc_read_close,
+ .codec_tag=(const AVCodecTag*[]){voc_codec_tags, 0},
};
diff --git a/contrib/ffmpeg/libavformat/vocenc.c b/contrib/ffmpeg/libavformat/vocenc.c
index ed304883d..6a07c92dd 100644
--- a/contrib/ffmpeg/libavformat/vocenc.c
+++ b/contrib/ffmpeg/libavformat/vocenc.c
@@ -51,28 +51,26 @@ static int voc_write_packet(AVFormatContext *s, AVPacket *pkt)
ByteIOContext *pb = &s->pb;
if (!voc->param_written) {
- int format = codec_get_tag(voc_codec_tags, enc->codec_id);
-
- if (format > 0xFF) {
+ if (enc->codec_tag > 0xFF) {
put_byte(pb, VOC_TYPE_NEW_VOICE_DATA);
put_le24(pb, pkt->size + 12);
put_le32(pb, enc->sample_rate);
put_byte(pb, enc->bits_per_sample);
put_byte(pb, enc->channels);
- put_le16(pb, format);
+ put_le16(pb, enc->codec_tag);
put_le32(pb, 0);
} else {
if (s->streams[0]->codec->channels > 1) {
put_byte(pb, VOC_TYPE_EXTENDED);
put_le24(pb, 4);
put_le16(pb, 65536-256000000/(enc->sample_rate*enc->channels));
- put_byte(pb, format);
+ put_byte(pb, enc->codec_tag);
put_byte(pb, enc->channels - 1);
}
put_byte(pb, VOC_TYPE_VOICE_DATA);
put_le24(pb, pkt->size + 2);
put_byte(pb, 256 - 1000000 / enc->sample_rate);
- put_byte(pb, format);
+ put_byte(pb, enc->codec_tag);
}
voc->param_written = 1;
} else {
@@ -101,4 +99,5 @@ AVOutputFormat voc_muxer = {
voc_write_header,
voc_write_packet,
voc_write_trailer,
+ .codec_tag=(const AVCodecTag*[]){voc_codec_tags, 0},
};
diff --git a/contrib/ffmpeg/libavformat/wav.c b/contrib/ffmpeg/libavformat/wav.c
index 7fb982349..0699bec70 100644
--- a/contrib/ffmpeg/libavformat/wav.c
+++ b/contrib/ffmpeg/libavformat/wav.c
@@ -25,6 +25,9 @@
typedef struct {
offset_t data;
offset_t data_end;
+ int64_t minpts;
+ int64_t maxpts;
+ int last_duration;
} WAVContext;
#ifdef CONFIG_MUXERS
@@ -32,7 +35,7 @@ static int wav_write_header(AVFormatContext *s)
{
WAVContext *wav = s->priv_data;
ByteIOContext *pb = &s->pb;
- offset_t fmt;
+ offset_t fmt, fact;
put_tag(pb, "RIFF");
put_le32(pb, 0); /* file length */
@@ -46,7 +49,16 @@ static int wav_write_header(AVFormatContext *s)
}
end_tag(pb, fmt);
+ if(s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
+ && !url_is_streamed(&s->pb)) {
+ fact = start_tag(pb, "fact");
+ put_le32(pb, 0);
+ end_tag(pb, fact);
+ }
+
av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
+ wav->maxpts = wav->last_duration = 0;
+ wav->minpts = INT64_MAX;
/* data header */
wav->data = start_tag(pb, "data");
@@ -59,7 +71,14 @@ static int wav_write_header(AVFormatContext *s)
static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
{
ByteIOContext *pb = &s->pb;
+ WAVContext *wav = s->priv_data;
put_buffer(pb, pkt->data, pkt->size);
+ if(pkt->pts != AV_NOPTS_VALUE) {
+ wav->minpts = FFMIN(wav->minpts, pkt->pts);
+ wav->maxpts = FFMAX(wav->maxpts, pkt->pts);
+ wav->last_duration = pkt->duration;
+ } else
+ av_log(s, AV_LOG_ERROR, "wav_write_packet: NOPTS\n");
return 0;
}
@@ -79,6 +98,18 @@ static int wav_write_trailer(AVFormatContext *s)
url_fseek(pb, file_size, SEEK_SET);
put_flush_packet(pb);
+
+ if(s->streams[0]->codec->codec_tag != 0x01) {
+ /* Update num_samps in fact chunk */
+ int number_of_samples;
+ number_of_samples = av_rescale(wav->maxpts - wav->minpts + wav->last_duration,
+ s->streams[0]->codec->sample_rate * (int64_t)s->streams[0]->time_base.num,
+ s->streams[0]->time_base.den);
+ url_fseek(pb, wav->data-12, SEEK_SET);
+ put_le32(pb, number_of_samples);
+ url_fseek(pb, file_size, SEEK_SET);
+ put_flush_packet(pb);
+ }
}
return 0;
}
@@ -188,13 +219,11 @@ static int wav_read_packet(AVFormatContext *s,
size = (size / st->codec->block_align) * st->codec->block_align;
}
size= FFMIN(size, left);
- if (av_new_packet(pkt, size))
+ ret= av_get_packet(&s->pb, pkt, size);
+ if (ret <= 0)
return AVERROR_IO;
pkt->stream_index = 0;
- ret = get_buffer(&s->pb, pkt->data, pkt->size);
- if (ret < 0)
- av_free_packet(pkt);
/* note: we need to modify the packet size here to handle the last
packet */
pkt->size = ret;
@@ -235,6 +264,8 @@ AVInputFormat wav_demuxer = {
wav_read_packet,
wav_read_close,
wav_read_seek,
+ .flags= AVFMT_GENERIC_INDEX,
+ .codec_tag= (const AVCodecTag*[]){codec_wav_tags, 0},
};
#endif
#ifdef CONFIG_WAV_MUXER
@@ -249,5 +280,6 @@ AVOutputFormat wav_muxer = {
wav_write_header,
wav_write_packet,
wav_write_trailer,
+ .codec_tag= (const AVCodecTag*[]){codec_wav_tags, 0},
};
#endif
diff --git a/contrib/ffmpeg/libavformat/wc3movie.c b/contrib/ffmpeg/libavformat/wc3movie.c
index 6b3242797..3e58a1bba 100644
--- a/contrib/ffmpeg/libavformat/wc3movie.c
+++ b/contrib/ffmpeg/libavformat/wc3movie.c
@@ -115,8 +115,8 @@ static int wc3_probe(AVProbeData *p)
if (p->buf_size < 12)
return 0;
- if ((LE_32(&p->buf[0]) != FORM_TAG) ||
- (LE_32(&p->buf[8]) != MOVE_TAG))
+ if ((AV_RL32(&p->buf[0]) != FORM_TAG) ||
+ (AV_RL32(&p->buf[8]) != MOVE_TAG))
return 0;
return AVPROBE_SCORE_MAX;
@@ -153,8 +153,8 @@ static int wc3_read_header(AVFormatContext *s,
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
return AVERROR_IO;
- fourcc_tag = LE_32(&preamble[0]);
- size = (BE_32(&preamble[4]) + 1) & (~1);
+ fourcc_tag = AV_RL32(&preamble[0]);
+ size = (AV_RB32(&preamble[4]) + 1) & (~1);
do {
switch (fourcc_tag) {
@@ -170,7 +170,7 @@ static int wc3_read_header(AVFormatContext *s,
url_fseek(pb, 8, SEEK_CUR);
if ((ret = get_buffer(pb, preamble, 4)) != 4)
return AVERROR_IO;
- wc3->palette_count = LE_32(&preamble[0]);
+ wc3->palette_count = AV_RL32(&preamble[0]);
if((unsigned)wc3->palette_count >= UINT_MAX / PALETTE_SIZE){
wc3->palette_count= 0;
return -1;
@@ -193,8 +193,8 @@ static int wc3_read_header(AVFormatContext *s,
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
return AVERROR_IO;
- wc3->width = LE_32(&preamble[0]);
- wc3->height = LE_32(&preamble[4]);
+ wc3->width = AV_RL32(&preamble[0]);
+ wc3->height = AV_RL32(&preamble[4]);
break;
case PALT_TAG:
@@ -229,9 +229,9 @@ static int wc3_read_header(AVFormatContext *s,
if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
WC3_PREAMBLE_SIZE)
return AVERROR_IO;
- fourcc_tag = LE_32(&preamble[0]);
+ fourcc_tag = AV_RL32(&preamble[0]);
/* chunk sizes are 16-bit aligned */
- size = (BE_32(&preamble[4]) + 1) & (~1);
+ size = (AV_RB32(&preamble[4]) + 1) & (~1);
} while (fourcc_tag != BRCH_TAG);
@@ -291,9 +291,9 @@ static int wc3_read_packet(AVFormatContext *s,
WC3_PREAMBLE_SIZE)
ret = AVERROR_IO;
- fourcc_tag = LE_32(&preamble[0]);
+ fourcc_tag = AV_RL32(&preamble[0]);
/* chunk sizes are 16-bit aligned */
- size = (BE_32(&preamble[4]) + 1) & (~1);
+ size = (AV_RB32(&preamble[4]) + 1) & (~1);
switch (fourcc_tag) {
@@ -305,7 +305,7 @@ static int wc3_read_packet(AVFormatContext *s,
/* load up new palette */
if ((ret = get_buffer(pb, preamble, 4)) != 4)
return AVERROR_IO;
- palette_number = LE_32(&preamble[0]);
+ palette_number = AV_RL32(&preamble[0]);
if (palette_number >= wc3->palette_count)
return AVERROR_INVALIDDATA;
base_palette_index = palette_number * PALETTE_COUNT * 3;
diff --git a/contrib/ffmpeg/libavformat/westwood.c b/contrib/ffmpeg/libavformat/westwood.c
index 5c42e3b55..bed2f0d14 100644
--- a/contrib/ffmpeg/libavformat/westwood.c
+++ b/contrib/ffmpeg/libavformat/westwood.c
@@ -101,7 +101,7 @@ static int wsaud_probe(AVProbeData *p)
return 0;
/* check sample rate */
- field = LE_16(&p->buf[0]);
+ field = AV_RL16(&p->buf[0]);
if ((field < 8000) || (field > 48000))
return 0;
@@ -124,7 +124,7 @@ static int wsaud_read_header(AVFormatContext *s,
if (get_buffer(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
return AVERROR_IO;
- wsaud->audio_samplerate = LE_16(&header[0]);
+ wsaud->audio_samplerate = AV_RL16(&header[0]);
if (header[11] == 99)
wsaud->audio_type = CODEC_ID_ADPCM_IMA_WS;
else
@@ -170,10 +170,10 @@ static int wsaud_read_packet(AVFormatContext *s,
return AVERROR_IO;
/* validate the chunk */
- if (LE_32(&preamble[4]) != AUD_CHUNK_SIGNATURE)
+ if (AV_RL32(&preamble[4]) != AUD_CHUNK_SIGNATURE)
return AVERROR_INVALIDDATA;
- chunk_size = LE_16(&preamble[0]);
+ chunk_size = AV_RL16(&preamble[0]);
ret= av_get_packet(pb, pkt, chunk_size);
if (ret != chunk_size)
return AVERROR_IO;
@@ -202,8 +202,8 @@ static int wsvqa_probe(AVProbeData *p)
return 0;
/* check for the VQA signatures */
- if ((BE_32(&p->buf[0]) != FORM_TAG) ||
- (BE_32(&p->buf[8]) != WVQA_TAG))
+ if ((AV_RB32(&p->buf[0]) != FORM_TAG) ||
+ (AV_RB32(&p->buf[8]) != WVQA_TAG))
return 0;
return AVPROBE_SCORE_MAX;
@@ -224,7 +224,7 @@ static int wsvqa_read_header(AVFormatContext *s,
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
- av_set_pts_info(st, 33, 1, 90000);
+ av_set_pts_info(st, 33, 1, VQA_FRAMERATE);
wsvqa->video_stream_index = st->index;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_WS_VQA;
@@ -242,25 +242,22 @@ static int wsvqa_read_header(AVFormatContext *s,
av_free(st->codec->extradata);
return AVERROR_IO;
}
- st->codec->width = LE_16(&header[6]);
- st->codec->height = LE_16(&header[8]);
-
- st->codec->time_base.num = 1;
- st->codec->time_base.den = VQA_FRAMERATE;
+ st->codec->width = AV_RL16(&header[6]);
+ st->codec->height = AV_RL16(&header[8]);
/* initialize the audio decoder stream for VQA v1 or nonzero samplerate */
- if (LE_16(&header[24]) || (LE_16(&header[0]) == 1)) {
+ if (AV_RL16(&header[24]) || (AV_RL16(&header[0]) == 1 && AV_RL16(&header[2]) == 1)) {
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
- av_set_pts_info(st, 33, 1, 90000);
+ av_set_pts_info(st, 33, 1, VQA_FRAMERATE);
st->codec->codec_type = CODEC_TYPE_AUDIO;
- if (LE_16(&header[0]) == 1)
+ if (AV_RL16(&header[0]) == 1)
st->codec->codec_id = CODEC_ID_WESTWOOD_SND1;
else
st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
st->codec->codec_tag = 0; /* no tag */
- st->codec->sample_rate = LE_16(&header[24]);
+ st->codec->sample_rate = AV_RL16(&header[24]);
if (!st->codec->sample_rate)
st->codec->sample_rate = 22050;
st->codec->channels = header[26];
@@ -284,8 +281,8 @@ static int wsvqa_read_header(AVFormatContext *s,
av_free(st->codec->extradata);
return AVERROR_IO;
}
- chunk_tag = BE_32(&scratch[0]);
- chunk_size = BE_32(&scratch[4]);
+ chunk_tag = AV_RB32(&scratch[0]);
+ chunk_size = AV_RB32(&scratch[4]);
/* catch any unknown header tags, for curiousity */
switch (chunk_tag) {
@@ -326,8 +323,8 @@ static int wsvqa_read_packet(AVFormatContext *s,
int skip_byte;
while (get_buffer(pb, preamble, VQA_PREAMBLE_SIZE) == VQA_PREAMBLE_SIZE) {
- chunk_type = BE_32(&preamble[0]);
- chunk_size = BE_32(&preamble[4]);
+ chunk_type = AV_RB32(&preamble[0]);
+ chunk_size = AV_RB32(&preamble[4]);
skip_byte = chunk_size & 0x01;
if ((chunk_type == SND1_TAG) || (chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) {
@@ -342,25 +339,14 @@ static int wsvqa_read_packet(AVFormatContext *s,
if (chunk_type == SND2_TAG) {
pkt->stream_index = wsvqa->audio_stream_index;
-
- pkt->pts = 90000;
- pkt->pts *= wsvqa->audio_frame_counter;
- pkt->pts /= wsvqa->audio_samplerate;
-
/* 2 samples/byte, 1 or 2 samples per frame depending on stereo */
wsvqa->audio_frame_counter += (chunk_size * 2) / wsvqa->audio_channels;
} else if(chunk_type == SND1_TAG) {
pkt->stream_index = wsvqa->audio_stream_index;
-
- pkt->pts = 90000;
- pkt->pts *= wsvqa->audio_frame_counter;
- pkt->pts /= wsvqa->audio_samplerate;
-
/* unpacked size is stored in header */
- wsvqa->audio_frame_counter += LE_16(pkt->data) / wsvqa->audio_channels;
+ wsvqa->audio_frame_counter += AV_RL16(pkt->data) / wsvqa->audio_channels;
} else {
pkt->stream_index = wsvqa->video_stream_index;
- pkt->pts = wsvqa->video_pts;
wsvqa->video_pts += VQA_VIDEO_PTS_INC;
}
/* stay on 16-bit alignment */
diff --git a/contrib/ffmpeg/libavformat/wv.c b/contrib/ffmpeg/libavformat/wv.c
index 2de07fe3f..ed1eefeea 100644
--- a/contrib/ffmpeg/libavformat/wv.c
+++ b/contrib/ffmpeg/libavformat/wv.c
@@ -50,8 +50,10 @@ static const int wv_rates[16] = {
typedef struct{
uint32_t blksize, flags;
int rate, chan, bpp;
+ uint32_t samples, soff;
int block_parsed;
uint8_t extra[WV_EXTRA_SIZE];
+ int64_t pos;
}WVContext;
static int wv_probe(AVProbeData *p)
@@ -73,6 +75,7 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb)
int size;
int rate, bpp, chan;
+ wc->pos = url_ftell(pb);
tag = get_le32(pb);
if (tag != MKTAG('w', 'v', 'p', 'k'))
return -1;
@@ -89,10 +92,10 @@ static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb)
}
get_byte(pb); // track no
get_byte(pb); // track sub index
- get_le32(pb); // total samples in file
- get_le32(pb); // offset in samples of current block
+ wc->samples = get_le32(pb); // total samples in file
+ wc->soff = get_le32(pb); // offset in samples of current block
get_buffer(pb, wc->extra, WV_EXTRA_SIZE);
- wc->flags = LE_32(wc->extra + 4);
+ wc->flags = AV_RL32(wc->extra + 4);
//parse flags
if(wc->flags & WV_FLOAT){
av_log(ctx, AV_LOG_ERROR, "Floating point data is not supported\n");
@@ -155,6 +158,8 @@ static int wv_read_header(AVFormatContext *s,
st->codec->sample_rate = wc->rate;
st->codec->bits_per_sample = wc->bpp;
av_set_pts_info(st, 64, 1, wc->rate);
+ s->start_time = 0;
+ s->duration = (int64_t)wc->samples * AV_TIME_BASE / st->codec->sample_rate;
return 0;
}
@@ -165,7 +170,7 @@ static int wv_read_packet(AVFormatContext *s,
int ret;
if (url_feof(&s->pb))
- return -EIO;
+ return AVERROR(EIO);
if(wc->block_parsed){
if(wv_read_block_header(s, &s->pb) < 0)
return -1;
@@ -182,7 +187,8 @@ static int wv_read_packet(AVFormatContext *s,
pkt->stream_index = 0;
wc->block_parsed = 1;
pkt->size = ret + WV_EXTRA_SIZE;
-
+ pkt->pts = wc->soff;
+ av_add_index_entry(s->streams[0], wc->pos, pkt->pts, 0, 0, AVINDEX_KEYFRAME);
return 0;
}
@@ -191,6 +197,38 @@ static int wv_read_close(AVFormatContext *s)
return 0;
}
+static int wv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+{
+ AVStream *st = s->streams[stream_index];
+ WVContext *wc = s->priv_data;
+ AVPacket pkt1, *pkt = &pkt1;
+ int ret;
+ int index = av_index_search_timestamp(st, timestamp, flags);
+ int64_t pos, pts;
+
+ /* if found, seek there */
+ if (index >= 0){
+ wc->block_parsed = 1;
+ url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET);
+ return 0;
+ }
+ /* if timestamp is out of bounds, return error */
+ if(timestamp < 0 || timestamp >= s->duration)
+ return -1;
+
+ pos = url_ftell(&s->pb);
+ do{
+ ret = av_read_frame(s, pkt);
+ if (ret < 0){
+ url_fseek(&s->pb, pos, SEEK_SET);
+ return -1;
+ }
+ pts = pkt->pts;
+ av_free_packet(pkt);
+ }while(pts < timestamp);
+ return 0;
+}
+
AVInputFormat wv_demuxer = {
"wv",
"WavPack",
@@ -199,4 +237,5 @@ AVInputFormat wv_demuxer = {
wv_read_header,
wv_read_packet,
wv_read_close,
+ wv_read_seek,
};
diff --git a/contrib/ffmpeg/libavformat/x11grab.c b/contrib/ffmpeg/libavformat/x11grab.c
new file mode 100644
index 000000000..8916d799a
--- /dev/null
+++ b/contrib/ffmpeg/libavformat/x11grab.c
@@ -0,0 +1,529 @@
+/*
+ * X11 video grab interface
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg integration:
+ * Copyright (C) 2006 Clemens Fruhwirth <clemens@endorphin.org>
+ * Edouard Gomez <ed.gomez@free.fr>
+ *
+ * This file contains code from grab.c:
+ * Copyright (c) 2000-2001 Fabrice Bellard
+ *
+ * This file contains code from the xvidcap project:
+ * Copyright (C) 1997-1998 Rasca, Berlin
+ * 2003-2004 Karl H. Beckers, Frankfurt
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 x11grab.c
+ * X11 frame device demuxer by Clemens Fruhwirth <clemens@endorphin.org>
+ * and Edouard Gomez <ed.gomez@free.fr>.
+ */
+
+#include "avformat.h"
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#define _LINUX_TIME_H 1
+#include <time.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xproto.h>
+#include <X11/Xutil.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+
+/**
+ * X11 Device Demuxer context
+ */
+typedef struct x11_grab_s
+{
+ int frame_size; /**< Size in bytes of a grabbed frame */
+ AVRational time_base; /**< Time base */
+ int64_t time_frame; /**< Current time */
+
+ int height; /**< Height of the grab frame */
+ int width; /**< Width of the grab frame */
+ int x_off; /**< Horizontal top-left corner coordinate */
+ int y_off; /**< Vertical top-left corner coordinate */
+
+ Display *dpy; /**< X11 display from which x11grab grabs frames */
+ XImage *image; /**< X11 image holding the grab */
+ int use_shm; /**< !0 when using XShm extension */
+ XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */
+ int mouse_warning_shown;
+} x11_grab_t;
+
+/**
+ * Initializes the x11 grab device demuxer (public device demuxer API).
+ *
+ * @param s1 Context from avformat core
+ * @param ap Parameters from avformat core
+ * @return <ul>
+ * <li>ENOMEM no memory left</li>
+ * <li>AVERROR_IO other failure case</li>
+ * <li>0 success</li>
+ * </ul>
+ */
+static int
+x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
+{
+ x11_grab_t *x11grab = s1->priv_data;
+ Display *dpy;
+ AVStream *st = NULL;
+ int input_pixfmt;
+ XImage *image;
+ int x_off = 0;
+ int y_off = 0;
+ int use_shm;
+ char *param, *offset;
+
+ param = av_strdup(s1->filename);
+ offset = strchr(param, '+');
+ if (offset) {
+ sscanf(offset, "%d,%d", &x_off, &y_off);
+ *offset= 0;
+ }
+
+ av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", s1->filename, param, x_off, y_off, ap->width, ap->height);
+
+ dpy = XOpenDisplay(param);
+ if(!dpy) {
+ av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
+ return AVERROR_IO;
+ }
+
+ if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
+ av_log(s1, AV_LOG_ERROR, "AVParameters don't have any video size. Use -s.\n");
+ return AVERROR_IO;
+ }
+
+ st = av_new_stream(s1, 0);
+ if (!st) {
+ return AVERROR(ENOMEM);
+ }
+ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
+
+ use_shm = XShmQueryExtension(dpy);
+ av_log(s1, AV_LOG_INFO, "shared memory extension %s found\n", use_shm ? "" : "not");
+
+ if(use_shm) {
+ int scr = XDefaultScreen(dpy);
+ image = XShmCreateImage(dpy,
+ DefaultVisual(dpy, scr),
+ DefaultDepth(dpy, scr),
+ ZPixmap,
+ NULL,
+ &x11grab->shminfo,
+ ap->width, ap->height);
+ x11grab->shminfo.shmid = shmget(IPC_PRIVATE,
+ image->bytes_per_line * image->height,
+ IPC_CREAT|0777);
+ if (x11grab->shminfo.shmid == -1) {
+ av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n");
+ return AVERROR(ENOMEM);
+ }
+ x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0);
+ x11grab->shminfo.readOnly = False;
+
+ if (!XShmAttach(dpy, &x11grab->shminfo)) {
+ av_log(s1, AV_LOG_ERROR, "Fatal: Failed to attach shared memory!\n");
+ /* needs some better error subroutine :) */
+ return AVERROR_IO;
+ }
+ } else {
+ image = XGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)),
+ x_off,y_off,
+ ap->width,ap->height,
+ AllPlanes, ZPixmap);
+ }
+
+ switch (image->bits_per_pixel) {
+ case 8:
+ av_log (s1, AV_LOG_DEBUG, "8 bit palette\n");
+ input_pixfmt = PIX_FMT_PAL8;
+ break;
+ case 16:
+ if ( image->red_mask == 0xf800 &&
+ image->green_mask == 0x07e0 &&
+ image->blue_mask == 0x001f ) {
+ av_log (s1, AV_LOG_DEBUG, "16 bit RGB565\n");
+ input_pixfmt = PIX_FMT_RGB565;
+ } else if (image->red_mask == 0x7c00 &&
+ image->green_mask == 0x03e0 &&
+ image->blue_mask == 0x001f ) {
+ av_log(s1, AV_LOG_DEBUG, "16 bit RGB555\n");
+ input_pixfmt = PIX_FMT_RGB555;
+ } else {
+ av_log(s1, AV_LOG_ERROR, "RGB ordering at image depth %i not supported ... aborting\n", image->bits_per_pixel);
+ av_log(s1, AV_LOG_ERROR, "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n", image->red_mask, image->green_mask, image->blue_mask);
+ return AVERROR_IO;
+ }
+ break;
+ case 24:
+ if ( image->red_mask == 0xff0000 &&
+ image->green_mask == 0x00ff00 &&
+ image->blue_mask == 0x0000ff ) {
+ input_pixfmt = PIX_FMT_BGR24;
+ } else if ( image->red_mask == 0x0000ff &&
+ image->green_mask == 0x00ff00 &&
+ image->blue_mask == 0xff0000 ) {
+ input_pixfmt = PIX_FMT_RGB24;
+ } else {
+ av_log(s1, AV_LOG_ERROR,"rgb ordering at image depth %i not supported ... aborting\n", image->bits_per_pixel);
+ av_log(s1, AV_LOG_ERROR, "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n", image->red_mask, image->green_mask, image->blue_mask);
+ return AVERROR_IO;
+ }
+ break;
+ case 32:
+#if 0
+ GetColorInfo (image, &c_info);
+ if ( c_info.alpha_mask == 0xff000000 && image->green_mask == 0x0000ff00) {
+ /* byte order is relevant here, not endianness
+ * endianness is handled by avcodec, but atm no such thing
+ * as having ABGR, instead of ARGB in a word. Since we
+ * need this for Solaris/SPARC, but need to do the conversion
+ * for every frame we do it outside of this loop, cf. below
+ * this matches both ARGB32 and ABGR32 */
+ input_pixfmt = PIX_FMT_ARGB32;
+ } else {
+ av_log(s1, AV_LOG_ERROR,"image depth %i not supported ... aborting\n", image->bits_per_pixel);
+ return AVERROR_IO;
+ }
+#endif
+ input_pixfmt = PIX_FMT_RGB32;
+ break;
+ default:
+ av_log(s1, AV_LOG_ERROR, "image depth %i not supported ... aborting\n", image->bits_per_pixel);
+ return -1;
+ }
+
+ x11grab->frame_size = ap->width * ap->height * image->bits_per_pixel/8;
+ x11grab->dpy = dpy;
+ x11grab->width = ap->width;
+ x11grab->height = ap->height;
+ x11grab->time_base = ap->time_base;
+ x11grab->time_frame = av_gettime() / av_q2d(ap->time_base);
+ x11grab->x_off = x_off;
+ x11grab->y_off = y_off;
+ x11grab->image = image;
+ x11grab->use_shm = use_shm;
+ x11grab->mouse_warning_shown = 0;
+
+ st->codec->codec_type = CODEC_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_RAWVIDEO;
+ st->codec->width = ap->width;
+ st->codec->height = ap->height;
+ st->codec->pix_fmt = input_pixfmt;
+ st->codec->time_base = ap->time_base;
+ st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(ap->time_base) * 8;
+
+ return 0;
+}
+
+/**
+ * Get pointer coordinates from X11.
+ *
+ * @param x Integer where horizontal coordinate will be returned
+ * @param y Integer where vertical coordinate will be returned
+ * @param dpy X11 display from where pointer coordinates are retrieved
+ * @param s1 Context used for logging errors if necessary
+ */
+static void
+get_pointer_coordinates(int *x, int *y, Display *dpy, AVFormatContext *s1)
+{
+ Window mrootwindow, childwindow;
+ int dummy;
+
+ mrootwindow = DefaultRootWindow(dpy);
+
+ if (XQueryPointer(dpy, mrootwindow, &mrootwindow, &childwindow,
+ x, y, &dummy, &dummy, (unsigned int*)&dummy)) {
+ } else {
+ x11_grab_t *s = s1->priv_data;
+ if (!s->mouse_warning_shown) {
+ av_log(s1, AV_LOG_INFO, "couldn't find mouse pointer\n");
+ s->mouse_warning_shown = 1;
+ }
+ *x = -1;
+ *y = -1;
+ }
+}
+
+/**
+ * Mouse painting helper function that applies an 'and' and 'or' mask pair to
+ * '*dst' pixel. It actually draws a mouse pointer pixel to grabbed frame.
+ *
+ * @param dst Destination pixel
+ * @param and Part of the mask that must be applied using a bitwise 'and'
+ * operator
+ * @param or Part of the mask that must be applied using a bitwise 'or'
+ * operator
+ * @param bits_per_pixel Bits per pixel used in the grabbed image
+ */
+static void inline
+apply_masks(uint8_t *dst, int and, int or, int bits_per_pixel)
+{
+ switch (bits_per_pixel) {
+ case 32:
+ *(uint32_t*)dst = (*(uint32_t*)dst & and) | or;
+ break;
+ case 16:
+ *(uint16_t*)dst = (*(uint16_t*)dst & and) | or;
+ break;
+ case 8:
+ *dst = !!or;
+ break;
+ }
+}
+
+/**
+ * Paints a mouse pointer in an X11 image.
+ *
+ * @param image Image where to paint the mouse pointer
+ * @param s context used to retrieve original grabbing rectangle
+ * coordinates
+ * @param x Mouse pointer coordinate
+ * @param y Mouse pointer coordinate
+ */
+static void
+paint_mouse_pointer(XImage *image, x11_grab_t *s, int x, int y)
+{
+ /* 16x20x1bpp bitmap for the black channel of the mouse pointer */
+ static const uint16_t const mousePointerBlack[] =
+ {
+ 0x0000, 0x0003, 0x0005, 0x0009, 0x0011,
+ 0x0021, 0x0041, 0x0081, 0x0101, 0x0201,
+ 0x03c1, 0x0049, 0x0095, 0x0093, 0x0120,
+ 0x0120, 0x0240, 0x0240, 0x0380, 0x0000
+ };
+
+ /* 16x20x1bpp bitmap for the white channel of the mouse pointer */
+ static const uint16_t const mousePointerWhite[] =
+ {
+ 0x0000, 0x0000, 0x0002, 0x0006, 0x000e,
+ 0x001e, 0x003e, 0x007e, 0x00fe, 0x01fe,
+ 0x003e, 0x0036, 0x0062, 0x0060, 0x00c0,
+ 0x00c0, 0x0180, 0x0180, 0x0000, 0x0000
+ };
+
+ int x_off = s->x_off;
+ int y_off = s->y_off;
+ int width = s->width;
+ int height = s->height;
+
+ if ( x - x_off >= 0 && x < width + x_off
+ && y - y_off >= 0 && y < height + y_off) {
+ uint8_t *im_data = (uint8_t*)image->data;
+ int bytes_per_pixel;
+ int line;
+ int masks;
+
+ /* Select correct masks and pixel size */
+ if (image->bits_per_pixel == 8) {
+ masks = 1;
+ } else {
+ masks = (image->red_mask|image->green_mask|image->blue_mask);
+ }
+ bytes_per_pixel = image->bits_per_pixel>>3;
+
+ /* Shift to right line */
+ im_data += image->bytes_per_line * (y - y_off);
+ /* Shift to right pixel in the line */
+ im_data += bytes_per_pixel * (x - x_off);
+
+ /* Draw the cursor - proper loop */
+ for (line = 0; line < FFMIN(20, (y_off + height) - y); line++) {
+ uint8_t *cursor = im_data;
+ int column;
+ uint16_t bm_b;
+ uint16_t bm_w;
+
+ bm_b = mousePointerBlack[line];
+ bm_w = mousePointerWhite[line];
+
+ for (column = 0; column < FFMIN(16, (x_off + width) - x); column++) {
+ apply_masks(cursor, ~(masks*(bm_b&1)), masks*(bm_w&1),
+ image->bits_per_pixel);
+ cursor += bytes_per_pixel;
+ bm_b >>= 1;
+ bm_w >>= 1;
+ }
+ im_data += image->bytes_per_line;
+ }
+ }
+}
+
+
+/**
+ * Reads new data in the image structure.
+ *
+ * @param dpy X11 display to grab from
+ * @param d
+ * @param image Image where the grab will be put
+ * @param x Top-Left grabbing rectangle horizontal coordinate
+ * @param y Top-Left grabbing rectangle vertical coordinate
+ * @return 0 if error, !0 if successful
+ */
+static int
+xget_zpixmap(Display *dpy, Drawable d, XImage *image, int x, int y)
+{
+ xGetImageReply rep;
+ xGetImageReq *req;
+ long nbytes;
+
+ if (!image) {
+ return 0;
+ }
+
+ LockDisplay(dpy);
+ GetReq(GetImage, req);
+
+ /* First set up the standard stuff in the request */
+ req->drawable = d;
+ req->x = x;
+ req->y = y;
+ req->width = image->width;
+ req->height = image->height;
+ req->planeMask = (unsigned int)AllPlanes;
+ req->format = ZPixmap;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.length) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ nbytes = (long)rep.length << 2;
+ _XReadPad(dpy, image->data, nbytes);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+/**
+ * Grabs a frame from x11 (public device demuxer API).
+ *
+ * @param s1 Context from avformat core
+ * @param pkt Packet holding the brabbed frame
+ * @return frame size in bytes
+ */
+static int
+x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
+{
+ x11_grab_t *s = s1->priv_data;
+ Display *dpy = s->dpy;
+ XImage *image = s->image;
+ int x_off = s->x_off;
+ int y_off = s->y_off;
+
+ int64_t curtime, delay;
+ struct timespec ts;
+
+ /* Calculate the time of the next frame */
+ s->time_frame += INT64_C(1000000);
+
+ /* wait based on the frame rate */
+ for(;;) {
+ curtime = av_gettime();
+ delay = s->time_frame * av_q2d(s->time_base) - curtime;
+ if (delay <= 0) {
+ if (delay < INT64_C(-1000000) * av_q2d(s->time_base)) {
+ s->time_frame += INT64_C(1000000);
+ }
+ break;
+ }
+ ts.tv_sec = delay / 1000000;
+ ts.tv_nsec = (delay % 1000000) * 1000;
+ nanosleep(&ts, NULL);
+ }
+
+ if (av_new_packet(pkt, s->frame_size) < 0) {
+ return AVERROR_IO;
+ }
+
+ pkt->pts = curtime;
+
+ if(s->use_shm) {
+ if (!XShmGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off, AllPlanes)) {
+ av_log (s1, AV_LOG_INFO, "XShmGetImage() failed\n");
+ }
+ } else {
+ if (!xget_zpixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), image, x_off, y_off)) {
+ av_log (s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
+ }
+ }
+
+ {
+ int pointer_x, pointer_y;
+ get_pointer_coordinates(&pointer_x, &pointer_y, dpy, s1);
+ paint_mouse_pointer(image, s, pointer_x, pointer_y);
+ }
+
+
+ /* XXX: avoid memcpy */
+ memcpy(pkt->data, image->data, s->frame_size);
+ return s->frame_size;
+}
+
+/**
+ * Closes x11 frame grabber (public device demuxer API).
+ *
+ * @param s1 Context from avformat core
+ * @return 0 success, !0 failure
+ */
+static int
+x11grab_read_close(AVFormatContext *s1)
+{
+ x11_grab_t *x11grab = s1->priv_data;
+
+ /* Detach cleanly from shared mem */
+ if (x11grab->use_shm) {
+ XShmDetach(x11grab->dpy, &x11grab->shminfo);
+ shmdt(x11grab->shminfo.shmaddr);
+ shmctl(x11grab->shminfo.shmid, IPC_RMID, NULL);
+ }
+
+ /* Destroy X11 image */
+ if (x11grab->image) {
+ XDestroyImage(x11grab->image);
+ x11grab->image = NULL;
+ }
+
+ /* Free X11 display */
+ XCloseDisplay(x11grab->dpy);
+ return 0;
+}
+
+/** x11 grabber device demuxer declaration */
+AVInputFormat x11_grab_device_demuxer =
+{
+ "x11grab",
+ "X11grab",
+ sizeof(x11_grab_t),
+ NULL,
+ x11grab_read_header,
+ x11grab_read_packet,
+ x11grab_read_close,
+ .flags = AVFMT_NOFILE,
+};
diff --git a/contrib/ffmpeg/libavformat/yuv.c b/contrib/ffmpeg/libavformat/yuv.c
deleted file mode 100644
index fe52cdea5..000000000
--- a/contrib/ffmpeg/libavformat/yuv.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * .Y.U.V image format
- * Copyright (c) 2003 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 "avformat.h"
-
-static int sizes[][2] = {
- { 640, 480 },
- { 720, 480 },
- { 720, 576 },
- { 352, 288 },
- { 352, 240 },
- { 160, 128 },
- { 512, 384 },
- { 640, 352 },
- { 640, 240 },
-};
-
-static int infer_size(int *width_ptr, int *height_ptr, int size)
-{
- int i;
-
- for(i=0;i<sizeof(sizes)/sizeof(sizes[0]);i++) {
- if ((sizes[i][0] * sizes[i][1]) == size) {
- *width_ptr = sizes[i][0];
- *height_ptr = sizes[i][1];
- return 0;
- }
- }
- return -1;
-}
-
-static int yuv_read(ByteIOContext *f,
- int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
- ByteIOContext pb1, *pb = &pb1;
- int img_size, ret;
- char fname[1024], *p;
- int size;
- URLContext *h;
- AVImageInfo info1, *info = &info1;
-
- img_size = url_fsize(f);
-
- /* XXX: hack hack */
- h = url_fileno(f);
- url_get_filename(h, fname, sizeof(fname));
-
- if (infer_size(&info->width, &info->height, img_size) < 0) {
- return AVERROR_IO;
- }
- info->pix_fmt = PIX_FMT_YUV420P;
-
- ret = alloc_cb(opaque, info);
- if (ret)
- return ret;
-
- size = info->width * info->height;
-
- p = strrchr(fname, '.');
- if (!p || p[1] != 'Y')
- return AVERROR_IO;
-
- get_buffer(f, info->pict.data[0], size);
-
- p[1] = 'U';
- if (url_fopen(pb, fname, URL_RDONLY) < 0)
- return AVERROR_IO;
-
- get_buffer(pb, info->pict.data[1], size / 4);
- url_fclose(pb);
-
- p[1] = 'V';
- if (url_fopen(pb, fname, URL_RDONLY) < 0)
- return AVERROR_IO;
-
- get_buffer(pb, info->pict.data[2], size / 4);
- url_fclose(pb);
- return 0;
-}
-
-static int yuv_write(ByteIOContext *pb2, AVImageInfo *info)
-{
- ByteIOContext pb1, *pb;
- char fname[1024], *p;
- int i, j, width, height;
- uint8_t *ptr;
- URLContext *h;
- static const char *ext = "YUV";
-
- /* XXX: hack hack */
- h = url_fileno(pb2);
- url_get_filename(h, fname, sizeof(fname));
-
- p = strrchr(fname, '.');
- if (!p || p[1] != 'Y')
- return AVERROR_IO;
-
- width = info->width;
- height = info->height;
-
- for(i=0;i<3;i++) {
- if (i == 1) {
- width >>= 1;
- height >>= 1;
- }
-
- if (i >= 1) {
- pb = &pb1;
- p[1] = ext[i];
- if (url_fopen(pb, fname, URL_WRONLY) < 0)
- return AVERROR_IO;
- } else {
- pb = pb2;
- }
-
- ptr = info->pict.data[i];
- for(j=0;j<height;j++) {
- put_buffer(pb, ptr, width);
- ptr += info->pict.linesize[i];
- }
- put_flush_packet(pb);
- if (i >= 1) {
- url_fclose(pb);
- }
- }
- return 0;
-}
-
-static int yuv_probe(AVProbeData *pd)
-{
- if (match_ext(pd->filename, "Y"))
- return AVPROBE_SCORE_MAX;
- else
- return 0;
-}
-
-AVImageFormat yuv_image_format = {
- "yuv",
- "Y",
- yuv_probe,
- yuv_read,
- (1 << PIX_FMT_YUV420P),
- yuv_write,
-};
diff --git a/contrib/ffmpeg/libavutil/Makefile b/contrib/ffmpeg/libavutil/Makefile
index ab0db8f9b..a760401ab 100644
--- a/contrib/ffmpeg/libavutil/Makefile
+++ b/contrib/ffmpeg/libavutil/Makefile
@@ -1,10 +1,5 @@
-#
-# libavutil Makefile
-#
include ../config.mak
-CFLAGS+=-DBUILD_AVUTIL
-
OBJS= mathematics.o \
rational.o \
intfloat_readwrite.o \
@@ -16,14 +11,17 @@ OBJS= mathematics.o \
mem.o \
fifo.o \
tree.o \
+ lzo.o \
+ random.o \
+ aes.o \
+ base64.o \
HEADERS = avutil.h common.h mathematics.h integer.h rational.h \
- intfloat_readwrite.h md5.h adler32.h log.h fifo.h
+ intfloat_readwrite.h md5.h adler32.h log.h fifo.h lzo.h \
+ random.h mem.h base64.h
NAME=avutil
-ifeq ($(BUILD_SHARED),yes)
LIBVERSION=$(LAVUVERSION)
LIBMAJOR=$(LAVUMAJOR)
-endif
include ../common.mak
diff --git a/contrib/ffmpeg/libavutil/aes.c b/contrib/ffmpeg/libavutil/aes.c
new file mode 100644
index 000000000..55ae0d4f3
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/aes.c
@@ -0,0 +1,239 @@
+/*
+ * copyright (c) 2007 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
+ *
+ * some optimization ideas from aes128.c by Reimar Doeffinger
+ */
+
+#include "common.h"
+#include "aes.h"
+
+typedef struct AVAES{
+ uint8_t round_key[15][4][4];
+ uint8_t state[2][4][4];
+ int rounds;
+}AVAES;
+
+const int av_aes_size= sizeof(AVAES);
+
+static const uint8_t rcon[10] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
+};
+
+static uint8_t sbox[256];
+static uint8_t inv_sbox[256];
+#ifdef CONFIG_SMALL
+static uint32_t enc_multbl[1][256];
+static uint32_t dec_multbl[1][256];
+#else
+static uint32_t enc_multbl[4][256];
+static uint32_t dec_multbl[4][256];
+#endif
+
+static inline void addkey(uint64_t dst[2], uint64_t src[2], uint64_t round_key[2]){
+ dst[0] = src[0] ^ round_key[0];
+ dst[1] = src[1] ^ round_key[1];
+}
+
+static void subshift(uint8_t s0[2][16], int s, uint8_t *box){
+ uint8_t (*s1)[16]= s0[0] - s;
+ uint8_t (*s3)[16]= s0[0] + s;
+ s0[0][0]=box[s0[1][ 0]]; s0[0][ 4]=box[s0[1][ 4]]; s0[0][ 8]=box[s0[1][ 8]]; s0[0][12]=box[s0[1][12]];
+ s1[0][3]=box[s1[1][ 7]]; s1[0][ 7]=box[s1[1][11]]; s1[0][11]=box[s1[1][15]]; s1[0][15]=box[s1[1][ 3]];
+ s0[0][2]=box[s0[1][10]]; s0[0][10]=box[s0[1][ 2]]; s0[0][ 6]=box[s0[1][14]]; s0[0][14]=box[s0[1][ 6]];
+ s3[0][1]=box[s3[1][13]]; s3[0][13]=box[s3[1][ 9]]; s3[0][ 9]=box[s3[1][ 5]]; s3[0][ 5]=box[s3[1][ 1]];
+}
+
+static inline int mix_core(uint32_t multbl[4][256], int a, int b, int c, int d){
+#ifdef CONFIG_SMALL
+#define ROT(x,s) ((x<<s)|(x>>(32-s)))
+ return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24);
+#else
+ return multbl[0][a] ^ multbl[1][b] ^ multbl[2][c] ^ multbl[3][d];
+#endif
+}
+
+static inline void mix(uint8_t state[2][4][4], uint32_t multbl[4][256], int s1, int s3){
+ ((uint32_t *)(state))[0] = mix_core(multbl, state[1][0][0], state[1][s1 ][1], state[1][2][2], state[1][s3 ][3]);
+ ((uint32_t *)(state))[1] = mix_core(multbl, state[1][1][0], state[1][s3-1][1], state[1][3][2], state[1][s1-1][3]);
+ ((uint32_t *)(state))[2] = mix_core(multbl, state[1][2][0], state[1][s3 ][1], state[1][0][2], state[1][s1 ][3]);
+ ((uint32_t *)(state))[3] = mix_core(multbl, state[1][3][0], state[1][s1-1][1], state[1][1][2], state[1][s3-1][3]);
+}
+
+static inline void crypt(AVAES *a, int s, uint8_t *sbox, uint32_t *multbl){
+ int r;
+
+ for(r=a->rounds-1; r>0; r--){
+ mix(a->state, multbl, 3-s, 1+s);
+ addkey(a->state[1], a->state[0], a->round_key[r]);
+ }
+ subshift(a->state[0][0], s, sbox);
+}
+
+void av_aes_crypt(AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt){
+ while(count--){
+ addkey(a->state[1], src, a->round_key[a->rounds]);
+ if(decrypt) {
+ crypt(a, 0, inv_sbox, dec_multbl);
+ if(iv){
+ addkey(a->state[0], a->state[0], iv);
+ memcpy(iv, src, 16);
+ }
+ addkey(dst, a->state[0], a->round_key[0]);
+ }else{
+ if(iv) addkey(a->state[1], a->state[1], iv);
+ crypt(a, 2, sbox, enc_multbl);
+ addkey(dst, a->state[0], a->round_key[0]);
+ if(iv) memcpy(iv, dst, 16);
+ }
+ src+=16;
+ dst+=16;
+ }
+}
+
+static void init_multbl2(uint8_t tbl[1024], int c[4], uint8_t *log8, uint8_t *alog8, uint8_t *sbox){
+ int i, j;
+ for(i=0; i<1024; i++){
+ int x= sbox[i>>2];
+ if(x) tbl[i]= alog8[ log8[x] + log8[c[i&3]] ];
+ }
+#ifndef CONFIG_SMALL
+ for(j=256; j<1024; j++)
+ for(i=0; i<4; i++)
+ tbl[4*j+i]= tbl[4*j + ((i-1)&3) - 1024];
+#endif
+}
+
+// this is based on the reference AES code by Paulo Barreto and Vincent Rijmen
+int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) {
+ int i, j, t, rconpointer = 0;
+ uint8_t tk[8][4];
+ int KC= key_bits>>5;
+ int rounds= KC + 6;
+ uint8_t log8[256];
+ uint8_t alog8[512];
+
+ if(!enc_multbl[4][1023]){
+ j=1;
+ for(i=0; i<255; i++){
+ alog8[i]=
+ alog8[i+255]= j;
+ log8[j]= i;
+ j^= j+j;
+ if(j>255) j^= 0x11B;
+ }
+ for(i=0; i<256; i++){
+ j= i ? alog8[255-log8[i]] : 0;
+ j ^= (j<<1) ^ (j<<2) ^ (j<<3) ^ (j<<4);
+ j = (j ^ (j>>8) ^ 99) & 255;
+ inv_sbox[j]= i;
+ sbox [i]= j;
+ }
+ init_multbl2(dec_multbl[0], (int[4]){0xe, 0x9, 0xd, 0xb}, log8, alog8, inv_sbox);
+ init_multbl2(enc_multbl[0], (int[4]){0x2, 0x1, 0x1, 0x3}, log8, alog8, sbox);
+ }
+
+ if(key_bits!=128 && key_bits!=192 && key_bits!=256)
+ return -1;
+
+ a->rounds= rounds;
+
+ memcpy(tk, key, KC*4);
+
+ for(t= 0; t < (rounds+1)*16;) {
+ memcpy(a->round_key[0][0]+t, tk, KC*4);
+ t+= KC*4;
+
+ for(i = 0; i < 4; i++)
+ tk[0][i] ^= sbox[tk[KC-1][(i+1)&3]];
+ tk[0][0] ^= rcon[rconpointer++];
+
+ for(j = 1; j < KC; j++){
+ if(KC != 8 || j != KC>>1)
+ for(i = 0; i < 4; i++) tk[j][i] ^= tk[j-1][i];
+ else
+ for(i = 0; i < 4; i++) tk[j][i] ^= sbox[tk[j-1][i]];
+ }
+ }
+
+ if(decrypt){
+ for(i=1; i<rounds; i++){
+ uint8_t tmp[3][16];
+ memcpy(tmp[2], a->round_key[i][0], 16);
+ subshift(tmp[1], 0, sbox);
+ mix(tmp, dec_multbl, 1, 3);
+ memcpy(a->round_key[i][0], tmp[0], 16);
+ }
+ }else{
+ for(i=0; i<(rounds+1)>>1; i++){
+ for(j=0; j<16; j++)
+ FFSWAP(int, a->round_key[i][0][j], a->round_key[rounds-i][0][j]);
+ }
+ }
+
+ return 0;
+}
+
+#ifdef TEST
+#include "log.h"
+
+int main(){
+ int i,j;
+ AVAES ae, ad, b;
+ uint8_t rkey[2][16]= {
+ {0},
+ {0x10, 0xa5, 0x88, 0x69, 0xd7, 0x4b, 0xe5, 0xa3, 0x74, 0xcf, 0x86, 0x7c, 0xfb, 0x47, 0x38, 0x59}};
+ uint8_t pt[16], rpt[2][16]= {
+ {0x6a, 0x84, 0x86, 0x7c, 0xd7, 0x7e, 0x12, 0xad, 0x07, 0xea, 0x1b, 0xe8, 0x95, 0xc5, 0x3f, 0xa3},
+ {0}};
+ uint8_t rct[2][16]= {
+ {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf},
+ {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}};
+ uint8_t temp[16];
+
+ av_aes_init(&ae, "PI=3.141592654..", 128, 0);
+ av_aes_init(&ad, "PI=3.141592654..", 128, 1);
+ av_log_level= AV_LOG_DEBUG;
+
+ for(i=0; i<2; i++){
+ av_aes_init(&b, rkey[i], 128, 1);
+ av_aes_crypt(&b, temp, rct[i], 1, NULL, 1);
+ for(j=0; j<16; j++)
+ if(rpt[i][j] != temp[j])
+ av_log(NULL, AV_LOG_ERROR, "%d %02X %02X\n", j, rpt[i][j], temp[j]);
+ }
+
+ for(i=0; i<10000; i++){
+ for(j=0; j<16; j++){
+ pt[j]= random();
+ }
+{START_TIMER
+ av_aes_crypt(&ae, temp, pt, 1, NULL, 0);
+ if(!(i&(i-1)))
+ av_log(NULL, AV_LOG_ERROR, "%02X %02X %02X %02X\n", temp[0], temp[5], temp[10], temp[15]);
+ av_aes_crypt(&ad, temp, temp, 1, NULL, 1);
+STOP_TIMER("aes")}
+ for(j=0; j<16; j++){
+ if(pt[j] != temp[j]){
+ av_log(NULL, AV_LOG_ERROR, "%d %d %02X %02X\n", i,j, pt[j], temp[j]);
+ }
+ }
+ }
+ return 0;
+}
+#endif
diff --git a/contrib/ffmpeg/libavutil/aes.h b/contrib/ffmpeg/libavutil/aes.h
new file mode 100644
index 000000000..34ba0a2fa
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/aes.h
@@ -0,0 +1,45 @@
+/*
+ * copyright (c) 2007 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 AES_H
+#define AES_H
+
+extern const int av_aes_size;
+
+struct AVAES;
+
+/**
+ * initalizes a AVAES context
+ * @param key_bits 128, 192 or 256
+ * @param decrypt 0 for encryption, 1 for decryption
+ */
+int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
+
+/**
+ * encrypts / decrypts.
+ * @param count number of 16 byte blocks
+ * @param dst destination array, can be equal to src
+ * @param src source array, can be equal to dst
+ * @param iv initalization vector for CBC mode, if NULL then ECB will be used
+ * @param decrypt 0 for encryption, 1 for decryption
+ */
+void av_aes_crypt(struct AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt);
+
+#endif /* AES_H */
diff --git a/contrib/ffmpeg/libavutil/avutil.h b/contrib/ffmpeg/libavutil/avutil.h
index 08cc61567..32bc40bfb 100644
--- a/contrib/ffmpeg/libavutil/avutil.h
+++ b/contrib/ffmpeg/libavutil/avutil.h
@@ -34,8 +34,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVUTIL_VERSION_INT ((49<<16)+(1<<8)+0)
-#define LIBAVUTIL_VERSION 49.1.0
+#define LIBAVUTIL_VERSION_INT ((49<<16)+(4<<8)+0)
+#define LIBAVUTIL_VERSION 49.4.0
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
diff --git a/contrib/ffmpeg/libavformat/base64.c b/contrib/ffmpeg/libavutil/base64.c
index 6279244d3..bee800c82 100644
--- a/contrib/ffmpeg/libavformat/base64.c
+++ b/contrib/ffmpeg/libavutil/base64.c
@@ -70,7 +70,7 @@ int av_base64_decode(uint8_t * out, const char *in, int out_length)
* fixed edge cases and made it work from data (vs. strings) by ryan.
*****************************************************************************/
-char *av_base64_encode(uint8_t * src, int len)
+char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len)
{
static const char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -79,11 +79,10 @@ char *av_base64_encode(uint8_t * src, int len)
int i_shift = 0;
int bytes_remaining = len;
- if (len < UINT_MAX / 4) {
- ret = dst = av_malloc(len * 4 / 3 + 12);
- } else
+ if (len >= UINT_MAX / 4 ||
+ buf_len < len * 4 / 3 + 12)
return NULL;
-
+ ret = dst = buf;
if (len) { // special edge case, what should we really do here?
while (bytes_remaining) {
i_bits = (i_bits << 8) + *src++;
diff --git a/contrib/ffmpeg/libavformat/base64.h b/contrib/ffmpeg/libavutil/base64.h
index 03d43afe4..3d905313c 100644
--- a/contrib/ffmpeg/libavformat/base64.h
+++ b/contrib/ffmpeg/libavutil/base64.h
@@ -19,6 +19,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-int av_base64_decode(uint8_t * out, const char *in, int out_length); // param order as strncpy()
-char *av_base64_encode(uint8_t * src, int len); // src is not a string, it's data.
+/**
+ * decodes base64
+ * param order as strncpy()
+ */
+int av_base64_decode(uint8_t * out, const char *in, int out_length);
+
+/**
+ * encodes base64
+ * @param src data, not a string
+ * @param buf output string
+ */
+char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len);
diff --git a/contrib/ffmpeg/libavutil/bswap.h b/contrib/ffmpeg/libavutil/bswap.h
index 4614c9045..03d613db2 100644
--- a/contrib/ffmpeg/libavutil/bswap.h
+++ b/contrib/ffmpeg/libavutil/bswap.h
@@ -37,7 +37,7 @@
#endif
#if defined(ARCH_X86)
-static always_inline uint16_t bswap_16(uint16_t x)
+static av_always_inline uint16_t bswap_16(uint16_t x)
{
__asm("rorw $8, %0" :
LEGACY_REGS (x) :
@@ -45,7 +45,7 @@ static always_inline uint16_t bswap_16(uint16_t x)
return x;
}
-static always_inline uint32_t bswap_32(uint32_t x)
+static av_always_inline uint32_t bswap_32(uint32_t x)
{
#if __CPU__ != 386
__asm("bswap %0":
@@ -82,12 +82,12 @@ static inline uint64_t bswap_64(uint64_t x)
#elif defined(ARCH_SH4)
-static always_inline uint16_t bswap_16(uint16_t x) {
+static av_always_inline uint16_t bswap_16(uint16_t x) {
__asm__("swap.b %0,%0":"=r"(x):"0"(x));
return x;
}
-static always_inline uint32_t bswap_32(uint32_t x) {
+static av_always_inline uint32_t bswap_32(uint32_t x) {
__asm__(
"swap.b %0,%0\n"
"swap.w %0,%0\n"
@@ -110,12 +110,12 @@ static inline uint64_t bswap_64(uint64_t x)
}
#else
-static always_inline uint16_t bswap_16(uint16_t x){
+static av_always_inline uint16_t bswap_16(uint16_t x){
return (x>>8) | (x<<8);
}
#ifdef ARCH_ARM
-static always_inline uint32_t bswap_32(uint32_t x){
+static av_always_inline uint32_t bswap_32(uint32_t x){
uint32_t t;
__asm__ (
"eor %1, %0, %0, ror #16 \n\t"
@@ -126,7 +126,7 @@ static always_inline uint32_t bswap_32(uint32_t x){
return x;
}
#else
-static always_inline uint32_t bswap_32(uint32_t x){
+static av_always_inline uint32_t bswap_32(uint32_t x){
x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
return (x>>16) | (x<<16);
}
diff --git a/contrib/ffmpeg/libavutil/common.h b/contrib/ffmpeg/libavutil/common.h
index 41bbe8f63..9ec5c7c78 100644
--- a/contrib/ffmpeg/libavutil/common.h
+++ b/contrib/ffmpeg/libavutil/common.h
@@ -26,9 +26,7 @@
#ifndef COMMON_H
#define COMMON_H
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include <inttypes.h>
#ifdef HAVE_AV_CONFIG_H
/* only include the following when compiling package */
@@ -39,42 +37,23 @@
# include <string.h>
# include <ctype.h>
# include <limits.h>
-# ifndef __BEOS__
-# include <errno.h>
-# else
-# include "berrno.h"
-# endif
+# include <errno.h>
# include <math.h>
#endif /* HAVE_AV_CONFIG_H */
-/* Suppress restrict if it was not defined in config.h. */
-#ifndef restrict
-# define restrict
-#endif
-
-#ifndef always_inline
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-# define always_inline __attribute__((always_inline)) inline
-#else
-# define always_inline inline
-#endif
-#endif
-
-#ifndef attribute_used
+#ifndef av_always_inline
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-# define attribute_used __attribute__((used))
+# define av_always_inline __attribute__((always_inline)) inline
+# define av_noinline __attribute__((noinline))
#else
-# define attribute_used
+# define av_always_inline inline
+# define av_noinline
#endif
#endif
-#ifndef attribute_unused
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-# define attribute_unused __attribute__((unused))
-#else
-# define attribute_unused
-#endif
-#endif
+#ifdef HAVE_AV_CONFIG_H
+# include "internal.h"
+#endif /* HAVE_AV_CONFIG_H */
#ifndef attribute_deprecated
#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
@@ -84,92 +63,7 @@
#endif
#endif
-# include <inttypes.h>
-
-#ifndef PRId64
-#define PRId64 "lld"
-#endif
-
-#ifndef PRIu64
-#define PRIu64 "llu"
-#endif
-
-#ifndef PRIx64
-#define PRIx64 "llx"
-#endif
-
-#ifndef PRIX64
-#define PRIX64 "llX"
-#endif
-
-#ifndef PRId32
-#define PRId32 "d"
-#endif
-
-#ifndef PRIdFAST16
-#define PRIdFAST16 PRId32
-#endif
-
-#ifndef PRIdFAST32
-#define PRIdFAST32 PRId32
-#endif
-
-#ifndef INT16_MIN
-#define INT16_MIN (-0x7fff-1)
-#endif
-
-#ifndef INT16_MAX
-#define INT16_MAX 0x7fff
-#endif
-
-#ifndef INT32_MIN
-#define INT32_MIN (-0x7fffffff-1)
-#endif
-
-#ifndef INT32_MAX
-#define INT32_MAX 0x7fffffff
-#endif
-
-#ifndef UINT32_MAX
-#define UINT32_MAX 0xffffffff
-#endif
-
-#ifndef INT64_MIN
-#define INT64_MIN (-0x7fffffffffffffffLL-1)
-#endif
-
-#ifndef INT64_MAX
-#define INT64_MAX int64_t_C(9223372036854775807)
-#endif
-
-#ifndef UINT64_MAX
-#define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF)
-#endif
-
-#ifndef INT_BIT
-# if INT_MAX != 2147483647
-# define INT_BIT 64
-# else
-# define INT_BIT 32
-# endif
-#endif
-
-#ifndef int64_t_C
-#define int64_t_C(c) (c ## LL)
-#define uint64_t_C(c) (c ## ULL)
-#endif
-
-#if defined(__MINGW32__) && !defined(BUILD_AVUTIL) && defined(BUILD_SHARED_AV)
-# define FF_IMPORT_ATTR __declspec(dllimport)
-#else
-# define FF_IMPORT_ATTR
-#endif
-
-
-#ifdef HAVE_AV_CONFIG_H
-/* only include the following when compiling package */
-# include "internal.h"
-#endif
+#include "mem.h"
//rounded divison & shift
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
@@ -184,7 +78,7 @@
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
/* misc math functions */
-extern FF_IMPORT_ATTR const uint8_t ff_log2_tab[256];
+extern const uint8_t ff_log2_tab[256];
static inline int av_log2(unsigned int v)
{
@@ -221,7 +115,7 @@ static inline int av_log2_16bit(unsigned int v)
/* median of 3 */
static inline int mid_pred(int a, int b, int c)
{
-#if HAVE_CMOV
+#ifdef HAVE_CMOV
int i=b;
asm volatile(
"cmp %2, %1 \n\t"
@@ -264,9 +158,9 @@ static inline int mid_pred(int a, int b, int c)
* @param a value to clip
* @param amin minimum value of the clip range
* @param amax maximum value of the clip range
- * @return cliped value
+ * @return clipped value
*/
-static inline int clip(int a, int amin, int amax)
+static inline int av_clip(int a, int amin, int amax)
{
if (a < amin) return amin;
else if (a > amax) return amax;
@@ -276,9 +170,9 @@ static inline int clip(int a, int amin, int amax)
/**
* clip a signed integer value into the 0-255 range
* @param a value to clip
- * @return cliped value
+ * @return clipped value
*/
-static inline uint8_t clip_uint8(int a)
+static inline uint8_t av_clip_uint8(int a)
{
if (a&(~255)) return (-a)>>31;
else return a;
@@ -415,7 +309,7 @@ tend= read_time();\
static uint64_t tsum=0;\
static int tcount=0;\
static int tskip_count=0;\
- if(tcount<2 || tend - tstart < 8*tsum/tcount){\
+ if(tcount<2 || tend - tstart < FFMAX(8*tsum/tcount, 2000)){\
tsum+= tend - tstart;\
tcount++;\
}else\
@@ -429,21 +323,4 @@ tend= read_time();\
#define STOP_TIMER(id) {}
#endif
-/* memory */
-
-#ifdef __GNUC__
- #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
-#else
- #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
-#endif
-
-/* memory */
-void *av_malloc(unsigned int size);
-void *av_realloc(void *ptr, unsigned int size);
-void av_free(void *ptr);
-
-void *av_mallocz(unsigned int size);
-char *av_strdup(const char *s);
-void av_freep(void *ptr);
-
#endif /* COMMON_H */
diff --git a/contrib/ffmpeg/libavutil/crc.c b/contrib/ffmpeg/libavutil/crc.c
index baa605d32..02fb860b8 100644
--- a/contrib/ffmpeg/libavutil/crc.c
+++ b/contrib/ffmpeg/libavutil/crc.c
@@ -21,10 +21,17 @@
#include "common.h"
#include "crc.h"
+#if LIBAVUTIL_VERSION_INT < (50<<16)
AVCRC *av_crcEDB88320;
AVCRC *av_crc04C11DB7;
AVCRC *av_crc8005 ;
AVCRC *av_crc07 ;
+#else
+AVCRC av_crcEDB88320[257];
+AVCRC av_crc04C11DB7[257];
+AVCRC av_crc8005 [257];
+AVCRC av_crc07 [257];
+#endif
/**
* Inits a crc table.
diff --git a/contrib/ffmpeg/libavutil/crc.h b/contrib/ffmpeg/libavutil/crc.h
index e739c309b..1f6431992 100644
--- a/contrib/ffmpeg/libavutil/crc.h
+++ b/contrib/ffmpeg/libavutil/crc.h
@@ -23,10 +23,17 @@
typedef uint32_t AVCRC;
+#if LIBAVUTIL_VERSION_INT < (50<<16)
extern AVCRC *av_crcEDB88320;
extern AVCRC *av_crc04C11DB7;
extern AVCRC *av_crc8005 ;
extern AVCRC *av_crc07 ;
+#else
+extern AVCRC av_crcEDB88320[];
+extern AVCRC av_crc04C11DB7[];
+extern AVCRC av_crc8005 [];
+extern AVCRC av_crc07 [];
+#endif
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length);
diff --git a/contrib/ffmpeg/libavutil/fifo.c b/contrib/ffmpeg/libavutil/fifo.c
index 550f13de5..8ac3a0cb5 100644
--- a/contrib/ffmpeg/libavutil/fifo.c
+++ b/contrib/ffmpeg/libavutil/fifo.c
@@ -24,11 +24,11 @@
int av_fifo_init(AVFifoBuffer *f, int size)
{
+ f->wptr = f->rptr =
f->buffer = av_malloc(size);
+ f->end = f->buffer + size;
if (!f->buffer)
return -1;
- f->end = f->buffer + size;
- f->wptr = f->rptr = f->buffer;
return 0;
}
@@ -50,23 +50,7 @@ int av_fifo_size(AVFifoBuffer *f)
*/
int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size)
{
- int len;
- int size = f->wptr - f->rptr;
- if (size < 0)
- size += f->end - f->buffer;
-
- if (size < buf_size)
- return -1;
- while (buf_size > 0) {
- len = FFMIN(f->end - f->rptr, buf_size);
- memcpy(buf, f->rptr, len);
- buf += len;
- f->rptr += len;
- if (f->rptr >= f->end)
- f->rptr = f->buffer;
- buf_size -= len;
- }
- return 0;
+ return av_fifo_generic_read(f, buf_size, NULL, buf);
}
/**
@@ -76,59 +60,52 @@ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
unsigned int old_size= f->end - f->buffer;
if(old_size < new_size){
- uint8_t *old= f->buffer;
-
- f->buffer= av_realloc(f->buffer, new_size);
-
- f->rptr += f->buffer - old;
- f->wptr += f->buffer - old;
-
- if(f->wptr < f->rptr){
- memmove(f->rptr + new_size - old_size, f->rptr, f->buffer + old_size - f->rptr);
- f->rptr += new_size - old_size;
- }
- f->end= f->buffer + new_size;
+ int len= av_fifo_size(f);
+ AVFifoBuffer f2;
+
+ av_fifo_init(&f2, new_size);
+ av_fifo_read(f, f2.buffer, len);
+ f2.wptr += len;
+ av_free(f->buffer);
+ *f= f2;
}
}
void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
{
- int len;
-
- while (size > 0) {
- len = FFMIN(f->end - f->wptr, size);
+ do {
+ int len = FFMIN(f->end - f->wptr, size);
memcpy(f->wptr, buf, len);
f->wptr += len;
if (f->wptr >= f->end)
f->wptr = f->buffer;
buf += len;
size -= len;
- }
+ } while (size > 0);
}
-/* get data from the fifo (return -1 if not enough data) */
+/** get data from the fifo (return -1 if not enough data) */
int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest)
{
- int len;
- int size = f->wptr - f->rptr;
- if (size < 0)
- size += f->end - f->buffer;
+ int size = av_fifo_size(f);
if (size < buf_size)
return -1;
- while (buf_size > 0) {
- len = FFMIN(f->end - f->rptr, buf_size);
- func(dest, f->rptr, len);
- f->rptr += len;
- if (f->rptr >= f->end)
- f->rptr = f->buffer;
+ do {
+ int len = FFMIN(f->end - f->rptr, buf_size);
+ if(func) func(dest, f->rptr, len);
+ else{
+ memcpy(dest, f->rptr, len);
+ dest = (uint8_t*)dest + len;
+ }
+ av_fifo_drain(f, len);
buf_size -= len;
- }
+ } while (buf_size > 0);
return 0;
}
-/* discard data from the fifo */
+/** discard data from the fifo */
void av_fifo_drain(AVFifoBuffer *f, int size)
{
f->rptr += size;
diff --git a/contrib/ffmpeg/libavutil/fifo.h b/contrib/ffmpeg/libavutil/fifo.h
index 9dec0e62d..e1e85293d 100644
--- a/contrib/ffmpeg/libavutil/fifo.h
+++ b/contrib/ffmpeg/libavutil/fifo.h
@@ -1,3 +1,26 @@
+/*
+ * 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 fifo.h
+ * A very simple circular buffer FIFO implementation.
+ */
+
#ifndef FIFO_H
#define FIFO_H
@@ -6,13 +29,65 @@ typedef struct AVFifoBuffer {
uint8_t *rptr, *wptr, *end;
} AVFifoBuffer;
+/**
+ * Initializes an AVFifoBuffer.
+ * @param *f AVFifoBuffer to initialize
+ * @param size of FIFO
+ * @return <0 for failure >=0 otherwise
+ */
int av_fifo_init(AVFifoBuffer *f, int size);
+
+/**
+ * Frees an AVFifoBuffer.
+ * @param *f AVFifoBuffer to free
+ */
void av_fifo_free(AVFifoBuffer *f);
+
+/**
+ * Returns the amount of data in bytes in the AVFifoBuffer, that is the
+ * amount of data you can read from it.
+ * @param *f AVFifoBuffer to read from
+ * @return size
+ */
int av_fifo_size(AVFifoBuffer *f);
+
+/**
+ * Reads data from an AVFifoBuffer.
+ * @param *f AVFifoBuffer to read from
+ * @param *buf data destination
+ * @param buf_size number of bytes to read
+ */
int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size);
+
+/**
+ * Feeds data from an AVFifoBuffer to a user supplied callback.
+ * @param *f AVFifoBuffer to read from
+ * @param buf_size number of bytes to read
+ * @param *func generic read function
+ * @param *dest data destination
+ */
int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest);
+
+/**
+ * Writes data into an AVFifoBuffer.
+ * @param *f AVFifoBuffer to write to
+ * @param *buf data source
+ * @param size data size
+ */
void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size);
+
+/**
+ * Resizes an AVFifoBuffer.
+ * @param *f AVFifoBuffer to resize
+ * @param size new AVFifoBuffer size in bytes
+ */
void av_fifo_realloc(AVFifoBuffer *f, unsigned int size);
+
+/**
+ * Reads and discards the specified amount of data from an AVFifoBuffer.
+ * @param *f AVFifoBuffer to read from
+ * @param size amount of data to read in bytes
+ */
void av_fifo_drain(AVFifoBuffer *f, int size);
static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
diff --git a/contrib/ffmpeg/libavutil/integer.c b/contrib/ffmpeg/libavutil/integer.c
index 09cd756e2..3269a366a 100644
--- a/contrib/ffmpeg/libavutil/integer.c
+++ b/contrib/ffmpeg/libavutil/integer.c
@@ -49,10 +49,6 @@ AVInteger av_sub_i(AVInteger a, AVInteger b){
return a;
}
-/**
- * returns the rounded down value of the logarithm of base 2 of the given AVInteger.
- * this is simply the index of the most significant bit which is 1. Or 0 of all bits are 0
- */
int av_log2_i(AVInteger a){
int i;
@@ -84,9 +80,6 @@ AVInteger av_mul_i(AVInteger a, AVInteger b){
return out;
}
-/**
- * returns 0 if a==b, 1 if a>b and -1 if a<b.
- */
int av_cmp_i(AVInteger a, AVInteger b){
int i;
int v= (int16_t)a.v[AV_INTEGER_SIZE-1] - (int16_t)b.v[AV_INTEGER_SIZE-1];
@@ -99,10 +92,6 @@ int av_cmp_i(AVInteger a, AVInteger b){
return 0;
}
-/**
- * bitwise shift.
- * @param s the number of bits by which the value should be shifted right, may be negative for shifting left
- */
AVInteger av_shr_i(AVInteger a, int s){
AVInteger out;
int i;
@@ -117,10 +106,6 @@ AVInteger av_shr_i(AVInteger a, int s){
return out;
}
-/**
- * returns a % b.
- * @param quot a/b will be stored here
- */
AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b){
int i= av_log2_i(a) - av_log2_i(b);
AVInteger quot_temp;
@@ -145,18 +130,12 @@ AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b){
return a;
}
-/**
- * returns a/b.
- */
AVInteger av_div_i(AVInteger a, AVInteger b){
AVInteger quot;
av_mod_i(&quot, a, b);
return quot;
}
-/**
- * converts the given int64_t to an AVInteger.
- */
AVInteger av_int2i(int64_t a){
AVInteger out;
int i;
@@ -168,11 +147,6 @@ AVInteger av_int2i(int64_t a){
return out;
}
-/**
- * converts the given AVInteger to an int64_t.
- * if the AVInteger is too large to fit into an int64_t,
- * then only the least significant 64bit will be used
- */
int64_t av_i2int(AVInteger a){
int i;
int64_t out=(int8_t)a.v[AV_INTEGER_SIZE-1];
diff --git a/contrib/ffmpeg/libavutil/integer.h b/contrib/ffmpeg/libavutil/integer.h
index a50ad9bae..2a4d70316 100644
--- a/contrib/ffmpeg/libavutil/integer.h
+++ b/contrib/ffmpeg/libavutil/integer.h
@@ -37,13 +37,46 @@ typedef struct AVInteger{
AVInteger av_add_i(AVInteger a, AVInteger b);
AVInteger av_sub_i(AVInteger a, AVInteger b);
+
+/**
+ * returns the rounded down value of the logarithm of base 2 of the given AVInteger.
+ * this is simply the index of the most significant bit which is 1. Or 0 of all bits are 0
+ */
int av_log2_i(AVInteger a);
AVInteger av_mul_i(AVInteger a, AVInteger b);
+
+/**
+ * returns 0 if a==b, 1 if a>b and -1 if a<b.
+ */
int av_cmp_i(AVInteger a, AVInteger b);
+
+/**
+ * bitwise shift.
+ * @param s the number of bits by which the value should be shifted right, may be negative for shifting left
+ */
AVInteger av_shr_i(AVInteger a, int s);
+
+/**
+ * returns a % b.
+ * @param quot a/b will be stored here
+ */
AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b);
+
+/**
+ * returns a/b.
+ */
AVInteger av_div_i(AVInteger a, AVInteger b);
+
+/**
+ * converts the given int64_t to an AVInteger.
+ */
AVInteger av_int2i(int64_t a);
+
+/**
+ * converts the given AVInteger to an int64_t.
+ * if the AVInteger is too large to fit into an int64_t,
+ * then only the least significant 64bit will be used
+ */
int64_t av_i2int(AVInteger a);
#endif // INTEGER_H
diff --git a/contrib/ffmpeg/libavutil/internal.h b/contrib/ffmpeg/libavutil/internal.h
index 4cb0d2a7e..eefbfa1e4 100644
--- a/contrib/ffmpeg/libavutil/internal.h
+++ b/contrib/ffmpeg/libavutil/internal.h
@@ -26,14 +26,71 @@
#ifndef INTERNAL_H
#define INTERNAL_H
-#if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC)
-# define PIC
+#ifndef attribute_used
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+# define attribute_used __attribute__((used))
+#else
+# define attribute_used
+#endif
+#endif
+
+#ifndef attribute_unused
+#if defined(__GNUC__)
+# define attribute_unused __attribute__((unused))
+#else
+# define attribute_unused
+#endif
+#endif
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifndef INT16_MIN
+#define INT16_MIN (-0x7fff-1)
+#endif
+
+#ifndef INT16_MAX
+#define INT16_MAX 0x7fff
+#endif
+
+#ifndef INT32_MIN
+#define INT32_MIN (-0x7fffffff-1)
#endif
-#ifndef ENODATA
-# define ENODATA 61
+#ifndef INT32_MAX
+#define INT32_MAX 0x7fffffff
+#endif
+
+#ifndef UINT32_MAX
+#define UINT32_MAX 0xffffffff
+#endif
+
+#ifndef INT64_MIN
+#define INT64_MIN (-0x7fffffffffffffffLL-1)
+#endif
+
+#ifndef INT64_MAX
+#define INT64_MAX INT64_C(9223372036854775807)
+#endif
+
+#ifndef UINT64_MAX
+#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF)
+#endif
+
+#ifndef INT_BIT
+# if INT_MAX != 2147483647
+# define INT_BIT 64
+# else
+# define INT_BIT 32
+# endif
+#endif
+
+#if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC)
+# define PIC
#endif
+#include "intreadwrite.h"
#include "bswap.h"
#include <stddef.h>
@@ -93,9 +150,9 @@
/* dprintf macros */
#ifdef DEBUG
-# define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__)
+# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
#else
-# define dprintf(fmt,...)
+# define dprintf(pctx, ...)
#endif
#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
@@ -132,7 +189,7 @@ extern const uint32_t ff_inverse[256];
# define FASTDIV(a,b) ((a)/(b))
#endif
-extern FF_IMPORT_ATTR const uint8_t ff_sqrt_tab[128];
+extern const uint8_t ff_sqrt_tab[128];
static inline int ff_sqrt(int a)
{
@@ -194,6 +251,7 @@ if((y)<(x)){\
#define srand srand_is_forbidden_due_to_state_trashing
#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
#define strcat strcat_is_forbidden_due_to_security_issues_use_pstrcat
+#define exit exit_is_forbidden
#if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H))
#define printf please_use_av_log
#define fprintf please_use_av_log
@@ -212,7 +270,7 @@ if((y)<(x)){\
/* XXX: add ISOC specific test to avoid specific BSD testing. */
/* better than nothing implementation. */
/* btw, rintf() is existing on fbsd too -- alex */
-static always_inline long int lrintf(float x)
+static av_always_inline long int lrintf(float x)
{
#ifdef __MINGW32__
# ifdef ARCH_X86_32
diff --git a/contrib/ffmpeg/libavutil/intreadwrite.h b/contrib/ffmpeg/libavutil/intreadwrite.h
new file mode 100644
index 000000000..7225f0b67
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/intreadwrite.h
@@ -0,0 +1,99 @@
+/*
+ * 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 INTREADWRITE_H
+#define INTREADWRITE_H
+
+#ifdef __GNUC__
+
+struct unaligned_64 { uint64_t l; } __attribute__((packed));
+struct unaligned_32 { uint32_t l; } __attribute__((packed));
+struct unaligned_16 { uint16_t l; } __attribute__((packed));
+
+#define LD16(a) (((const struct unaligned_16 *) (a))->l)
+#define LD32(a) (((const struct unaligned_32 *) (a))->l)
+#define LD64(a) (((const struct unaligned_64 *) (a))->l)
+
+#define ST16(a, b) (((struct unaligned_16 *) (a))->l) = (b)
+#define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
+
+#else /* __GNUC__ */
+
+#define LD16(a) (*((uint16_t*)(a)))
+#define LD32(a) (*((uint32_t*)(a)))
+#define LD64(a) (*((uint64_t*)(a)))
+
+#define ST16(a, b) *((uint16_t*)(a)) = (b)
+#define ST32(a, b) *((uint32_t*)(a)) = (b)
+
+#endif /* !__GNUC__ */
+
+/* endian macros */
+#define AV_RB8(x) (((uint8_t*)(x))[0])
+#define AV_WB8(p, d) { ((uint8_t*)(p))[0] = (d); }
+
+#define AV_RB16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define AV_WB16(p, d) { \
+ ((uint8_t*)(p))[1] = (d); \
+ ((uint8_t*)(p))[0] = (d)>>8; }
+
+#define AV_RB24(x) ((((uint8_t*)(x))[0] << 16) | \
+ (((uint8_t*)(x))[1] << 8) | \
+ ((uint8_t*)(x))[2])
+#define AV_WB24(p, d) { \
+ ((uint8_t*)(p))[2] = (d); \
+ ((uint8_t*)(p))[1] = (d)>>8; \
+ ((uint8_t*)(p))[0] = (d)>>16; }
+
+#define AV_RB32(x) ((((uint8_t*)(x))[0] << 24) | \
+ (((uint8_t*)(x))[1] << 16) | \
+ (((uint8_t*)(x))[2] << 8) | \
+ ((uint8_t*)(x))[3])
+#define AV_WB32(p, d) { \
+ ((uint8_t*)(p))[3] = (d); \
+ ((uint8_t*)(p))[2] = (d)>>8; \
+ ((uint8_t*)(p))[1] = (d)>>16; \
+ ((uint8_t*)(p))[0] = (d)>>24; }
+
+#define AV_RL8(x) AV_RB8(x)
+#define AV_WL8(p, d) AV_WB8(p, d)
+
+#define AV_RL16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define AV_WL16(p, d) { \
+ ((uint8_t*)(p))[0] = (d); \
+ ((uint8_t*)(p))[1] = (d)>>8; }
+
+#define AV_RL24(x) ((((uint8_t*)(x))[2] << 16) | \
+ (((uint8_t*)(x))[1] << 8) | \
+ ((uint8_t*)(x))[0])
+#define AV_WL24(p, d) { \
+ ((uint8_t*)(p))[0] = (d); \
+ ((uint8_t*)(p))[1] = (d)>>8; \
+ ((uint8_t*)(p))[2] = (d)>>16; }
+
+#define AV_RL32(x) ((((uint8_t*)(x))[3] << 24) | \
+ (((uint8_t*)(x))[2] << 16) | \
+ (((uint8_t*)(x))[1] << 8) | \
+ ((uint8_t*)(x))[0])
+#define AV_WL32(p, d) { \
+ ((uint8_t*)(p))[0] = (d); \
+ ((uint8_t*)(p))[1] = (d)>>8; \
+ ((uint8_t*)(p))[2] = (d)>>16; \
+ ((uint8_t*)(p))[3] = (d)>>24; }
+
+#endif /* INTREADWRITE_H */
diff --git a/contrib/ffmpeg/libavutil/log.c b/contrib/ffmpeg/libavutil/log.c
index 8b2dc6f6d..4fd503d0d 100644
--- a/contrib/ffmpeg/libavutil/log.c
+++ b/contrib/ffmpeg/libavutil/log.c
@@ -28,7 +28,7 @@
int av_log_level = AV_LOG_INFO;
-static void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
+void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
diff --git a/contrib/ffmpeg/libavutil/log.h b/contrib/ffmpeg/libavutil/log.h
index 0ff1f9fcf..fa88f5fb2 100644
--- a/contrib/ffmpeg/libavutil/log.h
+++ b/contrib/ffmpeg/libavutil/log.h
@@ -38,12 +38,65 @@ struct AVCLASS {
/* av_log API */
+#if LIBAVUTIL_VERSION_INT < (50<<16)
#define AV_LOG_QUIET -1
+#define AV_LOG_FATAL 0
#define AV_LOG_ERROR 0
+#define AV_LOG_WARNING 1
#define AV_LOG_INFO 1
+#define AV_LOG_VERBOSE 1
#define AV_LOG_DEBUG 2
+#else
+#define AV_LOG_QUIET -8
+
+/**
+ * something went really wrong and we will crash now
+ */
+#define AV_LOG_PANIC 0
+
+/**
+ * something went wrong and recovery is not possible
+ * like no header in a format which depends on it or a combination
+ * of parameters which are not allowed
+ */
+#define AV_LOG_FATAL 8
+
+/**
+ * something went wrong and cannot losslessly be recovered
+ * but not all future data is affected
+ */
+#define AV_LOG_ERROR 16
+
+/**
+ * something somehow does not look correct / something which may or may not
+ * lead to some problems like use of -vstrict -2
+ */
+#define AV_LOG_WARNING 24
+
+#define AV_LOG_INFO 32
+#define AV_LOG_VERBOSE 40
+
+/**
+ * stuff which is only useful for libav* developers
+ */
+#define AV_LOG_DEBUG 48
+#endif
extern int av_log_level;
+/**
+ * Send the specified message to the log if the level is less than or equal to
+ * the current av_log_level. By default, all logging messages are sent to
+ * stderr. This behavior can be altered by setting a different av_vlog callback
+ * function.
+ *
+ * @param avcl A pointer to an arbitrary struct of which the first field is a
+ * pointer to an AVClass struct.
+ * @param level The importance level of the message, lower values signifying
+ * higher importance.
+ * @param fmt The format string (printf-compatible) that specifies how
+ * subsequent arguments are converted to output.
+ * @see av_vlog
+ */
#ifdef __GNUC__
extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
#else
@@ -55,6 +108,7 @@ extern void av_vlog(void*, int level, const char *fmt, va_list);
extern int av_log_get_level(void);
extern void av_log_set_level(int);
extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
+extern void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
#else
extern void (*av_vlog)(void*, int, const char*, va_list);
#endif
diff --git a/contrib/ffmpeg/libavcodec/lzo.c b/contrib/ffmpeg/libavutil/lzo.c
index 015c80d0d..d3849a743 100644
--- a/contrib/ffmpeg/libavcodec/lzo.c
+++ b/contrib/ffmpeg/libavutil/lzo.c
@@ -26,7 +26,7 @@
//! define if we may write up to 12 bytes beyond the output buffer
#define OUTBUF_PADDED 1
-//! define if we may read up to 4 bytes beyond the input buffer
+//! define if we may read up to 8 bytes beyond the input buffer
#define INBUF_PADDED 1
typedef struct LZOContext {
uint8_t *in, *in_end;
@@ -45,6 +45,12 @@ static inline int get_byte(LZOContext *c) {
return 1;
}
+#ifdef INBUF_PADDED
+#define GETB(c) (*(c).in++)
+#else
+#define GETB(c) get_byte(&(c))
+#endif
+
/**
* \brief decode a length value in the coding used by lzo
* \param x previous byte value
@@ -60,26 +66,36 @@ static inline int get_len(LZOContext *c, int x, int mask) {
return cnt;
}
+//#define UNALIGNED_LOADSTORE
+#define BUILTIN_MEMCPY
+#ifdef UNALIGNED_LOADSTORE
+#define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s);
+#define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s);
+#elif defined(BUILTIN_MEMCPY)
+#define COPY2(d, s) memcpy(d, s, 2);
+#define COPY4(d, s) memcpy(d, s, 4);
+#else
+#define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1];
+#define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3];
+#endif
+
/**
* \brief copy bytes from input to output buffer with checking
- * \param cnt number of bytes to copy, must be > 0
+ * \param cnt number of bytes to copy, must be >= 0
*/
static inline void copy(LZOContext *c, int cnt) {
register uint8_t *src = c->in;
register uint8_t *dst = c->out;
- if (src + cnt > c->in_end) {
- cnt = c->in_end - src;
+ if (cnt > c->in_end - src) {
+ cnt = FFMAX(c->in_end - src, 0);
c->error |= LZO_INPUT_DEPLETED;
}
- if (dst + cnt > c->out_end) {
- cnt = c->out_end - dst;
+ if (cnt > c->out_end - dst) {
+ cnt = FFMAX(c->out_end - dst, 0);
c->error |= LZO_OUTPUT_FULL;
}
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
+ COPY4(dst, src);
src += 4;
dst += 4;
cnt -= 4;
@@ -93,7 +109,7 @@ static inline void copy(LZOContext *c, int cnt) {
/**
* \brief copy previously decoded bytes to current position
* \param back how many bytes back we start
- * \param cnt number of bytes to copy, must be > 0
+ * \param cnt number of bytes to copy, must be >= 0
*
* cnt > back is valid, this will copy the bytes we just copied,
* thus creating a repeating pattern with a period length of back.
@@ -101,12 +117,12 @@ static inline void copy(LZOContext *c, int cnt) {
static inline void copy_backptr(LZOContext *c, int back, int cnt) {
register uint8_t *src = &c->out[-back];
register uint8_t *dst = c->out;
- if (src < c->out_start) {
+ if (src < c->out_start || src > dst) {
c->error |= LZO_INVALID_BACKPTR;
return;
}
- if (dst + cnt > c->out_end) {
- cnt = c->out_end - dst;
+ if (cnt > c->out_end - dst) {
+ cnt = FFMAX(c->out_end - dst, 0);
c->error |= LZO_OUTPUT_FULL;
}
if (back == 1) {
@@ -114,22 +130,16 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) {
dst += cnt;
} else {
#ifdef OUTBUF_PADDED
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
+ COPY2(dst, src);
+ COPY2(dst + 2, src + 2);
src += 4;
dst += 4;
cnt -= 4;
if (cnt > 0) {
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- dst[4] = src[4];
- dst[5] = src[5];
- dst[6] = src[6];
- dst[7] = src[7];
+ COPY2(dst, src);
+ COPY2(dst + 2, src + 2);
+ COPY2(dst + 4, src + 4);
+ COPY2(dst + 6, src + 6);
src += 8;
dst += 8;
cnt -= 8;
@@ -162,7 +172,7 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) {
* LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes
*/
int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
- enum {COPY, BACKPTR} state = COPY;
+ int state= 0;
int x;
LZOContext c;
c.in = in;
@@ -170,57 +180,94 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
c.out = c.out_start = out;
c.out_end = (uint8_t *)out + * outlen;
c.error = 0;
- x = get_byte(&c);
+ x = GETB(c);
if (x > 17) {
copy(&c, x - 17);
- x = get_byte(&c);
+ x = GETB(c);
if (x < 16) c.error |= LZO_ERROR;
}
+ if (c.in > c.in_end)
+ c.error |= LZO_INPUT_DEPLETED;
while (!c.error) {
int cnt, back;
- if (x >> 4) {
- if (x >> 6) {
+ if (x > 15) {
+ if (x > 63) {
cnt = (x >> 5) - 1;
- back = (get_byte(&c) << 3) + ((x >> 2) & 7) + 1;
- } else if (x >> 5) {
+ back = (GETB(c) << 3) + ((x >> 2) & 7) + 1;
+ } else if (x > 31) {
cnt = get_len(&c, x, 31);
- x = get_byte(&c);
- back = (get_byte(&c) << 6) + (x >> 2) + 1;
+ x = GETB(c);
+ back = (GETB(c) << 6) + (x >> 2) + 1;
} else {
cnt = get_len(&c, x, 7);
back = (1 << 14) + ((x & 8) << 11);
- x = get_byte(&c);
- back += (get_byte(&c) << 6) + (x >> 2);
+ x = GETB(c);
+ back += (GETB(c) << 6) + (x >> 2);
if (back == (1 << 14)) {
if (cnt != 1)
c.error |= LZO_ERROR;
break;
}
}
- } else
- switch (state) {
- case COPY:
+ } else if(!state){
cnt = get_len(&c, x, 15);
copy(&c, cnt + 3);
- x = get_byte(&c);
- if (x >> 4)
+ x = GETB(c);
+ if (x > 15)
continue;
cnt = 1;
- back = (1 << 11) + (get_byte(&c) << 2) + (x >> 2) + 1;
- break;
- case BACKPTR:
+ back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
+ } else {
cnt = 0;
- back = (get_byte(&c) << 2) + (x >> 2) + 1;
- break;
+ back = (GETB(c) << 2) + (x >> 2) + 1;
}
copy_backptr(&c, back, cnt + 2);
+ state=
cnt = x & 3;
- state = cnt ? BACKPTR : COPY;
- if (cnt)
- copy(&c, cnt);
- x = get_byte(&c);
+ copy(&c, cnt);
+ x = GETB(c);
}
*inlen = c.in_end - c.in;
+ if (c.in > c.in_end)
+ *inlen = 0;
*outlen = c.out_end - c.out;
return c.error;
}
+
+#ifdef TEST
+#include <stdio.h>
+#include <lzo/lzo1x.h>
+#include "log.h"
+#define MAXSZ (10*1024*1024)
+int main(int argc, char *argv[]) {
+ FILE *in = fopen(argv[1], "rb");
+ uint8_t *orig = av_malloc(MAXSZ + 16);
+ uint8_t *comp = av_malloc(2*MAXSZ + 16);
+ uint8_t *decomp = av_malloc(MAXSZ + 16);
+ size_t s = fread(orig, 1, MAXSZ, in);
+ lzo_uint clen = 0;
+ long tmp[LZO1X_MEM_COMPRESS];
+ int inlen, outlen;
+ int i;
+ av_log_level = AV_LOG_DEBUG;
+ lzo1x_999_compress(orig, s, comp, &clen, tmp);
+ for (i = 0; i < 300; i++) {
+START_TIMER
+ inlen = clen; outlen = MAXSZ;
+#ifdef LIBLZO
+ if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL))
+#elif defined(LIBLZO_UNSAFE)
+ if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL))
+#else
+ if (lzo1x_decode(decomp, &outlen, comp, &inlen))
+#endif
+ av_log(NULL, AV_LOG_ERROR, "decompression error\n");
+STOP_TIMER("lzod")
+ }
+ if (memcmp(orig, decomp, s))
+ av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n");
+ else
+ av_log(NULL, AV_LOG_ERROR, "decompression ok\n");
+ return 0;
+}
+#endif
diff --git a/contrib/ffmpeg/libavcodec/lzo.h b/contrib/ffmpeg/libavutil/lzo.h
index 4d00dd721..5b3d98f40 100644
--- a/contrib/ffmpeg/libavcodec/lzo.h
+++ b/contrib/ffmpeg/libavutil/lzo.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _LZO_H
+#ifndef LZO_H
#define LZO_H
#define LZO_INPUT_DEPLETED 1
@@ -27,7 +27,7 @@
#define LZO_INVALID_BACKPTR 4
#define LZO_ERROR 8
-#define LZO_INPUT_PADDING 4
+#define LZO_INPUT_PADDING 8
#define LZO_OUTPUT_PADDING 12
int lzo1x_decode(void *out, int *outlen, void *in, int *inlen);
diff --git a/contrib/ffmpeg/libavutil/md5.c b/contrib/ffmpeg/libavutil/md5.c
index d33ad1483..f71703124 100644
--- a/contrib/ffmpeg/libavutil/md5.c
+++ b/contrib/ffmpeg/libavutil/md5.c
@@ -35,10 +35,9 @@
#include "md5.h"
typedef struct AVMD5{
+ uint64_t len;
uint8_t block[64];
uint32_t ABCD[4];
- uint64_t len;
- int b_used;
} AVMD5;
const int av_md5_size= sizeof(AVMD5);
@@ -50,7 +49,7 @@ static const uint8_t S[4][4] = {
{ 6, 10, 15, 21 } /* Round 4 */
};
-static const uint32_t T[64] = {
+static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* Round 1 */
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
@@ -76,11 +75,12 @@ static const uint32_t T[64] = {
t = S[i>>4][i&3];\
a += T[i];\
\
- switch(i>>4){\
- case 0: a += (d ^ (b&(c^d))) + X[ i &15 ]; break;\
- case 1: a += (c ^ (d&(c^b))) + X[ (1+5*i)&15 ]; break;\
- case 2: a += (b^c^d) + X[ (5+3*i)&15 ]; break;\
- case 3: a += (c^(b|~d)) + X[ ( 7*i)&15 ]; break;\
+ if(i<32){\
+ if(i<16) a += (d ^ (b&(c^d))) + X[ i &15 ];\
+ else a += (c ^ (d&(c^b))) + X[ (1+5*i)&15 ];\
+ }else{\
+ if(i<48) a += (b^c^d) + X[ (5+3*i)&15 ];\
+ else a += (c^(b|~d)) + X[ ( 7*i)&15 ];\
}\
a = b + (( a << t ) | ( a >> (32 - t) ));
@@ -117,7 +117,6 @@ CORE4(0) CORE4(16) CORE4(32) CORE4(48)
void av_md5_init(AVMD5 *ctx){
ctx->len = 0;
- ctx->b_used = 0;
ctx->ABCD[0] = 0x10325476;
ctx->ABCD[1] = 0x98badcfe;
@@ -126,35 +125,29 @@ void av_md5_init(AVMD5 *ctx){
}
void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){
- int i;
+ int i, j;
+ j= ctx->len & 63;
ctx->len += len;
for( i = 0; i < len; i++ ){
- ctx->block[ ctx->b_used++ ] = src[i];
- if( 64 == ctx->b_used ){
+ ctx->block[j++] = src[i];
+ if( 64 == j ){
body(ctx->ABCD, (uint32_t*) ctx->block);
- ctx->b_used = 0;
+ j = 0;
}
}
}
void av_md5_final(AVMD5 *ctx, uint8_t *dst){
int i;
+ uint64_t finalcount= le2me_64(ctx->len<<3);
- ctx->block[ctx->b_used++] = 0x80;
-
- memset(&ctx->block[ctx->b_used], 0, 64 - ctx->b_used);
-
- if( 56 < ctx->b_used ){
- body( ctx->ABCD, (uint32_t*) ctx->block );
- memset(ctx->block, 0, 64);
- }
-
- for(i=0; i<8; i++)
- ctx->block[56+i] = (ctx->len << 3) >> (i<<3);
+ av_md5_update(ctx, "\200", 1);
+ while((ctx->len & 63)<56)
+ av_md5_update(ctx, "", 1);
- body(ctx->ABCD, (uint32_t*) ctx->block);
+ av_md5_update(ctx, &finalcount, 8);
for(i=0; i<4; i++)
((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]);
@@ -170,6 +163,7 @@ void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){
#ifdef TEST
#include <stdio.h>
+#undef printf
main(){
uint64_t md5val;
int i;
diff --git a/contrib/ffmpeg/libavutil/mem.c b/contrib/ffmpeg/libavutil/mem.c
index f43fb5420..a91ac4a07 100644
--- a/contrib/ffmpeg/libavutil/mem.c
+++ b/contrib/ffmpeg/libavutil/mem.c
@@ -26,7 +26,7 @@
#include "common.h"
-/* here we can use OS dependant allocation functions */
+/* here we can use OS dependent allocation functions */
#undef malloc
#undef free
#undef realloc
@@ -39,11 +39,6 @@
memory allocator. You do not need to suppress this file because the
linker will do it automatically */
-/**
- * Memory allocation of size byte with alignment suitable for all
- * memory accesses (including vectors if available on the
- * CPU). av_malloc(0) must return a non NULL pointer.
- */
void *av_malloc(unsigned int size)
{
void *ptr;
@@ -96,11 +91,6 @@ void *av_malloc(unsigned int size)
return ptr;
}
-/**
- * av_realloc semantics (same as glibc): if ptr is NULL and size > 0,
- * identical to malloc(size). If size is zero, it is identical to
- * free(ptr) and NULL is returned.
- */
void *av_realloc(void *ptr, unsigned int size)
{
#ifdef CONFIG_MEMALIGN_HACK
@@ -121,11 +111,6 @@ void *av_realloc(void *ptr, unsigned int size)
#endif
}
-/**
- * Free memory which has been allocated with av_malloc(z)() or av_realloc().
- * NOTE: ptr = NULL is explicetly allowed
- * Note2: it is recommended that you use av_freep() instead
- */
void av_free(void *ptr)
{
/* XXX: this test should not be needed on most libcs */
@@ -137,10 +122,6 @@ void av_free(void *ptr)
#endif
}
-/**
- * Frees memory and sets the pointer to NULL.
- * @param arg pointer to the pointer which should be freed
- */
void av_freep(void *arg)
{
void **ptr= (void**)arg;
diff --git a/contrib/ffmpeg/libavutil/mem.h b/contrib/ffmpeg/libavutil/mem.h
new file mode 100644
index 000000000..4ebdad8f5
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/mem.h
@@ -0,0 +1,65 @@
+/*
+ * copyright (c) 2006 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
+ */
+
+/**
+ * @file mem.h
+ * Memory handling functions.
+ */
+
+#ifndef AV_MEM_H
+#define AV_MEM_H
+
+#ifdef __GNUC__
+ #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
+#else
+ #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
+#endif
+
+/**
+ * Memory allocation of size byte with alignment suitable for all
+ * memory accesses (including vectors if available on the
+ * CPU). av_malloc(0) must return a non NULL pointer.
+ */
+void *av_malloc(unsigned int size);
+
+/**
+ * av_realloc semantics (same as glibc): if ptr is NULL and size > 0,
+ * identical to malloc(size). If size is zero, it is identical to
+ * free(ptr) and NULL is returned.
+ */
+void *av_realloc(void *ptr, unsigned int size);
+
+/**
+ * Free memory which has been allocated with av_malloc(z)() or av_realloc().
+ * NOTE: ptr = NULL is explicetly allowed
+ * Note2: it is recommended that you use av_freep() instead
+ */
+void av_free(void *ptr);
+
+void *av_mallocz(unsigned int size);
+char *av_strdup(const char *s);
+
+/**
+ * Frees memory and sets the pointer to NULL.
+ * @param ptr pointer to the pointer which should be freed
+ */
+void av_freep(void *ptr);
+
+#endif /* AV_MEM_H */
diff --git a/contrib/ffmpeg/libavutil/random.c b/contrib/ffmpeg/libavutil/random.c
new file mode 100644
index 000000000..c3e71e699
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/random.c
@@ -0,0 +1,104 @@
+/*
+ * Mersenne Twister Random Algorithm
+ * Copyright (c) 2006 Ryan Martell.
+ * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by
+ * Takuji Nishimura and Makoto Matsumoto.
+ *
+ * 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
+ */
+
+
+/**
+see http://en.wikipedia.org/wiki/Mersenne_twister for an explanation of this algorithm.
+*/
+#include <stdio.h>
+#include "random.h"
+
+//#define DEBUG
+
+#ifdef DEBUG
+#include "common.h"
+#include "log.h"
+#endif
+
+
+/* Period parameters */
+#define M 397
+#define A 0x9908b0df /* constant vector a */
+#define UPPER_MASK 0x80000000 /* most significant w-r bits */
+#define LOWER_MASK 0x7fffffff /* least significant r bits */
+
+/** initializes mt[AV_RANDOM_N] with a seed */
+void av_init_random(unsigned int seed, AVRandomState *state)
+{
+ int index;
+
+ /*
+ This differs from the wikipedia article. Source is from the Makoto
+ Makoto Matsumoto and Takuji Nishimura code, with the following comment:
+ */
+ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
+ /* In the previous versions, MSBs of the seed affect */
+ /* only MSBs of the array mt[]. */
+ state->mt[0] = seed & 0xffffffff;
+ for (index = 1; index < AV_RANDOM_N; index++) {
+ unsigned int prev= state->mt[index - 1];
+ state->mt[index] = (1812433253UL * (prev ^ (prev>>30)) + index) & 0xffffffff;
+ }
+ state->index= index; // will cause it to generate untempered numbers the first iteration
+}
+
+/** generate AV_RANDOM_N words at one time (which will then be tempered later) (av_random calls this; you shouldn't) */
+void av_random_generate_untempered_numbers(AVRandomState *state)
+{
+ int kk;
+ unsigned int y;
+
+ for (kk = 0; kk < AV_RANDOM_N - M; kk++) {
+ y = (state->mt[kk] & UPPER_MASK) | (state->mt[kk + 1] & LOWER_MASK);
+ state->mt[kk] = state->mt[kk + M] ^ (y >> 1) ^ ((y&1)*A);
+ }
+ for (; kk < AV_RANDOM_N - 1; kk++) {
+ y = (state->mt[kk] & UPPER_MASK) | (state->mt[kk + 1] & LOWER_MASK);
+ state->mt[kk] = state->mt[kk + (M - AV_RANDOM_N)] ^ (y >> 1) ^ ((y&1)*A);
+ }
+ y = (state->mt[AV_RANDOM_N - 1] & UPPER_MASK) | (state->mt[0] & LOWER_MASK);
+ state->mt[AV_RANDOM_N - 1] = state->mt[M - 1] ^ (y >> 1) ^ ((y&1)*A);
+ state->index = 0;
+}
+
+#ifdef DEBUG
+void av_benchmark_random(void)
+{
+ int x=0;
+ int i, j;
+ AVRandomState state;
+
+ av_init_random(0xdeadbeef, &state);
+ for (j = 0; j < 100; j++) {
+ START_TIMER;
+ x+= av_random(&state);
+ STOP_TIMER("first call to av_random");
+ for (i = 1; i < AV_RANDOM_N; i++) {
+ START_TIMER;
+ x+= av_random(&state);
+ STOP_TIMER("AV_RANDOM_N calls of av_random");
+ }
+ }
+ av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
+}
+#endif
diff --git a/contrib/ffmpeg/libavutil/random.h b/contrib/ffmpeg/libavutil/random.h
new file mode 100644
index 000000000..d9d08a5de
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/random.h
@@ -0,0 +1,69 @@
+/*
+ * Mersenne Twister Random Algorithm
+ * Copyright (c) 2006 Ryan Martell.
+ * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by
+ * Takuji Nishimura and Makoto Matsumoto.
+ *
+ * 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 AV_RANDOM_H
+#define AV_RANDOM_H
+
+#define AV_RANDOM_N 624
+
+typedef struct {
+ unsigned int mt[AV_RANDOM_N]; ///< the array for the state vector
+ int index; ///< current untempered value we use as the base.
+} AVRandomState;
+
+
+void av_init_random(unsigned int seed, AVRandomState *state); ///< to be inlined, the struct must be visible, so it doesn't make sense to try and keep it opaque with malloc/free like calls
+void av_random_generate_untempered_numbers(AVRandomState *state); ///< Regenerate the untempered numbers (must be done every 624 iterations, or it will loop)
+
+/** generates a random number on [0,0xffffffff]-interval */
+static inline unsigned int av_random(AVRandomState *state)
+{
+ unsigned int y;
+
+ // regenerate the untempered numbers if we should...
+ if (state->index >= AV_RANDOM_N)
+ av_random_generate_untempered_numbers(state);
+
+ // grab one...
+ y = state->mt[state->index++];
+
+ /* Now temper (Mersenne Twister coefficients) The coefficients for MT19937 are.. */
+ y ^= (y >> 11);
+ y ^= (y << 7) & 0x9d2c5680;
+ y ^= (y << 15) & 0xefc60000;
+ y ^= (y >> 18);
+
+ return y;
+}
+
+/** return random in range [0-1] as double */
+static inline double av_random_real1(AVRandomState *state)
+{
+ /* divided by 2^32-1 */
+ return av_random(state) * (1.0 / 4294967296.0);
+}
+
+// only available if DEBUG is defined in the .c file
+void av_benchmark_random(void);
+#endif // AV_RANDOM_H
+
diff --git a/contrib/ffmpeg/libavutil/rational.c b/contrib/ffmpeg/libavutil/rational.c
index 0e018c41b..ac0c9d371 100644
--- a/contrib/ffmpeg/libavutil/rational.c
+++ b/contrib/ffmpeg/libavutil/rational.c
@@ -38,8 +38,10 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
int sign= (nom<0) ^ (den<0);
int64_t gcd= ff_gcd(FFABS(nom), FFABS(den));
- nom = FFABS(nom)/gcd;
- den = FFABS(den)/gcd;
+ if(gcd){
+ nom = FFABS(nom)/gcd;
+ den = FFABS(den)/gcd;
+ }
if(nom<=max && den<=max){
a1= (AVRational){nom, den};
den=0;
@@ -65,7 +67,7 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
nom= den;
den= next_den;
}
- assert(ff_gcd(a1.num, a1.den) == 1);
+ assert(ff_gcd(a1.num, a1.den) <= 1U);
*dst_nom = sign ? -a1.num : a1.num;
*dst_den = a1.den;
@@ -73,40 +75,24 @@ int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max)
return den==0;
}
-/**
- * returns b*c.
- */
AVRational av_mul_q(AVRational b, AVRational c){
av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX);
return b;
}
-/**
- * returns b/c.
- */
AVRational av_div_q(AVRational b, AVRational c){
return av_mul_q(b, (AVRational){c.den, c.num});
}
-/**
- * returns b+c.
- */
AVRational av_add_q(AVRational b, AVRational c){
av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX);
return b;
}
-/**
- * returns b-c.
- */
AVRational av_sub_q(AVRational b, AVRational c){
return av_add_q(b, (AVRational){-c.num, c.den});
}
-/**
- * Converts a double precission floating point number to a AVRational.
- * @param max the maximum allowed numerator and denominator
- */
AVRational av_d2q(double d, int max){
AVRational a;
#define LOG2 0.69314718055994530941723212145817656807550013436025
diff --git a/contrib/ffmpeg/libavutil/rational.h b/contrib/ffmpeg/libavutil/rational.h
index 43fc22114..63c0b150f 100644
--- a/contrib/ffmpeg/libavutil/rational.h
+++ b/contrib/ffmpeg/libavutil/rational.h
@@ -38,7 +38,10 @@ typedef struct AVRational{
} AVRational;
/**
- * returns 0 if a==b, 1 if a>b and -1 if a<b.
+ * Compare two rationals.
+ * @param a first rational
+ * @param b second rational
+ * @return 0 if a==b, 1 if a>b and -1 if a<b.
*/
static inline int av_cmp_q(AVRational a, AVRational b){
const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
@@ -48,24 +51,64 @@ static inline int av_cmp_q(AVRational a, AVRational b){
}
/**
- * converts the given AVRational to a double.
+ * Rational to double conversion.
+ * @param a rational to convert
+ * @return (double) a
*/
static inline double av_q2d(AVRational a){
return a.num / (double) a.den;
}
/**
- * reduce a fraction.
- * this is usefull for framerate calculations
+ * Reduce a fraction.
+ * This is useful for framerate calculations.
+ * @param dst_nom destination numerator
+ * @param dst_den destination denominator
+ * @param nom source numerator
+ * @param den source denominator
* @param max the maximum allowed for dst_nom & dst_den
* @return 1 if exact, 0 otherwise
*/
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
+/**
+ * Multiplies two rationals.
+ * @param b first rational.
+ * @param c second rational.
+ * @return b*c.
+ */
AVRational av_mul_q(AVRational b, AVRational c);
+
+/**
+ * Divides one rational by another.
+ * @param b first rational.
+ * @param c second rational.
+ * @return b/c.
+ */
AVRational av_div_q(AVRational b, AVRational c);
+
+/**
+ * Adds two rationals.
+ * @param b first rational.
+ * @param c second rational.
+ * @return b+c.
+ */
AVRational av_add_q(AVRational b, AVRational c);
+
+/**
+ * Subtracts one rational from another.
+ * @param b first rational.
+ * @param c second rational.
+ * returns b-c.
+ */
AVRational av_sub_q(AVRational b, AVRational c);
+
+/**
+ * Converts a double precision floating point number to a rational.
+ * @param d double to convert
+ * @param max the maximum allowed numerator and denominator
+ * @return (AVRational) d.
+ */
AVRational av_d2q(double d, int max);
#endif // RATIONAL_H
diff --git a/contrib/ffmpeg/libavutil/sha1.c b/contrib/ffmpeg/libavutil/sha1.c
new file mode 100644
index 000000000..6c10791f4
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/sha1.c
@@ -0,0 +1,160 @@
+// SHA-1 code Copyright 2007 Michael Nidermayer <michaelni@gmx.at>
+// license LGPL
+// based on public domain SHA-1 code by Steve Reid <steve@edmweb.com>
+
+#include "common.h"
+#include "sha1.h"
+
+typedef struct AVSHA1 {
+ uint64_t count;
+ uint8_t buffer[64];
+ uint32_t state[5];
+} AVSHA1;
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define blk0(i) (block[i] = be2me_32(((uint32_t*)buffer)[i]))
+#define blk(i) (block[i] = rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1))
+
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y) +blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y) +blk (i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=( w^x ^y) +blk (i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk (i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=( w^x ^y) +blk (i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+
+static void transform(uint32_t state[5], uint8_t buffer[64]){
+ uint32_t block[80];
+ unsigned int i, a, b, c, d, e;
+
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+#ifdef CONFIG_SMALL
+ for(i=0; i<80; i++){
+ int t;
+ if(i<16) t= be2me_32(((uint32_t*)buffer)[i]);
+ else t= rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1);
+ block[i]= t;
+ t+= e+rol(a,5);
+ if(i<40){
+ if(i<20) t+= ((b&(c^d))^d) +0x5A827999;
+ else t+= ( b^c ^d) +0x6ED9EBA1;
+ }else{
+ if(i<60) t+= (((b|c)&d)|(b&c))+0x8F1BBCDC;
+ else t+= ( b^c ^d) +0xCA62C1D6;
+ }
+ e= d;
+ d= c;
+ c= rol(b,30);
+ b= a;
+ a= t;
+ }
+#else
+ for(i=0; i<15; i+=5){
+ R0(a,b,c,d,e,0+i); R0(e,a,b,c,d,1+i); R0(d,e,a,b,c,2+i); R0(c,d,e,a,b,3+i); R0(b,c,d,e,a,4+i);
+ }
+ R0(a,b,c,d,e,15); R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ for(i=20; i<40; i+=5){
+ R2(a,b,c,d,e,0+i); R2(e,a,b,c,d,1+i); R2(d,e,a,b,c,2+i); R2(c,d,e,a,b,3+i); R2(b,c,d,e,a,4+i);
+ }
+ for(; i<60; i+=5){
+ R3(a,b,c,d,e,0+i); R3(e,a,b,c,d,1+i); R3(d,e,a,b,c,2+i); R3(c,d,e,a,b,3+i); R3(b,c,d,e,a,4+i);
+ }
+ for(; i<80; i+=5){
+ R4(a,b,c,d,e,0+i); R4(e,a,b,c,d,1+i); R4(d,e,a,b,c,2+i); R4(c,d,e,a,b,3+i); R4(b,c,d,e,a,4+i);
+ }
+#endif
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+}
+
+void av_sha1_init(AVSHA1* ctx){
+ ctx->state[0] = 0x67452301;
+ ctx->state[1] = 0xEFCDAB89;
+ ctx->state[2] = 0x98BADCFE;
+ ctx->state[3] = 0x10325476;
+ ctx->state[4] = 0xC3D2E1F0;
+ ctx->count = 0;
+}
+
+void av_sha1_update(AVSHA1* ctx, uint8_t* data, unsigned int len){
+ unsigned int i, j;
+
+ j = ctx->count & 63;
+ ctx->count += len;
+#ifdef CONFIG_SMALL
+ for( i = 0; i < len; i++ ){
+ ctx->buffer[ j++ ] = data[i];
+ if( 64 == j ){
+ transform(ctx->state, ctx->buffer);
+ j = 0;
+ }
+ }
+#else
+ if ((j + len) > 63) {
+ memcpy(&ctx->buffer[j], data, (i = 64-j));
+ transform(ctx->state, ctx->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ transform(ctx->state, &data[i]);
+ }
+ j=0;
+ }
+ else i = 0;
+ memcpy(&ctx->buffer[j], &data[i], len - i);
+#endif
+}
+
+void av_sha1_final(AVSHA1* ctx, uint8_t digest[20]){
+ int i;
+ uint64_t finalcount= be2me_64(ctx->count<<3);
+
+ av_sha1_update(ctx, "\200", 1);
+ while ((ctx->count & 63) != 56) {
+ av_sha1_update(ctx, "", 1);
+ }
+ av_sha1_update(ctx, &finalcount, 8); /* Should cause a transform() */
+ for(i=0; i<5; i++)
+ ((uint32_t*)digest)[i]= be2me_32(ctx->state[i]);
+}
+
+// use the following to test
+// gcc -DTEST -DHAVE_AV_CONFIG_H -I.. sha1.c -O2 -W -Wall -o sha1 && time ./sha1
+#ifdef TEST
+#include <stdio.h>
+#undef printf
+
+int main(){
+ int i, k;
+ AVSHA1 ctx;
+ unsigned char digest[20];
+
+ for(k=0; k<3; k++){
+ av_sha1_init(&ctx);
+ if(k==0)
+ av_sha1_update(&ctx, "abc", 3);
+ else if(k==1)
+ av_sha1_update(&ctx, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56);
+ else
+ for(i=0; i<1000*1000; i++)
+ av_sha1_update(&ctx, "a", 1);
+ av_sha1_final(&ctx, digest);
+ for (i = 0; i < 20; i++)
+ printf("%02X", digest[i]);
+ putchar('\n');
+ }
+ //Test Vectors (from FIPS PUB 180-1)
+ printf("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\n"
+ "84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\n"
+ "34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\n");
+
+ return 0;
+}
+#endif
diff --git a/contrib/ffmpeg/libavutil/sha1.h b/contrib/ffmpeg/libavutil/sha1.h
new file mode 100644
index 000000000..8739cbde9
--- /dev/null
+++ b/contrib/ffmpeg/libavutil/sha1.h
@@ -0,0 +1,11 @@
+#ifndef AV_SHA1_H
+#define AV_SHA1_H
+
+extern const int av_sha1_size;
+
+struct AVSHA1;
+
+void av_sha1_init(struct AVSHA1* context);
+void av_sha1_update(struct AVSHA1* context, uint8_t* data, unsigned int len);
+void av_sha1_final(struct AVSHA1* context, uint8_t digest[20]);
+#endif
diff --git a/contrib/ffmpeg/libavutil/tree.h b/contrib/ffmpeg/libavutil/tree.h
index 36897ef46..be1735858 100644
--- a/contrib/ffmpeg/libavutil/tree.h
+++ b/contrib/ffmpeg/libavutil/tree.h
@@ -18,6 +18,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * @file tree.h
+ * A tree container.
+ * @author Michael Niedermayer <michaelni@gmx.at>
+ */
+
#ifndef TREE_H
#define TREE_H
@@ -26,25 +32,25 @@ struct AVTreeNode;
/**
* Finds an element.
* @param root a pointer to the root node of the tree
- * @param next if next is not NULL then next[0] will contain the previous element and
- * next[1] the next element if either doesnt exist then the corresponding
- * entry in next is unchanged
- * @return an element with cmp(key, elem)==0 or NULL if no such element exists in
- * the tree
+ * @param next If next is not NULL then next[0] will contain the previous
+ * element and next[1] the next element if either does not exist
+ * then the corresponding entry in next is unchanged.
+ * @return An element with cmp(key, elem)==0 or NULL if no such element exists in
+ * the tree.
*/
void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *key, const void *b), void *next[2]);
/**
* Finds a element for which cmp(key, elem)==0, if no such element is found key
* is inserted into the tree.
- * @param rootp a pointer to a pointer to the root node of the tree note the
- * root node can change during insertions, this is required to
- * keep the tree balanced
+ * @param rootp A pointer to a pointer to the root node of the tree. Note that
+ * the root node can change during insertions, this is required
+ * to keep the tree balanced.
*
- * @return if no insertion happened, the found element
- * if a insertion happened, then either key or NULL is returned (which it is
- * depends on the tree state and the implemenattion, you should make no
- * asumtations that its one or the other in code)
+ * @return If no insertion happened, the found element.
+ * If an insertion happened, then either key or NULL will be returned.
+ * Which one it is depends on the tree state and the implementation. You
+ * should make no assumptions that it's one or the other in the code.
*/
void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b));
void av_tree_destroy(struct AVTreeNode *t);
diff --git a/contrib/ffmpeg/libavutil/x86_cpu.h b/contrib/ffmpeg/libavutil/x86_cpu.h
index 3d54b2a60..67d4cd9aa 100644
--- a/contrib/ffmpeg/libavutil/x86_cpu.h
+++ b/contrib/ffmpeg/libavutil/x86_cpu.h
@@ -57,4 +57,8 @@
# define REGSP esp
#endif
+#if defined(ARCH_X86_64) || (defined(ARCH_X86_32) && defined(CONFIG_EBX_AVAILABLE) && defined(CONFIG_EBP_AVAILABLE))
+# define CONFIG_7REGS 1
+#endif
+
#endif /* AVUTIL_X86CPU_H */
diff --git a/contrib/ffmpeg/libpostproc/Makefile b/contrib/ffmpeg/libpostproc/Makefile
index a6765365d..d30b4a18d 100644
--- a/contrib/ffmpeg/libpostproc/Makefile
+++ b/contrib/ffmpeg/libpostproc/Makefile
@@ -7,10 +7,8 @@ incdir=$(prefix)/include/postproc
EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
NAME=postproc
-ifeq ($(BUILD_SHARED),yes)
LIBVERSION=$(SPPVERSION)
LIBMAJOR=$(SPPMAJOR)
-endif
STATIC_OBJS=postprocess.o
SHARED_OBJS=postprocess_pic.o
diff --git a/contrib/ffmpeg/libpostproc/postprocess.c b/contrib/ffmpeg/libpostproc/postprocess.c
index c9f2893e3..f68c8a723 100644
--- a/contrib/ffmpeg/libpostproc/postprocess.c
+++ b/contrib/ffmpeg/libpostproc/postprocess.c
@@ -466,7 +466,7 @@ static inline void horizX1Filter(uint8_t *src, int stride, int QP)
/**
* accurate deblock filter
*/
-static always_inline void do_a_deblock_C(uint8_t *src, int step, int stride, PPContext *c){
+static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride, PPContext *c){
int y;
const int QP= c->QP;
const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
diff --git a/contrib/ffmpeg/libpostproc/postprocess_altivec_template.c b/contrib/ffmpeg/libpostproc/postprocess_altivec_template.c
index 3a33a5885..6a76c0eb7 100644
--- a/contrib/ffmpeg/libpostproc/postprocess_altivec_template.c
+++ b/contrib/ffmpeg/libpostproc/postprocess_altivec_template.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "avutil.h"
#ifdef CONFIG_DARWIN
#define AVV(x...) (x)
@@ -67,7 +68,7 @@ static inline int vertClassify_altivec(uint8_t src[], int stride, PPContext *c)
vector by assuming (stride % 16) == 0, unfortunately
this is not always true.
*/
- short __attribute__ ((aligned(16))) data[8];
+ DECLARE_ALIGNED(16, short, data[8]);
int numEq;
uint8_t *src2 = src;
vector signed short v_dcOffset;
@@ -206,7 +207,7 @@ static inline void doVertLowPass_altivec(uint8_t *src, int stride, PPContext *c)
const vector signed int zero = vec_splat_s32(0);
const int properStride = (stride % 16);
const int srcAlign = ((unsigned long)src2 % 16);
- short __attribute__ ((aligned(16))) qp[8];
+ DECLARE_ALIGNED(16, short, qp[8]);
qp[0] = c->QP;
vector signed short vqp = vec_ld(0, qp);
vqp = vec_splat(vqp, 0);
@@ -392,7 +393,7 @@ static inline void doVertDefFilter_altivec(uint8_t src[], int stride, PPContext
*/
uint8_t *src2 = src;
const vector signed int zero = vec_splat_s32(0);
- short __attribute__ ((aligned(16))) qp[8];
+ DECLARE_ALIGNED(16, short, qp[8]);
qp[0] = 8*c->QP;
vector signed short vqp = vec_ld(0, qp);
vqp = vec_splat(vqp, 0);
@@ -515,7 +516,7 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
src & stride :-(
*/
uint8_t *srcCopy = src;
- uint8_t __attribute__((aligned(16))) dt[16];
+ DECLARE_ALIGNED(16, uint8_t, dt[16]);
const vector signed int zero = vec_splat_s32(0);
vector unsigned char v_dt;
dt[0] = deringThreshold;
@@ -579,7 +580,7 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
v_avg = vec_avg(v_min, v_max);
}
- signed int __attribute__((aligned(16))) S[8];
+ DECLARE_ALIGNED(16, signed int, S[8]);
{
const vector unsigned short mask1 = (vector unsigned short)
AVV(0x0001, 0x0002, 0x0004, 0x0008,
@@ -675,7 +676,7 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
/* I'm not sure the following is actually faster
than straight, unvectorized C code :-( */
- int __attribute__((aligned(16))) tQP2[4];
+ DECLARE_ALIGNED(16, int, tQP2[4]);
tQP2[0]= c->QP/2 + 1;
vector signed int vQP2 = vec_ld(0, tQP2);
vQP2 = vec_splat(vQP2, 0);
diff --git a/contrib/ffmpeg/libpostproc/postprocess_template.c b/contrib/ffmpeg/libpostproc/postprocess_template.c
index c22d5d1b6..f084130a6 100644
--- a/contrib/ffmpeg/libpostproc/postprocess_template.c
+++ b/contrib/ffmpeg/libpostproc/postprocess_template.c
@@ -2645,7 +2645,7 @@ Switch between
/**
* accurate deblock filter
*/
-static always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, PPContext *c){
+static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, PPContext *c){
int64_t dc_mask, eq_mask, both_masks;
int64_t sums[10*8*2];
src+= step*3; // src points to begin of the 8x8 Block
@@ -3464,7 +3464,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
uint8_t *srcBlock= &(src[y*srcStride]);
uint8_t *dstBlock= tempDst + dstStride;
- // From this point on it is guranteed that we can read and write 16 lines downward
+ // From this point on it is guaranteed that we can read and write 16 lines downward
// finish 1 block before the next otherwise we might have a problem
// with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing
for(x=0; x<width; x+=BLOCK_SIZE)
@@ -3578,7 +3578,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
srcBlock= tempSrc;
}
- // From this point on it is guranteed that we can read and write 16 lines downward
+ // From this point on it is guaranteed that we can read and write 16 lines downward
// finish 1 block before the next otherwise we might have a problem
// with the L1 Cache of the P4 ... or only a few blocks at a time or soemthing
for(x=0; x<width; x+=BLOCK_SIZE)
diff --git a/contrib/ffmpeg/libswscale/Makefile b/contrib/ffmpeg/libswscale/Makefile
index 82e9bfc02..a1c25a76a 100644
--- a/contrib/ffmpeg/libswscale/Makefile
+++ b/contrib/ffmpeg/libswscale/Makefile
@@ -2,25 +2,23 @@
include ../config.mak
NAME=swscale
-ifeq ($(BUILD_SHARED),yes)
LIBVERSION=$(SWSVERSION)
LIBMAJOR=$(SWSMAJOR)
-endif
EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS)
-OBJS= swscale.o rgb2rgb.o yuv2rgb.o
-ifeq ($(TARGET_ALTIVEC),yes)
-OBJS+= yuv2rgb_altivec.o
-endif
+OBJS= swscale.o rgb2rgb.o
+
+OBJS-$(TARGET_ALTIVEC) += yuv2rgb_altivec.o
+OBJS-$(CONFIG_GPL) += yuv2rgb.o
HEADERS = swscale.h rgb2rgb.h
include ../common.mak
-cs_test: cs_test.c $(LIB)
+cs_test: cs_test.o $(LIB)
-swscale-example: swscale-example.o $(LIB)
+swscale-example: swscale-example.o $(LIB) -lm
clean::
rm -f cs_test swscale-example
diff --git a/contrib/ffmpeg/libswscale/cs_test.c b/contrib/ffmpeg/libswscale/cs_test.c
index 6b2deab3e..cd0100618 100644
--- a/contrib/ffmpeg/libswscale/cs_test.c
+++ b/contrib/ffmpeg/libswscale/cs_test.c
@@ -23,7 +23,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <inttypes.h>
-#include <malloc.h>
#include "swscale.h"
#include "rgb2rgb.h"
@@ -32,9 +31,6 @@
#define srcByte 0x55
#define dstByte 0xBB
-#ifdef __APPLE_CC__
-#define memalign(x,y) malloc(y)
-#endif
static int cpu_caps;
@@ -54,7 +50,7 @@ static char *args_parse(int argc, char *argv[])
cpu_caps |= SWS_CPU_CAPS_3DNOW;
break;
default:
- fprintf(stderr, "Unknown option %c\n", o);
+ av_log(NULL, AV_LOG_ERROR, "Unknown option %c\n", o);
}
}
@@ -64,14 +60,14 @@ static char *args_parse(int argc, char *argv[])
int main(int argc, char **argv)
{
int i, funcNum;
- uint8_t *srcBuffer= (uint8_t*)memalign(128, SIZE);
- uint8_t *dstBuffer= (uint8_t*)memalign(128, SIZE);
+ uint8_t *srcBuffer= (uint8_t*)av_malloc(SIZE);
+ uint8_t *dstBuffer= (uint8_t*)av_malloc(SIZE);
int failedNum=0;
int passedNum=0;
- printf("memory corruption test ...\n");
+ av_log(NULL, AV_LOG_INFO, "memory corruption test ...\n");
args_parse(argc, argv);
- fprintf(stderr, "CPU capabilities forced to %x\n", cpu_caps);
+ av_log(NULL, AV_LOG_INFO, "CPU capabilities forced to %x\n", cpu_caps);
sws_rgb2rgb_init(cpu_caps);
for(funcNum=0; funcNum<100; funcNum++){
@@ -80,16 +76,16 @@ int main(int argc, char **argv)
int srcBpp=0;
int dstBpp=0;
- printf("."); fflush(stdout);
+ av_log(NULL, AV_LOG_INFO,".");
memset(srcBuffer, srcByte, SIZE);
for(width=32; width<64; width++){
int dstOffset;
- for(dstOffset=128; dstOffset<196; dstOffset++){
+ for(dstOffset=128; dstOffset<196; dstOffset+=4){
int srcOffset;
memset(dstBuffer, dstByte, SIZE);
- for(srcOffset=128; srcOffset<196; srcOffset++){
+ for(srcOffset=128; srcOffset<196; srcOffset+=4){
uint8_t *src= srcBuffer+srcOffset;
uint8_t *dst= dstBuffer+dstOffset;
char *name=NULL;
@@ -149,6 +145,7 @@ int main(int argc, char **argv)
srcBpp=4;
dstBpp=2;
name="rgb32to15";
+ //((*s++) << TGA_SHIFT32) | TGA_ALPHA32;
rgb32to15(src, dst, width*srcBpp);
break;
case 9:
@@ -272,7 +269,7 @@ int main(int argc, char **argv)
for(i=0; i<SIZE; i++){
if(srcBuffer[i]!=srcByte){
- printf("src damaged at %d w:%d src:%d dst:%d %s\n",
+ av_log(NULL, AV_LOG_INFO, "src damaged at %d w:%d src:%d dst:%d %s\n",
i, width, srcOffset, dstOffset, name);
failed=1;
break;
@@ -280,7 +277,7 @@ int main(int argc, char **argv)
}
for(i=0; i<dstOffset; i++){
if(dstBuffer[i]!=dstByte){
- printf("dst damaged at %d w:%d src:%d dst:%d %s\n",
+ av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n",
i, width, srcOffset, dstOffset, name);
failed=1;
break;
@@ -288,7 +285,7 @@ int main(int argc, char **argv)
}
for(i=dstOffset + width*dstBpp; i<SIZE; i++){
if(dstBuffer[i]!=dstByte){
- printf("dst damaged at %d w:%d src:%d dst:%d %s\n",
+ av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n",
i, width, srcOffset, dstOffset, name);
failed=1;
break;
@@ -301,6 +298,6 @@ int main(int argc, char **argv)
else if(srcBpp) passedNum++;
}
- printf("%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum);
+ av_log(NULL, AV_LOG_INFO, "%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum);
return failedNum;
}
diff --git a/contrib/ffmpeg/libswscale/rgb2rgb.c b/contrib/ffmpeg/libswscale/rgb2rgb.c
index 2bb5d3355..a938abfc9 100644
--- a/contrib/ffmpeg/libswscale/rgb2rgb.c
+++ b/contrib/ffmpeg/libswscale/rgb2rgb.c
@@ -91,7 +91,7 @@ void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *sr
long srcStride1, long srcStride2,
long srcStride3, long dstStride);
-#if defined(ARCH_X86)
+#if defined(ARCH_X86) && defined(CONFIG_GPL)
static const uint64_t mmx_null __attribute__((aligned(8))) = 0x0000000000000000ULL;
static const uint64_t mmx_one __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL;
static const uint64_t mask32b attribute_used __attribute__((aligned(8))) = 0x000000FF000000FFULL;
@@ -175,7 +175,7 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
#define RENAME(a) a ## _C
#include "rgb2rgb_template.c"
-#if defined(ARCH_X86)
+#if defined(ARCH_X86) && defined(CONFIG_GPL)
//MMX versions
#undef RENAME
@@ -214,7 +214,7 @@ static uint64_t __attribute__((aligned(8))) dither8[2]={
*/
void sws_rgb2rgb_init(int flags){
-#if defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)
+#if (defined(HAVE_MMX2) || defined(HAVE_3DNOW) || defined(HAVE_MMX)) && defined(CONFIG_GPL)
if(flags & SWS_CPU_CAPS_MMX2){
rgb15to16= rgb15to16_MMX2;
rgb15to24= rgb15to24_MMX2;
@@ -341,7 +341,7 @@ void sws_rgb2rgb_init(int flags){
}
/**
- * Pallete is assumed to contain bgr32
+ * Palette is assumed to contain BGR32.
*/
void palette8torgb32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
@@ -391,7 +391,7 @@ void palette8tobgr32(const uint8_t *src, uint8_t *dst, long num_pixels, const ui
}
/**
- * Pallete is assumed to contain bgr32
+ * Palette is assumed to contain BGR32.
*/
void palette8torgb24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
@@ -446,7 +446,7 @@ void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const ui
}
/**
- * Pallete is assumed to contain bgr15, see rgb32to15 to convert the palette
+ * Palette is assumed to contain BGR15, see rgb32to15 to convert the palette.
*/
void palette8torgb15(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette)
{
diff --git a/contrib/ffmpeg/libswscale/swscale.c b/contrib/ffmpeg/libswscale/swscale.c
index eb9092c19..f6a23425b 100644
--- a/contrib/ffmpeg/libswscale/swscale.c
+++ b/contrib/ffmpeg/libswscale/swscale.c
@@ -22,7 +22,7 @@
*/
/*
- supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09
+ supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09, PAL8
supported output formats: YV12, I420/IYUV, YUY2, UYVY, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09
{BGR,RGB}{1,4,8,15,16} support dithering
@@ -61,11 +61,6 @@ untested special converters
#include <unistd.h>
#include "config.h"
#include <assert.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#else
-#include <stdlib.h>
-#endif
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
@@ -112,14 +107,17 @@ untested special converters
|| (x)==PIX_FMT_BGR32|| (x)==PIX_FMT_RGB24|| (x)==PIX_FMT_RGB565|| (x)==PIX_FMT_RGB555\
|| (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P\
|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE\
- || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P)
+ || (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P\
+ || (x)==PIX_FMT_PAL8 || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_RGB8\
+ || (x)==PIX_FMT_BGR4_BYTE || (x)==PIX_FMT_RGB4_BYTE)
#define isSupportedOut(x) ((x)==PIX_FMT_YUV420P || (x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422\
|| (x)==PIX_FMT_YUV444P || (x)==PIX_FMT_YUV422P || (x)==PIX_FMT_YUV411P\
|| isRGB(x) || isBGR(x)\
|| (x)==PIX_FMT_NV12 || (x)==PIX_FMT_NV21\
|| (x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE\
|| (x)==PIX_FMT_GRAY8 || (x)==PIX_FMT_YUV410P)
-#define isPacked(x) ((x)==PIX_FMT_YUYV422 || (x)==PIX_FMT_UYVY422 ||isRGB(x) || isBGR(x))
+#define isPacked(x) ((x)==PIX_FMT_PAL8 || (x)==PIX_FMT_YUYV422 ||\
+ (x)==PIX_FMT_UYVY422 || isRGB(x) || isBGR(x))
#define RGB2YUV_SHIFT 16
#define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
@@ -149,7 +147,7 @@ add BGR4 output support
write special BGR->BGR scaler
*/
-#if defined(ARCH_X86)
+#if defined(ARCH_X86) && defined (CONFIG_GPL)
static uint64_t attribute_used __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL;
static uint64_t attribute_used __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL;
static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL;
@@ -208,6 +206,12 @@ extern const uint8_t dither_8x8_32[8][8];
extern const uint8_t dither_8x8_73[8][8];
extern const uint8_t dither_8x8_220[8][8];
+static const char * sws_context_to_name(void * ptr) {
+ return "swscaler";
+}
+
+static AVClass sws_context_class = { "SWScaler", sws_context_to_name, NULL };
+
char *sws_format_name(enum PixelFormat format)
{
switch (format) {
@@ -290,7 +294,7 @@ char *sws_format_name(enum PixelFormat format)
}
}
-#if defined(ARCH_X86)
+#if defined(ARCH_X86) && defined (CONFIG_GPL)
void in_asm_used_var_warning_killer()
{
volatile int i= bF8+bFC+w10+
@@ -313,7 +317,7 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt
for(j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
- dest[i]= FFMIN(FFMAX(val>>19, 0), 255);
+ dest[i]= av_clip_uint8(val>>19);
}
if(uDest != NULL)
@@ -328,8 +332,8 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt
v += chrSrc[j][i + 2048] * chrFilter[j];
}
- uDest[i]= FFMIN(FFMAX(u>>19, 0), 255);
- vDest[i]= FFMIN(FFMAX(v>>19, 0), 255);
+ uDest[i]= av_clip_uint8(u>>19);
+ vDest[i]= av_clip_uint8(v>>19);
}
}
@@ -346,7 +350,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
for(j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
- dest[i]= FFMIN(FFMAX(val>>19, 0), 255);
+ dest[i]= av_clip_uint8(val>>19);
}
if(uDest == NULL)
@@ -364,8 +368,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
v += chrSrc[j][i + 2048] * chrFilter[j];
}
- uDest[2*i]= FFMIN(FFMAX(u>>19, 0), 255);
- uDest[2*i+1]= FFMIN(FFMAX(v>>19, 0), 255);
+ uDest[2*i]= av_clip_uint8(u>>19);
+ uDest[2*i+1]= av_clip_uint8(v>>19);
}
else
for(i=0; i<chrDstW; i++)
@@ -379,8 +383,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
v += chrSrc[j][i + 2048] * chrFilter[j];
}
- uDest[2*i]= FFMIN(FFMAX(v>>19, 0), 255);
- uDest[2*i+1]= FFMIN(FFMAX(u>>19, 0), 255);
+ uDest[2*i]= av_clip_uint8(v>>19);
+ uDest[2*i+1]= av_clip_uint8(u>>19);
}
}
@@ -391,7 +395,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
int Y2=1<<18;\
int U=1<<18;\
int V=1<<18;\
- type *r, *b, *g;\
+ type attribute_unused *r, *b, *g;\
const int i2= 2*i;\
\
for(j=0; j<lumFilterSize; j++)\
@@ -422,9 +426,9 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
#define YSCALE_YUV_2_RGBX_C(type) \
YSCALE_YUV_2_PACKEDX_C(type)\
- r = c->table_rV[V];\
- g = c->table_gU[U] + c->table_gV[V];\
- b = c->table_bU[U];\
+ r = (type *)c->table_rV[V];\
+ g = (type *)(c->table_gU[U] + c->table_gV[V]);\
+ b = (type *)c->table_bU[U];\
#define YSCALE_YUV_2_PACKED2_C \
for(i=0; i<(dstW>>1); i++){\
@@ -437,9 +441,9 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
#define YSCALE_YUV_2_RGB2_C(type) \
YSCALE_YUV_2_PACKED2_C\
type *r, *b, *g;\
- r = c->table_rV[V];\
- g = c->table_gU[U] + c->table_gV[V];\
- b = c->table_bU[U];\
+ r = (type *)c->table_rV[V];\
+ g = (type *)(c->table_gU[U] + c->table_gV[V]);\
+ b = (type *)c->table_bU[U];\
#define YSCALE_YUV_2_PACKED1_C \
for(i=0; i<(dstW>>1); i++){\
@@ -452,9 +456,9 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
#define YSCALE_YUV_2_RGB1_C(type) \
YSCALE_YUV_2_PACKED1_C\
type *r, *b, *g;\
- r = c->table_rV[V];\
- g = c->table_gU[U] + c->table_gV[V];\
- b = c->table_bU[U];\
+ r = (type *)c->table_rV[V];\
+ g = (type *)(c->table_gU[U] + c->table_gV[V]);\
+ b = (type *)c->table_bU[U];\
#define YSCALE_YUV_2_PACKED1B_C \
for(i=0; i<(dstW>>1); i++){\
@@ -467,9 +471,9 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
#define YSCALE_YUV_2_RGB1B_C(type) \
YSCALE_YUV_2_PACKED1B_C\
type *r, *b, *g;\
- r = c->table_rV[V];\
- g = c->table_gU[U] + c->table_gV[V];\
- b = c->table_bU[U];\
+ r = (type *)c->table_rV[V];\
+ g = (type *)(c->table_gU[U] + c->table_gV[V]);\
+ b = (type *)c->table_bU[U];\
#define YSCALE_YUV_2_ANYRGB_C(func, func2)\
switch(c->dstFormat)\
@@ -803,27 +807,27 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l
//Note: we have C, X86, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
//Plain C versions
-#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT)
+#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) || !defined(CONFIG_GPL)
#define COMPILE_C
#endif
#ifdef ARCH_POWERPC
-#if defined (HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)
+#if (defined (HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_ALTIVEC
#endif //HAVE_ALTIVEC
#endif //ARCH_POWERPC
#if defined(ARCH_X86)
-#if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
+#if ((defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_MMX
#endif
-#if defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
+#if (defined (HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_MMX2
#endif
-#if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
+#if ((defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)) && defined (CONFIG_GPL)
#define COMPILE_3DNOW
#endif
#endif //ARCH_X86 || ARCH_X86_64
@@ -1201,7 +1205,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
*outFilterSize= filterSize;
if(flags&SWS_PRINT_INFO)
- MSG_V("SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize);
+ av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize);
/* try to reduce the filter-size (step2 reduce it) */
for(i=0; i<dstW; i++)
{
@@ -1250,8 +1254,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
// Note the +1 is for the MMXscaler which reads over the end
/* align at 16 for AltiVec (needed by hScale_altivec_real) */
- *outFilter= av_malloc(*outFilterSize*(dstW+1)*sizeof(int16_t));
- memset(*outFilter, 0, *outFilterSize*(dstW+1)*sizeof(int16_t));
+ *outFilter= av_mallocz(*outFilterSize*(dstW+1)*sizeof(int16_t));
/* Normalize & Store in outFilter */
for(i=0; i<dstW; i++)
@@ -1463,14 +1466,14 @@ static void globalInit(void){
// generating tables:
int i;
for(i=0; i<768; i++){
- int c= FFMIN(FFMAX(i-256, 0), 255);
+ int c= av_clip_uint8(i-256);
clip_table[i]=c;
}
}
static SwsFunc getSwsFunc(int flags){
-#ifdef RUNTIME_CPUDETECT
+#if defined(RUNTIME_CPUDETECT) && defined (CONFIG_GPL)
#if defined(ARCH_X86)
// ordered per speed fasterst first
if(flags & SWS_CPU_CAPS_MMX2)
@@ -1578,7 +1581,7 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
case 0x83: conv= rgb15to32; break;
case 0x84: conv= rgb16to32; break;
case 0x86: conv= rgb24to32; break;
- default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
+ default: av_log(c, AV_LOG_ERROR, "swScaler: internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
}
}else if( (isBGR(srcFormat) && isRGB(dstFormat))
@@ -1600,11 +1603,11 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr
case 0x84: conv= rgb16tobgr32; break;
case 0x86: conv= rgb24tobgr32; break;
case 0x88: conv= rgb32tobgr32; break;
- default: MSG_ERR("swScaler: internal error %s -> %s converter\n",
+ default: av_log(c, AV_LOG_ERROR, "swScaler: internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
}
}else{
- MSG_ERR("swScaler: internal error %s -> %s converter\n",
+ av_log(c, AV_LOG_ERROR, "swScaler: internal error %s -> %s converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
}
@@ -1873,7 +1876,12 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange
if(!srcRange){
cy= (cy*255) / 219;
oy= 16<<16;
- }
+ }else{
+ crv= (crv*224) / 255;
+ cbu= (cbu*224) / 255;
+ cgu= (cgu*224) / 255;
+ cgv= (cgv*224) / 255;
+ }
cy = (cy *contrast )>>16;
crv= (crv*contrast * saturation)>>32;
@@ -1948,7 +1956,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
asm volatile("emms\n\t"::: "memory");
#endif
-#ifndef RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off
+#if !defined(RUNTIME_CPUDETECT) || !defined (CONFIG_GPL) //ensure that the flags match the compiled variant if cpudetect is off
flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC);
#ifdef HAVE_MMX2
flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
@@ -1973,19 +1981,19 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
if(!isSupportedIn(srcFormat))
{
- MSG_ERR("swScaler: %s is not supported as input format\n", sws_format_name(srcFormat));
+ av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input format\n", sws_format_name(srcFormat));
return NULL;
}
if(!isSupportedOut(dstFormat))
{
- MSG_ERR("swScaler: %s is not supported as output format\n", sws_format_name(dstFormat));
+ av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output format\n", sws_format_name(dstFormat));
return NULL;
}
/* sanity check */
if(srcW<4 || srcH<1 || dstW<8 || dstH<1) //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code
{
- MSG_ERR("swScaler: %dx%d -> %dx%d is invalid scaling dimension\n",
+ av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n",
srcW, srcH, dstW, dstH);
return NULL;
}
@@ -1993,9 +2001,9 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
if(!dstFilter) dstFilter= &dummyFilter;
if(!srcFilter) srcFilter= &dummyFilter;
- c= av_malloc(sizeof(SwsContext));
- memset(c, 0, sizeof(SwsContext));
+ c= av_mallocz(sizeof(SwsContext));
+ c->av_class = &sws_context_class;
c->srcW= srcW;
c->srcH= srcH;
c->dstW= dstW;
@@ -2058,11 +2066,13 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
{
c->swScale= PlanarToNV12Wrapper;
}
+#ifdef CONFIG_GPL
/* yuv2bgr */
if((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P) && (isBGR(dstFormat) || isRGB(dstFormat)))
{
c->swScale= yuv2rgb_get_func_ptr(c);
}
+#endif
if( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P )
{
@@ -2135,7 +2145,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
if(c->swScale){
if(flags&SWS_PRINT_INFO)
- MSG_INFO("SwScaler: using unscaled %s -> %s special converter\n",
+ av_log(c, AV_LOG_INFO, "SwScaler: using unscaled %s -> %s special converter\n",
sws_format_name(srcFormat), sws_format_name(dstFormat));
return c;
}
@@ -2147,7 +2157,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
if(!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR))
{
if(flags&SWS_PRINT_INFO)
- MSG_INFO("SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n");
+ av_log(c, AV_LOG_INFO, "SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n");
}
if(usesHFilter) c->canMMX2BeUsed=0;
}
@@ -2279,12 +2289,11 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
//Note we need at least one pixel more at the end because of the mmx code (just in case someone wanna replace the 4000/8000)
/* align at 16 bytes for AltiVec */
for(i=0; i<c->vLumBufSize; i++)
- c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_malloc(4000);
+ c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_mallocz(4000);
for(i=0; i<c->vChrBufSize; i++)
c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= av_malloc(8000);
//try to avoid drawing green stuff between the right end and the stride end
- for(i=0; i<c->vLumBufSize; i++) memset(c->lumPixBuf[i], 0, 4000);
for(i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000);
ASSERT(c->chrDstH <= dstH)
@@ -2297,47 +2306,47 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
char *dither= "";
#endif
if(flags&SWS_FAST_BILINEAR)
- MSG_INFO("SwScaler: FAST_BILINEAR scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: FAST_BILINEAR scaler, ");
else if(flags&SWS_BILINEAR)
- MSG_INFO("SwScaler: BILINEAR scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: BILINEAR scaler, ");
else if(flags&SWS_BICUBIC)
- MSG_INFO("SwScaler: BICUBIC scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: BICUBIC scaler, ");
else if(flags&SWS_X)
- MSG_INFO("SwScaler: Experimental scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Experimental scaler, ");
else if(flags&SWS_POINT)
- MSG_INFO("SwScaler: Nearest Neighbor / POINT scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Nearest Neighbor / POINT scaler, ");
else if(flags&SWS_AREA)
- MSG_INFO("SwScaler: Area Averageing scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Area Averageing scaler, ");
else if(flags&SWS_BICUBLIN)
- MSG_INFO("SwScaler: luma BICUBIC / chroma BILINEAR scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: luma BICUBIC / chroma BILINEAR scaler, ");
else if(flags&SWS_GAUSS)
- MSG_INFO("SwScaler: Gaussian scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Gaussian scaler, ");
else if(flags&SWS_SINC)
- MSG_INFO("SwScaler: Sinc scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Sinc scaler, ");
else if(flags&SWS_LANCZOS)
- MSG_INFO("SwScaler: Lanczos scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Lanczos scaler, ");
else if(flags&SWS_SPLINE)
- MSG_INFO("SwScaler: Bicubic spline scaler, ");
+ av_log(c, AV_LOG_INFO, "SwScaler: Bicubic spline scaler, ");
else
- MSG_INFO("SwScaler: ehh flags invalid?! ");
+ av_log(c, AV_LOG_INFO, "SwScaler: ehh flags invalid?! ");
if(dstFormat==PIX_FMT_BGR555 || dstFormat==PIX_FMT_BGR565)
- MSG_INFO("from %s to%s %s ",
+ av_log(c, AV_LOG_INFO, "from %s to%s %s ",
sws_format_name(srcFormat), dither, sws_format_name(dstFormat));
else
- MSG_INFO("from %s to %s ",
+ av_log(c, AV_LOG_INFO, "from %s to %s ",
sws_format_name(srcFormat), sws_format_name(dstFormat));
if(flags & SWS_CPU_CAPS_MMX2)
- MSG_INFO("using MMX2\n");
+ av_log(c, AV_LOG_INFO, "using MMX2\n");
else if(flags & SWS_CPU_CAPS_3DNOW)
- MSG_INFO("using 3DNOW\n");
+ av_log(c, AV_LOG_INFO, "using 3DNOW\n");
else if(flags & SWS_CPU_CAPS_MMX)
- MSG_INFO("using MMX\n");
+ av_log(c, AV_LOG_INFO, "using MMX\n");
else if(flags & SWS_CPU_CAPS_ALTIVEC)
- MSG_INFO("using AltiVec\n");
+ av_log(c, AV_LOG_INFO, "using AltiVec\n");
else
- MSG_INFO("using C\n");
+ av_log(c, AV_LOG_INFO, "using C\n");
}
if(flags & SWS_PRINT_INFO)
@@ -2345,70 +2354,70 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
if(flags & SWS_CPU_CAPS_MMX)
{
if(c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR))
- MSG_V("SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n");
else
{
if(c->hLumFilterSize==4)
- MSG_V("SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n");
else if(c->hLumFilterSize==8)
- MSG_V("SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n");
else
- MSG_V("SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n");
if(c->hChrFilterSize==4)
- MSG_V("SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n");
else if(c->hChrFilterSize==8)
- MSG_V("SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n");
else
- MSG_V("SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n");
}
}
else
{
#if defined(ARCH_X86)
- MSG_V("SwScaler: using X86-Asm scaler for horizontal scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using X86-Asm scaler for horizontal scaling\n");
#else
if(flags & SWS_FAST_BILINEAR)
- MSG_V("SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n");
else
- MSG_V("SwScaler: using C scaler for horizontal scaling\n");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using C scaler for horizontal scaling\n");
#endif
}
if(isPlanarYUV(dstFormat))
{
if(c->vLumFilterSize==1)
- MSG_V("SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
- MSG_V("SwScaler: using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
else
{
if(c->vLumFilterSize==1 && c->vChrFilterSize==2)
- MSG_V("SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n"
"SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n",(flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(c->vLumFilterSize==2 && c->vChrFilterSize==2)
- MSG_V("SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else
- MSG_V("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
}
if(dstFormat==PIX_FMT_BGR24)
- MSG_V("SwScaler: using %s YV12->BGR24 Converter\n",
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR24 Converter\n",
(flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
else if(dstFormat==PIX_FMT_RGB32)
- MSG_V("SwScaler: using %s YV12->BGR32 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR32 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(dstFormat==PIX_FMT_BGR565)
- MSG_V("SwScaler: using %s YV12->BGR16 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR16 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
else if(dstFormat==PIX_FMT_BGR555)
- MSG_V("SwScaler: using %s YV12->BGR15 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: using %s YV12->BGR15 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
- MSG_V("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
+ av_log(c, AV_LOG_VERBOSE, "SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
}
if(flags & SWS_PRINT_INFO)
{
- MSG_DBG2("SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
+ av_log(c, AV_LOG_DEBUG, "SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
- MSG_DBG2("SwScaler:Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
+ av_log(c, AV_LOG_DEBUG, "SwScaler:Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
}
@@ -2420,10 +2429,10 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
* swscale warper, so we don't need to export the SwsContext.
* assumes planar YUV to be in YUV order instead of YVU
*/
-int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
- MSG_ERR("swScaler: slices start in the middle!\n");
+ av_log(c, AV_LOG_ERROR, "swScaler: slices start in the middle!\n");
return 0;
}
if (c->sliceDir == 0) {
@@ -2432,21 +2441,22 @@ int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
// copy strides, so they can safely be modified
if (c->sliceDir == 1) {
+ uint8_t* src2[4]= {src[0], src[1], src[2]};
// slices go from top to bottom
- int srcStride2[3]= {srcStride[0], srcStride[1], srcStride[2]};
- int dstStride2[3]= {dstStride[0], dstStride[1], dstStride[2]};
- return c->swScale(c, src, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);
+ int srcStride2[4]= {srcStride[0], srcStride[1], srcStride[2]};
+ int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2]};
+ return c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);
} else {
// slices go from bottom to top => we flip the image internally
- uint8_t* src2[3]= {src[0] + (srcSliceH-1)*srcStride[0],
+ uint8_t* src2[4]= {src[0] + (srcSliceH-1)*srcStride[0],
src[1] + ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1],
src[2] + ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2]
};
- uint8_t* dst2[3]= {dst[0] + (c->dstH-1)*dstStride[0],
+ uint8_t* dst2[4]= {dst[0] + (c->dstH-1)*dstStride[0],
dst[1] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1],
dst[2] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2]};
- int srcStride2[3]= {-srcStride[0], -srcStride[1], -srcStride[2]};
- int dstStride2[3]= {-dstStride[0], -dstStride[1], -dstStride[2]};
+ int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2]};
+ int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2]};
return c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2);
}
@@ -2455,15 +2465,9 @@ int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSli
/**
* swscale warper, so we don't need to export the SwsContext
*/
-int sws_scale(SwsContext *c, uint8_t* srcParam[], int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t* dstParam[], int dstStride[]){
- uint8_t *src[3];
- uint8_t *dst[3];
- src[0] = srcParam[0]; src[1] = srcParam[1]; src[2] = srcParam[2];
- dst[0] = dstParam[0]; dst[1] = dstParam[1]; dst[2] = dstParam[2];
-//printf("sws: slice %d %d\n", srcSliceY, srcSliceH);
-
- return c->swScale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
+int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+ int srcSliceH, uint8_t* dst[], int dstStride[]){
+ return sws_scale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
}
SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
@@ -2727,9 +2731,9 @@ void sws_printVec(SwsVector *a){
for(i=0; i<a->length; i++)
{
int x= (int)((a->coeff[i]-min)*60.0/range +0.5);
- MSG_DBG2("%1.3f ", a->coeff[i]);
- for(;x>0; x--) MSG_DBG2(" ");
- MSG_DBG2("|\n");
+ av_log(NULL, AV_LOG_DEBUG, "%1.3f ", a->coeff[i]);
+ for(;x>0; x--) av_log(NULL, AV_LOG_DEBUG, " ");
+ av_log(NULL, AV_LOG_DEBUG, "|\n");
}
}
@@ -2802,7 +2806,7 @@ void sws_freeContext(SwsContext *c){
av_free(c->hChrFilterPos);
c->hChrFilterPos = NULL;
-#if defined(ARCH_X86)
+#if defined(ARCH_X86) && defined(CONFIG_GPL)
#ifdef MAP_ANONYMOUS
if(c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
if(c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
diff --git a/contrib/ffmpeg/libswscale/swscale.h b/contrib/ffmpeg/libswscale/swscale.h
index 06088b8e4..27d1aa3ef 100644
--- a/contrib/ffmpeg/libswscale/swscale.h
+++ b/contrib/ffmpeg/libswscale/swscale.h
@@ -27,6 +27,8 @@
* external api for the swscale stuff
*/
+#include "avutil.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -109,7 +111,7 @@ struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, i
int sws_scale(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]);
int sws_scale_ordered(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t* dst[], int dstStride[]);
+ int srcSliceH, uint8_t* dst[], int dstStride[]) attribute_deprecated;
int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation);
diff --git a/contrib/ffmpeg/libswscale/swscale_altivec_template.c b/contrib/ffmpeg/libswscale/swscale_altivec_template.c
index d65c28538..251b38ca1 100644
--- a/contrib/ffmpeg/libswscale/swscale_altivec_template.c
+++ b/contrib/ffmpeg/libswscale/swscale_altivec_template.c
@@ -226,7 +226,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int
for(j=0; j<filterSize; j++) {
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
- dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1);
+ dst[i] = av_clip(val>>7, 0, (1<<15)-1);
}
}
else
@@ -265,7 +265,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int
val_vEven = vec_mule(src_v, filter_v);
val_s = vec_sums(val_vEven, vzero);
vec_st(val_s, 0, tempo);
- dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1);
+ dst[i] = av_clip(tempo[3]>>7, 0, (1<<15)-1);
}
}
break;
@@ -292,7 +292,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int
val_v = vec_msums(src_v, filter_v, (vector signed int)vzero);
val_s = vec_sums(val_v, vzero);
vec_st(val_s, 0, tempo);
- dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1);
+ dst[i] = av_clip(tempo[3]>>7, 0, (1<<15)-1);
}
}
break;
@@ -321,7 +321,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int
vector signed int val_s = vec_sums(val_v, vzero);
vec_st(val_s, 0, tempo);
- dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1);
+ dst[i] = av_clip(tempo[3]>>7, 0, (1<<15)-1);
}
}
break;
@@ -383,7 +383,7 @@ static inline void hScale_altivec_real(int16_t *dst, int dstW, uint8_t *src, int
val_s = vec_sums(val_v, vzero);
vec_st(val_s, 0, tempo);
- dst[i] = FFMIN(FFMAX(0, tempo[3]>>7), (1<<15)-1);
+ dst[i] = av_clip(tempo[3]>>7, 0, (1<<15)-1);
}
}
diff --git a/contrib/ffmpeg/libswscale/swscale_internal.h b/contrib/ffmpeg/libswscale/swscale_internal.h
index 837b6eaf5..5b62ea065 100644
--- a/contrib/ffmpeg/libswscale/swscale_internal.h
+++ b/contrib/ffmpeg/libswscale/swscale_internal.h
@@ -33,13 +33,6 @@
#define AVV(x...) {x}
#endif
-#define MSG_WARN(args...) av_log(NULL, AV_LOG_DEBUG, ##args )
-#define MSG_FATAL(args...) av_log(NULL, AV_LOG_ERROR, ##args )
-#define MSG_ERR(args...) av_log(NULL, AV_LOG_ERROR, ##args )
-#define MSG_V(args...) av_log(NULL, AV_LOG_INFO, ##args )
-#define MSG_DBG2(args...) av_log(NULL, AV_LOG_DEBUG, ##args )
-#define MSG_INFO(args...) av_log(NULL, AV_LOG_INFO, ##args )
-
#define MAX_FILTER_SIZE 256
typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
@@ -47,6 +40,11 @@ typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride
/* this struct should be aligned on at least 32-byte boundary */
typedef struct SwsContext{
+ /**
+ * info on struct for av_log
+ */
+ AVClass *av_class;
+
/**
*
* Note the src,dst,srcStride,dstStride will be copied, in the sws_scale() warper so they can freely be modified here
@@ -76,7 +74,7 @@ typedef struct SwsContext{
int16_t *vChrFilter;
int16_t *vChrFilterPos;
- uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
+ uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change a lot of code for this to be useful
int hLumFilterSize;
int hChrFilterSize;
@@ -101,10 +99,10 @@ typedef struct SwsContext{
int dstY;
int flags;
void * yuvTable; // pointer to the yuv->rgb table start so it can be freed()
- void * table_rV[256];
- void * table_gU[256];
+ uint8_t * table_rV[256];
+ uint8_t * table_gU[256];
int table_gV[256];
- void * table_bU[256];
+ uint8_t * table_bU[256];
//Colorspace stuff
int contrast, brightness, saturation; // for sws_getColorspaceDetails
@@ -182,11 +180,11 @@ char *sws_format_name(int format);
#define isGray16(x) ((x)==PIX_FMT_GRAY16BE || (x)==PIX_FMT_GRAY16LE)
#define isRGB(x) ((x)==PIX_FMT_BGR32 || (x)==PIX_FMT_RGB24 \
|| (x)==PIX_FMT_RGB565 || (x)==PIX_FMT_RGB555 \
- || (x)==PIX_FMT_RGB8 || (x)==PIX_FMT_RGB4 \
+ || (x)==PIX_FMT_RGB8 || (x)==PIX_FMT_RGB4 || (x)==PIX_FMT_RGB4_BYTE \
|| (x)==PIX_FMT_MONOBLACK)
#define isBGR(x) ((x)==PIX_FMT_RGB32 || (x)==PIX_FMT_BGR24 \
|| (x)==PIX_FMT_BGR565 || (x)==PIX_FMT_BGR555 \
- || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_BGR4 \
+ || (x)==PIX_FMT_BGR8 || (x)==PIX_FMT_BGR4 || (x)==PIX_FMT_BGR4_BYTE \
|| (x)==PIX_FMT_MONOBLACK)
static inline int fmt_depth(int fmt)
diff --git a/contrib/ffmpeg/libswscale/swscale_template.c b/contrib/ffmpeg/libswscale/swscale_template.c
index e725a3bb0..ad46be127 100644
--- a/contrib/ffmpeg/libswscale/swscale_template.c
+++ b/contrib/ffmpeg/libswscale/swscale_template.c
@@ -1730,7 +1730,6 @@ static inline void RENAME(yuy2ToY)(uint8_t *dst, uint8_t *src, long width)
static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
- assert(src1 == src2);
#ifdef HAVE_MMX
asm volatile(
"movq "MANGLE(bm01010101)", %%mm4\n\t"
@@ -1761,6 +1760,7 @@ static inline void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1,
dstV[i]= src1[4*i + 3];
}
#endif
+ assert(src1 == src2);
}
//this is allmost identical to the previous, end exists only cuz yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses
@@ -1790,7 +1790,6 @@ static inline void RENAME(uyvyToY)(uint8_t *dst, uint8_t *src, long width)
static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
- assert(src1 == src2);
#ifdef HAVE_MMX
asm volatile(
"movq "MANGLE(bm01010101)", %%mm4\n\t"
@@ -1821,6 +1820,7 @@ static inline void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1,
dstV[i]= src1[4*i + 2];
}
#endif
+ assert(src1 == src2);
}
static inline void RENAME(bgr32ToY)(uint8_t *dst, uint8_t *src, int width)
@@ -1942,7 +1942,6 @@ static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width)
static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width)
{
- assert(src1 == src2);
#ifdef HAVE_MMX
asm volatile(
"mov %3, %%"REG_a" \n\t"
@@ -2072,6 +2071,7 @@ static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1
dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128;
}
#endif
+ assert(src1 == src2);
}
static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width)
@@ -2279,6 +2279,38 @@ static inline void RENAME(rgb15ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1
}
}
+static inline void RENAME(palToY)(uint8_t *dst, uint8_t *src, int width, uint32_t *pal)
+{
+ int i;
+ for(i=0; i<width; i++)
+ {
+ int d= src[i];
+ int b= pal[d] &0xFF;
+ int g=(pal[d]>>8 )&0xFF;
+ int r= pal[d]>>16;
+
+ dst[i]= ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16;
+ }
+}
+
+static inline void RENAME(palToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width, uint32_t *pal)
+{
+ int i;
+ assert(src1 == src2);
+ for(i=0; i<width; i++)
+ {
+ int d0= src1[2*i ];
+ int d1= src1[2*i+1];
+ int p = (pal[d0]&0xFF00FF) + (pal[d1]&0xFF00FF);
+ int g = (pal[d0]+pal[d1]-p)>>8;
+ int b= p&0x1FF;
+ int r= p>>16;
+
+ dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128;
+ dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128;
+ }
+}
+
// Bilinear / Bicubic scaling
static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc,
int16_t *filter, int16_t *filterPos, long filterSize)
@@ -2456,7 +2488,7 @@ static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW
val += ((int)src[srcPos + j])*filter[filterSize*i + j];
}
// filter += hFilterSize;
- dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1); // the cubic equation does overflow ...
+ dst[i] = av_clip(val>>7, 0, (1<<15)-1); // the cubic equation does overflow ...
// dst[i] = val>>7;
}
#endif
@@ -2467,7 +2499,7 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i
int flags, int canMMX2BeUsed, int16_t *hLumFilter,
int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
- int32_t *mmx2FilterPos)
+ int32_t *mmx2FilterPos, uint8_t *pal)
{
if(srcFormat==PIX_FMT_YUYV422 || srcFormat==PIX_FMT_GRAY16BE)
{
@@ -2519,6 +2551,11 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i
RENAME(rgb15ToY)(formatConvBuffer, src, srcW);
src= formatConvBuffer;
}
+ else if(srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
+ {
+ RENAME(palToY)(formatConvBuffer, src, srcW, pal);
+ src= formatConvBuffer;
+ }
#ifdef HAVE_MMX
// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
@@ -2664,7 +2701,7 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1,
int srcW, int xInc, int flags, int canMMX2BeUsed, int16_t *hChrFilter,
int16_t *hChrFilterPos, int hChrFilterSize, void *funnyUVCode,
int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
- int32_t *mmx2FilterPos)
+ int32_t *mmx2FilterPos, uint8_t *pal)
{
if(srcFormat==PIX_FMT_YUYV422)
{
@@ -2730,6 +2767,12 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1,
{
return;
}
+ else if(srcFormat==PIX_FMT_RGB8 || srcFormat==PIX_FMT_BGR8 || srcFormat==PIX_FMT_PAL8 || srcFormat==PIX_FMT_BGR4_BYTE || srcFormat==PIX_FMT_RGB4_BYTE)
+ {
+ RENAME(palToUV)(formatConvBuffer, formatConvBuffer+2048, src1, src2, srcW, pal);
+ src1= formatConvBuffer;
+ src2= formatConvBuffer+2048;
+ }
#ifdef HAVE_MMX
// use the new MMX scaler if the mmx2 can't be used (its faster than the x86asm one)
@@ -2932,6 +2975,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;
const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);
int lastDstY;
+ uint8_t *pal=NULL;
/* vars whch will change and which we need to storw back in the context */
int dstY= c->dstY;
@@ -2941,6 +2985,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
int lastInChrBuf= c->lastInChrBuf;
if(isPacked(c->srcFormat)){
+ pal= src[1];
src[0]=
src[1]=
src[2]= src[0];
@@ -2972,7 +3017,7 @@ i--;
static int firstTime=1; //FIXME move this into the context perhaps
if(flags & SWS_PRINT_INFO && firstTime)
{
- MSG_WARN("SwScaler: Warning: dstStride is not aligned!\n"
+ av_log(c, AV_LOG_WARNING, "SwScaler: Warning: dstStride is not aligned!\n"
"SwScaler: ->cannot do aligned memory acesses anymore\n");
firstTime=0;
}
@@ -3026,7 +3071,7 @@ i--;
RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
funnyYCode, c->srcFormat, formatConvBuffer,
- c->lumMmx2Filter, c->lumMmx2FilterPos);
+ c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
lastInLumBuf++;
}
while(lastInChrBuf < lastChrSrcY)
@@ -3043,7 +3088,7 @@ i--;
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
funnyUVCode, c->srcFormat, formatConvBuffer,
- c->chrMmx2Filter, c->chrMmx2FilterPos);
+ c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
lastInChrBuf++;
}
//wrap buf index around to stay inside the ring buffer
@@ -3068,7 +3113,7 @@ i--;
RENAME(hyscale)(lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
funnyYCode, c->srcFormat, formatConvBuffer,
- c->lumMmx2Filter, c->lumMmx2FilterPos);
+ c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
lastInLumBuf++;
}
while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
@@ -3084,7 +3129,7 @@ i--;
RENAME(hcscale)(chrPixBuf[ chrBufIndex ], chrDstW, src1, src2, chrSrcW, chrXInc,
flags, canMMX2BeUsed, hChrFilter, hChrFilterPos, hChrFilterSize,
funnyUVCode, c->srcFormat, formatConvBuffer,
- c->chrMmx2Filter, c->chrMmx2FilterPos);
+ c->chrMmx2Filter, c->chrMmx2FilterPos, pal);
lastInChrBuf++;
}
//wrap buf index around to stay inside the ring buffer
@@ -3107,15 +3152,15 @@ i--;
int i;
if(flags & SWS_ACCURATE_RND){
for(i=0; i<vLumFilterSize; i+=2){
- lumMmxFilter[2*i+0]= lumSrcPtr[i ];
- lumMmxFilter[2*i+1]= lumSrcPtr[i+(vLumFilterSize>1)];
+ lumMmxFilter[2*i+0]= (int32_t)lumSrcPtr[i ];
+ lumMmxFilter[2*i+1]= (int32_t)lumSrcPtr[i+(vLumFilterSize>1)];
lumMmxFilter[2*i+2]=
lumMmxFilter[2*i+3]= vLumFilter[dstY*vLumFilterSize + i ]
+ (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
}
for(i=0; i<vChrFilterSize; i+=2){
- chrMmxFilter[2*i+0]= chrSrcPtr[i ];
- chrMmxFilter[2*i+1]= chrSrcPtr[i+(vChrFilterSize>1)];
+ chrMmxFilter[2*i+0]= (int32_t)chrSrcPtr[i ];
+ chrMmxFilter[2*i+1]= (int32_t)chrSrcPtr[i+(vChrFilterSize>1)];
chrMmxFilter[2*i+2]=
chrMmxFilter[2*i+3]= vChrFilter[chrDstY*vChrFilterSize + i ]
+ (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
@@ -3124,6 +3169,7 @@ i--;
for(i=0; i<vLumFilterSize; i++)
{
lumMmxFilter[4*i+0]= (int32_t)lumSrcPtr[i];
+ lumMmxFilter[4*i+1]= (uint64_t)lumSrcPtr[i] >> 32;
lumMmxFilter[4*i+2]=
lumMmxFilter[4*i+3]=
((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
@@ -3131,6 +3177,7 @@ i--;
for(i=0; i<vChrFilterSize; i++)
{
chrMmxFilter[4*i+0]= (int32_t)chrSrcPtr[i];
+ chrMmxFilter[4*i+1]= (uint64_t)chrSrcPtr[i] >> 32;
chrMmxFilter[4*i+2]=
chrMmxFilter[4*i+3]=
((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001;
diff --git a/contrib/ffmpeg/libswscale/yuv2rgb.c b/contrib/ffmpeg/libswscale/yuv2rgb.c
index 9066b68b2..af7f86f40 100644
--- a/contrib/ffmpeg/libswscale/yuv2rgb.c
+++ b/contrib/ffmpeg/libswscale/yuv2rgb.c
@@ -22,8 +22,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with mpeg2dec; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* MMX/MMX2 Template stuff from Michael Niedermayer (michaelni@gmx.at) (needed for fast movntq support)
* 1,4,8bpp support by Michael Niedermayer (michaelni@gmx.at)
@@ -213,9 +213,9 @@ const int32_t Inverse_Table_6_9[8][4] = {
#define RGB(i) \
U = pu[i]; \
V = pv[i]; \
- r = c->table_rV[V]; \
- g = c->table_gU[U] + c->table_gV[V]; \
- b = c->table_bU[U];
+ r = (void *)c->table_rV[V]; \
+ g = (void *)(c->table_gU[U] + c->table_gV[V]); \
+ b = (void *)c->table_bU[U];
#define DST1(i) \
Y = py_1[2*i]; \
@@ -265,14 +265,16 @@ static int func_name(SwsContext *c, uint8_t* src[], int srcStride[], int srcSlic
for(y=0; y<srcSliceH; y+=2){\
dst_type *dst_1= (dst_type*)(dst[0] + (y+srcSliceY )*dstStride[0]);\
dst_type *dst_2= (dst_type*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);\
- dst_type *r, *g, *b;\
+ dst_type attribute_unused *r, *b;\
+ dst_type *g;\
uint8_t *py_1= src[0] + y*srcStride[0];\
uint8_t *py_2= py_1 + srcStride[0];\
uint8_t *pu= src[1] + (y>>1)*srcStride[1];\
uint8_t *pv= src[2] + (y>>1)*srcStride[2];\
unsigned int h_size= c->dstW>>3;\
while (h_size--) {\
- int U, V, Y;\
+ int attribute_unused U, V;\
+ int Y;\
#define EPILOG(dst_delta)\
pu += 4;\
@@ -609,7 +611,7 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c)
}
#endif
- MSG_WARN("No accelerated colorspace conversion found\n");
+ av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found\n");
switch(c->dstFormat){
case PIX_FMT_BGR32:
@@ -668,6 +670,11 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
if(!fullRange){
cy= (cy*255) / 219;
oy= 16<<16;
+ }else{
+ crv= (crv*224) / 255;
+ cbu= (cbu*224) / 255;
+ cgu= (cgu*224) / 255;
+ cgv= (cgv*224) / 255;
}
cy = (cy *contrast )>>16;
@@ -826,16 +833,16 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange,
default:
table_start= NULL;
- MSG_ERR("%ibpp not supported by yuv2rgb\n", bpp);
+ av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
//free mem?
return -1;
}
for (i = 0; i < 256; i++) {
- c->table_rV[i] = table_r + entry_size * div_round (crv * (i-128), 76309);
- c->table_gU[i] = table_g + entry_size * div_round (cgu * (i-128), 76309);
+ c->table_rV[i] = (uint8_t *)table_r + entry_size * div_round (crv * (i-128), 76309);
+ c->table_gU[i] = (uint8_t *)table_g + entry_size * div_round (cgu * (i-128), 76309);
c->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
- c->table_bU[i] = table_b + entry_size * div_round (cbu * (i-128), 76309);
+ c->table_bU[i] = (uint8_t *)table_b + entry_size * div_round (cbu * (i-128), 76309);
}
av_free(c->yuvTable);
diff --git a/contrib/ffmpeg/libswscale/yuv2rgb_altivec.c b/contrib/ffmpeg/libswscale/yuv2rgb_altivec.c
index ca0680a49..72e418e8d 100644
--- a/contrib/ffmpeg/libswscale/yuv2rgb_altivec.c
+++ b/contrib/ffmpeg/libswscale/yuv2rgb_altivec.c
@@ -710,22 +710,22 @@ SwsFunc yuv2rgb_init_altivec (SwsContext *c)
switch(c->dstFormat){
case PIX_FMT_RGB24:
- MSG_WARN("ALTIVEC: Color Space RGB24\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGB24\n");
return altivec_yuv2_rgb24;
case PIX_FMT_BGR24:
- MSG_WARN("ALTIVEC: Color Space BGR24\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGR24\n");
return altivec_yuv2_bgr24;
case PIX_FMT_ARGB:
- MSG_WARN("ALTIVEC: Color Space ARGB\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ARGB\n");
return altivec_yuv2_argb;
case PIX_FMT_ABGR:
- MSG_WARN("ALTIVEC: Color Space ABGR\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space ABGR\n");
return altivec_yuv2_abgr;
case PIX_FMT_RGBA:
- MSG_WARN("ALTIVEC: Color Space RGBA\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space RGBA\n");
return altivec_yuv2_rgba;
case PIX_FMT_BGRA:
- MSG_WARN("ALTIVEC: Color Space BGRA\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space BGRA\n");
return altivec_yuv2_bgra;
default: return NULL;
}
@@ -734,7 +734,7 @@ SwsFunc yuv2rgb_init_altivec (SwsContext *c)
case PIX_FMT_UYVY422:
switch(c->dstFormat){
case PIX_FMT_BGR32:
- MSG_WARN("ALTIVEC: Color Space UYVY -> RGB32\n");
+ av_log(c, AV_LOG_WARNING, "ALTIVEC: Color Space UYVY -> RGB32\n");
return altivec_uyvy_rgb32;
default: return NULL;
}
@@ -877,7 +877,7 @@ altivec_yuv2packedX (SwsContext *c,
instead. */
static int printed_error_message;
if(!printed_error_message) {
- MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
+ av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n",
sws_format_name(c->dstFormat));
printed_error_message=1;
}
@@ -952,7 +952,7 @@ altivec_yuv2packedX (SwsContext *c,
case PIX_FMT_BGR24: out_bgr24 (R,G,B,nout); break;
default:
/* Unreachable, I think. */
- MSG_ERR("altivec_yuv2packedX doesn't support %s output\n",
+ av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n",
sws_format_name(c->dstFormat));
return;
}
diff --git a/contrib/ffmpeg/libswscale/yuv2rgb_init.c b/contrib/ffmpeg/libswscale/yuv2rgb_init.c
new file mode 100644
index 000000000..371dce5da
--- /dev/null
+++ b/contrib/ffmpeg/libswscale/yuv2rgb_init.c
@@ -0,0 +1,412 @@
+#include "avutil.h"
+#include "swscale.h"
+#include "swscale_internal.h"
+
+#define YTABLE_MIN 384
+
+/**
+ * YUV -> RGB conversion matrixes (inverse of table 6.9 in MPEG2 standard)
+ *
+ * An YUV -> RGB conversion matrix is in the form
+ * | 1 0 Rv |
+ * | 1 Gu Gv |
+ * | 1 Bu 0 |
+ *
+ * Inverse_Table_6_9 stores | Rv Bu Gv Gu | * 255/224*2^16.
+ * \arg Maximum Rv value: 117570
+ * \arg Maximum Bu value: 138420
+ * \arg Maximum Gv + Gu value: 25642 + 53281 = 78923
+ *
+ * These values are needed to allocate table_{r, g, b}. If you modify
+ * this table, please update allocate_tables() accordingly
+ */
+const int32_t Inverse_Table_6_9[8][4] = {
+ {0, 0, 0, 0}, /* no sequence_display_extension */
+ {117500, 138420, -13985, -34933}, /* ITU-R Rec. 709 (1990) */
+ {0, 0, 0, 0}, /* unspecified */
+ {0, 0, 0, 0}, /* reserved */
+ {104480, 132820, -24811, -53150}, /* FCC */
+ {104570, 132210, -25642, -53281}, /* ITU-R Rec. 624-4 System B, G */
+ {104570, 132210, -25642, -53281}, /* SMPTE 170M */
+ {117570, 136230, -16892, -35552} /* SMPTE 240M (1987) */
+};
+
+
+/**
+ * Dithering matrixes (these are bayer ordered dither matrixes
+ * with some manual changes by Michael)
+ */
+const uint8_t __attribute__((aligned(8))) dither_2x2_4[2][8]={
+{ 1, 3, 1, 3, 1, 3, 1, 3, },
+{ 2, 0, 2, 0, 2, 0, 2, 0, },
+};
+
+const uint8_t __attribute__((aligned(8))) dither_2x2_8[2][8]={
+{ 6, 2, 6, 2, 6, 2, 6, 2, },
+{ 0, 4, 0, 4, 0, 4, 0, 4, },
+};
+
+const uint8_t __attribute__((aligned(8))) dither_8x8_32[8][8]={
+{ 17, 9, 23, 15, 16, 8, 22, 14, },
+{ 5, 29, 3, 27, 4, 28, 2, 26, },
+{ 21, 13, 19, 11, 20, 12, 18, 10, },
+{ 0, 24, 6, 30, 1, 25, 7, 31, },
+{ 16, 8, 22, 14, 17, 9, 23, 15, },
+{ 4, 28, 2, 26, 5, 29, 3, 27, },
+{ 20, 12, 18, 10, 21, 13, 19, 11, },
+{ 1, 25, 7, 31, 0, 24, 6, 30, },
+};
+
+#if 0
+const uint8_t __attribute__((aligned(8))) dither_8x8_64[8][8]={
+{ 0, 48, 12, 60, 3, 51, 15, 63, },
+{ 32, 16, 44, 28, 35, 19, 47, 31, },
+{ 8, 56, 4, 52, 11, 59, 7, 55, },
+{ 40, 24, 36, 20, 43, 27, 39, 23, },
+{ 2, 50, 14, 62, 1, 49, 13, 61, },
+{ 34, 18, 46, 30, 33, 17, 45, 29, },
+{ 10, 58, 6, 54, 9, 57, 5, 53, },
+{ 42, 26, 38, 22, 41, 25, 37, 21, },
+};
+#endif
+
+const uint8_t __attribute__((aligned(8))) dither_8x8_73[8][8]={
+{ 0, 55, 14, 68, 3, 58, 17, 72, },
+{ 37, 18, 50, 32, 40, 22, 54, 35, },
+{ 9, 64, 5, 59, 13, 67, 8, 63, },
+{ 46, 27, 41, 23, 49, 31, 44, 26, },
+{ 2, 57, 16, 71, 1, 56, 15, 70, },
+{ 39, 21, 52, 34, 38, 19, 51, 33, },
+{ 11, 66, 7, 62, 10, 65, 6, 60, },
+{ 48, 30, 43, 25, 47, 29, 42, 24, },
+};
+
+#if 0
+const uint8_t __attribute__((aligned(8))) dither_8x8_128[8][8]={
+{ 68, 36, 92, 60, 66, 34, 90, 58, },
+{ 20, 116, 12, 108, 18, 114, 10, 106, },
+{ 84, 52, 76, 44, 82, 50, 74, 42, },
+{ 0, 96, 24, 120, 6, 102, 30, 126, },
+{ 64, 32, 88, 56, 70, 38, 94, 62, },
+{ 16, 112, 8, 104, 22, 118, 14, 110, },
+{ 80, 48, 72, 40, 86, 54, 78, 46, },
+{ 4, 100, 28, 124, 2, 98, 26, 122, },
+};
+#endif
+
+#if 1
+const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={
+{117, 62, 158, 103, 113, 58, 155, 100, },
+{ 34, 199, 21, 186, 31, 196, 17, 182, },
+{144, 89, 131, 76, 141, 86, 127, 72, },
+{ 0, 165, 41, 206, 10, 175, 52, 217, },
+{110, 55, 151, 96, 120, 65, 162, 107, },
+{ 28, 193, 14, 179, 38, 203, 24, 189, },
+{138, 83, 124, 69, 148, 93, 134, 79, },
+{ 7, 172, 48, 213, 3, 168, 45, 210, },
+};
+#elif 1
+// tries to correct a gamma of 1.5
+const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={
+{ 0, 143, 18, 200, 2, 156, 25, 215, },
+{ 78, 28, 125, 64, 89, 36, 138, 74, },
+{ 10, 180, 3, 161, 16, 195, 8, 175, },
+{109, 51, 93, 38, 121, 60, 105, 47, },
+{ 1, 152, 23, 210, 0, 147, 20, 205, },
+{ 85, 33, 134, 71, 81, 30, 130, 67, },
+{ 14, 190, 6, 171, 12, 185, 5, 166, },
+{117, 57, 101, 44, 113, 54, 97, 41, },
+};
+#elif 1
+// tries to correct a gamma of 2.0
+const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={
+{ 0, 124, 8, 193, 0, 140, 12, 213, },
+{ 55, 14, 104, 42, 66, 19, 119, 52, },
+{ 3, 168, 1, 145, 6, 187, 3, 162, },
+{ 86, 31, 70, 21, 99, 39, 82, 28, },
+{ 0, 134, 11, 206, 0, 129, 9, 200, },
+{ 62, 17, 114, 48, 58, 16, 109, 45, },
+{ 5, 181, 2, 157, 4, 175, 1, 151, },
+{ 95, 36, 78, 26, 90, 34, 74, 24, },
+};
+#else
+// tries to correct a gamma of 2.5
+const uint8_t __attribute__((aligned(8))) dither_8x8_220[8][8]={
+{ 0, 107, 3, 187, 0, 125, 6, 212, },
+{ 39, 7, 86, 28, 49, 11, 102, 36, },
+{ 1, 158, 0, 131, 3, 180, 1, 151, },
+{ 68, 19, 52, 12, 81, 25, 64, 17, },
+{ 0, 119, 5, 203, 0, 113, 4, 195, },
+{ 45, 9, 96, 33, 42, 8, 91, 30, },
+{ 2, 172, 1, 144, 2, 165, 0, 137, },
+{ 77, 23, 60, 15, 72, 21, 56, 14, },
+};
+#endif
+
+static int get_entry_size(int bpp)
+{
+ switch(bpp) {
+ case 32:
+ return 4;
+ case 16:
+ case 15:
+ return 2;
+ case 24:
+ case 8:
+ case 4:
+ case 1:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+/**
+ * Allocate table_r, table_g, and table_b
+ *
+ * For cache efficency reasons, these three tables are allocated
+ * together, so that they are contiguous in memory
+ *
+ * table_r is indexed in the range
+ * [-128 * 117570 / 76309, 255 + 127 * 117570 / 76309] =
+ * [-197.21, 451.67] ---> [-198, 452]
+ * table_b is indexed in the range
+ * [-128 * 138420 / 76309, 255 + 127 * 138420 / 76309] =
+ * [232.18, 485.37] ---> [-233, 486]
+ * table_g is indexed in the range
+ * [-128 * 78923 / 76309, 255 + 127 * 78923 / 76309] =
+ * [-132.38, 386.35] ---> [-133, 387]
+ *
+ * Please look at the comments after Inverse_Table_6_9 to see where these
+ * numbers are coming from.
+ */
+static void *allocate_tables(uint8_t **table_r, uint8_t **table_g, uint8_t **table_b, int bpp)
+{
+ uint8_t *table;
+ int entry_size;
+
+ entry_size = get_entry_size(bpp);
+
+ /* First allocate the memory... */
+ switch (bpp) {
+ case 32:
+ case 15:
+ case 16:
+ case 8:
+ case 4:
+ table = av_malloc((198 + 452 + 233 + 486 + 133 + 387) * entry_size);
+ break;
+ case 24:
+ table = av_malloc(256 + 2 * 233);
+ break;
+ case 1:
+ table = av_malloc (256 * 2);
+ break;
+ default:
+ table = NULL;
+ }
+ if (table == NULL) {
+ MSG_ERR("Cannot allocate memory for the YUV -> RGB tables!\n");
+
+ return NULL;
+ }
+
+ /* ...and then, assign the table_* value */
+ switch (bpp) {
+ case 32:
+ case 15:
+ case 16:
+ case 8:
+ case 4:
+ *table_r = table + 198 * entry_size;
+ *table_b = table + (198 + 452 + 133 + 387 + 233) * entry_size;
+ *table_g = table + (198 + 452 + 133) * entry_size;
+ break;
+ case 24:
+ *table_r = *table_g = *table_b = table + 233;
+ break;
+ case 1:
+ *table_g = table;
+ *table_r = *table_b = NULL;
+ break;
+ }
+
+ return table;
+}
+
+/**
+ * Initialize the table_rV, table_gU[i], table_gV, and table_bU fields
+ * in SwsContext
+ *
+ * @param inv_table the YUV -> RGB table (this is a line of Inverse_Table_6_9)
+ * @param fullRange 0->MPEG YUV space 1->JPEG YUV space
+*/
+int yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
+{
+ int i;
+ static uint8_t ytable[1024];
+ int64_t cy, oy;
+ int64_t crv, cbu, cgu, cgv;
+ int entry_size = 0;
+ uint8_t *table_r, *table_g, *table_b;
+ int value;
+
+ if ((inv_table[0] == 0) || (inv_table[1] == 0) || (inv_table[2] == 0) || (inv_table[3] == 0)) {
+ MSG_ERR("Invalid YUV ---> RGB table!\n");
+
+ return -1;
+ }
+ crv = inv_table[0];
+ cbu = inv_table[1];
+ cgu = inv_table[2];
+ cgv = inv_table[3];
+ if (fullRange) {
+ cy = 1 << 16;
+ oy = 0;
+ crv= (crv*224) / 255;
+ cbu= (cbu*224) / 255;
+ cgu= (cgu*224) / 255;
+ cgv= (cgv*224) / 255;
+ //FIXME maybe its cleaner if the tables where based on full range (*244/255)
+ } else {
+ cy = ((1 << 16) * 255) / 219;
+ oy= 16 << 16;
+ }
+
+ cy = (cy *contrast )>>16;
+ crv= (crv*contrast * saturation)>>32;
+ cbu= (cbu*contrast * saturation)>>32;
+ cgu= (cgu*contrast * saturation)>>32;
+ cgv= (cgv*contrast * saturation)>>32;
+ oy -= 256*brightness;
+
+ for (i = 0; i < 1024; i++) {
+ value = (cy*(((i - YTABLE_MIN)<<16) - oy) + (1<<31))>>32;
+ ytable[i] = av_clip_uint8(value);
+ }
+
+ entry_size = get_entry_size(fmt_depth(c->dstFormat));
+ av_free(c->yuvTable);
+ c->yuvTable = allocate_tables(&table_r, &table_g, &table_b, fmt_depth(c->dstFormat));
+ if (c->yuvTable == NULL) {
+ return -1;
+ }
+
+ switch (fmt_depth(c->dstFormat)) {
+ case 32:
+ for (i = -198; i < 256 + 197; i++) {
+ value = ytable[i + YTABLE_MIN];
+ if (isBGR(c->dstFormat)) {
+ value <<= 16;
+ }
+ ((uint32_t *)table_r)[i] = value;
+ }
+ for (i = -133; i < 256 + 132; i++) {
+ ((uint32_t *)table_g)[i] = ytable[i + YTABLE_MIN] << 8;
+ }
+ for (i = -233; i < 256 + 232; i++) {
+ value = ytable[i + YTABLE_MIN];
+ if (!isBGR(c->dstFormat)) {
+ value <<= 16;
+ }
+ ((uint32_t *)table_b)[i] = value;
+ }
+ break;
+
+ case 24:
+ for (i = -233; i < 256 + 232; i++) {
+ ((uint8_t * )table_b)[i] = ytable[i + YTABLE_MIN];
+ }
+ break;
+
+ case 15:
+ case 16:
+ for (i = -198; i < 256 + 197; i++) {
+ value = ytable[i + YTABLE_MIN] >> 3;
+ if (isBGR(c->dstFormat)) {
+ value <<= ((fmt_depth(c->dstFormat) == 16) ? 11 : 10);
+ }
+ ((uint16_t *)table_r)[i] = value;
+ }
+ for (i = -133; i < 256 + 132; i++) {
+ value = ytable[i + YTABLE_MIN];
+ value >>= ((fmt_depth(c->dstFormat) == 16) ? 2 : 3);
+ ((uint16_t *)table_g)[i] = value << 5;
+ }
+ for (i = -233; i < 256 + 232; i++) {
+ value = ytable[i + YTABLE_MIN] >> 3;
+ if (!isBGR(c->dstFormat)) {
+ value <<= ((fmt_depth(c->dstFormat) == 16) ? 11 : 10);
+ }
+ ((uint16_t *)table_b)[i] = value;
+ }
+ break;
+ case 8:
+ for (i = -198; i < 256 + 197; i++) {
+ value = (ytable[i + YTABLE_MIN - 16] + 18) / 36;
+ if (isBGR(c->dstFormat)) {
+ value <<= 5;
+ }
+ ((uint8_t *)table_r)[i] = value;
+ }
+ for (i = -133; i < 256 + 132; i++) {
+ value = (ytable[i + YTABLE_MIN - 16] + 18) / 36;
+ if (!isBGR(c->dstFormat)) {
+ value <<= 1;
+ }
+ ((uint8_t *)table_g)[i] = value << 2;
+ }
+ for (i = -233; i < 256 + 232; i++) {
+ value = (ytable[i + YTABLE_MIN - 37] + 43) / 85;
+ if (!isBGR(c->dstFormat)) {
+ value <<= 6;
+ }
+ ((uint8_t *)table_b)[i] = value;
+ }
+ break;
+ case 4:
+ for (i = -198; i < 256 + 197; i++) {
+ value = ytable[i + YTABLE_MIN - 110] >> 7;
+ if (isBGR(c->dstFormat)) {
+ value <<= 3;
+ }
+ ((uint8_t *)table_r)[i] = value;
+ }
+ for (i = -133; i < 256 + 132; i++) {
+ value = (ytable[i + YTABLE_MIN - 37]+ 43) / 85;
+ ((uint8_t *)table_g)[i] = value << 1;
+ }
+ for (i = -233; i < 256 + 232; i++) {
+ value = ytable[i + YTABLE_MIN - 110] >> 7;
+ if (!isBGR(c->dstFormat)) {
+ value <<= 3;
+ }
+ ((uint8_t *)table_b)[i] = value;
+ }
+ break;
+ case 1:
+ for (i = 0; i < 256 + 256; i++) {
+ value = ytable[i + YTABLE_MIN - 110] >> 7;
+ ((uint8_t *)table_g)[i] = value;
+ }
+ break;
+ default:
+ MSG_ERR("%ibpp not supported by yuv2rgb\n", fmt_depth(c->dstFormat));
+ av_free(c->yuvTable);
+ c->yuvTable = NULL;
+
+ return -1;
+ }
+
+ for (i = 0; i < 256; i++) {
+ c->table_rV[i] = table_r +
+ entry_size * ROUNDED_DIV(crv * (i - 128), 76309);
+ c->table_gU[i] = table_g +
+ entry_size * ROUNDED_DIV(cgu * (i - 128), 76309);
+ c->table_gV[i] = entry_size * ROUNDED_DIV(cgv * (i - 128), 76309);
+ c->table_bU[i] = table_b +
+ entry_size * ROUNDED_DIV(cbu * (i - 128), 76309);
+ }
+
+ return 0;
+}
diff --git a/contrib/ffmpeg/libswscale/yuv2rgb_mlib.c b/contrib/ffmpeg/libswscale/yuv2rgb_mlib.c
index 824ee39d1..c99e019cd 100644
--- a/contrib/ffmpeg/libswscale/yuv2rgb_mlib.c
+++ b/contrib/ffmpeg/libswscale/yuv2rgb_mlib.c
@@ -17,9 +17,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
+ * along with mpeg2dec; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <mlib_types.h>
diff --git a/contrib/ffmpeg/libswscale/yuv2rgb_template.c b/contrib/ffmpeg/libswscale/yuv2rgb_template.c
index fd222350e..28ee24add 100644
--- a/contrib/ffmpeg/libswscale/yuv2rgb_template.c
+++ b/contrib/ffmpeg/libswscale/yuv2rgb_template.c
@@ -20,8 +20,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with mpeg2dec; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* 15,24 bpp and dithering from Michael Niedermayer (michaelni@gmx.at)
* MMX/MMX2 Template stuff from Michael Niedermayer (needed for fast movntq support)
@@ -133,7 +133,7 @@ static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStr
}
h_size= (c->dstW+7)&~7;
- if(h_size*2 > dstStride[0]) h_size-=8;
+ if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
//printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&b5Dither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
@@ -228,7 +228,7 @@ static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStr
}
h_size= (c->dstW+7)&~7;
- if(h_size*2 > dstStride[0]) h_size-=8;
+ if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
//printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&b5Dither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
@@ -317,7 +317,7 @@ static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStr
}
h_size= (c->dstW+7)&~7;
- if(h_size*3 > dstStride[0]) h_size-=8;
+ if(h_size*3 > FFABS(dstStride[0])) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
@@ -463,7 +463,7 @@ static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStr
}
h_size= (c->dstW+7)&~7;
- if(h_size*4 > dstStride[0]) h_size-=8;
+ if(h_size*4 > FFABS(dstStride[0])) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ );
diff --git a/contrib/ffmpeg/output_example.c b/contrib/ffmpeg/output_example.c
index 7f75b76f2..ca12b783f 100644
--- a/contrib/ffmpeg/output_example.c
+++ b/contrib/ffmpeg/output_example.c
@@ -28,7 +28,7 @@
#include <math.h>
#ifndef M_PI
-#define M_PI 3.1415926535897931
+#define M_PI 3.14159265358979323846
#endif
#include "avformat.h"
@@ -220,7 +220,7 @@ static AVStream *add_video_stream(AVFormatContext *oc, int codec_id)
motion of the chroma plane doesnt match the luma plane */
c->mb_decision=2;
}
- // some formats want stream headers to be seperate
+ // some formats want stream headers to be separate
if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name, "mov") || !strcmp(oc->oformat->name, "3gp"))
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
diff --git a/contrib/ffmpeg/pktdumper.c b/contrib/ffmpeg/pktdumper.c
index 3535fd03f..d43f46b45 100644
--- a/contrib/ffmpeg/pktdumper.c
+++ b/contrib/ffmpeg/pktdumper.c
@@ -1,3 +1,23 @@
+/*
+ * Copyright (c) 2005 Francois Revol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#include <avformat.h>
#include <limits.h>
#include <fcntl.h>
diff --git a/contrib/ffmpeg/qt-faststart.c b/contrib/ffmpeg/qt-faststart.c
index f9de43514..2cbf12b1d 100644
--- a/contrib/ffmpeg/qt-faststart.c
+++ b/contrib/ffmpeg/qt-faststart.c
@@ -8,7 +8,7 @@
* is in front of the data, thus facilitating network streaming.
*
* Compile this program using:
- * cc qt-faststart.c -o qt-faststart
+ * make qt-faststart
* Invoke the program with:
* qt-faststart <infile.mov> <outfile.mov>
*
diff --git a/contrib/ffmpeg/tests/Makefile b/contrib/ffmpeg/tests/Makefile
index c4c6925f8..3417c687e 100644
--- a/contrib/ffmpeg/tests/Makefile
+++ b/contrib/ffmpeg/tests/Makefile
@@ -6,6 +6,7 @@ include ../config.mak
VPATH=$(SRC_PATH_BARE)/tests
SRC_DIR=$(SRC_PATH)/tests
+BUILD_DIR=$(BUILD_ROOT)/tests
CFLAGS=-O2 -Wall -g
REFFILE1=$(SRC_DIR)/ffmpeg.regression.ref
@@ -15,9 +16,15 @@ SERVER_REFFILE=$(SRC_DIR)/ffserver.regression.ref
LIBAV_REFFILE=$(SRC_DIR)/libav.regression.ref
-all fulltest test: codectest libavtest test-server
+SEEK_REFFILE=$(SRC_DIR)/seek.regression.ref
+
+all fulltest test: codectest libavtest
test-server: vsynth1/00.pgm asynth1.sw
+ @echo
+ @echo "Unfortunately ffserver is broken and therefore its regression"
+ @echo "test fails randomly. Treat the results accordingly."
+ @echo
@$(SRC_DIR)/server-regression.sh $(SERVER_REFFILE) $(SRC_DIR)/test.conf
# fast regression tests for all codecs
@@ -36,15 +43,27 @@ libavtest:
@echo
endif
+ifeq ($(CONFIG_SWSCALER),yes)
+test-server codectest mpeg4 mpeg ac3 snow snowll libavtest: swscale_error
+swscale_error:
+ @echo
+ @echo "This regression test is incompatible with --enable-swscaler."
+ @echo
+ @exit 1
+endif
+
+seektest: seek_test$(EXESUF)
+ @$(SRC_DIR)/seek_test.sh $(SEEK_REFFILE)
+
# video generation
vsynth1/00.pgm: videogen$(EXESUF)
@mkdir -p vsynth1
- ./videogen 'vsynth1/'
+ $(BUILD_DIR)/$< 'vsynth1/'
vsynth2/00.pgm: rotozoom$(EXESUF)
@mkdir -p vsynth2
- ./rotozoom 'vsynth2/' $(SRC_DIR)/lena.pnm
+ $(BUILD_DIR)/$< 'vsynth2/' $(SRC_DIR)/lena.pnm
videogen$(EXESUF): videogen.c
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
@@ -55,7 +74,7 @@ rotozoom$(EXESUF): rotozoom.c
# audio generation
asynth1.sw: audiogen$(EXESUF)
- ./audiogen $@
+ $(BUILD_DIR)/$< $@
audiogen$(EXESUF): audiogen.c
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
@@ -63,6 +82,10 @@ audiogen$(EXESUF): audiogen.c
tiny_psnr$(EXESUF): tiny_psnr.c
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
+#FIXME cleanup shit below
+seek_test$(EXESUF): seek_test.c
+ $(CC) $(LDFLAGS) $(CFLAGS) -DHAVE_AV_CONFIG_H -I.. -I$(SRC_PATH)/libavformat/ -I$(SRC_PATH)/libavcodec/ -I$(SRC_PATH)/libavutil/ -o $@ $< $(SRC_PATH)/libavformat/libavformat.a $(SRC_PATH)/libavcodec/libavcodec.a $(SRC_PATH)/libavutil/libavutil.a $(EXTRALIBS)
+
DSPDEPS = $(SRC_PATH)/libavcodec/i386/dsputil_mmx.c \
$(SRC_PATH)/libavcodec/i386/dsputil_mmx_avg.h \
$(SRC_PATH)/libavcodec/i386/dsputil_mmx_rnd.h \
@@ -87,5 +110,5 @@ distclean clean:
rm -rf vsynth1 vsynth2 data
rm -f asynth1.sw *~ audiogen$(EXESUF) videogen$(EXESUF) rotozoom$(EXESUF) tiny_psnr$(EXESUF)
-.PHONY: all fulltest test codectest libavtest test-server
+.PHONY: all fulltest test codectest libavtest test-server seektest
.PHONY: mpeg4 mpeg ac3 snow snowll distclean clean
diff --git a/contrib/ffmpeg/tests/audiogen.c b/contrib/ffmpeg/tests/audiogen.c
index 31c437149..68ae13586 100644
--- a/contrib/ffmpeg/tests/audiogen.c
+++ b/contrib/ffmpeg/tests/audiogen.c
@@ -1,7 +1,26 @@
/*
* Generates a synthetic stereo sound
* NOTE: no floats are used to guaranty a bit exact output.
+ *
+ * Copyright (c) 2002 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include <stdlib.h>
#include <stdio.h>
diff --git a/contrib/ffmpeg/tests/ffmpeg.regression.ref b/contrib/ffmpeg/tests/ffmpeg.regression.ref
index 9db847a1f..ae5355406 100644
--- a/contrib/ffmpeg/tests/ffmpeg.regression.ref
+++ b/contrib/ffmpeg/tests/ffmpeg.regression.ref
@@ -7,10 +7,10 @@ f3b008355f68394b6cad694f3488ea2b *./data/a-mpeg2.mpg
736978 ./data/a-mpeg2.mpg
9f364a477987c3b14412e303b94377ca *./data/out.yuv
stddev: 7.68 PSNR:30.41 bytes:7602176
-1ed851cc079a7bc999e1cc2dc2aa146c *./data/a-mpeg2ivlc.mpg
-727637 ./data/a-mpeg2ivlc.mpg
-9f364a477987c3b14412e303b94377ca *./data/out.yuv
-stddev: 7.68 PSNR:30.41 bytes:7602176
+1716f466ea82b4d90677868b2ce1f8e2 *./data/a-mpeg2ivlc-qprd.mpg
+708232 ./data/a-mpeg2ivlc-qprd.mpg
+40746946d5661606f7a649c62b6c4bee *./data/out.yuv
+stddev: 12.21 PSNR:26.38 bytes:7602176
2566ea5760247a9485c8281cb52291a8 *./data/a-mpeg2.mpg
735853 ./data/a-mpeg2.mpg
55c22a09e4924977ee2cc4180078d3ae *./data/out.yuv
@@ -19,17 +19,17 @@ stddev: 7.67 PSNR:30.42 bytes:7602176
749746 ./data/a-mpeg2i.mpg
5189af71e6aa96cc2f6452e7f6b29287 *./data/out.yuv
stddev: 7.68 PSNR:30.41 bytes:7602176
-f2067ddbe91a90ef12d606bba91cb900 *./data/a-mpeg2thread.mpg
-812667 ./data/a-mpeg2thread.mpg
-f101d3844ea2e12ac38001718c519232 *./data/out.yuv
-stddev: 7.63 PSNR:30.46 bytes:7602176
-fb900ca681fc054ed634ee4eadc9dc38 *./data/a-mpeg2threadivlc.mpg
-803035 ./data/a-mpeg2threadivlc.mpg
-f101d3844ea2e12ac38001718c519232 *./data/out.yuv
-stddev: 7.63 PSNR:30.46 bytes:7602176
-fd5f3e2a81558213bdfb8a7c86b3f541 *./data/a-mpeg2reuse.mpg
-2099878 ./data/a-mpeg2reuse.mpg
-e7f8692982e6d339a1f64bde4c297e59 *./data/out.yuv
+69576facff13d45171e3a6c53b8018c4 *./data/a-mpeg2thread.mpg
+813459 ./data/a-mpeg2thread.mpg
+c0e8cbde76ff8377494fe6843fd03e11 *./data/out.yuv
+stddev: 7.63 PSNR:30.47 bytes:7602176
+17af99d1a7fc391242a809b0782263af *./data/a-mpeg2threadivlc.mpg
+803833 ./data/a-mpeg2threadivlc.mpg
+c0e8cbde76ff8377494fe6843fd03e11 *./data/out.yuv
+stddev: 7.63 PSNR:30.47 bytes:7602176
+c8d8b07b5fa97e0affb4a52d4d30a2b6 *./data/a-mpeg2reuse.mpg
+2102956 ./data/a-mpeg2reuse.mpg
+75d3dfc8133f0122cb9e272a21bc8c5c *./data/out.yuv
stddev: 7.67 PSNR:30.42 bytes:7602176
c83ae8d8f3e2b4506df58e6a2f7e3b2a *./data/a-msmpeg4v2.avi
636512 ./data/a-msmpeg4v2.avi
@@ -67,22 +67,30 @@ stddev: 7.99 PSNR:30.06 bytes:7602176
7933744 ./data/a-huffyuv.avi
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-5f35533ff4357e405971466ee06375db *./data/a-mpeg4-rc.avi
-814102 ./data/a-mpeg4-rc.avi
-2cc2a0b6699d861b4cffad28a704067b *./data/out.yuv
-stddev: 10.41 PSNR:27.76 bytes:7602176
+b27e911f1563455700c93e6ae39715ca *./data/a-mpeg4-rc.avi
+813988 ./data/a-mpeg4-rc.avi
+f57311745de96b6551c175679b138efc *./data/out.yuv
+stddev: 10.40 PSNR:27.78 bytes:7602176
85e2456a673041d528b242d78318fb65 *./data/a-mpeg4-adv.avi
600188 ./data/a-mpeg4-adv.avi
60edc5a67271e425d0a2a52981895b81 *./data/out.yuv
stddev: 10.25 PSNR:27.91 bytes:7602176
-c429ad61139904f03a211ba2bdf4cf01 *./data/a-mpeg4-thread.avi
-761308 ./data/a-mpeg4-thread.avi
-cd5bb5cbd9a7ea0953825482d2990f5a *./data/out.yuv
-stddev: 12.31 PSNR:26.31 bytes:7602176
-339c0dd9f30afa33a6f7134f84d5b60a *./data/a-mpeg4-Q.avi
-878910 ./data/a-mpeg4-Q.avi
-83b3cef07c91a397c63bc4bc45df667f *./data/out.yuv
+d099307d14c1a4daa145618ca0522888 *./data/a-mpeg4-qprd.avi
+657996 ./data/a-mpeg4-qprd.avi
+8a52c562082bad78cabb40ffa292ceec *./data/out.yuv
+stddev: 12.12 PSNR:26.44 bytes:7602176
+9192b10ae298ba325d53abf7b5b91ba3 *./data/a-mpeg4-adap.avi
+400650 ./data/a-mpeg4-adap.avi
+0ce1d1fbebc9e9178e1a1d4a32a5804c *./data/out.yuv
+stddev: 14.66 PSNR:24.80 bytes:7602176
+41b27141442f773eca9ef3d48d8d555a *./data/a-mpeg4-Q.avi
+878264 ./data/a-mpeg4-Q.avi
+8995abbcc97ed4767fcbc0bf46accd01 *./data/out.yuv
stddev: 5.61 PSNR:33.13 bytes:7602176
+5fff534f0b958547dfdb811d4f289931 *./data/a-mpeg4-thread.avi
+761170 ./data/a-mpeg4-thread.avi
+fe1d119938f8a26174b38eeaa18dff85 *./data/out.yuv
+stddev: 12.31 PSNR:26.31 bytes:7602176
c1dae02bddd79790266bc0a9f7d6eb0e *./data/a-mpeg4-PSP.mp4
406449 ./data/a-mpeg4-PSP.mp4
7315281e07830456208dff61337c982b *./data/a-error-mpeg4-adv.avi
@@ -93,9 +101,9 @@ b699b2fd005571dda3f8d34cb0ce7aec *./data/a-mpeg4-nr.avi
688676 ./data/a-mpeg4-nr.avi
2c16e13b1367022d52b0e75d93a734ba *./data/out.yuv
stddev: 7.02 PSNR:31.18 bytes:7602176
-215cd567b5001181c24128e535cf77b0 *./data/a-mpeg1b.mpg
-1026948 ./data/a-mpeg1b.mpg
-1ee27511d22a4a553cac2ca64a79f2e1 *./data/out.yuv
+225ab004f6ac16e5ade3b453f45b9d96 *./data/a-mpeg1b.mpg
+1026429 ./data/a-mpeg1b.mpg
+dd9a471c6b2d1004a90e42f34707becf *./data/out.yuv
stddev: 6.34 PSNR:32.07 bytes:7602176
2f9cb2ede35f7d12f6b518c50e20d81c *./data/a-mjpeg.avi
1567580 ./data/a-mjpeg.avi
@@ -105,8 +113,8 @@ stddev: 7.93 PSNR:30.13 bytes:7602176
6264498 ./data/a-ljpeg.avi
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-8b9359781a7e87d09af1b1c9a536cb75 *./data/a-jpegls.avi
-9086694 ./data/a-jpegls.avi
+dca9d700da7857217408c310c501b9bc *./data/a-jpegls.avi
+9086676 ./data/a-jpegls.avi
0f8637e9b861230aff9894825af83720 *./data/out.yuv
stddev: 2.84 PSNR:39.04 bytes:7602176
7eee6367442884321e27d15a26bc032a *./data/a-rv10.rm
@@ -125,30 +133,30 @@ stddev: 20.00 PSNR:22.10 bytes:7602176
1454536 ./data/a-asv2.avi
0b310840a6d3970595983491687669df *./data/out.yuv
stddev: 18.82 PSNR:22.63 bytes:7602176
-4478bd22d09ae383b5cff05100437727 *./data/a-flv.flv
-649017 ./data/a-flv.flv
+cbdb25fe5bb6a895baf9799b8ccb3038 *./data/a-flv.flv
+649040 ./data/a-flv.flv
40281942d6ee254f7d3027b8593b19be *./data/out.yuv
stddev: 8.06 PSNR:29.99 bytes:7602176
f8f51fa737add17f7fecaefa118b57ed *./data/a-ffv1.avi
2654678 ./data/a-ffv1.avi
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-b12ff53580cd8a9ce92ab7a0649e99f9 *./data/a-snow.avi
-155948 ./data/a-snow.avi
-b3feb1bf17bb4e720da1f1e8b4da4c03 *./data/out.yuv
-stddev: 23.19 PSNR:20.81 bytes:7602176
-265c4e0c45b2313817fa4d86dccbe6ba *./data/a-snow53.avi
-3519574 ./data/a-snow53.avi
+9078723c943de5d79490f54b99e6ea9e *./data/a-snow.avi
+156656 ./data/a-snow.avi
+f2932084b52e2ede167c9ba21eae0656 *./data/out.yuv
+stddev: 23.14 PSNR:20.83 bytes:7602176
+ba999e86070aa971376e7f317a022c37 *./data/a-snow53.avi
+3519486 ./data/a-snow53.avi
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-2fcbcdc63816e1321bf4b6b5380338d2 *./data/a-dv.dv
+c299f64c3e85b928c5bfe71629cee006 *./data/a-dv.dv
7200000 ./data/a-dv.dv
-c2082cd8adf417c4ebc32654e446cba1 *./data/out.yuv
-stddev: 8.86 PSNR:29.17 bytes:7602176
-4f71942eb699bf3b12508a9e777a319f *./data/a-dv.dv
+3b9ead854b912e43ead976e4e86aab3b *./data/out.yuv
+stddev: 8.91 PSNR:29.12 bytes:7602176
+70dc9a58345e603094dedcac71e2dcd2 *./data/a-dv.dv
14400000 ./data/a-dv.dv
-fc866b8879a34f5b440647e5135e4bfb *./data/out.yuv
-stddev: 8.45 PSNR:29.58 bytes:7602176
+d727da8c7ce387ebe68845a1be916ee3 *./data/out.yuv
+stddev: 8.50 PSNR:29.52 bytes:7602176
6860534864cad0de4b1af9f987aaf9bf *./data/a-svq1.mov
1365791 ./data/a-svq1.mov
fb0a97094a89d6f379535f615783d00c *./data/out.yuv
@@ -158,25 +166,33 @@ stddev: 10.98 PSNR:27.30 bytes:7602176
83f8df5d5f84480566af548bb037fceb *./data/out.wav
stddev:9330.70 PSNR:16.92 bytes:1054720
stddev:4396.13 PSNR:23.46 bytes:1052672
-dd68110cb7e5388392f89d5160d3a825 *./data/a-ac3.rm
+aefe11ab5067621a1c674859d6413891 *./data/a-ac3.rm
98203 ./data/a-ac3.rm
-9e6e66847a568ef4f1f229b0939d2aae *./data/a-g726.wav
-24268 ./data/a-g726.wav
-a719ab6d47d8d601520edb13bf6136b4 *./data/out.wav
-stddev:8459.88 PSNR:17.77 bytes:96256
-ea2efb8ba20695a35ab0d71a7ee86f22 *./data/a-adpcm_ima.wav
-266288 ./data/a-adpcm_ima.wav
+39878597b1d65cce473639a7d8c93b02 *./data/a-g726.wav
+24279 ./data/a-g726.wav
+888f2f016e608d044a1bacbca5497ed2 *./data/out.wav
+stddev:8368.02 PSNR:17.87 bytes:96256
+de3f0e1f50b19bd8572fdd3dee2e72c4 *./data/a-adpcm_ima.wav
+266300 ./data/a-adpcm_ima.wav
60178d48204f5662d91776e36eddc82e *./data/out.wav
stddev:11441.89 PSNR:15.15 bytes:1054720
-d2eee867856d2bdb6d08e936d4ceec0c *./data/a-adpcm_ms.wav
-267308 ./data/a-adpcm_ms.wav
+628d4789cf9ee16a756ac54b7fd8650d *./data/a-adpcm_ms.wav
+267320 ./data/a-adpcm_ms.wav
91a84bb4f319a3a0bf0c0441b3d3a529 *./data/out.wav
stddev:1050.18 PSNR:35.89 bytes:1054720
-48ae9fcb043a44e316998b85043b61bc *./data/a-adpcm_yam.wav
-264236 ./data/a-adpcm_yam.wav
+ab11d9151644cbff27827b7e89f37aa9 *./data/a-adpcm_yam.wav
+264248 ./data/a-adpcm_yam.wav
e92cec8c07913ffb91ad2b11f79cdc00 *./data/out.wav
stddev:18312.68 PSNR:11.06 bytes:1056768
c3382f03ce2efb5d475240d288a33898 *./data/a-flac.flac
353368 ./data/a-flac.flac
c4228df189aad9567a037727d0e763e4 *./data/out.wav
stddev: 33.31 PSNR:65.87 bytes:1040384
+0c406c4e4586ca27064e28637b662631 *./data/a-wmav1.asf
+106004 ./data/a-wmav1.asf
+stddev:12251.50 PSNR:14.56 bytes:1056768
+stddev:2106.00 PSNR:29.85 bytes:1048576
+82442aaa5fdbd327769e4c4ad369147e *./data/a-wmav2.asf
+106044 ./data/a-wmav2.asf
+stddev:12255.92 PSNR:14.55 bytes:1056768
+stddev:2099.31 PSNR:29.88 bytes:1048576
diff --git a/contrib/ffmpeg/tests/ffserver.regression.ref b/contrib/ffmpeg/tests/ffserver.regression.ref
index 7350fa481..851a40d22 100644
--- a/contrib/ffmpeg/tests/ffserver.regression.ref
+++ b/contrib/ffmpeg/tests/ffserver.regression.ref
@@ -1,10 +1,10 @@
-418d0c843a6605a7d48f285804a69df4 ff-test_h.avi
-ad4605187044d5e169f32a2ea205f937 ff-test_l.avi
-34f4f0c160efcdb37c0999680e07c41c ff-test.swf
-fe6de6234a8bb4ace52b86763741cecd ff-test_h.asf
-68e7c8a8ff64c4016a8d4e5ea27353f3 ff-test_l.asf
-cba8663681bf3ef89c95c09bb90204db ff-test_h.rm
-0a14086c708a7b8f4604e705a2bb7087 ff-test_l.rm
-353a9a8fb3d5bb2334ac991b5c60f6d3 ff-test.jpg
-7cbd46a6174d8203c26be333980595b5 ff-test_small.jpg
-aaa459e638cd1dc2c120760fa4e1e384 ff-test.mjpg
+b33ed697236149e1503b60ca9f645b6f ff-test_h.avi
+3c104d3664ed260be9117ed1273c6dcc ff-test_l.avi
+d976848a9e4d5d8fc2659e4841cdece5 ff-test.swf
+5dd7a3cbc430f2534cdfc68030e4d5f5 ff-test_h.asf
+1111699f36f2fe2240d3e5c73827df50 ff-test_l.asf
+0b4c970507eeb57381c92c3309f2d982 ff-test_h.rm
+daaaa2e170f48f8bd423c0c45ab632c7 ff-test_l.rm
+e0dc91430660c619e97b5c82e0f398fc ff-test.jpg
+0346739ee6ba2d3bbacb9814d00d7d2d ff-test_small.jpg
+77a905f865ca536b6b92b9beb96beb94 ff-test.mjpg
diff --git a/contrib/ffmpeg/tests/lena.pnm b/contrib/ffmpeg/tests/lena.pnm
index 9fa0c923f..700508c86 100644
--- a/contrib/ffmpeg/tests/lena.pnm
+++ b/contrib/ffmpeg/tests/lena.pnm
@@ -2,7 +2,7 @@ P6
# CREATOR: The GIMP's PNM Filter Version 1.0
256 256
255
-â‰}߈‚â†väˆ|âŠ{â†|à†rÞ„uÝ„nÞŠvß‚kÞ„jÜ„pà€gÝ‚tÞsà‚jà„râŠvæŠrèŽrè’wì—zè—yî•vê”xévè†tàwfØvvÊZa´P_¨@Tœ>\œ=Y¤EX¦GXªJZ®IZ²J\²NW±JV¯LV°OZ²LX²LX´NX²LV²NZ°NZ®JS´JT´OV¸SY¼TZÂXZÂTXÂZYÄ^ZÄ[\Ê`\Ê^\Ë\ZÌf_Îb^ÎebÌabËbbËkhÍffÎd`Ìb]Îb`Ê`^Êg_Ëd^Ëd`Ëa^ÎhaÎhjÑb^ÐebÐfaÐgfÒebÔe`ÒddÒfbÒgdÎheÎf`Ïd^ÐffÐjfÌfeÎfbÎjfÐgbÓidÑibÐicÎhjÒheÊghÊknÎhlÌffËe_ÇddÌf^Îe]ÍcbÊcbÈjhÍibÍdaÎddÎdbÒb\Ðe`ÑhbÒf`Ðg`ÐjdÑd\ÏfdÎ``ÎjjÒplÍgcÌd_ÈbbÒe`Êd`ÎfgÌb^Çb`Îe`È`eÎieÈbcÈc^Êb`ÌcbÈccÎabËadÈbbÇbdÈ^^ÉbcÄbaÀ\`Â[dÀZ`»Za´X_°T[±PX¨HV¶LP¾V\È`]ÑlbÔqlÖzlÙtÜ„pÞˆnÞŠrÚŽvÝ‚nÜzgÜ~jÚ€jÜlÞ€nÜ€rÞ‚rÝ€pÞ†xÞ‚n߀hÞ€jÜ~j߀eÞ€lÞfà}fÝ‚jÞhÜ€eÞ„hÜ„m܆nÝ‚jÞ†q݈qÝ„pÜ‚hØ„nä”nï¹…ôÈøÎ–øÐžúÔ£üÔœúÔŸôÈ⪀Ärj§M\¥HX¨PZ®OZµX\¹Z\¶Za¼^`ºac¼X\¼^^¾ZZ½^b»dhº[cº\aÃZ[À[^ÃZZÃZ^¾^^Ã]`Â_^Á`cÄ`bÀ^_Å^]¼V\Á`cÂ`bÄbhÁ``Æ[[ÂbbÄa`¿[]¼V\¼V\ºVZ¾\bÚ{væ’€è”zÒrdâ‰}߈‚â†väˆ|âŠ{â†|à†rÞ„uÝ„nÞŠvß‚kÞ„jÜ„pà€gÝ‚tÞsà‚jà„râŠvæŠrèŽrè’wì—zè—yî•vê”xévè†tàwfØvvÊZa´P_¨@Tœ>\œ=Y¤EX¦GXªJZ®IZ²J\²NW±JV¯LV°OZ²LX²LX´NX²LV²NZ°NZ®JS´JT´OV¸SY¼TZÂXZÂTXÂZYÄ^ZÄ[\Ê`\Ê^\Ë\ZÌf_Îb^ÎebÌabËbbËkhÍffÎd`Ìb]Îb`Ê`^Êg_Ëd^Ëd`Ëa^ÎhaÎhjÑb^ÐebÐfaÐgfÒebÔe`ÒddÒfbÒgdÎheÎf`Ïd^ÐffÐjfÌfeÎfbÎjfÐgbÓidÑibÐicÎhjÒheÊghÊknÎhlÌffËe_ÇddÌf^Îe]ÍcbÊcbÈjhÍibÍdaÎddÎdbÒb\Ðe`ÑhbÒf`Ðg`ÐjdÑd\ÏfdÎ``ÎjjÒplÍgcÌd_ÈbbÒe`Êd`ÎfgÌb^Çb`Îe`È`eÎieÈbcÈc^Êb`ÌcbÈccÎabËadÈbbÇbdÈ^^ÉbcÄbaÀ\`Â[dÀZ`»Za´X_°T[±PX¨HV¶LP¾V\È`]ÑlbÔqlÖzlÙtÜ„pÞˆnÞŠrÚŽvÝ‚nÜzgÜ~jÚ€jÜlÞ€nÜ€rÞ‚rÝ€pÞ†xÞ‚n߀hÞ€jÜ~j߀eÞ€lÞfà}fÝ‚jÞhÜ€eÞ„hÜ„m܆nÝ‚jÞ†q݈qÝ„pÜ‚hØ„nä”nï¹…ôÈøÎ–øÐžúÔ£üÔœúÔŸôÈ⪀Ärj§M\¥HX¨PZ®OZµX\¹Z\¶Za¼^`ºac¼X\¼^^¾ZZ½^b»dhº[cº\aÃZ[À[^ÃZZÃZ^¾^^Ã]`Â_^Á`cÄ`bÀ^_Å^]¼V\Á`cÂ`bÄbhÁ``Æ[[ÂbbÄa`¿[]¼V\¼V\ºVZ¾\bÚ{væ’€è”zÒrdâŠ|à†yâ†vä†xâˆvâ„vàƒnà‚oß„m߆p߀hàhÞ„oà€gÝ€tÞ‚nß‚lÞnáˆtæ‹qçrè“yë—zë—yî–vì”vêuç„oßwh×omÈX_´O^§AW>Yž<V¤BV¦FZªFY®JZ°JZ²KV±JT®JT°LX³IS²JV³LW±JT²LX²LW¯JR³KU²PW¸QX¼U[ÂWYÃVZÂZXÄ\ZÆ\]Ê][Ê^^Ë[[Êa^Ïc^ÎdbËddËa^ÌheËccÎfbÍc^Ía`Ëa`ÊfcÌd`Íb`Ìb_ÏieÎgjÐd_ÐgdÐhdÒidÓfaÔeaÓfbÒfbÒfbÏidÐd`Ïc_ÐecÐgbÎdbÏfcÐhbÐgaÒhaÑfbÏhdÎhfÒgaËgjÍhiÍjjËebÌb`ÉbaÌe^Ðd]ÎcaÌb`ÈfdÍjaÊb_ÌddÍc_Ña\ÍfbÐfaÐfaÏf^ÐgbÐe^Ðd`Îb_ÌhhÒjiÎhdÌdaÇbaÐd_Ìc_ÌccÍd_Éa`ÍdaÉacËhiÈ^`Èa^ÉccÊdeÉa`ÎbcËceÈ`bÇbdÈ``Ë`aÄ`aÁ\_Â[bÀ\`ºY`µW^³TZ°OY¨JVµJP½TXÇ_^ÏjbÔpl×ylÙ}rÝ‚rÞ‡uߊrÛŠs݃mÜ|jÝhÜ~kÜmÜ}kÜ~oÞ‚pÜ€mÝ‚pÞƒoà€h߀hÝjÞ~fÞ~lÞ€hß~iÞ€hÞ„iÜdÞƒhÞ‚i܆o܃jÝ„qÞ†nÞ„pÜiÙlâ‘oôÅ÷ΘùМúÔ¡üÔúÖžö˔求Êzm¨NX¥HXªLV®Q\³X]¸Y\¹Y\½\^½``¼Z]»]]¾\[¼^b¼`eº]a¸[`¿[\¿Y\ÃZYÄ\]¿_`Ä^]Ä^^À_aÄa`Á`_Ä^\½WZÂ_aÁ^aÅbdÄ_`Ç]ZÂbbÄ`^À\\¾U\¾V\¼Z\À_bØtlÞ…vÚ}l¶WZâ†xà†qâ†vä‚nâ‡vâ†tâ€eà}lànà€ià€há~gÞ‚kà€fß|jÞ‚kß„nÞ€gä„næŒrévì’tì–|ì–xí–yì’sënæ„gÞxiÔfbÈZ\µL[¨<UŸ7S›;T¢<S§>T¬@T°KZ°LY°FS±FQ²EP±IV®FR°GS±JV²HOµFN²IT°GO³KV¶LRºOR¼VXÀTXÄWYÆ\\È_ZÊ\VÉ^ZÊZUÌZXÍ_\Ðb\Îa[ÌecÏ`\Îb_ËcbÐa^Ë`aÏbbÑf`Ðd_Íc]Ìc`Ïb]Òc`Ïb\Òc\ÐfgÐfdÑfbÒf`Òb^ÕebÔe`Ód^Ôa[Ñf^Òb^ÐabÎcdÎc_Ñc^ÑfcÎfdÎdaÏedÎfdÐc^Ïb`ÌdhËknÌdfËmjÊbbÍgbÊb`Îd`Î`ZËc`ËjfÌieËbbÊe`Í^XÎd\Îd^ÎgdÓd^Îh`Íb`Ðe`Ïa]ÐfbÐd^ÐffÍedÐd`Îa\Ë_\Ç`cÌ`^ÉfhÌ^]Ëb`Éa`Êa_Ê_^ÅbeÎa\ÎabËcaÌbaÌabÉ`^ÊbdÌ_\È^^Æ^`Æ[]ÁZ^¼\f¼W^¹T[¶RZ²LT«KX¬EPºUXÄ\^Èe`ÓlgÔvnØ{nÛrÛ†pÞˆt߈tÞ„mÞ‚oÞ~gÞ}gÜoÜ|gÞ€nÜ€nÜiÝ‚nß‚là€fßißfßeÞ~cà€ià‚hÝ€j߀fÞ}dÞeÞ‚gÝ‚iÜ‚lÝ„mÜ„rÞ‚kÝ‚jÚiÛhè¢xñ¾Š÷ÊøÐšúÒ›ûÔžüÖžûÒ•òÉߞs¸d_£HX¦JW«P]²V]¸V[¼[]½TWº[^»Z]½ZZ¼`^ÀZ^¾`a¿\^º^bº_d½]^¾^\Âa[Á__Æ_[À`_Á^]Ã]\Â\^Å\ZÀ^^¿[`Ä^^Æ``Ç]bÇ\[ÄbdÇ`\Ä_`Á[\Å[]Å`cÅb`¹VZœET~,KfEà‚ià…páƒrâ‚nâ…tâƒrà„kã€lâ€kà„nà‚jâiÞnß~mÝ~hà‚lÞ~iâƒjå‰mçŽré“rì“wì”sì–rî•ní‘pêŒlå€dÞtfÔjaÉWZ¸NX¨=Rž:Q¢8N¤:O¦@R­DT®DR²DPµHSµFP²DN³LW¯GR²KR²HR²GO²HN²HR°JT³LU³PY´OX»QY»VZÃUWÅZ]ÃYWÅ]]Ê^YÈ^]Ê]XÈa^Ì]]Í`^Ê_[Ðd]Ìc_Ìb`Íb^Íd_Íd`Îa^Îb]Îb^Ìd^Íb\Ðb^Îf_ÐbaÏc`ÏfaÐgbÒfaÓh^ÒhaÓd^Ñb_ÒgbÏhaÒdbÎb`ÐkhÑedÏdaÐfbÐdbÍa`ÑefÏcaÐd`ÏbfÌ`_Ë`bÒdbÎb^ËgfÌbaË`\Í^\Í`]ÉfbÌgdËhcÎedÎ^VÎ_[Ìb\Ëe_ÎdcÐb^Óa]Ðc`Ðb[Ïb_Òb\ÎcaÐd^ÐfbÌecÏ`\Ða^Êb`Í`\ËbbÊ]]Ëb]Ë`^Ì`]Ê\\È^`Í^^É]^ÈbaÎa_Ê_\Ì`[Ëb`Ç[[É^]Ç]]È_^Æ\^¼Y_¼Ya¹TX¸PX·QS³LU¬HT±JU¼SYÂ]^ÎffÑql×xpÚ{nÜ‚qÞ„tߊuß…rß‚nÝ‚pÞ€jÝ~jÞƒká„lß‚iàjÞ„mßiàjá„kàƒgâ‚eßjßg߀jà‚jß}eÞjß‚jÞƒjÜ‚lÜlÝnÛmÜlÜkÚhÚ~mÞ‰n쮀õÂŒöÌ™øÐšûÓžúÓ›üÔ™øÍ’ë·~Єl¬U[¨LY¬NU¯S\¸SZ¹XZºZ]¼\^¼Z_»Z\º]^¾[^¼]a¾\aÀ\]¾X[ÀZ`Á\^Â^^Â`^Ä[XÄ_^ÁZ\Ã_[Ã\_Ä^ZÆ]\Ä]^Ä`\Æ`cÆ``Å`]Ã`_Æa]ÈbbÆbdÉ_^Ä_\°NTŒ/Id@\B\Aàƒlà†nä‚iázká…oâƒká‚lâƒkä‚nàná„kâiß~hàhâ‚làbà‚hâ„jæŠjèŽnê’oë“qì–sì•oî”nìhèŽmå}eÞo^Õf]É\[µKT¨;OŸ8Q8P¥<P©@S¬BR®@P°HS´CN³GQ´FP±GT±IO´IR´DM±GP³IQ°DO°JR´KS¶OV¸OS½QT»VZÀW[Â[_Ä]`Æ\^È[VÊ^ZÎ[WÌb\Ï^ZËb_Í_ZÌa^Î`\Ïa^Í_ZÊfdÐd^Ïd`Ðe_Î`]Ïc\ÎaZÐ`]Ðe]Ð`[ÐdbÒfbÐfbÓb^Ôb[ÒdaÓd`ÒebÔd^ÐcaÐ_\ÑbbÐfbÓb^Òd`Ôd_Ñ`]Îc^ÐfaÎbbÑc\Ïc`ËcbÐa^ÐfdÍdbÎb`Ìb`ÍcbÏ`\Îa^Ìa^Ï`^ÈfcÏb^ÌcZÌc]ÍbaÎb\ÍdaÏcaÐhdÏc]Íd`Ïa]Îa_Î`_Î`[Ïb_Íd_Ðd_Ìc^ÌbbÑaZÌ`]Ì`]Êa^ÊbfÌb]Í``Èa_Ì_^ÊaaÊ^]Ì`dÌd`Ì`_Ìa]Èa`ÈbaÈ`]Ä^_À\`¼V\¿YbºTZ·U`´NV²NX¯LY®HV±NX¾X^ÈegÐjfÖsoÚzrÜ~tß„vàˆuà†rá„oßlÞ‚pßjßläƒiá†lá„mâ†oájâƒlá„jáƒlßj߀ià‚jà€hà†jàkà~fà€gßlÚ}aÝnÚlÚƒlÚhÛ€fÚ‚gÚ|iØkä—tð¹„öÆ’ùΘúМûÔšþÖœûÓ˜õÆŒä¤uÀlc¬JR¬IU«LU²RX³SZ¼VXÀ\]½ZZºY^»^a¾ZZ¾]^½Y\º\]¼Y_½ZZ½XZ¾\\¿\\Ã^^½]b¿]^Ä^\Ä\\Á^\Æ\\Â^^Ä^_È^\Í_\É\\Æ^`ÈdcÎfbËhbÃ_]®HO…,Fe@\@ZAZBäƒnâ‚pâ‚kâƒná„nâƒjâ€hâƒlâ‚jà‚qâ…lâkà€j߀iájáhãƒjä‹qèŒnè’rç”pé“tê’të“kínêŽhç‹hâ~gÝp\Ôh]ÉVT²JRª?Qœ7N :O¢=O¨<N¬BR°DQ±IV±GR³LX±KV°MV±NV³FN°DO±IP²CL±FO±DOµJR¸RVºNW¾RRÁWVÃVZÁVYÄZ^ÄX[È\ZË\YÍ\XÌ]YÐ]VÎ[XÍ^XÑb`Ì``Ðb_Îd_ÐebÑd`Òc`Îb^ÏbaÎb`Ía\Ñc\Îd`Ï`\ÏbcÏgcÐb\Ôb^Ód^ÓgdÔg]Öc^Ôb\Ðb\ÐfcÑddÐd`Óc`Ób]Ô_]Ñd_Î`aÐdcÎ`cÒc_Òb_ÑeaÒe`ÑdaÎdcÐd`Îb^Ï`^Îb_Ð_\Íb^ÏcaÍc`Òc`Ì_[Î`ZÎebÐb]ÐhdÒhdÒhaÑddÏfbÎb`ÎebÏb^Îb]Îd`Íb_Îb^ÐfbÌdfÎa\Èb`Î_ZÍcaÌb`ÉbaË^]Ìb`Ì__Ëc`Æ^\È]^Ì`^Ê`_É_^Ë`^ÌddÈ__Ã]bÅ\`À\`ÀZ^¹V`µPZ´PX±SZ²PZ®IT©HW·S\Â_hÏkiÔqnÚvlÛ}tàmá‡vâˆsâ‡sà„má„mß…lÞ‚oã†ná‡lâˆmåˆoä‰kä†pâ„pâ…jã‚fà‚là‚jà…gà‚ká‚fÞ€hàhÞ~dÜ‚jÜ€jÜ~jÜ‚oÜ€fÚ€jÚ‚mØ|hÖ~kÜ„lê©|óÀ‹øÊ’ùЛûÔžüÕœüÖžúјð»ˆÖr´WY¨LX¨M[¯T\±TZºTX¼X]¼Y_¼X\¼\_½\]ÂZZ¾\^¾[]ÀZ\ÁX[¼^c½[[¿^aÀ[ZÃ]\ÂZYÄ\]Ã\\Â\\Ã[\Æa^Ê`[Ç\[Æ`aÇ^`È^^ÌhcÏgcÇ]Y²OV†,Gb$HY@X=Z@\>ä„pâ„nâ‚jã‚eß„nâƒhâ‚lâjã‚mâ‚jâ€gá€jà€gÞ€jáiâ„iåˆpåŽpçqè“rç“vé“rê’nênêŽmæŒoç„fä~hÝr^×bVÊX\¶NW¦>Rœ<Qž<R£<M§?O­FT±CN³FSµIRµJU±KT²JU´JR³HO²CP°IP²KP±BK°DM´JQ¶MV¹OV¾PQ¾TWÁTZÆVUÄ[aÅ^\Ê^\É\YÉ]YÍb[Ì^XÎ^YÌb^Î^ZÍ^\Îb]Îd`Ìc`Ða^Ðd\Ïb^Ða`Ða^Ï_\Óc\Îd`Ðc]Ñc_Ðb^Òb^ÒaZÓheÖb`Ôc]Òb`Ñb[ÐcbÒd`ÑdbÒfeÖc^Ò`\Ñ``ÏfdÏdeÒfdÐcbÐecÒa`Ïc_ÏddÏdaÐc`Ñc\Îd_Ðb^Òb\Îc`Ïd]ÍdaÌb`Ïc`Ï_ZÎc]Îe_Ïb[Ðd^ÓhaÓd_ÒgfÎddÏb]ÐgdÏb]Î`^ÎddÎd`Îb_ÎaaÌcbÎc`ÉbcÍa^Í`\Ê`\Ë_]Ì`^Ê_`Î`bÊbcÊ`aÌ`_Îb^Ìa`Ë``Ìe_ËadÈ^cÄ^bÆ^`Â\aÁX^¼WY¶R]·T]±Vc±N[­KY«JX²NZ¼VaÊehÖpkØvrÜ|qÝsÞ…tâŠpâˆráŠvãˆnàˆtá…rä‡täˆnåŠpæ‰påŒoè‡jã…ká„kâƒgá€lâ‚hà‚hàhâ~fâ‚fá‚fà‚hÝ~hÜ|jÜ|hÙ€kÙ€pÜ€lÚ€oØ‚pØ~jØyhä“qñ¶€øÄú͘úÒœüÕŸüÖüÕŸ÷ʓ簀È{i¬MX­MY­MU´NW¶OUºZ[¸T\·VZ¼\^½Y[¾ZYÂ`]À[[¿YX½\]¾Z\À\`¿\b¿Z^Ã\\Á]`Ã^]Ä_`Æ_^Â]^Æ^^Å^^Å`ZÊcdÍdcÌecÎk`ÄZ\¨EQ&Ea?\HZBZ<\B\Bã‚pà‚máƒmágâƒlä‚gâ‚oâ‚hâ€gã‚kâ‚jãjà~fÞ~mâ€jãŠtæŠnætè’påqç‘pêpêlêŽmêŽnç‰mæ„gà|gÝo\Ôf\ÈWY¶HR¦<LŸ7L 6J¢=O¨:J­FR²GQ°@L·KR´HO´HRµMV±HT²GT°FQ´JT²DM´DN±DKµEN·MP¼NQÀQUÁRSÅTSÇXVÈZ[Æ\bÇ]ZË\YË]ZÎ^ZÏ`\Ï_\Í_[ÌeaÌ`\Ða[Ðd\Îb^Óa[Òb^Òc^Ñb^ÎfaÒa^Ð`ZÐc_Óc`Òf_ÐfdÑd^Òc^ÑgeÒfbÔe`ÓkhÒegÒfcÔa]Òd^Ôf\ÔefÑd^Õa_Ò``ÒfcÐecÑcbÌa_ÐedÑgdÑffÐhdÒecÒb^ÒffÑebÑ`\Í_\Ï`ZÎf]Ñd_Ïc`ÌbaÌ`]Ðb]Ðc^Óf]ÒifÒfcÕjfÓe^ÐcaÐd`Îb\ÎebÎc^Ðc`Òa_Ðd\Íc`Î_\Ì`\ÏbaÎ`[Ì`_Ê`]Î^ZÌ[^Î_^Ì_^ÎbbÎaaÉbcÎ``ËbdÎ`^ÎbcËb`Æ_`À`bÃY\ÃZ]¾TX¿QV¹T[¶Zc´MX²OWªJ\®HW¹S^Á^hÐooÖvpØwpÜ}qÜ„wà…pá‰tâŽsâŠsâ†tã†lå†påŠpäŒuã‰lãŠqä‰qä†mâ„nâ…oâŠnâ†jáƒnà‚láfâgá}bàhÞ„rÝ|eÚjÚ|lÛ€mÚ}lØ~mÚ~hØ}i×{iÞ~hé¥{ô¿ˆúÊ‘úÑžûÓœüÖ¢üÖ ûÒœóÃŽážvºb`¦JX­LV¬NZ¶PWºX\»TZ¼V[½Z_ÀY\¾[[Ä[ZÀZ[¾[]À_\½[\¿_a¾]_¿^^ÂabÂ_bÂ\\ÀceÅa^Ê`[Éb^Ìb`Îb\Ðd`ÒhbÏfeÃ\[¦@Ly!B^>W>X<ZBY>[9_@âlà‚là„sâhâ„jâiä„hä†kä†kâ†mâiàƒpà€màlá…pä‰påråoænè‘qæ‘pèŽpèsç‰jèŽuèˆoä‚dâ{jÝreÖjeÆ^a¶Q\¦@Sœ8MŸ9L¤?P©@M®DM²CN±BN¶FP´GR´LT±IW´FP³HT°JT´FO±DN¯JS±DL¶KS¹NR»QW¼UZÁSWÀY_ÅXXÂY\ÈWZÆ^[Ê\\ÊYVÌ`]Í`\Ï^`Ð`[Ða_Ñ^\Ða\Òd\ÎdbÐc_Ðc]ÏfdÒd`ÑfcÐa^Ïb_ÎdaÒa]Ñb`Òc`Ô`[ÑaaÑdbÒfbÔd_Òd_Òf`Òc_Ôb^Òb^ÒdaÔc\Òb\ÓcaÒ^[ÐbcÓjiÒdbÔb^ÐdbÑcbÑabÎaaÎdbÑdaÓgeÏa`ÎdfÌbeÎ`bÌfbÌgbÍf`Ì_]Í_^Ðb]Ðd]ÐgaÑgfÐigÒjfÐgdÑdcÐfbÎdaÌfcÐd`Ðb_ÎgfÓfbÌ`^Ìa^Î\[Ía`ÎcdÌcbÎdeÍ_ZÌ`^Ì^bÍ_`Ì`\ÎbbÐcaÍadÌabÊ\ZÏ__ÊaaÃ^dÀbgÂ^d¿Z`¾VZ¾TY»S\¶P[³NX³NX®HV­FX³Q^¼[gËfgÓol×xqÛ~uÜ‚uâ…tã‰râŒxãˆväŠwãŠoã†oäŠqã‹räŽuæˆmåŒmå‹qã…jã„má…jã†oä†ná‚pâ‚hàkà€dá‚jÝlÝ~lÜ~jÚlÝ}jÙ€pØlÙnØ~iØzeØxf߉jð°øÅŠúΕûÓ ûÔžüÖŸýÖøÌ“íµ„Ð…l«NXªISªM\°NVµTZ·V^ºTZ¼X_¾Z\Ä\ZÀ_`¾\`Ä_[À``¾\]À]`¼^`¾bbÀ]^Â__Â^^Äb^ÆbdÌ^]Ìb`ÐfbÐg^ÒgdÒiaÄZ[¤>Lu$CZ<V@YBZC^D\?\>`;â‚jà‚oâ‚nâláƒlæ‚jâ…mä„kä…lãƒlà~nâ‚nànà‚ná†oãŒqætæ‘oèŒpæ‘ränæoåpåŠkæ‰lç‰oç‚dä|fÞqbÕhbÈ^^´V\¤BRž=O9N¥=J¨>J®BPµFP²FO³OWµIRµFN´KQ°HP°IQ®CO°DL±KP°EL³EK³FR·OX¼OV¼RU¿QPÄUUÃVVÆWVÆZYË\YÈZWÌ\VÈ\\Ì\XÍ_^Ìa[Í`^Ïa`Ña[ÎcbÌ`_Ð_]ÎefÐ_[Ðc`Ñb`ÎdaÒb`ÍdcÐbZÏabÑc`Ñd\Ða`Ña]Òc`Ôd`Ôc^Ð`ZÑaZÔc`Ò`_ÐbaÒbaÒd_ÐcbÐaaÑeeÔc`Ò`]Ò`]Ô_\ÒecÓfgÎbbÏa`ÎacÏbbÎb`ÌjfÌbbÎe`Îc`ÌcaÍbbÎ^\Í`ZÌb`Îa]ÌcaÑedÒghÐkmÑooÑefÎdeÎb^ÏfdÐb_Ìb`ÍbaÑfcÌ`ZÌa`Ì]_Ðb[Ì_`Ë`]Î``Ð`\Ê\]ÌZ[Ê``Ë`^Î^\Ï`^Ì``Í_^Ì_\Ï_^Ê^ZÊ^`Â\`À]h¿\dÀelÂV\ºPX¶T\³LZ²JX°NY®FT´OY¸V^ÌecÑok×ztÜznÜsß„pàŠvâŒyäŠvåvä‰pä†oá‰täŠxä‰rãnäˆrä‰pâˆoäƒlà„nâ‚pâ„oâ„râ€fá‚sà‚jÞƒpÝ}kÜ~nÜ~lÛjÜ€jÚoÙlØ}oÚ|kØ}lÚ{kÙyeæœt󻇸ɒúÏšúÓ ûÖ üؤüÓ˜õÆŒä¦w»jbªLT°R[®NU¸T[µPW¹X^»X\»X\¾Z\¼\`À`aÀZ^½[]¼\_¼`e¼Z^¿^`¾aeÂhjÄabÈabÊb_ÊfeÍedÑhgÒigÒlfÆ\]£?Nx#D[AR@ZFXFX@\CZB]?aAâƒqà‚lâ~iâ‚lâ„mä‚iäƒnä„mã†râƒlâƒnà„màjâ€iã„mæŠtç‘nå“tçtä‹nåŽlæpäŒpäŠlå†jä‰ræ‚hâ{hÚwhÖheÉ`d´OZ¥@Rœ8N;N¥?O«AK°AL±DN°GP²QX³DM´FO²DN²EL²HN²GN±HN±EL±IP²GN¶HPµLQ¹PT½NQ¿UU¿SVÄZYÂWXÅWVÉZXÌZVÎ\WÈ\\Ë`\Ð_]Î`[Îc^Ñb[Ð`YÎc_Î`\ÎccÎc_Ðc`Î`\Î`bÍb[Ð`^Íb`Ò`ZÒc_ÐdbÐb]Îb]Òc]ÒdbÓa^ÑcfÐ`]Òc]Ñ`[Îb_Ï^ZÔc^Ñ_ZÑb^ÒecÐ^^Ób^Òd`Ò\XÒ_[Ðb`Ñ^]Í]]Î`\Ïb^Ìa^Ð``Ð\[Ïb^Ðc]Íb^Ì``Ëc`Í^\Ì`\Î_YÍbbÑfdÑbbÏedÏfdÎffÍbbÐc`ËbcÍa`Îb`ËdbÐb`Ðb]Ìe`ËaaÌa_Î`[ÌddÌ[YÊ\_Ë]\Ë\]Í^ZÌ`^Ì^ZÌ`ZÍ\]Ð^\ÎZ\Ï\ZÏa_Ê`\Ë]]Â\`Â[`À[b¿Y]¾X`¾RV¶QZ°PZ²S\¯JW«JZ®O[¶P[Æ`dÐjiÖxpÚzvÜ€xÝ„tàˆyâ‰vãŠwãŠxä‡näŠrã‡máˆpá‡sátä‡näˆkâŠoá‰qàƒgà€mâ‚jâ‚jâ€hàmÝhÝlÝ~jÛ€lÜ|kÛ€jÚ}jÛ~lÛ|iØ{kØ~k×~lØveÔvfÜ„jì¬|õÉøÌ’ùÒ›ûÔžüÕžû×¢úҗf֌i³TW¬JS°PU´PZ´RV¹V[»Y\ºVX¼V\¾UXÀ\\À_]¾[^¾\]ÀWZ¾\`ÀZ\ÁadÂbcÃfiÆdhÇddÌedÎgdÒhiÓldÊ\[ >OnA_IV@XEZA\ LZ?]>\>b<c@â‚hßlànâƒtä†qä…jå…mä„lã‡mãlàƒrâ„oà‚qâ†päŠsçtçvæsæ’oårã‹qåŠsä‹rá„kåˆlæ‡læ„jã}dÞtcÖh\ÊZZ¸LT¦@Nž6I5H¥>Mª<I°=J¯BN¯JR¶JR´HP²HR³CO±JR³JP±FL´FK°EL²EM´HN¸LP¹MP¸PU¾LR¾QSÃWXÅZYÆZWÈWUÈZXÈYTÌ`\Ë_\Ï_[Ð`^ÍZVÌ^\Ìc]Ïc_Ò`[Îc_Ð^_Ð_ZÐb^Òb_Ì]^Î``Ð`^Î`^Ñ_\Ñ`YÎb`Ò`ZÐ^YÓd_ÔfdÖe`Ô_\Òa\Ó`YÒ`ZÐ``Ð`\Òb`ÐfhÑgfÓdaÒa_Òa\Ó^\Õ^WÒ_ZÑ]XÒZVÐ^[Ï^[ÐZWÒ]WÍ]^Ì\^Î^]Î]YÎ^ZÍ`ZÌ^[Î^ZÌ`]Ð\WÌ][ÐaaÍ`_Ïb`ÍdiÎdbÒcbÒb`ÎcaÍbaÑc_ÏcbÐd_Ï_\Î`\Î^\Î\ZÎ^ZÎb^Î`XÍ\[Í_\Í\YÌ\[Ì^^Ê_\Î_\Î^[Î\ZÌ[\Í\XÎ``Î`_É\[Æ\aÂ^dÂZbÂ_fÀV]ºQ\µNW²N[°NW®JV®L\±T`·YhÆafÎjlÔtrÛ{tÜ~xß…yà‰|â‹vâ‹xâ‰xãŒtäŽuâ†pá†ràˆrâ‰nâ‡lâˆnáˆkâˆoã…ißjàlà„jájá‚ißoà‚lÞ~hÜlÞ~mÚ€kÛ}kÜ}jÛlÚ}lÙ|jØ|i×zmÖxkÖydã–qòº†øÇ’úКúÔžûÖ¢ûØ¡üÖ÷ÊŽç°~Çw`¨JU­KS°OX±TW¶X^¼]]¿ZYÁ\]½Z]Á\ZÄ^ZÀ[]À\Y¿Z]¿ZZ½Y\¼]cÄbfÃ]_ÅcbÉdfÐdhÒifÒjgÈ\_¤<Nr#Gf4XWDV>W=X<Z=X:`;_?f?f@â€fß‚pâ‚oäjä„næ…mæ…iäƒiä…mâ†râ‚nâ„má„nåŠpærètérç‘sçræoå‰iä‡pâˆnàˆqä‡jæˆpæ‡nã~gàt^Ùg[ÉTQ´FL¨7FŸ8Lš0Gž6I¨<L¯BM°DN°HN¶EN´GPµHQ²LV°JT°IT°DN¯FP²FQ´DL¶GN¸KO¸LP¹JN¼QW¿STÁX\ÆYXÄUUÈZ\ÊZVÇ^\ÌXYÈabÍ^[Îb_Í^\Ë]aÌ^YÏ^_Ð`ZÍbcÍ^aÏ^ZÎ`^Ð``Î`eÏbcÑb_ÎcbÐaaÐc_Ñ`\Ò^XÏ\ZÐaZÏ_`Ó`_Ó`]Ôb^Ò^ZÑ]ZÑ`\ÒdbÑcdÐdlÕhfÒgfÒebÒ`aÕ^ZÒXXÑYVÑ[WÎZZÏZZÎZWÎ]WÎ\XÎ`\Ì`bÐ^[Í`[Ì\_Ê\ZÍ_\Ê`]É^]Ê^[ÈbaÌZXÎ`bÌ]^ÌbbÏfeÏcdÐcbÐaaÏdbÒddÎcbÌfcÌ_ZÌ_]Í^ZÌ^\Ì^[Ì__Ì^`Ê][ËabË^_Î]WË_`Î`^Ë^]Î`XÍ\\Î]ZÎb`Í^_É^]È^`Ä]^ÀY`Ã\_Ã^a¾^dÀR\¶MX¸NW´LS±JQ±JY¶P^¹WbÃ[fÑfjÖolÖutÜ€xà†xâ…{â‡zâŠuâ‰uáŠwäˆtâ‡sá†mà†qá‡pâ…mà†lá‡hãˆhâ‡kÞƒlâƒlß„ná‚jâƒkÞ„mßjÞ€lÜ~lÝmÛmÜlÞhØ€mÛ|jÙ}mÚ~kÖwhÖzlÕvhÜ€dê«zö‹ù͘úÒ™ûÕŸúØ¥üÛ üÔ™ò‰ڜw´\Z¬JP²NT³RW´V[¶ST¾ac¼^cÀ`aÄY^Â]^Â^^¿Z]¿\\¿V\Àab½^cÃ\\Á_bÆbbÎd`ÒheÐhhÊ^X¢=MsAYA\FYDS:U7Z<\8_=c9h=j>c9äƒpã„oä„mã„jä„hæ„nå…lå„hå…oã†oä…jã†rãˆuçŽoètç”rç”tä‘ræpåŒsã‡hã‡kâ„oà†qåŠhæŠnç†låcàsZØgZÊXR·JN§<Kž6Hœ3H£;I¨CN®?M¯DO²HS±DNµHP³IR²HN²LV²FN¬KV°FN±HP°EP´HM·KT¸KO¸KR½SVÀSRÂTWÆXUÄZ\ÆYXÈYXÈ\[É]ZÊ`ZÊ`ZÌ^WÌ]ZÍ]ZÌa\Ì^[Î_[Î_[Î\]Ìb]ÍabÎa_Ña`ÌchÎ]]ÎbbÐbaÐacÑabÒc]ÎacÐ`]Ð`]ÒddÕ^^Ô`aÒ\]Ð^^Ï__Ô^ZÔ^^ÑedÓfeÒhhÒgaÒadÑ[\ÎZXÑ\ZÍ[XÊZWËVUÎWRÍZZÎVWÎ]\ÌbdÎ^[ÍZYÈ\`Ë\XÌZ[ÊYYÌ^\Ì^^Ì\ZÎa^Ða_Ìb`Ì^^ÎbdÐ`^ÎbeÌbfÐb^ÐdcÏhfÐbbÍb^Ê\\Ð_]Ê^\Ì_bÍa^Ê`aË`aÌ^[Î\ZÍ_]Ì\XÉ]\Ì\ZÏ]\ÍZ]ÈZ]Îa`Ì^aÎ_\Ë]\Æ\_Ä^bÃU]ÄX^¾V^ÀYb¸OW¹QX¸NVµLU²LX¶Pa½XcÆaiÎfjÔprØwtÚ~wÞƒyß„và†xãˆ{âŠtâŠxâˆtà‰vá‡tá‡o߇tâ‰oà‚mâˆjä†kâ…jã†jâ„iàmâƒmâ‚qá‚nâ€lÞƒrß‚oÝ‚sÜ„rÞ€nÜ~lÜ~nÚ~hÚ~qÙ{h×xkØxi×xdÖvgâlô¸€øÇ‘úÑ›úÔŸúÖ üؤüØ¢øÐ”Él°IN¬MU²OU´TY½UW¼VX½ZZ¾[^¾^]Â\ZÀ[]¾]]ÂZZ¾[`½]]Á^aÆb`Ä^^ÉfdÌfdÏjdÂZ_¢9Kt>W=V:ZCXA[BW;^?^<b=d=g@a>f'Lä„jã…qä„pâ…må†mç„kåˆpä‡iä‡qä†näˆqåŒnåvèrçwé“rè’tèrçŽrçŠlä†jâ†nà‚rá†tçˆkèŠnèŠmè€fÞs^ØgXÊXU¶KP¦=KŸ:Nž4K¦<Kª@M¯BR°BL²FR¶LV²LVµNV±DN±LU²GM°EP²FO²IR±DP²IQ¶IR·JO¸KQ½NR¾TUÅTVÇWVÂ\_Æ[ZÊ[XÆ\ZÉ\ZËZVÌ_[Ì\YÍ`^Ì_]Ë`_Ì`\Î`^Ì]ZÎ^^Ì\\Ï`\Î_aÍ``ËbfÍadÏ``Î_cÓd_Ð_^Ñb]Òc`Ð`\Î``ÏcbÓ^`Òa^Ð`]Ò`_Ð_^Î^^ÏbfÑebÐdeÒa`ÑbbÒdcÎ`cÎ_\ÎYVÌZZËUUÍXVÌZVÊYWÌ\[ÌZ\Î\ZÍ`]Ì^^Ì]`Î\\Î\XÈ]^È[\Î\[Ê]\Ñ[XÏcaÌdgÌacÎ`^Íb`ÌbdÌefÍfhÌa`ÌdhÎ^[Ëa`Ç]`ÌbbË\[É\_Ìb^Ë``Ë_^Ìb^Î]\ÎZXÊ^aÌ_^Ê[ZË^^Î]`Í\`ËbaÐ^\Ï``Ë`aÊbdÇX]ÀT_ÁV^ÀV\¼V`¿TYºLWºNX´NZ°KZ´Oaº[jÆclÎilÓkjÕwxÛ|tÞ€và„xá‚tâ†sâ‹xá‡wâ†tß…và‚qá‡và„oãˆpã†iâ†gä„hâ„mä„jáƒlà€eánàqá„rá€há~kÞƒp݃rÞ„pß‚nÞ‚lÝ~lÜ€oÚzlÛjÚyjÖwgÖxjÔtf×|gì¥xöÀ‰úÊ”ûÒœùÕ¡úÙ§üÙ¤üמ÷Ë’ã§v¹d]®JP²OT´PXºUV¹VV¾XX¾V[Á^`À]`¾Y\¿ZZ¿\^À^]¿`bÅ[]Å``ÈcdËgbÍgcÄZV¢=Ks<X9W@[@\@\BZ=]?^>b=e<e<b:bAcEä‚gä„pä„näiå…lä…hä†jä‡lå‡pä‰væ†pçŒrèsé”té”ré”rè’ræ‘tèpæŠeä‡fâ‡lâ…pã…iæˆoèˆièˆjåcâv^ÜhVÌ[VºHN§<JŸ9J¡9K¦?Q¥?P¬AN°BN²DN³GQ´HS´KT²KT°NV²FO´CL°CL²EP®ENµHO·GP¶JSºNU½PVÂPQÂTUÆUVÆYZÄZ]É\\ÆVVÊ[[É\\Ë_\Í^ZÎb]ÊZ]Ð`\Î^\Ía`Ê_aÌ^ZÊ]`Ð]ZÎ`aÌ`^Î`aÑ`^Ð`aÔ``Ò`_ÐaaÐb]ÑbbÒb]ÓbcÏ_`Ï_^ÐaeÓehÑ`^Ñ^]Ò_\Ñ``Ò``ÒcdÏbbÓddÑ\ZÔ\YÓ`_Ð[XÎXVÍZXÉZVÈXYÈVWÌ[XÈVDÌ[YÍ]ZÉ]^ÊZ[Ì^[Í\\Ì\XÌZZÉ\YÆ\YÊ[^Ë_]ÍabÌ_`ÎbeÌ`aÌ]`ËabÍheÎbeÍcbÎ_`Í__Ê^]Í__Ë^^ÌaJÎabÍ^`É^^Ëa_Ï^\ÎZXÌ`\É`cÊ\`Í]\Ì[^Ì^]Í[]Í`]Ê``Ç]`É^_É[_ÆW_ÅX_ÄT`¼RX¸QH¶L]¸N[´HX¶JX¶LY¼Y]Ç^bÏelÒjjÔqnÙwsÝ|rÞ€rÞƒvá†xá†wâ‡tâ‰vß„wÞ†t߆s߆sá‰rá‰mà…râ‡oá…là„Vâ„oà‚pâƒkà„qãƒoà€jß„nÞ‚p߆nà‚n߃TÞƒrÞ€mÝnÛoÛ~qÙ~oØ|nØvmÕrOÒqe܃iï®löÄdùÎúÓ‚úØ—úÚžüÛ¡üÖ õƘښ³\~«Nw®Ni´PZ¼VV½WU¼UZ¿XZ¾[YÀ_[Á^[¿^\ÀaaÂ^^Â_`Èd`ÇgeÍg]Â[]¨CUw#R[NXNTG_DZ2]B\:`Hb?eBe;b<`<d@d >ä‡sâ…lá…nâƒkä…mä‰läŠnæˆpå‡räŠtåŒrèŽqè’uêré’qèrêoèpèkå‡jä†mã†mâ„lã†lèˆiæ‹lè†gä~eàr[ØfVÉVP´HM¨>Kš6L;M¥;K¨BP®BR°@M´IR´GP´HP²HQ²JQ¯FM²FN°IS²EK°CM²BM´CMµEO¸LTºOW½OUÂRRÄSVÄSUÆXXÉWTË[ZÈZVÈ]YÆ\\Ê[ZÌ\YÍ`]Ð__Í^]Ð][Ò`]Ï_]Í_XÏ`^ÐZZÑ]\ÎYZÎ^`Óa_ÎceÕb^Ò^`Ñ^\ÒZXÒ``ÎbdÏ`bÎa`Ñ`^Î^eÐ`eÐ``Ð^^Ð`_Ð^]Ð`aÕcgÓdaÒ``Ñ^`Î][Ñ[XÏZYÏWUÍXYÉ[\ÈXZÆX[ÊXVÊX[ËZ[È\^Ê^^Ìb`ÈXVÄ[ZÉWWÌYWÉYXÈ]\Ê[XÎ_^ÌabÊafË_aÍefÌbcËbfÍejËgfÊfjÌaaÎ^\ËbdÍ`_Ì`aËbaÏa_Ë\`Ð][Î^^É]\Í]ZË]`Î]\Ì]\Ê\XÍ[]Î`]Í]]Î^]Ê_`Æ`dË]^Æ[_ÉW^ÅW^ÁRY¿T^µP[·P[¹RZ´JX¹LYºQ^½VaÈYcÏbfÕhkÕqnÙwqÝ}tÜ}tßuà‚tÞ†vá…tâˆuÞ„vá„qà†oß„ná†kà†mà„náƒnáƒnà‚iá†mÝ…pà€ná„pà„pá†lßoàn߃mÞ€pàƒmà‚rßpÜ~oÚpÝ~pÜ~pØxjØzjÕtcÔtcÖveçžsô¿ŠúË—ùÒ úרúÚ«ûÛ¦ýÚ¥úΘ賆ÂvfªLU«JS±NX¶PW»QTºVY¿VX¾\]À^^ÄZX¿[\Â^aÄdhÇbbÍdbÏhgÅ]\¤?Pu>Z9W;V=Z=Z@a"LaBfFdCf;iAd<b@d@f>e<ä„wä†mä„oãˆlâ‹väŽrå‰nä‰næ‹yæpæsè’tè’oêrépê‘péjèŽnçŠfç†jäiâ…mâ†nã†kå†jç‡lè†læ|eÞp[ÙdTÌ[R¶HP¤<Hš5Hž4I¢9Hª@P®@O±CN¯DQ´FN°DO®FL°FN­HP®HN°EQ®EQ°CO²JU²IS·FP·LTºNTºQX¼PU¿X[ÂRVÇY[ÆVTÄVXÇXXÈ^YÅZ\ÉVXË^XÌ_`Î^YÎ][Ï\ZÎcdÎ_\Ñ\WÐ\ZÏYYÌ^^ÉX\Í^\Ð\\Î``Ñ\]Ð[ZÔ`_Ñ\VÐ^\Ì\_Ê^bÎ`_Ð_aÐckÏgkÒbdÑ`^Ò`]Ð^^Ò\\Ñ_^Ò`^Ò^]Ï]^ÍZ\Ñ\ZÑ[[ÍZXÎ[WÎ[WËYVÇYZÉ^`ËXTÊ_aÊ]XÌ]XÌ]VÆXTÈXUÂ\XÃXZÉVWÈ]ZÈZZÊ]]Ì`bÌ`cÎabÌ`aÍdcÌaeËfjÌccÊejÌabÍ``Ê]`Ê^`Í^^Ï`_Ï`^Ë`^Í]^Ì^`Ì][ÐZXÌZXËZZÐ^_Ï_aÐ[XÎ][Í\ZÐ\\Ê]_Î_cËXZÉWZËY]ÄV\ÃQZÂY`¼T]¹T\ºPV¸JT´JZ¶M[¾UcÆ[fÌblÓklÔmpÔtrÙzqÛ~uÞ€uß‚tÜ€t߃sá„tà„tÞ†rÞmÞ…oá„là‡rá†lß‚p߃oàoá‡q߃lÞ€oá…ráƒnâ‚làƒoàkàƒoß‚jÞ€pÞp߃qß~lÚ{pÛ{nÜ{oØzlÙ{kÖviÕtfÖrcÝfî­~øÆŽùИùÖ¤úئùÚ©üÛ«üÖ£öÅÜžy·^Y¨DO¯FQ´OT¸RX½SX½TYÀZ\À^^Â]_ÂbbÂ_cÌecÊfdÏfeÀVWœ:Js?X:W>V<Y>YC^D`FdDdCe>d@d?^>d=cAa<^;äˆvãˆnäˆoã‡gä‡råˆjå‡qåŠpæŒsæuê‘rêrèŽoêséoéŠjèŒfè‹kè‰eæ‡nâ„kä„jã‰rä‡oçˆlç‰næ„gä}gÝq]Öi]ÊXQ¶FK£6Fž0C›3G 8J§?N©BN°CP²DJµGM±KT°CK¯GN°FN°DL®GP°HN¯HQ²GP®BNµEPµKR¸NS¼QTÀSUÂSUÃSXÅZ\ÄVXÄVXÃVYÅW]Ç^^È]YÈ\]É\\Ë_ZÈ[WË]\Ï_]Ê^^Î\YÈ\ZÌVVÌ]]É`cÎ`^Ð^_Ï`_ÑabÑ^^ÐabÐ^ZËZYÍ`^Î`bÌ_aÑ^]Ò`cÐ`bÒ_aÏ`cÐ`^Ï\\Ó^\ÐbcÏ\[Ò]]Ô\[ÒZ[Ò[YÏZZÌZZÍ\]ÈYZÌTTÌ\^ÊXYËVVÊXXÊ[XËZZÇTSÉVTÉTXÆVVÅTWÂZ[ÅY[È\^Ê\ZÊ\\Ì`bË]`Ë_dÈbhÊbeÎehÎacËabÐ``Ë^^Ê^^Ì^_Ë^`Ï^aÑ``Ï`^ÏZ\Î^aÌ`_Í\ZÊ]_Ë^\Ê[^ÌZ\Ð]XÍ_`Î[XÏ[\Î]\Ì]bÌY^ÉZcÇV\ÄUXÀV_¼Wa¿Wd¸U`¹NVµJX¶HY¹KY¾R`Å]fÌchÒhk×pnÔwsØzsÚzqÜ~oÝ€uÜ€uÝ„tà„vß…xÞ†sß‚o܆tàƒjà‚oáƒhàƒpà‚pß‚láƒmá‚oà~jà~kâ‚jã†rá„oà„là€oÞƒsà€nßnÞ~mÞ~lÚzkÛzjÜzlÙyiÚwf×ufÖqbÕpaÕrbæ–pô¼„øË”úÔžùÙªúÚªüÛ¬üÜ©ûÒ™ñ¾ƒÎƒhªJR¦DO¯OX³PV·PT»RYÀUZºW`¾Y[À_dÃacÈdfÌhe¾W[>Nn@Y<X@U>Y?V=\Cb"Od'Pe#Kj%Ld$GdDb>d@b>_?^<`CåŠwâŠpåŠnä†päˆjæ‹päˆqæŒvètè’uè“véoèpé‰oèˆièŒkçŒfçˆkçˆjæ†lä†næ†må‡qçˆjéˆhè‰lç‚gä}fàp[ÖbVÈUP¸AJ¦:I™0Fœ2G£<N¦:K«BP±HR²JT²FP±AP³BL´EP°EP®DN¯EQ²EO°DN¯EN°GPµEMºFN¼NT¾PTÂQSÄVWÁX\ÃVVÅZ\ÄYXÆ\YÁ\^ÄWZÉ][ÉVTÆYZÎ]ZÍ]YÈ]^È\`È^`Ì[ZËZZÎZWÍZ^ÏYZÍ[]Ñ^`Ð\ZÔ^`Ñ^^Ñ_aÒ^ZÐ\ZÐbaÎ`bÐ^]Îa_Ð\]Ð`dÐ\^Ða`Ñ^\Ð\`Ñ^aÔ^^Ñ^aÒ\^Ó^bÐ\\Ð\\Ð^^Ð[[Í]aÊ\[ÌXYÎ[WÏZUÌYTÈTPÇTTÆWVÈWSÆWYÅYUÆVVÉVQÃXZÄVVÈXXÉWWË^\É``Ê]aËabÊefÍafÌbdÊbfÌ_^Ë]`Í_eÎ^]ÌZ[È^cË^`Î_`Í_^Î^`Î][ÌYXÎ^`Î_`Ì^^Ë^bË^ZÎ]XÌ\ZÍ][Ò^^Î]\Ê\^È[`ÈY_ÇUZÂTZ½R[¿S\¾S\¼R\¼PZ»OZ¹L\»NYÄT_ÆZdÎbdÐflÕopÕrnÙwsÚwoÚ|tÝvÝ€uÜxÞ‚vÝ‚tÞ†sß…sÞ‚oà…káƒlß‚oá€iÞ‚tà€ià‚làjà}iß~i߀lá‚pá…nâ‚rál߀jàlÞ~mÜ}nÝ~jÛzjÛziÛ{iÚvjÚubØtbÖtbÕp_Ön_Üdî­y÷ÈŽùÑ—øÖ¥ùÚªûÛ©ûÞªüפøÈå©z¾f[§EP®LR¯OX·MS¸QYºRZ¶T\¼Z_À\`ÅddÊd_Ã\\¥?Lt?Z=V=X@X>\>Z@^@d@fAdAa>b<`@`<a:_>_9Z>\>å†mäˆpå‰oæˆpä†käˆpäˆpçsé’yè”réxçˆjç‡lç†hèƒfè†cç„få‚eç‡jèˆnå‡räƒhæ‡oæ†oè†jçˆkç†låzfÜp\ØgXÇYU´EM¤7Kœ1H4I£:N¥<O«DT®DO²EP²DJ±HS¶HO±HS¯GO´LR°AL±JP®DO¯DM²IO¶FJ¹IP¼MR¼NQ¼RXÄUXÈXTÇYWÆTTÆTTÅZ_Æ\[Æ\[Ì]ZÌYXÉXXÌZYÎZZÌ\bÎ`_ÉYZÍZZÍ\\ÐYXÒ_^Ñ^bÎ`aÑ^bÐ^bÒ][Î\_Ñ\YÐ\bÎZYÒ`^Ó[ZÐ`]Ñ_`Ð^^Ð_bÒ`^Ò``Ò]^Ñ^]Ð__Ñ``Ð]\Ï\^Ò^^ÐZZÑ\ZÔcaÒ^\ÓZXÐ[WÐZXÏ[UÊWVÌZVÌXTÃXVÈURÆXUÄUVÄWTÃSRÅXRÂTR¾XWÆVUÈVWÉ\[Ç\]Ë^_Ê\`Í_bË_dÈadÎbeÍ^aÍ\^É\aË_`Ë^_Ê`eÌZ\Î`gÍbdÍehÎ[^Î\_ÏbfÍ^bÌ][Ê_bÍ\XÐ\YÎZZÏ]YÐ^]Ë_aÉYZÄY[ÈZ\ÈXZÄRWÂX]¾RV½S]ºQ\¸R]¶NY¶KX¸MZ¿R]ÄXdÎ\`ÑjjÒlj×qnÖtrØxpÙypÜzpÛ~sÜ€wÞ~pÜ„w߃tà…tßjß‚lá€jànàƒnÝ€rÞ‚lÜ€qß~gá€kà‚lß~lâ€nà~jâ‚nâ€qßmà~lÞ|jÞzfÛwfÛxkØvfÚtgØvjÙtbØsbÔqdÖq^×o\Ös_ä“oòº‡ùÌ”ùÕ¢øØ¦úÚ¬úÛ§üܧüÔ›ð¾…ÑŠl®MRªGP®LU±MV±OV´RY¸SYºZ]À]bÉheÁYY¤>Hw"A^>V<V=X>Y>]A_BaHg"If&KdCb@_DaD`B]?^<^:]>\;ä‰pä…käŠläˆlãˆläˆrä‹qè’uê–ué’vèŠmæ„hæ€eæ‚gæ€hæ‚bå€eä‚iç†gè‹dç‡må‡hã…nä†læŠnçˆlè…nå|fÞub×bWÉVS±DM£=L˜/E3F£=M§=N®AM­CP°DQ´EN´EO±GR²EQ²BN²HR²HO°FL®FP±FO²FPµHPºLR»IR¾PTÁU\ÅRVÆVVÆVXÈVXÆXYË\ZÈ^[ÈZYÊ\YÊ][Ì[ZÎ\XÌ\YÊ^`ËZYË\[ÎZ[Ê\^Î^\Ï^bÑ]]Ð`bÑblÐ[^Ò^^Î\_Ë[]ÍZXÎ_bÐc`Ô^^Ð`_Ó^_ÑbcÒ\_ÒabÑ[ZÓ^`ÐZ_Ò[YÐbbÑbbÒZZÒ^ZÐXYÏZYÒ[\Ò_\Î[\ÎZ^ÎX[ËZ^ÈXcÆdqÄhrȇÇuzņ‘Ày~Àv~¾jp¾kr¼[`½X^ÁWVÅWVÆXWÉ[XÃXZÈWZÇ^^Ç\_ÇZ_Ë[_ÈX\Í^aÍ^^É^`Ï^`Ì^cÍ]`Ð^aÌaeÎbcÍ`dÎ\\Ñ]]Ï]^Í\`Ì`cÎb^Ñ[UÐ^ZÌ]ZÎ]`Î]^Ç\^ÊZ^É]\ÈY_ÃS\¾T^½Q\»R\¸VaºPX¶JT·JZºLY¼P\ÅT`Ê^cÐhgÔlkÕnfÖvqÙtiØwpÚzrÚ}sÚ|vÝ|nÝ€uÞ‚tÞ‚rÞƒqßoÞ€l߀mà€mÜqÞlß‚pßjá€jâ‚kâ€iâià~hàoáià}hßzlÝzgÜzjÚwjÕuj×qdØwhØqeÚrcØtbÖrcØsbØp_ÖrdÜ{dì©xöÅŒùΘùÖ¤úÚ¨úÚ©ûܪýÙ£÷Ìæ­}ÀhZ¨FR­JT°KS²PX¸U\¹RZ¼^bÁb`¼X\£@Nv@[>X?W=X@X>\A_AdCa FeFg"IgFaEa@dAb>^9^<`;_>]<æ‹xä‰qåŠså†nä…låŠtçŒnê’uìréˆhæ†hå€hä|cæ}cäz_ãz[ç|bä€cçˆlèŠjçŒpç‰lä†qå‹uèˆlé‰pêƒbå~lát_Ùj^È\[²GS¥;K™3Jœ2H <R¦=N­>O®CL²FQµFN³HSµKT´LU°GN²FR²GQ²FM¯EN°FP³HN¹GN¸PW¹NU¾RY¾QYÄUTÌXUÅWXÈZYËVXËZXÉZVËYUÍ[ZÊ[YË\ZÐ]\Í[\Ì\`Ì^cË[\ÑZXÎ]aÏ^]Òa\Ð\\Ñ[^Ð`bÒ^bÔ`bÒ]]ÎZ]Ð\]Ï\^ÒljÒ_aÐ``ÒbbÒdmÏ]`Ô\`Ð]_ÒYYÑ_`Ñ[[Ó^\ÒhfÍ_eÒY\Ï\`ÌZ\ÎbnÈ_fÍz‚ÈpuÅuÂs{¿x…Å„‰ÊžÏ”‰Î šÔœ•Ρ¡Ðš’Ѩ£Ô¤”ͤ¢É œÀ€†Áu}¾[]ÁVYÂRTÅTTÂVVÁVZÆXZÈ\aÌZZÌZ_ÍZ]Í\^ÎY]Ê_bË]aÏbfÎbfÎ`hÎacÍ_dÍ_cÉY_Í[]Ë]aË\\ÑZZÐYZÌ__Î\^Í[ZÌZ]ÌY_ÇYYÅV\ÂT_ÀR[¼Q\½S[ºR^¼LV¹KT¸HT¹NY¸UaÆU_Ì`eÒgdÕklÔqnÖsmÕup×toÚulÙxrÚ{uÛzrÛxÝ€tÞ€o݃rßlÞ‚pÞ~jÞ~mÜnÝ}oÞ€lÞ€náiâgâ€lâ€ià|hà~ià|iß|hÞyhÞvfÚxfÚvhØwlØvdØvjØrc×tg×udÕpaÕvdÖsdÕqaØqbãpó¶ŠøÈ’ùÓœúצúÛªûܪýÛ©üÔœóĈזt°RW­W_®OX³SZ¹U]¼Y^¼_a¼VV˜8Jq B\:V?ZBZAY<Z@]@^BbDgGh"Fe#IcDfAcE`=]<]>]=\<^?\<æŠuäˆnå‰kæˆlä…nèŠmè’yê”sê–pé‰læ‚eå}eäw]âw^âu\ßxdâw]âjèŠnæ‰hæˆnå‡mä†pä†réŒrçŠpé„hæ}dàs_Üe\Í]Z¶HO¦<Mœ6Lœ2J 9K¨<L¬=O°@L°BQ²FR²FUµFQ±JX®FP³EM´HO´FM³CN²DL´FL¿FL¹PS¿PVÀNQÂLPÄQVÈUSÇYYÇVWÇYXÊYZÌ\[ÌZYÊ^[Ì[VÌ\YÏ^ZÌ]^Ì^^Ð\^Î^]ÐZZÒ\\Ñ^\Ó\\Ð^`ÑcdÒ\aÏ]^Ð^_Ï[_Ð^`Ó]_Ï^^Ë]_Ð]\ÐabÐb`Ò`bÒ\^Ò^\Ò^]Õ_[ÒX[ÒZZÐ]^Î\bÐirÍivÇr€Æq}Æ~‰Â}ŠÃ}‚¾|ˆÀ~ŠÈ‰ŒÊ––Í’ˆÏ”ϥΡ›Î£›ÎŸœÓ­Ñ¥˜Ö´¦Ù¨˜Ö°§Ú³¢Ó¤šÊ§¥È˜™Àv|¿`h¿WZ¾UX¾VY¿X^ÄV]Ê\_ÈZ`ÈZZÊ\^È]_Ê`dÉehÈdlÉagÌdiÌcdÌ`bÌ\^ÏaeÏZXÍ^^Ð]^Ï[^Î`_É[^Í\^Î^`ÌZ\ÇY^ÉUVÃX^ÁV\ÁNV¼OZ½NZ¼P[¶LX·IV·LX¸P]ÂX`Ì\cÐed×kjÖqjØsnÖqmÕtlÖxpØtl×{xÛzrÜ~pÜ~vÞ€pÞpÞqàqÜ{mÞ~nÞ~ná~kà}mÞjà€lâjägâ€gß{eá|hßzjÞ}fÝzhÝxdØwfÙtfÖvj×tdØvh×rb×paÙr`ÖscÖrbÖsdÕobÖubÚxeë¡wöÀŒøÍ˜úÔ¤úبûÚ¨üÜ©ýÚ§üÏ—ì´Êxa¯NU«KT¶UZ¹U\Â_\¼TVŸ@Nq@X :V<V>X:W>Z:`@`Ae!Ga@f$Id: lena.pnm,v 1.1.2.1 2006/12/02 01:20:05 dgp85 Exp $Jb"Gd"FbE^>[:Z:\;a<^;`<`=æˆqæˆræ…nä†näˆtçŽqì”sì”uë‘qè†häbãt]ßt\Þp^ßn\ßqcáv`ä‚jç‹oèŽmå‹næ‰lçˆqæˆqèŠlè‹nê„iæhÞscÜgXÎZV´FL£:G™2Hœ6F£9I¨:G«>N¯?L°BR·FP²ER±IQ²DN¯DM¯EN³GP´HP¶HO´EN¸FK¾JO¾MNÁNVÁOTÂQVÇTVÈY]ÈWVÊXZÊVRÌWTÌ\YÌZTÎ`_ÍZTÌ\XÍ\YÊ[ZÊ_\Ì\ZÎ[\Ð\[ÑegÐ`bÑ_`Ò__Ò^`Ô^bÔ^^ÔacÒ\\Ò]aÑY^Î]`Ð^]Ò_`Ôa\Óf_Ô]\Ô\\Ó^\Ô\YÑZXÏZ\Ì[fÌivÄw†Ç{„É‚ˆÇ}€Æƒ‡Çƒ†ÀƒÂŠÂ‹Ê“Ò —̘͌”͘‘Ïž˜Õ¦šÔ­¨Ñ¨›Í£žÒ¦›Ò©ŸÐ§–Ѧ”Ò£˜Ö¯¢Û¶§Ú´£Ø³£Ï¥žÄ”—¼pz¼]f»U[¼NWÄWYÇUXÈZ[ÆY[ÆX^È^bÌ`dÈdjËahÌ_eÐ^bÎ`cÌ\_Ï^^ÍZ^ÎZYÎ\_Í\ZÏ\[Ñ[^Ë\^ÎXYËVWÅT_ÆVZÅS[¾W`½SX¾MW¼OZ¼MWµLY°J\·KV¸P\ÄV\Í_fÒfaÓmlÔrlÙtjØsjÖsj×umÕuqÙvlÜzmÚzrÜ{nÞ€sÜnÞ€q߀nÜ~nà€l߀p߀màkÞ|hà~oâ|gâ~gá€iàzfß|hàzhÝvfÞubÜwgÚudØrd×qg×sb×pfÖpfÖpaØpb×p^ÖpfÖn^Ön_×pbÖveß„nð°‚øÆ‘úКøÖ§úÚªüÜ­üàªþئøÉŽâ¡v¾c[²PXºX\¿]]ºXXœ=Lq>[;S:U<Y=Z<Z>Z?^?bDcCcBfCdBdEbA`EZ>X9Z:^8a8]7_=^;æ‡tæ„læ‡kçˆræŠmëpì’pê’lêŠmçhäx`àr\ÝlWÜiZÜm]ÝkYàw^ä‚gèŠlèŒhæoæ‡på‰lèŠoéŽsé‰iê†hå|dár\ÚfWÏWR¸EM¦8Gš2E˜3F 6K§<L©8L²BO°DN³GT´FQ±FL±IR­DR²KO³DM¶CLµGQ´GP·JP¾HN¼HPÁMTÃPRÅRVÉTSËVVÍXWÍZVÆUVÊWTÍZXÐZXÒ]YÐ]ZÏ\VÐYVÌYUÎZZÎ\]Î^\Ð_^Ò_\Ð]]Ô`]ÒZZÑ`aÖ__Ô^^Õ_\Ò`_Ð^aÐ]^Ñ^^Ï\[Ð]^Ò[ZÓ^XÓ]YÑ\`ÒZ\Ð[]Ð[aÌfrÆt‚Ãv€Æ~‚Æ}€Ê†ŠÃz‚¾s|Â|‚ÄzÃ|ƒÊŠŽÒ–ŽÎ™Ì›‘Θ’Ηϣ ÔªÕ§›Ô§˜Ð¥œÑ¬žÍš‘ʔ̟–ЪŸÕ¨”Ó©šÖ³¢×­œÝº©Þ¸¥Ø³¢Ð¥˜Â„ŠºdoºPWÀRXÂSZÃY_ÆX^È[^É\aÈ`dÉ\aÌ[`Ï]`Ð^`Ê\eÊ]cË]`É[]Î^_ÌW[ÎYYËZ^Î^^ÇX`ÆT[ÄVaÉUWÂSX¾T`ÀRX¾OX¸P^·QZ´JX²IV»IV¼MZ¿X`ÎbcÔgeÖnjØoiØxuØsnÕtqÕroØupÚwoÚwrÚxqÛ|wÜzsÝ‚rÞ}qÞ~nÞqß{lÞ{gÞ|là~jß{lß{ià|hÞzhá|hÞxjÝzfÞsdÝweÝscÜreÚtdØpeÖn`ØqeÖo`Öod×ocØp^ÔrdÔsc×scØn\ÕpcÔqdÖudç–qô»†úË’ùÓ¢úاûܬûß®þà®þÖžóÂÖrºYZ¾YZ½XY£GQuA\<R=U >X>V>X=[>Z>`@dDfDbCb>d@`>`@\@\@[>^<`9b:\8Z9]8è„hæˆoç†iêŒsèrìoì’rêŽnè‡håeàsXÞlYÛ`RÚ^RÚeZÛl]äu^ä…gèŠjê‹iç‹mèŠnè‰pé‰lìkèŠpê†eæ€jãrZÜjZÎVP¶FL¤6F—.Cš6I£5J§:K¨<L°?J¬AP±CPµFN²AM±BP¯FL±FN¯FP³EM¹IQ³CL¶EPºJN¼MT¿RZÄVZÃRUÊTWÌVTÌSUÍWVÉZXÌYYÍYXÐZ]Ð[\Ð\YÎ^ZÑZWÎZXÎZ[Ò^ZÏbaÑa`Ð`]Ñ\\Ñ\\Ñ\bÒ]\Ö^`ÔYYÔ\\ÑXYÓ^ZÏUVÑ\\Ð^^Ð^]Ñ^\Ô\\ÐY]Î[cÊanÉ_pÀfxÆy‚È}†¾qÀz„ƆɄŠÀz„½u~¾tyÇ‚…Æ‚ƒÈ‚„ÌŒŒÐ“ŠÉŒ†Ì””ИŒÐœ™Ô¢•УѮ¦Ð¦ Î¤ŸÎ¡šÌ¢Ð ’У™Ô° Ò¦“Ó¬ŸÖ±Ú³¤Ù°¤Ý¼ªß· à¸¢Òª¢Á|‚ºU^¿PVÃUZÂUZÈRWÅ\_Æ\bÈ^hÌZbÍ^dÌ\bËbjÊ[^Ë\cÈZ\Í^bÌ[aÆY`ÊZ\ÊW[ÉY`ÉSYÅX]ÅTYÀR^¿PX½R]ºO[¹QXºPX³JX¯IY·P\»NZÂZ`Ï``ÒhfÙlgÚshÛshÚtk×rlØsnØsnÚvnÜvnÙxtÚzsÛ~xÜ~uÞ~sÞq߀nà|lÛylÞ{nß}mÛ{lÜzfÜvfÝvfÝzfÞvdàxcÞubÜtcÜrbÜp`ÜvhÚsd×ndÖnbÙod×lbØn`ÖocÔse×od×pd×o`ÖnbÔrcÓkbØv`íªzøÄŒúИùبûÛ«ûܯþà¯þÞ¬ýҘÉuf¼\Z§DOz"D\@T?T>XAXD\D`@`DbCcFdEd Eb@b>d@^>W?X>\FbHb=`:_?^9\9`<é„mæ…lçˆpêŒqë“pí–qì‘lêŠhè€eäxZÜmUØcSÖXOÔ[RÕ`YÛo`â{bæƒfê‹léjèŽkê‹nç‹lêuëpëŒpé‡læ‚iâubÚfXÍZTµBI 6J–-F–.D¡4E£5Hª;H°?K¬>M®@L¯AM±DO²@L²DL²FO±ER°BN´FP´IRµIQ¸FO¼IS½MTÂTZÅOQÈTVÊSRËUVÈWVËYVÎUTÎ\\ÌXZÒ\]ÐWWÎZXÑYUÏ[YÎZYÍ`^ÎYZÒ[ZÒZZÒ^^ÑZ\Ï_`Ò]\Ò`cÏ\^Ó\[ÑXZÐYXÐXZÎ]]Ï^`ÊbnÍeoÍpÌpyÅjw¾`k¶dvÃtxË€Äv~¾zƒÅx~Å|~Év{ÇzxÆzzÅ‚ŠÈ‚Æx~Ç‚‡É…Ȇ…ƖʇƒÎ’ŒÍ“Ì•‘Ó Ò¤ŸÔ¨ Ñ¢™Ò¦–Ï¢šÒ©™ÕžÒª¡Ô¯š×§–Ó« ÚµžÝ´¤Ø´¥Ûº®âÀªá»¦Þ¶¦Ìžœ¹jr¼PYÀPU¾T\ÀX`Æ]gÉ[bÆ`iÉ`hÇ^fÌ\bÈZ_ÉZbÌ\`Ï\^ÈY`ÈZ^ÌVZÊX^ÆXZÆUXÂS[ÂRW¾NV½QZ½R\¼NU»R]¸JS´O[³HV·Q^»NVÆY_Ð^_Ôji×poÚndÚshÜvmÙukÙriØtmÙuoÛwoÚyqÙwqØ}xÙ{vÜ|uÝ|mÞ|qÞ}iÛylÝvjÞzgÜxhÜweÜvcÜubÝxcÛwfÜt`ÜthÛraÜrbÚtcÜp`ÙpeÙqcØk`ÖndØm`ÚkXØpbÖo]ÙpbÚp`Øo^Øo^ÖpbÕl^Ôl`á‰fó¶„úÌ•ùÖ®üÚ®ûܬýß®ÿà­ÿÝ©üÌ“ážy²MR~#CX<W@S>U=W;Z?Z@_CdBgCe?cEcAb@cAaBZ@Z?`F`B`B]:\>Z9Z;_<`:æˆoçŠmèpìoí–zì“mê‹mèƒlæzbàrXÚdTÐVKÍSOÎRN×dZÝvhâ~lä†gèŒlìŒléŽiêŽlè‹léŠlêŒnéŠné„hè}`ãvdÜh[ÌVPµCL¡4F—*B”/Fœ2EŸAX¨>M®@O©>M­>L°AN°BK°FS±@I¯CM²DL±?L³@JµJS´JPºFO¹JR¼OT¿NSÄQRÃTWÆTTÇTTÌVTÉXXÉX\ÊVWÊZ\ËZXÅZ\ÌXUÊW\ÇXTÍ]XÌ]^Ì\YÑ^\Î^^ÐZ\Ñ\_Ñ]^Ò]^Ò[ZÑZZÒX]ÍU]ÌalÉZkÍkxÎ~ŒÍ~ˆË~„¾rz¾fm¸Xe¼Ydºix¼hrÄnsÀpxÄrvÄx|ÅrwÈqwÅvzÈ‚ƒÊ}€É„‚ÉxzȂʆ†ÈŒÇˆŠÊ”ŽÎ˜–Ì™‘Ï”‘Í–Ò¤—ҜϗŽÑ¨œÖ§”ϜҬœÙ¨–Ó«¢Ú¸§Ø®žÖ²¦Üº¦Ý¶Ü¶¢Ü¼®Þ¼­à¼¦à¹¥Öµ¨¾~ˆ·T_¹NV¿V_½[dÃV_ÄY`Å^eÉ\dÇV\ÇV[ÆXcÉ[`ÉY^ÇX]ÍZ\ÌX\ÇW\ÃTZÀRX¿R\ÅQWÁNW¾MXÀOUºLV¶MYµGT²FT²IW¸MZ½OVÅR\Î]`ÓfdÖmlØrkÜvnÚulØulØtjØsmÚsmÝtpÙvpØzw×wuÙxsÝ|pÞ}rÝ}nß|nÞzhÝugÝwfÛtbÝxhÜxfÚsbÜr_ÜveÜteÞudÛucÚqdÛp^ÙrfÚpcØpbØpeØn`ØpfÖl\Ùm`Øl^Öl`ÚoaØo^Ùo`ÕsbÔmaÔl\Ùq\ìŸsùÄúÏŸûתûÜ­ýÞ±ÿß®ÿà¬ÿÚ ñ¼ˆ©HP\>RAV@U?XAZAZ?X>bAeDf>d@bBd@eBdD_C^D[@^>aD`>]=\A]?\:_:b9æ‡rèŠmë’xì”ní•vípê†jæ€fãzfÞiZÐXPÆJJ¾EJÇOLØ`XÞrbã|dæ†iêmê‘pêŒkìŽoèŠmémëˆkíŒjê†jèƒgät[Þk\Ð[PµDM¡6H–3G“.G˜5M;N 7J¦=L¨CSªFP­GT¬AL¬AK±AJ®DM­AL²DK±EM´FQ³IS³HR¸KSÁJUÀMSÂLQÆTZÅSTÇUUÆRUÆXZÈZ\ÌUTÉW[ËTXÎWUÌ\_ÎYWÊZZÌVUÍ\[Î[^ÏZXÒ]`ÐZ[Ò]^Ð^\Î[^ÐUXÒX\ÑTZÕelß›ŠÐy€Ñ„Ê}|Ãv{¾ow¾biÀbiÂ\c¾\i¹_n¸dlÀlwÀlvÀnsºfm¿kp¾jrËzxÇqwÅutÈ„È|{Ê…ˆË€~È„…ˆ‚Í“”Ò…Ï’’ÍžšÑ›Ê”ŽÌ˜—Ò¢‘Ô¤—Ò«¡Õ£‘Óž×´¥Ü®—Ö¬™Ø¸¨Ü±–ܰŸÚ·¨ßº¢âº¡Ý´¦Û»°ßÀ«ä¾¦ÝºªÇµguµR_¸Xc¼PXÂS[ÂR\ÀWZÂX_ÉYZÂV^ÅX^ÆX^ÇV\ÆV]ÆX^ÆX]ÄV]ÂT[ÂPTÁPXÂPVÀQWºNX´L\·LW³KU²DR°EQ´KX¼OXÉRWÎ`hÖedØpiÚriÜtnÜvnÚul×tiÙrjÚqjÚwjÜwmÛvnØsmÚvrÜ}qÜ|rÞzkÞ|nß~rÞzlÜtdÚqcÛtdÜqeÚpbÜrbÝr`ÜueÝtcÚvgÜqbÜr`ÜpbÙqeÙpb×pgÙo`Øl`ØpaÚp_Ûn_Øo_×pfÙrcÛo`Ørd×o_Õm^Õk^à}dò±‚ûÅ‘úÒ üبýݰþá³ÿä³ÿÞ£ò¾€‘.CM 8P>R=W?V@\@Z=\>dBhCc@bBbBdE`=]?Z=\B_@g#I_@^BW<^B`?_6d=f:çŠrèrë“pí˜vì’qêŠjç‚håx`ßp]Õ^OÄKM°@J´@JÈUPÖdXÞugä~fæ†dêtìlëŽmêŽjêmêŠlìŒmê‹oë†iè~hãvaÝf[ÎXS¶FO 6J”,D0F™2J›8LŸ6H£:L§=L¬=N©@Nª@Nª?K­AN¬AM¬BI²FM²CL°CL³FO¶EL¸JQ¹LV¼NXÁPVÄQVÄTVÄPRÅTYÆWYÃZ^ÆXZÅTSÍXXÊVUÌZZÏXVÉYZÎZVÐXXÎ[\Ñ[YÐZYÐZ\ÐXZÐXXÎY\ÐXXÎw‚Ïb`Í`dÇaeÈmqÆllÀgj½cj»^jÀbh½\g¼[j¼\h´`r¿gnÁnzÂlp¾nvºfr¹erÂhpÅw¼htÅrxÆy|Ê~}ʈˆÈ„ňŠÌŽŠÐ–ÍŽ†ÍŽ‡Ð˜É“Í ›Ðœ—Ц Ö¬Ñ–Ò²¤×²£Õ¬œÖ± Û¯”Ö¥–ײ¢Ý¸žÚ®™×±¥Ü¼­Þ¹£Ý¸ªÞ¼°àÁ±âÁªÞº¥Õ°¨½‚ˆ¯Xf¶NZ»NXÀPXÀV]ÄT\ÃSZÄT[Å[`ÆV]ÇW[ÆUXÇU_ÆWYÂV[ÀUZ¿TZÃOW¾MS¾PZ¶KW³JY´LW²FS²GU²@J·KW¾KUÇT^Ö^`ÖhfÜlbÜqhÞwjßvnÛtmÚthÙslÚsjÜtnØwrÚvoÚwrÚunÛvnÛ{uÝxkàylÞ}oß}qÜwhÚuiÛrbÚn`ÚnbÝraÝsbÜsbÛvfÚtcÜqaÛsgÚp`ÚrbÚufÚpeÙpcØodÙpbØpbØo^Úp_ØsbÚqaØthØqfÙl_×oaÕpfØsfè–sø¼ŠýОüتþÞ°þâ¶ÿâ¬ýÔÑ|_Z8P>Q=T>W>Z?\@_?bBfBeDdAdCeA`<[<Y>Z>`@d!Db?]<\=X;\9`;b:hAf=éŽmê”ví›sî—rëvê„då€dãw^ÚiXÌQK¶BF¤3C²9EÈRNÕbVÝsbä€fç‡hìŽnêŽhêmèŽléjëŒníŒnìŠmêŠnè}hãv\ÝfZÏWO¶CIž4G+BŽ-C–2F›0E¢4G¤:I¦?N¦?L¦@O¨=J¬CN¬AK¯DJ®CM­BL¯FS±FT·FN´HSµHN¸MV»FK»OVÁRYÇQRÄTWÄS[ÃVYÉSRÈUVÇRUÊZ[ÊWZÇ[]ÈZ\ËXWÊW[Í^_ËZ\ÑZZÎWYÎ[^ÏWUÐXYÎV\Ög_ìšrÊNMÀV[¾_d¿\d¼_c»`e¼X]»]g¼\e¹\f¾`n½^cºbl¾ms¼nvÁlp»ip¸doºhpÄptÀsxÂprÄpwÆtwÆ|~Â~…Át|Ë…†Ë„~Î’‹É…‚ĉŠÌ–’͌ӧ—Ó›ŒÐš–Õ¦˜Ù®ŸÙ± Ö²¥Ú°œÖ¥–Ô¯£Ú²˜Û²ŸÛµ¦Ú¶Þ°–Ú­¢Ú¸®à»¦àº¨Ü¸¬Ú»±Ü¾«â¾ªÛ·¢Ã–™´cm²LX³NX¸NW½NX¾T\ÁYd¼T]ÅU\ÄSXÃTYÅS[ÇSXÂTZ¾S]ÀTY¾Q\½NVÀOV»MX´P_·GT´LX±FS®FT¶FR¼LZÁS\Ï_aÖffÚnhÜtiàvjÞyoÜujÝtgÛsjÛsjÜqiØtnØrjØtnØsnÚupÙtnÚunÞ|kÞ|qÞyiÜxoÚpdÚpbØnaÚndÞo`Ûo^ÜpbÞqaÜvfÞp`ÜoaÙqdÚscÛrdÚpeÚo`Øk`ÛpbÙn^Øl_ØpaÚueÙrfÚse×tjÚrdÖpcÒqe×n`Üykï¤|ýÊ•þצÿß²ÿà­þÕ•ê¥p‚)AL :Q>Q 9U=X>YB^@dCgGfCcBdBhBb@[:Y<X<]@a@c@`BY=Y:\:]:c<g>c9\8ì’pë™xîœrî”mì‹kéƒiåxbßq`Õ`W¿JI¢:J–+B¯>FÇQOÖe\àtaæ~eèŒkéŽnìkêŽlëjçqè‰jì‰kêŠnê…hçzbãrYÞf[ÐVN¸FNœ2E-FŽ)C“.G™4HŸ8M¢>N¥;L«:Gª>L¨@K¯>K¬@M­CO«BQ¬EP®DO®EN²HT´BN¸GM·FR¸DNºNTÀNVÁPSÃQUÀRXÂVVÃQTÅPSÅTXÊ`cÊZ[ÈXXÌ\[ÉZ[ËZ^ÎZYÏVVÑZXÌZZÌZ[ÌXXÌQWÏXZåœ}Îo\ :T¶NY¼\cÀZbº`i¼X[À^e¸X`º`jº[eº\e¸Wb¾biÂjpÁflÃko¼eg¹fp¼jr¾lvÀnuÁkoÆs{Ànw¾x€ÄrtÅz‚Ɔ„ŃƒÄƒˆÈŒˆË‰‰Ò¥˜Ôž”Л•ΣšÔ¤™Ô¦šÖ°£Ø®šÕ£–Ø´¢Ú´£Ù¨”ر¤Û¸¤Þ®—תžØµ¤à¹ Ý¶£Üº­Þ¿°Þ¼¦à»­Ú»¬Ú¼®Úº¨Ýº¡Ô®¡¸t{­N[¯FT´IV´OZ¸U`ºPW¿NS¾RY¼RXÃR[ÁTZÂRXÀT\¾PYÁLV¼OY¸JU¹LY´LZ³KX¸HQ®FR°AQ³FVºNZÅW^Ñ_aÙjfÝmgÞtlâwlàxnàylÞxlÞtfØuqÙrmÖspØtlØqlØrm×pmÖpi×upÙunÞxpÞ{kÞ{nÚrbØphÚlbØn`ÝnaÜneÜp`ÞsdÞtbÛteÚpdØoaÚrfÚodØqaØpeÚo`ÚpbØohÙoaÚqeÙsgÙteÙp`ÚtdÙugÖrf×ufÖteØshâƒmù¾ˆÿÒžÿÛ¥ÿÒ–ï«xŸBHT=N>Q>T@T@V<\Bb?gCf Fd@f EgAhC`BX>Y=]?cBbA^@X:Z?[>`;d>k?d>T2I2ì“rî–wî•wìré…jæ}fâtdÚdVÊTR«<F—*B–*B¨;IÅRMÔbZÝo\ä|`èŒlêŒkì’jëqêŠlêjèŠmìŠlêŠlêƒiè|bâmYÝcUÏUQ¶CK4D)BŽ)B˜2F›6H :K =L¤@N¬<L©BPªCR«@N¬AO©DO«BP«DP¯GT°CL®DP´FN´HPµKT½LS»NU¾PUÁPSÄNP¿OUÅRTÄRRÄVZÄTVÆWYÇV[ÄVZËUWËZYÎZ^ÌVYÉ]_ÐZXÎZZÐZXÐXXÏ\\ÐXVâuXÂRT²IZ½PX¿V_ÄVYÃ^c»V`½Xb¾_iÁei½[h·Yd¸\dºdp¼dnÃilÀkr¸fq·fq½go¾jsÂouÆrvÁjnÄknÅpuÅxvÃx}ÄvyÆ€|ˆ‡Ì‰†Ð’†Ð“‹Ò¤ Ó¢Ó ›Õ¤˜Ö¤Ô¦šÔ¬ Ø¬˜ØªØ¯ Ø°šÞ°ŸÙª¢Ü¹§à´ŸÜ¯œÜ´§ß¸¡áº¢Þ¸¬Û¼²ß²ݼ¬Ú¶¦Ú½³Ü¾µâÁ¬Û¾¨Á–š¬Wc±DT´MX±JU¶GP¹JS·LW½QX¾OWÀQZ¾PXÀOXÂOU¼N[ºLU¶OZ´O]²HX¶JW´JV±HR­ET´GU¹NZÄP[Ò`eØjdßpiÞvnâzqâ{mÞzmßxqÞwlÚtjÙtnØrjÖro×mhÔtmÖnkÔokÔmfÚnhÛrlÝ{mÞzpÝsdÛtjÛpeÙndÜo`Þr`ÞraàsdÞugÜteÛpdÛr`ÛpfÜoaÜqaÛpd×nbØqhÚpgÙpdÚrjÛqhÝtfÚnbÛseÜtdÚukÚugÝxlÛxnßxjó¢~ÿÈ’ÿÌŒï§q£HNY?Q;T>V@U>V<[=\=dAa>d@cBfBgA`AZ@\A]@`BdA_AV=Z@[>\=bBi"Cg!DW9F3D3î•~î”pî“oìŒkç„hçx^ßlYÒZT¸FNš.>*C–0F¬?LÈRNÒc\Þp\ãyaç‰gìŽlì’jêrê‰nêŒiìqìŒné‹mæƒkæ{`álXÜfXÍVQ³EK›/D(CŽ(B“2J›8L¢4G¢;R¢@RªFW«HVªGY­HX©BP­GR¬COªAQ­EP¬DR¬IU³DR´KV·JT¸IT¼NRÁRXÄTY½JPÁMQÃSVÁSXÂUXÂUZÅVZÇUYÆUVÊUZËX[ÊXXÌ\[Ì[\ÐYXÎWZÑZ\ÒXYÏZVÐpg»NR»MU½RZ½KVÂV]ÂW_¿V]½V_½Za¾Z^¿_h¾\e¼\g¼\eÀdmÅlpÃnqÀks¾en¾ku¾jsÄovÆorÄirÃacºktÀt{¼krºjtÈ{Êyż…Њ…Í’ŠÓ—‰ÔšÓ¤—Ø¢ŽÑšÒ­ Ø¥‘Ï –Ó©£Û¯˜Ö£”Ô¦žØ¸«Þ¶£Ü±ŸÛ¸©ßº¥ß±žÛµªÞ¾¯á¾¥àº§Ý»¬ÛÀ²Ý¾¦Þ»ªÜ¼®ßúâóáÁ©Ë¡šªYg¦CUªBP¬HS¯HQ²JS¶JR¼MT¼PWÀRX»NX»PY¹NX¸NZ¶MV³K^´IVµJU³LX¯IY®AN²FTºJXÅR\ÑZ]Ùihßnfßwnâzräznãzjâynß|qÜyrÜwnÚrlØmiÔjlÕlkÔjhÓklÒgd×lhØoiÛwkÝylÝvhÝthÜpbÜpbÞp_ÞreÞofÜsfÞt`ÝtiÜpaÛo`ÙpiÚqbØpfÚpdØoeÛsiÜrcÛrgÜteÚpeßsdÝtgÛtjÜtjÜwiÚujÞznß}pà{nî’uù´}æŽi›<FX<W?WBW>V=X<Z>]>`<d<`@d@cCd?a@Y@ZBcFeDg@bB^EX<]A\@d>n(Jp,ObAI
+â‰}߈‚â†väˆ|âŠ{â†|à†rÞ„uÝ„nÞŠvß‚kÞ„jÜ„pà€gÝ‚tÞsà‚jà„râŠvæŠrèŽrè’wì—zè—yî•vê”xévè†tàwfØvvÊZa´P_¨@Tœ>\œ=Y¤EX¦GXªJZ®IZ²J\²NW±JV¯LV°OZ²LX²LX´NX²LV²NZ°NZ®JS´JT´OV¸SY¼TZÂXZÂTXÂZYÄ^ZÄ[\Ê`\Ê^\Ë\ZÌf_Îb^ÎebÌabËbbËkhÍffÎd`Ìb]Îb`Ê`^Êg_Ëd^Ëd`Ëa^ÎhaÎhjÑb^ÐebÐfaÐgfÒebÔe`ÒddÒfbÒgdÎheÎf`Ïd^ÐffÐjfÌfeÎfbÎjfÐgbÓidÑibÐicÎhjÒheÊghÊknÎhlÌffËe_ÇddÌf^Îe]ÍcbÊcbÈjhÍibÍdaÎddÎdbÒb\Ðe`ÑhbÒf`Ðg`ÐjdÑd\ÏfdÎ``ÎjjÒplÍgcÌd_ÈbbÒe`Êd`ÎfgÌb^Çb`Îe`È`eÎieÈbcÈc^Êb`ÌcbÈccÎabËadÈbbÇbdÈ^^ÉbcÄbaÀ\`Â[dÀZ`»Za´X_°T[±PX¨HV¶LP¾V\È`]ÑlbÔqlÖzlÙtÜ„pÞˆnÞŠrÚŽvÝ‚nÜzgÜ~jÚ€jÜlÞ€nÜ€rÞ‚rÝ€pÞ†xÞ‚n߀hÞ€jÜ~j߀eÞ€lÞfà}fÝ‚jÞhÜ€eÞ„hÜ„m܆nÝ‚jÞ†q݈qÝ„pÜ‚hØ„nä”nï¹…ôÈøÎ–øÐžúÔ£üÔœúÔŸôÈ⪀Ärj§M\¥HX¨PZ®OZµX\¹Z\¶Za¼^`ºac¼X\¼^^¾ZZ½^b»dhº[cº\aÃZ[À[^ÃZZÃZ^¾^^Ã]`Â_^Á`cÄ`bÀ^_Å^]¼V\Á`cÂ`bÄbhÁ``Æ[[ÂbbÄa`¿[]¼V\¼V\ºVZ¾\bÚ{væ’€è”zÒrdâ‰}߈‚â†väˆ|âŠ{â†|à†rÞ„uÝ„nÞŠvß‚kÞ„jÜ„pà€gÝ‚tÞsà‚jà„râŠvæŠrèŽrè’wì—zè—yî•vê”xévè†tàwfØvvÊZa´P_¨@Tœ>\œ=Y¤EX¦GXªJZ®IZ²J\²NW±JV¯LV°OZ²LX²LX´NX²LV²NZ°NZ®JS´JT´OV¸SY¼TZÂXZÂTXÂZYÄ^ZÄ[\Ê`\Ê^\Ë\ZÌf_Îb^ÎebÌabËbbËkhÍffÎd`Ìb]Îb`Ê`^Êg_Ëd^Ëd`Ëa^ÎhaÎhjÑb^ÐebÐfaÐgfÒebÔe`ÒddÒfbÒgdÎheÎf`Ïd^ÐffÐjfÌfeÎfbÎjfÐgbÓidÑibÐicÎhjÒheÊghÊknÎhlÌffËe_ÇddÌf^Îe]ÍcbÊcbÈjhÍibÍdaÎddÎdbÒb\Ðe`ÑhbÒf`Ðg`ÐjdÑd\ÏfdÎ``ÎjjÒplÍgcÌd_ÈbbÒe`Êd`ÎfgÌb^Çb`Îe`È`eÎieÈbcÈc^Êb`ÌcbÈccÎabËadÈbbÇbdÈ^^ÉbcÄbaÀ\`Â[dÀZ`»Za´X_°T[±PX¨HV¶LP¾V\È`]ÑlbÔqlÖzlÙtÜ„pÞˆnÞŠrÚŽvÝ‚nÜzgÜ~jÚ€jÜlÞ€nÜ€rÞ‚rÝ€pÞ†xÞ‚n߀hÞ€jÜ~j߀eÞ€lÞfà}fÝ‚jÞhÜ€eÞ„hÜ„m܆nÝ‚jÞ†q݈qÝ„pÜ‚hØ„nä”nï¹…ôÈøÎ–øÐžúÔ£üÔœúÔŸôÈ⪀Ärj§M\¥HX¨PZ®OZµX\¹Z\¶Za¼^`ºac¼X\¼^^¾ZZ½^b»dhº[cº\aÃZ[À[^ÃZZÃZ^¾^^Ã]`Â_^Á`cÄ`bÀ^_Å^]¼V\Á`cÂ`bÄbhÁ``Æ[[ÂbbÄa`¿[]¼V\¼V\ºVZ¾\bÚ{væ’€è”zÒrdâŠ|à†yâ†vä†xâˆvâ„vàƒnà‚oß„m߆p߀hàhÞ„oà€gÝ€tÞ‚nß‚lÞnáˆtæ‹qçrè“yë—zë—yî–vì”vêuç„oßwh×omÈX_´O^§AW>Yž<V¤BV¦FZªFY®JZ°JZ²KV±JT®JT°LX³IS²JV³LW±JT²LX²LW¯JR³KU²PW¸QX¼U[ÂWYÃVZÂZXÄ\ZÆ\]Ê][Ê^^Ë[[Êa^Ïc^ÎdbËddËa^ÌheËccÎfbÍc^Ía`Ëa`ÊfcÌd`Íb`Ìb_ÏieÎgjÐd_ÐgdÐhdÒidÓfaÔeaÓfbÒfbÒfbÏidÐd`Ïc_ÐecÐgbÎdbÏfcÐhbÐgaÒhaÑfbÏhdÎhfÒgaËgjÍhiÍjjËebÌb`ÉbaÌe^Ðd]ÎcaÌb`ÈfdÍjaÊb_ÌddÍc_Ña\ÍfbÐfaÐfaÏf^ÐgbÐe^Ðd`Îb_ÌhhÒjiÎhdÌdaÇbaÐd_Ìc_ÌccÍd_Éa`ÍdaÉacËhiÈ^`Èa^ÉccÊdeÉa`ÎbcËceÈ`bÇbdÈ``Ë`aÄ`aÁ\_Â[bÀ\`ºY`µW^³TZ°OY¨JVµJP½TXÇ_^ÏjbÔpl×ylÙ}rÝ‚rÞ‡uߊrÛŠs݃mÜ|jÝhÜ~kÜmÜ}kÜ~oÞ‚pÜ€mÝ‚pÞƒoà€h߀hÝjÞ~fÞ~lÞ€hß~iÞ€hÞ„iÜdÞƒhÞ‚i܆o܃jÝ„qÞ†nÞ„pÜiÙlâ‘oôÅ÷ΘùМúÔ¡üÔúÖžö˔求Êzm¨NX¥HXªLV®Q\³X]¸Y\¹Y\½\^½``¼Z]»]]¾\[¼^b¼`eº]a¸[`¿[\¿Y\ÃZYÄ\]¿_`Ä^]Ä^^À_aÄa`Á`_Ä^\½WZÂ_aÁ^aÅbdÄ_`Ç]ZÂbbÄ`^À\\¾U\¾V\¼Z\À_bØtlÞ…vÚ}l¶WZâ†xà†qâ†vä‚nâ‡vâ†tâ€eà}lànà€ià€há~gÞ‚kà€fß|jÞ‚kß„nÞ€gä„næŒrévì’tì–|ì–xí–yì’sënæ„gÞxiÔfbÈZ\µL[¨<UŸ7S›;T¢<S§>T¬@T°KZ°LY°FS±FQ²EP±IV®FR°GS±JV²HOµFN²IT°GO³KV¶LRºOR¼VXÀTXÄWYÆ\\È_ZÊ\VÉ^ZÊZUÌZXÍ_\Ðb\Îa[ÌecÏ`\Îb_ËcbÐa^Ë`aÏbbÑf`Ðd_Íc]Ìc`Ïb]Òc`Ïb\Òc\ÐfgÐfdÑfbÒf`Òb^ÕebÔe`Ód^Ôa[Ñf^Òb^ÐabÎcdÎc_Ñc^ÑfcÎfdÎdaÏedÎfdÐc^Ïb`ÌdhËknÌdfËmjÊbbÍgbÊb`Îd`Î`ZËc`ËjfÌieËbbÊe`Í^XÎd\Îd^ÎgdÓd^Îh`Íb`Ðe`Ïa]ÐfbÐd^ÐffÍedÐd`Îa\Ë_\Ç`cÌ`^ÉfhÌ^]Ëb`Éa`Êa_Ê_^ÅbeÎa\ÎabËcaÌbaÌabÉ`^ÊbdÌ_\È^^Æ^`Æ[]ÁZ^¼\f¼W^¹T[¶RZ²LT«KX¬EPºUXÄ\^Èe`ÓlgÔvnØ{nÛrÛ†pÞˆt߈tÞ„mÞ‚oÞ~gÞ}gÜoÜ|gÞ€nÜ€nÜiÝ‚nß‚là€fßißfßeÞ~cà€ià‚hÝ€j߀fÞ}dÞeÞ‚gÝ‚iÜ‚lÝ„mÜ„rÞ‚kÝ‚jÚiÛhè¢xñ¾Š÷ÊøÐšúÒ›ûÔžüÖžûÒ•òÉߞs¸d_£HX¦JW«P]²V]¸V[¼[]½TWº[^»Z]½ZZ¼`^ÀZ^¾`a¿\^º^bº_d½]^¾^\Âa[Á__Æ_[À`_Á^]Ã]\Â\^Å\ZÀ^^¿[`Ä^^Æ``Ç]bÇ\[ÄbdÇ`\Ä_`Á[\Å[]Å`cÅb`¹VZœET~,KfEà‚ià…páƒrâ‚nâ…tâƒrà„kã€lâ€kà„nà‚jâiÞnß~mÝ~hà‚lÞ~iâƒjå‰mçŽré“rì“wì”sì–rî•ní‘pêŒlå€dÞtfÔjaÉWZ¸NX¨=Rž:Q¢8N¤:O¦@R­DT®DR²DPµHSµFP²DN³LW¯GR²KR²HR²GO²HN²HR°JT³LU³PY´OX»QY»VZÃUWÅZ]ÃYWÅ]]Ê^YÈ^]Ê]XÈa^Ì]]Í`^Ê_[Ðd]Ìc_Ìb`Íb^Íd_Íd`Îa^Îb]Îb^Ìd^Íb\Ðb^Îf_ÐbaÏc`ÏfaÐgbÒfaÓh^ÒhaÓd^Ñb_ÒgbÏhaÒdbÎb`ÐkhÑedÏdaÐfbÐdbÍa`ÑefÏcaÐd`ÏbfÌ`_Ë`bÒdbÎb^ËgfÌbaË`\Í^\Í`]ÉfbÌgdËhcÎedÎ^VÎ_[Ìb\Ëe_ÎdcÐb^Óa]Ðc`Ðb[Ïb_Òb\ÎcaÐd^ÐfbÌecÏ`\Ða^Êb`Í`\ËbbÊ]]Ëb]Ë`^Ì`]Ê\\È^`Í^^É]^ÈbaÎa_Ê_\Ì`[Ëb`Ç[[É^]Ç]]È_^Æ\^¼Y_¼Ya¹TX¸PX·QS³LU¬HT±JU¼SYÂ]^ÎffÑql×xpÚ{nÜ‚qÞ„tߊuß…rß‚nÝ‚pÞ€jÝ~jÞƒká„lß‚iàjÞ„mßiàjá„kàƒgâ‚eßjßg߀jà‚jß}eÞjß‚jÞƒjÜ‚lÜlÝnÛmÜlÜkÚhÚ~mÞ‰n쮀õÂŒöÌ™øÐšûÓžúÓ›üÔ™øÍ’ë·~Єl¬U[¨LY¬NU¯S\¸SZ¹XZºZ]¼\^¼Z_»Z\º]^¾[^¼]a¾\aÀ\]¾X[ÀZ`Á\^Â^^Â`^Ä[XÄ_^ÁZ\Ã_[Ã\_Ä^ZÆ]\Ä]^Ä`\Æ`cÆ``Å`]Ã`_Æa]ÈbbÆbdÉ_^Ä_\°NTŒ/Id@\B\Aàƒlà†nä‚iázká…oâƒká‚lâƒkä‚nàná„kâiß~hàhâ‚làbà‚hâ„jæŠjèŽnê’oë“qì–sì•oî”nìhèŽmå}eÞo^Õf]É\[µKT¨;OŸ8Q8P¥<P©@S¬BR®@P°HS´CN³GQ´FP±GT±IO´IR´DM±GP³IQ°DO°JR´KS¶OV¸OS½QT»VZÀW[Â[_Ä]`Æ\^È[VÊ^ZÎ[WÌb\Ï^ZËb_Í_ZÌa^Î`\Ïa^Í_ZÊfdÐd^Ïd`Ðe_Î`]Ïc\ÎaZÐ`]Ðe]Ð`[ÐdbÒfbÐfbÓb^Ôb[ÒdaÓd`ÒebÔd^ÐcaÐ_\ÑbbÐfbÓb^Òd`Ôd_Ñ`]Îc^ÐfaÎbbÑc\Ïc`ËcbÐa^ÐfdÍdbÎb`Ìb`ÍcbÏ`\Îa^Ìa^Ï`^ÈfcÏb^ÌcZÌc]ÍbaÎb\ÍdaÏcaÐhdÏc]Íd`Ïa]Îa_Î`_Î`[Ïb_Íd_Ðd_Ìc^ÌbbÑaZÌ`]Ì`]Êa^ÊbfÌb]Í``Èa_Ì_^ÊaaÊ^]Ì`dÌd`Ì`_Ìa]Èa`ÈbaÈ`]Ä^_À\`¼V\¿YbºTZ·U`´NV²NX¯LY®HV±NX¾X^ÈegÐjfÖsoÚzrÜ~tß„vàˆuà†rá„oßlÞ‚pßjßläƒiá†lá„mâ†oájâƒlá„jáƒlßj߀ià‚jà€hà†jàkà~fà€gßlÚ}aÝnÚlÚƒlÚhÛ€fÚ‚gÚ|iØkä—tð¹„öÆ’ùΘúМûÔšþÖœûÓ˜õÆŒä¤uÀlc¬JR¬IU«LU²RX³SZ¼VXÀ\]½ZZºY^»^a¾ZZ¾]^½Y\º\]¼Y_½ZZ½XZ¾\\¿\\Ã^^½]b¿]^Ä^\Ä\\Á^\Æ\\Â^^Ä^_È^\Í_\É\\Æ^`ÈdcÎfbËhbÃ_]®HO…,Fe@\@ZAZBäƒnâ‚pâ‚kâƒná„nâƒjâ€hâƒlâ‚jà‚qâ…lâkà€j߀iájáhãƒjä‹qèŒnè’rç”pé“tê’të“kínêŽhç‹hâ~gÝp\Ôh]ÉVT²JRª?Qœ7N :O¢=O¨<N¬BR°DQ±IV±GR³LX±KV°MV±NV³FN°DO±IP²CL±FO±DOµJR¸RVºNW¾RRÁWVÃVZÁVYÄZ^ÄX[È\ZË\YÍ\XÌ]YÐ]VÎ[XÍ^XÑb`Ì``Ðb_Îd_ÐebÑd`Òc`Îb^ÏbaÎb`Ía\Ñc\Îd`Ï`\ÏbcÏgcÐb\Ôb^Ód^ÓgdÔg]Öc^Ôb\Ðb\ÐfcÑddÐd`Óc`Ób]Ô_]Ñd_Î`aÐdcÎ`cÒc_Òb_ÑeaÒe`ÑdaÎdcÐd`Îb^Ï`^Îb_Ð_\Íb^ÏcaÍc`Òc`Ì_[Î`ZÎebÐb]ÐhdÒhdÒhaÑddÏfbÎb`ÎebÏb^Îb]Îd`Íb_Îb^ÐfbÌdfÎa\Èb`Î_ZÍcaÌb`ÉbaË^]Ìb`Ì__Ëc`Æ^\È]^Ì`^Ê`_É_^Ë`^ÌddÈ__Ã]bÅ\`À\`ÀZ^¹V`µPZ´PX±SZ²PZ®IT©HW·S\Â_hÏkiÔqnÚvlÛ}tàmá‡vâˆsâ‡sà„má„mß…lÞ‚oã†ná‡lâˆmåˆoä‰kä†pâ„pâ…jã‚fà‚là‚jà…gà‚ká‚fÞ€hàhÞ~dÜ‚jÜ€jÜ~jÜ‚oÜ€fÚ€jÚ‚mØ|hÖ~kÜ„lê©|óÀ‹øÊ’ùЛûÔžüÕœüÖžúјð»ˆÖr´WY¨LX¨M[¯T\±TZºTX¼X]¼Y_¼X\¼\_½\]ÂZZ¾\^¾[]ÀZ\ÁX[¼^c½[[¿^aÀ[ZÃ]\ÂZYÄ\]Ã\\Â\\Ã[\Æa^Ê`[Ç\[Æ`aÇ^`È^^ÌhcÏgcÇ]Y²OV†,Gb$HY@X=Z@\>ä„pâ„nâ‚jã‚eß„nâƒhâ‚lâjã‚mâ‚jâ€gá€jà€gÞ€jáiâ„iåˆpåŽpçqè“rç“vé“rê’nênêŽmæŒoç„fä~hÝr^×bVÊX\¶NW¦>Rœ<Qž<R£<M§?O­FT±CN³FSµIRµJU±KT²JU´JR³HO²CP°IP²KP±BK°DM´JQ¶MV¹OV¾PQ¾TWÁTZÆVUÄ[aÅ^\Ê^\É\YÉ]YÍb[Ì^XÎ^YÌb^Î^ZÍ^\Îb]Îd`Ìc`Ða^Ðd\Ïb^Ða`Ða^Ï_\Óc\Îd`Ðc]Ñc_Ðb^Òb^ÒaZÓheÖb`Ôc]Òb`Ñb[ÐcbÒd`ÑdbÒfeÖc^Ò`\Ñ``ÏfdÏdeÒfdÐcbÐecÒa`Ïc_ÏddÏdaÐc`Ñc\Îd_Ðb^Òb\Îc`Ïd]ÍdaÌb`Ïc`Ï_ZÎc]Îe_Ïb[Ðd^ÓhaÓd_ÒgfÎddÏb]ÐgdÏb]Î`^ÎddÎd`Îb_ÎaaÌcbÎc`ÉbcÍa^Í`\Ê`\Ë_]Ì`^Ê_`Î`bÊbcÊ`aÌ`_Îb^Ìa`Ë``Ìe_ËadÈ^cÄ^bÆ^`Â\aÁX^¼WY¶R]·T]±Vc±N[­KY«JX²NZ¼VaÊehÖpkØvrÜ|qÝsÞ…tâŠpâˆráŠvãˆnàˆtá…rä‡täˆnåŠpæ‰påŒoè‡jã…ká„kâƒgá€lâ‚hà‚hàhâ~fâ‚fá‚fà‚hÝ~hÜ|jÜ|hÙ€kÙ€pÜ€lÚ€oØ‚pØ~jØyhä“qñ¶€øÄú͘úÒœüÕŸüÖüÕŸ÷ʓ簀È{i¬MX­MY­MU´NW¶OUºZ[¸T\·VZ¼\^½Y[¾ZYÂ`]À[[¿YX½\]¾Z\À\`¿\b¿Z^Ã\\Á]`Ã^]Ä_`Æ_^Â]^Æ^^Å^^Å`ZÊcdÍdcÌecÎk`ÄZ\¨EQ&Ea?\HZBZ<\B\Bã‚pà‚máƒmágâƒlä‚gâ‚oâ‚hâ€gã‚kâ‚jãjà~fÞ~mâ€jãŠtæŠnætè’påqç‘pêpêlêŽmêŽnç‰mæ„gà|gÝo\Ôf\ÈWY¶HR¦<LŸ7L 6J¢=O¨:J­FR²GQ°@L·KR´HO´HRµMV±HT²GT°FQ´JT²DM´DN±DKµEN·MP¼NQÀQUÁRSÅTSÇXVÈZ[Æ\bÇ]ZË\YË]ZÎ^ZÏ`\Ï_\Í_[ÌeaÌ`\Ða[Ðd\Îb^Óa[Òb^Òc^Ñb^ÎfaÒa^Ð`ZÐc_Óc`Òf_ÐfdÑd^Òc^ÑgeÒfbÔe`ÓkhÒegÒfcÔa]Òd^Ôf\ÔefÑd^Õa_Ò``ÒfcÐecÑcbÌa_ÐedÑgdÑffÐhdÒecÒb^ÒffÑebÑ`\Í_\Ï`ZÎf]Ñd_Ïc`ÌbaÌ`]Ðb]Ðc^Óf]ÒifÒfcÕjfÓe^ÐcaÐd`Îb\ÎebÎc^Ðc`Òa_Ðd\Íc`Î_\Ì`\ÏbaÎ`[Ì`_Ê`]Î^ZÌ[^Î_^Ì_^ÎbbÎaaÉbcÎ``ËbdÎ`^ÎbcËb`Æ_`À`bÃY\ÃZ]¾TX¿QV¹T[¶Zc´MX²OWªJ\®HW¹S^Á^hÐooÖvpØwpÜ}qÜ„wà…pá‰tâŽsâŠsâ†tã†lå†påŠpäŒuã‰lãŠqä‰qä†mâ„nâ…oâŠnâ†jáƒnà‚láfâgá}bàhÞ„rÝ|eÚjÚ|lÛ€mÚ}lØ~mÚ~hØ}i×{iÞ~hé¥{ô¿ˆúÊ‘úÑžûÓœüÖ¢üÖ ûÒœóÃŽážvºb`¦JX­LV¬NZ¶PWºX\»TZ¼V[½Z_ÀY\¾[[Ä[ZÀZ[¾[]À_\½[\¿_a¾]_¿^^ÂabÂ_bÂ\\ÀceÅa^Ê`[Éb^Ìb`Îb\Ðd`ÒhbÏfeÃ\[¦@Ly!B^>W>X<ZBY>[9_@âlà‚là„sâhâ„jâiä„hä†kä†kâ†mâiàƒpà€màlá…pä‰påråoænè‘qæ‘pèŽpèsç‰jèŽuèˆoä‚dâ{jÝreÖjeÆ^a¶Q\¦@Sœ8MŸ9L¤?P©@M®DM²CN±BN¶FP´GR´LT±IW´FP³HT°JT´FO±DN¯JS±DL¶KS¹NR»QW¼UZÁSWÀY_ÅXXÂY\ÈWZÆ^[Ê\\ÊYVÌ`]Í`\Ï^`Ð`[Ða_Ñ^\Ða\Òd\ÎdbÐc_Ðc]ÏfdÒd`ÑfcÐa^Ïb_ÎdaÒa]Ñb`Òc`Ô`[ÑaaÑdbÒfbÔd_Òd_Òf`Òc_Ôb^Òb^ÒdaÔc\Òb\ÓcaÒ^[ÐbcÓjiÒdbÔb^ÐdbÑcbÑabÎaaÎdbÑdaÓgeÏa`ÎdfÌbeÎ`bÌfbÌgbÍf`Ì_]Í_^Ðb]Ðd]ÐgaÑgfÐigÒjfÐgdÑdcÐfbÎdaÌfcÐd`Ðb_ÎgfÓfbÌ`^Ìa^Î\[Ía`ÎcdÌcbÎdeÍ_ZÌ`^Ì^bÍ_`Ì`\ÎbbÐcaÍadÌabÊ\ZÏ__ÊaaÃ^dÀbgÂ^d¿Z`¾VZ¾TY»S\¶P[³NX³NX®HV­FX³Q^¼[gËfgÓol×xqÛ~uÜ‚uâ…tã‰râŒxãˆväŠwãŠoã†oäŠqã‹räŽuæˆmåŒmå‹qã…jã„má…jã†oä†ná‚pâ‚hàkà€dá‚jÝlÝ~lÜ~jÚlÝ}jÙ€pØlÙnØ~iØzeØxf߉jð°øÅŠúΕûÓ ûÔžüÖŸýÖøÌ“íµ„Ð…l«NXªISªM\°NVµTZ·V^ºTZ¼X_¾Z\Ä\ZÀ_`¾\`Ä_[À``¾\]À]`¼^`¾bbÀ]^Â__Â^^Äb^ÆbdÌ^]Ìb`ÐfbÐg^ÒgdÒiaÄZ[¤>Lu$CZ<V@YBZC^D\?\>`;â‚jà‚oâ‚nâláƒlæ‚jâ…mä„kä…lãƒlà~nâ‚nànà‚ná†oãŒqætæ‘oèŒpæ‘ränæoåpåŠkæ‰lç‰oç‚dä|fÞqbÕhbÈ^^´V\¤BRž=O9N¥=J¨>J®BPµFP²FO³OWµIRµFN´KQ°HP°IQ®CO°DL±KP°EL³EK³FR·OX¼OV¼RU¿QPÄUUÃVVÆWVÆZYË\YÈZWÌ\VÈ\\Ì\XÍ_^Ìa[Í`^Ïa`Ña[ÎcbÌ`_Ð_]ÎefÐ_[Ðc`Ñb`ÎdaÒb`ÍdcÐbZÏabÑc`Ñd\Ða`Ña]Òc`Ôd`Ôc^Ð`ZÑaZÔc`Ò`_ÐbaÒbaÒd_ÐcbÐaaÑeeÔc`Ò`]Ò`]Ô_\ÒecÓfgÎbbÏa`ÎacÏbbÎb`ÌjfÌbbÎe`Îc`ÌcaÍbbÎ^\Í`ZÌb`Îa]ÌcaÑedÒghÐkmÑooÑefÎdeÎb^ÏfdÐb_Ìb`ÍbaÑfcÌ`ZÌa`Ì]_Ðb[Ì_`Ë`]Î``Ð`\Ê\]ÌZ[Ê``Ë`^Î^\Ï`^Ì``Í_^Ì_\Ï_^Ê^ZÊ^`Â\`À]h¿\dÀelÂV\ºPX¶T\³LZ²JX°NY®FT´OY¸V^ÌecÑok×ztÜznÜsß„pàŠvâŒyäŠvåvä‰pä†oá‰täŠxä‰rãnäˆrä‰pâˆoäƒlà„nâ‚pâ„oâ„râ€fá‚sà‚jÞƒpÝ}kÜ~nÜ~lÛjÜ€jÚoÙlØ}oÚ|kØ}lÚ{kÙyeæœt󻇸ɒúÏšúÓ ûÖ üؤüÓ˜õÆŒä¦w»jbªLT°R[®NU¸T[µPW¹X^»X\»X\¾Z\¼\`À`aÀZ^½[]¼\_¼`e¼Z^¿^`¾aeÂhjÄabÈabÊb_ÊfeÍedÑhgÒigÒlfÆ\]£?Nx#D[AR@ZFXFX@\CZB]?aAâƒqà‚lâ~iâ‚lâ„mä‚iäƒnä„mã†râƒlâƒnà„màjâ€iã„mæŠtç‘nå“tçtä‹nåŽlæpäŒpäŠlå†jä‰ræ‚hâ{hÚwhÖheÉ`d´OZ¥@Rœ8N;N¥?O«AK°AL±DN°GP²QX³DM´FO²DN²EL²HN²GN±HN±EL±IP²GN¶HPµLQ¹PT½NQ¿UU¿SVÄZYÂWXÅWVÉZXÌZVÎ\WÈ\\Ë`\Ð_]Î`[Îc^Ñb[Ð`YÎc_Î`\ÎccÎc_Ðc`Î`\Î`bÍb[Ð`^Íb`Ò`ZÒc_ÐdbÐb]Îb]Òc]ÒdbÓa^ÑcfÐ`]Òc]Ñ`[Îb_Ï^ZÔc^Ñ_ZÑb^ÒecÐ^^Ób^Òd`Ò\XÒ_[Ðb`Ñ^]Í]]Î`\Ïb^Ìa^Ð``Ð\[Ïb^Ðc]Íb^Ì``Ëc`Í^\Ì`\Î_YÍbbÑfdÑbbÏedÏfdÎffÍbbÐc`ËbcÍa`Îb`ËdbÐb`Ðb]Ìe`ËaaÌa_Î`[ÌddÌ[YÊ\_Ë]\Ë\]Í^ZÌ`^Ì^ZÌ`ZÍ\]Ð^\ÎZ\Ï\ZÏa_Ê`\Ë]]Â\`Â[`À[b¿Y]¾X`¾RV¶QZ°PZ²S\¯JW«JZ®O[¶P[Æ`dÐjiÖxpÚzvÜ€xÝ„tàˆyâ‰vãŠwãŠxä‡näŠrã‡máˆpá‡sátä‡näˆkâŠoá‰qàƒgà€mâ‚jâ‚jâ€hàmÝhÝlÝ~jÛ€lÜ|kÛ€jÚ}jÛ~lÛ|iØ{kØ~k×~lØveÔvfÜ„jì¬|õÉøÌ’ùÒ›ûÔžüÕžû×¢úҗf֌i³TW¬JS°PU´PZ´RV¹V[»Y\ºVX¼V\¾UXÀ\\À_]¾[^¾\]ÀWZ¾\`ÀZ\ÁadÂbcÃfiÆdhÇddÌedÎgdÒhiÓldÊ\[ >OnA_IV@XEZA\ LZ?]>\>b<c@â‚hßlànâƒtä†qä…jå…mä„lã‡mãlàƒrâ„oà‚qâ†päŠsçtçvæsæ’oårã‹qåŠsä‹rá„kåˆlæ‡læ„jã}dÞtcÖh\ÊZZ¸LT¦@Nž6I5H¥>Mª<I°=J¯BN¯JR¶JR´HP²HR³CO±JR³JP±FL´FK°EL²EM´HN¸LP¹MP¸PU¾LR¾QSÃWXÅZYÆZWÈWUÈZXÈYTÌ`\Ë_\Ï_[Ð`^ÍZVÌ^\Ìc]Ïc_Ò`[Îc_Ð^_Ð_ZÐb^Òb_Ì]^Î``Ð`^Î`^Ñ_\Ñ`YÎb`Ò`ZÐ^YÓd_ÔfdÖe`Ô_\Òa\Ó`YÒ`ZÐ``Ð`\Òb`ÐfhÑgfÓdaÒa_Òa\Ó^\Õ^WÒ_ZÑ]XÒZVÐ^[Ï^[ÐZWÒ]WÍ]^Ì\^Î^]Î]YÎ^ZÍ`ZÌ^[Î^ZÌ`]Ð\WÌ][ÐaaÍ`_Ïb`ÍdiÎdbÒcbÒb`ÎcaÍbaÑc_ÏcbÐd_Ï_\Î`\Î^\Î\ZÎ^ZÎb^Î`XÍ\[Í_\Í\YÌ\[Ì^^Ê_\Î_\Î^[Î\ZÌ[\Í\XÎ``Î`_É\[Æ\aÂ^dÂZbÂ_fÀV]ºQ\µNW²N[°NW®JV®L\±T`·YhÆafÎjlÔtrÛ{tÜ~xß…yà‰|â‹vâ‹xâ‰xãŒtäŽuâ†pá†ràˆrâ‰nâ‡lâˆnáˆkâˆoã…ißjàlà„jájá‚ißoà‚lÞ~hÜlÞ~mÚ€kÛ}kÜ}jÛlÚ}lÙ|jØ|i×zmÖxkÖydã–qòº†øÇ’úКúÔžûÖ¢ûØ¡üÖ÷ÊŽç°~Çw`¨JU­KS°OX±TW¶X^¼]]¿ZYÁ\]½Z]Á\ZÄ^ZÀ[]À\Y¿Z]¿ZZ½Y\¼]cÄbfÃ]_ÅcbÉdfÐdhÒifÒjgÈ\_¤<Nr#Gf4XWDV>W=X<Z=X:`;_?f?f@â€fß‚pâ‚oäjä„næ…mæ…iäƒiä…mâ†râ‚nâ„má„nåŠpærètérç‘sçræoå‰iä‡pâˆnàˆqä‡jæˆpæ‡nã~gàt^Ùg[ÉTQ´FL¨7FŸ8Lš0Gž6I¨<L¯BM°DN°HN¶EN´GPµHQ²LV°JT°IT°DN¯FP²FQ´DL¶GN¸KO¸LP¹JN¼QW¿STÁX\ÆYXÄUUÈZ\ÊZVÇ^\ÌXYÈabÍ^[Îb_Í^\Ë]aÌ^YÏ^_Ð`ZÍbcÍ^aÏ^ZÎ`^Ð``Î`eÏbcÑb_ÎcbÐaaÐc_Ñ`\Ò^XÏ\ZÐaZÏ_`Ó`_Ó`]Ôb^Ò^ZÑ]ZÑ`\ÒdbÑcdÐdlÕhfÒgfÒebÒ`aÕ^ZÒXXÑYVÑ[WÎZZÏZZÎZWÎ]WÎ\XÎ`\Ì`bÐ^[Í`[Ì\_Ê\ZÍ_\Ê`]É^]Ê^[ÈbaÌZXÎ`bÌ]^ÌbbÏfeÏcdÐcbÐaaÏdbÒddÎcbÌfcÌ_ZÌ_]Í^ZÌ^\Ì^[Ì__Ì^`Ê][ËabË^_Î]WË_`Î`^Ë^]Î`XÍ\\Î]ZÎb`Í^_É^]È^`Ä]^ÀY`Ã\_Ã^a¾^dÀR\¶MX¸NW´LS±JQ±JY¶P^¹WbÃ[fÑfjÖolÖutÜ€xà†xâ…{â‡zâŠuâ‰uáŠwäˆtâ‡sá†mà†qá‡pâ…mà†lá‡hãˆhâ‡kÞƒlâƒlß„ná‚jâƒkÞ„mßjÞ€lÜ~lÝmÛmÜlÞhØ€mÛ|jÙ}mÚ~kÖwhÖzlÕvhÜ€dê«zö‹ù͘úÒ™ûÕŸúØ¥üÛ üÔ™ò‰ڜw´\Z¬JP²NT³RW´V[¶ST¾ac¼^cÀ`aÄY^Â]^Â^^¿Z]¿\\¿V\Àab½^cÃ\\Á_bÆbbÎd`ÒheÐhhÊ^X¢=MsAYA\FYDS:U7Z<\8_=c9h=j>c9äƒpã„oä„mã„jä„hæ„nå…lå„hå…oã†oä…jã†rãˆuçŽoètç”rç”tä‘ræpåŒsã‡hã‡kâ„oà†qåŠhæŠnç†låcàsZØgZÊXR·JN§<Kž6Hœ3H£;I¨CN®?M¯DO²HS±DNµHP³IR²HN²LV²FN¬KV°FN±HP°EP´HM·KT¸KO¸KR½SVÀSRÂTWÆXUÄZ\ÆYXÈYXÈ\[É]ZÊ`ZÊ`ZÌ^WÌ]ZÍ]ZÌa\Ì^[Î_[Î_[Î\]Ìb]ÍabÎa_Ña`ÌchÎ]]ÎbbÐbaÐacÑabÒc]ÎacÐ`]Ð`]ÒddÕ^^Ô`aÒ\]Ð^^Ï__Ô^ZÔ^^ÑedÓfeÒhhÒgaÒadÑ[\ÎZXÑ\ZÍ[XÊZWËVUÎWRÍZZÎVWÎ]\ÌbdÎ^[ÍZYÈ\`Ë\XÌZ[ÊYYÌ^\Ì^^Ì\ZÎa^Ða_Ìb`Ì^^ÎbdÐ`^ÎbeÌbfÐb^ÐdcÏhfÐbbÍb^Ê\\Ð_]Ê^\Ì_bÍa^Ê`aË`aÌ^[Î\ZÍ_]Ì\XÉ]\Ì\ZÏ]\ÍZ]ÈZ]Îa`Ì^aÎ_\Ë]\Æ\_Ä^bÃU]ÄX^¾V^ÀYb¸OW¹QX¸NVµLU²LX¶Pa½XcÆaiÎfjÔprØwtÚ~wÞƒyß„và†xãˆ{âŠtâŠxâˆtà‰vá‡tá‡o߇tâ‰oà‚mâˆjä†kâ…jã†jâ„iàmâƒmâ‚qá‚nâ€lÞƒrß‚oÝ‚sÜ„rÞ€nÜ~lÜ~nÚ~hÚ~qÙ{h×xkØxi×xdÖvgâlô¸€øÇ‘úÑ›úÔŸúÖ üؤüØ¢øÐ”Él°IN¬MU²OU´TY½UW¼VX½ZZ¾[^¾^]Â\ZÀ[]¾]]ÂZZ¾[`½]]Á^aÆb`Ä^^ÉfdÌfdÏjdÂZ_¢9Kt>W=V:ZCXA[BW;^?^<b=d=g@a>f'Lä„jã…qä„pâ…må†mç„kåˆpä‡iä‡qä†näˆqåŒnåvèrçwé“rè’tèrçŽrçŠlä†jâ†nà‚rá†tçˆkèŠnèŠmè€fÞs^ØgXÊXU¶KP¦=KŸ:Nž4K¦<Kª@M¯BR°BL²FR¶LV²LVµNV±DN±LU²GM°EP²FO²IR±DP²IQ¶IR·JO¸KQ½NR¾TUÅTVÇWVÂ\_Æ[ZÊ[XÆ\ZÉ\ZËZVÌ_[Ì\YÍ`^Ì_]Ë`_Ì`\Î`^Ì]ZÎ^^Ì\\Ï`\Î_aÍ``ËbfÍadÏ``Î_cÓd_Ð_^Ñb]Òc`Ð`\Î``ÏcbÓ^`Òa^Ð`]Ò`_Ð_^Î^^ÏbfÑebÐdeÒa`ÑbbÒdcÎ`cÎ_\ÎYVÌZZËUUÍXVÌZVÊYWÌ\[ÌZ\Î\ZÍ`]Ì^^Ì]`Î\\Î\XÈ]^È[\Î\[Ê]\Ñ[XÏcaÌdgÌacÎ`^Íb`ÌbdÌefÍfhÌa`ÌdhÎ^[Ëa`Ç]`ÌbbË\[É\_Ìb^Ë``Ë_^Ìb^Î]\ÎZXÊ^aÌ_^Ê[ZË^^Î]`Í\`ËbaÐ^\Ï``Ë`aÊbdÇX]ÀT_ÁV^ÀV\¼V`¿TYºLWºNX´NZ°KZ´Oaº[jÆclÎilÓkjÕwxÛ|tÞ€và„xá‚tâ†sâ‹xá‡wâ†tß…và‚qá‡và„oãˆpã†iâ†gä„hâ„mä„jáƒlà€eánàqá„rá€há~kÞƒp݃rÞ„pß‚nÞ‚lÝ~lÜ€oÚzlÛjÚyjÖwgÖxjÔtf×|gì¥xöÀ‰úÊ”ûÒœùÕ¡úÙ§üÙ¤üמ÷Ë’ã§v¹d]®JP²OT´PXºUV¹VV¾XX¾V[Á^`À]`¾Y\¿ZZ¿\^À^]¿`bÅ[]Å``ÈcdËgbÍgcÄZV¢=Ks<X9W@[@\@\BZ=]?^>b=e<e<b:bAcEä‚gä„pä„näiå…lä…hä†jä‡lå‡pä‰væ†pçŒrèsé”té”ré”rè’ræ‘tèpæŠeä‡fâ‡lâ…pã…iæˆoèˆièˆjåcâv^ÜhVÌ[VºHN§<JŸ9J¡9K¦?Q¥?P¬AN°BN²DN³GQ´HS´KT²KT°NV²FO´CL°CL²EP®ENµHO·GP¶JSºNU½PVÂPQÂTUÆUVÆYZÄZ]É\\ÆVVÊ[[É\\Ë_\Í^ZÎb]ÊZ]Ð`\Î^\Ía`Ê_aÌ^ZÊ]`Ð]ZÎ`aÌ`^Î`aÑ`^Ð`aÔ``Ò`_ÐaaÐb]ÑbbÒb]ÓbcÏ_`Ï_^ÐaeÓehÑ`^Ñ^]Ò_\Ñ``Ò``ÒcdÏbbÓddÑ\ZÔ\YÓ`_Ð[XÎXVÍZXÉZVÈXYÈVWÌ[XÈVDÌ[YÍ]ZÉ]^ÊZ[Ì^[Í\\Ì\XÌZZÉ\YÆ\YÊ[^Ë_]ÍabÌ_`ÎbeÌ`aÌ]`ËabÍheÎbeÍcbÎ_`Í__Ê^]Í__Ë^^ÌaJÎabÍ^`É^^Ëa_Ï^\ÎZXÌ`\É`cÊ\`Í]\Ì[^Ì^]Í[]Í`]Ê``Ç]`É^_É[_ÆW_ÅX_ÄT`¼RX¸QH¶L]¸N[´HX¶JX¶LY¼Y]Ç^bÏelÒjjÔqnÙwsÝ|rÞ€rÞƒvá†xá†wâ‡tâ‰vß„wÞ†t߆s߆sá‰rá‰mà…râ‡oá…là„Vâ„oà‚pâƒkà„qãƒoà€jß„nÞ‚p߆nà‚n߃TÞƒrÞ€mÝnÛoÛ~qÙ~oØ|nØvmÕrOÒqe܃iï®löÄdùÎúÓ‚úØ—úÚžüÛ¡üÖ õƘښ³\~«Nw®Ni´PZ¼VV½WU¼UZ¿XZ¾[YÀ_[Á^[¿^\ÀaaÂ^^Â_`Èd`ÇgeÍg]Â[]¨CUw#R[NXNTG_DZ2]B\:`Hb?eBe;b<`<d@d >ä‡sâ…lá…nâƒkä…mä‰läŠnæˆpå‡räŠtåŒrèŽqè’uêré’qèrêoèpèkå‡jä†mã†mâ„lã†lèˆiæ‹lè†gä~eàr[ØfVÉVP´HM¨>Kš6L;M¥;K¨BP®BR°@M´IR´GP´HP²HQ²JQ¯FM²FN°IS²EK°CM²BM´CMµEO¸LTºOW½OUÂRRÄSVÄSUÆXXÉWTË[ZÈZVÈ]YÆ\\Ê[ZÌ\YÍ`]Ð__Í^]Ð][Ò`]Ï_]Í_XÏ`^ÐZZÑ]\ÎYZÎ^`Óa_ÎceÕb^Ò^`Ñ^\ÒZXÒ``ÎbdÏ`bÎa`Ñ`^Î^eÐ`eÐ``Ð^^Ð`_Ð^]Ð`aÕcgÓdaÒ``Ñ^`Î][Ñ[XÏZYÏWUÍXYÉ[\ÈXZÆX[ÊXVÊX[ËZ[È\^Ê^^Ìb`ÈXVÄ[ZÉWWÌYWÉYXÈ]\Ê[XÎ_^ÌabÊafË_aÍefÌbcËbfÍejËgfÊfjÌaaÎ^\ËbdÍ`_Ì`aËbaÏa_Ë\`Ð][Î^^É]\Í]ZË]`Î]\Ì]\Ê\XÍ[]Î`]Í]]Î^]Ê_`Æ`dË]^Æ[_ÉW^ÅW^ÁRY¿T^µP[·P[¹RZ´JX¹LYºQ^½VaÈYcÏbfÕhkÕqnÙwqÝ}tÜ}tßuà‚tÞ†vá…tâˆuÞ„vá„qà†oß„ná†kà†mà„náƒnáƒnà‚iá†mÝ…pà€ná„pà„pá†lßoàn߃mÞ€pàƒmà‚rßpÜ~oÚpÝ~pÜ~pØxjØzjÕtcÔtcÖveçžsô¿ŠúË—ùÒ úרúÚ«ûÛ¦ýÚ¥úΘ賆ÂvfªLU«JS±NX¶PW»QTºVY¿VX¾\]À^^ÄZX¿[\Â^aÄdhÇbbÍdbÏhgÅ]\¤?Pu>Z9W;V=Z=Z@a"LaBfFdCf;iAd<b@d@f>e<ä„wä†mä„oãˆlâ‹väŽrå‰nä‰næ‹yæpæsè’tè’oêrépê‘péjèŽnçŠfç†jäiâ…mâ†nã†kå†jç‡lè†læ|eÞp[ÙdTÌ[R¶HP¤<Hš5Hž4I¢9Hª@P®@O±CN¯DQ´FN°DO®FL°FN­HP®HN°EQ®EQ°CO²JU²IS·FP·LTºNTºQX¼PU¿X[ÂRVÇY[ÆVTÄVXÇXXÈ^YÅZ\ÉVXË^XÌ_`Î^YÎ][Ï\ZÎcdÎ_\Ñ\WÐ\ZÏYYÌ^^ÉX\Í^\Ð\\Î``Ñ\]Ð[ZÔ`_Ñ\VÐ^\Ì\_Ê^bÎ`_Ð_aÐckÏgkÒbdÑ`^Ò`]Ð^^Ò\\Ñ_^Ò`^Ò^]Ï]^ÍZ\Ñ\ZÑ[[ÍZXÎ[WÎ[WËYVÇYZÉ^`ËXTÊ_aÊ]XÌ]XÌ]VÆXTÈXUÂ\XÃXZÉVWÈ]ZÈZZÊ]]Ì`bÌ`cÎabÌ`aÍdcÌaeËfjÌccÊejÌabÍ``Ê]`Ê^`Í^^Ï`_Ï`^Ë`^Í]^Ì^`Ì][ÐZXÌZXËZZÐ^_Ï_aÐ[XÎ][Í\ZÐ\\Ê]_Î_cËXZÉWZËY]ÄV\ÃQZÂY`¼T]¹T\ºPV¸JT´JZ¶M[¾UcÆ[fÌblÓklÔmpÔtrÙzqÛ~uÞ€uß‚tÜ€t߃sá„tà„tÞ†rÞmÞ…oá„là‡rá†lß‚p߃oàoá‡q߃lÞ€oá…ráƒnâ‚làƒoàkàƒoß‚jÞ€pÞp߃qß~lÚ{pÛ{nÜ{oØzlÙ{kÖviÕtfÖrcÝfî­~øÆŽùИùÖ¤úئùÚ©üÛ«üÖ£öÅÜžy·^Y¨DO¯FQ´OT¸RX½SX½TYÀZ\À^^Â]_ÂbbÂ_cÌecÊfdÏfeÀVWœ:Js?X:W>V<Y>YC^D`FdDdCe>d@d?^>d=cAa<^;äˆvãˆnäˆoã‡gä‡råˆjå‡qåŠpæŒsæuê‘rêrèŽoêséoéŠjèŒfè‹kè‰eæ‡nâ„kä„jã‰rä‡oçˆlç‰næ„gä}gÝq]Öi]ÊXQ¶FK£6Fž0C›3G 8J§?N©BN°CP²DJµGM±KT°CK¯GN°FN°DL®GP°HN¯HQ²GP®BNµEPµKR¸NS¼QTÀSUÂSUÃSXÅZ\ÄVXÄVXÃVYÅW]Ç^^È]YÈ\]É\\Ë_ZÈ[WË]\Ï_]Ê^^Î\YÈ\ZÌVVÌ]]É`cÎ`^Ð^_Ï`_ÑabÑ^^ÐabÐ^ZËZYÍ`^Î`bÌ_aÑ^]Ò`cÐ`bÒ_aÏ`cÐ`^Ï\\Ó^\ÐbcÏ\[Ò]]Ô\[ÒZ[Ò[YÏZZÌZZÍ\]ÈYZÌTTÌ\^ÊXYËVVÊXXÊ[XËZZÇTSÉVTÉTXÆVVÅTWÂZ[ÅY[È\^Ê\ZÊ\\Ì`bË]`Ë_dÈbhÊbeÎehÎacËabÐ``Ë^^Ê^^Ì^_Ë^`Ï^aÑ``Ï`^ÏZ\Î^aÌ`_Í\ZÊ]_Ë^\Ê[^ÌZ\Ð]XÍ_`Î[XÏ[\Î]\Ì]bÌY^ÉZcÇV\ÄUXÀV_¼Wa¿Wd¸U`¹NVµJX¶HY¹KY¾R`Å]fÌchÒhk×pnÔwsØzsÚzqÜ~oÝ€uÜ€uÝ„tà„vß…xÞ†sß‚o܆tàƒjà‚oáƒhàƒpà‚pß‚láƒmá‚oà~jà~kâ‚jã†rá„oà„là€oÞƒsà€nßnÞ~mÞ~lÚzkÛzjÜzlÙyiÚwf×ufÖqbÕpaÕrbæ–pô¼„øË”úÔžùÙªúÚªüÛ¬üÜ©ûÒ™ñ¾ƒÎƒhªJR¦DO¯OX³PV·PT»RYÀUZºW`¾Y[À_dÃacÈdfÌhe¾W[>Nn@Y<X@U>Y?V=\Cb"Od'Pe#Kj%Ld$GdDb>d@b>_?^<`CåŠwâŠpåŠnä†päˆjæ‹päˆqæŒvètè’uè“véoèpé‰oèˆièŒkçŒfçˆkçˆjæ†lä†næ†må‡qçˆjéˆhè‰lç‚gä}fàp[ÖbVÈUP¸AJ¦:I™0Fœ2G£<N¦:K«BP±HR²JT²FP±AP³BL´EP°EP®DN¯EQ²EO°DN¯EN°GPµEMºFN¼NT¾PTÂQSÄVWÁX\ÃVVÅZ\ÄYXÆ\YÁ\^ÄWZÉ][ÉVTÆYZÎ]ZÍ]YÈ]^È\`È^`Ì[ZËZZÎZWÍZ^ÏYZÍ[]Ñ^`Ð\ZÔ^`Ñ^^Ñ_aÒ^ZÐ\ZÐbaÎ`bÐ^]Îa_Ð\]Ð`dÐ\^Ða`Ñ^\Ð\`Ñ^aÔ^^Ñ^aÒ\^Ó^bÐ\\Ð\\Ð^^Ð[[Í]aÊ\[ÌXYÎ[WÏZUÌYTÈTPÇTTÆWVÈWSÆWYÅYUÆVVÉVQÃXZÄVVÈXXÉWWË^\É``Ê]aËabÊefÍafÌbdÊbfÌ_^Ë]`Í_eÎ^]ÌZ[È^cË^`Î_`Í_^Î^`Î][ÌYXÎ^`Î_`Ì^^Ë^bË^ZÎ]XÌ\ZÍ][Ò^^Î]\Ê\^È[`ÈY_ÇUZÂTZ½R[¿S\¾S\¼R\¼PZ»OZ¹L\»NYÄT_ÆZdÎbdÐflÕopÕrnÙwsÚwoÚ|tÝvÝ€uÜxÞ‚vÝ‚tÞ†sß…sÞ‚oà…káƒlß‚oá€iÞ‚tà€ià‚làjà}iß~i߀lá‚pá…nâ‚rál߀jàlÞ~mÜ}nÝ~jÛzjÛziÛ{iÚvjÚubØtbÖtbÕp_Ön_Üdî­y÷ÈŽùÑ—øÖ¥ùÚªûÛ©ûÞªüפøÈå©z¾f[§EP®LR¯OX·MS¸QYºRZ¶T\¼Z_À\`ÅddÊd_Ã\\¥?Lt?Z=V=X@X>\>Z@^@d@fAdAa>b<`@`<a:_>_9Z>\>å†mäˆpå‰oæˆpä†käˆpäˆpçsé’yè”réxçˆjç‡lç†hèƒfè†cç„få‚eç‡jèˆnå‡räƒhæ‡oæ†oè†jçˆkç†låzfÜp\ØgXÇYU´EM¤7Kœ1H4I£:N¥<O«DT®DO²EP²DJ±HS¶HO±HS¯GO´LR°AL±JP®DO¯DM²IO¶FJ¹IP¼MR¼NQ¼RXÄUXÈXTÇYWÆTTÆTTÅZ_Æ\[Æ\[Ì]ZÌYXÉXXÌZYÎZZÌ\bÎ`_ÉYZÍZZÍ\\ÐYXÒ_^Ñ^bÎ`aÑ^bÐ^bÒ][Î\_Ñ\YÐ\bÎZYÒ`^Ó[ZÐ`]Ñ_`Ð^^Ð_bÒ`^Ò``Ò]^Ñ^]Ð__Ñ``Ð]\Ï\^Ò^^ÐZZÑ\ZÔcaÒ^\ÓZXÐ[WÐZXÏ[UÊWVÌZVÌXTÃXVÈURÆXUÄUVÄWTÃSRÅXRÂTR¾XWÆVUÈVWÉ\[Ç\]Ë^_Ê\`Í_bË_dÈadÎbeÍ^aÍ\^É\aË_`Ë^_Ê`eÌZ\Î`gÍbdÍehÎ[^Î\_ÏbfÍ^bÌ][Ê_bÍ\XÐ\YÎZZÏ]YÐ^]Ë_aÉYZÄY[ÈZ\ÈXZÄRWÂX]¾RV½S]ºQ\¸R]¶NY¶KX¸MZ¿R]ÄXdÎ\`ÑjjÒlj×qnÖtrØxpÙypÜzpÛ~sÜ€wÞ~pÜ„w߃tà…tßjß‚lá€jànàƒnÝ€rÞ‚lÜ€qß~gá€kà‚lß~lâ€nà~jâ‚nâ€qßmà~lÞ|jÞzfÛwfÛxkØvfÚtgØvjÙtbØsbÔqdÖq^×o\Ös_ä“oòº‡ùÌ”ùÕ¢øØ¦úÚ¬úÛ§üܧüÔ›ð¾…ÑŠl®MRªGP®LU±MV±OV´RY¸SYºZ]À]bÉheÁYY¤>Hw"A^>V<V=X>Y>]A_BaHg"If&KdCb@_DaD`B]?^<^:]>\;ä‰pä…käŠläˆlãˆläˆrä‹qè’uê–ué’vèŠmæ„hæ€eæ‚gæ€hæ‚bå€eä‚iç†gè‹dç‡må‡hã…nä†læŠnçˆlè…nå|fÞub×bWÉVS±DM£=L˜/E3F£=M§=N®AM­CP°DQ´EN´EO±GR²EQ²BN²HR²HO°FL®FP±FO²FPµHPºLR»IR¾PTÁU\ÅRVÆVVÆVXÈVXÆXYË\ZÈ^[ÈZYÊ\YÊ][Ì[ZÎ\XÌ\YÊ^`ËZYË\[ÎZ[Ê\^Î^\Ï^bÑ]]Ð`bÑblÐ[^Ò^^Î\_Ë[]ÍZXÎ_bÐc`Ô^^Ð`_Ó^_ÑbcÒ\_ÒabÑ[ZÓ^`ÐZ_Ò[YÐbbÑbbÒZZÒ^ZÐXYÏZYÒ[\Ò_\Î[\ÎZ^ÎX[ËZ^ÈXcÆdqÄhrȇÇuzņ‘Ày~Àv~¾jp¾kr¼[`½X^ÁWVÅWVÆXWÉ[XÃXZÈWZÇ^^Ç\_ÇZ_Ë[_ÈX\Í^aÍ^^É^`Ï^`Ì^cÍ]`Ð^aÌaeÎbcÍ`dÎ\\Ñ]]Ï]^Í\`Ì`cÎb^Ñ[UÐ^ZÌ]ZÎ]`Î]^Ç\^ÊZ^É]\ÈY_ÃS\¾T^½Q\»R\¸VaºPX¶JT·JZºLY¼P\ÅT`Ê^cÐhgÔlkÕnfÖvqÙtiØwpÚzrÚ}sÚ|vÝ|nÝ€uÞ‚tÞ‚rÞƒqßoÞ€l߀mà€mÜqÞlß‚pßjá€jâ‚kâ€iâià~hàoáià}hßzlÝzgÜzjÚwjÕuj×qdØwhØqeÚrcØtbÖrcØsbØp_ÖrdÜ{dì©xöÅŒùΘùÖ¤úÚ¨úÚ©ûܪýÙ£÷Ìæ­}ÀhZ¨FR­JT°KS²PX¸U\¹RZ¼^bÁb`¼X\£@Nv@[>X?W=X@X>\A_AdCa FeFg"IgFaEa@dAb>^9^<`;_>]<æ‹xä‰qåŠså†nä…låŠtçŒnê’uìréˆhæ†hå€hä|cæ}cäz_ãz[ç|bä€cçˆlèŠjçŒpç‰lä†qå‹uèˆlé‰pêƒbå~lát_Ùj^È\[²GS¥;K™3Jœ2H <R¦=N­>O®CL²FQµFN³HSµKT´LU°GN²FR²GQ²FM¯EN°FP³HN¹GN¸PW¹NU¾RY¾QYÄUTÌXUÅWXÈZYËVXËZXÉZVËYUÍ[ZÊ[YË\ZÐ]\Í[\Ì\`Ì^cË[\ÑZXÎ]aÏ^]Òa\Ð\\Ñ[^Ð`bÒ^bÔ`bÒ]]ÎZ]Ð\]Ï\^ÒljÒ_aÐ``ÒbbÒdmÏ]`Ô\`Ð]_ÒYYÑ_`Ñ[[Ó^\ÒhfÍ_eÒY\Ï\`ÌZ\ÎbnÈ_fÍz‚ÈpuÅuÂs{¿x…Å„‰ÊžÏ”‰Î šÔœ•Ρ¡Ðš’Ѩ£Ô¤”ͤ¢É œÀ€†Áu}¾[]ÁVYÂRTÅTTÂVVÁVZÆXZÈ\aÌZZÌZ_ÍZ]Í\^ÎY]Ê_bË]aÏbfÎbfÎ`hÎacÍ_dÍ_cÉY_Í[]Ë]aË\\ÑZZÐYZÌ__Î\^Í[ZÌZ]ÌY_ÇYYÅV\ÂT_ÀR[¼Q\½S[ºR^¼LV¹KT¸HT¹NY¸UaÆU_Ì`eÒgdÕklÔqnÖsmÕup×toÚulÙxrÚ{uÛzrÛxÝ€tÞ€o݃rßlÞ‚pÞ~jÞ~mÜnÝ}oÞ€lÞ€náiâgâ€lâ€ià|hà~ià|iß|hÞyhÞvfÚxfÚvhØwlØvdØvjØrc×tg×udÕpaÕvdÖsdÕqaØqbãpó¶ŠøÈ’ùÓœúצúÛªûܪýÛ©üÔœóĈזt°RW­W_®OX³SZ¹U]¼Y^¼_a¼VV˜8Jq B\:V?ZBZAY<Z@]@^BbDgGh"Fe#IcDfAcE`=]<]>]=\<^?\<æŠuäˆnå‰kæˆlä…nèŠmè’yê”sê–pé‰læ‚eå}eäw]âw^âu\ßxdâw]âjèŠnæ‰hæˆnå‡mä†pä†réŒrçŠpé„hæ}dàs_Üe\Í]Z¶HO¦<Mœ6Lœ2J 9K¨<L¬=O°@L°BQ²FR²FUµFQ±JX®FP³EM´HO´FM³CN²DL´FL¿FL¹PS¿PVÀNQÂLPÄQVÈUSÇYYÇVWÇYXÊYZÌ\[ÌZYÊ^[Ì[VÌ\YÏ^ZÌ]^Ì^^Ð\^Î^]ÐZZÒ\\Ñ^\Ó\\Ð^`ÑcdÒ\aÏ]^Ð^_Ï[_Ð^`Ó]_Ï^^Ë]_Ð]\ÐabÐb`Ò`bÒ\^Ò^\Ò^]Õ_[ÒX[ÒZZÐ]^Î\bÐirÍivÇr€Æq}Æ~‰Â}ŠÃ}‚¾|ˆÀ~ŠÈ‰ŒÊ––Í’ˆÏ”ϥΡ›Î£›ÎŸœÓ­Ñ¥˜Ö´¦Ù¨˜Ö°§Ú³¢Ó¤šÊ§¥È˜™Àv|¿`h¿WZ¾UX¾VY¿X^ÄV]Ê\_ÈZ`ÈZZÊ\^È]_Ê`dÉehÈdlÉagÌdiÌcdÌ`bÌ\^ÏaeÏZXÍ^^Ð]^Ï[^Î`_É[^Í\^Î^`ÌZ\ÇY^ÉUVÃX^ÁV\ÁNV¼OZ½NZ¼P[¶LX·IV·LX¸P]ÂX`Ì\cÐed×kjÖqjØsnÖqmÕtlÖxpØtl×{xÛzrÜ~pÜ~vÞ€pÞpÞqàqÜ{mÞ~nÞ~ná~kà}mÞjà€lâjägâ€gß{eá|hßzjÞ}fÝzhÝxdØwfÙtfÖvj×tdØvh×rb×paÙr`ÖscÖrbÖsdÕobÖubÚxeë¡wöÀŒøÍ˜úÔ¤úبûÚ¨üÜ©ýÚ§üÏ—ì´Êxa¯NU«KT¶UZ¹U\Â_\¼TVŸ@Nq@X :V<V>X:W>Z:`@`Ae!Ga@f$Id$Jb"Gd"FbE^>[:Z:\;a<^;`<`=æˆqæˆræ…nä†näˆtçŽqì”sì”uë‘qè†häbãt]ßt\Þp^ßn\ßqcáv`ä‚jç‹oèŽmå‹næ‰lçˆqæˆqèŠlè‹nê„iæhÞscÜgXÎZV´FL£:G™2Hœ6F£9I¨:G«>N¯?L°BR·FP²ER±IQ²DN¯DM¯EN³GP´HP¶HO´EN¸FK¾JO¾MNÁNVÁOTÂQVÇTVÈY]ÈWVÊXZÊVRÌWTÌ\YÌZTÎ`_ÍZTÌ\XÍ\YÊ[ZÊ_\Ì\ZÎ[\Ð\[ÑegÐ`bÑ_`Ò__Ò^`Ô^bÔ^^ÔacÒ\\Ò]aÑY^Î]`Ð^]Ò_`Ôa\Óf_Ô]\Ô\\Ó^\Ô\YÑZXÏZ\Ì[fÌivÄw†Ç{„É‚ˆÇ}€Æƒ‡Çƒ†ÀƒÂŠÂ‹Ê“Ò —̘͌”͘‘Ïž˜Õ¦šÔ­¨Ñ¨›Í£žÒ¦›Ò©ŸÐ§–Ѧ”Ò£˜Ö¯¢Û¶§Ú´£Ø³£Ï¥žÄ”—¼pz¼]f»U[¼NWÄWYÇUXÈZ[ÆY[ÆX^È^bÌ`dÈdjËahÌ_eÐ^bÎ`cÌ\_Ï^^ÍZ^ÎZYÎ\_Í\ZÏ\[Ñ[^Ë\^ÎXYËVWÅT_ÆVZÅS[¾W`½SX¾MW¼OZ¼MWµLY°J\·KV¸P\ÄV\Í_fÒfaÓmlÔrlÙtjØsjÖsj×umÕuqÙvlÜzmÚzrÜ{nÞ€sÜnÞ€q߀nÜ~nà€l߀p߀màkÞ|hà~oâ|gâ~gá€iàzfß|hàzhÝvfÞubÜwgÚudØrd×qg×sb×pfÖpfÖpaØpb×p^ÖpfÖn^Ön_×pbÖveß„nð°‚øÆ‘úКøÖ§úÚªüÜ­üàªþئøÉŽâ¡v¾c[²PXºX\¿]]ºXXœ=Lq>[;S:U<Y=Z<Z>Z?^?bDcCcBfCdBdEbA`EZ>X9Z:^8a8]7_=^;æ‡tæ„læ‡kçˆræŠmëpì’pê’lêŠmçhäx`àr\ÝlWÜiZÜm]ÝkYàw^ä‚gèŠlèŒhæoæ‡på‰lèŠoéŽsé‰iê†hå|dár\ÚfWÏWR¸EM¦8Gš2E˜3F 6K§<L©8L²BO°DN³GT´FQ±FL±IR­DR²KO³DM¶CLµGQ´GP·JP¾HN¼HPÁMTÃPRÅRVÉTSËVVÍXWÍZVÆUVÊWTÍZXÐZXÒ]YÐ]ZÏ\VÐYVÌYUÎZZÎ\]Î^\Ð_^Ò_\Ð]]Ô`]ÒZZÑ`aÖ__Ô^^Õ_\Ò`_Ð^aÐ]^Ñ^^Ï\[Ð]^Ò[ZÓ^XÓ]YÑ\`ÒZ\Ð[]Ð[aÌfrÆt‚Ãv€Æ~‚Æ}€Ê†ŠÃz‚¾s|Â|‚ÄzÃ|ƒÊŠŽÒ–ŽÎ™Ì›‘Θ’Ηϣ ÔªÕ§›Ô§˜Ð¥œÑ¬žÍš‘ʔ̟–ЪŸÕ¨”Ó©šÖ³¢×­œÝº©Þ¸¥Ø³¢Ð¥˜Â„ŠºdoºPWÀRXÂSZÃY_ÆX^È[^É\aÈ`dÉ\aÌ[`Ï]`Ð^`Ê\eÊ]cË]`É[]Î^_ÌW[ÎYYËZ^Î^^ÇX`ÆT[ÄVaÉUWÂSX¾T`ÀRX¾OX¸P^·QZ´JX²IV»IV¼MZ¿X`ÎbcÔgeÖnjØoiØxuØsnÕtqÕroØupÚwoÚwrÚxqÛ|wÜzsÝ‚rÞ}qÞ~nÞqß{lÞ{gÞ|là~jß{lß{ià|hÞzhá|hÞxjÝzfÞsdÝweÝscÜreÚtdØpeÖn`ØqeÖo`Öod×ocØp^ÔrdÔsc×scØn\ÕpcÔqdÖudç–qô»†úË’ùÓ¢úاûܬûß®þà®þÖžóÂÖrºYZ¾YZ½XY£GQuA\<R=U >X>V>X=[>Z>`@dDfDbCb>d@`>`@\@\@[>^<`9b:\8Z9]8è„hæˆoç†iêŒsèrìoì’rêŽnè‡håeàsXÞlYÛ`RÚ^RÚeZÛl]äu^ä…gèŠjê‹iç‹mèŠnè‰pé‰lìkèŠpê†eæ€jãrZÜjZÎVP¶FL¤6F—.Cš6I£5J§:K¨<L°?J¬AP±CPµFN²AM±BP¯FL±FN¯FP³EM¹IQ³CL¶EPºJN¼MT¿RZÄVZÃRUÊTWÌVTÌSUÍWVÉZXÌYYÍYXÐZ]Ð[\Ð\YÎ^ZÑZWÎZXÎZ[Ò^ZÏbaÑa`Ð`]Ñ\\Ñ\\Ñ\bÒ]\Ö^`ÔYYÔ\\ÑXYÓ^ZÏUVÑ\\Ð^^Ð^]Ñ^\Ô\\ÐY]Î[cÊanÉ_pÀfxÆy‚È}†¾qÀz„ƆɄŠÀz„½u~¾tyÇ‚…Æ‚ƒÈ‚„ÌŒŒÐ“ŠÉŒ†Ì””ИŒÐœ™Ô¢•УѮ¦Ð¦ Î¤ŸÎ¡šÌ¢Ð ’У™Ô° Ò¦“Ó¬ŸÖ±Ú³¤Ù°¤Ý¼ªß· à¸¢Òª¢Á|‚ºU^¿PVÃUZÂUZÈRWÅ\_Æ\bÈ^hÌZbÍ^dÌ\bËbjÊ[^Ë\cÈZ\Í^bÌ[aÆY`ÊZ\ÊW[ÉY`ÉSYÅX]ÅTYÀR^¿PX½R]ºO[¹QXºPX³JX¯IY·P\»NZÂZ`Ï``ÒhfÙlgÚshÛshÚtk×rlØsnØsnÚvnÜvnÙxtÚzsÛ~xÜ~uÞ~sÞq߀nà|lÛylÞ{nß}mÛ{lÜzfÜvfÝvfÝzfÞvdàxcÞubÜtcÜrbÜp`ÜvhÚsd×ndÖnbÙod×lbØn`ÖocÔse×od×pd×o`ÖnbÔrcÓkbØv`íªzøÄŒúИùبûÛ«ûܯþà¯þÞ¬ýҘÉuf¼\Z§DOz"D\@T?T>XAXD\D`@`DbCcFdEd Eb@b>d@^>W?X>\FbHb=`:_?^9\9`<é„mæ…lçˆpêŒqë“pí–qì‘lêŠhè€eäxZÜmUØcSÖXOÔ[RÕ`YÛo`â{bæƒfê‹léjèŽkê‹nç‹lêuëpëŒpé‡læ‚iâubÚfXÍZTµBI 6J–-F–.D¡4E£5Hª;H°?K¬>M®@L¯AM±DO²@L²DL²FO±ER°BN´FP´IRµIQ¸FO¼IS½MTÂTZÅOQÈTVÊSRËUVÈWVËYVÎUTÎ\\ÌXZÒ\]ÐWWÎZXÑYUÏ[YÎZYÍ`^ÎYZÒ[ZÒZZÒ^^ÑZ\Ï_`Ò]\Ò`cÏ\^Ó\[ÑXZÐYXÐXZÎ]]Ï^`ÊbnÍeoÍpÌpyÅjw¾`k¶dvÃtxË€Äv~¾zƒÅx~Å|~Év{ÇzxÆzzÅ‚ŠÈ‚Æx~Ç‚‡É…Ȇ…ƖʇƒÎ’ŒÍ“Ì•‘Ó Ò¤ŸÔ¨ Ñ¢™Ò¦–Ï¢šÒ©™ÕžÒª¡Ô¯š×§–Ó« ÚµžÝ´¤Ø´¥Ûº®âÀªá»¦Þ¶¦Ìžœ¹jr¼PYÀPU¾T\ÀX`Æ]gÉ[bÆ`iÉ`hÇ^fÌ\bÈZ_ÉZbÌ\`Ï\^ÈY`ÈZ^ÌVZÊX^ÆXZÆUXÂS[ÂRW¾NV½QZ½R\¼NU»R]¸JS´O[³HV·Q^»NVÆY_Ð^_Ôji×poÚndÚshÜvmÙukÙriØtmÙuoÛwoÚyqÙwqØ}xÙ{vÜ|uÝ|mÞ|qÞ}iÛylÝvjÞzgÜxhÜweÜvcÜubÝxcÛwfÜt`ÜthÛraÜrbÚtcÜp`ÙpeÙqcØk`ÖndØm`ÚkXØpbÖo]ÙpbÚp`Øo^Øo^ÖpbÕl^Ôl`á‰fó¶„úÌ•ùÖ®üÚ®ûܬýß®ÿà­ÿÝ©üÌ“ážy²MR~#CX<W@S>U=W;Z?Z@_CdBgCe?cEcAb@cAaBZ@Z?`F`B`B]:\>Z9Z;_<`:æˆoçŠmèpìoí–zì“mê‹mèƒlæzbàrXÚdTÐVKÍSOÎRN×dZÝvhâ~lä†gèŒlìŒléŽiêŽlè‹léŠlêŒnéŠné„hè}`ãvdÜh[ÌVPµCL¡4F—*B”/Fœ2EŸAX¨>M®@O©>M­>L°AN°BK°FS±@I¯CM²DL±?L³@JµJS´JPºFO¹JR¼OT¿NSÄQRÃTWÆTTÇTTÌVTÉXXÉX\ÊVWÊZ\ËZXÅZ\ÌXUÊW\ÇXTÍ]XÌ]^Ì\YÑ^\Î^^ÐZ\Ñ\_Ñ]^Ò]^Ò[ZÑZZÒX]ÍU]ÌalÉZkÍkxÎ~ŒÍ~ˆË~„¾rz¾fm¸Xe¼Ydºix¼hrÄnsÀpxÄrvÄx|ÅrwÈqwÅvzÈ‚ƒÊ}€É„‚ÉxzȂʆ†ÈŒÇˆŠÊ”ŽÎ˜–Ì™‘Ï”‘Í–Ò¤—ҜϗŽÑ¨œÖ§”ϜҬœÙ¨–Ó«¢Ú¸§Ø®žÖ²¦Üº¦Ý¶Ü¶¢Ü¼®Þ¼­à¼¦à¹¥Öµ¨¾~ˆ·T_¹NV¿V_½[dÃV_ÄY`Å^eÉ\dÇV\ÇV[ÆXcÉ[`ÉY^ÇX]ÍZ\ÌX\ÇW\ÃTZÀRX¿R\ÅQWÁNW¾MXÀOUºLV¶MYµGT²FT²IW¸MZ½OVÅR\Î]`ÓfdÖmlØrkÜvnÚulØulØtjØsmÚsmÝtpÙvpØzw×wuÙxsÝ|pÞ}rÝ}nß|nÞzhÝugÝwfÛtbÝxhÜxfÚsbÜr_ÜveÜteÞudÛucÚqdÛp^ÙrfÚpcØpbØpeØn`ØpfÖl\Ùm`Øl^Öl`ÚoaØo^Ùo`ÕsbÔmaÔl\Ùq\ìŸsùÄúÏŸûתûÜ­ýÞ±ÿß®ÿà¬ÿÚ ñ¼ˆ©HP\>RAV@U?XAZAZ?X>bAeDf>d@bBd@eBdD_C^D[@^>aD`>]=\A]?\:_:b9æ‡rèŠmë’xì”ní•vípê†jæ€fãzfÞiZÐXPÆJJ¾EJÇOLØ`XÞrbã|dæ†iêmê‘pêŒkìŽoèŠmémëˆkíŒjê†jèƒgät[Þk\Ð[PµDM¡6H–3G“.G˜5M;N 7J¦=L¨CSªFP­GT¬AL¬AK±AJ®DM­AL²DK±EM´FQ³IS³HR¸KSÁJUÀMSÂLQÆTZÅSTÇUUÆRUÆXZÈZ\ÌUTÉW[ËTXÎWUÌ\_ÎYWÊZZÌVUÍ\[Î[^ÏZXÒ]`ÐZ[Ò]^Ð^\Î[^ÐUXÒX\ÑTZÕelß›ŠÐy€Ñ„Ê}|Ãv{¾ow¾biÀbiÂ\c¾\i¹_n¸dlÀlwÀlvÀnsºfm¿kp¾jrËzxÇqwÅutÈ„È|{Ê…ˆË€~È„…ˆ‚Í“”Ò…Ï’’ÍžšÑ›Ê”ŽÌ˜—Ò¢‘Ô¤—Ò«¡Õ£‘Óž×´¥Ü®—Ö¬™Ø¸¨Ü±–ܰŸÚ·¨ßº¢âº¡Ý´¦Û»°ßÀ«ä¾¦ÝºªÇµguµR_¸Xc¼PXÂS[ÂR\ÀWZÂX_ÉYZÂV^ÅX^ÆX^ÇV\ÆV]ÆX^ÆX]ÄV]ÂT[ÂPTÁPXÂPVÀQWºNX´L\·LW³KU²DR°EQ´KX¼OXÉRWÎ`hÖedØpiÚriÜtnÜvnÚul×tiÙrjÚqjÚwjÜwmÛvnØsmÚvrÜ}qÜ|rÞzkÞ|nß~rÞzlÜtdÚqcÛtdÜqeÚpbÜrbÝr`ÜueÝtcÚvgÜqbÜr`ÜpbÙqeÙpb×pgÙo`Øl`ØpaÚp_Ûn_Øo_×pfÙrcÛo`Ørd×o_Õm^Õk^à}dò±‚ûÅ‘úÒ üبýݰþá³ÿä³ÿÞ£ò¾€‘.CM 8P>R=W?V@\@Z=\>dBhCc@bBbBdE`=]?Z=\B_@g#I_@^BW<^B`?_6d=f:çŠrèrë“pí˜vì’qêŠjç‚håx`ßp]Õ^OÄKM°@J´@JÈUPÖdXÞugä~fæ†dêtìlëŽmêŽjêmêŠlìŒmê‹oë†iè~hãvaÝf[ÎXS¶FO 6J”,D0F™2J›8LŸ6H£:L§=L¬=N©@Nª@Nª?K­AN¬AM¬BI²FM²CL°CL³FO¶EL¸JQ¹LV¼NXÁPVÄQVÄTVÄPRÅTYÆWYÃZ^ÆXZÅTSÍXXÊVUÌZZÏXVÉYZÎZVÐXXÎ[\Ñ[YÐZYÐZ\ÐXZÐXXÎY\ÐXXÎw‚Ïb`Í`dÇaeÈmqÆllÀgj½cj»^jÀbh½\g¼[j¼\h´`r¿gnÁnzÂlp¾nvºfr¹erÂhpÅw¼htÅrxÆy|Ê~}ʈˆÈ„ňŠÌŽŠÐ–ÍŽ†ÍŽ‡Ð˜É“Í ›Ðœ—Ц Ö¬Ñ–Ò²¤×²£Õ¬œÖ± Û¯”Ö¥–ײ¢Ý¸žÚ®™×±¥Ü¼­Þ¹£Ý¸ªÞ¼°àÁ±âÁªÞº¥Õ°¨½‚ˆ¯Xf¶NZ»NXÀPXÀV]ÄT\ÃSZÄT[Å[`ÆV]ÇW[ÆUXÇU_ÆWYÂV[ÀUZ¿TZÃOW¾MS¾PZ¶KW³JY´LW²FS²GU²@J·KW¾KUÇT^Ö^`ÖhfÜlbÜqhÞwjßvnÛtmÚthÙslÚsjÜtnØwrÚvoÚwrÚunÛvnÛ{uÝxkàylÞ}oß}qÜwhÚuiÛrbÚn`ÚnbÝraÝsbÜsbÛvfÚtcÜqaÛsgÚp`ÚrbÚufÚpeÙpcØodÙpbØpbØo^Úp_ØsbÚqaØthØqfÙl_×oaÕpfØsfè–sø¼ŠýОüتþÞ°þâ¶ÿâ¬ýÔÑ|_Z8P>Q=T>W>Z?\@_?bBfBeDdAdCeA`<[<Y>Z>`@d!Db?]<\=X;\9`;b:hAf=éŽmê”ví›sî—rëvê„då€dãw^ÚiXÌQK¶BF¤3C²9EÈRNÕbVÝsbä€fç‡hìŽnêŽhêmèŽléjëŒníŒnìŠmêŠnè}hãv\ÝfZÏWO¶CIž4G+BŽ-C–2F›0E¢4G¤:I¦?N¦?L¦@O¨=J¬CN¬AK¯DJ®CM­BL¯FS±FT·FN´HSµHN¸MV»FK»OVÁRYÇQRÄTWÄS[ÃVYÉSRÈUVÇRUÊZ[ÊWZÇ[]ÈZ\ËXWÊW[Í^_ËZ\ÑZZÎWYÎ[^ÏWUÐXYÎV\Ög_ìšrÊNMÀV[¾_d¿\d¼_c»`e¼X]»]g¼\e¹\f¾`n½^cºbl¾ms¼nvÁlp»ip¸doºhpÄptÀsxÂprÄpwÆtwÆ|~Â~…Át|Ë…†Ë„~Î’‹É…‚ĉŠÌ–’͌ӧ—Ó›ŒÐš–Õ¦˜Ù®ŸÙ± Ö²¥Ú°œÖ¥–Ô¯£Ú²˜Û²ŸÛµ¦Ú¶Þ°–Ú­¢Ú¸®à»¦àº¨Ü¸¬Ú»±Ü¾«â¾ªÛ·¢Ã–™´cm²LX³NX¸NW½NX¾T\ÁYd¼T]ÅU\ÄSXÃTYÅS[ÇSXÂTZ¾S]ÀTY¾Q\½NVÀOV»MX´P_·GT´LX±FS®FT¶FR¼LZÁS\Ï_aÖffÚnhÜtiàvjÞyoÜujÝtgÛsjÛsjÜqiØtnØrjØtnØsnÚupÙtnÚunÞ|kÞ|qÞyiÜxoÚpdÚpbØnaÚndÞo`Ûo^ÜpbÞqaÜvfÞp`ÜoaÙqdÚscÛrdÚpeÚo`Øk`ÛpbÙn^Øl_ØpaÚueÙrfÚse×tjÚrdÖpcÒqe×n`Üykï¤|ýÊ•þצÿß²ÿà­þÕ•ê¥p‚)AL :Q>Q 9U=X>YB^@dCgGfCcBdBhBb@[:Y<X<]@a@c@`BY=Y:\:]:c<g>c9\8ì’pë™xîœrî”mì‹kéƒiåxbßq`Õ`W¿JI¢:J–+B¯>FÇQOÖe\àtaæ~eèŒkéŽnìkêŽlëjçqè‰jì‰kêŠnê…hçzbãrYÞf[ÐVN¸FNœ2E-FŽ)C“.G™4HŸ8M¢>N¥;L«:Gª>L¨@K¯>K¬@M­CO«BQ¬EP®DO®EN²HT´BN¸GM·FR¸DNºNTÀNVÁPSÃQUÀRXÂVVÃQTÅPSÅTXÊ`cÊZ[ÈXXÌ\[ÉZ[ËZ^ÎZYÏVVÑZXÌZZÌZ[ÌXXÌQWÏXZåœ}Îo\ :T¶NY¼\cÀZbº`i¼X[À^e¸X`º`jº[eº\e¸Wb¾biÂjpÁflÃko¼eg¹fp¼jr¾lvÀnuÁkoÆs{Ànw¾x€ÄrtÅz‚Ɔ„ŃƒÄƒˆÈŒˆË‰‰Ò¥˜Ôž”Л•ΣšÔ¤™Ô¦šÖ°£Ø®šÕ£–Ø´¢Ú´£Ù¨”ر¤Û¸¤Þ®—תžØµ¤à¹ Ý¶£Üº­Þ¿°Þ¼¦à»­Ú»¬Ú¼®Úº¨Ýº¡Ô®¡¸t{­N[¯FT´IV´OZ¸U`ºPW¿NS¾RY¼RXÃR[ÁTZÂRXÀT\¾PYÁLV¼OY¸JU¹LY´LZ³KX¸HQ®FR°AQ³FVºNZÅW^Ñ_aÙjfÝmgÞtlâwlàxnàylÞxlÞtfØuqÙrmÖspØtlØqlØrm×pmÖpi×upÙunÞxpÞ{kÞ{nÚrbØphÚlbØn`ÝnaÜneÜp`ÞsdÞtbÛteÚpdØoaÚrfÚodØqaØpeÚo`ÚpbØohÙoaÚqeÙsgÙteÙp`ÚtdÙugÖrf×ufÖteØshâƒmù¾ˆÿÒžÿÛ¥ÿÒ–ï«xŸBHT=N>Q>T@T@V<\Bb?gCf Fd@f EgAhC`BX>Y=]?cBbA^@X:Z?[>`;d>k?d>T2I2ì“rî–wî•wìré…jæ}fâtdÚdVÊTR«<F—*B–*B¨;IÅRMÔbZÝo\ä|`èŒlêŒkì’jëqêŠlêjèŠmìŠlêŠlêƒiè|bâmYÝcUÏUQ¶CK4D)BŽ)B˜2F›6H :K =L¤@N¬<L©BPªCR«@N¬AO©DO«BP«DP¯GT°CL®DP´FN´HPµKT½LS»NU¾PUÁPSÄNP¿OUÅRTÄRRÄVZÄTVÆWYÇV[ÄVZËUWËZYÎZ^ÌVYÉ]_ÐZXÎZZÐZXÐXXÏ\\ÐXVâuXÂRT²IZ½PX¿V_ÄVYÃ^c»V`½Xb¾_iÁei½[h·Yd¸\dºdp¼dnÃilÀkr¸fq·fq½go¾jsÂouÆrvÁjnÄknÅpuÅxvÃx}ÄvyÆ€|ˆ‡Ì‰†Ð’†Ð“‹Ò¤ Ó¢Ó ›Õ¤˜Ö¤Ô¦šÔ¬ Ø¬˜ØªØ¯ Ø°šÞ°ŸÙª¢Ü¹§à´ŸÜ¯œÜ´§ß¸¡áº¢Þ¸¬Û¼²ß²ݼ¬Ú¶¦Ú½³Ü¾µâÁ¬Û¾¨Á–š¬Wc±DT´MX±JU¶GP¹JS·LW½QX¾OWÀQZ¾PXÀOXÂOU¼N[ºLU¶OZ´O]²HX¶JW´JV±HR­ET´GU¹NZÄP[Ò`eØjdßpiÞvnâzqâ{mÞzmßxqÞwlÚtjÙtnØrjÖro×mhÔtmÖnkÔokÔmfÚnhÛrlÝ{mÞzpÝsdÛtjÛpeÙndÜo`Þr`ÞraàsdÞugÜteÛpdÛr`ÛpfÜoaÜqaÛpd×nbØqhÚpgÙpdÚrjÛqhÝtfÚnbÛseÜtdÚukÚugÝxlÛxnßxjó¢~ÿÈ’ÿÌŒï§q£HNY?Q;T>V@U>V<[=\=dAa>d@cBfBgA`AZ@\A]@`BdA_AV=Z@[>\=bBi"Cg!DW9F3D3î•~î”pî“oìŒkç„hçx^ßlYÒZT¸FNš.>*C–0F¬?LÈRNÒc\Þp\ãyaç‰gìŽlì’jêrê‰nêŒiìqìŒné‹mæƒkæ{`álXÜfXÍVQ³EK›/D(CŽ(B“2J›8L¢4G¢;R¢@RªFW«HVªGY­HX©BP­GR¬COªAQ­EP¬DR¬IU³DR´KV·JT¸IT¼NRÁRXÄTY½JPÁMQÃSVÁSXÂUXÂUZÅVZÇUYÆUVÊUZËX[ÊXXÌ\[Ì[\ÐYXÎWZÑZ\ÒXYÏZVÐpg»NR»MU½RZ½KVÂV]ÂW_¿V]½V_½Za¾Z^¿_h¾\e¼\g¼\eÀdmÅlpÃnqÀks¾en¾ku¾jsÄovÆorÄirÃacºktÀt{¼krºjtÈ{Êyż…Њ…Í’ŠÓ—‰ÔšÓ¤—Ø¢ŽÑšÒ­ Ø¥‘Ï –Ó©£Û¯˜Ö£”Ô¦žØ¸«Þ¶£Ü±ŸÛ¸©ßº¥ß±žÛµªÞ¾¯á¾¥àº§Ý»¬ÛÀ²Ý¾¦Þ»ªÜ¼®ßúâóáÁ©Ë¡šªYg¦CUªBP¬HS¯HQ²JS¶JR¼MT¼PWÀRX»NX»PY¹NX¸NZ¶MV³K^´IVµJU³LX¯IY®AN²FTºJXÅR\ÑZ]Ùihßnfßwnâzräznãzjâynß|qÜyrÜwnÚrlØmiÔjlÕlkÔjhÓklÒgd×lhØoiÛwkÝylÝvhÝthÜpbÜpbÞp_ÞreÞofÜsfÞt`ÝtiÜpaÛo`ÙpiÚqbØpfÚpdØoeÛsiÜrcÛrgÜteÚpeßsdÝtgÛtjÜtjÜwiÚujÞznß}pà{nî’uù´}æŽi›<FX<W?WBW>V=X<Z>]>`<d<`@d@cCd?a@Y@ZBcFeDg@bB^EX<]A\@d>n(Jp,ObAI
3?0R9î”zï”tïlì…eèfâr\×cWÄTS¨;H”.D(Aš3E°BJÃQSÕbXßp[ä|hé‡jênì’pë’têŽtêŽrê‹në‰lê†gé„jç{bàoZÙg\ÎTP²BI™-BŒ,BŒ(@”1E6JŸ:K¢>P¨?O©DV©DU§AR¨L^§DT®CNª>M­BN°@M¬EQ¬?N°EO²GR´KU·LXºKR¼PX¾NXÂTZ¾TZÀRUÃQYÂTWÆRTÈXYÆUXÄTTÍUVÊWWÌTXÌZZÐXXÑYXÍUVÎV[ÏSW×ppÕdWºMU»Q[ÂSVÀVX¾RW¼PW¶MVºSaÁU\¸Vb¿^dÁ\gÃbiÁ^bÀ`iÃjmÀ^a¾gn¿mpÁjrÆljÌmoÈnmÀeo¼enÁrzÈnrÉ|yÇrpÈ{€È~|Àw͆Ά‚ΖӘŠÐ‘ˆÔ£•Õ™ŽÓœÖ­¡Ø°Úª–Õ¨ ×´¦ß¸ŸÜ±¢Ú¶¨Ý¹¦Üµ¢Ûµ©ß»ªà¸¢à¹©Ü»®Ý¿®ß»¥Úº©Ù¹®ÚÀ´ÝÀ²àÁ³à·áõãÄ­Î¥š«bož>MŸBN¤>J¬BN®DNµIR³LW¸R[¹KR¹PW¸LX´JX°HW¶JV³L^¹PVµIU²ET±BR¯FV¸IXÁS\Ð^e×jjÞqnàvhã}nã|kã|mä~pàylßzoÞtlÚsjÙmfÔhdÑfdÍfiÎcfÐb_ÒbaÔieØpiÜxpÞymÞviÞrbÞobßp`ÞpeÝqeÞtgÞuiÞsdÞq_ÜpeÞpdÚp`ÛoeÝobÙrfÝqfÛshÛrcÛsgÜrdÞvfÞqbÜvhßxjÞyiÝxjÞwjãnålç„lÖo\’2C_AU?ZBVAV=Z@[?a?`=b@f>e>f@f;b>[<U;^Bg$JdC`>ZEV@Z>bEbCq)Ls.QfBT;D6K;E]ï•xî’rì‰nèƒlæxdÜl^ÏVS·DH1B“-D–*Bœ4F®BOÄVXÕdYÝn\æ€hè‰hìlî‘nèqìsêsê‹mî‹oêŠiè„iæxaâr\ÛbWÊVU°CK›,BŽ*D*@—2Gž6H¡:M¤@P¦=M¨BTªAO«DR¬GS¬CQ®GSªBR°DQ¬BQ«BO®DP±ER·HR´HR¶MV¸KT¼QY¾PWÂPVÂPZÁNTÀPUÂSWÆVUÌVZÈTVÇUVÊVUÈX[ËX\ÈZZÏXYÐYVÎWWÍW[Õf`é§~ÇPQ½MX¼SWÂPS¼OU¹MV¶KW»PW¼S]¾V]¼Y[¾ahÄfk¾[a¼`gÆhe¿_d¼]bÂgjÇlpÄjlÄopÆnp»jwÃkoÆuxÁmsÉppÄlsÂwzÃqxÀ{…˃„Åz|ȇʇɖ‘ÏŠÎŽŒÐŸš×¬™Ø ”Ö¨¡×°ŸÜ¨—Ú­¢Û³¤Ý¹¡Ý´£Û²§Üºªß¶¢Ýµ¨Þ¼±âÁ¯à·¢Þ¼¨Ü¼®Ûº¤Þ»©ß¼«Ü¾²Ü¾±Þ¶¢Ú´¨Ý¾µßƺҲ´¬~Œ©t¢Sbž<K¤@O«DQ´GR´O[·KV¸OX·JS¶JU²JX·HS³ETµJZ´DU¬DU¬BT¬CX¸KWÁN^Ñ^d×npßwsáznä|lå|lå‚sç€rã~oÞxpàwjÜxn×ohÕebÏbdÉ\`Å]dÈZ[Î\`Òbg×njÝrkÞzkÞvlßseÞpeÞn`ßrcâucâudàxjßwbÞl_ÜnbÜpbÜn^ÚodÜqfÛpfÜseÜtdÚshÜreÜtjÝzoÝtdÞvhÞxhàweàxjâzlã€pè€hØkb™7J`@X>V=V<Y=V:V9Y?aAg Ch!Cf?d<`=_:Z=X:^>dAgBdF\GZAYD]BfDh$Gr+Ng"EV:J5O;„:SËurîvìŒpê‡læ~fäq\Ù`TÃLN¦5G˜9M•2J“,D˜4H®CNÇUSÔdXÝq]æ{bèŠhëiìoìjì‘pënéŠrë‰kë‡iê„fæ|cát`ÚbUÉVR±@I›,DŽ*D*D˜1Fœ4F 3I¦@R§?L«GY¨@M¬>P¬@R¬@MªDR«CR­CO­DO®ER¯DO°FNµHPµJQ´LT³OTºMT¿NSÄSRÄT\ÀQTÁQVÃRVÆZ[ÄUVÆSVÄXZÈSXÊX\ÍVXËSVËWXÒ\\ÌYXÐTZßwpÜmUÁNUÂQP¾NSºIP¸JS·IP¸P]¿QV¾X`¾Y]¾T\Â]a¾X_¾ciÉbeÂ\aÀ_cÂflÂlnÂei¼hrÆchÌnnÍquÅpqÈprÃjl¿lxÃsz¾ekÇxzÌzÈ||Í~zÇ€|Í‘ˆË‚~Ëš’Ô¤”Ô™’Õ¦Ù­–تŸÚ©ŸÙ³ªÜ²œÚ¨Ú±¢Û¸¤á´œÛ°žÜ·¬ß¸§àºªÞ¸«Ý»°à¼§Þ¸¢Ö¶§Ø»¬Ú¸¥Ó¬¢Ñ°¯Ò½¼ØÅÇàÎÈæÔÍëÙÐæÛÐà×Ëξ¸«`hœ5H¦;M¬DQ±MZ¸IR±KW³LW³HP®DT±HTµGU±IV°FX«FXªBY³EV¸K\ÀS^ÒbdÖnmßsmá{på~nä€månæ€nâ~sá{nà|sÝxlØodÓd`Ì\_ÂV^¿PZÀTXÅT\Î`_ÖedÚpiÝulàxkßufßpdàrdßsgàrbâxgßvjßtdÞn^ÞneÝpcÝp`ÛpdÜpcÝrlÞrgÝrdÝqfÞreÞukÜqeÜrhÝuiàwiáxjâ{häoæoÞwh¸KPk@XAU@V?W=W<V:\>bDc?fBc@h@f<d:\>Y=^AeCe DfG]BXC\A\@`Dh!Fr2Sh$HS;J<N<y0Nºioà‰{êŒvê‡mèiäwdÜj\ÌVR´?G™.D˜3G›6I™1E/F¬AMÈTSÕbZßqbæ|cé…hëŽnìsì’pîpí‘uìnìŠhê†jè…dæ~dár]ÚfYÊTP°ENœ2F(D/F–2FŸ:L 5J¥?M§FT«H[¬BQ«@O«EQ«FQªBQ¬DT¬AP®FT°CO°DO°GR´GU·IPºNY»PX½TYÀU]ÁTWÂNTÀPRÂPV¿UXÀQXÊXYÈTUÆV]ÈV\ÉYZÎVZÊVXÌVXÒXXÒVXÒ\Väx^ÅUWÀSS¼LR¸JT·FO·LX¸KS»U_ÁW]¼X]½SX¼U\»PXÃbfÂZ\Âdl¾XbÀbgÅhm¾dlÃdh¿afÂgmËlnÁilÄnsÆln¾jrÉrpÂrxÂsxÇz|ÌzzÍywÍ€Ì|zË‹ˆÎ–Ò”ŽÒ—“׬–Ý©šØ¦›Ø´©Ý¶ Ü¬›×§œÛ·¢Ü±Û¨šÛ·§Üºªá·¦Ú®¤Ü¿³à¼¦Þ³¡Ú·©Ú·¨Ö­žÒ­©Ò¸¼ÚľäÎÃèÎÂêÐÃìÓÅìÓÇïÖÆòÝÏòàÑòàÉÒ´­ŸDV›4LŸ8J¨ER®FT®LV°HP®EP®CQ±CO°FU±GV¬FX¨FX©>T²GX³K\¼O`Ð_cØlhÞukâwlå{næ€pä~lç€pä|nãzkæ{lß|rÛriÕgbÌX^ÃPX´DN³JV¹IVÄTZÐ]^ØkjÛoiàwnàxnÞtißr`ÝrhàrcârdàteàsdÝpfÝn`ÝrhÞpcÜreÜpdÜodÞqfÝqeÝpdàobßtgßrbßvlàwkàwlãznâ~qæ€nä|gÂVVz'HXCU@X>X@V 8[AX<`@`>d@h@c=c<`8[:Z<]<d?jEb?_HVDX@^D^Bf$Kq.Py7Yf FO9Q@m'N¡YiÓ~täxë…fè†næycßn`Ô^W¿MO :K™.A˜2G˜3Hœ5Gž3H¬FRÉWTÖd^àtdå|fé‡gë‹iìlê‘nìŽnìpëŽmìŒjèŠmæ„læ|bàq]ÚaVÍRL°@K›5F*DŠ&B”2H4J¤8M¤<L§?Sª>Nª?P¬@O«?N­FR¬ER«@N®ER¯FR®DQ¯CO³ET³JPµLV¸MVºLSºNU¾QXÁRW¼PVÄPUÄV[ÄX\È[\ÊX_ÊVWÇ\bÊVZÆ\ZÈX^ÈTTËTWÐZ\ÐZ]ÔgbÐ[VÄQR¼KR¼HPºMXµKT¹NW½O[ÀT]À^^ºRX¼RX¼X_Æ]cÃ^dÃ\c½\d¿]bÂ^b¿em¼dl¼cjÀ[bÀjlÅdoÂlrÆhlÊqoÅjiÁisÃhlÂrv΂ÈllË|xÏ€}ËŠŠÎŒ‡É~‚ӟء֠”Ú°¢Þ²šÜ©žØ¦œÛ¶¨Û«šØ§œÙ²¨Ý¸¤Þ°žÝ´¤Û¸¬à¹¦Þ² Ù¯žÙ±£Øª›Ó°²Ô¿½àËÂåÏÃæÌÄè̾èÔÆæÎÅèÎÀçÑÆêÓÄîÖÆïÞÒôáÎïÚ¾»|’1Hš4K¡>M©CR¬GT®DQ®HV®CT¬FT¬FW­BS¬DT¥DV¤@V­DXµN\¾Q^Ï`cØgbÞsláwiå}nä~lä}kæ€kä}nå|nâ}qà|oÞrfÚg`ÌZY¼JP¬?J¤;M§;M³IXÅU^Óca×kmÞtpâxlàujàsdÝoaàpbào`àtcârdßpbÝpdÞncßqdÞodÞqhÞuiÝqgÜtiÜreÝrdÞrfàsbásháwháthâzlå€næzkÐ_Z.JZ>VET=X?X<\>^>`>c?f Da>e@f>b@]AX=Z=cBjBhC\AVAXBX=^B`Go-R|:[t5XdHW=o)K XhÅxzÛƒuä’wéˆvèhâtcÛdVÊQP­@K™.Fš0Hš4H™4Gš0Hž5H®CNÄTUÖd\àq`å|bê…fìŒkì’kênìqì‘rêjêtè‡pèƒkæz`Þm[ØaZÌOP³>Kœ0F+C+Fš2F 6I¤;L¨>Rª>L¬<O®GT­DT«DP­DP©CP«BP¬BN¬AO®DT®HQ²HS²ITµJRºNT¸OZÀOTÀNV¾RTÀRVÀPTÃRVÅSUÄXYÉVXÆTXÄZ`ÍWZÈWXÈTYÎYXÌXWÐ[\Ò\]Ñ]VÈQT»IN»LQ»NTºLU½NU¼T_¼U`ÀZbÀWa½RY¼[cÂ]`ÀX^¿[fÀ[^½Z`¾Z`¾_d¸T]Àcf¿`dÀhnÂckÆru¾bkÂlqÃbdÄnrÉhkÄlpÊrqÇprÉopÇimÐ~zÉzw͈„Ô•ˆÔ…Ó˜ŽÚ«—Ü® Ö¢œØ±žß³œÚª ×¬¢Þ¹«Þ­šÖ§žÚµ¨Ýº¢Û®™Ö§›Ò ˜Ò¨¡Ò´´ØÀ¼äÌÂçÏÂèÏĿɏåÌÀæÌ¿æÌºçÐÂçʼèͼéÒÃêÐÃîÙÉïÞÐðÞÈØÄ¸¤^l0Iš7J¢>N¨FS«BQ¬ES°ES­DP¦BS¨FVªDS¨BV£=U§BV´KZ»P\Î`dØjhÝrlâuhäzjåmä{iæ~lå|mâznä|oàzrÜskØljÏ_`¾NW¢8J•1H–2J¡6MºJXÊ[_ÒhiÜnjÝtkàvpßseÝrfàobâreàufár`ÝpbÛoaÝofÜrjÝpbÝndÞpfßqhÞvjÜrgÜshßshßsiâulâviãviåtæ€pÛmc¢<O`@T>T?U 8Z8Z8[;b>c>d@d@d@f=b>`@W<Y<b<i>i?`BU?ZBYB\AcFi(Or-Ts0Tn+P`?p&J›SdÀprÒ~wÙ‡vß‹uè|dãybßm^ÑZQ·EO 5J”.Dœ4K4I5H6J¢8H±DOÆTTÒbVßq_å|dè„fënì‘lì’lì‘pìŽnênëŒoéˆmédåz_àn[Ø`TÈMQ®MLž5J+E,F˜2HŸ6H¥8J¦?N§@N¬?QªBP¯@N¬BO¬CT¬@P®L[®HW«DR®FS®AN³HU²BO¶JRºNV¸OWÂQT¾TX¿QTÃQXÁRZÃVYÄSVÆX[ÊTXÊWVÆW]ÌVVÊZ[ÊVYÌ]XÌYYÏ[\ÖaXÉPRºHP¸MT¹IQ½KRºLT¼OTÂX`¿V`¾V`¹T`À]bÂ\cÀVZ¿Zb¿Zc¾]b·T^¿^]ºXb¼al¾`gÄfgÁgnÊjmÈlnÌroÈipÊvvÄcfÂprÇklÃqvÇrsÄjnËz|ÎvwÍ€Ò‹†Ï†…Õ™×›Ž×œŽÜ¯£ß®˜Ü©šÚ¬¡Þµ¦àº¥Ý°¤Ù²¦Ú´œÜ¦Ô¤–ΜšÏ¤¨Ñ²¶ÞÄ¿åÌÀæÎÂèʹæÌÀå˽äɾäÉ¿äÍÂäɼæÌºæÍÀäÅ»æÊµéÐÃéÓÈîÛÐïÛÍðßÄд­—BT”2F˜7LŸ<M¨>P¦>MªDR­@O¬@Q©DV©@Q¨AU¨?R­>T³KZ¿PYÍ]d×efÝnjàxläpä€mâ|kä{mãznã~pä|páxpÝqjÙleÍ_\¼NW™:J„%C€"AŒ(D¨@RÃTZÎceÕhiÛrlÞvjàujàtkàn`ârfàveàtiÞrgÛpdßqdÞrhÞn`ÝndÝrfàthàobÜpdÞqfÞsjàtjäxiâvmåylénßvi¹LPmCU=U9T :V 7[:]@b?d@f@fBc>f@c@`<X>W=_@d>iBbAZ=W@\?^B`Bg"Mq1Wv6[l)Pg%Jz1R˜Nc»mrÎxÏ}tÖ~uÕ†yèvaâr^ØaRÃLL¤7G›.Bœ6L¢5H¡:Lž9Jž1D¢;N®BLÅTVÔdXßo[ä{hçˆnëŽhîpìlìrëŽrëŒnêŽnêŠmè‚däzbàn[×bUÉTR°FMŸ6J‘-E2L˜3G:L¤8L¤:L¦<N©@Q®@M®CP®BN«BP¯FQ®JX°DQ°BQªAR®DQ²DN²HT¶JRµKR¼LS¾NUÀQTÁPQÆPOÅPUÇRTÃRVÄVZËVWÊUUÊVVËVWÊZ^ÌYXÌ\[ÌZ\Ð]YÇW\ºLT¸FP¶HR¸HNºPZ½RV¾T^¿X`¸MX½XaÂ`hÂY_¼X_¾[bÀZaºU\ºZa¼U]¸V^½^fÄbfÅghÄkoÄbbÆntÎttÆhnÌolËlnÇooÈilÄrvÉzyÇosÌwuÉkqÏ€|Ö†€Ò€€ÔŒƒÔ‘‹Ö˜‘Û£–ݪ™Øš”Ù®›Ýª“ܨšÚ¯ Þ·¢Ú­žÏŽ‡Ï–”Π¥Õ¸¹áÉÄäÌÃêÓÈèË»æÈ»åÃ®äÆµäɺå˾å̽ãǺäÈ»äÆ¹è̺æÏÂâÆ¹èʶéÓÇëÔÆîÛÎìÚÌêØ¿º”—”:N”-Fœ2F¡;L¢>O¥CU£@T§AS¦F[¢@R£?T¦:O©@T´IXÁPXÏ[_ÖfcÝokàznä~pä~mázmä|kä|lâ}oâ|qÞzsßqkÚlfÑbdºQWž7M~=q@x=ž4I·LWÊX\ÒfhØlmÞumàvmÞvgßriàocÞofáreßsiÜndÜmdßtlÝoeÞphÜpgàrhàpfÞnbÞodàpfäneæpfäxoê~lè|mÈc`†%@[:R 9U8X 6Y :Z:^=eBgCgChCdBgCaBY@T ;\Bd?hBa>\@Y@\B_Cf1Vh2Zm'Rr6Zp1Xn*Rx2T™Lc·lsÉ|xÐwÌzuÍzsÖ}râq^ÜfVÊTP°>Jœ2Iš2Eœ7K 8I¢8G¡4C2Dž7K®EOÃTVÖe[Ýscä{bæ†péŒnìŽlëoìŽqëŒlêqêqèŠkèeãy_Ýo\ÖbXÈRO°CMž5I‘,F’(C–2Gž3G¥:O¤;N§@P«;Q¬>M¬?R°FT«FR¯FS°HU­FU¯EO­CT°DO®ES¶KS¹KT¸LT¸KS»OVÁPVÀSUÄRUÁT[ÄQWÅVXÅW\ÈVVÌVXÊXXÍXXÈYYÈXXÍ\^Ò`\ÉRR»OXºJQ»JO¶LXºHP¼PUºS]ºNV½PXºU^ÆZ\ÁY_¹UZºQXÂ`g¼TX¼V`¶U_ºU`ÀW\ÃcgÅ^bÆgjÂ^gÂlpÊkmÊorËjiÇdjÌqsÊfjËnpÐtxÆmrÏrrËtvÎzÑwtÎ}wÒ†Ñ~|ד†Ø”†Õ“Ø£˜Þ©–Ù¡˜Ö¡”Ú³£Û¦ŽÒ•ŠÏ”’Ê•—Õ´´áÀ·æÍÄéÍÂèÌÁêʸåÈ¼ãÆºà¼áÅ´åʼãžãÈ»âÈ¿âÄ·âɼåǺèɹæÎ¼âƺå˹åÍÂêÐÃìßÒíÚÈäÓ»¸ˆ‹2G“0H›0FŸ9N <P£BS¢?T¢AT£@S BV¤>RªAS·GTÂPZÎZ\ØgdÜqnáznä~qå|lå~mç~kä{là|pâxnÜytßvkÚljÌaf¾V[ @R‚"Dh=p>Š$@¦;LÀQXÊ\aÖhgÜpiàuoàzoátjßpfàpfápdÞthÛqgÜogßpbÞqfÞpgÞqiÞrdàshÝn_àreàqfäqfæuiç{qé}jÜl_5FbAT8V?Y>Z;Z<`@dBjBgDdBfAf@`@\AU@Y>h Dj"Bd?\=X?YB^Aa#Je&Oh)Sl-Vt8az/Z~3Y–Pi³iuÈzxÍ~ЂzÈwsÇrqËulàfRÔ^N¼FJ¡7G˜2Hœ6HŸ8J¢6G¡:GŸ7E 6HŸ4E­EMÃQRÔ`ZÜq_äybèfêŠrëŽoënìŽnêpêŒlìŠnèŒlèƒbäycànZ×`UÊPL´DNž2G‘(B,E˜4Jœ;N¢<P¤?P¨ATª>Pª@S¬DV®GU©CN®HV±FPªDN­ER«CP­CR²HQ´IRºJP·JR¹LT»PUÀPSÀSUÂTXÃPTÄTXÇWVÈZ`ÈZZÉXZÈQTÌZ\ÈWZÉXYÐ^YÉXU¼JQ¶NX¸GN¼KQ¸OXµKWºQ[¾RY¶MZ¾[`Å\aÀRW»X_¸T_¼Z[¼W\²QZµQ^½Z`À^dÁ[\ÄdjÄc`¼X_ÇfjÆkoÇvsÆgfÂnpÍtrËlmÏrnÏqqÌuxÎvtÏrsÒ|xÏzzÌ|}ÌyvÏ|ÔŒ‰Ó†ˆÑ‰Ù¤–ܪ™ÚÙ¥–Û¬š×¡•Ì„~ƔϦ¯Ý¹±èȺæÈ¼ê˶åËÀãĵßļâ¼âȾäʸÞÀ¶æÈ´äÊÁâÈ¿ãǽáǺãµäȸàżãǹåÎÆãÐÇäÒÌèÔËíÝÑîßÔíØÂÜÆ¹¡[kŽ/E“1I—6Fš8Mœ7M>NCU¡?R¢@R <P¦?R®FU¼Q]Î]_×ddÛnláxoå~tå€tä€sæoå|jã{mãznà|sßxqÜolÓefÂV_¦AP„%Bd8^9y:˜1G³FSÃR[Ñ__ÚkhÞumÞuláwkàrcßpdàrfÞpeÜqfÛmcÞpgÞnhÞrjÜnfÞqnàrgÞpfÞuhàvpãwnçxnç~rÞscµBNk@VAb8\`0S^IZ<\=eCfAgAe@gBfBcB^@X@X>b@jBfB]AY>[@\?`=d$Lh%Nm+Vt4_u0\‚:`–Kh­fwÅvxÍ|zÐxÓƒwÂqn¾nl΂zØZNÈQN¬=H›1I›6I¡8L ?Nž8J¢:M5G9JŸ6G«>LÇTSÕ^XÞr`ã{gæ„hèŠrêŒpëoì’têŒnêŠlìŒnêŠgè…dåz`àlZÖ^SÈRR°@Hž6IŽ,G+F•8L›8L£<N¨?Q¨AQªAP©;N¬?L«DO¨@P­AM¯DQ«@P­@N¬BN®FS³HS´HN¶FQ¸IQ¸QY½PT¿PVÀSVÃRUÄRUÇTTÈUWÇUVÊTWÇ[\ÆVXÈWXÉYYÌZ^Î[S»MR¸JQºJO¹KR½MWÀRZ¼QZ¼PZ¼NX¾W_ÃW\¾V^½W`½V\¾U\·V^µN\¬M\µTb¿]eÆbcÂehÂaf¾ekÂhmÄhmËwtÌmnÌsrÌvrÆptÐwsËnpÎxxÔvuÏwvÐtkÈruÊsrÎqsÎvvÏ{vÓÖ’†ÛžŒÙ™‹Ú¡”Ü©—Õ–ŒÏŠƒÈƒ„Çž¦Ü¾¸âĸãĹæÀ±çŴ俵âÂ´ÞÆÁäÌÃæÐÄäȺâĺâIJ῰åïáĹâ¶àÁ·ßĻ߯ÂâÏÇäÎÄéÒÂèÐÊéÓÄêÔÈìÜÒïàÔìÜÒìÛÀͳ­—ASŠ-CŽ1G“0F˜6J–9L™8Mš;Pž;P¡<P¥@S®GXÃQ]Î]_×ihÞqlázmç~mæ€qä|lå}oå|lã}mã|qà|vàskÚppÑglÂZc¨BT‚$Ab9W;fB†,H¢DUµKVÈX`ÕgbÝojàtláwpàthÞpgàsjÞpgÝndÞqfÞocßncàrjÝohàrcàrjàqeâpdâulæukê}pærÍZV€ @Y@V@V;Z>Y;\>a<c>h>hAd>gBfA_>Z>X?a?n Bm$E]=Z@]D^D_@^Ab"Gh*Xl.Yv7b:_”Jg«at¼t|ÊywË~{ÐxÎ|xÀon΀wÔ‹ÌRP³DHŸ2F›2Fš7H¤>N¢>L£:I¢8H:Hž2Dž4H®AMÃQQÔc^Ýq\âxbæ€fåŠfëŒnì’sêqêŽsêuínêˆlçƒjä|dÜn`Õ`TÇOMµ@HŸ3GŽ+FŒ1J4O˜<P¢BR©AR§BP¯FS«AUªBN®BN¬AS¯DM®DSªCR±FR­CO®BQ³JT²HN·GN¸JP»MP¾QYÂPT¾RYÂUWÄRQÆTSÄUXÁTYÆVXÆV^ÈZ`ÎZ[ÍZZË]_¿TX¼TT¶KR·HQ¾NSÁSZºPZ·LW¼T`½R_¾W^»T^¼V]ÂTV¶JT´S\°HY³P\¹Ta¼Zc¼V_ÊehÂblÁfnÆabÇghÌlhËijÌrqÍgjÈtwÎvsÒrsÑwrÒ{zÎzvÍnlÀhoÎwtÈlmÍyyÓyvÏ{zׄ׈֒‡Ú©šÖ”„ÑŽ€Å€}½ŠÐ¤¨âÁ²åÇ¼æÆ¶åȹâ÷ửâÄ¸áÆ¿æË¼æÌÁæÅµãǽâÀ²ÞÁ¶Ý»²Ú¶¬Þ¼®àƾàùäʽèÒÆéÔÄçÎÂèɹåÌÀäɼå̾èÒÃêÔÅîÝÍîÚÆïÚÁ¸…†“@M†0F…,D3G3H˜7Kš8Lž7Kž6O¦?O¬HXÃRXÑ^[ØifÞphâxnå}pæ~pã}lä~täziâ~sâ€vá|rÞvnÚphÒb`ÀVZ¥<J‡%B_ 6P8`@v$F˜<U®GWÄV^Ñc`ÚjgÞpkávlávmàujàpeÞphÞldÞqfÞlbÞpißphßndÞqhàpjàqhâseåthèxiê|mÛmb£7F^;R:R :W?X<]@bAh@fAg@g?j!De@`:X<R 9^;fBpBfBV<[@^>aC_AaBfLi&Tr5b~8b•Pn¨bwÀv}É~|ÈÌzwÎ|sÂqrÊ{qÔ‹|Ø{¹CK¤9I™3Fš5N 6G¢:L¡:K¤;K¦9Lž6Fœ1DŸ8J¯=IÃPTÔbYÝnZâw`æƒièˆjéŒvêpësêuêŒrê‹nê‹uè‚lã~iÞn^Ôe`ÆRR²LT 2F)E4I–5K;O¤<M¨BQ¦?M«DP¬ET¨?O®AP¯AM¬@L®CQ®DP°BN¬HQ­FN²FS¯FM¶ER¸JRºPT¾OTÂQRÆX]ÂUWÀRTÃSVÉQVÆVXÈVXÈVZÈW\ÆZaÍbaÆYZ¼X_¼Q\¶PZ½U]¸IU¼RZ½NZºNX¼R\¾S\ÁX\¾U^¾SU¼OZ¹RV¶Xd¶V\¸Zg¿X\¼\iÂ`b¿\dÅklÁ_f¿hlÈeaÅotÊlhÄbdÊrsÎolÌtrÓtnÒyvÓzvÉloÄrxÊssÊosÌrrÐtwÏyyÖ‚{Ò€ƒÔ”ˆÚžŒÕ‘€ÈxzÀt|•ŸÙ¬£âøã¶ä´âµã÷ã¸àûäôæÉ»à½²åıßÀ¸à¸«Ý¼³Þ¼²áÈÀݸáúçʹäĸäÂ°åÆ±âÁ²à²ÝÅÀ߯ºàÊÂàÉ¿âÎÀäÐÆåÐÅèÔÈîÚÈÜÎŶŸª™`tŽ>O‰,B‹.BŽ0B™2Fž:G›4K¤:N®DQ¿RZÏ]^Øhbßoiâxkå}så~mä}qå~räylâ{pã~ràynßwnÞphÓdaÄY_¥<K†">c9UBWFg Gˆ3M¢BTºIUÊ\\ÖbbÚmhßtnâtnáufârbßnbÜndÝmbÜmfÞmeÝoiÞrlßqjãrhásjäxjèylêzläti¾NPq>Z?Q
9V 8W;W=`BfDjEj"DfAe@dBb;^<Z<[?iBnBiA[=X=aE`BbDd Fj*Qf&Qg"Nu3]IjªdtºryÊ{|Ë~{Î{ÂxvÂutÊ~uЈyÖŽ}×’¨;Lš2F›6J›6J¡7H¤;K¢>P¤:G¢;N 9L 4Hž4G°DPÁOSÔ^UÚmZâyhæ‚féˆhë‹mêŽpéŒréŽtéŒrëˆlé†lç„käydÜj[Ö^VÄTS²DL7K*CŽ+B”+Eœ9L¡;Q¥@P©?R«BR©CRªBQ­DUª@O¬CNª@O¬BO°DO±AO³FPµFR±JO´JQµJS¹MU¾OZÅRVÄTYÀSUÃSVÄNQÆT[ÇVWÍXXÊV]ÊWYÌ_aÔe^ÂQV½NT¼LVÀQW¾TZ¼PV¸OWºLT¸RX½QW¾T[¸V^ÃT\ºOV¼Yc¾Xc½\d¾X`¼WdºZbÀYaÆeiÆfhÁbhÃjnÅ`fÀlrÎtrÇkoÌtrÌfmÂnsÒurÊjjÑvmÎnnÇsrÍnlÉinÎrrÐpmÎ|zÐxtÎvwÓƒÙ–‰ÔŠ|Ãpp·o~Ì¥¨ß²¢à»±å¹¦âÄ·àÀ¹ß¹«ãƺæÉ¼åȾ᾵⺬ßĻܾ»Û´¬Ú¿¼à¸¦ßøæÊºãŶིྶ޼±ÜÁºÞúàúà¸äÊ»ãÌÄäËÂåÎÂãÎÀæÎÀæÎÄèÒÅìÖÉðÚËîÞËÖÎÀ¬„“…4F‡-F‰)A’0F•3H–3H£:L®BOÁOZÐ\^ÖicÝolÞwkäpå~pã|lætä~lâ|nãzrß}vßztÜqlÔdaÃVX¥>M‡&Af:X=X@`<p82Hª?LÀTZÏ[]ÖgeÞoiâvlãtgâseàqdÞqdÞmcÜmfÞkaßnfßphàriárjátkæxlêzlèxhÑ^Z‰*FZ;S:T ;V ;W:\@gAl"HjDhAhBg>f?]<Z:W>d>qCjC`@W@[BbB`CcD`Ie"Jh$Rl(Sƒ;_¦[n¾rzÅzzÊ{z΀|΀vÁvxÅ|zÓŒ}Õ”€Õ}דš:N—4H7J <J¢8J£9J¢7H¢8J¤<Nž8NŸ5GŸ6H¬?MÂPOÐ^XÛpbâu`ç„jè†nëŒpèŽjéŒvèzèŒsìŒtèŠrè…mäzbÞpaÕbYÉRSµBMž5F’+C,D—0C7H¢9J¦=N¨@Q¨@R¬GS­CP«BN©DP¯EO­@M¬FP®AO°HV®IQ°DP²HN¹HO¸MS¼JS½MSÀPWÀTVÁRUÁSVÆV\ÆTVÆTZÇX[ÈTUÉW\×i`Í_\¼HT¼IR¼HR¼KTÁTZÂPT¸N\¸NU·NX¼NV¼QZ¼TZÁV\ºNX¿Xb¿W\ÄXZ¹XbÀX\»_hÃdmÆbcÁfnÆba¾`jÉnuÉfkÍorÐppÉfkÊnpÐpoÊt{ÏrpÍptÌllÌnmÀirÇlkÄlsÈrtÌoqÊxyÐ~{ÓŒˆÐ€{ÄimŒױ§á½®Ýµ¬â´ Ûº¶ß¶¨äƶ࿴弧æÄµå´àÀ¶Üº´à¼¯â¹ݼ´ãǶܶ¬Ý¼²Ý»±à¿­ßÄÀàļàļãŹæÈ»äƼâǼâȾäʾäËÄäʽäÍÂåÌÂçÍÂçÒÆèÔÈêÕÉñÚÈòÞÈàÖıŒ•¢FP$@‹)D/F”2Gž6K®BO¾MTÎX\×hdÞrkàznã~på~pã|nå~sã{mäykâ~sâu߃ÜlgÒdfÁRX¨@L‹'Dj<Z>U:W 9f9~;™4J²FVÈV]Óa`Úgeàthâtgàteârfán_ÝlbÛlbÞqgàpgàndáqiãtläulçxmê{kÝj`¦8Ib5T 8T 8T9Y<\<^<h@i@jDl HgBfBfA\?V;`?kDlA`>^?\D\=fFbCc I`Lb!Nm$R{9^Ri¼nxÆwxÆy|ÈxvÎyÈzxÄxzщ~×~Ö“€Ö‘€Ø‘~˜<Nš7Kž9L£<I¤<K¤:K¢<M£=K :L¡9Jœ6K 9L¬ANÁNMÐb\Úpbâvdæ‚jèˆpêrèŽxèŽté‘zéwêŒrèˆsèƒiäzdÜo`Õ_XÇTV´FN <O‘*DŽ(B–0FŸ2F£:K¦=M§<K®BP©@N®@N¬BS¬CQ­FR¬BO«DP­FQ±EO­@I±FR´EJ¸JN»LRÀLQÀNSÂTVÂTWÀVXÂWXÈTVÂVXÂUXÅUXÆWZÎd^ÔcYÁRU¸LT·PW²EQ·LW¿OTÃRW¼OXºRXºNV¾QU¶R\¼NW¸PY»TZ»U`¼RZÁWZ¿Yb½^fÈfgËhlÈgjÃ^dÅlsÍpoÌmpÐwwÐsrÈhqÏzwÏjlÌnnÌonÈkrÏpoÈfhÆlpÊhjÂbmÌrsÌprÌtnÇnnÀkqÄrp¿nxÉ’‘ܱ¨âº©â½®ß¼¬Ú¶²ã¼£Û½´à² á¸§Üº°ß·©Þ¹¬Þ»´Þ¼°ÞÀ¶äÁ®ß¼µßµ«Ü¾ºàÄ´âÈÁß¼±æÄ®åÌÃåǸáÈ¾äÆ»ãȾäʼãÊÁâȼäʺãÊÀäÌ»è̽åŰçϾèÏÀçÏÀêμíÔÃðàÊâÖ³}†}%A"=ˆ'@.Cœ6L¨?O½MVÌ`aÕfdÜocàxsä€rã}sä|oæ~pâzpâ|räzrå€pÞxrÞldÔb_ÀRWª@LŒ'Dl:^=W:W 4`;m:Ž)C¨<LºGSÌ`aØdcÞohàuiâtgàtfÝqeÜm`ÜlaÞkbàndßriâtjátkäyné|räsd¾PTr;Z>T:V<V<Z>`Af@j Bh@i@h=fBeDa<[@_AgAjBf H\>\>c"Gb@cBaD`I]Hb Nv3\˜Vn´lxÅyÇwxÃw|ÊzwÆxxÁxzÎ…~Ó}Ö”‚Ö”€×’ÕŽ}š4Jœ8H¡:L£<M£<N¤<K¢<K¡?JŸ<Jž;Pž6J >P¬BNÁUYÕaZÜo`âuaç‚næ†oè‰pèŽréŒuêŒvêŠrèŠpé‡oè‚jæzeÞpbØbXÅRT¯BM <R’*DŽ,H–/Fš8K <M¤?N¥?L¦AM¨>Q«>M®FU®IV´BL¯@M®BP¬BO®EM­DQ²DQ³EL·IPºLS·JQ½NV¿PVÂRXÂTWÄVZÆXYÁVY½RXÄPUÅ\_ÝŠuÊSTºHM±BP°EP®EP¶EPºNRÂRX¾V[¿RX¹KT¿SU¾OX¾TX¾U^»PV¹R\¼X_¸Vb¾X`Ã`_ÆhkÈadÁfrÈrrÎijÏuvÒwuÎnoÇrvÌljÌnpÏvwÌqyÅntÎurÉflÉmrÇlrÈlmÉhhÆmrËrlÆkn¼em½js¿|ˆÑš”ܦ–ᶡඦ࿴࿰ྰ߯¢ß¸¥Ü¸²Û±¦Þ¶£Ü¸°Ú´²àº®àº­Þ´§Ý¶²àÀµâÅ¾çÆ·á¾¶èÆ±äɾ߽¹èƲäÈÁåÊ¿ãÈ¾ãÆºâȼåʾáøãŸãÊ»ä̾ãʾâȼæÎ¾æÒÈäÏÄåÑÃæÎÁê×ÊðؼÜξ›Vjv:~"@Œ)A˜4H§>K»NVÎZYÓd`Ûngàyoãzlä~på|oäzmæ}päzrã|oã~uãwnÞnkÒdcÄTZªBNŒ-Hj<\8[9X6X5b 5v6+E°>JÆWZÒ][ÚfcÞnfàriàteÞndÝk_Ük`ÜjbßjaàtjárhãtlæznèygÑc\Œ(F^;V<V;\=Z>^<d=i>i>h@f@eBh"DcA^@[?dAh Fc<\;V:^?`Bc?h$IZB]H\Mp(T”NjµlxÇ{|Ê|ÆxvÃxyÂquÀsvÇ~xÒŠÖ”Ö”‚Õ“‚Õ’Ô~›6Kœ4J¡:K¢>P¢<L£;Kž>N¢@N¤=K :Lž:N ;L¬GSÀQWÒc\ÛlZávbä‚må†nè‹pæŠpæˆrèŠtéŽsè†hçŠrç„jå{fßp_×f`ÄRS°DOœ6L‘,G,F–/Fš5K¤:N¥<Nª>K¨<O«?L¬?L­CR¬FU®CPªDT¬@L¬@M¬BN®DO±FN´FN¶HPºKR»MT½PW¿MVÁPVÀV[ÂQVÄQU¿QUÀNVÂNWÞ„pèmÆNR´AMµDP·IU´DO·JQºNZ½MR½QY¾PT¼MT¼OU»QX¼QVºMW¶P\¹PZ¼W`Ä[^¿^hÄZ\Ã\fÄmuÌjmÇ`jËsrÒssÍsuÌrnÆ\`ÄnsÎqnÐptÌyzÏnqÐqsÊrrÂenÂioÀ^hºbnÅllº`j¾blºdrÍ•’Û²§Ú¨™Ú¢˜Þ­œá»°æ¼¤à¼¯Þ´¤Þº©Ý±¥ß¸¦Ø´²Ù°¨àº¦Ü³§Ú¦šÚ²ªÚ·²âÀ±âļåÄ·äÄºáÆ¼á¼´çÆ·ãÉÁÞÀ»æÆ²âõãÇ¿áÄ·ãʼå;ãȺæÈ¸åʼãÊ»äɼàÈÂáÆ¸çÒÅçÐÅèÑÃèÕÆéÚÒéÒÄîØ¸É®¨~*D~ ?‡#B”/D¤;H¹HRÌ[ZÔd]Üofàvlå{næ}nä}lä~oä~tä{rá}rá|wàvpÜomÓbdÄXY¨FRŠ,En=]<^<]>Z7[ 7f5~>›2F²DNËUSÖ`ZÚh`ÜobÞviÜraÞk^Ýj\Ük`àlbßreärhåwpæzmÜma¥>Ib:X>X<X=Z<X>`;iAj>hAgBi!EhAdC`@Z?^>gBfD`CY>^@dAfB`>_AVA_Kj%R…?a¬cwÇy}Î}È{|Ãrt»nv¿psÉ€ÒŒ}Ò€Ô’Õ‘~Õ”‚Ö“~Ö‘ <Jž8I¡:L£?L¢;L£>L¢9J 7I¢:JŸ9Jž7L 4F«CPÂSXÑ`WÜnbâzeå‚mä‡pç‹oêŽoèŠsè‹qè‰té‹tçŠræˆoå|iÝpcÔcbÆRS³EP<SŒ,I,G•3Jš5J¡8K£<L¢<LªAN¨DR«BO¬BP­CR«CN®FP¬CP®AO°BN®EM²DP¸FMµGO¶KR¹NSÀSYÃQTÄSX½RXÀPNÂTVÂORºPVÀTZê©„æƒbÂEL±=JºDN·KT³HV´NZºRZµLT»R[ºLVÁOT¾NWÀPXºMX¾T^¼U]ÄX^ÂV`Ã`fÆ^d¼YcÈbbÌ]cËjqÌjpÑotÒztÍgh¿ajÂlrÏleÅioÔurÌjsÍorÍloÃchÃmn¾`j¾`fÁ`bº`j´\f¿t~Ó–Ý ‹â¸§Ý¬¢Þ®žß°¤å´›à²¤ß¶ŸÜ±¦ß¶¨Þº«Ù­¬Þ¸ŸÛ²¨Ú¨›×°®Ù´¯à½±à¿µà½¶ä³âÄ»äÄ¹äÆºáÇÀãÀ±åÎÁàÃÀ⽫áÉÃåÉ¹áÆ½äȺäʼáǺáÈÀâȽßÄ·àĸÞĺÞĶàÊÂäÏÂæÔÈçÑÅéÚÎìÚÏëÞÊãÑ¿£ft˜;J„ BŽ*Bž8HµFOÊUVÔbZÝnfàvjä|lä~oã|mä€qä~qãztä~tàznßxoÜlgÓcdÇTV«CR+Er>^;\>^9\7[
6^ 4m5‡"=Ÿ8F»IOÊVUÒ`XÕj`ÚqbÛpbÚj[Üj\Üh[ßn`ÞqdâtjåwlàvkÃRTt=V<V9U<Y=[=`Ed<j?f>h<gBfAf@cCZ>^BcBiDcBZA^DaCjBiF`@X@R=`Iƒ<d§`wÄy€Ð€€Ì}|ÈxzÁrqºnsÇ~|͆}ÔŒ{ÕÔ|ÖŽ|Ô~Ô“‚Ö‘}Ÿ>P¡<J¡:H¤<J¡<M 8L ;L¢>M¡<Jž6Hœ7Kœ7K§APÀOTÒaZÜpeâweå‚lç†néŠnæŒqèŽoêoéˆpéˆsé‹xçˆuä|iÞrdÔe`ÈVT²EQœ5MŽ,HŒ-K–1J˜7Mž4F¥;L¥<Lª?MªAO«AL¬BO¬FSªDS®FT°FS¬DQ®DO­DV²FR´LX¸NV¹NU¼KR¾PTÂMU½OVÀSX¼T\ºPX¸JU´K\Îmdô»ŠÚuY¸BK¯BL·EO´HU¯KW¶KV·JV¼LT¼NXºKU½PU¾RW¾PWÅZ\ÂZ^ÄVZÄY_ÃZ^ÀZbÅdeÇ^d¿alÇhlÍopÒppÓwnÈbcÃhpÆjiÈilÃhsÎtmÎjoÎqrÐmjÅflÆehÂahÄde¹Q`®Pd³ViÁ„ŽÖžšÝ™†Ü¯¤â°›àÀµà°¢á³¢Ü¦šÞ®—ܯ§ß¹£Ü¹¬Þ´¢Ý¯œÕ šÚ¶¬Ü¸µá»ªß¾·Ü¶¯à½­ãÀ³ß»°ãÁ±áżáÅ¼ãÆ´ßÀ»ä°ãÊÁÞÁ»äIJáŽáŸßżâĵàµàÀ¹ÞµÜÊÄÝÇÀáÊÀàǺåÌ»äÎÆæÒÆçÓÈèÔÄëÜÒîßÏëáÊÑĺžXft=Š'Cš2H¯HRÈZ^Ôd`Úmfßugãzlä|näzmä~rå}nâ~wä|rá|tÞxpÜniÔb`ÄSZ©DT.Jr?b>`<_:`:\ 5\ 5] 5l5‡$> :G³HNÂVXÌvyÒ“ÖŸ Ö£¤ÐŠÙi`ÛndÜ„}ãzjäwfÐcZŽ'D[=YAW;[@Z;`Bb@h?j$Ig?f=iEhDdB_C^Bd>fDeE\?\BbBhBi!Cb>X=P 9T@r*S›Ut¿t|Ñ}~Î}~Äx{Ápw¿prÈzuшÓŒ}Ռ֑|Ô‚ÔŽ|ÔŽ€ÕŽ|ÕŒ|¢<L¢@P ;L¢:H <Nž>O¢=J =Ož:Mž:Lš0Fœ4G§>P¿MPÒd_Üpdáxcähç‡nëŠmêŒrê‹oé‹séŠsêŠoéŠvçŠtä}iÞr`Ôc\ÇSV²FTš4N.JŽ+G”2Lœ6L¡7K¦>N¨>N¨:L©>K¬<J¬BP¬AO±FR°IV«BQ­DQ®ET¯GX²MZ²LY¶GQºLS¸PW½KRÁQZÂRVÀRV½LR¼LT¹IX¹Q]誊õ¯Íb`°?R²IU®HY²FSµFV¹GOºNWºHU¼PWºNTÀPTÂOR¾PUÅSVÄV]ÅYaÂR[¿[bÌaaÆ^gÄblÉioÊinÒsqÐhgÄfnÊklÌihÄhrÉnkÍlhÆlvÍruÍpuÅmrÈbg¶^lÂce²P`ªOd´`p̘”ݦ™Ü¨Ûª á¯•⯣㷜ޱ¨Þ¦œÛ¯¡Û¨œß¶žÝ°¤Þ¬™Ô ™Ó££Ü´¨à¾´ä¿²Þ¸²á¾®Þ¾¶Û·°à¶¦ß¿¸ÞÀ¸äĶãǾâÇ»âöÝÀ¸âÆ¹âÆ»àÄ»åÆ¶àÆºÞÁ¶Øµ¯ÚÀ·ßÄ½àÆ¼äÌ»äÎÁàÊÃâǸàɾâÍÄåÎÁäÐÅåÐÇêÖÆéÜÓîàÐîßÄ˰¬}"B~ C’0IªFTÈXXÐccÚldßxoäyhâxläyjâ}pà|qã{qä~tã}sà~wÜplÓ``ÄX[¨FUˆ+FpD`;]>a:_:[7\6X 5Z
diff --git a/contrib/ffmpeg/tests/libav.regression.ref b/contrib/ffmpeg/tests/libav.regression.ref
index a5ea5f15d..a498d6799 100644
--- a/contrib/ffmpeg/tests/libav.regression.ref
+++ b/contrib/ffmpeg/tests/libav.regression.ref
@@ -2,35 +2,35 @@ ffmpeg regression test
8a0536ccfe36f4fff408b3327d33e1dd *./data/b-libav.avi
340344 ./data/b-libav.avi
./data/b-libav.avi CRC=0x400c29e9
-85caa242a36abeab85a27c82ba73cc28 *./data/b-libav.asf
-339767 ./data/b-libav.asf
+786446e80ead936e5faa8f5908f19281 *./data/b-libav.asf
+339775 ./data/b-libav.asf
./data/b-libav.asf CRC=0x74113749
-1ad618e9fd318eb3483270cf9b9b3f43 *./data/b-libav.rm
+1ce78eeb6881ffe5b649a9b5105de919 *./data/b-libav.rm
355405 ./data/b-libav.rm
bdb7484c68db722f66ba1630cf79844c *./data/b-libav.mpg
378880 ./data/b-libav.mpg
./data/b-libav.mpg CRC=0x2b71a386
-0bf8fb3b4d7bb70ed89356e94cd8ffa2 *./data/b-libav.ts
-471316 ./data/b-libav.ts
+322d59758fe9446147223a607d1699bc *./data/b-libav.ts
+471692 ./data/b-libav.ts
./data/b-libav.ts CRC=0xcc4948e1
-16cf1c37c123f8d3c4a31d192d9b0cc6 *./data/b-libav.swf
-41836 ./data/b-libav.swf
-./data/b-libav.swf CRC=0xcdec36a1
-87a8c8be5db2513356b28f29dff5769e *./data/b-libav.ffm
+d6fdeb9f7083cc827f9510c6c4517dc0 *./data/b-libav.swf
+335771 ./data/b-libav.swf
+./data/b-libav.swf CRC=0xe14e8847
+a1cd7fff97d5e4c83f0d18a22d51c552 *./data/b-libav.ffm
380928 ./data/b-libav.ffm
./data/b-libav.ffm CRC=0x01522b4a
-5e8aa303a877cfac6569ed11cf20e92b *./data/b-libav.flv
-335810 ./data/b-libav.flv
+f8ad5bd78f4d012a8ce9570aa395ac54 *./data/b-libav.flv
+335833 ./data/b-libav.flv
./data/b-libav.flv CRC=0xe14e8847
16518706f425cb537362bfc1c58b8de5 *./data/b-libav.mov
366923 ./data/b-libav.mov
./data/b-libav.mov CRC=0x45079dca
-26c41db318d9aacfd6b9e734c0ea4d94 *./data/b-libav.dv
+7820fa85ab86c62028d8dbda94589573 *./data/b-libav.dv
3600000 ./data/b-libav.dv
-./data/b-libav.dv CRC=0xa6b8b635
-2b3f921fb7a01bb126cab5ee21ae3f8d *./data/b-libav.gxf
-815700 ./data/b-libav.gxf
-./data/b-libav.gxf CRC=0x238a01b0
+./data/b-libav.dv CRC=0xf517e829
+feb04ba3cf4f607d5527664eb69ec72e *./data/b-libav.gxf
+814640 ./data/b-libav.gxf
+./data/b-libav.gxf CRC=0xa376c09e
9a9da315747599f7718cc9a9a09c21ff *./data/b-libav.pbm
317075 ./data/b-libav.pbm
./data/b-libav.pbm CRC=0xb92906cb
@@ -45,8 +45,15 @@ bdb7484c68db722f66ba1630cf79844c *./data/b-libav.mpg
b977a4fedff90a79baf70c8e02986820 *./data/b-libav.y4m
3801810 ./data/b-libav.y4m
./data/b-libav%02d.pgm CRC=0x84c09106
+de216b43403f51e57e644fbf812568bf *./data/b-libav02.pgm
./data/b-libav%02d.ppm CRC=0x25c06ecf
+86bbdb77afa289ff363120f8044f29df *./data/b-libav02.ppm
+./data/b-libav%02d.bmp CRC=0xf3a66ecf
+c3a9f333ddebff6eae3f4360bad2de29 *./data/b-libav02.bmp
+./data/b-libav%02d.tga CRC=0xf3a66ecf
+f558eef0740c4b247f1eb17e1dbf7adf *./data/b-libav02.tga
./data/b-libav%02d.jpg CRC=0x62328baa
+5d6c53e5297c4485e26c25e37885376f *./data/b-libav02.jpg
b0a8c8063d81921db5d7c8f50a1cc454 *./data/b-libav.wav
89132 ./data/b-libav.wav
./data/b-libav.wav CRC=0x2a09519c
@@ -62,8 +69,8 @@ e2a6d6fae17394dfe87cb5bb8ae11837 *./data/b-libav.al
272b91d8fc31ed43b08246d182719751 *./data/b-libav.mmf
22609 ./data/b-libav.mmf
./data/b-libav.mmf CRC=0x03633476
-c8cf5bac13fb7862bcbce76977328f92 *./data/b-libav.aif
-89160 ./data/b-libav.aif
+ae3a23a7ea13c92a2909445ca8144dcd *./data/b-libav.aif
+89142 ./data/b-libav.aif
./data/b-libav.aif CRC=0x2a09519c
8d117c49d6b210abe783d1b0b897cec7 *./data/b-libav.voc
32768 ./data/b-libav.voc
@@ -74,8 +81,8 @@ ce356ce2708cb6033ab5d762da93cfd4 *./data/b-libav-yuv422p.yuv
304128 ./data/b-libav-yuv422p.yuv
ce356ce2708cb6033ab5d762da93cfd4 *./data/b-libav-yuv444p.yuv
304128 ./data/b-libav-yuv444p.yuv
-ce356ce2708cb6033ab5d762da93cfd4 *./data/b-libav-yuv422.yuv
- 304128 ./data/b-libav-yuv422.yuv
+ce356ce2708cb6033ab5d762da93cfd4 *./data/b-libav-yuyv422.yuv
+ 304128 ./data/b-libav-yuyv422.yuv
545f61c353a8b4419808785cb4f0069d *./data/b-libav-yuv410p.yuv
304128 ./data/b-libav-yuv410p.yuv
d6c03f930018ff859bd43f52b92e9321 *./data/b-libav-yuv411p.yuv
@@ -90,8 +97,8 @@ deb2f7ebe297df2c1fe264d19b34d2fb *./data/b-libav-rgb24.yuv
304128 ./data/b-libav-rgb24.yuv
deb2f7ebe297df2c1fe264d19b34d2fb *./data/b-libav-bgr24.yuv
304128 ./data/b-libav-bgr24.yuv
-deb2f7ebe297df2c1fe264d19b34d2fb *./data/b-libav-rgba32.yuv
- 304128 ./data/b-libav-rgba32.yuv
+deb2f7ebe297df2c1fe264d19b34d2fb *./data/b-libav-rgb32.yuv
+ 304128 ./data/b-libav-rgb32.yuv
5d395f62bff8ac475f743268c772ca3a *./data/b-libav-rgb565.yuv
304128 ./data/b-libav-rgb565.yuv
2ffd6871fcbfe9570454e8703ac8ea01 *./data/b-libav-rgb555.yuv
diff --git a/contrib/ffmpeg/tests/regression.sh b/contrib/ffmpeg/tests/regression.sh
index 70f4eba12..c4c2f776b 100755
--- a/contrib/ffmpeg/tests/regression.sh
+++ b/contrib/ffmpeg/tests/regression.sh
@@ -4,7 +4,7 @@
#
#
#set -x
-# Even in the 21st century some diffs are not supporting -u.
+# Even in the 21st century some diffs do not support -u.
diff -u "$0" "$0" > /dev/null 2>&1
if [ $? -eq 0 ]; then
diff_cmd="diff -u"
@@ -24,7 +24,7 @@ datadir="./data"
logfile="$datadir/ffmpeg.regression"
outfile="$datadir/a-"
-# tests to do
+# tests to run
if [ "$1" = "mpeg4" ] ; then
do_mpeg4=y
elif [ "$1" = "mpeg" ] ; then
@@ -41,7 +41,7 @@ elif [ "$1" = "snow" ] ; then
elif [ "$1" = "snowll" ] ; then
do_snowll=y
elif [ "$1" = "libavtest" ] ; then
- do_libav=y
+ do_libavtest=y
logfile="$datadir/libav.regression"
outfile="$datadir/b-"
else
@@ -69,6 +69,8 @@ else
do_adpcm_ima_wav=y
do_adpcm_ms=y
do_flac=y
+ do_wma=y
+ do_vorbis=y
do_rc=y
do_mpeg4adv=y
do_mpeg4thread=y
@@ -93,6 +95,8 @@ ffmpeg="../ffmpeg_g"
tiny_psnr="./tiny_psnr"
reffile="$2"
benchfile="$datadir/ffmpeg.bench"
+bench="$datadir/bench.tmp"
+bench2="$datadir/bench2.tmp"
raw_src="$3/%02d.pgm"
raw_dst="$datadir/out.yuv"
raw_ref="$datadir/ref.yuv"
@@ -107,7 +111,7 @@ else
do_md5sum() { echo No md5sum program found; }
fi
-# create the data directory if it does not exists
+# create the data directory if it does not exist
mkdir -p $datadir
FFMPEG_OPTS="-y -flags +bitexact -dct fastint -idct simple"
@@ -117,7 +121,7 @@ do_ffmpeg()
f="$1"
shift
echo $ffmpeg $FFMPEG_OPTS $*
- $ffmpeg $FFMPEG_OPTS -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
+ $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench 2> /tmp/ffmpeg$$
egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
rm -f /tmp/ffmpeg$$
do_md5sum $f >> $logfile
@@ -128,8 +132,27 @@ do_ffmpeg()
else
wc -c $f >> $logfile
fi
- expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
- echo `cat $datadir/bench2.tmp` $f >> $benchfile
+ expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
+ echo `cat $bench2` $f >> $benchfile
+}
+
+do_ffmpeg_nomd5()
+{
+ f="$1"
+ shift
+ echo $ffmpeg $FFMPEG_OPTS $*
+ $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench 2> /tmp/ffmpeg$$
+ egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
+ rm -f /tmp/ffmpeg$$
+ if [ $f = $raw_dst ] ; then
+ $tiny_psnr $f $raw_ref >> $logfile
+ elif [ $f = $pcm_dst ] ; then
+ $tiny_psnr $f $pcm_ref 2 >> $logfile
+ else
+ wc -c $f >> $logfile
+ fi
+ expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
+ echo `cat $bench2` $f >> $benchfile
}
do_ffmpeg_crc()
@@ -148,27 +171,28 @@ do_ffmpeg_nocheck()
f="$1"
shift
echo $ffmpeg $FFMPEG_OPTS $*
- $ffmpeg $FFMPEG_OPTS -benchmark $* > $datadir/bench.tmp 2> /tmp/ffmpeg$$
+ $ffmpeg $FFMPEG_OPTS -benchmark $* > $bench 2> /tmp/ffmpeg$$
egrep -v "^(Stream|Press|Input|Output|frame| Stream| Duration|video:)" /tmp/ffmpeg$$ || true
rm -f /tmp/ffmpeg$$
- expr "`cat $datadir/bench.tmp`" : '.*utime=\(.*s\)' > $datadir/bench2.tmp
- echo `cat $datadir/bench2.tmp` $f >> $benchfile
+ expr "`cat $bench`" : '.*utime=\(.*s\)' > $bench2
+ echo `cat $bench2` $f >> $benchfile
}
do_video_decoding()
{
- do_ffmpeg $raw_dst -y -i $file -f rawvideo $@ $raw_dst
+ do_ffmpeg $raw_dst -y $1 -i $file -f rawvideo $2 $raw_dst
}
do_video_encoding()
{
- do_ffmpeg $file -y $1 -f pgmyuv -i $raw_src $2 $file
+ file=${outfile}$1
+ do_ffmpeg $file -y $2 -f $3 -i $raw_src $4 $file
}
do_audio_encoding()
{
file=${outfile}$1
- do_ffmpeg $file -y -ab 128 -ac 2 -f s16le -i $pcm_src $3 $file
+ do_ffmpeg $file -y -ab 128k -ac 2 -f s16le -i $pcm_src $3 $file
}
do_audio_decoding()
@@ -196,7 +220,7 @@ do_image_formats()
file=${outfile}libav%02d.$1
$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src $2 $3 $file
do_ffmpeg_crc $file $3 -i $file
-
+ do_md5sum ${outfile}libav02.$1 >> $logfile
}
do_audio_only()
@@ -212,44 +236,33 @@ echo "ffmpeg benchmarks" > $benchfile
###################################
# generate reference for quality check
do_ffmpeg_nocheck $raw_ref -y -f pgmyuv -i $raw_src -an -f rawvideo $raw_ref
-do_ffmpeg_nocheck $pcm_ref -y -ab 128 -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav $pcm_ref
+do_ffmpeg_nocheck $pcm_ref -y -ab 128k -ac 2 -ar 44100 -f s16le -i $pcm_src -f wav $pcm_ref
###################################
if [ -n "$do_mpeg" ] ; then
-# mpeg1 encoding
-file=${outfile}mpeg1.mpg
-do_video_encoding "-qscale 10" "-f mpeg1video"
-
-# mpeg1 decoding
+# mpeg1
+do_video_encoding mpeg1.mpg "-qscale 10" pgmyuv "-f mpeg1video"
do_video_decoding
fi
###################################
if [ -n "$do_mpeg2" ] ; then
-# mpeg2 encoding
-file=${outfile}mpeg2.mpg
-do_video_encoding "-qscale 10" "-vcodec mpeg2video -f mpeg1video"
-
-# mpeg2 decoding
+# mpeg2
+do_video_encoding mpeg2.mpg "-qscale 10" pgmyuv "-vcodec mpeg2video -f mpeg1video"
do_video_decoding
-# mpeg2 encoding using intra vlc
-file=${outfile}mpeg2ivlc.mpg
-do_video_encoding "-qscale 10" "-vcodec mpeg2video -f mpeg1video -flags2 +ivlc"
+# mpeg2 encoding intra vlc qprd
+do_video_encoding mpeg2ivlc-qprd.mpg "-vb 500k -bf 2 -flags +trell+qprd+mv0 -flags2 +ivlc -cmp 2 -subcmp 2 -mbd rd" pgmyuv "-vcodec mpeg2video -f mpeg2video"
# mpeg2 decoding
do_video_decoding
-# mpeg2 encoding
-file=${outfile}mpeg2.mpg
-do_video_encoding "-qscale 10" "-vcodec mpeg2video -idct int -dct int -f mpeg1video"
-
-# mpeg2 decoding
-do_ffmpeg $raw_dst -y -idct int -i $file -f rawvideo $raw_dst
+# mpeg2
+do_video_encoding mpeg2.mpg "-qscale 10" pgmyuv "-vcodec mpeg2video -idct int -dct int -f mpeg1video"
+do_video_decoding "-idct int"
# mpeg2 encoding interlaced
-file=${outfile}mpeg2i.mpg
-do_video_encoding "-qscale 10" "-vcodec mpeg2video -f mpeg1video -flags +ildct+ilme"
+do_video_encoding mpeg2i.mpg "-qscale 10" pgmyuv "-vcodec mpeg2video -f mpeg1video -flags +ildct+ilme"
# mpeg2 decoding
do_video_decoding
@@ -258,15 +271,13 @@ fi
###################################
if [ -n "$do_mpeg2thread" ] ; then
# mpeg2 encoding interlaced
-file=${outfile}mpeg2thread.mpg
-do_video_encoding "-qscale 10" "-vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 2"
+do_video_encoding mpeg2thread.mpg "-qscale 10" pgmyuv "-vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 2"
# mpeg2 decoding
do_video_decoding
# mpeg2 encoding interlaced using intra vlc
-file=${outfile}mpeg2threadivlc.mpg
-do_video_encoding "-qscale 10" "-vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2"
+do_video_encoding mpeg2threadivlc.mpg "-qscale 10" pgmyuv "-vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -flags2 +ivlc -threads 2"
# mpeg2 decoding
do_video_decoding
@@ -281,381 +292,301 @@ fi
###################################
if [ -n "$do_msmpeg4v2" ] ; then
-# msmpeg4 encoding
-file=${outfile}msmpeg4v2.avi
-do_video_encoding "-qscale 10" "-an -vcodec msmpeg4v2"
-
-# msmpeg4v2 decoding
+# msmpeg4
+do_video_encoding msmpeg4v2.avi "-qscale 10" pgmyuv "-an -vcodec msmpeg4v2"
do_video_decoding
fi
###################################
if [ -n "$do_msmpeg4" ] ; then
-# msmpeg4 encoding
-file=${outfile}msmpeg4.avi
-do_video_encoding "-qscale 10" "-an -vcodec msmpeg4"
-
-# msmpeg4 decoding
+# msmpeg4
+do_video_encoding msmpeg4.avi "-qscale 10" pgmyuv "-an -vcodec msmpeg4"
do_video_decoding
fi
###################################
if [ -n "$do_wmv1" ] ; then
-# wmv1 encoding
-file=${outfile}wmv1.avi
-do_video_encoding "-qscale 10" "-an -vcodec wmv1"
-
-# wmv1 decoding
+# wmv1
+do_video_encoding wmv1.avi "-qscale 10" pgmyuv "-an -vcodec wmv1"
do_video_decoding
fi
###################################
if [ -n "$do_wmv2" ] ; then
-# wmv2 encoding
-file=${outfile}wmv2.avi
-do_video_encoding "-qscale 10" "-an -vcodec wmv2"
-
-# wmv2 decoding
+# wmv2
+do_video_encoding wmv2.avi "-qscale 10" pgmyuv "-an -vcodec wmv2"
do_video_decoding
fi
###################################
if [ -n "$do_h261" ] ; then
-# h261 encoding
-file=${outfile}h261.avi
-do_video_encoding "-qscale 11" "-s 352x288 -an -vcodec h261"
-
-# h261 decoding
+# h261
+do_video_encoding h261.avi "-qscale 11" pgmyuv "-s 352x288 -an -vcodec h261"
do_video_decoding
fi
###################################
if [ -n "$do_h263" ] ; then
-# h263 encoding
-file=${outfile}h263.avi
-do_video_encoding "-qscale 10" "-s 352x288 -an -vcodec h263"
-
-# h263 decoding
+# h263
+do_video_encoding h263.avi "-qscale 10" pgmyuv "-s 352x288 -an -vcodec h263"
do_video_decoding
fi
###################################
if [ -n "$do_h263p" ] ; then
-# h263p encoding
-file=${outfile}h263p.avi
-do_video_encoding "-qscale 2 -flags +umv+aiv+aic" "-s 352x288 -an -vcodec h263p -ps 300"
-
-# h263p decoding
+# h263p
+do_video_encoding h263p.avi "-qscale 2 -flags +umv+aiv+aic" pgmyuv "-s 352x288 -an -vcodec h263p -ps 300"
do_video_decoding
fi
###################################
if [ -n "$do_mpeg4" ] ; then
# mpeg4
-file=${outfile}odivx.mp4
-do_video_encoding "-flags +mv4 -mbd bits -qscale 10" "-an -vcodec mpeg4"
-
-# mpeg4 decoding
+do_video_encoding odivx.mp4 "-flags +mv4 -mbd bits -qscale 10" pgmyuv "-an -vcodec mpeg4"
do_video_decoding
fi
###################################
if [ -n "$do_huffyuv" ] ; then
# huffyuv
-file=${outfile}huffyuv.avi
-do_video_encoding "" "-an -vcodec huffyuv -pix_fmt yuv422p"
-
-# huffyuv decoding
-do_video_decoding -strict -2 -pix_fmt yuv420p
+do_video_encoding huffyuv.avi "" pgmyuv "-an -vcodec huffyuv -pix_fmt yuv422p"
+do_video_decoding "" "-strict -2 -pix_fmt yuv420p"
fi
###################################
if [ -n "$do_rc" ] ; then
# mpeg4 rate control
-file=${outfile}mpeg4-rc.avi
-do_video_encoding "-b 400k -bf 2" "-an -vcodec mpeg4"
-
-# mpeg4 rate control decoding
+do_video_encoding mpeg4-rc.avi "-b 400k -bf 2" pgmyuv "-an -vcodec mpeg4"
do_video_decoding
fi
###################################
if [ -n "$do_mpeg4adv" ] ; then
# mpeg4
-file=${outfile}mpeg4-adv.avi
-do_video_encoding "-qscale 9 -flags +mv4+part+aic+trell -mbd bits -ps 200" "-an -vcodec mpeg4"
+do_video_encoding mpeg4-adv.avi "-qscale 9 -flags +mv4+part+aic+trell -mbd bits -ps 200" pgmyuv "-an -vcodec mpeg4"
+do_video_decoding
-# mpeg4 decoding
+# mpeg4
+do_video_encoding mpeg4-qprd.avi "-b 450k -bf 2 -flags +mv4+trell+qprd+mv0 -cmp 2 -subcmp 2 -mbd rd" pgmyuv "-an -vcodec mpeg4"
do_video_decoding
-fi
-###################################
-if [ -n "$do_mpeg4thread" ] ; then
# mpeg4
-file=${outfile}mpeg4-thread.avi
-do_video_encoding "-b 500k -flags +mv4+part+aic+trell -mbd bits -ps 200 -bf 2" "-an -vcodec mpeg4 -threads 2"
+do_video_encoding mpeg4-adap.avi "-b 550k -bf 2 -flags +mv4+trell+mv0 -cmp 1 -subcmp 2 -mbd rd -scplx_mask 0.3" pgmyuv "-an -vcodec mpeg4"
+do_video_decoding
-# mpeg4 decoding
+# mpeg4
+do_video_encoding mpeg4-Q.avi "-qscale 7 -flags +mv4+qpel -mbd 2 -bf 2 -cmp 1 -subcmp 2" pgmyuv "-an -vcodec mpeg4"
do_video_decoding
fi
###################################
-if [ -n "$do_mpeg4adv" ] ; then
+if [ -n "$do_mpeg4thread" ] ; then
# mpeg4
-file=${outfile}mpeg4-Q.avi
-do_video_encoding "-qscale 7 -flags +mv4+qpel -mbd 2 -bf 2 -cmp 1 -subcmp 2" "-an -vcodec mpeg4"
-
-# mpeg4 decoding
+do_video_encoding mpeg4-thread.avi "-b 500k -flags +mv4+part+aic+trell -mbd bits -ps 200 -bf 2" pgmyuv "-an -vcodec mpeg4 -threads 2"
do_video_decoding
fi
###################################
if [ -n "$do_mp4psp" ] ; then
# mp4 PSP style
-file=${outfile}mpeg4-PSP.mp4
-do_ffmpeg $file -y -b 768k -s 320x240 -f psp -ar 24000 -ab 32 -i $raw_src $file
+do_video_encoding mpeg4-PSP.mp4 "-vb 768k -s 320x240" psp "-ar 24000 -ab 32k -i $raw_src"
fi
###################################
if [ -n "$do_error" ] ; then
# damaged mpeg4
-file=${outfile}error-mpeg4-adv.avi
-do_video_encoding "-qscale 7 -flags +mv4+part+aic -mbd rd -ps 250 -error 10" "-an -vcodec mpeg4"
-
-# damaged mpeg4 decoding
+do_video_encoding error-mpeg4-adv.avi "-qscale 7 -flags +mv4+part+aic -mbd rd -ps 250 -error 10" pgmyuv "-an -vcodec mpeg4"
do_video_decoding
fi
###################################
if [ -n "$do_mpeg4nr" ] ; then
# noise reduction
-file=${outfile}mpeg4-nr.avi
-do_video_encoding "-qscale 8 -flags +mv4 -mbd rd -nr 200" "-an -vcodec mpeg4"
-
-# mpeg4 decoding
+do_video_encoding mpeg4-nr.avi "-qscale 8 -flags +mv4 -mbd rd -nr 200" pgmyuv "-an -vcodec mpeg4"
do_video_decoding
fi
###################################
if [ -n "$do_mpeg1b" ] ; then
# mpeg1
-file=${outfile}mpeg1b.mpg
-do_video_encoding "-qscale 8 -bf 3 -ps 200" "-an -vcodec mpeg1video -f mpeg1video"
-
-# mpeg1 decoding
+do_video_encoding mpeg1b.mpg "-qscale 8 -bf 3 -ps 200" pgmyuv "-an -vcodec mpeg1video -f mpeg1video"
do_video_decoding
fi
###################################
if [ -n "$do_mjpeg" ] ; then
# mjpeg
-file=${outfile}mjpeg.avi
-do_video_encoding "-qscale 10" "-an -vcodec mjpeg -pix_fmt yuvj420p"
-
-# mjpeg decoding
-do_video_decoding -pix_fmt yuv420p
+do_video_encoding mjpeg.avi "-qscale 10" pgmyuv "-an -vcodec mjpeg -pix_fmt yuvj420p"
+do_video_decoding "" "-pix_fmt yuv420p"
fi
###################################
if [ -n "$do_ljpeg" ] ; then
# ljpeg
-file=${outfile}ljpeg.avi
-do_video_encoding "" "-an -vcodec ljpeg -strict -1"
-
-# ljpeg decoding
+do_video_encoding ljpeg.avi "" pgmyuv "-an -vcodec ljpeg -strict -1"
do_video_decoding
fi
###################################
if [ -n "$do_jpegls" ] ; then
# jpeg ls
-file=${outfile}jpegls.avi
-do_video_encoding "" "-an -vcodec jpegls -vtag MJPG"
-
-# jpeg ls decoding
-do_video_decoding -pix_fmt yuv420p
+do_video_encoding jpegls.avi "" pgmyuv "-an -vcodec jpegls -vtag MJPG"
+do_video_decoding "" "-pix_fmt yuv420p"
fi
###################################
if [ -n "$do_rv10" ] ; then
# rv10 encoding
-file=${outfile}rv10.rm
-do_video_encoding "-qscale 10" "-an"
-
-# rv10 decoding
+do_video_encoding rv10.rm "-qscale 10" pgmyuv "-an"
do_video_decoding
fi
###################################
if [ -n "$do_rv20" ] ; then
# rv20 encoding
-file=${outfile}rv20.rm
-do_video_encoding "-qscale 10" "-vcodec rv20 -an"
-
-# rv20 decoding
+do_video_encoding rv20.rm "-qscale 10" pgmyuv "-vcodec rv20 -an"
do_video_decoding
fi
###################################
if [ -n "$do_asv1" ] ; then
# asv1 encoding
-file=${outfile}asv1.avi
-do_video_encoding "-qscale 10" "-an -vcodec asv1"
-
-# asv1 decoding
+do_video_encoding asv1.avi "-qscale 10" pgmyuv "-an -vcodec asv1"
do_video_decoding
fi
###################################
if [ -n "$do_asv2" ] ; then
# asv2 encoding
-file=${outfile}asv2.avi
-do_video_encoding "-qscale 10" "-an -vcodec asv2"
-
-# asv2 decoding
+do_video_encoding asv2.avi "-qscale 10" pgmyuv "-an -vcodec asv2"
do_video_decoding
fi
###################################
if [ -n "$do_flv" ] ; then
# flv encoding
-file=${outfile}flv.flv
-do_video_encoding "-qscale 10" "-an -vcodec flv"
-
-# flv decoding
+do_video_encoding flv.flv "-qscale 10" pgmyuv "-an -vcodec flv"
do_video_decoding
fi
###################################
if [ -n "$do_ffv1" ] ; then
# ffv1 encoding
-file=${outfile}ffv1.avi
-do_video_encoding "-strict -2" "-an -vcodec ffv1"
-
-# ffv1 decoding
+do_video_encoding ffv1.avi "-strict -2" pgmyuv "-an -vcodec ffv1"
do_video_decoding
fi
###################################
if [ -n "$do_snow" ] ; then
-# snow encoding
-file=${outfile}snow.avi
-do_video_encoding "-strict -2" "-an -vcodec snow -qscale 2 -flags +qpel -me iter -dia_size 2 -cmp 12 -subcmp 12 -s 128x64"
-
-# snow decoding
-do_video_decoding -s 352x288
+# snow
+do_video_encoding snow.avi "-strict -2" pgmyuv "-an -vcodec snow -qscale 2 -flags +qpel -me iter -dia_size 2 -cmp 12 -subcmp 12 -s 128x64"
+do_video_decoding "" "-s 352x288"
fi
###################################
if [ -n "$do_snowll" ] ; then
-# snow encoding
-file=${outfile}snow53.avi
-do_video_encoding "-strict -2" "-an -vcodec snow -qscale .001 -pred 1 -flags +mv4+qpel"
-
-# snow decoding
+# snow
+do_video_encoding snow53.avi "-strict -2" pgmyuv "-an -vcodec snow -qscale .001 -pred 1 -flags +mv4+qpel"
do_video_decoding
fi
###################################
if [ -n "$do_dv" ] ; then
-# dv encoding
-file=${outfile}dv.dv
-do_video_encoding "-dct int" "-s pal -an"
-
-# dv decoding
-do_video_decoding -s cif
+# dv
+do_video_encoding dv.dv "-dct int" pgmyuv "-s pal -an"
+do_video_decoding "" "-s cif"
fi
###################################
if [ -n "$do_dv50" ] ; then
-# dv50 encoding
-file=${outfile}dv.dv
-do_video_encoding "-dct int" "-s pal -pix_fmt yuv422p -an"
-
-# dv50 decoding
-do_video_decoding -s cif -pix_fmt yuv420p
+# dv50
+do_video_encoding dv.dv "-dct int" pgmyuv "-s pal -pix_fmt yuv422p -an"
+do_video_decoding "" "-s cif -pix_fmt yuv420p"
fi
###################################
if [ -n "$do_svq1" ] ; then
-# svq1 encoding
-file=${outfile}svq1.mov
-do_video_encoding "" "-an -vcodec svq1 -qscale 3 -pix_fmt yuv410p"
-
-# svq1 decoding
-do_video_decoding -pix_fmt yuv420p
+# svq1
+do_video_encoding svq1.mov "" pgmyuv "-an -vcodec svq1 -qscale 3 -pix_fmt yuv410p"
+do_video_decoding "" "-pix_fmt yuv420p"
fi
###################################
if [ -n "$do_mp2" ] ; then
-# mp2 encoding
+# mp2
do_audio_encoding mp2.mp2 "-ar 44100"
-
-# mp2 decoding
do_audio_decoding
$tiny_psnr $pcm_dst $pcm_ref 2 1924 >> $logfile
fi
###################################
if [ -n "$do_ac3" ] ; then
-# ac3 encoding
+# ac3
do_audio_encoding ac3.rm "" -vn
-
-# ac3 decoding
#do_audio_decoding
fi
###################################
if [ -n "$do_g726" ] ; then
-# g726 encoding
-do_audio_encoding g726.wav "-ar 44100" "-ab 32 -ac 1 -ar 8000 -acodec g726"
-
-# g726 decoding
+# g726
+do_audio_encoding g726.wav "-ar 44100" "-ab 32k -ac 1 -ar 8000 -acodec g726"
do_audio_decoding
fi
###################################
if [ -n "$do_adpcm_ima_wav" ] ; then
-# encoding
+# adpcm ima
do_audio_encoding adpcm_ima.wav "-ar 44100" "-acodec adpcm_ima_wav"
-
-# decoding
do_audio_decoding
fi
###################################
if [ -n "$do_adpcm_ms" ] ; then
-# encoding
+# adpcm ms
do_audio_encoding adpcm_ms.wav "-ar 44100" "-acodec adpcm_ms"
-
-# decoding
do_audio_decoding
fi
###################################
if [ -n "$do_adpcm_yam" ] ; then
-# encoding
+# adpcm yamaha
do_audio_encoding adpcm_yam.wav "-ar 44100" "-acodec adpcm_yamaha"
-
-# decoding
do_audio_decoding
fi
###################################
if [ -n "$do_flac" ] ; then
-# encoding
+# flac
do_audio_encoding flac.flac "-ar 44100" "-acodec flac -compression_level 2"
-
-# decoding
do_audio_decoding
fi
###################################
-# libav testing
+if [ -n "$do_wma" ] ; then
+# wmav1
+do_audio_encoding wmav1.asf "-ar 44100" "-acodec wmav1"
+do_ffmpeg_nomd5 $pcm_dst -y -i $file -f wav $pcm_dst
+$tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
+# wmav2
+do_audio_encoding wmav2.asf "-ar 44100" "-acodec wmav2"
+do_ffmpeg_nomd5 $pcm_dst -y -i $file -f wav $pcm_dst
+$tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
+fi
+
###################################
+#if [ -n "$do_vorbis" ] ; then
+# vorbis
+#disabled because its broken
+#do_audio_encoding vorbis.asf "-ar 44100" "-acodec vorbis"
+#do_audio_decoding
+#fi
-if [ -n "$do_libav" ] ; then
+###################################
+# libavformat testing
+###################################
+
+if [ -n "$do_libavtest" ] ; then
# avi
do_libav avi
@@ -675,8 +606,8 @@ do_libav mpg
# mpegts
do_libav ts
-# swf (decode audio only)
-do_libav swf "-acodec mp2"
+# swf
+do_libav swf -an
# ffm
do_libav ffm
@@ -724,13 +655,19 @@ do_ffmpeg $file -t 1 -y -qscale 10 -f pgmyuv -i $raw_src $file
####################
# image formats
-# pgm (we do not do md5 on image files yet)
+# pgm
do_image_formats pgm
-# ppm (we do not do md5 on image files yet)
+# ppm
do_image_formats ppm
-# jpeg (we do not do md5 on image files yet)
+# bmp
+do_image_formats bmp
+
+# tga
+do_image_formats tga
+
+# jpeg
do_image_formats jpg "-flags +bitexact -dct fastint -idct simple -pix_fmt yuvj420p" "-f image2"
####################
@@ -759,8 +696,8 @@ do_audio_only voc
####################
# pix_fmt conversions
-conversions="yuv420p yuv422p yuv444p yuv422 yuv410p yuv411p yuvj420p \
- yuvj422p yuvj444p rgb24 bgr24 rgba32 rgb565 rgb555 gray monow \
+conversions="yuv420p yuv422p yuv444p yuyv422 yuv410p yuv411p yuvj420p \
+ yuvj422p yuvj444p rgb24 bgr24 rgb32 rgb565 rgb555 gray monow \
monob pal8"
for pix_fmt in $conversions ; do
file=${outfile}libav-${pix_fmt}.yuv
@@ -770,7 +707,7 @@ for pix_fmt in $conversions ; do
-f rawvideo -s 352x288 -pix_fmt yuv444p $file
done
-fi
+fi # [ -n "$do_libavtest" ]
diff --git a/contrib/ffmpeg/tests/rotozoom.c b/contrib/ffmpeg/tests/rotozoom.c
index 5549d6ec2..52f5546a3 100644
--- a/contrib/ffmpeg/tests/rotozoom.c
+++ b/contrib/ffmpeg/tests/rotozoom.c
@@ -1,8 +1,25 @@
/*
* Generates a synthetic YUV video sequence suitable for codec testing.
- * GPLv2
- * rotozoom.c -> s.bechet@av7.net
+ *
+ * copyright (c) Sebastien Bechet <s.bechet@av7.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 <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
diff --git a/contrib/ffmpeg/tests/rotozoom.regression.ref b/contrib/ffmpeg/tests/rotozoom.regression.ref
index 91dbe27d9..94c4e1b72 100644
--- a/contrib/ffmpeg/tests/rotozoom.regression.ref
+++ b/contrib/ffmpeg/tests/rotozoom.regression.ref
@@ -7,10 +7,10 @@ stddev: 4.95 PSNR:34.21 bytes:7602176
198667 ./data/a-mpeg2.mpg
b7cae8a1f751b821cddcbe4d5dbc518c *./data/out.yuv
stddev: 4.96 PSNR:34.19 bytes:7602176
-6dc412b7972918b0c3be5b448c76cdbb *./data/a-mpeg2ivlc.mpg
-197869 ./data/a-mpeg2ivlc.mpg
-b7cae8a1f751b821cddcbe4d5dbc518c *./data/out.yuv
-stddev: 4.96 PSNR:34.19 bytes:7602176
+4dd6e884eeccfb5c0d9b5542349e3d62 *./data/a-mpeg2ivlc-qprd.mpg
+249692 ./data/a-mpeg2ivlc-qprd.mpg
+99214c2a75ece2a0bf4f5afebc0f8ed7 *./data/out.yuv
+stddev: 4.41 PSNR:35.22 bytes:7602176
f979bcca866e6e4cad5dc6cb06e56cfb *./data/a-mpeg2.mpg
198041 ./data/a-mpeg2.mpg
f6d9bf24ff8676a7f6076c05cd2c81a3 *./data/out.yuv
@@ -19,17 +19,17 @@ f90197a8b6e62ae25f82625337f27240 *./data/a-mpeg2i.mpg
204579 ./data/a-mpeg2i.mpg
ea5057b60146c06d40449cdfc686bf13 *./data/out.yuv
stddev: 4.98 PSNR:34.17 bytes:7602176
-dc359097986fc04df7541f720fa5da14 *./data/a-mpeg2thread.mpg
-183314 ./data/a-mpeg2thread.mpg
-354eb621a217e50252dbed937f9eab18 *./data/out.yuv
-stddev: 4.76 PSNR:34.57 bytes:7602176
-fb02afb5a0c79c7e99a32e60e19a86bc *./data/a-mpeg2threadivlc.mpg
-182460 ./data/a-mpeg2threadivlc.mpg
-354eb621a217e50252dbed937f9eab18 *./data/out.yuv
-stddev: 4.76 PSNR:34.57 bytes:7602176
-b567ce695c24fb1e08ff1c137a805e1a *./data/a-mpeg2reuse.mpg
-394759 ./data/a-mpeg2reuse.mpg
-c3a86762e97a8869ed3c969ee2e084b8 *./data/out.yuv
+c346717be44450e41d9d6e07f59d1490 *./data/a-mpeg2thread.mpg
+182959 ./data/a-mpeg2thread.mpg
+02b85a7f67ced2d146a5c4e8000712b6 *./data/out.yuv
+stddev: 4.75 PSNR:34.57 bytes:7602176
+ff30b3df75626398873ac4f30093a5ae *./data/a-mpeg2threadivlc.mpg
+182105 ./data/a-mpeg2threadivlc.mpg
+02b85a7f67ced2d146a5c4e8000712b6 *./data/out.yuv
+stddev: 4.75 PSNR:34.57 bytes:7602176
+3942f86a6aa6fe5aea586fedf210e33e *./data/a-mpeg2reuse.mpg
+394265 ./data/a-mpeg2reuse.mpg
+afbc483eaa769925259e6094cfda2c72 *./data/out.yuv
stddev: 4.76 PSNR:34.56 bytes:7602176
c09815e40a9d260628e1ebad8b2b3774 *./data/a-msmpeg4v2.avi
129918 ./data/a-msmpeg4v2.avi
@@ -67,22 +67,30 @@ a1323da0c8b437cd6961f8c90451880b *./data/a-huffyuv.avi
6455232 ./data/a-huffyuv.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-a418db8cc1410a50a154e8418d78e3d7 *./data/a-mpeg4-rc.avi
-227918 ./data/a-mpeg4-rc.avi
-56b327651c526538576fbc104f696dde *./data/out.yuv
-stddev: 4.24 PSNR:35.55 bytes:7602176
+968ca132d8cf46f84e657abcf8473b7c *./data/a-mpeg4-rc.avi
+227934 ./data/a-mpeg4-rc.avi
+895773fe8250c806a0d1592a6dd12401 *./data/out.yuv
+stddev: 4.24 PSNR:35.56 bytes:7602176
9001cf571eb7f26fa5592bdec6538583 *./data/a-mpeg4-adv.avi
173590 ./data/a-mpeg4-adv.avi
699edf05648fdc42196b7bebef9be269 *./data/out.yuv
stddev: 4.84 PSNR:34.41 bytes:7602176
-5d94ca237bd1ba1a6cdab6796485c6dc *./data/a-mpeg4-thread.avi
-254248 ./data/a-mpeg4-thread.avi
-1cb815783ab9dc787add51cdbc97e156 *./data/out.yuv
-stddev: 4.03 PSNR:36.01 bytes:7602176
-59e682efe457070d21170fdb117c1961 *./data/a-mpeg4-Q.avi
-165840 ./data/a-mpeg4-Q.avi
-f5838ffcf1dd6c538e27dbe906e5eadd *./data/out.yuv
+1e12bb209dae0ab4b64265b0a4262257 *./data/a-mpeg4-qprd.avi
+234048 ./data/a-mpeg4-qprd.avi
+1ec355ffb30d2adf302a550cf5812636 *./data/out.yuv
+stddev: 4.23 PSNR:35.58 bytes:7602176
+d581d6f4a331325905b8ffb05cd3bfd3 *./data/a-mpeg4-adap.avi
+204284 ./data/a-mpeg4-adap.avi
+c2c7f1c7844ab92d34247ccb70198c61 *./data/out.yuv
+stddev: 4.04 PSNR:35.99 bytes:7602176
+a5150067914ee1dee50f8fc8dcaee841 *./data/a-mpeg4-Q.avi
+165802 ./data/a-mpeg4-Q.avi
+4dcc71ad79bee90777cf5299044be362 *./data/out.yuv
stddev: 4.00 PSNR:36.08 bytes:7602176
+8cd8940d7451925784536fe9b2f2a5e3 *./data/a-mpeg4-thread.avi
+254260 ./data/a-mpeg4-thread.avi
+d160a4224ea1af66c85178912f8d3a7c *./data/out.yuv
+stddev: 4.03 PSNR:36.01 bytes:7602176
5b5b88ce610114e346a5df4f46995bb9 *./data/a-mpeg4-PSP.mp4
325006 ./data/a-mpeg4-PSP.mp4
90e65096aa9ebafa3fe3f44a5a47cdc4 *./data/a-error-mpeg4-adv.avi
@@ -93,9 +101,9 @@ c41187c99588fb7229ad330b2f80d28b *./data/a-mpeg4-nr.avi
155044 ./data/a-mpeg4-nr.avi
f7fc191308679f709405e62271f5c65f *./data/out.yuv
stddev: 4.73 PSNR:34.62 bytes:7602176
-1244f602a39b255ca676ca1e47617afd *./data/a-mpeg1b.mpg
-230033 ./data/a-mpeg1b.mpg
-df02ed235141aa229b47b91b28f71da5 *./data/out.yuv
+977f3caf286e8f36c6ab4c7464632f26 *./data/a-mpeg1b.mpg
+229806 ./data/a-mpeg1b.mpg
+f41c60846bfb8cb6dcf6071c846c82b4 *./data/out.yuv
stddev: 4.13 PSNR:35.79 bytes:7602176
b179402bba391073b5f5f9324a834061 *./data/a-mjpeg.avi
703564 ./data/a-mjpeg.avi
@@ -105,8 +113,8 @@ bc0d8c868c1a05db0ff03f41768f6c5e *./data/a-ljpeg.avi
4766558 ./data/a-ljpeg.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-8a2f3984a27a7513545cf98bc05fd066 *./data/a-jpegls.avi
-8334508 ./data/a-jpegls.avi
+f67cd488dfd06c03ad1d6d94d81b80c8 *./data/a-jpegls.avi
+8334488 ./data/a-jpegls.avi
a63d4e3ea1f0b0c0d44821da9e09b8f4 *./data/out.yuv
stddev: 0.67 PSNR:51.57 bytes:7602176
989a42671603dc1a7e6b156dccf0e820 *./data/a-rv10.rm
@@ -125,30 +133,30 @@ stddev: 10.47 PSNR:27.72 bytes:7602176
789072 ./data/a-asv2.avi
74a78015b64b2cf8cb9da2e44f508a69 *./data/out.yuv
stddev: 10.28 PSNR:27.88 bytes:7602176
-bd76377d9e167caff10ebaf381f01a82 *./data/a-flv.flv
-131337 ./data/a-flv.flv
+7163b470e93feb36b3f01e82168a3d31 *./data/a-flv.flv
+131360 ./data/a-flv.flv
8999c8264fb0941561f64c4a736e9d88 *./data/out.yuv
stddev: 5.33 PSNR:33.58 bytes:7602176
d72b0960e162d4998b9acbabb07e99ab *./data/a-ffv1.avi
3525804 ./data/a-ffv1.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-4b306a67e21771eba4c61b1cf0f56141 *./data/a-snow.avi
-68526 ./data/a-snow.avi
-d2914543504345fad6e5593f66f072bc *./data/out.yuv
-stddev: 10.93 PSNR:27.34 bytes:7602176
-892221ef4c1debf694a481a5e23e1136 *./data/a-snow53.avi
-2722066 ./data/a-snow53.avi
+40a6e938ac2bd92ee12cd57925e86454 *./data/a-snow.avi
+68758 ./data/a-snow.avi
+1e356854142898c7c4aab4bfedadf235 *./data/out.yuv
+stddev: 10.86 PSNR:27.40 bytes:7602176
+3d0da6aeec9b80c6ee0ff4b747bdd0f0 *./data/a-snow53.avi
+2721980 ./data/a-snow53.avi
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
stddev: 0.00 PSNR:99.99 bytes:7602176
-af9f474238c9c68cb32e389659ee25ab *./data/a-dv.dv
+54cdeaee32d1007666a1e487e739daf6 *./data/a-dv.dv
7200000 ./data/a-dv.dv
-bb69dda7a84a5b166434e28e1243d3d1 *./data/out.yuv
-stddev: 2.99 PSNR:38.59 bytes:7602176
-91dc1c1dc4a8cca72f27d85db6d7636f *./data/a-dv.dv
+75bf724e37f667f36af50e2051846574 *./data/out.yuv
+stddev: 3.11 PSNR:38.24 bytes:7602176
+ac6741e4c79e9ed18f179c4124ede29c *./data/a-dv.dv
14400000 ./data/a-dv.dv
-74b01209bb5e096d570dd4df112bb82d *./data/out.yuv
-stddev: 2.98 PSNR:38.61 bytes:7602176
+ad9907f4ef608f025f5fc38b4b067b37 *./data/out.yuv
+stddev: 3.11 PSNR:38.25 bytes:7602176
7ba9292d663819a9a1d1cdecc6f1b079 *./data/a-svq1.mov
768407 ./data/a-svq1.mov
6bc10518bc387c3bdf117997713ee69a *./data/out.yuv
@@ -158,25 +166,33 @@ stddev: 3.44 PSNR:37.39 bytes:7602176
83f8df5d5f84480566af548bb037fceb *./data/out.wav
stddev:9330.70 PSNR:16.92 bytes:1054720
stddev:4396.13 PSNR:23.46 bytes:1052672
-dd68110cb7e5388392f89d5160d3a825 *./data/a-ac3.rm
+aefe11ab5067621a1c674859d6413891 *./data/a-ac3.rm
98203 ./data/a-ac3.rm
-9e6e66847a568ef4f1f229b0939d2aae *./data/a-g726.wav
-24268 ./data/a-g726.wav
-a719ab6d47d8d601520edb13bf6136b4 *./data/out.wav
-stddev:8459.88 PSNR:17.77 bytes:96256
-ea2efb8ba20695a35ab0d71a7ee86f22 *./data/a-adpcm_ima.wav
-266288 ./data/a-adpcm_ima.wav
+39878597b1d65cce473639a7d8c93b02 *./data/a-g726.wav
+24279 ./data/a-g726.wav
+888f2f016e608d044a1bacbca5497ed2 *./data/out.wav
+stddev:8368.02 PSNR:17.87 bytes:96256
+de3f0e1f50b19bd8572fdd3dee2e72c4 *./data/a-adpcm_ima.wav
+266300 ./data/a-adpcm_ima.wav
60178d48204f5662d91776e36eddc82e *./data/out.wav
stddev:11441.89 PSNR:15.15 bytes:1054720
-d2eee867856d2bdb6d08e936d4ceec0c *./data/a-adpcm_ms.wav
-267308 ./data/a-adpcm_ms.wav
+628d4789cf9ee16a756ac54b7fd8650d *./data/a-adpcm_ms.wav
+267320 ./data/a-adpcm_ms.wav
91a84bb4f319a3a0bf0c0441b3d3a529 *./data/out.wav
stddev:1050.18 PSNR:35.89 bytes:1054720
-48ae9fcb043a44e316998b85043b61bc *./data/a-adpcm_yam.wav
-264236 ./data/a-adpcm_yam.wav
+ab11d9151644cbff27827b7e89f37aa9 *./data/a-adpcm_yam.wav
+264248 ./data/a-adpcm_yam.wav
e92cec8c07913ffb91ad2b11f79cdc00 *./data/out.wav
stddev:18312.68 PSNR:11.06 bytes:1056768
c3382f03ce2efb5d475240d288a33898 *./data/a-flac.flac
353368 ./data/a-flac.flac
c4228df189aad9567a037727d0e763e4 *./data/out.wav
stddev: 33.31 PSNR:65.87 bytes:1040384
+0c406c4e4586ca27064e28637b662631 *./data/a-wmav1.asf
+106004 ./data/a-wmav1.asf
+stddev:12251.50 PSNR:14.56 bytes:1056768
+stddev:2106.00 PSNR:29.85 bytes:1048576
+82442aaa5fdbd327769e4c4ad369147e *./data/a-wmav2.asf
+106044 ./data/a-wmav2.asf
+stddev:12255.92 PSNR:14.55 bytes:1056768
+stddev:2099.31 PSNR:29.88 bytes:1048576
diff --git a/contrib/ffmpeg/tests/seek_test.c b/contrib/ffmpeg/tests/seek_test.c
new file mode 100644
index 000000000..e17409439
--- /dev/null
+++ b/contrib/ffmpeg/tests/seek_test.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2007 Michael Niedermayer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "avformat.h"
+
+int main(int argc, char **argv)
+{
+ const char *filename;
+ AVFormatContext *ic;
+ int i, ret, stream_id;
+ int64_t timestamp;
+
+ /* initialize libavcodec, and register all codecs and formats */
+ av_register_all();
+
+ if (argc != 2) {
+ printf("usage: %s input_file\n"
+ "\n", argv[0]);
+ exit(1);
+ }
+
+ filename = argv[1];
+
+ /* allocate the media context */
+ ic = av_alloc_format_context();
+ if (!ic) {
+ fprintf(stderr, "Memory error\n");
+ exit(1);
+ }
+
+ ret = av_open_input_file(&ic, filename, NULL, 0, NULL);
+ if (ret < 0) {
+ fprintf(stderr, "cant open %s\n", filename);
+ exit(1);
+ }
+
+ ret = av_find_stream_info(ic);
+ if (ret < 0) {
+ fprintf(stderr, "%s: could not find codec parameters\n", filename);
+ exit(1);
+ }
+
+ for(i=0; ; i++){
+ AVPacket pkt;
+ AVStream *st;
+
+ memset(&pkt, 0, sizeof(pkt));
+ if(ret>=0){
+ ret= av_read_frame(ic, &pkt);
+ printf("ret:%2d", ret);
+ if(ret>=0){
+ st= ic->streams[pkt.stream_index];
+ printf(" st:%2d dts:%f pts:%f pos:%Ld size:%d flags:%d", pkt.stream_index, pkt.dts*av_q2d(st->time_base), pkt.pts*av_q2d(st->time_base), pkt.pos, pkt.size, pkt.flags);
+ }
+ printf("\n");
+ }
+
+ if(i>25) break;
+
+ stream_id= (i>>1)%(ic->nb_streams+1) - 1;
+ timestamp= (i*19362894167LL) % (4*AV_TIME_BASE) - AV_TIME_BASE;
+ if(stream_id>=0){
+ st= ic->streams[stream_id];
+ timestamp= av_rescale_q(timestamp, AV_TIME_BASE_Q, st->time_base);
+ }
+ ret = av_seek_frame(ic, stream_id, timestamp, (i&1)*AVSEEK_FLAG_BACKWARD);
+ printf("ret:%2d st:%2d ts:%f flags:%d\n", ret, stream_id, timestamp*(stream_id<0 ? 1.0/AV_TIME_BASE : av_q2d(st->time_base)), i&1);
+ }
+
+ return 0;
+}
diff --git a/contrib/ffmpeg/tests/seek_test.sh b/contrib/ffmpeg/tests/seek_test.sh
new file mode 100755
index 000000000..eeac747b1
--- /dev/null
+++ b/contrib/ffmpeg/tests/seek_test.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#feel free to clean this up ive made no attempt to write this overly portable ...
+
+datadir="./data"
+
+logfile="$datadir/seek.regression"
+reffile="$1"
+
+list=`ls data/a-* data/b-* | sort`
+rm $logfile
+for i in $list ; do
+ echo ---------------- >>$logfile
+ echo $i >>$logfile
+ ./seek_test $i >> $logfile
+done
+
+if diff -u "$logfile" "$reffile" ; then
+ echo
+ echo Regression test succeeded.
+ exit 0
+else
+ echo
+ echo Regression test: Error.
+ exit 1
+fi
diff --git a/contrib/ffmpeg/tests/server-regression.sh b/contrib/ffmpeg/tests/server-regression.sh
index fb28fbae8..1f561aa54 100755
--- a/contrib/ffmpeg/tests/server-regression.sh
+++ b/contrib/ffmpeg/tests/server-regression.sh
@@ -10,26 +10,28 @@ fi
# Make sure that the data directory exists
mkdir -p data
-cp "$2" data/test.conf
#perl -e 'chomp($wd = `pwd`); print map { s!data/!!; "<Stream $_>\nFile $wd/data/$_\n</Stream>\n\n" } @ARGV' data/a* >> data/test.conf
#perl -e 'chomp($wd = `pwd`); print map { s!data/!!; "<Stream $_.asf>\nFile $wd/data/$_\n</Stream>\n\n" } @ARGV' data/a* >> data/test.conf
-FILES=`sed -n 's/^[^#]*<Stream \(.*\)>.*/\1/p' data/test.conf | grep -v html`
+FILES=`sed -n 's/^[^#]*<Stream \(.*\)>.*/\1/p' test.conf | grep -v html`
-rm -f /tmp/feed.ffm
-../ffserver -d -f data/test.conf 2> /dev/null &
+rm -f feed1.ffm
+../ffserver -d -f test.conf 2> /dev/null &
FFSERVER_PID=$!
-echo "Waiting for feeds to startup..."
sleep 2
+echo "Waiting for feeds to startup..."
+../ffmpeg -loop_input -flags +bitexact -dct fastint -idct simple -y -f pgmyuv -i vsynth1/%02d.pgm http://localhost:9999/feed1.ffm 2> /dev/null &
+FFMPEG_PID=$!
+sleep 5
(
cd data || exit $?
rm -f ff-*;
WGET_OPTIONS="--user-agent=NSPlayer -q --proxy=off -e verbose=off -e server_response=off"
for file in $FILES; do
if [ `expr $file : "a-*"` != 0 ]; then
- wget $WGET_OPTIONS --output-document=- http://localhost:9999/$file > ff-$file &
+ wget $WGET_OPTIONS --output-document=- http://localhost:9999/$file > ff-$file
else
- wget $WGET_OPTIONS --output-document=- http://localhost:9999/$file?date=19700101T000000Z | dd bs=1 count=100000 > ff-$file 2>/dev/null &
+ wget $WGET_OPTIONS --output-document=- http://localhost:9999/$file?date=19700101T000000Z | dd bs=1 count=20000 > ff-$file 2>/dev/null
fi
MDFILES="$MDFILES ff-$file"
done
@@ -37,8 +39,10 @@ sleep 2
# the status page is always different
md5sum $MDFILES > ffserver.regression
)
+kill $FFMPEG_PID
kill $FFSERVER_PID
wait > /dev/null 2>&1
+rm -f feed1.ffm
if $diff_cmd data/ffserver.regression "$1" ; then
echo
echo Server regression test succeeded.
diff --git a/contrib/ffmpeg/tests/test.conf b/contrib/ffmpeg/tests/test.conf
index cc2038a60..afd4c16fb 100644
--- a/contrib/ffmpeg/tests/test.conf
+++ b/contrib/ffmpeg/tests/test.conf
@@ -52,13 +52,14 @@ CustomLog -
# maximum size of the feed (100M bytes here). Default:
# File=/tmp/feed_name.ffm FileMaxSize=5M
-File /tmp/feed.ffm
+File feed1.ffm
FileMaxSize 100M
# Fire up ffmpeg pointing at this stream
-Launch ../ffmpeg -loop_input -flags +bitexact -dct fastint -idct simple -y -f pgmyuv -i vsynth1/%02d.pgm
-acl allow localhost
+#Launch ../../ffmpeg -loop_input -flags +bitexact -dct fastint -idct simple -y -f pgmyuv -i vsynth1/%02d.pgm
+
+ACL allow localhost
</Feed>
##################################################################
diff --git a/contrib/ffmpeg/tests/videogen.c b/contrib/ffmpeg/tests/videogen.c
index a6b8ce167..39d85a26a 100644
--- a/contrib/ffmpeg/tests/videogen.c
+++ b/contrib/ffmpeg/tests/videogen.c
@@ -1,7 +1,26 @@
/*
* Generates a synthetic YUV video sequence suitable for codec testing.
* NOTE: no floats are used to guaranty a bit exact output.
+ *
+ * Copyright (c) 2002 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
#include <stdlib.h>
#include <stdio.h>
diff --git a/contrib/ffmpeg/vhook/Makefile b/contrib/ffmpeg/vhook/Makefile
index 06b48935e..167b8bfb0 100644
--- a/contrib/ffmpeg/vhook/Makefile
+++ b/contrib/ffmpeg/vhook/Makefile
@@ -11,7 +11,8 @@ ALLHOOKS=$(HOOKS) imlib2$(SLIBSUF) drawtext$(SLIBSUF)
ifeq ($(HAVE_IMLIB2),yes)
HOOKS += imlib2$(SLIBSUF)
- LIBS_imlib2$(SLIBSUF) = -lImlib2
+ CFLAGS += `imlib2-config --cflags`
+ LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
endif
ifeq ($(HAVE_FREETYPE2),yes)
@@ -46,6 +47,4 @@ distclean: clean
.PHONY: all depend dep clean distclean install* uninstall*
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+-include .depend
diff --git a/contrib/ffmpeg/vhook/fish.c b/contrib/ffmpeg/vhook/fish.c
index 2a30d2847..1571cf9b9 100644
--- a/contrib/ffmpeg/vhook/fish.c
+++ b/contrib/ffmpeg/vhook/fish.c
@@ -354,7 +354,7 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
if (ci->toRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the toRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination
diff --git a/contrib/ffmpeg/vhook/imlib2.c b/contrib/ffmpeg/vhook/imlib2.c
index 87c54cf0b..4e6ffb67c 100644
--- a/contrib/ffmpeg/vhook/imlib2.c
+++ b/contrib/ffmpeg/vhook/imlib2.c
@@ -103,7 +103,6 @@
#undef time
#include <sys/time.h>
#include <time.h>
-#include <X11/Xlib.h>
#include <Imlib2.h>
#include "eval.h"
@@ -341,17 +340,17 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
imlib_context_set_image(image);
data = imlib_image_get_data();
- avpicture_fill(&picture1, (uint8_t *) data, PIX_FMT_RGBA32, width, height);
+ avpicture_fill(&picture1, (uint8_t *) data, PIX_FMT_RGB32, width, height);
// if we already got a SWS context, let's realloc if is not re-useable
ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
width, height, pix_fmt,
- width, height, PIX_FMT_RGBA32,
+ width, height, PIX_FMT_RGB32,
sws_flags, NULL, NULL, NULL);
if (ci->toRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the toRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
@@ -431,13 +430,13 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
}
ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
- width, height, PIX_FMT_RGBA32,
+ width, height, PIX_FMT_RGB32,
width, height, pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ci->fromRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the fromRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination
diff --git a/contrib/ffmpeg/vhook/null.c b/contrib/ffmpeg/vhook/null.c
index 041e5abda..c93308906 100644
--- a/contrib/ffmpeg/vhook/null.c
+++ b/contrib/ffmpeg/vhook/null.c
@@ -81,7 +81,7 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
if (ci->toRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the toRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination
@@ -102,7 +102,7 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
if (ci->fromRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the fromRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination
diff --git a/contrib/ffmpeg/vhook/ppm.c b/contrib/ffmpeg/vhook/ppm.c
index 51badd58d..9f618e55b 100644
--- a/contrib/ffmpeg/vhook/ppm.c
+++ b/contrib/ffmpeg/vhook/ppm.c
@@ -81,7 +81,7 @@ static rwpipe *rwpipe_open( int argc, char *argv[] )
close( output[ 1 ] );
execl("/bin/sh", "sh", "-c", command, (char*)NULL );
- exit( 255 );
+ _exit( 255 );
}
else
{
@@ -266,7 +266,7 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
if (ci->toRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the toRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
@@ -335,7 +335,7 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
if (ci->fromRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the fromRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
diff --git a/contrib/ffmpeg/vhook/watermark.c b/contrib/ffmpeg/vhook/watermark.c
index 4d2acd2aa..aa6fee63c 100644
--- a/contrib/ffmpeg/vhook/watermark.c
+++ b/contrib/ffmpeg/vhook/watermark.c
@@ -208,23 +208,23 @@ static void Process0(void *ctx,
int thrG = ci->thrG;
int thrB = ci->thrB;
- if (pix_fmt != PIX_FMT_RGBA32) {
+ if (pix_fmt != PIX_FMT_RGB32) {
int size;
- size = avpicture_get_size(PIX_FMT_RGBA32, src_width, src_height);
+ size = avpicture_get_size(PIX_FMT_RGB32, src_width, src_height);
buf = av_malloc(size);
- avpicture_fill(&picture1, buf, PIX_FMT_RGBA32, src_width, src_height);
+ avpicture_fill(&picture1, buf, PIX_FMT_RGB32, src_width, src_height);
// if we already got a SWS context, let's realloc if is not re-useable
ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
src_width, src_height, pix_fmt,
- src_width, src_height, PIX_FMT_RGBA32,
+ src_width, src_height, PIX_FMT_RGB32,
sws_flags, NULL, NULL, NULL);
if (ci->toRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the toRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
@@ -248,7 +248,7 @@ static void Process0(void *ctx,
ym_size = ci->y_size;
// I'll do the *4 => <<2 crap later. Most compilers understand that anyway.
- // According to avcodec.h PIX_FMT_RGBA32 is handled in endian specific manner.
+ // According to avcodec.h PIX_FMT_RGB32 is handled in endian specific manner.
for (y=0; y<src_height; y++) {
offs = y * (src_width * 4);
offsm = (((y * ym_size) / src_height) * 4) * xm_size; // offsm first in maskline. byteoffs!
@@ -291,15 +291,15 @@ static void Process0(void *ctx,
- if (pix_fmt != PIX_FMT_RGBA32) {
+ if (pix_fmt != PIX_FMT_RGB32) {
ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
- src_width, src_height, PIX_FMT_RGBA32,
+ src_width, src_height, PIX_FMT_RGB32,
src_width, src_height, pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ci->fromRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the fromRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination
@@ -339,23 +339,23 @@ static void Process1(void *ctx,
uint32_t pixel;
uint32_t pixelm;
- if (pix_fmt != PIX_FMT_RGBA32) {
+ if (pix_fmt != PIX_FMT_RGB32) {
int size;
- size = avpicture_get_size(PIX_FMT_RGBA32, src_width, src_height);
+ size = avpicture_get_size(PIX_FMT_RGB32, src_width, src_height);
buf = av_malloc(size);
- avpicture_fill(&picture1, buf, PIX_FMT_RGBA32, src_width, src_height);
+ avpicture_fill(&picture1, buf, PIX_FMT_RGB32, src_width, src_height);
// if we already got a SWS context, let's realloc if is not re-useable
ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
src_width, src_height, pix_fmt,
- src_width, src_height, PIX_FMT_RGBA32,
+ src_width, src_height, PIX_FMT_RGB32,
sws_flags, NULL, NULL, NULL);
if (ci->toRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the toRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
@@ -379,7 +379,7 @@ static void Process1(void *ctx,
ym_size = ci->y_size;
// I'll do the *4 => <<2 crap later. Most compilers understand that anyway.
- // According to avcodec.h PIX_FMT_RGBA32 is handled in endian specific manner.
+ // According to avcodec.h PIX_FMT_RGB32 is handled in endian specific manner.
for (y=0; y<src_height; y++) {
offs = y * (src_width * 4);
offsm = (((y * ym_size) / src_height) * 4) * xm_size; // offsm first in maskline. byteoffs!
@@ -402,15 +402,15 @@ static void Process1(void *ctx,
} // foreach X
} // foreach Y
- if (pix_fmt != PIX_FMT_RGBA32) {
+ if (pix_fmt != PIX_FMT_RGB32) {
ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
- src_width, src_height, PIX_FMT_RGBA32,
+ src_width, src_height, PIX_FMT_RGB32,
src_width, src_height, pix_fmt,
sws_flags, NULL, NULL, NULL);
if (ci->fromRGB_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the fromRGB conversion context\n");
- exit(1);
+ return;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination
@@ -577,12 +577,12 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
}
// Determine required buffer size and allocate buffer
- ci->numBytes = avpicture_get_size(PIX_FMT_RGBA32, ci->pCodecCtx->width,
+ ci->numBytes = avpicture_get_size(PIX_FMT_RGB32, ci->pCodecCtx->width,
ci->pCodecCtx->height);
ci->buffer = av_malloc(ci->numBytes);
// Assign appropriate parts of buffer to image planes in pFrameRGB
- avpicture_fill((AVPicture *)ci->pFrameRGB, ci->buffer, PIX_FMT_RGBA32,
+ avpicture_fill((AVPicture *)ci->pFrameRGB, ci->buffer, PIX_FMT_RGB32,
ci->pCodecCtx->width, ci->pCodecCtx->height);
}
// TODO loop, pingpong etc?
@@ -601,16 +601,16 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
// Did we get a video frame?
if(ci->frameFinished)
{
- // Convert the image from its native format to RGBA32
+ // Convert the image from its native format to RGB32
ci->watermark_convert_ctx =
sws_getCachedContext(ci->watermark_convert_ctx,
ci->pCodecCtx->width, ci->pCodecCtx->height, ci->pCodecCtx->pix_fmt,
- ci->pCodecCtx->width, ci->pCodecCtx->height, PIX_FMT_RGBA32,
+ ci->pCodecCtx->width, ci->pCodecCtx->height, PIX_FMT_RGB32,
sws_flags, NULL, NULL, NULL);
if (ci->watermark_convert_ctx == NULL) {
av_log(NULL, AV_LOG_ERROR,
"Cannot initialize the watermark conversion context\n");
- exit(1);
+ return -1;
}
// img_convert parameters are 2 first destination, then 4 source
// sws_scale parameters are context, 4 first source, then 2 destination