summaryrefslogtreecommitdiff
path: root/contrib/ffmpeg/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ffmpeg/libavcodec')
-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.h (renamed from contrib/ffmpeg/libavcodec/lzo.h)26
-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/lzo.c226
-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.h50
-rw-r--r--contrib/ffmpeg/libavcodec/zmbv.c7
-rw-r--r--contrib/ffmpeg/libavcodec/zmbvenc.c328
214 files changed, 22867 insertions, 9143 deletions
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/lzo.h b/contrib/ffmpeg/libavcodec/bmp.h
index 4d00dd721..cf6ace845 100644
--- a/contrib/ffmpeg/libavcodec/lzo.h
+++ b/contrib/ffmpeg/libavcodec/bmp.h
@@ -1,6 +1,6 @@
/*
- * LZO 1x decompression
- * copyright (c) 2006 Reimar Doeffinger
+ * internals for BMP codecs
+ * Copyright (c) 2005 Mans Rullgard
*
* This file is part of FFmpeg.
*
@@ -19,17 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _LZO_H
-#define LZO_H
+typedef struct BMPContext {
+ AVFrame picture;
+} BMPContext;
-#define LZO_INPUT_DEPLETED 1
-#define LZO_OUTPUT_FULL 2
-#define LZO_INVALID_BACKPTR 4
-#define LZO_ERROR 8
-
-#define LZO_INPUT_PADDING 4
-#define LZO_OUTPUT_PADDING 12
-
-int lzo1x_decode(void *out, int *outlen, void *in, int *inlen);
-
-#endif
+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/lzo.c b/contrib/ffmpeg/libavcodec/lzo.c
deleted file mode 100644
index 015c80d0d..000000000
--- a/contrib/ffmpeg/libavcodec/lzo.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * LZO 1x decompression
- * Copyright (c) 2006 Reimar Doeffinger
- *
- * 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"
-//! avoid e.g. MPlayers fast_memcpy, it slows things down here
-#undef memcpy
-#include <string.h>
-#include "lzo.h"
-
-//! 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 INBUF_PADDED 1
-typedef struct LZOContext {
- uint8_t *in, *in_end;
- uint8_t *out_start, *out, *out_end;
- int error;
-} LZOContext;
-
-/**
- * \brief read one byte from input buffer, avoiding overrun
- * \return byte read
- */
-static inline int get_byte(LZOContext *c) {
- if (c->in < c->in_end)
- return *c->in++;
- c->error |= LZO_INPUT_DEPLETED;
- return 1;
-}
-
-/**
- * \brief decode a length value in the coding used by lzo
- * \param x previous byte value
- * \param mask bits used from x
- * \return decoded length value
- */
-static inline int get_len(LZOContext *c, int x, int mask) {
- int cnt = x & mask;
- if (!cnt) {
- while (!(x = get_byte(c))) cnt += 255;
- cnt += mask + x;
- }
- return cnt;
-}
-
-/**
- * \brief copy bytes from input to output buffer with checking
- * \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;
- c->error |= LZO_INPUT_DEPLETED;
- }
- if (dst + cnt > c->out_end) {
- cnt = c->out_end - dst;
- 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];
- src += 4;
- dst += 4;
- cnt -= 4;
- if (cnt > 0)
-#endif
- memcpy(dst, src, cnt);
- c->in = src + cnt;
- c->out = dst + 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
- *
- * cnt > back is valid, this will copy the bytes we just copied,
- * thus creating a repeating pattern with a period length of back.
- */
-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) {
- c->error |= LZO_INVALID_BACKPTR;
- return;
- }
- if (dst + cnt > c->out_end) {
- cnt = c->out_end - dst;
- c->error |= LZO_OUTPUT_FULL;
- }
- if (back == 1) {
- memset(dst, *src, cnt);
- dst += cnt;
- } else {
-#ifdef OUTBUF_PADDED
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- 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];
- src += 8;
- dst += 8;
- cnt -= 8;
- }
-#endif
- if (cnt > 0) {
- int blocklen = back;
- while (cnt > blocklen) {
- memcpy(dst, src, blocklen);
- dst += blocklen;
- cnt -= blocklen;
- blocklen <<= 1;
- }
- memcpy(dst, src, cnt);
- }
- dst += cnt;
- }
- c->out = dst;
-}
-
-/**
- * \brief decode LZO 1x compressed data
- * \param out output buffer
- * \param outlen size of output buffer, number of bytes left are returned here
- * \param in input buffer
- * \param inlen size of input buffer, number of bytes left are returned here
- * \return 0 on success, otherwise error flags, see lzo.h
- *
- * make sure all buffers are appropriately padded, in must provide
- * 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 x;
- LZOContext c;
- c.in = in;
- c.in_end = (uint8_t *)in + *inlen;
- c.out = c.out_start = out;
- c.out_end = (uint8_t *)out + * outlen;
- c.error = 0;
- x = get_byte(&c);
- if (x > 17) {
- copy(&c, x - 17);
- x = get_byte(&c);
- if (x < 16) c.error |= LZO_ERROR;
- }
- while (!c.error) {
- int cnt, back;
- if (x >> 4) {
- if (x >> 6) {
- cnt = (x >> 5) - 1;
- back = (get_byte(&c) << 3) + ((x >> 2) & 7) + 1;
- } else if (x >> 5) {
- cnt = get_len(&c, x, 31);
- x = get_byte(&c);
- back = (get_byte(&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);
- if (back == (1 << 14)) {
- if (cnt != 1)
- c.error |= LZO_ERROR;
- break;
- }
- }
- } else
- switch (state) {
- case COPY:
- cnt = get_len(&c, x, 15);
- copy(&c, cnt + 3);
- x = get_byte(&c);
- if (x >> 4)
- continue;
- cnt = 1;
- back = (1 << 11) + (get_byte(&c) << 2) + (x >> 2) + 1;
- break;
- case BACKPTR:
- cnt = 0;
- back = (get_byte(&c) << 2) + (x >> 2) + 1;
- break;
- }
- copy_backptr(&c, back, cnt + 2);
- cnt = x & 3;
- state = cnt ? BACKPTR : COPY;
- if (cnt)
- copy(&c, cnt);
- x = get_byte(&c);
- }
- *inlen = c.in_end - c.in;
- *outlen = c.out_end - c.out;
- return c.error;
-}
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/libavcodec/xvmc_render.h b/contrib/ffmpeg/libavcodec/xvmc_render.h
new file mode 100644
index 000000000..37b342294
--- /dev/null
+++ b/contrib/ffmpeg/libavcodec/xvmc_render.h
@@ -0,0 +1,50 @@
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvlib.h>
+#include <X11/extensions/XvMClib.h>
+
+
+//the surface should be shown, video driver manipulate this
+#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
+
+typedef struct{
+//these are not changed by decoder!
+ int magic;
+
+ short * data_blocks;
+ XvMCMacroBlock * mv_blocks;
+ int total_number_of_mv_blocks;
+ int total_number_of_data_blocks;
+ int mc_type;//XVMC_MPEG1/2/4,XVMC_H263 without XVMC_IDCT
+ int idct;//does we use IDCT acceleration?
+ int chroma_format;//420,422,444
+ int unsigned_intra;//+-128 for intra pictures after clip
+ XvMCSurface* p_surface;//pointer to rendered surface, never changed
+
+//these are changed by decoder
+//used by XvMCRenderSurface function
+ XvMCSurface* p_past_surface;//pointer to the past surface
+ XvMCSurface* p_future_surface;//pointer to the future prediction surface
+
+ unsigned int picture_structure;//top/bottom fields or frame !
+ unsigned int flags;//XVMC_SECOND_FIELD - 1'st or 2'd field in the sequence
+ unsigned int display_flags; //1,2 or 1+2 fields for XvMCPutSurface,
+
+//these are internal communication one
+ int state;//0-free,1 Waiting to Display,2 Waiting for prediction
+ int start_mv_blocks_num;//offset in the array for the current slice,updated by vo
+ 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},
+};