summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libffmpeg/libavcodec/4xm.c752
-rw-r--r--src/libffmpeg/libavcodec/Doxyfile1038
-rw-r--r--src/libffmpeg/libavcodec/Makefile.am5
-rw-r--r--src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c26
-rw-r--r--src/libffmpeg/libavcodec/avcodec.h95
-rw-r--r--src/libffmpeg/libavcodec/common.c50
-rw-r--r--src/libffmpeg/libavcodec/common.h135
-rw-r--r--src/libffmpeg/libavcodec/cyuv.c6
-rw-r--r--src/libffmpeg/libavcodec/dsputil.c380
-rw-r--r--src/libffmpeg/libavcodec/dsputil.h61
-rw-r--r--src/libffmpeg/libavcodec/dv.c27
-rw-r--r--src/libffmpeg/libavcodec/error_resilience.c2
-rw-r--r--src/libffmpeg/libavcodec/golomb.c57
-rw-r--r--src/libffmpeg/libavcodec/golomb.h110
-rw-r--r--src/libffmpeg/libavcodec/h263.c199
-rw-r--r--src/libffmpeg/libavcodec/h263dec.c137
-rw-r--r--src/libffmpeg/libavcodec/h264.c93
-rw-r--r--src/libffmpeg/libavcodec/huffyuv.c42
-rw-r--r--src/libffmpeg/libavcodec/i386/dsputil_mmx.c3
-rw-r--r--src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c1
-rw-r--r--src/libffmpeg/libavcodec/imgconvert.c1723
-rw-r--r--src/libffmpeg/libavcodec/imgconvert_template.h852
-rw-r--r--src/libffmpeg/libavcodec/indeo3.c311
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess.c66
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess.h2
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h5
-rw-r--r--src/libffmpeg/libavcodec/libpostproc/postprocess_template.c2
-rw-r--r--src/libffmpeg/libavcodec/mjpeg.c51
-rw-r--r--src/libffmpeg/libavcodec/mlib/dsputil_mlib.c21
-rw-r--r--src/libffmpeg/libavcodec/motion_est_template.c4
-rw-r--r--src/libffmpeg/libavcodec/mpeg12.c279
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.c139
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.h3
-rw-r--r--src/libffmpeg/libavcodec/msmpeg4.c28
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_altivec.c18
-rw-r--r--src/libffmpeg/libavcodec/ppc/fft_altivec.c2
-rw-r--r--src/libffmpeg/libavcodec/ppc/gcc_fixes.h85
-rw-r--r--src/libffmpeg/libavcodec/ppc/gmc_altivec.c2
-rw-r--r--src/libffmpeg/libavcodec/ppc/idct_altivec.c24
-rw-r--r--src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c5
-rw-r--r--src/libffmpeg/libavcodec/ra144.c2918
-rw-r--r--src/libffmpeg/libavcodec/ra288.c451
-rw-r--r--src/libffmpeg/libavcodec/ratecontrol.c2
-rw-r--r--src/libffmpeg/libavcodec/svq1.c742
-rw-r--r--src/libffmpeg/libavcodec/svq1_vlc.h283
-rw-r--r--src/libffmpeg/libavcodec/svq3.c733
-rw-r--r--src/libffmpeg/libavcodec/utils.c29
-rw-r--r--src/libffmpeg/libavcodec/vp3.c2553
-rw-r--r--src/libffmpeg/libavcodec/vp3data.h2812
-rw-r--r--src/libffmpeg/libavcodec/wmadec.c2
-rw-r--r--src/libffmpeg/libavcodec/wmv2.c4
-rw-r--r--src/libffmpeg/xine_decoder.c30
52 files changed, 15154 insertions, 2246 deletions
diff --git a/src/libffmpeg/libavcodec/4xm.c b/src/libffmpeg/libavcodec/4xm.c
new file mode 100644
index 000000000..80e87c379
--- /dev/null
+++ b/src/libffmpeg/libavcodec/4xm.c
@@ -0,0 +1,752 @@
+/*
+ * 4XM codec
+ * Copyright (c) 2003 Michael Niedermayer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/**
+ * @file 4xm.c
+ * 4XM codec.
+ */
+
+#include "avcodec.h"
+#include "dsputil.h"
+#include "mpegvideo.h"
+
+//#undef NDEBUG
+//#include <assert.h>
+
+#define BLOCK_TYPE_VLC_BITS 5
+#define ACDC_VLC_BITS 9
+
+#define CFRAME_BUFFER_COUNT 100
+
+static const uint8_t block_type_tab[4][8][2]={
+ { //{8,4,2}x{8,4,2}
+ { 0,1}, { 2,2}, { 6,3}, {14,4}, {30,5}, {31,5}, { 0,0}
+ },{ //{8,4}x1
+ { 0,1}, { 0,0}, { 2,2}, { 6,3}, {14,4}, {15,4}, { 0,0}
+ },{ //1x{8,4}
+ { 0,1}, { 2,2}, { 0,0}, { 6,3}, {14,4}, {15,4}, { 0,0}
+ },{ //1x2, 2x1
+ { 0,1}, { 0,0}, { 0,0}, { 2,2}, { 6,3}, {14,4}, {15,4}
+ }
+};
+
+static const uint8_t size2index[4][4]={
+ {-1, 3, 1, 1},
+ { 3, 0, 0, 0},
+ { 2, 0, 0, 0},
+ { 2, 0, 0, 0},
+};
+
+static const int8_t mv[256][2]={
+{ 0, 0},{ 0, -1},{ -1, 0},{ 1, 0},{ 0, 1},{ -1, -1},{ 1, -1},{ -1, 1},
+{ 1, 1},{ 0, -2},{ -2, 0},{ 2, 0},{ 0, 2},{ -1, -2},{ 1, -2},{ -2, -1},
+{ 2, -1},{ -2, 1},{ 2, 1},{ -1, 2},{ 1, 2},{ -2, -2},{ 2, -2},{ -2, 2},
+{ 2, 2},{ 0, -3},{ -3, 0},{ 3, 0},{ 0, 3},{ -1, -3},{ 1, -3},{ -3, -1},
+{ 3, -1},{ -3, 1},{ 3, 1},{ -1, 3},{ 1, 3},{ -2, -3},{ 2, -3},{ -3, -2},
+{ 3, -2},{ -3, 2},{ 3, 2},{ -2, 3},{ 2, 3},{ 0, -4},{ -4, 0},{ 4, 0},
+{ 0, 4},{ -1, -4},{ 1, -4},{ -4, -1},{ 4, -1},{ 4, 1},{ -1, 4},{ 1, 4},
+{ -3, -3},{ -3, 3},{ 3, 3},{ -2, -4},{ -4, -2},{ 4, -2},{ -4, 2},{ -2, 4},
+{ 2, 4},{ -3, -4},{ 3, -4},{ 4, -3},{ -5, 0},{ -4, 3},{ -3, 4},{ 3, 4},
+{ -1, -5},{ -5, -1},{ -5, 1},{ -1, 5},{ -2, -5},{ 2, -5},{ 5, -2},{ 5, 2},
+{ -4, -4},{ -4, 4},{ -3, -5},{ -5, -3},{ -5, 3},{ 3, 5},{ -6, 0},{ 0, 6},
+{ -6, -1},{ -6, 1},{ 1, 6},{ 2, -6},{ -6, 2},{ 2, 6},{ -5, -4},{ 5, 4},
+{ 4, 5},{ -6, -3},{ 6, 3},{ -7, 0},{ -1, -7},{ 5, -5},{ -7, 1},{ -1, 7},
+{ 4, -6},{ 6, 4},{ -2, -7},{ -7, 2},{ -3, -7},{ 7, -3},{ 3, 7},{ 6, -5},
+{ 0, -8},{ -1, -8},{ -7, -4},{ -8, 1},{ 4, 7},{ 2, -8},{ -2, 8},{ 6, 6},
+{ -8, 3},{ 5, -7},{ -5, 7},{ 8, -4},{ 0, -9},{ -9, -1},{ 1, 9},{ 7, -6},
+{ -7, 6},{ -5, -8},{ -5, 8},{ -9, 3},{ 9, -4},{ 7, -7},{ 8, -6},{ 6, 8},
+{ 10, 1},{-10, 2},{ 9, -5},{ 10, -3},{ -8, -7},{-10, -4},{ 6, -9},{-11, 0},
+{ 11, 1},{-11, -2},{ -2, 11},{ 7, -9},{ -7, 9},{ 10, 6},{ -4, 11},{ 8, -9},
+{ 8, 9},{ 5, 11},{ 7,-10},{ 12, -3},{ 11, 6},{ -9, -9},{ 8, 10},{ 5, 12},
+{-11, 7},{ 13, 2},{ 6,-12},{ 10, 9},{-11, 8},{ -7, 12},{ 0, 14},{ 14, -2},
+{ -9, 11},{ -6, 13},{-14, -4},{ -5,-14},{ 5, 14},{-15, -1},{-14, -6},{ 3,-15},
+{ 11,-11},{ -7, 14},{ -5, 15},{ 8,-14},{ 15, 6},{ 3, 16},{ 7,-15},{-16, 5},
+{ 0, 17},{-16, -6},{-10, 14},{-16, 7},{ 12, 13},{-16, 8},{-17, 6},{-18, 3},
+{ -7, 17},{ 15, 11},{ 16, 10},{ 2,-19},{ 3,-19},{-11,-16},{-18, 8},{-19, -6},
+{ 2,-20},{-17,-11},{-10,-18},{ 8, 19},{-21, -1},{-20, 7},{ -4, 21},{ 21, 5},
+{ 15, 16},{ 2,-22},{-10,-20},{-22, 5},{ 20,-11},{ -7,-22},{-12, 20},{ 23, -5},
+{ 13,-20},{ 24, -2},{-15, 19},{-11, 22},{ 16, 19},{ 23,-10},{-18,-18},{ -9,-24},
+{ 24,-10},{ -3, 26},{-23, 13},{-18,-20},{ 17, 21},{ -4, 27},{ 27, 6},{ 1,-28},
+{-11, 26},{-17,-23},{ 7, 28},{ 11,-27},{ 29, 5},{-23,-19},{-28,-11},{-21, 22},
+{-30, 7},{-17, 26},{-27, 16},{ 13, 29},{ 19,-26},{ 10,-31},{-14,-30},{ 20,-27},
+{-29, 18},{-16,-31},{-28,-22},{ 21,-30},{-25, 28},{ 26,-29},{ 25,-32},{-32,-32}
+};
+
+// this is simply the scaled down elementwise product of the standard jpeg quantizer table and the AAN premul table
+static const uint8_t dequant_table[64]={
+ 16, 15, 13, 19, 24, 31, 28, 17,
+ 17, 23, 25, 31, 36, 63, 45, 21,
+ 18, 24, 27, 37, 52, 59, 49, 20,
+ 16, 28, 34, 40, 60, 80, 51, 20,
+ 18, 31, 48, 66, 68, 86, 56, 21,
+ 19, 38, 56, 59, 64, 64, 48, 20,
+ 27, 48, 55, 55, 56, 51, 35, 15,
+ 20, 35, 34, 32, 31, 22, 15, 8,
+};
+
+static VLC block_type_vlc[4];
+
+
+typedef struct CFrameBuffer{
+ int allocated_size;
+ int size;
+ int id;
+ uint8_t *data;
+}CFrameBuffer;
+
+typedef struct FourXContext{
+ AVCodecContext *avctx;
+ DSPContext dsp;
+ AVFrame current_picture, last_picture;
+ GetBitContext pre_gb; ///< ac/dc prefix
+ GetBitContext gb;
+ uint8_t *bytestream;
+ uint16_t *wordstream;
+ int mv[256];
+ VLC pre_vlc;
+ int last_dc;
+ DCTELEM __align8 block[6][64];
+ uint8_t *bitstream_buffer;
+ int bitstream_buffer_size;
+ CFrameBuffer cfrm[CFRAME_BUFFER_COUNT];
+} FourXContext;
+
+
+#define FIX_1_082392200 70936
+#define FIX_1_414213562 92682
+#define FIX_1_847759065 121095
+#define FIX_2_613125930 171254
+
+#define MULTIPLY(var,const) (((var)*(const)) >> 16)
+
+static void idct(DCTELEM block[64]){
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z5, z10, z11, z12, z13;
+ int i;
+ int temp[64];
+
+ for(i=0; i<8; i++){
+ tmp10 = block[8*0 + i] + block[8*4 + i];
+ tmp11 = block[8*0 + i] - block[8*4 + i];
+
+ tmp13 = block[8*2 + i] + block[8*6 + i];
+ tmp12 = MULTIPLY(block[8*2 + i] - block[8*6 + i], FIX_1_414213562) - tmp13;
+
+ tmp0 = tmp10 + tmp13;
+ tmp3 = tmp10 - tmp13;
+ tmp1 = tmp11 + tmp12;
+ tmp2 = tmp11 - tmp12;
+
+ z13 = block[8*5 + i] + block[8*3 + i];
+ z10 = block[8*5 + i] - block[8*3 + i];
+ z11 = block[8*1 + i] + block[8*7 + i];
+ z12 = block[8*1 + i] - block[8*7 + i];
+
+ tmp7 = z11 + z13;
+ tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);
+
+ z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
+ tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
+ tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5;
+
+ tmp6 = tmp12 - tmp7;
+ tmp5 = tmp11 - tmp6;
+ tmp4 = tmp10 + tmp5;
+
+ temp[8*0 + i] = tmp0 + tmp7;
+ temp[8*7 + i] = tmp0 - tmp7;
+ temp[8*1 + i] = tmp1 + tmp6;
+ temp[8*6 + i] = tmp1 - tmp6;
+ temp[8*2 + i] = tmp2 + tmp5;
+ temp[8*5 + i] = tmp2 - tmp5;
+ temp[8*4 + i] = tmp3 + tmp4;
+ temp[8*3 + i] = tmp3 - tmp4;
+ }
+
+ for(i=0; i<8*8; i+=8){
+ tmp10 = temp[0 + i] + temp[4 + i];
+ tmp11 = temp[0 + i] - temp[4 + i];
+
+ tmp13 = temp[2 + i] + temp[6 + i];
+ tmp12 = MULTIPLY(temp[2 + i] - temp[6 + i], FIX_1_414213562) - tmp13;
+
+ tmp0 = tmp10 + tmp13;
+ tmp3 = tmp10 - tmp13;
+ tmp1 = tmp11 + tmp12;
+ tmp2 = tmp11 - tmp12;
+
+ z13 = temp[5 + i] + temp[3 + i];
+ z10 = temp[5 + i] - temp[3 + i];
+ z11 = temp[1 + i] + temp[7 + i];
+ z12 = temp[1 + i] - temp[7 + i];
+
+ tmp7 = z11 + z13;
+ tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);
+
+ z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
+ tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
+ tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5;
+
+ tmp6 = tmp12 - tmp7;
+ tmp5 = tmp11 - tmp6;
+ tmp4 = tmp10 + tmp5;
+
+ block[0 + i] = (tmp0 + tmp7)>>6;
+ block[7 + i] = (tmp0 - tmp7)>>6;
+ block[1 + i] = (tmp1 + tmp6)>>6;
+ block[6 + i] = (tmp1 - tmp6)>>6;
+ block[2 + i] = (tmp2 + tmp5)>>6;
+ block[5 + i] = (tmp2 - tmp5)>>6;
+ block[4 + i] = (tmp3 + tmp4)>>6;
+ block[3 + i] = (tmp3 - tmp4)>>6;
+ }
+}
+
+static void init_vlcs(FourXContext *f){
+ static int done = 0;
+ int i;
+
+ if (!done) {
+ done = 1;
+
+ for(i=0; i<4; i++){
+ init_vlc(&block_type_vlc[i], BLOCK_TYPE_VLC_BITS, 7,
+ &block_type_tab[i][0][1], 2, 1,
+ &block_type_tab[i][0][0], 2, 1);
+ }
+ }
+}
+
+static void init_mv(FourXContext *f){
+ int i;
+
+ for(i=0; i<256; i++){
+ f->mv[i] = mv[i][0] + mv[i][1]*f->current_picture.linesize[0]/2;
+ }
+}
+
+static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){
+ int i;
+ dc*= 0x10001;
+
+ switch(log2w){
+ case 0:
+ for(i=0; i<h; i++){
+ dst[0] = scale*src[0] + dc;
+ if(scale) src += stride;
+ dst += stride;
+ }
+ break;
+ case 1:
+ for(i=0; i<h; i++){
+ ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
+ if(scale) src += stride;
+ dst += stride;
+ }
+ break;
+ case 2:
+ for(i=0; i<h; i++){
+ ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
+ ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc;
+ if(scale) src += stride;
+ dst += stride;
+ }
+ break;
+ case 3:
+ for(i=0; i<h; i++){
+ ((uint32_t*)dst)[0] = scale*((uint32_t*)src)[0] + dc;
+ ((uint32_t*)dst)[1] = scale*((uint32_t*)src)[1] + dc;
+ ((uint32_t*)dst)[2] = scale*((uint32_t*)src)[2] + dc;
+ ((uint32_t*)dst)[3] = scale*((uint32_t*)src)[3] + dc;
+ if(scale) src += stride;
+ dst += stride;
+ }
+ break;
+ default: assert(0);
+ }
+}
+
+static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride){
+ const int index= size2index[log2h][log2w];
+ const int h= 1<<log2h;
+ int code= get_vlc2(&f->gb, block_type_vlc[index].table, BLOCK_TYPE_VLC_BITS, 1);
+
+ assert(code>=0 && code<=6);
+
+ if(code == 0){
+ src += f->mv[ *f->bytestream++ ];
+ mcdc(dst, src, log2w, h, stride, 1, 0);
+ }else if(code == 1){
+ log2h--;
+ decode_p_block(f, dst , src , log2w, log2h, stride);
+ decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride);
+ }else if(code == 2){
+ log2w--;
+ decode_p_block(f, dst , src , log2w, log2h, stride);
+ decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride);
+ }else if(code == 4){
+ src += f->mv[ *f->bytestream++ ];
+ mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++));
+ }else if(code == 5){
+ mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++));
+ }else if(code == 6){
+ if(log2w){
+ dst[0] = le2me_16(*f->wordstream++);
+ dst[1] = le2me_16(*f->wordstream++);
+ }else{
+ dst[0 ] = le2me_16(*f->wordstream++);
+ dst[stride] = le2me_16(*f->wordstream++);
+ }
+ }
+}
+
+static int get32(void *p){
+ return le2me_32(*(uint32_t*)p);
+}
+
+static int decode_p_frame(FourXContext *f, uint8_t *buf, int length){
+ int x, y;
+ const int width= f->avctx->width;
+ const int height= f->avctx->height;
+ uint16_t *src= (uint16_t*)f->last_picture.data[0];
+ uint16_t *dst= (uint16_t*)f->current_picture.data[0];
+ const int stride= f->current_picture.linesize[0]>>1;
+ const int bitstream_size= get32(buf+8);
+ const int bytestream_size= get32(buf+16);
+ const int wordstream_size= get32(buf+12);
+
+ if(bitstream_size+ bytestream_size+ wordstream_size + 20 != length)
+ printf("lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size,
+ bitstream_size+ bytestream_size+ wordstream_size - length);
+
+ f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)(buf + 20), bitstream_size/4);
+ init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size);
+
+ f->wordstream= (uint16_t*)(buf + 20 + bitstream_size);
+ f->bytestream= buf + 20 + bitstream_size + wordstream_size;
+
+ init_mv(f);
+
+ for(y=0; y<height; y+=8){
+ for(x=0; x<width; x+=8){
+ decode_p_block(f, dst + x, src + x, 3, 3, stride);
+ }
+ src += 8*stride;
+ dst += 8*stride;
+ }
+
+ if(bitstream_size != (get_bits_count(&f->gb)+31)/32*4)
+ printf(" %d %d %d bytes left\n",
+ bitstream_size - (get_bits_count(&f->gb)+31)/32*4,
+ bytestream_size - (f->bytestream - (buf + 20 + bitstream_size + wordstream_size)),
+ wordstream_size - (((uint8_t*)f->wordstream) - (buf + 20 + bitstream_size))
+ );
+
+ return 0;
+}
+
+/**
+ * decode block and dequantize.
+ * Note this is allmost identical to mjpeg
+ */
+static int decode_i_block(FourXContext *f, DCTELEM *block){
+ int code, i, j, level, val;
+
+ /* DC coef */
+ val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);
+ if (val>>4){
+ printf("error dc run != 0\n");
+ }
+
+ if(val)
+ val = get_xbits(&f->gb, val);
+
+ val = val * dequant_table[0] + f->last_dc;
+ f->last_dc =
+ block[0] = val;
+ /* AC coefs */
+ i = 1;
+ for(;;) {
+ code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);
+
+ /* EOB */
+ if (code == 0)
+ break;
+ if (code == 0xf0) {
+ i += 16;
+ } else {
+ level = get_xbits(&f->gb, code & 0xf);
+ i += code >> 4;
+ if (i >= 64) {
+ printf("run %d oveflow\n", i);
+ return 0;
+ }
+
+ j= ff_zigzag_direct[i];
+ block[j] = level * dequant_table[j];
+ i++;
+ if (i >= 64)
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static inline void idct_put(FourXContext *f, int x, int y){
+ DCTELEM (*block)[64]= f->block;
+ int stride= f->current_picture.linesize[0]>>1;
+ int i;
+ uint16_t *dst = ((uint16_t*)f->current_picture.data[0]) + y * stride + x;
+
+ for(i=0; i<4; i++){
+ block[i][0] += 0x80*8*8;
+ idct(block[i]);
+ }
+
+ if(!(f->avctx->flags&CODEC_FLAG_GRAY)){
+ for(i=4; i<6; i++) idct(block[i]);
+ }
+
+ for(y=0; y<8; y++){
+ for(x=0; x<8; x++){
+ DCTELEM *temp= block[(x>>2) + 2*(y>>2)] + 2*(x&3) + 2*8*(y&3); //FIXME optimize
+ int cb= block[4][x + 8*y];
+ int cr= block[5][x + 8*y];
+ int cg= (cb + cr)>>1;
+ int y;
+
+ cb+=cb;
+
+ y = temp[0];
+ dst[0 ]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8);
+ y = temp[1];
+ dst[1 ]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8);
+ y = temp[8];
+ dst[ stride]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8);
+ y = temp[9];
+ dst[1+stride]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8);
+ dst += 2;
+ }
+ dst += 2*stride - 2*8;
+ }
+}
+
+static int decode_i_mb(FourXContext *f){
+ int i;
+
+ f->dsp.clear_blocks(f->block[0]);
+
+ for(i=0; i<6; i++){
+ if(decode_i_block(f, f->block[i]) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+static uint8_t *read_huffman_tables(FourXContext *f, uint8_t * const buf){
+ int frequency[512];
+ uint8_t flag[512];
+ int up[512];
+ uint8_t len_tab[257];
+ int bits_tab[257];
+ int start, end;
+ uint8_t *ptr= buf;
+ int j;
+
+ memset(frequency, 0, sizeof(frequency));
+ memset(up, -1, sizeof(up));
+
+ start= *ptr++;
+ end= *ptr++;
+ for(;;){
+ int i;
+
+ for(i=start; i<=end; i++){
+ frequency[i]= *ptr++;
+// printf("%d %d %d\n", start, end, frequency[i]);
+ }
+ start= *ptr++;
+ if(start==0) break;
+
+ end= *ptr++;
+ }
+ frequency[256]=1;
+
+ while((ptr - buf)&3) ptr++; // 4byte align
+
+// for(j=0; j<16; j++)
+// printf("%2X", ptr[j]);
+
+ for(j=257; j<512; j++){
+ int min_freq[2]= {256*256, 256*256};
+ int smallest[2]= {0, 0};
+ int i;
+ for(i=0; i<j; i++){
+ if(frequency[i] == 0) continue;
+ if(frequency[i] < min_freq[1]){
+ if(frequency[i] < min_freq[0]){
+ min_freq[1]= min_freq[0]; smallest[1]= smallest[0];
+ min_freq[0]= frequency[i];smallest[0]= i;
+ }else{
+ min_freq[1]= frequency[i];smallest[1]= i;
+ }
+ }
+ }
+ if(min_freq[1] == 256*256) break;
+
+ frequency[j]= min_freq[0] + min_freq[1];
+ flag[ smallest[0] ]= 0;
+ flag[ smallest[1] ]= 1;
+ up[ smallest[0] ]=
+ up[ smallest[1] ]= j;
+ frequency[ smallest[0] ]= frequency[ smallest[1] ]= 0;
+ }
+
+ for(j=0; j<257; j++){
+ int node;
+ int len=0;
+ int bits=0;
+
+ for(node= j; up[node] != -1; node= up[node]){
+ bits += flag[node]<<len;
+ len++;
+ if(len > 31) printf("vlc length overflow\n"); //can this happen at all ?
+ }
+
+ bits_tab[j]= bits;
+ len_tab[j]= len;
+ }
+
+ init_vlc(&f->pre_vlc, ACDC_VLC_BITS, 257,
+ len_tab , 1, 1,
+ bits_tab, 4, 4);
+
+ return ptr;
+}
+
+static int decode_i_frame(FourXContext *f, uint8_t *buf, int length){
+ int x, y;
+ const int width= f->avctx->width;
+ const int height= f->avctx->height;
+ uint16_t *dst= (uint16_t*)f->current_picture.data[0];
+ const int stride= f->current_picture.linesize[0]>>1;
+ const int bitstream_size= get32(buf);
+ const int token_count= get32(buf + bitstream_size + 8);
+ int prestream_size= 4*get32(buf + bitstream_size + 4);
+ uint8_t *prestream= buf + bitstream_size + 12;
+
+ if(prestream_size + bitstream_size + 12 != length)
+ fprintf(stderr, "size missmatch %d %d %d\n", prestream_size, bitstream_size, length);
+
+ prestream= read_huffman_tables(f, prestream);
+
+ init_get_bits(&f->gb, buf + 4, 8*bitstream_size);
+
+ prestream_size= length + buf - prestream;
+
+ f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)prestream, prestream_size/4);
+ init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size);
+
+ f->last_dc= 0*128*8*8;
+
+ for(y=0; y<height; y+=16){
+ for(x=0; x<width; x+=16){
+ if(decode_i_mb(f) < 0)
+ return -1;
+
+ idct_put(f, x, y);
+ }
+ dst += 16*stride;
+ }
+
+ if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)
+ printf("end missmatch\n");
+
+ return 0;
+}
+
+static int decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ FourXContext * const f = avctx->priv_data;
+ AVFrame *picture = data;
+ AVFrame *p, temp;
+ int i, frame_4cc, frame_size;
+
+ *data_size = 0;
+
+ /* special case for last picture */
+ if (buf_size == 0) {
+ return 0;
+ }
+
+ frame_4cc= get32(buf);
+ if(buf_size != get32(buf+4)+8){
+ fprintf(stderr, "size missmatch %d %d\n", buf_size, get32(buf+4));
+ }
+
+ if(frame_4cc == ff_get_fourcc("cfrm")){
+ int free_index=-1;
+ const int data_size= buf_size - 20;
+ const int id= get32(buf+12);
+ const int whole_size= get32(buf+16);
+ CFrameBuffer *cfrm;
+
+ for(i=0; i<CFRAME_BUFFER_COUNT; i++){
+ if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
+ printf("lost c frame %d\n", f->cfrm[i].id);
+ }
+
+ for(i=0; i<CFRAME_BUFFER_COUNT; i++){
+ if(f->cfrm[i].id == id) break;
+ if(f->cfrm[i].size == 0 ) free_index= i;
+ }
+
+ if(i>=CFRAME_BUFFER_COUNT){
+ i= free_index;
+ f->cfrm[i].id= id;
+ }
+ cfrm= &f->cfrm[i];
+
+ cfrm->data= av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE);
+
+ memcpy(cfrm->data + cfrm->size, buf+20, data_size);
+ cfrm->size += data_size;
+
+ if(cfrm->size >= whole_size){
+ buf= cfrm->data;
+ frame_size= cfrm->size;
+
+ if(id != avctx->frame_number){
+ printf("cframe id missmatch %d %d\n", id, avctx->frame_number);
+ }
+
+ cfrm->size= cfrm->id= 0;
+ frame_4cc= ff_get_fourcc("pfrm");
+ }else
+ return buf_size;
+ }else{
+ buf= buf + 12;
+ frame_size= buf_size - 12;
+ }
+
+ temp= f->current_picture;
+ f->current_picture= f->last_picture;
+ f->last_picture= temp;
+
+ p= &f->current_picture;
+ avctx->coded_frame= p;
+
+ avctx->flags |= CODEC_FLAG_EMU_EDGE; // alternatively we would have to use our own buffer management
+
+ if(p->data[0])
+ avctx->release_buffer(avctx, p);
+
+ p->reference= 1;
+ if(avctx->get_buffer(avctx, p) < 0){
+ fprintf(stderr, "get_buffer() failed\n");
+ return -1;
+ }
+
+ if(frame_4cc == ff_get_fourcc("ifrm")){
+ p->pict_type= I_TYPE;
+ if(decode_i_frame(f, buf, frame_size) < 0)
+ return -1;
+ }else if(frame_4cc == ff_get_fourcc("pfrm")){
+ p->pict_type= P_TYPE;
+ if(decode_p_frame(f, buf, frame_size) < 0)
+ return -1;
+ }else if(frame_4cc == ff_get_fourcc("snd_")){
+ printf("ignoring snd_ chunk length:%d\n", buf_size);
+ }else{
+ printf("ignoring unknown chunk length:%d\n", buf_size);
+ }
+
+#if 0
+for(i=0; i<20; i++){
+ printf("%2X %c ", buf[i], clip(buf[i],16,126));
+}
+#endif
+
+ p->key_frame= p->pict_type == I_TYPE;
+
+ *picture= *p;
+ *data_size = sizeof(AVPicture);
+
+ emms_c();
+
+ return buf_size;
+}
+
+
+static void common_init(AVCodecContext *avctx){
+ FourXContext * const f = avctx->priv_data;
+
+ dsputil_init(&f->dsp, avctx);
+
+ f->avctx= avctx;
+}
+
+static int decode_init(AVCodecContext *avctx){
+ FourXContext * const f = avctx->priv_data;
+
+ common_init(avctx);
+ init_vlcs(f);
+
+ avctx->pix_fmt= PIX_FMT_RGB565;
+
+ return 0;
+}
+
+
+static int decode_end(AVCodecContext *avctx){
+ FourXContext * const f = avctx->priv_data;
+ int i;
+
+ av_freep(&f->bitstream_buffer);
+ f->bitstream_buffer_size=0;
+ for(i=0; i<CFRAME_BUFFER_COUNT; i++){
+ av_freep(&f->cfrm[i].data);
+ f->cfrm[i].allocated_size= 0;
+ }
+ free_vlc(&f->pre_vlc);
+
+ avcodec_default_free_buffers(avctx);
+
+ return 0;
+}
+
+AVCodec fourxm_decoder = {
+ "4xm",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_4XM,
+ sizeof(FourXContext),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame,
+ /*CODEC_CAP_DR1,*/
+};
+
diff --git a/src/libffmpeg/libavcodec/Doxyfile b/src/libffmpeg/libavcodec/Doxyfile
new file mode 100644
index 000000000..3e81cbb7b
--- /dev/null
+++ b/src/libffmpeg/libavcodec/Doxyfile
@@ -0,0 +1,1038 @@
+# Doxyfile 1.3-rc1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = libavcodec
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doxy
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
+# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en
+# (Japanese with english messages), Korean, Norwegian, Polish, Portuguese,
+# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these class will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
+# members of a class in the documentation of that class as if those members were
+# ordinary class members. Constructors, destructors and assignment operators of
+# the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. It is allowed to use relative paths in the argument list.
+
+STRIP_FROM_PATH = .
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower case letters. If set to YES upper case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# users are adviced to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like the Qt-style comments (thus requiring an
+# explict @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF = YES
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# reimplements.
+
+INHERIT_DOCS = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consist of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C.
+# For instance some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
+# only. Doxygen will then generate output that is more tailored for Java.
+# For instance namespaces will be presented as packages, qualified scopes
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text.
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT =
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
+# *.h++ *.idl *.odl
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
+# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+
+EXCLUDE_PATTERNS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+
+INPUT_FILTER =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output dir.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non empty doxygen will try to run
+# the html help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the Html help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript and frames is required (for instance Mozilla, Netscape 4.0+,
+# or Internet explorer 4.0+). Note that for large projects the tree generation
+# can take a very long time. In such cases it is better to disable this feature.
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimised for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assigments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_XML = NO
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF = YES
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed.
+
+PREDEFINED = __attribute__(x)="" "RENAME(x)=x ## _TMPL" "DEF(x)=x ## _TMPL" \
+ HAVE_BUILTIN_VECTOR HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_3DNOW \
+ ATTR_ALIGN(x)=""
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+#EXPAND_AS_DEFINED = FF_COMMON_FRAME
+EXPAND_AS_DEFINED = declare_idct(idct, table, idct_row_head, idct_row, idct_row_tail, idct_row_mid)
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse the
+# parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tagfiles.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or
+# super classes. Setting the tag to NO turns the diagrams off. Note that this
+# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
+# recommended to install and use dot, since it yield more powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_WIDTH = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT = 1024
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermedate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
+
+# The CGI_NAME tag should be the name of the CGI script that
+# starts the search engine (doxysearch) with the correct parameters.
+# A script with this name will be generated by doxygen.
+
+CGI_NAME = search.cgi
+
+# The CGI_URL tag should be the absolute URL to the directory where the
+# cgi binaries are located. See the documentation of your http daemon for
+# details.
+
+CGI_URL =
+
+# The DOC_URL tag should be the absolute URL to the directory where the
+# documentation is located. If left blank the absolute path to the
+# documentation, with file:// prepended to it, will be used.
+
+DOC_URL =
+
+# The DOC_ABSPATH tag should be the absolute path to the directory where the
+# documentation is located. If left blank the directory on the local machine
+# will be used.
+
+DOC_ABSPATH =
+
+# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
+# is installed.
+
+BIN_ABSPATH = /usr/local/bin/
+
+# The EXT_DOC_PATHS tag can be used to specify one or more paths to
+# documentation generated for other projects. This allows doxysearch to search
+# the documentation for these projects as well.
+
+EXT_DOC_PATHS =
diff --git a/src/libffmpeg/libavcodec/Makefile.am b/src/libffmpeg/libavcodec/Makefile.am
index a66fa97d6..17307c0c2 100644
--- a/src/libffmpeg/libavcodec/Makefile.am
+++ b/src/libffmpeg/libavcodec/Makefile.am
@@ -16,6 +16,7 @@ ASFLAGS =
noinst_LTLIBRARIES = libavcodec.la
libavcodec_la_SOURCES = \
+ 4xm.c \
common.c \
cyuv.c \
dsputil.c \
@@ -42,11 +43,14 @@ libavcodec_la_SOURCES = \
mpegvideo.c \
msmpeg4.c \
opts.c \
+ ra144.c \
+ ra288.c \
ratecontrol.c \
rv10.c \
simple_idct.c \
svq1.c \
utils.c \
+ vp3.c \
wmadec.c
libavcodec_la_LDFLAGS = \
@@ -77,6 +81,7 @@ noinst_HEADERS = \
os_support.h \
simple_idct.h \
svq1_cb.h \
+ vp3data.h \
wmadata.h
.s.lo:
diff --git a/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c b/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c
new file mode 100644
index 000000000..9c5d8bf86
--- /dev/null
+++ b/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2002 Michael Niedermayer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "../dsputil.h"
+#include "../mpegvideo.h"
+#include "../avcodec.h"
+
+void MPV_common_init_armv4l(MpegEncContext *s)
+{
+}
diff --git a/src/libffmpeg/libavcodec/avcodec.h b/src/libffmpeg/libavcodec/avcodec.h
index 9277fa158..c2017706b 100644
--- a/src/libffmpeg/libavcodec/avcodec.h
+++ b/src/libffmpeg/libavcodec/avcodec.h
@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
-#define LIBAVCODEC_BUILD 4666
-#define LIBAVCODEC_BUILD_STR "4666"
+#define LIBAVCODEC_BUILD 4669
+#define LIBAVCODEC_BUILD_STR "4669"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
@@ -52,6 +52,12 @@ enum CodecID {
CODEC_ID_CYUV,
CODEC_ID_H264,
CODEC_ID_INDEO3,
+ CODEC_ID_VP3,
+ CODEC_ID_AAC,
+ CODEC_ID_MPEG4AAC,
+ CODEC_ID_ASV1,
+ CODEC_ID_FFV1,
+ CODEC_ID_4XM,
/* various pcm "codecs" */
CODEC_ID_PCM_S16LE,
@@ -67,6 +73,13 @@ enum CodecID {
CODEC_ID_ADPCM_IMA_QT,
CODEC_ID_ADPCM_IMA_WAV,
CODEC_ID_ADPCM_MS,
+ CODEC_ID_ADPCM_4XM,
+
+ /* AMR */
+ CODEC_ID_AMR_NB,
+ /* RealAudio codecs*/
+ CODEC_ID_RA_144,
+ CODEC_ID_RA_288,
};
enum CodecType {
@@ -79,24 +92,24 @@ enum CodecType {
* Pixel format.
*/
enum PixelFormat {
- PIX_FMT_YUV420P,
- PIX_FMT_YUV422,
- PIX_FMT_RGB24, ///< 3 bytes, R is first
- PIX_FMT_BGR24, ///< 3 bytes, B is first
- PIX_FMT_YUV422P,
- PIX_FMT_YUV444P,
+ PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
+ PIX_FMT_YUV422,
+ PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
+ PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
+ PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
+ PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
PIX_FMT_RGBA32, ///< always stored in cpu endianness
- PIX_FMT_YUV410P,
- PIX_FMT_YUV411P,
+ PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
+ PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
PIX_FMT_RGB565, ///< always stored in cpu endianness
PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
PIX_FMT_GRAY8,
PIX_FMT_MONOWHITE, ///< 0 is white
PIX_FMT_MONOBLACK, ///< 0 is black
PIX_FMT_PAL8, ///< 8 bit with RGBA palette
- PIX_FMT_YUVJ420P, ///< YUV full scale (jpeg)
- PIX_FMT_YUVJ422P, ///< YUV full scale (jpeg)
- PIX_FMT_YUVJ444P, ///< YUV full scale (jpeg)
+ PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
+ PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
+ PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
PIX_FMT_NB,
};
@@ -109,8 +122,11 @@ enum SampleFormat {
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
/**
- * Required number of zero bytes at the end of the input bitstream for decoding.
- * to avoid overreading (and possibly segfaulting)
+ * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
+ * this is mainly needed because some optimized bitstream readers read
+ * 32 or 64 bit at once and could read over the end<br>
+ * Note, if the first 23 bits of the additional bytes are not 0 then damaged
+ * MPEG bitstreams could cause overread and segfault
*/
#define FF_INPUT_BUFFER_PADDING_SIZE 8
@@ -308,7 +324,7 @@ static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
* type of the buffer (to keep track of who has to dealloc data[*])\
* - encoding: set by the one who allocs it\
* - decoding: set by the one who allocs it\
- * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
+ * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
*/\
int type;\
\
@@ -838,6 +854,7 @@ typedef struct AVCodecContext {
#define FF_IDCT_MLIB 6
#define FF_IDCT_ARM 7
#define FF_IDCT_ALTIVEC 8
+#define FF_IDCT_SH4 9
/**
* slice count.
@@ -1101,6 +1118,31 @@ typedef struct AVCodecContext {
* Dont touch, used by lavc default_get_buffer()
*/
void *internal_buffer;
+
+#define FF_QUALITY_SCALE 256
+ /**
+ * global quality for codecs which cannot change it per frame.
+ * this should be proportional to MPEG1/2/4 qscale.
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int global_quality;
+
+#define FF_CODER_TYPE_VLC 0
+#define FF_CODER_TYPE_AC 1
+ /**
+ * coder type
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int coder_type;
+
+ /**
+ * context model
+ * - encoding: set by user.
+ * - decoding: unused
+ */
+ int context_model;
} AVCodecContext;
@@ -1172,7 +1214,7 @@ typedef struct AVCodec {
*/
typedef struct AVPicture {
uint8_t *data[4];
- int linesize[4];
+ int linesize[4]; ///< number of bytes per line
} AVPicture;
extern AVCodec ac3_encoder;
@@ -1192,6 +1234,8 @@ extern AVCodec wmv1_encoder;
extern AVCodec wmv2_encoder;
extern AVCodec huffyuv_encoder;
extern AVCodec h264_encoder;
+extern AVCodec asv1_encoder;
+extern AVCodec ffv1_encoder;
extern AVCodec h263_decoder;
extern AVCodec mpeg4_decoder;
@@ -1220,6 +1264,16 @@ extern AVCodec oggvorbis_decoder;
extern AVCodec cyuv_decoder;
extern AVCodec h264_decoder;
extern AVCodec indeo3_decoder;
+extern AVCodec vp3_decoder;
+extern AVCodec amr_nb_decoder;
+extern AVCodec amr_nb_encoder;
+extern AVCodec aac_decoder;
+extern AVCodec mpeg4aac_decoder;
+extern AVCodec asv1_decoder;
+extern AVCodec ffv1_decoder;
+extern AVCodec fourxm_decoder;
+extern AVCodec ra_144_decoder;
+extern AVCodec ra_288_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
@@ -1240,6 +1294,7 @@ PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
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_MS, adpcm_ms);
+PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
#undef PCM_CODEC
@@ -1361,6 +1416,12 @@ void avcodec_register_all(void);
void avcodec_flush_buffers(AVCodecContext *avctx);
/* misc usefull functions */
+
+/**
+ * returns a single letter to describe the picture type
+ */
+char av_get_pict_type_char(int pict_type);
+
/**
* reduce a fraction.
* this is usefull for framerate calculations
diff --git a/src/libffmpeg/libavcodec/common.c b/src/libffmpeg/libavcodec/common.c
index 068195384..0e6cd69d0 100644
--- a/src/libffmpeg/libavcodec/common.c
+++ b/src/libffmpeg/libavcodec/common.c
@@ -67,6 +67,8 @@ void init_put_bits(PutBitContext *s,
#endif
}
+#ifdef CONFIG_ENCODERS
+
/* return the number of bits output */
int64_t get_bit_count(PutBitContext *s)
{
@@ -86,6 +88,8 @@ void align_put_bits(PutBitContext *s)
#endif
}
+#endif //CONFIG_ENCODERS
+
/* pad the end of the output stream with zeros */
void flush_put_bits(PutBitContext *s)
{
@@ -104,6 +108,8 @@ void flush_put_bits(PutBitContext *s)
#endif
}
+#ifdef CONFIG_ENCODERS
+
void put_string(PutBitContext * pbc, char *s)
{
while(*s){
@@ -115,6 +121,14 @@ void put_string(PutBitContext * pbc, char *s)
/* bit input functions */
+#endif //CONFIG_ENCODERS
+
+/**
+ * init GetBitContext.
+ * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
+ * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
+ * @param bit_size the size of the buffer in bits
+ */
void init_get_bits(GetBitContext *s,
const uint8_t *buffer, int bit_size)
{
@@ -126,9 +140,19 @@ void init_get_bits(GetBitContext *s,
#ifdef ALT_BITSTREAM_READER
s->index=0;
#elif defined LIBMPEG2_BITSTREAM_READER
+#ifdef LIBMPEG2_BITSTREAM_READER_HACK
+ if ((int)buffer&1) {
+ /* word alignment */
+ s->cache = (*buffer++)<<24;
+ s->buffer_ptr = buffer;
+ s->bit_count = 16-8;
+ } else
+#endif
+ {
s->buffer_ptr = buffer;
s->bit_count = 16;
s->cache = 0;
+ }
#elif defined A32_BITSTREAM_READER
s->buffer_ptr = (uint32_t*)buffer;
s->bit_count = 32;
@@ -138,7 +162,7 @@ void init_get_bits(GetBitContext *s,
{
OPEN_READER(re, s)
UPDATE_CACHE(re, s)
-// UPDATE_CACHE(re, s)
+ UPDATE_CACHE(re, s)
CLOSE_READER(re, s)
}
#ifdef A32_BITSTREAM_READER
@@ -146,6 +170,30 @@ void init_get_bits(GetBitContext *s,
#endif
}
+/**
+ * reads 0-32 bits.
+ */
+unsigned int get_bits_long(GetBitContext *s, int n){
+ if(n<=17) return get_bits(s, n);
+ else{
+ int ret= get_bits(s, 16) << (n-16);
+ return ret | get_bits(s, n-16);
+ }
+}
+
+/**
+ * shows 0-32 bits.
+ */
+unsigned int show_bits_long(GetBitContext *s, int n){
+ if(n<=17) return show_bits(s, n);
+ else{
+ GetBitContext gb= *s;
+ int ret= get_bits_long(s, n);
+ *s= gb;
+ return ret;
+ }
+}
+
void align_get_bits(GetBitContext *s)
{
int n= (-get_bits_count(s)) & 7;
diff --git a/src/libffmpeg/libavcodec/common.h b/src/libffmpeg/libavcodec/common.h
index 6f98dcc8c..3c65c44d6 100644
--- a/src/libffmpeg/libavcodec/common.h
+++ b/src/libffmpeg/libavcodec/common.h
@@ -16,6 +16,7 @@
#define ALT_BITSTREAM_READER
//#define LIBMPEG2_BITSTREAM_READER
//#define A32_BITSTREAM_READER
+#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO
#ifdef HAVE_AV_CONFIG_H
/* only include the following when compiling package */
@@ -157,7 +158,7 @@ typedef signed __int64 int64_t;
# include "bswap.h"
# if defined(__MINGW32__) || defined(__CYGWIN__) || \
- defined(__OS2__) || defined (__OpenBSD__)
+ defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__))
# define MANGLE(a) "_" #a
# else
# define MANGLE(a) #a
@@ -204,6 +205,25 @@ inline void dprintf(const char* fmt,...) {}
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+extern const uint32_t inverse[256];
+
+#ifdef ARCH_X86
+# define FASTDIV(a,b) \
+ ({\
+ int ret,dmy;\
+ asm volatile(\
+ "mull %3"\
+ :"=d"(ret),"=a"(dmy)\
+ :"1"(a),"g"(inverse[b])\
+ );\
+ ret;\
+ })
+#elif defined(CONFIG_FASTDIV)
+# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*inverse[b])>>32))
+#else
+# define FASTDIV(a,b) ((a)/(b))
+#endif
+
#ifdef ARCH_X86
// avoid +32 for shift optimization (gcc should do that ...)
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
@@ -480,6 +500,16 @@ LAST_SKIP_BITS(name, gb, num)
for examples see get_bits, show_bits, skip_bits, get_vlc
*/
+static inline int unaligned32_be(const void *v)
+{
+#ifdef CONFIG_ALIGN
+ const uint8_t *p=v;
+ return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]);
+#else
+ return be2me_32( unaligned32(v)); //original
+#endif
+}
+
#ifdef ALT_BITSTREAM_READER
# define MIN_CACHE_BITS 25
@@ -491,7 +521,7 @@ for examples see get_bits, show_bits, skip_bits, get_vlc
(gb)->index= name##_index;\
# define UPDATE_CACHE(name, gb)\
- name##_cache= be2me_32( unaligned32( ((uint8_t *)(gb)->buffer)+(name##_index>>3) ) ) << (name##_index&0x07);\
+ name##_cache= unaligned32_be( ((uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
# define SKIP_CACHE(name, gb, num)\
name##_cache <<= (num);\
@@ -524,7 +554,7 @@ static inline int get_bits_count(GetBitContext *s){
#elif defined LIBMPEG2_BITSTREAM_READER
//libmpeg2 like reader
-# define MIN_CACHE_BITS 16
+# define MIN_CACHE_BITS 17
# define OPEN_READER(name, gb)\
int name##_bit_count=(gb)->bit_count;\
@@ -536,13 +566,26 @@ static inline int get_bits_count(GetBitContext *s){
(gb)->cache= name##_cache;\
(gb)->buffer_ptr= name##_buffer_ptr;\
+#ifdef LIBMPEG2_BITSTREAM_READER_HACK
+
# define UPDATE_CACHE(name, gb)\
- if(name##_bit_count > 0){\
+ if(name##_bit_count >= 0){\
+ name##_cache+= (int)be2me_16(*(uint16_t*)name##_buffer_ptr) << name##_bit_count;\
+ ((uint16_t*)name##_buffer_ptr)++;\
+ name##_bit_count-= 16;\
+ }\
+
+#else
+
+# define UPDATE_CACHE(name, gb)\
+ if(name##_bit_count >= 0){\
name##_cache+= ((name##_buffer_ptr[0]<<8) + name##_buffer_ptr[1]) << name##_bit_count;\
name##_buffer_ptr+=2;\
name##_bit_count-= 16;\
}\
+#endif
+
# define SKIP_CACHE(name, gb, num)\
name##_cache <<= (num);\
@@ -638,6 +681,44 @@ static inline int get_bits_count(GetBitContext *s){
#endif
+/**
+ * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
+ * if MSB not set it is negative
+ * @param n length in bits
+ * @author BERO
+ */
+static inline int get_xbits(GetBitContext *s, int n){
+ register int tmp;
+ register int32_t cache;
+ OPEN_READER(re, s)
+ UPDATE_CACHE(re, s)
+ cache = GET_CACHE(re,s);
+ if ((int32_t)cache<0) { //MSB=1
+ tmp = NEG_USR32(cache,n);
+ } else {
+ // tmp = (-1<<n) | NEG_USR32(cache,n) + 1; mpeg12.c algo
+ // tmp = - (NEG_USR32(cache,n) ^ ((1 << n) - 1)); h263.c algo
+ tmp = - NEG_USR32(~cache,n);
+ }
+ LAST_SKIP_BITS(re, s, n)
+ CLOSE_READER(re, s)
+ return tmp;
+}
+
+static inline int get_sbits(GetBitContext *s, int n){
+ register int tmp;
+ OPEN_READER(re, s)
+ UPDATE_CACHE(re, s)
+ tmp= SHOW_SBITS(re, s, n);
+ LAST_SKIP_BITS(re, s, n)
+ CLOSE_READER(re, s)
+ return tmp;
+}
+
+/**
+ * reads 0-17 bits.
+ * Note, the alt bitstream reader can read upto 25 bits, but the libmpeg2 reader cant
+ */
static inline unsigned int get_bits(GetBitContext *s, int n){
register int tmp;
OPEN_READER(re, s)
@@ -648,6 +729,12 @@ static inline unsigned int get_bits(GetBitContext *s, int n){
return tmp;
}
+unsigned int get_bits_long(GetBitContext *s, int n);
+
+/**
+ * shows 0-17 bits.
+ * Note, the alt bitstream reader can read upto 25 bits, but the libmpeg2 reader cant
+ */
static inline unsigned int show_bits(GetBitContext *s, int n){
register int tmp;
OPEN_READER(re, s)
@@ -657,6 +744,8 @@ static inline unsigned int show_bits(GetBitContext *s, int n){
return tmp;
}
+unsigned int show_bits_long(GetBitContext *s, int n);
+
static inline void skip_bits(GetBitContext *s, int n){
//Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
OPEN_READER(re, s)
@@ -827,9 +916,18 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits
printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
return r;
}
+static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *func, int line){
+ int show= show_bits(s, n);
+ int r= get_xbits(s, n);
+
+ print_bin(show, n);
+ printf("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
+ return r;
+}
#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
@@ -1000,6 +1098,35 @@ if((y)<(x)){\
}
#endif
+#ifdef ARCH_X86
+static inline long long rdtsc()
+{
+ long long l;
+ asm volatile( "rdtsc\n\t"
+ : "=A" (l)
+ );
+ return l;
+}
+
+#define START_TIMER \
+static uint64_t tsum=0;\
+static int tcount=0;\
+static int tskip_count=0;\
+uint64_t tend;\
+uint64_t tstart= rdtsc();\
+
+#define STOP_TIMER(id) \
+tend= rdtsc();\
+if(tcount<2 || tend - tstart < 4*tsum/tcount){\
+ tsum+= tend - tstart;\
+ tcount++;\
+}else\
+ tskip_count++;\
+if(256*256*256*64%(tcount+tskip_count)==0){\
+ fprintf(stderr, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\
+}
+#endif
+
#define CLAMP_TO_8BIT(d) ((d > 0xff) ? 0xff : (d < 0) ? 0 : d)
/* avoid usage of various functions */
diff --git a/src/libffmpeg/libavcodec/cyuv.c b/src/libffmpeg/libavcodec/cyuv.c
index 1bf676a43..d1a6eabf2 100644
--- a/src/libffmpeg/libavcodec/cyuv.c
+++ b/src/libffmpeg/libavcodec/cyuv.c
@@ -37,7 +37,6 @@
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "bswap.h"
typedef struct CyuvDecodeContext {
@@ -98,6 +97,9 @@ static int cyuv_decode_frame(AVCodecContext *avctx,
/* pixel data starts 48 bytes in, after 3x16-byte tables */
stream_ptr = 48;
+ if(s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
s->frame.reference = 0;
if(avctx->get_buffer(avctx, &s->frame) < 0) {
fprintf(stderr, "get_buffer() failed\n");
@@ -159,8 +161,6 @@ static int cyuv_decode_frame(AVCodecContext *avctx,
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->frame;
- avctx->release_buffer(avctx, &s->frame);
-
return buf_size;
}
diff --git a/src/libffmpeg/libavcodec/dsputil.c b/src/libffmpeg/libavcodec/dsputil.c
index b9a5f1382..f6ce967da 100644
--- a/src/libffmpeg/libavcodec/dsputil.c
+++ b/src/libffmpeg/libavcodec/dsputil.c
@@ -187,6 +187,23 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
return s;
}
+static void bswap_buf(uint32_t *dst, uint32_t *src, int w){
+ int i;
+
+ for(i=0; i+8<=w; i+=8){
+ dst[i+0]= bswap_32(src[i+0]);
+ dst[i+1]= bswap_32(src[i+1]);
+ dst[i+2]= bswap_32(src[i+2]);
+ dst[i+3]= bswap_32(src[i+3]);
+ dst[i+4]= bswap_32(src[i+4]);
+ dst[i+5]= bswap_32(src[i+5]);
+ dst[i+6]= bswap_32(src[i+6]);
+ dst[i+7]= bswap_32(src[i+7]);
+ }
+ for(;i<w; i++){
+ dst[i+0]= bswap_32(src[i+0]);
+ }
+}
static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size)
{
@@ -466,6 +483,14 @@ CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c,
#else // 64 bit variant
#define PIXOP2(OPNAME, OP) \
+static void OPNAME ## _pixels2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+ int i;\
+ for(i=0; i<h; i++){\
+ OP(*((uint16_t*)(block )), LD16(pixels ));\
+ pixels+=line_size;\
+ block +=line_size;\
+ }\
+}\
static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
int i;\
for(i=0; i<h; i++){\
@@ -494,10 +519,10 @@ static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src
uint32_t a,b;\
a= LD32(&src1[i*src_stride1 ]);\
b= LD32(&src2[i*src_stride2 ]);\
- OP(*((uint32_t*)&dst[i*dst_stride ]), (a&b) + (((a^b)&0xFEFEFEFEUL)>>1));\
+ OP(*((uint32_t*)&dst[i*dst_stride ]), no_rnd_avg32(a, b));\
a= LD32(&src1[i*src_stride1+4]);\
b= LD32(&src2[i*src_stride2+4]);\
- OP(*((uint32_t*)&dst[i*dst_stride+4]), (a&b) + (((a^b)&0xFEFEFEFEUL)>>1));\
+ OP(*((uint32_t*)&dst[i*dst_stride+4]), no_rnd_avg32(a, b));\
}\
}\
\
@@ -508,10 +533,10 @@ static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, cons
uint32_t a,b;\
a= LD32(&src1[i*src_stride1 ]);\
b= LD32(&src2[i*src_stride2 ]);\
- OP(*((uint32_t*)&dst[i*dst_stride ]), (a|b) - (((a^b)&0xFEFEFEFEUL)>>1));\
+ OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
a= LD32(&src1[i*src_stride1+4]);\
b= LD32(&src2[i*src_stride2+4]);\
- OP(*((uint32_t*)&dst[i*dst_stride+4]), (a|b) - (((a^b)&0xFEFEFEFEUL)>>1));\
+ OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
}\
}\
\
@@ -522,7 +547,18 @@ static inline void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, cons
uint32_t a,b;\
a= LD32(&src1[i*src_stride1 ]);\
b= LD32(&src2[i*src_stride2 ]);\
- OP(*((uint32_t*)&dst[i*dst_stride ]), (a|b) - (((a^b)&0xFEFEFEFEUL)>>1));\
+ OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
+ }\
+}\
+\
+static inline void OPNAME ## _pixels2_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
+ int src_stride1, int src_stride2, int h){\
+ int i;\
+ for(i=0; i<h; i++){\
+ uint32_t a,b;\
+ a= LD16(&src1[i*src_stride1 ]);\
+ b= LD16(&src2[i*src_stride2 ]);\
+ OP(*((uint16_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
}\
}\
\
@@ -589,6 +625,23 @@ static inline void OPNAME ## _pixels8_l4(uint8_t *dst, const uint8_t *src1, uint
OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
}\
}\
+\
+static inline void OPNAME ## _pixels4_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+ OPNAME ## _pixels4_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
+}\
+\
+static inline void OPNAME ## _pixels4_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+ OPNAME ## _pixels4_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
+}\
+\
+static inline void OPNAME ## _pixels2_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+ OPNAME ## _pixels2_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
+}\
+\
+static inline void OPNAME ## _pixels2_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
+ OPNAME ## _pixels2_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
+}\
+\
static inline void OPNAME ## _no_rnd_pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
int i;\
@@ -635,6 +688,75 @@ static inline void OPNAME ## _no_rnd_pixels16_l4(uint8_t *dst, const uint8_t *sr
OPNAME ## _no_rnd_pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
}\
\
+static inline void OPNAME ## _pixels2_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
+{\
+ int i, a0, b0, a1, b1;\
+ a0= pixels[0];\
+ b0= pixels[1] + 2;\
+ a0 += b0;\
+ b0 += pixels[2];\
+\
+ pixels+=line_size;\
+ for(i=0; i<h; i+=2){\
+ a1= pixels[0];\
+ b1= pixels[1];\
+ a1 += b1;\
+ b1 += pixels[2];\
+\
+ block[0]= (a1+a0)>>2; /* FIXME non put */\
+ block[1]= (b1+b0)>>2;\
+\
+ pixels+=line_size;\
+ block +=line_size;\
+\
+ a0= pixels[0];\
+ b0= pixels[1] + 2;\
+ a0 += b0;\
+ b0 += pixels[2];\
+\
+ block[0]= (a1+a0)>>2;\
+ block[1]= (b1+b0)>>2;\
+ pixels+=line_size;\
+ block +=line_size;\
+ }\
+}\
+\
+static inline void OPNAME ## _pixels4_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
+{\
+ int i;\
+ const uint32_t a= LD32(pixels );\
+ const uint32_t b= LD32(pixels+1);\
+ uint32_t l0= (a&0x03030303UL)\
+ + (b&0x03030303UL)\
+ + 0x02020202UL;\
+ uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
+ + ((b&0xFCFCFCFCUL)>>2);\
+ uint32_t l1,h1;\
+\
+ pixels+=line_size;\
+ for(i=0; i<h; i+=2){\
+ uint32_t a= LD32(pixels );\
+ uint32_t b= LD32(pixels+1);\
+ l1= (a&0x03030303UL)\
+ + (b&0x03030303UL);\
+ h1= ((a&0xFCFCFCFCUL)>>2)\
+ + ((b&0xFCFCFCFCUL)>>2);\
+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
+ pixels+=line_size;\
+ block +=line_size;\
+ a= LD32(pixels );\
+ b= LD32(pixels+1);\
+ l0= (a&0x03030303UL)\
+ + (b&0x03030303UL)\
+ + 0x02020202UL;\
+ h0= ((a&0xFCFCFCFCUL)>>2)\
+ + ((b&0xFCFCFCFCUL)>>2);\
+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
+ pixels+=line_size;\
+ block +=line_size;\
+ }\
+}\
+\
static inline void OPNAME ## _pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
{\
int j;\
@@ -726,7 +848,7 @@ CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels8_x2_c
CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels8_y2_c , 8)\
CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels8_xy2_c, 8)\
-#define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) )
+#define op_avg(a, b) a = rnd_avg32(a, b)
#endif
#define op_put(a, b) a = b
@@ -819,6 +941,222 @@ static void gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
oy += dyy;
}
}
+
+static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ switch(width){
+ case 2: put_pixels2_c (dst, src, stride, height); break;
+ case 4: put_pixels4_c (dst, src, stride, height); break;
+ case 8: put_pixels8_c (dst, src, stride, height); break;
+ case 16:put_pixels16_c(dst, src, stride, height); break;
+ }
+}
+
+static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ switch(width){
+ case 2: avg_pixels2_c (dst, src, stride, height); break;
+ case 4: avg_pixels4_c (dst, src, stride, height); break;
+ case 8: avg_pixels8_c (dst, src, stride, height); break;
+ case 16:avg_pixels16_c(dst, src, stride, height); break;
+ }
+}
+
+static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+
+static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
+ int i,j;
+ for (i=0; i < height; i++) {
+ for (j=0; j < width; j++) {
+ dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
+ }
+ src += stride;
+ dst += stride;
+ }
+}
+#if 0
+#define TPEL_WIDTH(width)\
+static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\
+static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
+ void put_tpel_pixels_mc22_c(dst, src, stride, width, height);}
+#endif
+
#define H264_CHROMA_MC(OPNAME, OP)\
static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
const int A=(8-x)*(8-y);\
@@ -2561,13 +2899,37 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
dspfunc(put_no_rnd, 0, 16);
dspfunc(put, 1, 8);
dspfunc(put_no_rnd, 1, 8);
+ dspfunc(put, 2, 4);
+ dspfunc(put, 3, 2);
dspfunc(avg, 0, 16);
dspfunc(avg_no_rnd, 0, 16);
dspfunc(avg, 1, 8);
dspfunc(avg_no_rnd, 1, 8);
+ dspfunc(avg, 2, 4);
+ dspfunc(avg, 3, 2);
#undef dspfunc
+ c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
+ c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
+ c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
+ c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
+ c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
+ c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
+ c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
+ c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
+ c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
+
+ c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
+ c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
+ c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
+ c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
+ c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
+ c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
+ c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
+ c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
+ c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
+
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
@@ -2621,7 +2983,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
-
+
c->hadamard8_diff[0]= hadamard8_diff16_c;
c->hadamard8_diff[1]= hadamard8_diff_c;
c->hadamard8_abs = hadamard8_abs_c;
@@ -2643,6 +3005,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
+ c->bswap_buf= bswap_buf;
#ifdef HAVE_MMX
dsputil_init_mmx(c, avctx);
@@ -2662,6 +3025,9 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
#ifdef HAVE_MMI
dsputil_init_mmi(c, avctx);
#endif
+#ifdef ARCH_SH4
+ dsputil_init_sh4(c,avctx);
+#endif
switch(c->idct_permutation_type){
case FF_NO_IDCT_PERM:
diff --git a/src/libffmpeg/libavcodec/dsputil.h b/src/libffmpeg/libavcodec/dsputil.h
index e4a524d8d..190ea10f1 100644
--- a/src/libffmpeg/libavcodec/dsputil.h
+++ b/src/libffmpeg/libavcodec/dsputil.h
@@ -29,17 +29,14 @@
#include "common.h"
#include "avcodec.h"
-
-
#include "xineutils.h"
#if defined(ARCH_X86)
-#define HAVE_MMX 1
+#define HAVE_MMX 1
#endif
#undef DEBUG
-//#define DEBUG
/* dct code */
typedef short DCTELEM;
//typedef int DCTELEM;
@@ -85,6 +82,7 @@ void clear_blocks_c(DCTELEM *blocks);
/* add and put pixel (decoding) */
// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
+typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
@@ -154,30 +152,30 @@ typedef struct DSPContext {
me_cmp_func me_sub_cmp[11];
me_cmp_func mb_cmp[11];
- /* maybe create an array for 16/8 functions */
+ /* maybe create an array for 16/8/4/2 functions */
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[2][4] of motion compensation funcions for 2
- * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
+ * this is an array[4][4] of motion compensation funcions for 4
+ * horizontal blocksizes (2,4,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
*/
- op_pixels_func put_pixels_tab[2][4];
+ op_pixels_func put_pixels_tab[4][4];
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[2][4] of motion compensation funcions for 2
- * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
+ * this is an array[4][4] of motion compensation funcions for 4
+ * horizontal blocksizes (2,4,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)>>1
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
* @param h height
*/
- op_pixels_func avg_pixels_tab[2][4];
+ op_pixels_func avg_pixels_tab[4][4];
/**
* Halfpel motion compensation with no rounding (a+b)>>1.
@@ -202,6 +200,19 @@ typedef struct DSPContext {
* @param h height
*/
op_pixels_func avg_no_rnd_pixels_tab[2][4];
+
+ /**
+ * Thirdpel motion compensation with rounding (a+b+1)>>1.
+ * this is an array[12] of motion compensation funcions for the 9 thirdpel positions<br>
+ * *pixels_tab[ xthirdpel + 4*ythirdpel ]
+ * @param block destination where the result is stored
+ * @param pixels source
+ * @param line_size number of bytes in a horizontal line of block
+ * @param h height
+ */
+ tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
+ tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
+
qpel_mc_func put_qpel_pixels_tab[2][16];
qpel_mc_func avg_qpel_pixels_tab[2][16];
qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
@@ -229,6 +240,7 @@ typedef struct DSPContext {
/* huffyuv specific */
void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
+ void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w);
/* (I)DCT */
void (*fdct)(DCTELEM *block/* align 16*/);
@@ -248,6 +260,10 @@ typedef struct DSPContext {
/**
* idct input permutation.
+ * several optimized IDCTs need a permutated input (relative to the normal order of the reference
+ * IDCT)
+ * this permutation must be performed before the idct_put/add, note, normally this can be merged
+ * with the zigzag/alternate scan<br>
* an example to avoid confusion:
* - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
* - (x -> referece dct -> reference idct -> x)
@@ -272,6 +288,18 @@ void dsputil_init(DSPContext* p, AVCodecContext *avctx);
*/
void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
+#define BYTE_VEC32(c) ((c)*0x01010101UL)
+
+static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
+{
+ return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
+}
+
+static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
+{
+ return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
+}
+
/**
* Empty mmx state.
* this must be called between any dsp function and float/double code.
@@ -300,7 +328,7 @@ extern int mm_flags;
void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-#if 0
+#if 0
static inline void emms(void)
{
__asm __volatile ("emms;":::"memory");
@@ -360,6 +388,12 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
+#elif defined(ARCH_SH4)
+
+#define __align8 __attribute__ ((aligned (8)))
+
+void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
+
#else
#define __align8
@@ -370,7 +404,9 @@ void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
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)
@@ -378,6 +414,7 @@ struct unaligned_32 { uint32_t l; } __attribute__((packed));
#else /* __GNUC__ */
+#define LD16(a) (*((uint16_t*)(a)))
#define LD32(a) (*((uint32_t*)(a)))
#define LD64(a) (*((uint64_t*)(a)))
diff --git a/src/libffmpeg/libavcodec/dv.c b/src/libffmpeg/libavcodec/dv.c
index 32d4c3a27..d454e61e6 100644
--- a/src/libffmpeg/libavcodec/dv.c
+++ b/src/libffmpeg/libavcodec/dv.c
@@ -157,7 +157,7 @@ static const uint16_t block_sizes[6] = {
};
#ifndef ALT_BITSTREAM_READER
-#error only works with ALT_BITSTREAM_READER
+#warning only works with ALT_BITSTREAM_READER
#endif
/* decode ac coefs */
@@ -171,7 +171,10 @@ static void dv_decode_ac(DVVideoDecodeContext *s,
int pos = mb->pos;
int level, pos1, sign, run;
int partial_bit_count;
-
+#ifndef ALT_BITSTREAM_READER //FIXME
+ int re_index=0;
+ int re1_index=0;
+#endif
OPEN_READER(re, &s->gb);
#ifdef VLC_DEBUG
@@ -364,7 +367,7 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
/* write the remaining bits in a new buffer only if the
block is finished */
- bits_left = last_index - s->gb.index;
+ bits_left = last_index - get_bits_count(&s->gb);
if (mb->eob_reached) {
mb->partial_bit_count = 0;
mb_bit_count += bits_left;
@@ -389,13 +392,13 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
mb = mb1;
init_get_bits(&s->gb, mb_bit_buffer, 80*8);
for(j = 0;j < 6; j++) {
- if (!mb->eob_reached && s->gb.index < mb_bit_count) {
+ if (!mb->eob_reached && get_bits_count(&s->gb) < mb_bit_count) {
dv_decode_ac(s, mb, block, mb_bit_count);
/* if still not finished, no need to parse other blocks */
if (!mb->eob_reached) {
/* we could not parse the current AC coefficient,
so we add the remaining bytes */
- bits_left = mb_bit_count - s->gb.index;
+ bits_left = mb_bit_count - get_bits_count(&s->gb);
if (bits_left > 0) {
mb->partial_bit_count += bits_left;
mb->partial_bit_buffer =
@@ -410,7 +413,7 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
}
/* all blocks are finished, so the extra bytes can be used at
the video segment level */
- bits_left = mb_bit_count - s->gb.index;
+ bits_left = mb_bit_count - get_bits_count(&s->gb);
vs_bit_count += bits_left;
bit_copy(&vs_pb, &s->gb, bits_left);
next_mb:
@@ -473,12 +476,12 @@ static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
ptr = pixels;
for(y = 0;y < 8; y++) {
/* convert to 411P */
- c_ptr1 = c_ptr + linesize;
- c_ptr1[0] = c_ptr[0] = (ptr[0] + ptr[1]) >> 1;
- c_ptr1[1] = c_ptr[1] = (ptr[2] + ptr[3]) >> 1;
- c_ptr1[2] = c_ptr[2] = (ptr[4] + ptr[5]) >> 1;
- c_ptr1[3] = c_ptr[3] = (ptr[6] + ptr[7]) >> 1;
- c_ptr += linesize * 2;
+ c_ptr1 = c_ptr + 8*linesize;
+ c_ptr[0]= ptr[0]; c_ptr1[0]= ptr[4];
+ c_ptr[1]= ptr[1]; c_ptr1[1]= ptr[5];
+ c_ptr[2]= ptr[2]; c_ptr1[2]= ptr[6];
+ c_ptr[3]= ptr[3]; c_ptr1[3]= ptr[7];
+ c_ptr += linesize;
ptr += 8;
}
} else {
diff --git a/src/libffmpeg/libavcodec/error_resilience.c b/src/libffmpeg/libavcodec/error_resilience.c
index 6a940ed0a..4ac92bfd2 100644
--- a/src/libffmpeg/libavcodec/error_resilience.c
+++ b/src/libffmpeg/libavcodec/error_resilience.c
@@ -733,7 +733,7 @@ void ff_er_frame_end(MpegEncContext *s){
for(i=s->mb_num-2; i>=s->mb_width+100; i--){ //FIXME +100 hack
const int mb_xy= s->mb_index2xy[i];
int error1= s->error_status_table[mb_xy ];
- int error2= s->error_status_table[mb_xy+1];
+ int error2= s->error_status_table[s->mb_index2xy[i+1]];
if(error1&VP_START)
end_ok=1;
diff --git a/src/libffmpeg/libavcodec/golomb.c b/src/libffmpeg/libavcodec/golomb.c
index c8c200c30..a696b2a76 100644
--- a/src/libffmpeg/libavcodec/golomb.c
+++ b/src/libffmpeg/libavcodec/golomb.c
@@ -95,3 +95,60 @@ const uint8_t ff_ue_golomb_len[256]={
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,
};
+
+const uint8_t ff_interleaved_golomb_vlc_len[256]={
+9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
+9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
+9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+};
+
+const uint8_t ff_interleaved_ue_golomb_vlc_code[256]={
+ 15,16,7, 7, 17,18,8, 8, 3, 3, 3, 3, 3, 3, 3, 3,
+ 19,20,9, 9, 21,22,10,10,4, 4, 4, 4, 4, 4, 4, 4,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 23,24,11,11,25,26,12,12,5, 5, 5, 5, 5, 5, 5, 5,
+ 27,28,13,13,29,30,14,14,6, 6, 6, 6, 6, 6, 6, 6,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+const int8_t ff_interleaved_se_golomb_vlc_code[256]={
+ 8, -8, 4, 4, 9, -9, -4, -4, 2, 2, 2, 2, 2, 2, 2, 2,
+ 10,-10, 5, 5, 11,-11, -5, -5, -2, -2, -2, -2, -2, -2, -2, -2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 12,-12, 6, 6, 13,-13, -6, -6, 3, 3, 3, 3, 3, 3, 3, 3,
+ 14,-14, 7, 7, 15,-15, -7, -7, -3, -3, -3, -3, -3, -3, -3, -3,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
diff --git a/src/libffmpeg/libavcodec/golomb.h b/src/libffmpeg/libavcodec/golomb.h
index 510d913ae..9861b18d1 100644
--- a/src/libffmpeg/libavcodec/golomb.h
+++ b/src/libffmpeg/libavcodec/golomb.h
@@ -32,6 +32,10 @@ extern const uint8_t ff_ue_golomb_vlc_code[512];
extern const int8_t ff_se_golomb_vlc_code[512];
extern const uint8_t ff_ue_golomb_len[256];
+extern const uint8_t ff_interleaved_golomb_vlc_len[256];
+extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
+extern const int8_t ff_interleaved_se_golomb_vlc_code[256];
+
/**
* read unsigned exp golomb code.
@@ -62,24 +66,33 @@ static inline int get_ue_golomb(GetBitContext *gb){
}
static inline int svq3_get_ue_golomb(GetBitContext *gb){
- unsigned int buf;
+ uint32_t buf;
int log;
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb)|1;
-
- if((buf & 0xAAAAAAAA) == 0)
- return INVALID_VLC;
+ buf=GET_CACHE(re, gb);
+
+ if(buf&0xAA800000){
+ buf >>= 32 - 8;
+ LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_interleaved_ue_golomb_vlc_code[buf];
+ }else{
+ buf|=1;
+ if((buf & 0xAAAAAAAA) == 0)
+ return INVALID_VLC;
- for(log=31; (buf & 0x80000000) == 0; log--){
- buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
- }
+ for(log=31; (buf & 0x80000000) == 0; log--){
+ buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
+ }
- LAST_SKIP_BITS(re, gb, 63 - 2*log);
- CLOSE_READER(re, gb);
+ LAST_SKIP_BITS(re, gb, 63 - 2*log);
+ CLOSE_READER(re, gb);
- return ((buf << log) >> log) - 1;
+ return ((buf << log) >> log) - 1;
+ }
}
/**
@@ -141,19 +154,59 @@ static inline int svq3_get_se_golomb(GetBitContext *gb){
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb)|1;
+ buf=GET_CACHE(re, gb);
+
+ if(buf&0xAA800000){
+ buf >>= 32 - 8;
+ LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
+ CLOSE_READER(re, gb);
+
+ return ff_interleaved_se_golomb_vlc_code[buf];
+ }else{
+ buf |=1;
+ if((buf & 0xAAAAAAAA) == 0)
+ return INVALID_VLC;
- if((buf & 0xAAAAAAAA) == 0)
- return INVALID_VLC;
+ for(log=31; (buf & 0x80000000) == 0; log--){
+ buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
+ }
- for(log=31; (buf & 0x80000000) == 0; log--){
- buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
+ LAST_SKIP_BITS(re, gb, 63 - 2*log);
+ CLOSE_READER(re, gb);
+
+ return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
}
+}
- LAST_SKIP_BITS(re, gb, 63 - 2*log);
- CLOSE_READER(re, gb);
+/**
+ * read unsigned golomb rice code.
+ */
+static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len){
+ unsigned int buf;
+ int log;
+
+ OPEN_READER(re, gb);
+ UPDATE_CACHE(re, gb);
+ buf=GET_CACHE(re, gb);
- return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
+ log= av_log2(buf);
+//printf("buf:%X log:%d\n", buf, log);
+ if(log > 31-limit){
+ buf >>= log - k;
+ buf += (30-log)<<k;
+ LAST_SKIP_BITS(re, gb, 32 + k - log);
+ CLOSE_READER(re, gb);
+
+ return buf;
+ }else if(log == 31-limit){
+ buf >>= log - esc_len;
+ buf -= 1<<esc_len;
+ LAST_SKIP_BITS(re, gb, esc_len + limit + 1);
+ CLOSE_READER(re, gb);
+
+ return buf + 1;
+ }else
+ return -1;
}
#ifdef TRACE
@@ -257,3 +310,22 @@ static inline void set_se_golomb(PutBitContext *pb, int i){
#endif
set_ue_golomb(pb, i);
}
+
+/**
+ * write unsigned golomb rice code.
+ */
+static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
+ int e;
+
+ assert(i>=0);
+
+ e= i>>k;
+ if(e<limit){
+ put_bits(pb, e + k + 1, (1<<k) + (i&((1<<k)-1)));
+ }else{
+// printf("set %08X, %d\n", (1<<esc_len) + i - 1, limit + esc_len + 1);
+ put_bits(pb, limit + esc_len + 1, (1<<esc_len) + i - 1);
+// put_bits(pb, 1, limit + 1);
+// put_bits(pb, i - 1, esc_len);
+ }
+}
diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c
index ed4da642f..5b3119ac9 100644
--- a/src/libffmpeg/libavcodec/h263.c
+++ b/src/libffmpeg/libavcodec/h263.c
@@ -73,8 +73,6 @@ static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
static void mpeg4_decode_sprite_trajectory(MpegEncContext * s);
static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr);
-extern uint32_t inverse[256];
-
#ifdef CONFIG_ENCODERS
static uint8_t uni_DCtab_lum_len[512];
static uint8_t uni_DCtab_chrom_len[512];
@@ -104,6 +102,11 @@ max run: 29/41
*/
#endif
+#if 0 //3IV1 is quite rare and tis slows things down a tiny bit
+#define IS_3IV1 s->avctx->codec_tag == ff_get_fourcc("3IV1")
+#else
+#define IS_3IV1 0
+#endif
int h263_get_picture_format(int width, int height)
{
@@ -645,6 +648,7 @@ void mpeg4_encode_mb(MpegEncContext * s,
s->last_bits++;
}
s->skip_count++;
+
return;
}
}
@@ -1823,7 +1827,6 @@ static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_
{
int a, b, c, wrap, pred, scale;
uint16_t *dc_val;
- int dummy;
/* find prediction */
if (n < 4) {
@@ -1831,6 +1834,9 @@ static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_
} else {
scale = s->c_dc_scale;
}
+ if(IS_3IV1)
+ scale= 8;
+
wrap= s->block_wrap[n];
dc_val = s->dc_val[0] + s->block_index[n];
@@ -1859,16 +1865,7 @@ static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_
*dir_ptr = 0; /* left */
}
/* we assume pred is positive */
-#ifdef ARCH_X86
- asm volatile (
- "xorl %%edx, %%edx \n\t"
- "mul %%ecx \n\t"
- : "=d" (pred), "=a"(dummy)
- : "a" (pred + (scale >> 1)), "c" (inverse[scale])
- );
-#else
- pred = (pred + (scale >> 1)) / scale;
-#endif
+ pred = FASTDIV((pred + (scale >> 1)), scale);
/* prepare address for prediction update */
*dc_val_ptr = &dc_val[0];
@@ -2708,7 +2705,7 @@ static int mpeg4_decode_partition_a(MpegEncContext *s){
if(s->pict_type==I_TYPE){
int i;
- if(show_bits(&s->gb, 19)==DC_MARKER){
+ if(show_bits_long(&s->gb, 19)==DC_MARKER){
return mb_num-1;
}
@@ -2956,7 +2953,7 @@ int ff_mpeg4_decode_partitions(MpegEncContext *s)
s->mb_num_left= mb_num;
if(s->pict_type==I_TYPE){
- if(get_bits(&s->gb, 19)!=DC_MARKER){
+ if(get_bits_long(&s->gb, 19)!=DC_MARKER){
fprintf(stderr, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
@@ -3437,10 +3434,12 @@ static int h263_decode_motion(MpegEncContext * s, int pred, int f_code)
sign = get_bits1(&s->gb);
shift = f_code - 1;
- val = (code - 1) << shift;
- if (shift > 0)
+ val = code;
+ if (shift) {
+ val = (val - 1) << shift;
val |= get_bits(&s->gb, shift);
- val++;
+ val++;
+ }
if (sign)
val = -val;
val += pred;
@@ -3448,11 +3447,7 @@ static int h263_decode_motion(MpegEncContext * s, int pred, int f_code)
/* modulo decoding */
if (!s->h263_long_vectors) {
l = 1 << (f_code + 4);
- if (val < -l) {
- val += l<<1;
- } else if (val >= l) {
- val -= l<<1;
- }
+ val = ((val + l)&(l*2-1)) - l;
} else {
/* horrible h263 long vector mode */
if (pred < -31 && val < -63)
@@ -3562,12 +3557,10 @@ static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
if(level == -128){
if (s->h263_rv10) {
/* XXX: should patch encoder too */
- level = get_bits(&s->gb, 12);
- level= (level + ((-1)<<11)) ^ ((-1)<<11); //sign extension
+ level = get_sbits(&s->gb, 12);
}else{
level = get_bits(&s->gb, 5);
- level += get_bits(&s->gb, 6)<<5;
- level= (level + ((-1)<<10)) ^ ((-1)<<10); //sign extension
+ level |= get_sbits(&s->gb, 6)<<5;
}
}
} else {
@@ -3619,9 +3612,19 @@ static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
if (code == 0) {
level = 0;
} else {
- level = get_bits(&s->gb, code);
- if ((level >> (code - 1)) == 0) /* if MSB not set it is negative*/
- level = - (level ^ ((1 << code) - 1));
+ if(IS_3IV1){
+ if(code==1)
+ level= 2*get_bits1(&s->gb)-1;
+ else{
+ if(get_bits1(&s->gb))
+ level = get_bits(&s->gb, code-1) + (1<<(code-1));
+ else
+ level = -get_bits(&s->gb, code-1) - (1<<(code-1));
+ }
+ }else{
+ level = get_xbits(&s->gb, code);
+ }
+
if (code > 8){
if(get_bits1(&s->gb)==0){ /* marker */
if(s->error_resilience>=2){
@@ -3645,6 +3648,9 @@ static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
} else {
*dc_val = level * s->c_dc_scale;
}
+ if(IS_3IV1)
+ *dc_val = level * 8;
+
if(s->error_resilience>=3){
if(*dc_val > 2048 + s->y_dc_scale + s->c_dc_scale){
fprintf(stderr, "dc overflow at %dx%d\n", s->mb_x, s->mb_y);
@@ -3674,8 +3680,8 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
/* DC coef */
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
- if(n<4) level= (level + (s->y_dc_scale>>1))/s->y_dc_scale; //FIXME optimizs
- else level= (level + (s->c_dc_scale>>1))/s->c_dc_scale;
+ if(n<4) level= FASTDIV((level + (s->y_dc_scale>>1)), s->y_dc_scale);
+ else level= FASTDIV((level + (s->c_dc_scale>>1)), s->c_dc_scale);
dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_stride]<<n)&32;
}else{
level = mpeg4_decode_dc(s, n, &dc_pred_dir);
@@ -3768,10 +3774,14 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
SKIP_COUNTER(re, &s->gb, 1+11+5+1);
i+= run + 1;
- if(last) i+=192;
+ if(last) i+=192;
}else{
int cache;
cache= GET_CACHE(re, &s->gb);
+
+ if(IS_3IV1)
+ cache ^= 0xC0000000;
+
if (cache&0x80000000) {
if (cache&0x40000000) {
/* third escape */
@@ -3781,20 +3791,24 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
SKIP_COUNTER(re, &s->gb, 2+1+6);
UPDATE_CACHE(re, &s->gb);
- if(SHOW_UBITS(re, &s->gb, 1)==0){
- fprintf(stderr, "1. marker bit missing in 3. esc\n");
- return -1;
- }; SKIP_CACHE(re, &s->gb, 1);
-
- level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
+ if(IS_3IV1){
+ level= SHOW_SBITS(re, &s->gb, 12); LAST_SKIP_BITS(re, &s->gb, 12);
+ }else{
+ if(SHOW_UBITS(re, &s->gb, 1)==0){
+ fprintf(stderr, "1. marker bit missing in 3. esc\n");
+ return -1;
+ }; SKIP_CACHE(re, &s->gb, 1);
+
+ level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
+
+ if(SHOW_UBITS(re, &s->gb, 1)==0){
+ fprintf(stderr, "2. marker bit missing in 3. esc\n");
+ return -1;
+ }; LAST_SKIP_CACHE(re, &s->gb, 1);
+
+ SKIP_COUNTER(re, &s->gb, 1+12+1);
+ }
- if(SHOW_UBITS(re, &s->gb, 1)==0){
- fprintf(stderr, "2. marker bit missing in 3. esc\n");
- return -1;
- }; LAST_SKIP_CACHE(re, &s->gb, 1);
-
- SKIP_COUNTER(re, &s->gb, 1+12+1);
-
if(level*s->qscale>1024 || level*s->qscale<-1024){
fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
@@ -3888,10 +3902,21 @@ static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
/* most is hardcoded. should extend to handle all h263 streams */
int h263_decode_picture_header(MpegEncContext *s)
{
- int format, width, height;
+ int format, width, height, i;
+ uint32_t startcode;
+
+ align_get_bits(&s->gb);
+
+ startcode= get_bits(&s->gb, 22-8);
- /* picture start code */
- if (get_bits(&s->gb, 22) != 0x20) {
+ for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>0; i--) {
+ startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
+
+ if(startcode == 0x20)
+ break;
+ }
+
+ if (startcode != 0x20) {
fprintf(stderr, "Bad picture start code\n");
return -1;
}
@@ -3974,15 +3999,26 @@ int h263_decode_picture_header(MpegEncContext *s)
s->h263_aic = 1;
}
- skip_bits(&s->gb, 7);
- /* these are the 7 bits: (in order of appearence */
- /* Deblocking Filter */
- /* Slice Structured */
- /* Reference Picture Selection */
- /* Independent Segment Decoding */
- /* Alternative Inter VLC */
- /* Modified Quantization */
- /* Prevent start code emulation */
+ if (get_bits1(&s->gb) != 0) {
+ fprintf(stderr, "Deblocking Filter not supported\n");
+ }
+ if (get_bits1(&s->gb) != 0) {
+ fprintf(stderr, "Slice Structured not supported\n");
+ }
+ if (get_bits1(&s->gb) != 0) {
+ fprintf(stderr, "Reference Picture Selection not supported\n");
+ }
+ if (get_bits1(&s->gb) != 0) {
+ fprintf(stderr, "Independent Segment Decoding not supported\n");
+ }
+ if (get_bits1(&s->gb) != 0) {
+ fprintf(stderr, "Alternative Inter VLC not supported\n");
+ }
+ if (get_bits1(&s->gb) != 0) {
+ fprintf(stderr, "Modified Quantization not supported\n");
+ }
+
+ skip_bits(&s->gb, 1); /* Prevent start code emulation */
skip_bits(&s->gb, 3); /* Reserved */
} else if (ufep != 0) {
@@ -4058,6 +4094,18 @@ int h263_decode_picture_header(MpegEncContext *s)
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
+ if(s->avctx->debug&FF_DEBUG_PICT_INFO){
+ printf("qp:%d %c size:%d rnd:%d %s %s %s %s\n",
+ s->qscale, av_get_pict_type_char(s->pict_type),
+ s->gb.size_in_bits, 1-s->no_rounding,
+ s->mv_type == MV_TYPE_8X8 ? "ADV" : "",
+ s->umvplus ? "UMV" : "",
+ s->h263_long_vectors ? "LONG" : "",
+ s->h263_plus ? "+" : ""
+ );
+ }
+
+
return 0;
}
@@ -4083,19 +4131,13 @@ static void mpeg4_decode_sprite_trajectory(MpegEncContext * s)
length= get_vlc(&s->gb, &sprite_trajectory);
if(length){
- x= get_bits(&s->gb, length);
-
- if ((x >> (length - 1)) == 0) /* if MSB not set it is negative*/
- x = - (x ^ ((1 << length) - 1));
+ x= get_xbits(&s->gb, length);
}
if(!(s->divx_version==500 && s->divx_build==413)) skip_bits1(&s->gb); /* marker bit */
length= get_vlc(&s->gb, &sprite_trajectory);
if(length){
- y=get_bits(&s->gb, length);
-
- if ((y >> (length - 1)) == 0) /* if MSB not set it is negative*/
- y = - (y ^ ((1 << length) - 1));
+ y=get_xbits(&s->gb, length);
}
skip_bits1(&s->gb); /* marker bit */
//printf("%d %d %d %d\n", x, y, i, s->sprite_warping_accuracy);
@@ -4374,7 +4416,8 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
}
s->progressive_sequence= get_bits1(gb)^1;
- if(!get_bits1(gb)) printf("OBMC not supported (very likely buggy encoder)\n"); /* OBMC Disable */
+ if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
+ printf("OBMC not supported (very likely buggy encoder)\n"); /* OBMC Disable */
if (vo_ver_id == 1) {
s->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
} else {
@@ -4722,15 +4765,15 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
}
if(s->alternate_scan){
- ff_init_scantable(s, &s->inter_scantable , ff_alternate_vertical_scan);
- ff_init_scantable(s, &s->intra_scantable , ff_alternate_vertical_scan);
- ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_vertical_scan);
- ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
} else{
- ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct);
- ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct);
- ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan);
- ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
}
if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
@@ -4761,12 +4804,12 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
s->b_code=1;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d\n",
+ printf("qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d\n",
s->qscale, s->f_code, s->b_code,
s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")),
gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first,
s->quarter_sample ? "q" : "h", s->data_partitioning, s->resync_marker, s->num_sprite_warping_points,
- s->sprite_warping_accuracy);
+ s->sprite_warping_accuracy, 1-s->no_rounding);
}
if(!s->scalability){
@@ -4889,7 +4932,7 @@ int intel_h263_decode_picture_header(MpegEncContext *s)
int format;
/* picture header */
- if (get_bits(&s->gb, 22) != 0x20) {
+ if (get_bits_long(&s->gb, 22) != 0x20) {
fprintf(stderr, "Bad picture start code\n");
return -1;
}
diff --git a/src/libffmpeg/libavcodec/h263dec.c b/src/libffmpeg/libavcodec/h263dec.c
index 98215bf4c..efc43cd67 100644
--- a/src/libffmpeg/libavcodec/h263dec.c
+++ b/src/libffmpeg/libavcodec/h263dec.c
@@ -325,87 +325,56 @@ static int mpeg4_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
}
}
}
-
- for(; i<buf_size; i++){
+
+ if(vop_found){
+ for(; i<buf_size; i++){
state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
+ }
}
pc->frame_start_found= vop_found;
pc->state= state;
- return -1;
+ return END_NOT_FOUND;
}
-/**
- * draws an line from (ex, ey) -> (sx, sy).
- * @param w width of the image
- * @param h height of the image
- * @param stride stride/linesize of the image
- * @param color color of the arrow
- */
-static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
- int t, x, y, f;
-
- ex= clip(ex, 0, w-1);
- ey= clip(ey, 0, h-1);
+static int h263_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
+ ParseContext *pc= &s->parse_context;
+ int vop_found, i;
+ uint32_t state;
- buf[sy*stride + sx]+= color;
+ vop_found= pc->frame_start_found;
+ state= pc->state;
- if(ABS(ex - sx) > ABS(ey - sy)){
- if(sx > ex){
- t=sx; sx=ex; ex=t;
- t=sy; sy=ey; ey=t;
- }
- buf+= sx + sy*stride;
- ex-= sx;
- f= ((ey-sy)<<16)/ex;
- for(x= 0; x <= ex; x++){
- y= ((x*f) + (1<<15))>>16;
- buf[y*stride + x]+= color;
- }
- }else{
- if(sy > ey){
- t=sx; sx=ex; ex=t;
- t=sy; sy=ey; ey=t;
- }
- buf+= sx + sy*stride;
- ey-= sy;
- if(ey) f= ((ex-sx)<<16)/ey;
- else f= 0;
- for(y= 0; y <= ey; y++){
- x= ((y*f) + (1<<15))>>16;
- buf[y*stride + x]+= color;
+ i=0;
+ if(!vop_found){
+ for(i=0; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(state>>(32-22) == 0x20){
+ i++;
+ vop_found=1;
+ break;
+ }
}
}
-}
-/**
- * draws an arrow from (ex, ey) -> (sx, sy).
- * @param w width of the image
- * @param h height of the image
- * @param stride stride/linesize of the image
- * @param color color of the arrow
- */
-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= ex - sx;
- int dy= ey - sy;
-
- if(dx*dx + dy*dy > 3*3){
- int rx= dx + dy;
- int ry= -dx + dy;
- int length= ff_sqrt((rx*rx + ry*ry)<<8);
-
- //FIXME subpixel accuracy
- rx= ROUNDED_DIV(rx*3<<4, length);
- ry= ROUNDED_DIV(ry*3<<4, length);
-
- draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
- draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
+ if(vop_found){
+ for(; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(state>>(32-22) == 0x20){
+ pc->frame_start_found=0;
+ pc->state=-1;
+ return i-3;
+ }
+ }
}
- draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
+ pc->frame_start_found= vop_found;
+ pc->state= state;
+
+ return END_NOT_FOUND;
}
int ff_h263_decode_frame(AVCodecContext *avctx,
@@ -438,6 +407,8 @@ uint64_t time= rdtsc();
if(s->codec_id==CODEC_ID_MPEG4){
next= mpeg4_find_frame_end(s, buf, buf_size);
+ }else if(s->codec_id==CODEC_ID_H263){
+ next= h263_find_frame_end(s, buf, buf_size);
}else{
fprintf(stderr, "this codec doesnt support truncated bitstreams\n");
return -1;
@@ -700,39 +671,8 @@ retry:
MPV_frame_end(s);
- if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture_ptr){
- const int shift= 1 + s->quarter_sample;
- int mb_y;
- uint8_t *ptr= s->last_picture.data[0];
- s->low_delay=0; //needed to see the vectors without trashing the buffers
-
- for(mb_y=0; mb_y<s->mb_height; mb_y++){
- int mb_x;
- for(mb_x=0; mb_x<s->mb_width; mb_x++){
- const int mb_index= mb_x + mb_y*s->mb_stride;
- if(IS_8X8(s->current_picture.mb_type[mb_index])){
- int i;
- for(i=0; i<4; i++){
- int sx= mb_x*16 + 4 + 8*(i&1);
- int sy= mb_y*16 + 4 + 8*(i>>1);
- int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2);
- int mx= (s->motion_val[xy][0]>>shift) + sx;
- int my= (s->motion_val[xy][1]>>shift) + sy;
- draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
- }
- }else{
- int sx= mb_x*16 + 8;
- int sy= mb_y*16 + 8;
- int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2);
- int mx= (s->motion_val[xy][0]>>shift) + sx;
- int my= (s->motion_val[xy][1]>>shift) + sy;
- draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
- }
- s->mbskip_table[mb_index]=0;
- }
- }
- }
-
+assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
+assert(s->current_picture.pict_type == s->pict_type);
if(s->pict_type==B_TYPE || s->low_delay){
*pict= *(AVFrame*)&s->current_picture;
ff_print_debug_info(s, s->current_picture_ptr);
@@ -751,6 +691,7 @@ retry:
#ifdef PRINT_FRAME_TIME
printf("%Ld\n", rdtsc()-time);
#endif
+
return get_consumed_bytes(s, buf_size);
}
@@ -782,7 +723,7 @@ AVCodec h263_decoder = {
NULL,
ff_h263_decode_end,
ff_h263_decode_frame,
- CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
};
AVCodec msmpeg4v1_decoder = {
diff --git a/src/libffmpeg/libavcodec/h264.c b/src/libffmpeg/libavcodec/h264.c
index c52758ed9..0df229b53 100644
--- a/src/libffmpeg/libavcodec/h264.c
+++ b/src/libffmpeg/libavcodec/h264.c
@@ -197,7 +197,9 @@ typedef struct H264Context{
int halfpel_flag;
int thirdpel_flag;
-
+ int unknown_svq3_flag;
+ int next_slice_index;
+
SPS sps_buffer[MAX_SPS_COUNT];
SPS sps; ///< current sps
@@ -297,6 +299,14 @@ static VLC run7_vlc;
static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp);
static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
+static inline uint32_t pack16to32(int a, int b){
+#ifdef WORDS_BIGENDIAN
+ return (b&0xFFFF) + (a<<16);
+#else
+ return (a&0xFFFF) + (b<<16);
+#endif
+}
+
/**
* fill a rectangle.
* @param h height of the recatangle, should be a constant
@@ -319,6 +329,8 @@ static inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t v
*(uint16_t*)(p + 1*stride)=
*(uint16_t*)(p + 2*stride)=
*(uint16_t*)(p + 3*stride)= size==4 ? val : val*0x0101;
+ }else if(w==4 && h==1){
+ *(uint32_t*)(p + 0*stride)= size==4 ? val : val*0x01010101;
}else if(w==4 && h==2){
*(uint32_t*)(p + 0*stride)=
*(uint32_t*)(p + 1*stride)= size==4 ? val : val*0x01010101;
@@ -1474,7 +1486,7 @@ static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){
src[2+0*stride]=
src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
-};
+}
static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){
LOAD_TOP_EDGE
@@ -1497,7 +1509,7 @@ static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){
src[3+2*stride]=
src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2;
src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
-};
+}
static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride){
const int lt= src[-1-1*stride];
@@ -1521,7 +1533,7 @@ static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride
src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2;
src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
-};
+}
static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride){
LOAD_TOP_EDGE
@@ -1544,7 +1556,7 @@ static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride)
src[3+1*stride]=
src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
-};
+}
static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride){
LOAD_LEFT_EDGE
@@ -1565,7 +1577,7 @@ static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride)
src[2+2*stride]=
src[2+3*stride]=
src[3+3*stride]=l3;
-};
+}
static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int stride){
const int lt= src[-1-1*stride];
@@ -1589,7 +1601,7 @@ static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int strid
src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
src[0+3*stride]=(l2 + l3 + 1)>>1;
src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
-};
+}
static void pred16x16_vertical_c(uint8_t *src, int stride){
int i;
@@ -2278,13 +2290,19 @@ static void hl_decode_mb(H264Context *h){
if(!IS_INTRA4x4(mb_type)){
- for(i=0; i<16; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below
- uint8_t * const ptr= dest_y + h->block_offset[i];
- if(s->codec_id == CODEC_ID_H264)
+ if(s->codec_id == CODEC_ID_H264){
+ for(i=0; i<16; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below
+ uint8_t * const ptr= dest_y + h->block_offset[i];
h264_add_idct_c(ptr, h->mb + i*16, linesize);
- else
+ }
+ }
+ }else{
+ for(i=0; i<16; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below
+ uint8_t * const ptr= dest_y + h->block_offset[i];
svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0);
+ }
}
}
}
@@ -2292,22 +2310,31 @@ static void hl_decode_mb(H264Context *h){
if(!(s->flags&CODEC_FLAG_GRAY)){
chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp);
chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp);
- for(i=16; i<16+4; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
- uint8_t * const ptr= dest_cb + h->block_offset[i];
- if(s->codec_id == CODEC_ID_H264)
+ if(s->codec_id == CODEC_ID_H264){
+ for(i=16; i<16+4; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
+ uint8_t * const ptr= dest_cb + h->block_offset[i];
h264_add_idct_c(ptr, h->mb + i*16, uvlinesize);
- else
- svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2);
+ }
}
- }
- for(i=20; i<20+4; i++){
- if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
- uint8_t * const ptr= dest_cr + h->block_offset[i];
- if(s->codec_id == CODEC_ID_H264)
+ for(i=20; i<20+4; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
+ uint8_t * const ptr= dest_cr + h->block_offset[i];
h264_add_idct_c(ptr, h->mb + i*16, uvlinesize);
- else
+ }
+ }
+ }else{
+ for(i=16; i<16+4; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
+ uint8_t * const ptr= dest_cb + h->block_offset[i];
svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2);
+ }
+ }
+ for(i=20; i<20+4; i++){
+ if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
+ uint8_t * const ptr= dest_cr + h->block_offset[i];
+ svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2);
+ }
}
}
}
@@ -2546,7 +2573,7 @@ static Picture * remove_short(H264Context *h, int frame_num){
for(i=0; i<h->short_ref_count; i++){
Picture *pic= h->short_ref[i];
if(s->avctx->debug&FF_DEBUG_MMCO)
- printf("%d %d %X\n", i, pic->frame_num, (int)pic);
+ printf("%d %d %p\n", i, pic->frame_num, pic);
if(pic->frame_num == frame_num){
h->short_ref[i]= NULL;
memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i - 1)*sizeof(Picture*));
@@ -2998,7 +3025,7 @@ static int decode_slice_header(H264Context *h){
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
printf("mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n",
first_mb_in_slice,
- ff_get_pict_type_char(h->slice_type),
+ av_get_pict_type_char(h->slice_type),
pps_id, h->frame_num,
s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
h->ref_count[0], h->ref_count[1],
@@ -3182,7 +3209,7 @@ static int decode_mb(H264Context *h){
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
int mb_type, partition_count, cbp;
- memset(h->mb, 0, sizeof(int16_t)*24*16); //FIXME avoid if allready clear (move after skip handlong?
+ s->dsp.clear_blocks(h->mb); //FIXME avoid if allready clear (move after skip handlong?
tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
@@ -3209,7 +3236,7 @@ static int decode_mb(H264Context *h){
fill_caches(h, mb_type); //FIXME check what is needed and what not ...
pred_pskip_motion(h, &mx, &my);
fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
- fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, (mx&0xFFFF)+(my<<16), 4);
+ fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4);
write_back_motion(h, mb_type);
s->current_picture.mb_type[mb_xy]= mb_type; //FIXME SKIP type
@@ -3248,7 +3275,7 @@ static int decode_mb(H264Context *h){
assert(h->slice_type == I_TYPE);
decode_intra_mb:
if(mb_type > 25){
- fprintf(stderr, "mb_type %d in %c slice to large at %d %d\n", mb_type, ff_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
+ fprintf(stderr, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
return -1;
}
partition_count=0;
@@ -3439,7 +3466,7 @@ decode_intra_mb:
my += get_se_golomb(&s->gb);
tprintf("final mv:%d %d\n", mx, my);
- fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, (mx&0xFFFF) + (my<<16), 4);
+ fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
}
}
}
@@ -3462,7 +3489,7 @@ decode_intra_mb:
my += get_se_golomb(&s->gb);
tprintf("final mv:%d %d\n", mx, my);
- fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (mx&0xFFFF) + (my<<16), 4);
+ fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
}
}
}
@@ -3486,7 +3513,7 @@ decode_intra_mb:
my += get_se_golomb(&s->gb);
tprintf("final mv:%d %d\n", mx, my);
- fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (mx&0xFFFF) + (my<<16), 4);
+ fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}
}
}
@@ -3982,7 +4009,7 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
AVCodecContext * const avctx= s->avctx;
int buf_index=0;
int i;
-#if 0
+#if 0
for(i=0; i<32; i++){
printf("%X ", buf[i]);
}
diff --git a/src/libffmpeg/libavcodec/huffyuv.c b/src/libffmpeg/libavcodec/huffyuv.c
index 1ab31a933..26058b19e 100644
--- a/src/libffmpeg/libavcodec/huffyuv.c
+++ b/src/libffmpeg/libavcodec/huffyuv.c
@@ -117,24 +117,6 @@ static const unsigned char classic_add_chroma[256] = {
6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2,
};
-static inline void bswap_buf(uint32_t *dst, uint32_t *src, int w){
- int i;
-
- for(i=0; i+8<=w; i+=8){
- dst[i+0]= bswap_32(src[i+0]);
- dst[i+1]= bswap_32(src[i+1]);
- dst[i+2]= bswap_32(src[i+2]);
- dst[i+3]= bswap_32(src[i+3]);
- dst[i+4]= bswap_32(src[i+4]);
- dst[i+5]= bswap_32(src[i+5]);
- dst[i+6]= bswap_32(src[i+6]);
- dst[i+7]= bswap_32(src[i+7]);
- }
- for(;i<w; i++){
- dst[i+0]= bswap_32(src[i+0]);
- }
-}
-
static inline int add_left_prediction(uint8_t *dst, uint8_t *src, int w, int acc){
int i;
@@ -255,17 +237,15 @@ static int generate_bits_table(uint32_t *dst, uint8_t *len_table){
uint32_t bits=0;
for(len=32; len>0; len--){
- int bit= 1<<(32-len);
for(index=0; index<256; index++){
- if(len_table[index]==len){
- if(bits & (bit-1)){
- fprintf(stderr, "Error generating huffman table\n");
- return -1;
- }
- dst[index]= bits>>(32-len);
- bits+= bit;
- }
+ if(len_table[index]==len)
+ dst[index]= bits++;
}
+ if(bits & 1){
+ fprintf(stderr, "Error generating huffman table\n");
+ return -1;
+ }
+ bits >>= 1;
}
return 0;
}
@@ -749,7 +729,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
if (buf_size == 0)
return 0;
- bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4);
+ s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4);
init_get_bits(&s->gb, s->bitstream_buffer, buf_size*8);
@@ -1117,7 +1097,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
char *p= avctx->stats_out;
for(i=0; i<3; i++){
for(j=0; j<256; j++){
- sprintf(p, "%Ld ", s->stats[i][j]);
+ sprintf(p, "%llu ", s->stats[i][j]);
p+= strlen(p);
s->stats[i][j]= 0;
}
@@ -1126,7 +1106,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
}
}else{
flush_put_bits(&s->pb);
- bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
+ s->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
}
s->picture_number++;
@@ -1178,4 +1158,4 @@ AVCodec huffyuv_encoder = {
.options = huffyuv_options,
};
-#endif //CONFIG_ENCODERS \ No newline at end of file
+#endif //CONFIG_ENCODERS
diff --git a/src/libffmpeg/libavcodec/i386/dsputil_mmx.c b/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
index 74836387a..c22eebb07 100644
--- a/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/dsputil_mmx.c
@@ -1532,6 +1532,7 @@ static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *bloc
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
mm_flags = mm_support();
+printf (" hey! mmflags = %X\n", mm_flags);
if (avctx->dsp_mask) {
if (avctx->dsp_mask & FF_MM_FORCE)
@@ -1559,8 +1560,10 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
const int dct_algo = avctx->dct_algo;
const int idct_algo= avctx->idct_algo;
+#ifdef CONFIG_ENCODERS
if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)
c->fdct = ff_fdct_mmx;
+#endif //CONFIG_ENCODERS
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx;
diff --git a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c
index 8e452b499..d2f477b7b 100644
--- a/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/mpegvideo_mmx.c
@@ -26,7 +26,6 @@
extern uint8_t zigzag_direct_noperm[64];
extern uint16_t inv_zigzag_direct16[64];
-extern uint32_t inverse[256];
static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL;
static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
diff --git a/src/libffmpeg/libavcodec/imgconvert.c b/src/libffmpeg/libavcodec/imgconvert.c
index ca1aec6ad..6a36c8558 100644
--- a/src/libffmpeg/libavcodec/imgconvert.c
+++ b/src/libffmpeg/libavcodec/imgconvert.c
@@ -22,6 +22,11 @@
* Misc image convertion routines.
*/
+/* TODO:
+ * - write 'ffimg' program to test all the image related stuff
+ * - move all api to slice based system
+ * - integrate deinterlacing, postprocessing and scaling in the conversion process
+ */
#include "avcodec.h"
#include "dsputil.h"
@@ -34,16 +39,27 @@
#include "i386/mmx.h"
#endif
+#define xglue(x, y) x ## y
+#define glue(x, y) xglue(x, y)
+
+#define FF_COLOR_RGB 0 /* RGB color space */
+#define FF_COLOR_GRAY 1 /* gray color space */
+#define FF_COLOR_YUV 2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
+#define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
+
+#define FF_PIXEL_PLANAR 0 /* each channel has one component in AVPicture */
+#define FF_PIXEL_PACKED 1 /* only one components containing all the channels */
+#define FF_PIXEL_PALETTE 2 /* one components containing indexes for a palette */
+
typedef struct PixFmtInfo {
const char *name;
- uint8_t nb_components; /* number of components in AVPicture array */
- uint8_t is_yuv : 1; /* true if YUV instead of RGB color space */
- uint8_t is_packed : 1; /* true if multiple components in same word */
- uint8_t is_paletted : 1; /* true if paletted */
+ 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 is_gray : 1; /* true if gray or monochrome format */
- 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 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 */
@@ -51,87 +67,153 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
/* YUV formats */
[PIX_FMT_YUV420P] = {
.name = "yuv420p",
- .nb_components = 3, .is_yuv = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
.x_chroma_shift = 1, .y_chroma_shift = 1,
},
[PIX_FMT_YUV422P] = {
.name = "yuv422p",
- .nb_components = 3, .is_yuv = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
.x_chroma_shift = 1, .y_chroma_shift = 0,
},
[PIX_FMT_YUV444P] = {
.name = "yuv444p",
- .nb_components = 3, .is_yuv = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
[PIX_FMT_YUV422] = {
.name = "yuv422",
- .nb_components = 1, .is_yuv = 1, .is_packed = 1,
+ .nb_channels = 1,
+ .color_type = FF_COLOR_YUV,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 8,
.x_chroma_shift = 1, .y_chroma_shift = 0,
},
[PIX_FMT_YUV410P] = {
.name = "yuv410p",
- .nb_components = 3, .is_yuv = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
.x_chroma_shift = 2, .y_chroma_shift = 2,
},
[PIX_FMT_YUV411P] = {
.name = "yuv411p",
- .nb_components = 3, .is_yuv = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
.x_chroma_shift = 2, .y_chroma_shift = 0,
},
+ /* JPEG YUV */
+ [PIX_FMT_YUVJ420P] = {
+ .name = "yuvj420p",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV_JPEG,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
+ .x_chroma_shift = 1, .y_chroma_shift = 1,
+ },
+ [PIX_FMT_YUVJ422P] = {
+ .name = "yuvj422p",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV_JPEG,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
+ .x_chroma_shift = 1, .y_chroma_shift = 0,
+ },
+ [PIX_FMT_YUVJ444P] = {
+ .name = "yuvj444p",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_YUV_JPEG,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
+ .x_chroma_shift = 0, .y_chroma_shift = 0,
+ },
+
/* RGB formats */
[PIX_FMT_RGB24] = {
.name = "rgb24",
- .nb_components = 1, .is_packed = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 8,
},
[PIX_FMT_BGR24] = {
.name = "bgr24",
- .nb_components = 1, .is_packed = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 8,
},
[PIX_FMT_RGBA32] = {
.name = "rgba32",
- .nb_components = 1, .is_packed = 1, .is_alpha = 1,
+ .nb_channels = 4, .is_alpha = 1,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 8,
},
[PIX_FMT_RGB565] = {
.name = "rgb565",
- .nb_components = 1, .is_packed = 1,
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 5,
},
[PIX_FMT_RGB555] = {
.name = "rgb555",
- .nb_components = 1, .is_packed = 1, .is_alpha = 1,
+ .nb_channels = 4, .is_alpha = 1,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 5,
},
/* gray / mono formats */
[PIX_FMT_GRAY8] = {
.name = "gray",
- .nb_components = 1, .is_gray = 1,
+ .nb_channels = 1,
+ .color_type = FF_COLOR_GRAY,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 8,
},
[PIX_FMT_MONOWHITE] = {
.name = "monow",
- .nb_components = 1, .is_packed = 1, .is_gray = 1,
+ .nb_channels = 1,
+ .color_type = FF_COLOR_GRAY,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 1,
},
[PIX_FMT_MONOBLACK] = {
.name = "monob",
- .nb_components = 1, .is_packed = 1, .is_gray = 1,
+ .nb_channels = 1,
+ .color_type = FF_COLOR_GRAY,
+ .pixel_type = FF_PIXEL_PLANAR,
+ .depth = 1,
},
/* paletted formats */
[PIX_FMT_PAL8] = {
.name = "pal8",
- .nb_components = 1, .is_packed = 1, .is_paletted = 1,
+ .nb_channels = 4, .is_alpha = 1,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PALETTE,
+ .depth = 8,
},
};
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift)
{
- if (pix_fmt_info[pix_fmt].is_yuv) {
- *h_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
- *v_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
- } else {
- *h_shift=0;
- *v_shift=0;
- }
+ *h_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
+ *v_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
}
const char *avcodec_get_pix_fmt_name(int pix_fmt)
@@ -142,6 +224,16 @@ const char *avcodec_get_pix_fmt_name(int pix_fmt)
return pix_fmt_info[pix_fmt].name;
}
+enum PixelFormat avcodec_get_pix_fmt(const char* name)
+{
+ int i;
+
+ for (i=0; i < PIX_FMT_NB; i++)
+ if (!strcmp(pix_fmt_info[i].name, name))
+ break;
+ return i;
+}
+
/* Picture field are filled with 'ptr' addresses. Also return size */
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
int pix_fmt, int width, int height)
@@ -157,6 +249,9 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
case PIX_FMT_YUV444P:
case PIX_FMT_YUV410P:
case PIX_FMT_YUV411P:
+ case PIX_FMT_YUVJ420P:
+ case PIX_FMT_YUVJ422P:
+ case PIX_FMT_YUVJ444P:
w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
size2 = w2 * h2;
@@ -218,28 +313,298 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
}
}
+int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
+ unsigned char *dest, int dest_size)
+{
+ PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
+ int i, j, w, h, data_planes;
+ unsigned char* s;
+ int size = avpicture_get_size(pix_fmt, width, height);
+
+ if (size > dest_size)
+ return -1;
+
+ if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
+ if (pix_fmt == PIX_FMT_YUV422 || pix_fmt == PIX_FMT_RGB565 ||
+ pix_fmt == PIX_FMT_RGB555)
+ w = width * 2;
+ else if (pix_fmt == PIX_FMT_PAL8)
+ w = width;
+ else
+ w = width * (pf->depth * pf->nb_channels / 8);
+
+ data_planes = 1;
+ h = height;
+ } else {
+ data_planes = pf->nb_channels;
+ w = width;
+ h = height;
+ }
+
+ for (i=0; i<data_planes; i++) {
+ if (i == 1) {
+ w = width >> pf->x_chroma_shift;
+ h = height >> pf->y_chroma_shift;
+ }
+ s = src->data[i];
+ for(j=0; j<h; j++) {
+ memcpy(dest, s, w);
+ dest += w;
+ s += src->linesize[i];
+ }
+ }
+
+ if (pf->pixel_type == FF_PIXEL_PALETTE)
+ memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);
+
+ return size;
+}
+
int avpicture_get_size(int pix_fmt, int width, int height)
{
AVPicture dummy_pict;
return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
}
+/**
+ * compute the loss when converting from a pixel format to another
+ */
+int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
+ int has_alpha)
+{
+ const PixFmtInfo *pf, *ps;
+ int loss;
+
+ ps = &pix_fmt_info[src_pix_fmt];
+ pf = &pix_fmt_info[dst_pix_fmt];
+
+ /* compute loss */
+ loss = 0;
+ pf = &pix_fmt_info[dst_pix_fmt];
+ if (pf->depth < ps->depth ||
+ (dst_pix_fmt == PIX_FMT_RGB555 && src_pix_fmt == PIX_FMT_RGB565))
+ loss |= FF_LOSS_DEPTH;
+ if (pf->x_chroma_shift > ps->x_chroma_shift ||
+ pf->y_chroma_shift > ps->y_chroma_shift)
+ loss |= FF_LOSS_RESOLUTION;
+ switch(pf->color_type) {
+ case FF_COLOR_RGB:
+ if (ps->color_type != FF_COLOR_RGB &&
+ ps->color_type != FF_COLOR_GRAY)
+ loss |= FF_LOSS_COLORSPACE;
+ break;
+ case FF_COLOR_GRAY:
+ if (ps->color_type != FF_COLOR_GRAY)
+ loss |= FF_LOSS_COLORSPACE;
+ break;
+ case FF_COLOR_YUV:
+ if (ps->color_type != FF_COLOR_YUV)
+ loss |= FF_LOSS_COLORSPACE;
+ break;
+ case FF_COLOR_YUV_JPEG:
+ if (ps->color_type != FF_COLOR_YUV_JPEG &&
+ ps->color_type != FF_COLOR_YUV &&
+ ps->color_type != FF_COLOR_GRAY)
+ loss |= FF_LOSS_COLORSPACE;
+ break;
+ default:
+ /* fail safe test */
+ if (ps->color_type != pf->color_type)
+ loss |= FF_LOSS_COLORSPACE;
+ break;
+ }
+ if (pf->color_type == FF_COLOR_GRAY &&
+ ps->color_type != FF_COLOR_GRAY)
+ loss |= FF_LOSS_CHROMA;
+ if (!pf->is_alpha && (ps->is_alpha && has_alpha))
+ loss |= FF_LOSS_ALPHA;
+ if (pf->pixel_type == FF_PIXEL_PALETTE &&
+ (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))
+ loss |= FF_LOSS_COLORQUANT;
+ return loss;
+}
+
+static int avg_bits_per_pixel(int pix_fmt)
+{
+ int bits;
+ const PixFmtInfo *pf;
+
+ pf = &pix_fmt_info[pix_fmt];
+ switch(pf->pixel_type) {
+ case FF_PIXEL_PACKED:
+ switch(pix_fmt) {
+ case PIX_FMT_YUV422:
+ case PIX_FMT_RGB565:
+ case PIX_FMT_RGB555:
+ bits = 16;
+ break;
+ default:
+ bits = pf->depth * pf->nb_channels;
+ break;
+ }
+ break;
+ case FF_PIXEL_PLANAR:
+ if (pf->x_chroma_shift == 0 && pf->y_chroma_shift == 0) {
+ bits = pf->depth * pf->nb_channels;
+ } else {
+ bits = pf->depth + ((2 * pf->depth) >>
+ (pf->x_chroma_shift + pf->y_chroma_shift));
+ }
+ break;
+ case FF_PIXEL_PALETTE:
+ bits = 8;
+ break;
+ default:
+ bits = -1;
+ break;
+ }
+ return bits;
+}
+
+static int avcodec_find_best_pix_fmt1(int pix_fmt_mask,
+ int src_pix_fmt,
+ int has_alpha,
+ int loss_mask)
+{
+ int dist, i, loss, min_dist, dst_pix_fmt;
+
+ /* find exact color match with smallest size */
+ dst_pix_fmt = -1;
+ min_dist = 0x7fffffff;
+ for(i = 0;i < PIX_FMT_NB; i++) {
+ if (pix_fmt_mask & (1 << i)) {
+ loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
+ if (loss == 0) {
+ dist = avg_bits_per_pixel(i);
+ if (dist < min_dist) {
+ min_dist = dist;
+ dst_pix_fmt = i;
+ }
+ }
+ }
+ }
+ return dst_pix_fmt;
+}
+
+/**
+ * find best pixel format to convert to. Return -1 if none found
+ */
+int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
+ int has_alpha, int *loss_ptr)
+{
+ int dst_pix_fmt, loss_mask, i;
+ static const int loss_mask_order[] = {
+ ~0, /* no loss first */
+ ~FF_LOSS_ALPHA,
+ ~FF_LOSS_RESOLUTION,
+ ~(FF_LOSS_COLORSPACE | FF_LOSS_RESOLUTION),
+ ~FF_LOSS_COLORQUANT,
+ ~FF_LOSS_DEPTH,
+ 0,
+ };
+
+ /* try with successive loss */
+ i = 0;
+ for(;;) {
+ loss_mask = loss_mask_order[i++];
+ dst_pix_fmt = avcodec_find_best_pix_fmt1(pix_fmt_mask, src_pix_fmt,
+ has_alpha, loss_mask);
+ if (dst_pix_fmt >= 0)
+ goto found;
+ if (loss_mask == 0)
+ break;
+ }
+ return -1;
+ found:
+ if (loss_ptr)
+ *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
+ return dst_pix_fmt;
+}
+
+static void img_copy_plane(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ for(;height > 0; height--) {
+ memcpy(dst, src, width);
+ dst += dst_wrap;
+ src += src_wrap;
+ }
+}
+
+/**
+ * Copy image 'src' to 'dst'.
+ */
+void img_copy(AVPicture *dst, AVPicture *src,
+ int pix_fmt, int width, int height)
+{
+ int bwidth, bits, i;
+ PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
+
+ pf = &pix_fmt_info[pix_fmt];
+ switch(pf->pixel_type) {
+ case FF_PIXEL_PACKED:
+ switch(pix_fmt) {
+ case PIX_FMT_YUV422:
+ case PIX_FMT_RGB565:
+ case PIX_FMT_RGB555:
+ bits = 16;
+ break;
+ default:
+ bits = pf->depth * pf->nb_channels;
+ break;
+ }
+ bwidth = (width * bits + 7) >> 3;
+ img_copy_plane(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ bwidth, height);
+ break;
+ case FF_PIXEL_PLANAR:
+ for(i = 0; i < pf->nb_channels; i++) {
+ int w, h;
+ w = width;
+ h = height;
+ if (i == 1 || i == 2) {
+ w >>= pf->x_chroma_shift;
+ h >>= pf->y_chroma_shift;
+ }
+ bwidth = (w * pf->depth + 7) >> 3;
+ img_copy_plane(dst->data[i], dst->linesize[i],
+ src->data[i], src->linesize[i],
+ bwidth, h);
+ }
+ break;
+ case FF_PIXEL_PALETTE:
+ img_copy_plane(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ width, height);
+ /* copy the palette */
+ img_copy_plane(dst->data[1], dst->linesize[1],
+ src->data[1], src->linesize[1],
+ 4, 256);
+ break;
+ }
+}
/* XXX: totally non optimized */
static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
int width, int height)
{
- uint8_t *lum, *cb, *cr;
- int x, y;
- const uint8_t *p;
+ const uint8_t *p, *p1;
+ uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
+ int x;
- lum = dst->data[0];
- cb = dst->data[1];
- cr = dst->data[2];
- p = src->data[0];
-
- for(y=0;y<height;y+=2) {
+ p1 = src->data[0];
+ lum1 = dst->data[0];
+ cb1 = dst->data[1];
+ cr1 = dst->data[2];
+
+ for(;height >= 2; height -= 2) {
+ p = p1;
+ lum = lum1;
+ cb = cb1;
+ cr = cr1;
for(x=0;x<width;x+=2) {
lum[0] = p[0];
cb[0] = p[1];
@@ -250,27 +615,279 @@ static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
cb++;
cr++;
}
+ p1 += src->linesize[0];
+ lum1 += dst->linesize[0];
+ p = p1;
+ lum = lum1;
for(x=0;x<width;x+=2) {
lum[0] = p[0];
lum[1] = p[2];
p += 4;
lum += 2;
}
+ p1 += src->linesize[0];
+ lum1 += dst->linesize[0];
+ cb1 += dst->linesize[1];
+ cr1 += dst->linesize[2];
+ }
+}
+
+static void yuv422_to_yuv422p(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const uint8_t *p, *p1;
+ uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
+ int w;
+
+ p1 = src->data[0];
+ lum1 = dst->data[0];
+ cb1 = dst->data[1];
+ cr1 = dst->data[2];
+ for(;height > 0; height--) {
+ p = p1;
+ lum = lum1;
+ cb = cb1;
+ cr = cr1;
+ for(w = width; w >= 2; w -= 2) {
+ lum[0] = p[0];
+ cb[0] = p[1];
+ lum[1] = p[2];
+ cr[0] = p[3];
+ p += 4;
+ lum += 2;
+ cb++;
+ cr++;
+ }
+ p1 += src->linesize[0];
+ lum1 += dst->linesize[0];
+ cb1 += dst->linesize[1];
+ cr1 += dst->linesize[2];
}
}
-#define SCALEBITS 8
+static void yuv422p_to_yuv422(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ uint8_t *p, *p1;
+ const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
+ int w;
+
+ p1 = dst->data[0];
+ lum1 = src->data[0];
+ cb1 = src->data[1];
+ cr1 = src->data[2];
+ for(;height > 0; height--) {
+ p = p1;
+ lum = lum1;
+ cb = cb1;
+ cr = cr1;
+ for(w = width; w >= 2; w -= 2) {
+ p[0] = lum[0];
+ p[1] = cb[0];
+ p[2] = lum[1];
+ p[3] = cr[0];
+ p += 4;
+ lum += 2;
+ cb++;
+ cr++;
+ }
+ p1 += dst->linesize[0];
+ lum1 += src->linesize[0];
+ cb1 += src->linesize[1];
+ cr1 += src->linesize[2];
+ }
+}
+
+#define SCALEBITS 10
#define ONE_HALF (1 << (SCALEBITS - 1))
-#define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5))
+#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
+
+#define YUV_TO_RGB1_CCIR(cb1, cr1)\
+{\
+ cb = (cb1) - 128;\
+ cr = (cr1) - 128;\
+ r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
+ g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
+ ONE_HALF;\
+ b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
+}
+
+#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
+{\
+ y = ((y1) - 16) * FIX(255.0/219.0);\
+ r = cm[(y + r_add) >> SCALEBITS];\
+ g = cm[(y + g_add) >> SCALEBITS];\
+ b = cm[(y + b_add) >> SCALEBITS];\
+}
+
+#define YUV_TO_RGB1(cb1, cr1)\
+{\
+ cb = (cb1) - 128;\
+ cr = (cr1) - 128;\
+ r_add = FIX(1.40200) * cr + ONE_HALF;\
+ g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\
+ b_add = FIX(1.77200) * cb + ONE_HALF;\
+}
+
+#define YUV_TO_RGB2(r, g, b, y1)\
+{\
+ y = (y1) << SCALEBITS;\
+ r = cm[(y + r_add) >> SCALEBITS];\
+ g = cm[(y + g_add) >> SCALEBITS];\
+ b = cm[(y + b_add) >> SCALEBITS];\
+}
+
+#define Y_CCIR_TO_JPEG(y)\
+ cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]
+
+#define Y_JPEG_TO_CCIR(y)\
+ (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
+
+#define C_CCIR_TO_JPEG(y)\
+ cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]
+
+/* NOTE: the clamp is really necessary! */
+static inline int C_JPEG_TO_CCIR(int y) {
+ y = (((y - 128) * FIX(112.0/127.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS);
+ if (y < 16)
+ y = 16;
+ return y;
+}
+
+
+#define RGB_TO_Y(r, g, b) \
+((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
+ FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
+
+#define RGB_TO_U(r1, g1, b1, shift)\
+(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
+ FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_V(r1, g1, b1, shift)\
+(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
+ FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_Y_CCIR(r, g, b) \
+((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
+ FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
+
+#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
+(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
+ FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
+(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
+ FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+static uint8_t y_ccir_to_jpeg[256];
+static uint8_t y_jpeg_to_ccir[256];
+static uint8_t c_ccir_to_jpeg[256];
+static uint8_t c_jpeg_to_ccir[256];
+
+/* init various conversion tables */
+static void img_convert_init(void)
+{
+ int i;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
+
+ for(i = 0;i < 256; i++) {
+ y_ccir_to_jpeg[i] = Y_CCIR_TO_JPEG(i);
+ y_jpeg_to_ccir[i] = Y_JPEG_TO_CCIR(i);
+ c_ccir_to_jpeg[i] = C_CCIR_TO_JPEG(i);
+ c_jpeg_to_ccir[i] = C_JPEG_TO_CCIR(i);
+ }
+}
+
+/* apply to each pixel the given table */
+static void img_apply_table(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height, const uint8_t *table1)
+{
+ int n;
+ const uint8_t *s;
+ uint8_t *d;
+ const uint8_t *table;
+
+ table = table1;
+ for(;height > 0; height--) {
+ s = src;
+ d = dst;
+ n = width;
+ while (n >= 4) {
+ d[0] = table[s[0]];
+ d[1] = table[s[1]];
+ d[2] = table[s[2]];
+ d[3] = table[s[3]];
+ d += 4;
+ s += 4;
+ n -= 4;
+ }
+ while (n > 0) {
+ d[0] = table[s[0]];
+ d++;
+ s++;
+ n--;
+ }
+ dst += dst_wrap;
+ src += src_wrap;
+ }
+}
/* XXX: use generic filter ? */
+/* XXX: in most cases, the sampling position is incorrect */
+
+/* 4x1 -> 1x1 */
+static void shrink41(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ int w;
+ const uint8_t *s;
+ uint8_t *d;
+
+ for(;height > 0; height--) {
+ s = src;
+ d = dst;
+ for(w = width;w > 0; w--) {
+ d[0] = (s[0] + s[1] + s[2] + s[3] + 2) >> 2;
+ s += 4;
+ d++;
+ }
+ src += src_wrap;
+ dst += dst_wrap;
+ }
+}
+
+/* 2x1 -> 1x1 */
+static void shrink21(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ int w;
+ const uint8_t *s;
+ uint8_t *d;
+
+ for(;height > 0; height--) {
+ s = src;
+ d = dst;
+ for(w = width;w > 0; w--) {
+ d[0] = (s[0] + s[1]) >> 1;
+ s += 2;
+ d++;
+ }
+ src += src_wrap;
+ dst += dst_wrap;
+ }
+}
+
/* 1x2 -> 1x1 */
-static void shrink2(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
- int width, int height)
+static void shrink12(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
{
int w;
- uint8_t *s1, *s2, *d;
+ uint8_t *d;
+ const uint8_t *s1, *s2;
for(;height > 0; height--) {
s1 = src;
@@ -298,27 +915,28 @@ static void shrink2(uint8_t *dst, int dst_wrap,
/* 2x2 -> 1x1 */
static void shrink22(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
+ const uint8_t *src, int src_wrap,
int width, int height)
{
int w;
- uint8_t *s1, *s2, *d;
+ const uint8_t *s1, *s2;
+ uint8_t *d;
for(;height > 0; height--) {
s1 = src;
s2 = s1 + src_wrap;
d = dst;
for(w = width;w >= 4; w-=4) {
- d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1;
- d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 1;
- d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 1;
- d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 1;
+ d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
+ d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
+ d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
+ d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
s1 += 8;
s2 += 8;
d += 4;
}
for(;w > 0; w--) {
- d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1;
+ d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
s1 += 2;
s2 += 2;
d++;
@@ -328,41 +946,142 @@ static void shrink22(uint8_t *dst, int dst_wrap,
}
}
-/* 1x1 -> 2x2 */
-static void grow22(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
+/* 4x4 -> 1x1 */
+static void shrink44(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
int width, int height)
{
int w;
- uint8_t *s1, *d;
+ const uint8_t *s1, *s2, *s3, *s4;
+ uint8_t *d;
for(;height > 0; height--) {
s1 = src;
+ s2 = s1 + src_wrap;
+ s3 = s2 + src_wrap;
+ s4 = s3 + src_wrap;
d = dst;
- for(w = width;w >= 4; w-=4) {
- d[1] = d[0] = s1[0];
- d[3] = d[2] = s1[1];
- s1 += 2;
- d += 4;
- }
- for(;w > 0; w--) {
- d[0] = s1[0];
- s1 ++;
+ for(w = width;w > 0; w--) {
+ d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
+ s2[0] + s2[1] + s2[2] + s2[3] +
+ s3[0] + s3[1] + s3[2] + s3[3] +
+ s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
+ s1 += 4;
+ s2 += 4;
+ s3 += 4;
+ s4 += 4;
d++;
}
+ src += 4 * src_wrap;
+ dst += dst_wrap;
+ }
+}
+
+static void grow21_line(uint8_t *dst, const uint8_t *src,
+ int width)
+{
+ int w;
+ const uint8_t *s1;
+ uint8_t *d;
+
+ s1 = src;
+ d = dst;
+ for(w = width;w >= 4; w-=4) {
+ d[1] = d[0] = s1[0];
+ d[3] = d[2] = s1[1];
+ s1 += 2;
+ d += 4;
+ }
+ for(;w >= 2; w -= 2) {
+ d[1] = d[0] = s1[0];
+ s1 ++;
+ d += 2;
+ }
+ /* only needed if width is not a multiple of two */
+ /* XXX: veryfy that */
+ if (w) {
+ d[0] = s1[0];
+ }
+}
+
+static void grow41_line(uint8_t *dst, const uint8_t *src,
+ int width)
+{
+ int w, v;
+ const uint8_t *s1;
+ uint8_t *d;
+
+ s1 = src;
+ d = dst;
+ for(w = width;w >= 4; w-=4) {
+ v = s1[0];
+ d[0] = v;
+ d[1] = v;
+ d[2] = v;
+ d[3] = v;
+ s1 ++;
+ d += 4;
+ }
+}
+
+/* 1x1 -> 2x1 */
+static void grow21(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ for(;height > 0; height--) {
+ grow21_line(dst, src, width);
+ src += src_wrap;
+ dst += dst_wrap;
+ }
+}
+
+/* 1x1 -> 2x2 */
+static void grow22(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ for(;height > 0; height--) {
+ grow21_line(dst, src, width);
if (height%2)
src += src_wrap;
dst += dst_wrap;
}
}
+/* 1x1 -> 4x1 */
+static void grow41(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ for(;height > 0; height--) {
+ grow41_line(dst, src, width);
+ src += src_wrap;
+ dst += dst_wrap;
+ }
+}
+
+/* 1x1 -> 4x4 */
+static void grow44(uint8_t *dst, int dst_wrap,
+ const uint8_t *src, int src_wrap,
+ int width, int height)
+{
+ for(;height > 0; height--) {
+ grow41_line(dst, src, width);
+ if ((height & 3) == 1)
+ src += src_wrap;
+ dst += dst_wrap;
+ }
+}
+
/* 1x2 -> 2x1 */
static void conv411(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
+ const uint8_t *src, int src_wrap,
int width, int height)
{
int w, c;
- uint8_t *s1, *s2, *d;
+ const uint8_t *s1, *s2;
+ uint8_t *d;
width>>=1;
@@ -383,357 +1102,36 @@ static void conv411(uint8_t *dst, int dst_wrap,
}
}
-static void img_copy(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
- int width, int height)
+/* XXX: add jpeg quantize code */
+
+#define TRANSP_INDEX (6*6*6)
+
+/* this is maybe slow, but allows for extensions */
+static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
{
- for(;height > 0; height--) {
- memcpy(dst, src, width);
- dst += dst_wrap;
- src += src_wrap;
- }
+ return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6));
}
-#define SCALE_BITS 10
-
-#define C_Y (76309 >> (16 - SCALE_BITS))
-#define C_RV (117504 >> (16 - SCALE_BITS))
-#define C_BU (138453 >> (16 - SCALE_BITS))
-#define C_GU (13954 >> (16 - SCALE_BITS))
-#define C_GV (34903 >> (16 - SCALE_BITS))
+static void build_rgb_palette(uint8_t *palette, int has_alpha)
+{
+ uint32_t *pal;
+ static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
+ int i, r, g, b;
-#define YUV_TO_RGB2(r, g, b, y1)\
-{\
- y = (y1 - 16) * C_Y;\
- r = cm[(y + r_add) >> SCALE_BITS];\
- g = cm[(y + g_add) >> SCALE_BITS];\
- b = cm[(y + b_add) >> SCALE_BITS];\
-}
-
-/* XXX: no chroma interpolating is done */
-#define RGB_FUNCTIONS(rgb_name) \
- \
-static void yuv420p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
- int width, int height) \
-{ \
- uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; \
- int w, y, cb, cr, r_add, g_add, b_add, width2; \
- uint8_t *cm = cropTbl + MAX_NEG_CROP; \
- unsigned int r, g, b; \
- \
- d = dst->data[0]; \
- y1_ptr = src->data[0]; \
- cb_ptr = src->data[1]; \
- cr_ptr = src->data[2]; \
- width2 = (width + 1) >> 1; \
- for(;height >= 2; height -= 2) { \
- d1 = d; \
- d2 = d + dst->linesize[0]; \
- y2_ptr = y1_ptr + src->linesize[0]; \
- for(w = width; w >= 2; w -= 2) { \
- cb = cb_ptr[0] - 128; \
- cr = cr_ptr[0] - 128; \
- r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
- g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
- b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
- \
- /* output 4 pixels */ \
- YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d1, r, g, b); \
- \
- YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
- RGB_OUT(d1 + BPP, r, g, b); \
- \
- YUV_TO_RGB2(r, g, b, y2_ptr[0]); \
- RGB_OUT(d2, r, g, b); \
- \
- YUV_TO_RGB2(r, g, b, y2_ptr[1]); \
- RGB_OUT(d2 + BPP, r, g, b); \
- \
- d1 += 2 * BPP; \
- d2 += 2 * BPP; \
- \
- y1_ptr += 2; \
- y2_ptr += 2; \
- cb_ptr++; \
- cr_ptr++; \
- } \
- /* handle odd width */ \
- if (w) { \
- cb = cb_ptr[0] - 128; \
- cr = cr_ptr[0] - 128; \
- r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
- g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
- b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
- \
- YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d1, r, g, b); \
- \
- YUV_TO_RGB2(r, g, b, y2_ptr[0]); \
- RGB_OUT(d2, r, g, b); \
- d1 += BPP; \
- d2 += BPP; \
- y1_ptr++; \
- y2_ptr++; \
- cb_ptr++; \
- cr_ptr++; \
- } \
- d += 2 * dst->linesize[0]; \
- y1_ptr += 2 * src->linesize[0] - width; \
- cb_ptr += src->linesize[1] - width2; \
- cr_ptr += src->linesize[2] - width2; \
- } \
- /* handle odd height */ \
- if (height) { \
- d1 = d; \
- for(w = width; w >= 2; w -= 2) { \
- cb = cb_ptr[0] - 128; \
- cr = cr_ptr[0] - 128; \
- r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
- g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
- b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
- \
- /* output 2 pixels */ \
- YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d1, r, g, b); \
- \
- YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
- RGB_OUT(d1 + BPP, r, g, b); \
- \
- d1 += 2 * BPP; \
- \
- y1_ptr += 2; \
- cb_ptr++; \
- cr_ptr++; \
- } \
- /* handle width */ \
- if (w) { \
- cb = cb_ptr[0] - 128; \
- cr = cr_ptr[0] - 128; \
- r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
- g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
- b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
- \
- /* output 2 pixels */ \
- YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d1, r, g, b); \
- d1 += BPP; \
- \
- y1_ptr++; \
- cb_ptr++; \
- cr_ptr++; \
- } \
- } \
-} \
- \
-/* XXX: no chroma interpolating is done */ \
-static void yuv422p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
- int width, int height) \
-{ \
- uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; \
- int w, y, cb, cr, r_add, g_add, b_add, width2; \
- uint8_t *cm = cropTbl + MAX_NEG_CROP; \
- unsigned int r, g, b; \
- \
- d = dst->data[0]; \
- y1_ptr = src->data[0]; \
- cb_ptr = src->data[1]; \
- cr_ptr = src->data[2]; \
- width2 = (width + 1) >> 1; \
- for(;height > 0; height --) { \
- d1 = d; \
- for(w = width; w >= 2; w -= 2) { \
- cb = cb_ptr[0] - 128; \
- cr = cr_ptr[0] - 128; \
- r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
- g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
- b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
- \
- /* output 2 pixels */ \
- YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d1, r, g, b); \
- \
- YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
- RGB_OUT(d1 + BPP, r, g, b); \
- \
- d1 += 2 * BPP; \
- \
- y1_ptr += 2; \
- cb_ptr++; \
- cr_ptr++; \
- } \
- /* handle width */ \
- if (w) { \
- cb = cb_ptr[0] - 128; \
- cr = cr_ptr[0] - 128; \
- r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
- g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
- b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
- \
- /* output 2 pixels */ \
- YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
- RGB_OUT(d1, r, g, b); \
- d1 += BPP; \
- \
- y1_ptr++; \
- cb_ptr++; \
- cr_ptr++; \
- } \
- d += dst->linesize[0]; \
- y1_ptr += src->linesize[0] - width; \
- cb_ptr += src->linesize[1] - width2; \
- cr_ptr += src->linesize[2] - width2; \
- } \
-} \
- \
-static void rgb_name ## _to_yuv420p(AVPicture *dst, AVPicture *src, \
- int width, int height) \
-{ \
- int wrap, wrap3, x, y; \
- int r, g, b, r1, g1, b1; \
- uint8_t *lum, *cb, *cr; \
- const uint8_t *p; \
- \
- lum = dst->data[0]; \
- cb = dst->data[1]; \
- cr = dst->data[2]; \
- \
- wrap = dst->linesize[0]; \
- wrap3 = src->linesize[0]; \
- p = src->data[0]; \
- for(y=0;y<height;y+=2) { \
- for(x=0;x<width;x+=2) { \
- RGB_IN(r, g, b, p); \
- r1 = r; \
- g1 = g; \
- b1 = b; \
- lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \
- FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
- RGB_IN(r, g, b, p + BPP); \
- r1 += r; \
- g1 += g; \
- b1 += b; \
- lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + \
- FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
- p += wrap3; \
- lum += wrap; \
- \
- RGB_IN(r, g, b, p); \
- r1 += r; \
- g1 += g; \
- b1 += b; \
- lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \
- FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
- \
- RGB_IN(r, g, b, p + BPP); \
- r1 += r; \
- g1 += g; \
- b1 += b; \
- lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + \
- FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
- \
- cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
- FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> \
- (SCALEBITS + 2)) + 128; \
- cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
- FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> \
- (SCALEBITS + 2)) + 128; \
- \
- cb++; \
- cr++; \
- p += -wrap3 + 2 * BPP; \
- lum += -wrap + 2; \
- } \
- p += wrap3 + (wrap3 - width * BPP); \
- lum += wrap + (wrap - width); \
- cb += dst->linesize[1] - width / 2; \
- cr += dst->linesize[2] - width / 2; \
- } \
-} \
- \
-static void rgb_name ## _to_gray(AVPicture *dst, AVPicture *src, \
- int width, int height) \
-{ \
- const unsigned char *p; \
- unsigned char *q; \
- int r, g, b, dst_wrap, src_wrap; \
- int x, y; \
- \
- p = src->data[0]; \
- src_wrap = src->linesize[0] - BPP * width; \
- \
- q = dst->data[0]; \
- dst_wrap = dst->linesize[0] - width; \
- \
- for(y=0;y<height;y++) { \
- for(x=0;x<width;x++) { \
- RGB_IN(r, g, b, p); \
- q[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \
- FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
- q++; \
- p += BPP; \
- } \
- p += src_wrap; \
- q += dst_wrap; \
- } \
-} \
- \
-static void gray_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
- int width, int height) \
-{ \
- const unsigned char *p; \
- unsigned char *q; \
- int r, dst_wrap, src_wrap; \
- int x, y; \
- \
- p = src->data[0]; \
- src_wrap = src->linesize[0] - width; \
- \
- q = dst->data[0]; \
- dst_wrap = dst->linesize[0] - BPP * width; \
- \
- for(y=0;y<height;y++) { \
- for(x=0;x<width;x++) { \
- r = p[0]; \
- RGB_OUT(q, r, r, r); \
- q += BPP; \
- p ++; \
- } \
- p += src_wrap; \
- q += dst_wrap; \
- } \
-} \
- \
-static void pal8_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
- int width, int height) \
-{ \
- const unsigned char *p; \
- unsigned char *q; \
- int r, g, b, dst_wrap, src_wrap; \
- int x, y; \
- uint32_t v;\
- const uint32_t *palette;\
-\
- p = src->data[0]; \
- src_wrap = src->linesize[0] - width; \
- palette = (uint32_t *)src->data[1];\
- \
- q = dst->data[0]; \
- dst_wrap = dst->linesize[0] - BPP * width; \
- \
- for(y=0;y<height;y++) { \
- for(x=0;x<width;x++) { \
- v = palette[p[0]];\
- r = (v >> 16) & 0xff;\
- g = (v >> 8) & 0xff;\
- b = (v) & 0xff;\
- RGB_OUT(q, r, g, b); \
- q += BPP; \
- p ++; \
- } \
- p += src_wrap; \
- q += dst_wrap; \
- } \
+ pal = (uint32_t *)palette;
+ i = 0;
+ for(r = 0; r < 6; r++) {
+ for(g = 0; g < 6; g++) {
+ for(b = 0; b < 6; b++) {
+ pal[i++] = (0xff << 24) | (pal_value[r] << 16) |
+ (pal_value[g] << 8) | pal_value[b];
+ }
+ }
+ }
+ if (has_alpha)
+ pal[i++] = 0;
+ while (i < 256)
+ pal[i++] = 0xff000000;
}
/* copy bit n to bits 0 ... n - 1 */
@@ -746,6 +1144,8 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
/* rgb555 handling */
+#define RGB_NAME rgb555
+
#define RGB_IN(r, g, b, s)\
{\
unsigned int v = ((const uint16_t *)(s))[0];\
@@ -754,21 +1154,29 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
b = bitcopy_n(v << 3, 3);\
}
-#define RGB_OUT(d, r, g, b)\
+#define RGBA_IN(r, g, b, a, s)\
+{\
+ unsigned int v = ((const uint16_t *)(s))[0];\
+ r = bitcopy_n(v >> (10 - 3), 3);\
+ g = bitcopy_n(v >> (5 - 3), 3);\
+ b = bitcopy_n(v << 3, 3);\
+ a = (-(v >> 15)) & 0xff;\
+}
+
+#define RGBA_OUT(d, r, g, b, a)\
{\
- ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;\
+ ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | \
+ ((a << 8) & 0x8000);\
}
#define BPP 2
-RGB_FUNCTIONS(rgb555)
-
-#undef RGB_IN
-#undef RGB_OUT
-#undef BPP
+#include "imgconvert_template.h"
/* rgb565 handling */
+#define RGB_NAME rgb565
+
#define RGB_IN(r, g, b, s)\
{\
unsigned int v = ((const uint16_t *)(s))[0];\
@@ -784,14 +1192,12 @@ RGB_FUNCTIONS(rgb555)
#define BPP 2
-RGB_FUNCTIONS(rgb565)
-
-#undef RGB_IN
-#undef RGB_OUT
-#undef BPP
+#include "imgconvert_template.h"
/* bgr24 handling */
+#define RGB_NAME bgr24
+
#define RGB_IN(r, g, b, s)\
{\
b = (s)[0];\
@@ -808,7 +1214,7 @@ RGB_FUNCTIONS(rgb565)
#define BPP 3
-RGB_FUNCTIONS(bgr24)
+#include "imgconvert_template.h"
#undef RGB_IN
#undef RGB_OUT
@@ -816,6 +1222,9 @@ RGB_FUNCTIONS(bgr24)
/* rgb24 handling */
+#define RGB_NAME rgb24
+#define FMT_RGB24
+
#define RGB_IN(r, g, b, s)\
{\
r = (s)[0];\
@@ -832,14 +1241,13 @@ RGB_FUNCTIONS(bgr24)
#define BPP 3
-RGB_FUNCTIONS(rgb24)
-
-#undef RGB_IN
-#undef RGB_OUT
-#undef BPP
+#include "imgconvert_template.h"
/* rgba32 handling */
+#define RGB_NAME rgba32
+#define FMT_RGBA32
+
#define RGB_IN(r, g, b, s)\
{\
unsigned int v = ((const uint32_t *)(s))[0];\
@@ -848,80 +1256,23 @@ RGB_FUNCTIONS(rgb24)
b = v & 0xff;\
}
-#define RGB_OUT(d, r, g, b)\
+#define RGBA_IN(r, g, b, a, s)\
{\
- ((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;\
+ unsigned int v = ((const uint32_t *)(s))[0];\
+ a = (v >> 24) & 0xff;\
+ r = (v >> 16) & 0xff;\
+ g = (v >> 8) & 0xff;\
+ b = v & 0xff;\
}
-#define BPP 4
-
-RGB_FUNCTIONS(rgba32)
-
-#undef RGB_IN
-#undef RGB_OUT
-#undef BPP
-
-
-static void rgb24_to_rgb565(AVPicture *dst, AVPicture *src,
- int width, int height)
-{
- const unsigned char *p;
- unsigned char *q;
- int r, g, b, dst_wrap, src_wrap;
- int x, y;
-
- p = src->data[0];
- src_wrap = src->linesize[0] - 3 * width;
-
- q = dst->data[0];
- dst_wrap = dst->linesize[0] - 2 * width;
-
- for(y=0;y<height;y++) {
- for(x=0;x<width;x++) {
- r = p[0];
- g = p[1];
- b = p[2];
-
- ((unsigned short *)q)[0] =
- ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
- q += 2;
- p += 3;
- }
- p += src_wrap;
- q += dst_wrap;
- }
+#define RGBA_OUT(d, r, g, b, a)\
+{\
+ ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;\
}
-/* NOTE: we also add a dummy alpha bit */
-static void rgb24_to_rgb555(AVPicture *dst, AVPicture *src,
- int width, int height)
-{
- const unsigned char *p;
- unsigned char *q;
- int r, g, b, dst_wrap, src_wrap;
- int x, y;
-
- p = src->data[0];
- src_wrap = src->linesize[0] - 3 * width;
-
- q = dst->data[0];
- dst_wrap = dst->linesize[0] - 2 * width;
+#define BPP 4
- for(y=0;y<height;y++) {
- for(x=0;x<width;x++) {
- r = p[0];
- g = p[1];
- b = p[2];
-
- ((unsigned short *)q)[0] =
- ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;
- q += 2;
- p += 3;
- }
- p += src_wrap;
- q += dst_wrap;
- }
-}
+#include "imgconvert_template.h"
static void mono_to_gray(AVPicture *dst, AVPicture *src,
int width, int height, int xor_mask)
@@ -989,7 +1340,6 @@ static void gray_to_mono(AVPicture *dst, AVPicture *src,
d = dst->data[0];
dst_wrap = dst->linesize[0] - ((width + 7) >> 3);
- printf("%d %d\n", width, height);
for(y=0;y<height;y++) {
n = width;
@@ -1033,65 +1383,26 @@ static void gray_to_monoblack(AVPicture *dst, AVPicture *src,
gray_to_mono(dst, src, width, height, 0x00);
}
-/* this is maybe slow, but allows for extensions */
-static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
-{
- return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6));
-}
+typedef struct ConvertEntry {
+ void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
+} ConvertEntry;
-/* XXX: put jpeg quantize code instead */
-static void rgb24_to_pal8(AVPicture *dst, AVPicture *src,
- int width, int height)
-{
- const unsigned char *p;
- unsigned char *q;
- int r, g, b, dst_wrap, src_wrap;
- int x, y, i;
- static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
- uint32_t *pal;
+/* Add each new convertion function in this table. In order to be able
+ to convert from any format to any format, the following constraints
+ must be satisfied:
- p = src->data[0];
- src_wrap = src->linesize[0] - 3 * width;
+ - all FF_COLOR_RGB formats must convert to and from PIX_FMT_RGB24
- q = dst->data[0];
- dst_wrap = dst->linesize[0] - width;
+ - all FF_COLOR_GRAY formats must convert to and from PIX_FMT_GRAY8
- for(y=0;y<height;y++) {
- for(x=0;x<width;x++) {
- r = p[0];
- g = p[1];
- b = p[2];
+ - all FF_COLOR_RGB formats with alpha must convert to and from PIX_FMT_RGBA32
- q[0] = gif_clut_index(r, g, b);
- q++;
- p += 3;
- }
- p += src_wrap;
- q += dst_wrap;
- }
+ - PIX_FMT_YUV444P and PIX_FMT_YUVJ444P must convert to and from
+ PIX_FMT_RGB24.
- /* build palette */
- pal = (uint32_t *)dst->data[1];
- i = 0;
- for(r = 0; r < 6; r++) {
- for(g = 0; g < 6; g++) {
- for(b = 0; b < 6; b++) {
- pal[i++] = (0xff << 24) | (pal_value[r] << 16) |
- (pal_value[g] << 8) | pal_value[b];
- }
- }
- }
- while (i < 256)
- pal[i++] = 0;
-}
-
-typedef struct ConvertEntry {
- void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
-} ConvertEntry;
+ - PIX_FMT_422 must convert to and from PIX_FMT_422P.
-/* add each new convertion function in this table */
-/* constraints;
- - all non YUV modes must convert at least to and from PIX_FMT_RGB24
+ The other conversion functions are just optimisations for common cases.
*/
static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
[PIX_FMT_YUV420P] = {
@@ -1111,27 +1422,45 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
.convert = yuv420p_to_rgba32
},
},
- [PIX_FMT_YUV422P] = {
+ [PIX_FMT_YUV422P] = {
+ [PIX_FMT_YUV422] = {
+ .convert = yuv422p_to_yuv422,
+ },
+ },
+ [PIX_FMT_YUV444P] = {
+ [PIX_FMT_RGB24] = {
+ .convert = yuv444p_to_rgb24
+ },
+ },
+ [PIX_FMT_YUVJ420P] = {
[PIX_FMT_RGB555] = {
- .convert = yuv422p_to_rgb555
+ .convert = yuvj420p_to_rgb555
},
[PIX_FMT_RGB565] = {
- .convert = yuv422p_to_rgb565
+ .convert = yuvj420p_to_rgb565
},
[PIX_FMT_BGR24] = {
- .convert = yuv422p_to_bgr24
+ .convert = yuvj420p_to_bgr24
},
[PIX_FMT_RGB24] = {
- .convert = yuv422p_to_rgb24
+ .convert = yuvj420p_to_rgb24
},
[PIX_FMT_RGBA32] = {
- .convert = yuv422p_to_rgba32
+ .convert = yuvj420p_to_rgba32
+ },
+ },
+ [PIX_FMT_YUVJ444P] = {
+ [PIX_FMT_RGB24] = {
+ .convert = yuvj444p_to_rgb24
},
},
[PIX_FMT_YUV422] = {
[PIX_FMT_YUV420P] = {
.convert = yuv422_to_yuv420p,
},
+ [PIX_FMT_YUV422P] = {
+ .convert = yuv422_to_yuv422p,
+ },
},
[PIX_FMT_RGB24] = {
@@ -1144,14 +1473,38 @@ static 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_BGR24] = {
+ .convert = rgb24_to_bgr24
+ },
[PIX_FMT_GRAY8] = {
.convert = rgb24_to_gray
},
- [PIX_FMT_PAL8] = {
+ [PIX_FMT_PAL8] = {
.convert = rgb24_to_pal8
},
+ [PIX_FMT_YUV444P] = {
+ .convert = rgb24_to_yuv444p
+ },
+ [PIX_FMT_YUVJ420P] = {
+ .convert = rgb24_to_yuvj420p
+ },
+ [PIX_FMT_YUVJ444P] = {
+ .convert = rgb24_to_yuvj444p
+ },
},
[PIX_FMT_RGBA32] = {
+ [PIX_FMT_RGB24] = {
+ .convert = rgba32_to_rgb24
+ },
+ [PIX_FMT_RGB555] = {
+ .convert = rgba32_to_rgb555
+ },
+ [PIX_FMT_PAL8] = {
+ .convert = rgba32_to_pal8
+ },
[PIX_FMT_YUV420P] = {
.convert = rgba32_to_yuv420p
},
@@ -1160,6 +1513,9 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
},
},
[PIX_FMT_BGR24] = {
+ [PIX_FMT_RGB24] = {
+ .convert = bgr24_to_rgb24
+ },
[PIX_FMT_YUV420P] = {
.convert = bgr24_to_yuv420p
},
@@ -1168,6 +1524,12 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
},
},
[PIX_FMT_RGB555] = {
+ [PIX_FMT_RGB24] = {
+ .convert = rgb555_to_rgb24
+ },
+ [PIX_FMT_RGBA32] = {
+ .convert = rgb555_to_rgba32
+ },
[PIX_FMT_YUV420P] = {
.convert = rgb555_to_yuv420p
},
@@ -1176,6 +1538,9 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
},
},
[PIX_FMT_RGB565] = {
+ [PIX_FMT_RGB24] = {
+ .convert = rgb565_to_rgb24
+ },
[PIX_FMT_YUV420P] = {
.convert = rgb565_to_yuv420p
},
@@ -1242,8 +1607,6 @@ static int avpicture_alloc(AVPicture *picture,
void *ptr;
size = avpicture_get_size(pix_fmt, width, height);
- if (size < 0)
- goto fail;
ptr = av_malloc(size);
if (!ptr)
goto fail;
@@ -1259,11 +1622,20 @@ static void avpicture_free(AVPicture *picture)
av_free(picture->data[0]);
}
+/* return true if yuv planar */
+static inline int is_yuv_planar(PixFmtInfo *ps)
+{
+ return (ps->color_type == FF_COLOR_YUV ||
+ ps->color_type == FF_COLOR_YUV_JPEG) &&
+ ps->pixel_type == FF_PIXEL_PLANAR;
+}
+
/* XXX: always use linesize. Return -1 if not supported */
int img_convert(AVPicture *dst, int dst_pix_fmt,
AVPicture *src, int src_pix_fmt,
int src_width, int src_height)
{
+ static int inited;
int i, ret, dst_width, dst_height, int_pix_fmt;
PixFmtInfo *src_pix, *dst_pix;
ConvertEntry *ce;
@@ -1275,26 +1647,19 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
if (src_width <= 0 || src_height <= 0)
return 0;
+ if (!inited) {
+ inited = 1;
+ img_convert_init();
+ }
+
dst_width = src_width;
dst_height = src_height;
dst_pix = &pix_fmt_info[dst_pix_fmt];
src_pix = &pix_fmt_info[src_pix_fmt];
if (src_pix_fmt == dst_pix_fmt) {
- /* XXX: incorrect */
- /* same format: just copy */
- for(i = 0; i < dst_pix->nb_components; i++) {
- int w, h;
- w = dst_width;
- h = dst_height;
- if (dst_pix->is_yuv && (i == 1 || i == 2)) {
- w >>= dst_pix->x_chroma_shift;
- h >>= dst_pix->y_chroma_shift;
- }
- img_copy(dst->data[i], dst->linesize[i],
- src->data[i], src->linesize[i],
- w, h);
- }
+ /* no conversion needed: just copy */
+ img_copy(dst, src, dst_pix_fmt, dst_width, dst_height);
return 0;
}
@@ -1306,13 +1671,21 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
}
/* gray to YUV */
- if (dst_pix->is_yuv && src_pix_fmt == PIX_FMT_GRAY8) {
+ if (is_yuv_planar(dst_pix) &&
+ src_pix_fmt == PIX_FMT_GRAY8) {
int w, h, y;
uint8_t *d;
- img_copy(dst->data[0], dst->linesize[0],
- src->data[0], src->linesize[0],
- dst_width, dst_height);
+ if (dst_pix->color_type == FF_COLOR_YUV_JPEG) {
+ img_copy_plane(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ dst_width, dst_height);
+ } else {
+ img_apply_table(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ dst_width, dst_height,
+ y_jpeg_to_ccir);
+ }
/* fill U and V with 128 */
w = dst_width;
h = dst_height;
@@ -1329,18 +1702,26 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
}
/* YUV to gray */
- if (src_pix->is_yuv && dst_pix_fmt == PIX_FMT_GRAY8) {
- img_copy(dst->data[0], dst->linesize[0],
- src->data[0], src->linesize[0],
- dst_width, dst_height);
+ if (is_yuv_planar(src_pix) &&
+ dst_pix_fmt == PIX_FMT_GRAY8) {
+ if (src_pix->color_type == FF_COLOR_YUV_JPEG) {
+ img_copy_plane(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ dst_width, dst_height);
+ } else {
+ img_apply_table(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ dst_width, dst_height,
+ y_ccir_to_jpeg);
+ }
return 0;
}
- /* YUV to YUV */
- if (dst_pix->is_yuv && src_pix->is_yuv) {
- int x_shift, y_shift, w, h;
+ /* YUV to YUV planar */
+ if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) {
+ int x_shift, y_shift, w, h, xy_shift;
void (*resize_func)(uint8_t *dst, int dst_wrap,
- uint8_t *src, int src_wrap,
+ const uint8_t *src, int src_wrap,
int width, int height);
/* compute chroma size of the smallest dimensions */
@@ -1357,40 +1738,116 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift);
y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift);
- if (x_shift == 0 && y_shift == 0) {
- resize_func = img_copy; /* should never happen */
- } else if (x_shift == 0 && y_shift == 1) {
- resize_func = shrink2;
- } else if (x_shift == 1 && y_shift == 1) {
+ xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf);
+ /* there must be filters for conversion at least from and to
+ YUV444 format */
+ switch(xy_shift) {
+ case 0x00:
+ resize_func = img_copy_plane;
+ break;
+ case 0x10:
+ resize_func = shrink21;
+ break;
+ case 0x20:
+ resize_func = shrink41;
+ break;
+ case 0x01:
+ resize_func = shrink12;
+ break;
+ case 0x11:
resize_func = shrink22;
- } else if (x_shift == -1 && y_shift == -1) {
+ break;
+ case 0x22:
+ resize_func = shrink44;
+ break;
+ case 0xf0:
+ resize_func = grow21;
+ break;
+ case 0xe0:
+ resize_func = grow41;
+ break;
+ case 0xff:
resize_func = grow22;
- } else if (x_shift == -1 && y_shift == 1) {
+ break;
+ case 0xee:
+ resize_func = grow44;
+ break;
+ case 0xf1:
resize_func = conv411;
- } else {
+ break;
+ default:
/* currently not handled */
- return -1;
+ goto no_chroma_filter;
}
- img_copy(dst->data[0], dst->linesize[0],
- src->data[0], src->linesize[0],
- dst_width, dst_height);
+ img_copy_plane(dst->data[0], dst->linesize[0],
+ src->data[0], src->linesize[0],
+ dst_width, dst_height);
for(i = 1;i <= 2; i++)
resize_func(dst->data[i], dst->linesize[i],
src->data[i], src->linesize[i],
dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift);
- return 0;
+ /* if yuv color space conversion is needed, we do it here on
+ the destination image */
+ if (dst_pix->color_type != src_pix->color_type) {
+ const uint8_t *y_table, *c_table;
+ if (dst_pix->color_type == FF_COLOR_YUV) {
+ y_table = y_jpeg_to_ccir;
+ c_table = c_jpeg_to_ccir;
+ } else {
+ y_table = y_ccir_to_jpeg;
+ c_table = c_ccir_to_jpeg;
+ }
+ img_apply_table(dst->data[0], dst->linesize[0],
+ dst->data[0], dst->linesize[0],
+ dst_width, dst_height,
+ y_table);
+
+ for(i = 1;i <= 2; i++)
+ img_apply_table(dst->data[i], dst->linesize[i],
+ dst->data[i], dst->linesize[i],
+ dst_width>>dst_pix->x_chroma_shift,
+ dst_height>>dst_pix->y_chroma_shift,
+ c_table);
+ }
+ return 0;
}
+ no_chroma_filter:
/* try to use an intermediate format */
- if (src_pix_fmt == PIX_FMT_MONOWHITE ||
- src_pix_fmt == PIX_FMT_MONOBLACK ||
- dst_pix_fmt == PIX_FMT_MONOWHITE ||
- dst_pix_fmt == PIX_FMT_MONOBLACK) {
+ if (src_pix_fmt == PIX_FMT_YUV422 ||
+ dst_pix_fmt == PIX_FMT_YUV422) {
+ /* specific case: convert to YUV422P first */
+ int_pix_fmt = PIX_FMT_YUV422P;
+ } else if ((src_pix->color_type == FF_COLOR_GRAY &&
+ src_pix_fmt != PIX_FMT_GRAY8) ||
+ (dst_pix->color_type == FF_COLOR_GRAY &&
+ dst_pix_fmt != PIX_FMT_GRAY8)) {
+ /* gray8 is the normalized format */
int_pix_fmt = PIX_FMT_GRAY8;
+ } else if ((is_yuv_planar(src_pix) &&
+ src_pix_fmt != PIX_FMT_YUV444P &&
+ src_pix_fmt != PIX_FMT_YUVJ444P)) {
+ /* yuv444 is the normalized format */
+ if (src_pix->color_type == FF_COLOR_YUV_JPEG)
+ int_pix_fmt = PIX_FMT_YUVJ444P;
+ else
+ int_pix_fmt = PIX_FMT_YUV444P;
+ } else if ((is_yuv_planar(dst_pix) &&
+ dst_pix_fmt != PIX_FMT_YUV444P &&
+ dst_pix_fmt != PIX_FMT_YUVJ444P)) {
+ /* yuv444 is the normalized format */
+ if (dst_pix->color_type == FF_COLOR_YUV_JPEG)
+ int_pix_fmt = PIX_FMT_YUVJ444P;
+ else
+ int_pix_fmt = PIX_FMT_YUV444P;
} else {
- int_pix_fmt = PIX_FMT_RGB24;
+ /* the two formats are rgb or gray8 or yuv[j]444p */
+ if (src_pix->is_alpha && dst_pix->is_alpha)
+ int_pix_fmt = PIX_FMT_RGBA32;
+ else
+ int_pix_fmt = PIX_FMT_RGB24;
}
if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0)
return -1;
@@ -1407,6 +1864,62 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
return ret;
}
+/* NOTE: we scan all the pixels to have an exact information */
+static int get_alpha_info_pal8(AVPicture *src, int width, int height)
+{
+ const unsigned char *p;
+ int src_wrap, ret, x, y;
+ unsigned int a;
+ uint32_t *palette = (uint32_t *)src->data[1];
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - width;
+ ret = 0;
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ a = palette[p[0]] >> 24;
+ if (a == 0x00) {
+ ret |= FF_ALPHA_TRANSP;
+ } else if (a != 0xff) {
+ ret |= FF_ALPHA_SEMI_TRANSP;
+ }
+ p++;
+ }
+ p += src_wrap;
+ }
+ return ret;
+}
+
+/**
+ * Tell if an image really has transparent alpha values.
+ * @return ored mask of FF_ALPHA_xxx constants
+ */
+int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
+{
+ PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
+ int ret;
+
+ pf = &pix_fmt_info[pix_fmt];
+ /* no alpha can be represented in format */
+ if (!pf->is_alpha)
+ return 0;
+ switch(pix_fmt) {
+ case PIX_FMT_RGBA32:
+ ret = get_alpha_info_rgba32(src, width, height);
+ break;
+ case PIX_FMT_RGB555:
+ ret = get_alpha_info_rgb555(src, width, height);
+ break;
+ case PIX_FMT_PAL8:
+ ret = get_alpha_info_pal8(src, width, height);
+ break;
+ default:
+ /* we do not know, so everything is indicated */
+ ret = FF_ALPHA_TRANSP | FF_ALPHA_SEMI_TRANSP;
+ break;
+ }
+ return ret;
+}
#ifdef HAVE_MMX
#define DEINT_INPLACE_LINE_LUM \
diff --git a/src/libffmpeg/libavcodec/imgconvert_template.h b/src/libffmpeg/libavcodec/imgconvert_template.h
new file mode 100644
index 000000000..015b74f1e
--- /dev/null
+++ b/src/libffmpeg/libavcodec/imgconvert_template.h
@@ -0,0 +1,852 @@
+/*
+ * Templates for image convertion routines
+ * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef RGB_OUT
+#define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff)
+#endif
+
+static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
+ int w, y, cb, cr, r_add, g_add, b_add, width2;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
+ unsigned int r, g, b;
+
+ d = dst->data[0];
+ y1_ptr = src->data[0];
+ cb_ptr = src->data[1];
+ cr_ptr = src->data[2];
+ width2 = (width + 1) >> 1;
+ for(;height >= 2; height -= 2) {
+ d1 = d;
+ d2 = d + dst->linesize[0];
+ y2_ptr = y1_ptr + src->linesize[0];
+ for(w = width; w >= 2; w -= 2) {
+ YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
+ /* output 4 pixels */
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
+ RGB_OUT(d1 + BPP, r, g, b);
+
+ YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
+ RGB_OUT(d2, r, g, b);
+
+ YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[1]);
+ RGB_OUT(d2 + BPP, r, g, b);
+
+ d1 += 2 * BPP;
+ d2 += 2 * BPP;
+
+ y1_ptr += 2;
+ y2_ptr += 2;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ /* handle odd width */
+ if (w) {
+ YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+
+ YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
+ RGB_OUT(d2, r, g, b);
+ d1 += BPP;
+ d2 += BPP;
+ y1_ptr++;
+ y2_ptr++;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ d += 2 * dst->linesize[0];
+ y1_ptr += 2 * src->linesize[0] - width;
+ cb_ptr += src->linesize[1] - width2;
+ cr_ptr += src->linesize[2] - width2;
+ }
+ /* handle odd height */
+ if (height) {
+ d1 = d;
+ for(w = width; w >= 2; w -= 2) {
+ YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
+ /* output 2 pixels */
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
+ RGB_OUT(d1 + BPP, r, g, b);
+
+ d1 += 2 * BPP;
+
+ y1_ptr += 2;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ /* handle width */
+ if (w) {
+ YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
+ /* output 2 pixels */
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+ d1 += BPP;
+
+ y1_ptr++;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ }
+}
+
+static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2;
+ int w, y, cb, cr, r_add, g_add, b_add, width2;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
+ unsigned int r, g, b;
+
+ d = dst->data[0];
+ y1_ptr = src->data[0];
+ cb_ptr = src->data[1];
+ cr_ptr = src->data[2];
+ width2 = (width + 1) >> 1;
+ for(;height >= 2; height -= 2) {
+ d1 = d;
+ d2 = d + dst->linesize[0];
+ y2_ptr = y1_ptr + src->linesize[0];
+ for(w = width; w >= 2; w -= 2) {
+ YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
+ /* output 4 pixels */
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+
+ YUV_TO_RGB2(r, g, b, y1_ptr[1]);
+ RGB_OUT(d1 + BPP, r, g, b);
+
+ YUV_TO_RGB2(r, g, b, y2_ptr[0]);
+ RGB_OUT(d2, r, g, b);
+
+ YUV_TO_RGB2(r, g, b, y2_ptr[1]);
+ RGB_OUT(d2 + BPP, r, g, b);
+
+ d1 += 2 * BPP;
+ d2 += 2 * BPP;
+
+ y1_ptr += 2;
+ y2_ptr += 2;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ /* handle odd width */
+ if (w) {
+ YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+
+ YUV_TO_RGB2(r, g, b, y2_ptr[0]);
+ RGB_OUT(d2, r, g, b);
+ d1 += BPP;
+ d2 += BPP;
+ y1_ptr++;
+ y2_ptr++;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ d += 2 * dst->linesize[0];
+ y1_ptr += 2 * src->linesize[0] - width;
+ cb_ptr += src->linesize[1] - width2;
+ cr_ptr += src->linesize[2] - width2;
+ }
+ /* handle odd height */
+ if (height) {
+ d1 = d;
+ for(w = width; w >= 2; w -= 2) {
+ YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
+ /* output 2 pixels */
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+
+ YUV_TO_RGB2(r, g, b, y1_ptr[1]);
+ RGB_OUT(d1 + BPP, r, g, b);
+
+ d1 += 2 * BPP;
+
+ y1_ptr += 2;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ /* handle width */
+ if (w) {
+ YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
+ /* output 2 pixels */
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+ d1 += BPP;
+
+ y1_ptr++;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ }
+}
+
+static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ int wrap, wrap3, width2;
+ int r, g, b, r1, g1, b1, w;
+ uint8_t *lum, *cb, *cr;
+ const uint8_t *p;
+
+ lum = dst->data[0];
+ cb = dst->data[1];
+ cr = dst->data[2];
+
+ width2 = (width + 1) >> 1;
+ wrap = dst->linesize[0];
+ wrap3 = src->linesize[0];
+ p = src->data[0];
+ for(;height>=2;height -= 2) {
+ for(w = width; w >= 2; w -= 2) {
+ RGB_IN(r, g, b, p);
+ r1 = r;
+ g1 = g;
+ b1 = b;
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+
+ RGB_IN(r, g, b, p + BPP);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[1] = RGB_TO_Y_CCIR(r, g, b);
+ p += wrap3;
+ lum += wrap;
+
+ RGB_IN(r, g, b, p);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+
+ RGB_IN(r, g, b, p + BPP);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[1] = RGB_TO_Y_CCIR(r, g, b);
+
+ cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 2);
+ cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 2);
+
+ cb++;
+ cr++;
+ p += -wrap3 + 2 * BPP;
+ lum += -wrap + 2;
+ }
+ if (w) {
+ RGB_IN(r, g, b, p);
+ r1 = r;
+ g1 = g;
+ b1 = b;
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+ p += wrap3;
+ lum += wrap;
+ RGB_IN(r, g, b, p);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+ cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
+ cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
+ cb++;
+ cr++;
+ p += -wrap3 + BPP;
+ lum += -wrap + 1;
+ }
+ p += wrap3 + (wrap3 - width * BPP);
+ lum += wrap + (wrap - width);
+ cb += dst->linesize[1] - width2;
+ cr += dst->linesize[2] - width2;
+ }
+ /* handle odd height */
+ if (height) {
+ for(w = width; w >= 2; w -= 2) {
+ RGB_IN(r, g, b, p);
+ r1 = r;
+ g1 = g;
+ b1 = b;
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+
+ RGB_IN(r, g, b, p + BPP);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[1] = RGB_TO_Y_CCIR(r, g, b);
+ cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
+ cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
+ cb++;
+ cr++;
+ p += 2 * BPP;
+ lum += 2;
+ }
+ if (w) {
+ RGB_IN(r, g, b, p);
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+ cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
+ cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
+ }
+ }
+}
+
+static void glue(RGB_NAME, _to_gray)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, g, b, dst_wrap, src_wrap;
+ int x, y;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - BPP * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ RGB_IN(r, g, b, p);
+ q[0] = RGB_TO_Y(r, g, b);
+ q++;
+ p += BPP;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
+static void glue(gray_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, dst_wrap, src_wrap;
+ int x, y;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - BPP * width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ r = p[0];
+ RGB_OUT(q, r, r, r);
+ q += BPP;
+ p ++;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
+static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int r, g, b, dst_wrap, src_wrap;
+ int x, y;
+ uint32_t v;
+ const uint32_t *palette;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - width;
+ palette = (uint32_t *)src->data[1];
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - BPP * width;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ v = palette[p[0]];
+ r = (v >> 16) & 0xff;
+ g = (v >> 8) & 0xff;
+ b = (v) & 0xff;
+#ifdef RGBA_OUT
+ {
+ int a;
+ a = (v >> 24) & 0xff;
+ RGBA_OUT(q, r, g, b, a);
+ }
+#else
+ RGB_OUT(q, r, g, b);
+#endif
+ q += BPP;
+ p ++;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+}
+
+#if !defined(FMT_RGBA32) && defined(RGBA_OUT)
+/* alpha support */
+
+static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const uint8_t *s;
+ uint8_t *d;
+ int src_wrap, dst_wrap, j, y;
+ unsigned int v, r, g, b, a;
+
+ s = src->data[0];
+ src_wrap = src->linesize[0] - width * 4;
+
+ d = dst->data[0];
+ dst_wrap = dst->linesize[0] - width * BPP;
+
+ for(y=0;y<height;y++) {
+ for(j = 0;j < width; j++) {
+ v = ((const uint32_t *)(s))[0];
+ a = (v >> 24) & 0xff;
+ r = (v >> 16) & 0xff;
+ g = (v >> 8) & 0xff;
+ b = v & 0xff;
+ RGBA_OUT(d, r, g, b, a);
+ s += 4;
+ d += BPP;
+ }
+ s += src_wrap;
+ d += dst_wrap;
+ }
+}
+
+static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const uint8_t *s;
+ uint8_t *d;
+ int src_wrap, dst_wrap, j, y;
+ unsigned int r, g, b, a;
+
+ s = src->data[0];
+ src_wrap = src->linesize[0] - width * BPP;
+
+ d = dst->data[0];
+ dst_wrap = dst->linesize[0] - width * 4;
+
+ for(y=0;y<height;y++) {
+ for(j = 0;j < width; j++) {
+ RGBA_IN(r, g, b, a, s);
+ ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
+ d += 4;
+ s += BPP;
+ }
+ s += src_wrap;
+ d += dst_wrap;
+ }
+}
+
+#endif /* !defined(FMT_RGBA32) && defined(RGBA_IN) */
+
+#ifndef FMT_RGB24
+
+static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const uint8_t *s;
+ uint8_t *d;
+ int src_wrap, dst_wrap, j, y;
+ unsigned int r, g, b;
+
+ s = src->data[0];
+ src_wrap = src->linesize[0] - width * 3;
+
+ d = dst->data[0];
+ dst_wrap = dst->linesize[0] - width * BPP;
+
+ for(y=0;y<height;y++) {
+ for(j = 0;j < width; j++) {
+ r = s[0];
+ g = s[1];
+ b = s[2];
+ RGB_OUT(d, r, g, b);
+ s += 3;
+ d += BPP;
+ }
+ s += src_wrap;
+ d += dst_wrap;
+ }
+}
+
+static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const uint8_t *s;
+ uint8_t *d;
+ int src_wrap, dst_wrap, j, y;
+ unsigned int r, g , b;
+
+ s = src->data[0];
+ src_wrap = src->linesize[0] - width * BPP;
+
+ d = dst->data[0];
+ dst_wrap = dst->linesize[0] - width * 3;
+
+ for(y=0;y<height;y++) {
+ for(j = 0;j < width; j++) {
+ RGB_IN(r, g, b, s)
+ d[0] = r;
+ d[1] = g;
+ d[2] = b;
+ d += 3;
+ s += BPP;
+ }
+ s += src_wrap;
+ d += dst_wrap;
+ }
+}
+
+#endif /* !FMT_RGB24 */
+
+#ifdef FMT_RGB24
+
+static void yuv444p_to_rgb24(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
+ int w, y, cb, cr, r_add, g_add, b_add;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
+ unsigned int r, g, b;
+
+ d = dst->data[0];
+ y1_ptr = src->data[0];
+ cb_ptr = src->data[1];
+ cr_ptr = src->data[2];
+ for(;height > 0; height --) {
+ d1 = d;
+ for(w = width; w > 0; w--) {
+ YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
+
+ YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+ d1 += BPP;
+
+ y1_ptr++;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ d += dst->linesize[0];
+ y1_ptr += src->linesize[0] - width;
+ cb_ptr += src->linesize[1] - width;
+ cr_ptr += src->linesize[2] - width;
+ }
+}
+
+static void yuvj444p_to_rgb24(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1;
+ int w, y, cb, cr, r_add, g_add, b_add;
+ uint8_t *cm = cropTbl + MAX_NEG_CROP;
+ unsigned int r, g, b;
+
+ d = dst->data[0];
+ y1_ptr = src->data[0];
+ cb_ptr = src->data[1];
+ cr_ptr = src->data[2];
+ for(;height > 0; height --) {
+ d1 = d;
+ for(w = width; w > 0; w--) {
+ YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
+
+ YUV_TO_RGB2(r, g, b, y1_ptr[0]);
+ RGB_OUT(d1, r, g, b);
+ d1 += BPP;
+
+ y1_ptr++;
+ cb_ptr++;
+ cr_ptr++;
+ }
+ d += dst->linesize[0];
+ y1_ptr += src->linesize[0] - width;
+ cb_ptr += src->linesize[1] - width;
+ cr_ptr += src->linesize[2] - width;
+ }
+}
+
+static void rgb24_to_yuv444p(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ int src_wrap, x, y;
+ int r, g, b;
+ uint8_t *lum, *cb, *cr;
+ const uint8_t *p;
+
+ lum = dst->data[0];
+ cb = dst->data[1];
+ cr = dst->data[2];
+
+ src_wrap = src->linesize[0] - width * BPP;
+ p = src->data[0];
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ RGB_IN(r, g, b, p);
+ lum[0] = RGB_TO_Y_CCIR(r, g, b);
+ cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
+ cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
+ p += BPP;
+ cb++;
+ cr++;
+ lum++;
+ }
+ p += src_wrap;
+ lum += dst->linesize[0] - width;
+ cb += dst->linesize[1] - width;
+ cr += dst->linesize[2] - width;
+ }
+}
+
+static void rgb24_to_yuvj420p(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ int wrap, wrap3, width2;
+ int r, g, b, r1, g1, b1, w;
+ uint8_t *lum, *cb, *cr;
+ const uint8_t *p;
+
+ lum = dst->data[0];
+ cb = dst->data[1];
+ cr = dst->data[2];
+
+ width2 = (width + 1) >> 1;
+ wrap = dst->linesize[0];
+ wrap3 = src->linesize[0];
+ p = src->data[0];
+ for(;height>=2;height -= 2) {
+ for(w = width; w >= 2; w -= 2) {
+ RGB_IN(r, g, b, p);
+ r1 = r;
+ g1 = g;
+ b1 = b;
+ lum[0] = RGB_TO_Y(r, g, b);
+
+ RGB_IN(r, g, b, p + BPP);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[1] = RGB_TO_Y(r, g, b);
+ p += wrap3;
+ lum += wrap;
+
+ RGB_IN(r, g, b, p);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[0] = RGB_TO_Y(r, g, b);
+
+ RGB_IN(r, g, b, p + BPP);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[1] = RGB_TO_Y(r, g, b);
+
+ cb[0] = RGB_TO_U(r1, g1, b1, 2);
+ cr[0] = RGB_TO_V(r1, g1, b1, 2);
+
+ cb++;
+ cr++;
+ p += -wrap3 + 2 * BPP;
+ lum += -wrap + 2;
+ }
+ if (w) {
+ RGB_IN(r, g, b, p);
+ r1 = r;
+ g1 = g;
+ b1 = b;
+ lum[0] = RGB_TO_Y(r, g, b);
+ p += wrap3;
+ lum += wrap;
+ RGB_IN(r, g, b, p);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[0] = RGB_TO_Y(r, g, b);
+ cb[0] = RGB_TO_U(r1, g1, b1, 1);
+ cr[0] = RGB_TO_V(r1, g1, b1, 1);
+ cb++;
+ cr++;
+ p += -wrap3 + BPP;
+ lum += -wrap + 1;
+ }
+ p += wrap3 + (wrap3 - width * BPP);
+ lum += wrap + (wrap - width);
+ cb += dst->linesize[1] - width2;
+ cr += dst->linesize[2] - width2;
+ }
+ /* handle odd height */
+ if (height) {
+ for(w = width; w >= 2; w -= 2) {
+ RGB_IN(r, g, b, p);
+ r1 = r;
+ g1 = g;
+ b1 = b;
+ lum[0] = RGB_TO_Y(r, g, b);
+
+ RGB_IN(r, g, b, p + BPP);
+ r1 += r;
+ g1 += g;
+ b1 += b;
+ lum[1] = RGB_TO_Y(r, g, b);
+ cb[0] = RGB_TO_U(r1, g1, b1, 1);
+ cr[0] = RGB_TO_V(r1, g1, b1, 1);
+ cb++;
+ cr++;
+ p += 2 * BPP;
+ lum += 2;
+ }
+ if (w) {
+ RGB_IN(r, g, b, p);
+ lum[0] = RGB_TO_Y(r, g, b);
+ cb[0] = RGB_TO_U(r, g, b, 0);
+ cr[0] = RGB_TO_V(r, g, b, 0);
+ }
+ }
+}
+
+static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ int src_wrap, x, y;
+ int r, g, b;
+ uint8_t *lum, *cb, *cr;
+ const uint8_t *p;
+
+ lum = dst->data[0];
+ cb = dst->data[1];
+ cr = dst->data[2];
+
+ src_wrap = src->linesize[0] - width * BPP;
+ p = src->data[0];
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ RGB_IN(r, g, b, p);
+ lum[0] = RGB_TO_Y(r, g, b);
+ cb[0] = RGB_TO_U(r, g, b, 0);
+ cr[0] = RGB_TO_V(r, g, b, 0);
+ p += BPP;
+ cb++;
+ cr++;
+ lum++;
+ }
+ p += src_wrap;
+ lum += dst->linesize[0] - width;
+ cb += dst->linesize[1] - width;
+ cr += dst->linesize[2] - width;
+ }
+}
+
+#endif /* FMT_RGB24 */
+
+#if defined(FMT_RGB24) || defined(FMT_RGBA32)
+
+static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, AVPicture *src,
+ int width, int height)
+{
+ const unsigned char *p;
+ unsigned char *q;
+ int dst_wrap, src_wrap;
+ int x, y, has_alpha;
+ unsigned int r, g, b;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - BPP * width;
+
+ q = dst->data[0];
+ dst_wrap = dst->linesize[0] - width;
+ has_alpha = 0;
+
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+#ifdef RGBA_IN
+ {
+ unsigned int a;
+ RGBA_IN(r, g, b, a, p);
+ /* crude approximation for alpha ! */
+ if (a < 0x80) {
+ has_alpha = 1;
+ q[0] = TRANSP_INDEX;
+ } else {
+ q[0] = gif_clut_index(r, g, b);
+ }
+ }
+#else
+ RGB_IN(r, g, b, p);
+ q[0] = gif_clut_index(r, g, b);
+#endif
+ q++;
+ p += BPP;
+ }
+ p += src_wrap;
+ q += dst_wrap;
+ }
+
+ build_rgb_palette(dst->data[1], has_alpha);
+}
+
+#endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */
+
+#ifdef RGBA_IN
+
+static int glue(get_alpha_info_, RGB_NAME)(AVPicture *src, int width, int height)
+{
+ const unsigned char *p;
+ int src_wrap, ret, x, y;
+ unsigned int r, g, b, a;
+
+ p = src->data[0];
+ src_wrap = src->linesize[0] - BPP * width;
+ ret = 0;
+ for(y=0;y<height;y++) {
+ for(x=0;x<width;x++) {
+ RGBA_IN(r, g, b, a, p);
+ if (a == 0x00) {
+ ret |= FF_ALPHA_TRANSP;
+ } else if (a != 0xff) {
+ ret |= FF_ALPHA_SEMI_TRANSP;
+ }
+ p += BPP;
+ }
+ p += src_wrap;
+ }
+ return ret;
+}
+
+#endif /* RGBA_IN */
+
+#undef RGB_IN
+#undef RGBA_IN
+#undef RGB_OUT
+#undef RGBA_OUT
+#undef BPP
+#undef RGB_NAME
+#undef FMT_RGB24
+#undef FMT_RGBA32
diff --git a/src/libffmpeg/libavcodec/indeo3.c b/src/libffmpeg/libavcodec/indeo3.c
index 26a5fc47a..0cf411842 100644
--- a/src/libffmpeg/libavcodec/indeo3.c
+++ b/src/libffmpeg/libavcodec/indeo3.c
@@ -26,7 +26,6 @@
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
-#include "bswap.h"
#include "indeo3data.h"
@@ -255,6 +254,48 @@ typedef struct {
/* ---------------------------------------------------------------------- */
+#define LV1_CHECK(buf1,rle_v3,lv1,lp2) \
+ if((lv1 & 0x80) != 0) { \
+ if(rle_v3 != 0) \
+ rle_v3 = 0; \
+ else { \
+ rle_v3 = 1; \
+ buf1 -= 2; \
+ } \
+ } \
+ lp2 = 4;
+
+
+#define RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) \
+ if(rle_v3 == 0) { \
+ rle_v2 = *buf1; \
+ rle_v1 = 1; \
+ if(rle_v2 > 32) { \
+ rle_v2 -= 32; \
+ rle_v1 = 0; \
+ } \
+ rle_v3 = 1; \
+ } \
+ buf1--;
+
+
+#define LP2_CHECK(buf1,rle_v3,lp2) \
+ if(lp2 == 0 && rle_v3 != 0) \
+ rle_v3 = 0; \
+ else { \
+ buf1--; \
+ rle_v3 = 1; \
+ }
+
+
+#define RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) \
+ rle_v2--; \
+ if(rle_v2 == 0) { \
+ rle_v3 = 0; \
+ buf1 += 2; \
+ } \
+ lp2 = 4;
+
static void iv_Decode_Chunk(Indeo3DecodeContext *s,
unsigned char *cur, unsigned char *ref, int width, int height,
unsigned char *buf1, long fflags2, unsigned char *hdr,
@@ -268,7 +309,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
unsigned long *cur_lp, *ref_lp, *correction_lp[2], *correctionloworder_lp[2],
*correctionhighorder_lp[2];
unsigned short *correction_type_sp[2];
- ustr_t xustr[20], *ptr_ustr;
+ ustr_t strip_tbl[20], *strip;
int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width,
rle_v1, rle_v2, rle_v3;
@@ -280,22 +321,22 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(j = -1; j < 8; j++)
width_tbl[j] = i * j;
- ptr_ustr = xustr;
+ strip = strip_tbl;
for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160);
- ptr_ustr->ypos = ptr_ustr->xpos = 0;
- for(ptr_ustr->width = min_width_160; width > ptr_ustr->width; ptr_ustr->width *= 2);
- ptr_ustr->height = height;
- ptr_ustr->split_direction = 0;
- ptr_ustr->split_flag = 0;
- ptr_ustr->usl7 = 0;
+ strip->ypos = strip->xpos = 0;
+ for(strip->width = min_width_160; width > strip->width; strip->width *= 2);
+ strip->height = height;
+ strip->split_direction = 0;
+ strip->split_flag = 0;
+ strip->usl7 = 0;
bit_pos = 0;
rle_v1 = rle_v2 = rle_v3 = 0;
- while(ptr_ustr >= xustr) {
+ while(strip >= strip_tbl) {
if(bit_pos <= 0) {
bit_pos = 8;
bit_buf = *buf1++;
@@ -305,44 +346,44 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
cmd = (bit_buf >> bit_pos) & 0x03;
if(cmd == 0) {
- ptr_ustr++;
- memcpy(ptr_ustr, ptr_ustr-1, sizeof(ustr_t));
- ptr_ustr->split_flag = 1;
- ptr_ustr->split_direction = 0;
- ptr_ustr->height = (ptr_ustr->height > 8 ? ((ptr_ustr->height+8)>>4)<<3 : 4);
+ strip++;
+ memcpy(strip, strip-1, sizeof(ustr_t));
+ strip->split_flag = 1;
+ strip->split_direction = 0;
+ strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4);
continue;
} else if(cmd == 1) {
- ptr_ustr++;
- memcpy(ptr_ustr, ptr_ustr-1, sizeof(ustr_t));
- ptr_ustr->split_flag = 1;
- ptr_ustr->split_direction = 1;
- ptr_ustr->width = (ptr_ustr->width > 8 ? ((ptr_ustr->width+8)>>4)<<3 : 4);
+ strip++;
+ memcpy(strip, strip-1, sizeof(ustr_t));
+ strip->split_flag = 1;
+ strip->split_direction = 1;
+ strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4);
continue;
} else if(cmd == 2) {
- if(ptr_ustr->usl7 == 0) {
- ptr_ustr->usl7 = 1;
+ if(strip->usl7 == 0) {
+ strip->usl7 = 1;
ref_vectors = NULL;
continue;
}
} else if(cmd == 3) {
- if(ptr_ustr->usl7 == 0) {
- ptr_ustr->usl7 = 1;
+ if(strip->usl7 == 0) {
+ strip->usl7 = 1;
ref_vectors = buf2 + (*buf1 * 2);
buf1++;
continue;
}
}
- cur_frm_pos = cur + width * ptr_ustr->ypos + ptr_ustr->xpos;
+ cur_frm_pos = cur + width * strip->ypos + strip->xpos;
- if((blks_width = ptr_ustr->width) < 0)
+ if((blks_width = strip->width) < 0)
blks_width += 3;
blks_width >>= 2;
- blks_height = ptr_ustr->height;
+ blks_height = strip->height;
if(ref_vectors != NULL) {
- ref_frm_pos = ref + (ref_vectors[0] + ptr_ustr->ypos) * width +
- ref_vectors[1] + ptr_ustr->xpos;
+ ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width +
+ ref_vectors[1] + strip->xpos;
} else
ref_frm_pos = cur_frm_pos - width_tbl[4];
@@ -428,40 +469,21 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
break;
case 8:
if(lp2 == 0) {
- if(rle_v3 == 0) {
- rle_v2 = *buf1;
- rle_v1 = 1;
- if(rle_v2 > 32) {
- rle_v2 -= 32;
- rle_v1 = 0;
- }
- rle_v3 = 1;
- }
- buf1--;
+ RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
if(rle_v1 == 1 || ref_vectors != NULL) {
for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
cur_lp[j] = ref_lp[j];
}
- rle_v2--;
- if(rle_v2 == 0) {
- rle_v3 = 0;
- buf1 += 2;
- }
- lp2 = 4;
+ RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
break;
} else {
rle_v1 = 1;
rle_v2 = *buf1 - 1;
}
case 5:
- if(lp2 == 0 && rle_v3 != 0)
- rle_v3 = 0;
- else {
- buf1--;
- rle_v3 = 1;
- }
+ LP2_CHECK(buf1,rle_v3,lp2)
case 4:
for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1])
cur_lp[j] = ref_lp[j];
@@ -491,15 +513,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
cur_lp[j] = lv;
- if((lv1 & 0x80) != 0) {
- if(rle_v3 != 0)
- rle_v3 = 0;
- else {
- rle_v3 = 1;
- buf1 -= 2;
- }
- }
- lp2 = 4;
+ LV1_CHECK(buf1,rle_v3,lv1,lp2)
break;
default:
return;
@@ -532,7 +546,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
switch(correction_type_sp[lp2 & 0x01][k]) {
case 0:
cur_lp[width_tbl[1]] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
- if(lp2 > 0 || flag1 == 0 || ptr_ustr->ypos != 0)
+ if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)
cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
else
cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
@@ -544,7 +558,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
((((unsigned short *)ref_lp)[0] >> 1) + correction_lp[lp2 & 0x01][*buf1++]) << 1;
((unsigned short *)cur_lp)[width_tbl[2]+1] =
((((unsigned short *)ref_lp)[1] >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
- if(lp2 > 0 || flag1 == 0 || ptr_ustr->ypos != 0)
+ if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)
cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
else
cur_lp[0] = cur_lp[width_tbl[1]];
@@ -583,40 +597,21 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
case 8:
if(lp2 == 0) {
- if(rle_v3 == 0) {
- rle_v2 = *buf1;
- rle_v1 = 1;
- if(rle_v2 > 32) {
- rle_v2 -= 32;
- rle_v1 = 0;
- }
- rle_v3 = 1;
- }
- buf1--;
+ RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
if(rle_v1 == 1) {
for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
cur_lp[j] = ref_lp[j];
}
- rle_v2--;
- if(rle_v2 == 0) {
- rle_v3 = 0;
- buf1 += 2;
- }
- lp2 = 4;
+ RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
break;
} else {
rle_v2 = (*buf1) - 1;
rle_v1 = 1;
}
case 5:
- if(lp2 == 0 && rle_v3 != 0)
- rle_v3 = 0;
- else {
- buf1--;
- rle_v3 = 1;
- }
+ LP2_CHECK(buf1,rle_v3,lp2)
case 4:
for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
cur_lp[j] = *ref_lp;
@@ -633,15 +628,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
cur_lp[j] = lv;
- if((lv1 & 0x80) != 0) {
- if(rle_v3 != 0)
- rle_v3 = 0;
- else {
- rle_v3 = 1;
- buf1 -= 2;
- }
- }
- lp2 = 4;
+ LV1_CHECK(buf1,rle_v3,lv1,lp2)
break;
default:
@@ -680,7 +667,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
case 0:
cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1;
cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1;
- if(lp2 > 0 || ptr_ustr->ypos != 0 || flag1 == 0) {
+ if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {
cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
} else {
@@ -693,7 +680,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
case 1:
cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1++]) << 1;
cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1;
- if(lp2 > 0 || ptr_ustr->ypos != 0 || flag1 == 0) {
+ if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {
cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
} else {
@@ -743,16 +730,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
case 8:
if(lp2 == 0) {
- if(rle_v3 == 0) {
- rle_v2 = *buf1;
- rle_v1 = 1;
- if(rle_v2 > 32) {
- rle_v2 -= 32;
- rle_v1 = 0;
- }
- rle_v3 = 1;
- }
- buf1--;
+ RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
if(rle_v1 == 1) {
if(flag1 != 0) {
for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
@@ -768,24 +746,14 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
}
}
}
- rle_v2--;
- if(rle_v2 == 0) {
- rle_v3 = 0;
- buf1 += 2;
- }
- lp2 = 4;
+ RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
break;
} else {
rle_v1 = 1;
rle_v2 = (*buf1) - 1;
}
case 5:
- if(lp2 == 0 && rle_v3 != 0)
- rle_v3 = 0;
- else {
- buf1--;
- rle_v3 = 1;
- }
+ LP2_CHECK(buf1,rle_v3,lp2)
case 4:
if(lp2 == 0 && flag1 != 0) {
for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
@@ -827,15 +795,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
lv += (lv << 16);
for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
cur_lp[j] = lv;
- if((lv1 & 0x80) != 0) {
- if(rle_v3 != 0)
- rle_v3 = 0;
- else {
- rle_v3 = 1;
- buf1 -= 2;
- }
- }
- lp2 = 4;
+ LV1_CHECK(buf1,rle_v3,lv1,lp2)
break;
default:
@@ -900,26 +860,12 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
case 8:
if(lp2 == 0) {
- if(rle_v3 == 0) {
- rle_v2 = *buf1;
- rle_v1 = 1;
- if(rle_v2 > 32) {
- rle_v2 -= 32;
- rle_v1 = 0;
- }
- rle_v3 = 1;
- }
- buf1--;
+ RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
((unsigned long *)cur_frm_pos)[j] = ((unsigned long *)ref_frm_pos)[j];
((unsigned long *)cur_frm_pos)[j+1] = ((unsigned long *)ref_frm_pos)[j+1];
}
- rle_v2--;
- if(rle_v2 == 0) {
- rle_v3 = 0;
- buf1 += 2;
- }
- lp2 = 4;
+ RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
break;
} else {
rle_v1 = 1;
@@ -927,12 +873,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
}
case 5:
case 7:
- if(lp2 == 0 && rle_v3 != 0)
- rle_v3 = 0;
- else {
- buf1--;
- rle_v3 = 1;
- }
+ LP2_CHECK(buf1,rle_v3,lp2)
case 6:
case 4:
for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
@@ -950,15 +891,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
lv += (lv << 16);
for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
((unsigned long *)cur_frm_pos)[j] = ((unsigned long *)cur_frm_pos)[j+1] = lv;
- if((lv1 & 0x80) != 0) {
- if(rle_v3 != 0)
- rle_v3 = 0;
- else {
- rle_v3 = 1;
- buf1 -= 2;
- }
- }
- lp2 = 4;
+ LV1_CHECK(buf1,rle_v3,lv1,lp2)
break;
default:
@@ -1022,26 +955,12 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
case 8:
if(lp2 == 0) {
- if(rle_v3 == 0) {
- rle_v2 = *buf1;
- rle_v1 = 1;
- if(rle_v2 > 32) {
- rle_v2 -= 32;
- rle_v1 = 0;
- }
- rle_v3 = 1;
- }
- buf1--;
+ RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
cur_lp[j] = ref_lp[j];
- rle_v2--;
- if(rle_v2 == 0) {
- rle_v3 = 0;
- buf1 += 2;
- }
- lp2 = 4;
+ RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
break;
} else {
rle_v1 = 1;
@@ -1049,12 +968,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
}
case 5:
case 7:
- if(lp2 == 0 && rle_v3 != 0)
- rle_v3 = 0;
- else {
- buf1--;
- rle_v3 = 1;
- }
+ LP2_CHECK(buf1,rle_v3,lp2)
case 4:
case 6:
for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
@@ -1070,15 +984,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
lv += (lv << 16);
for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
cur_lp[j] = lv;
- if((lv1 & 0x80) != 0) {
- if(rle_v3 != 0)
- rle_v3 = 0;
- else {
- rle_v3 = 1;
- buf1 -= 2;
- }
- }
- lp2 = 4;
+ LV1_CHECK(buf1,rle_v3,lv1,lp2)
break;
default:
@@ -1100,22 +1006,22 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
}
}
- if(ptr_ustr < xustr)
+ if(strip < strip_tbl)
return;
- for( ; ptr_ustr >= xustr; ptr_ustr--) {
- if(ptr_ustr->split_flag != 0) {
- ptr_ustr->split_flag = 0;
- ptr_ustr->usl7 = (ptr_ustr-1)->usl7;
+ for( ; strip >= strip_tbl; strip--) {
+ if(strip->split_flag != 0) {
+ strip->split_flag = 0;
+ strip->usl7 = (strip-1)->usl7;
- if(ptr_ustr->split_direction) {
- ptr_ustr->xpos += ptr_ustr->width;
- ptr_ustr->width = (ptr_ustr-1)->width - ptr_ustr->width;
- if(region_160_width <= ptr_ustr->xpos && width < ptr_ustr->width + ptr_ustr->xpos)
- ptr_ustr->width = width - ptr_ustr->xpos;
+ if(strip->split_direction) {
+ strip->xpos += strip->width;
+ strip->width = (strip-1)->width - strip->width;
+ if(region_160_width <= strip->xpos && width < strip->width + strip->xpos)
+ strip->width = width - strip->xpos;
} else {
- ptr_ustr->ypos += ptr_ustr->height;
- ptr_ustr->height = (ptr_ustr-1)->height - ptr_ustr->height;
+ strip->ypos += strip->height;
+ strip->height = (strip-1)->height - strip->height;
}
break;
}
@@ -1149,6 +1055,9 @@ static int indeo3_decode_frame(AVCodecContext *avctx,
iv_decode_frame(s, buf, buf_size);
+ if(s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
+
s->frame.reference = 0;
if(avctx->get_buffer(avctx, &s->frame) < 0) {
fprintf(stderr, "get_buffer() failed\n");
@@ -1182,8 +1091,6 @@ static int indeo3_decode_frame(AVCodecContext *avctx,
*data_size=sizeof(AVFrame);
*(AVFrame*)data= s->frame;
- avctx->release_buffer(avctx, &s->frame);
-
return buf_size;
}
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.c b/src/libffmpeg/libavcodec/libpostproc/postprocess.c
index ce61ffd39..8473882bb 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess.c
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.c
@@ -169,8 +169,9 @@ static inline int isHorizDC(uint8_t src[], int stride, PPContext *c)
{
int numEq= 0;
int y;
- const int dcOffset= ((c->QP*c->ppMode.baseDcDiff)>>8) + 1;
+ const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
const int dcThreshold= dcOffset*2 + 1;
+
for(y=0; y<BLOCK_SIZE; y++)
{
if(((unsigned)(src[0] - src[1] + dcOffset)) < dcThreshold) numEq++;
@@ -191,8 +192,9 @@ static inline int isHorizDC(uint8_t src[], int stride, PPContext *c)
static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c){
int numEq= 0;
int y;
- const int dcOffset= ((c->QP*c->ppMode.baseDcDiff)>>8) + 1;
+ const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
const int dcThreshold= dcOffset*2 + 1;
+
src+= stride*4; // src points to begin of the 8x8 Block
for(y=0; y<BLOCK_SIZE-1; y++)
{
@@ -483,8 +485,8 @@ char *pp_help=
" c chrom chrominance filtring enabled\n"
" y nochrom chrominance filtring disabled\n"
"hb hdeblock (2 Threshold) horizontal deblocking filter\n"
-" 1. difference factor: default=64, higher -> more deblocking\n"
-" 2. flatness threshold: default=40, lower -> more deblocking\n"
+" 1. difference factor: default=32, higher -> more deblocking\n"
+" 2. flatness threshold: default=39, lower -> more deblocking\n"
" the h & v deblocking filters share these\n"
" so u cant set different thresholds for h / v\n"
"vb vdeblock (2 Threshold) vertical deblocking filter\n"
@@ -523,8 +525,8 @@ pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality)
ppMode->maxTmpNoise[2]= 3000;
ppMode->maxAllowedY= 234;
ppMode->minAllowedY= 16;
- ppMode->baseDcDiff= 256/4;
- ppMode->flatnessThreshold= 56-16;
+ ppMode->baseDcDiff= 256/8;
+ ppMode->flatnessThreshold= 56-16-1;
ppMode->maxClippedThreshold= 0.01;
ppMode->error=0;
@@ -705,12 +707,13 @@ static void reallocAlign(void **p, int alignment, int size){
memset(*p, 0, size);
}
-static void reallocBuffers(PPContext *c, int width, int height, int stride){
+static void reallocBuffers(PPContext *c, int width, int height, int stride, int qpStride){
int mbWidth = (width+15)>>4;
int mbHeight= (height+15)>>4;
int i;
c->stride= stride;
+ c->qpStride= qpStride;
reallocAlign((void **)&c->tempDst, 8, stride*24);
reallocAlign((void **)&c->tempSrc, 8, stride*24);
@@ -727,11 +730,12 @@ static void reallocBuffers(PPContext *c, int width, int height, int stride){
}
reallocAlign((void **)&c->deintTemp, 8, 2*width+32);
- reallocAlign((void **)&c->nonBQPTable, 8, mbWidth*mbHeight*sizeof(QP_STORE_T));
+ reallocAlign((void **)&c->nonBQPTable, 8, qpStride*mbHeight*sizeof(QP_STORE_T));
+ reallocAlign((void **)&c->stdQPTable, 8, qpStride*mbHeight*sizeof(QP_STORE_T));
reallocAlign((void **)&c->forcedQPTable, 8, mbWidth*sizeof(QP_STORE_T));
}
-static void global_init(){
+static void global_init(void){
int i;
memset(clip_table, 0, 256);
for(i=256; i<512; i++)
@@ -742,6 +746,7 @@ static void global_init(){
pp_context_t *pp_get_context(int width, int height, int cpuCaps){
PPContext *c= memalign(32, sizeof(PPContext));
int stride= (width+15)&(~15); //assumed / will realloc if needed
+ int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed
global_init();
@@ -755,7 +760,7 @@ pp_context_t *pp_get_context(int width, int height, int cpuCaps){
c->vChromaSubSample= 1;
}
- reallocBuffers(c, width, height, stride);
+ reallocBuffers(c, width, height, stride, qpStride);
c->frameNum=-1;
@@ -774,6 +779,7 @@ void pp_free_context(void *vc){
free(c->tempDst);
free(c->tempSrc);
free(c->deintTemp);
+ free(c->stdQPTable);
free(c->nonBQPTable);
free(c->forcedQPTable);
@@ -793,9 +799,11 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3],
PPMode *mode = (PPMode*)vm;
PPContext *c = (PPContext*)vc;
int minStride= MAX(srcStride[0], dstStride[0]);
-
- if(c->stride < minStride)
- reallocBuffers(c, width, height, minStride);
+
+ if(c->stride < minStride || c->qpStride < QPStride)
+ reallocBuffers(c, width, height,
+ MAX(minStride, c->stride),
+ MAX(c->qpStride, QPStride));
if(QP_store==NULL || (mode->lumMode & FORCE_QUANT))
{
@@ -807,6 +815,20 @@ void pp_postprocess(uint8_t * src[3], int srcStride[3],
else
for(i=0; i<mbWidth; i++) QP_store[i]= 1;
}
+//printf("pict_type:%d\n", pict_type);
+
+ if(pict_type & PP_PICT_TYPE_QP2){
+ int i;
+ const int count= mbHeight * QPStride;
+ for(i=0; i<(count>>2); i++){
+ ((uint32_t*)c->stdQPTable)[i] = (((uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F;
+ }
+ for(i<<=2; i<count; i++){
+ c->stdQPTable[i] = QP_store[i]>>1;
+ }
+ QP_store= c->stdQPTable;
+ }
+
if(0){
int x,y;
for(y=0; y<mbHeight; y++){
@@ -817,18 +839,16 @@ for(y=0; y<mbHeight; y++){
}
printf("\n");
}
-//printf("pict_type:%d\n", pict_type);
- if(pict_type!=3)
+ if((pict_type&7)!=3)
{
- int x,y;
- for(y=0; y<mbHeight; y++){
- for(x=0; x<mbWidth; x++){
- int qscale= QP_store[x + y*QPStride];
- if(qscale&~31)
- qscale=31;
- c->nonBQPTable[y*mbWidth + x]= qscale;
- }
+ int i;
+ const int count= mbHeight * QPStride;
+ for(i=0; i<(count>>2); i++){
+ ((uint32_t*)c->nonBQPTable)[i] = ((uint32_t*)QP_store)[i] & 0x1F1F1F1F;
+ }
+ for(i<<=2; i<count; i++){
+ c->nonBQPTable[i] = QP_store[i] & 0x1F;
}
}
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess.h b/src/libffmpeg/libavcodec/libpostproc/postprocess.h
index fd8a42c13..dae863044 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess.h
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess.h
@@ -66,6 +66,8 @@ void pp_free_context(pp_context_t *ppContext);
#define PP_FORMAT_411 (0x00000002|PP_FORMAT)
#define PP_FORMAT_444 (0x00000000|PP_FORMAT)
+#define PP_PICT_TYPE_QP2 0x00000010 ///< MPEG2 style QScale
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h b/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h
index febea1818..13b3e3831 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess_internal.h
@@ -137,6 +137,7 @@ typedef struct PPContext{
uint64_t __attribute__((aligned(8))) mmxDcOffset[32];
uint64_t __attribute__((aligned(8))) mmxDcThreshold[32];
+ QP_STORE_T *stdQPTable; ///< used to fix MPEG2 style qscale
QP_STORE_T *nonBQPTable;
QP_STORE_T *forcedQPTable;
@@ -147,7 +148,8 @@ typedef struct PPContext{
int cpuCaps;
- int stride; ///<size of some buffers (needed to realloc them if needed)
+ int qpStride; ///<size of qp buffers (needed to realloc them if needed)
+ int stride; ///<size of some buffers (needed to realloc them if needed)
int hChromaSubSample;
int vChromaSubSample;
@@ -155,3 +157,4 @@ typedef struct PPContext{
PPMode ppMode;
} PPContext;
+
diff --git a/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c b/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
index b4ecca123..48027e417 100644
--- a/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
+++ b/src/libffmpeg/libavcodec/libpostproc/postprocess_template.c
@@ -2993,7 +2993,7 @@ static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int
uint8_t *tempBlock2= c.tempBlocks + 8;
#endif
int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
- int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*mbWidth];
+ int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*QPStride];
int QP=0;
/* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards
if not than use a temporary buffer */
diff --git a/src/libffmpeg/libavcodec/mjpeg.c b/src/libffmpeg/libavcodec/mjpeg.c
index 5f1271abf..22530c9e4 100644
--- a/src/libffmpeg/libavcodec/mjpeg.c
+++ b/src/libffmpeg/libavcodec/mjpeg.c
@@ -478,7 +478,7 @@ static void escape_FF(MpegEncContext *s, int start)
int size= get_bit_count(&s->pb) - start*8;
int i, ff_count;
uint8_t *buf= s->pb.buf + start;
- int align= (-(int)(buf))&3;
+ int align= (-(size_t)(buf))&3;
assert((size&7) == 0);
size >>= 3;
@@ -557,12 +557,7 @@ static inline void mjpeg_encode_dc(MpegEncContext *s, int val,
mant--;
}
- /* compute the log (XXX: optimize) */
- nbits = 0;
- while (val != 0) {
- val = val >> 1;
- nbits++;
- }
+ nbits= av_log2(val) + 1;
put_bits(&s->pb, huff_size[nbits], huff_code[nbits]);
@@ -613,12 +608,7 @@ static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
mant--;
}
- /* compute the log (XXX: optimize) */
- nbits = 0;
- while (val != 0) {
- val = val >> 1;
- nbits++;
- }
+ nbits= av_log2(val) + 1;
code = (run << 4) | nbits;
put_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]);
@@ -902,34 +892,26 @@ static int mjpeg_decode_sof0(MJpegDecodeContext *s)
static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
{
- int code, diff;
-#if 1
+ int code;
code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
-#else
- code = get_vlc(&s->gb, &s->vlcs[0][dc_index]);
-#endif
if (code < 0)
{
dprintf("mjpeg_decode_dc: bad vlc: %d:%d (%p)\n", 0, dc_index,
&s->vlcs[0][dc_index]);
return 0xffff;
}
- if (code == 0) {
- diff = 0;
- } else {
- diff = get_bits(&s->gb, code);
- if ((diff & (1 << (code - 1))) == 0)
- diff = (-1 << code) | (diff + 1);
- }
- return diff;
+
+ if(code)
+ return get_xbits(&s->gb, code);
+ else
+ return 0;
}
/* decode block and dequantize */
static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
int component, int dc_index, int ac_index, int quant_index)
{
- int nbits, code, i, j, level;
- int run, val;
+ int code, i, j, level, val;
VLC *ac_vlc;
int16_t *quant_matrix;
@@ -947,11 +929,8 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
ac_vlc = &s->vlcs[1][ac_index];
i = 1;
for(;;) {
-#if 1
code = get_vlc2(&s->gb, s->vlcs[1][ac_index].table, 9, 2);
-#else
- code = get_vlc(&s->gb, ac_vlc);
-#endif
+
if (code < 0) {
dprintf("error ac\n");
return -1;
@@ -962,12 +941,8 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
if (code == 0xf0) {
i += 16;
} else {
- run = code >> 4;
- nbits = code & 0xf;
- level = get_bits(&s->gb, nbits);
- if ((level & (1 << (nbits - 1))) == 0)
- level = (-1 << nbits) | (level + 1);
- i += run;
+ level = get_xbits(&s->gb, code & 0xf);
+ i += code >> 4;
if (i >= 64) {
dprintf("error count: %d\n", i);
return -1;
diff --git a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
index 3b003325a..30111e282 100644
--- a/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
+++ b/src/libffmpeg/libavcodec/mlib/dsputil_mlib.c
@@ -251,18 +251,19 @@ void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
c->add_pixels_clamped = add_pixels_clamped_mlib;
put_pixels_clamped = c->put_pixels_clamped;
-
- if(avctx->dct_algo==FF_DCT_AUTO || avctx->dct_algo==FF_DCT_MLIB){
- c->fdct = ff_fdct_mlib;
- }
-
- if(avctx->idct_algo==FF_IDCT_AUTO || avctx->idct_algo==FF_IDCT_MLIB){
- c->idct_put= ff_idct_put_mlib;
- c->idct_add= ff_idct_add_mlib;
- c->idct_permutation_type= FF_NO_IDCT_PERM;
- }
}
void MPV_common_init_mlib(MpegEncContext *s)
{
+ int i;
+
+ if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
+ s->dsp.fdct = ff_fdct_mlib;
+ }
+
+ if(s->avctx->idct_algo==FF_IDCT_AUTO || s->avctx->idct_algo==FF_IDCT_MLIB){
+ s->dsp.idct_put= ff_idct_put_mlib;
+ s->dsp.idct_add= ff_idct_add_mlib;
+ s->dsp.idct_permutation_type= FF_NO_IDCT_PERM;
+ }
}
diff --git a/src/libffmpeg/libavcodec/motion_est_template.c b/src/libffmpeg/libavcodec/motion_est_template.c
index 2d403993c..546509e53 100644
--- a/src/libffmpeg/libavcodec/motion_est_template.c
+++ b/src/libffmpeg/libavcodec/motion_est_template.c
@@ -43,8 +43,8 @@
op_pixels_func (*chroma_hpel_put)[4];\
qpel_mc_func (*qpel_put)[16];\
qpel_mc_func (*qpel_avg)[16]= &s->dsp.avg_qpel_pixels_tab[size];\
- const __attribute__((unused)) int unu= time_pp + time_pb + (int)src_u + (int)src_v + (int)ref_u + (int)ref_v\
- + (int)ref2_y + (int)hpel_avg + (int)qpel_avg + (int)score_map;\
+ const __attribute__((unused)) int unu= time_pp + time_pb + (size_t)src_u + (size_t)src_v + (size_t)ref_u + (size_t)ref_v\
+ + (size_t)ref2_y + (size_t)hpel_avg + (size_t)qpel_avg + (size_t)score_map;\
if(s->no_rounding /*FIXME b_type*/){\
hpel_put= &s->dsp.put_no_rnd_pixels_tab[size];\
chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1];\
diff --git a/src/libffmpeg/libavcodec/mpeg12.c b/src/libffmpeg/libavcodec/mpeg12.c
index 11a8ea9c9..c31a711c7 100644
--- a/src/libffmpeg/libavcodec/mpeg12.c
+++ b/src/libffmpeg/libavcodec/mpeg12.c
@@ -316,13 +316,6 @@ static void common_init(MpegEncContext *s)
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
}
-void ff_mpeg1_clean_buffers(MpegEncContext *s){
- s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
- s->last_dc[1] = s->last_dc[0];
- s->last_dc[2] = s->last_dc[0];
- memset(s->last_mv, 0, sizeof(s->last_mv));
-}
-
#ifdef CONFIG_ENCODERS
void ff_mpeg1_encode_slice_header(MpegEncContext *s){
@@ -331,6 +324,13 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s){
put_bits(&s->pb, 1, 0); /* slice extra information */
}
+void ff_mpeg1_clean_buffers(MpegEncContext *s){
+ s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
+ s->last_dc[1] = s->last_dc[0];
+ s->last_dc[2] = s->last_dc[0];
+ memset(s->last_mv, 0, sizeof(s->last_mv));
+}
+
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
{
mpeg1_encode_sequence_header(s);
@@ -852,16 +852,13 @@ static inline int get_dmv(MpegEncContext *s)
static inline int get_qscale(MpegEncContext *s)
{
- int qscale;
+ int qscale = get_bits(&s->gb, 5);
if (s->mpeg2) {
if (s->q_scale_type) {
- qscale = non_linear_qscale[get_bits(&s->gb, 5)];
+ return non_linear_qscale[qscale];
} else {
- qscale = get_bits(&s->gb, 5) << 1;
+ return qscale << 1;
}
- } else {
- /* for mpeg1, we use the generic unquant code */
- qscale = get_bits(&s->gb, 5);
}
return qscale;
}
@@ -1179,7 +1176,7 @@ static int mpeg_decode_mb(MpegEncContext *s,
/* as h263, but only 17 codes */
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
{
- int code, sign, val, m, l, shift;
+ int code, sign, val, l, shift;
code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
if (code == 0) {
@@ -1191,22 +1188,19 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
sign = get_bits1(&s->gb);
shift = fcode - 1;
- val = (code - 1) << shift;
- if (shift > 0)
+ val = code;
+ if (shift) {
+ val = (val - 1) << shift;
val |= get_bits(&s->gb, shift);
- val++;
+ val++;
+ }
if (sign)
val = -val;
val += pred;
/* modulo decoding */
l = 1 << (shift+4);
- m = 2 * l;
- if (val < -l) {
- val += m;
- } else if (val >= l) {
- val -= m;
- }
+ val = ((val + l)&(l*2-1)) - l;
return val;
}
@@ -1226,9 +1220,7 @@ static inline int decode_dc(MpegEncContext *s, int component)
if (code == 0) {
diff = 0;
} else {
- diff = get_bits(&s->gb, code);
- if ((diff & (1 << (code - 1))) == 0)
- diff = (-1 << code) | (diff + 1);
+ diff = get_xbits(&s->gb, code);
}
return diff;
}
@@ -1543,16 +1535,8 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
return 0;
}
-/* compressed picture size */
-#define PICTURE_BUFFER_SIZE 100000
-
typedef struct Mpeg1Context {
MpegEncContext mpeg_enc_ctx;
- uint32_t header_state;
- int start_code; /* current start code */
- uint8_t buffer[PICTURE_BUFFER_SIZE];
- uint8_t *buf_ptr;
- int buffer_size;
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
} Mpeg1Context;
@@ -1565,11 +1549,7 @@ static int mpeg_decode_init(AVCodecContext *avctx)
common_init(&s->mpeg_enc_ctx);
init_vlcs(&s->mpeg_enc_ctx);
- s->header_state = 0xff;
s->mpeg_enc_ctx_allocated = 0;
- s->buffer_size = PICTURE_BUFFER_SIZE;
- s->start_code = -1;
- s->buf_ptr = s->buffer;
s->mpeg_enc_ctx.picture_number = 0;
s->repeat_field = 0;
s->mpeg_enc_ctx.codec_id= avctx->codec->id;
@@ -1578,14 +1558,12 @@ static int mpeg_decode_init(AVCodecContext *avctx)
/* return the 8 bit start code value and update the search
state. Return -1 if no start code found */
-static int find_start_code(uint8_t **pbuf_ptr, uint8_t *buf_end,
- uint32_t *header_state)
+static int find_start_code(uint8_t **pbuf_ptr, uint8_t *buf_end)
{
uint8_t *buf_ptr;
- unsigned int state, v;
+ unsigned int state=0xFFFFFFFF, v;
int val;
- state = *header_state;
buf_ptr = *pbuf_ptr;
while (buf_ptr < buf_end) {
v = *buf_ptr++;
@@ -1599,7 +1577,6 @@ static int find_start_code(uint8_t **pbuf_ptr, uint8_t *buf_end,
val = -1;
found:
*pbuf_ptr = buf_ptr;
- *header_state = state;
return val;
}
@@ -1744,15 +1721,15 @@ static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
}
if(s->alternate_scan){
- ff_init_scantable(s, &s->inter_scantable , ff_alternate_vertical_scan);
- ff_init_scantable(s, &s->intra_scantable , ff_alternate_vertical_scan);
- ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_vertical_scan);
- ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
}else{
- ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct);
- ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct);
- ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan);
- ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
}
/* composite display not parsed */
@@ -1793,33 +1770,33 @@ static void mpeg_decode_extension(AVCodecContext *avctx,
}
}
-#define DECODE_SLICE_MB_ADDR_ERROR -3 //we faild decoding the mb_x/y info
#define DECODE_SLICE_FATAL_ERROR -2
#define DECODE_SLICE_ERROR -1
#define DECODE_SLICE_OK 0
-#define DECODE_SLICE_EOP 1
/**
* decodes a slice.
* @return DECODE_SLICE_FATAL_ERROR if a non recoverable error occured<br>
* DECODE_SLICE_ERROR if the slice is damaged<br>
* DECODE_SLICE_OK if this slice is ok<br>
- * DECODE_SLICE_EOP if the end of the picture is reached
*/
static int mpeg_decode_slice(AVCodecContext *avctx,
AVFrame *pict,
int start_code,
- uint8_t *buf, int buf_size)
+ uint8_t **buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int ret;
const int field_pic= s->picture_structure != PICT_FRAME;
+ s->resync_mb_x= s->mb_x =
+ s->resync_mb_y= s->mb_y = -1;
+
start_code = (start_code - 1) & 0xff;
if (start_code >= s->mb_height){
fprintf(stderr, "slice below image (%d >= %d)\n", start_code, s->mb_height);
- return DECODE_SLICE_MB_ADDR_ERROR;
+ return -1;
}
ff_mpeg1_clean_buffers(s);
@@ -1874,12 +1851,12 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
}
s->first_slice = 0;
- init_get_bits(&s->gb, buf, buf_size*8);
+ init_get_bits(&s->gb, *buf, buf_size*8);
s->qscale = get_qscale(s);
if(s->qscale == 0){
fprintf(stderr, "qscale == 0\n");
- return DECODE_SLICE_MB_ADDR_ERROR;
+ return -1;
}
/* extra slice info */
@@ -1893,7 +1870,7 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
if (code < 0){
fprintf(stderr, "first mb_incr damaged\n");
- return DECODE_SLICE_MB_ADDR_ERROR;
+ return -1;
}
if (code >= 33) {
if (code == 33) {
@@ -1924,11 +1901,12 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
const int xy = s->mb_x*2 + 1 + (s->mb_y*2 +1)*wrap;
int motion_x, motion_y;
- if (s->mb_intra || s->mv_type == MV_TYPE_16X16) {
+ if (s->mb_intra) {
+ motion_x = motion_y = 0;
+ }else if (s->mv_type == MV_TYPE_16X16) {
motion_x = s->mv[0][0][0];
motion_y = s->mv[0][0][1];
} else /*if (s->mv_type == MV_TYPE_FIELD)*/ {
- int i;
motion_x = s->mv[0][0][0] + s->mv[0][1][0];
motion_y = s->mv[0][0][1] + s->mv[0][1][1];
motion_x = (motion_x>>1) | (motion_x&1);
@@ -1956,6 +1934,17 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
s->mb_x = 0;
s->mb_y++;
+
+ if(s->mb_y<<field_pic >= s->mb_height){
+ int left= s->gb.size_in_bits - get_bits_count(&s->gb);
+
+ if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)))
+ || (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){
+ fprintf(stderr, "end missmatch left=%d\n", left);
+ return -1;
+ }else
+ goto eos;
+ }
}
/* skip mb handling */
@@ -1985,24 +1974,31 @@ static int mpeg_decode_slice(AVCodecContext *avctx,
}
}
}
- if(s->mb_y<<field_pic >= s->mb_height){
- fprintf(stderr, "slice too long\n");
- return DECODE_SLICE_ERROR;
- }
}
-eos: //end of slice
+eos: // end of slice
+ *buf += get_bits_count(&s->gb)/8 - 1;
//printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
+ return 0;
+}
- emms_c();
-
-//intf("%d %d %d %d\n", s->mb_y, s->mb_height, s->pict_type, s->picture_number);
+/**
+ * handles slice ends.
+ * @return 1 if it seems to be the last slice of
+ */
+static int slice_end(AVCodecContext *avctx, AVFrame *pict)
+{
+ Mpeg1Context *s1 = avctx->priv_data;
+ MpegEncContext *s = &s1->mpeg_enc_ctx;
+
/* end of slice reached */
- if (s->mb_y<<field_pic == s->mb_height && !s->first_field) {
+ if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) {
/* end of image */
- if(s->mpeg2)
- s->qscale >>=1;
+ if(s->mpeg2){
+ s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2;
+ }else
+ s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG1;
+
ff_er_frame_end(s);
MPV_frame_end(s);
@@ -2014,16 +2010,14 @@ eos: //end of slice
s->picture_number++;
/* latency of 1 frame for I and P frames */
/* XXX: use another variable than picture_number */
- if (s->last_picture_ptr == NULL) {
- return DECODE_SLICE_OK;
- } else {
+ if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)&s->last_picture;
ff_print_debug_info(s, s->last_picture_ptr);
}
}
- return DECODE_SLICE_EOP;
+ return 1;
} else {
- return DECODE_SLICE_OK;
+ return 0;
}
}
@@ -2167,17 +2161,55 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
}
}
+/**
+ * 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 mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){
+ ParseContext *pc= &s->parse_context;
+ int i;
+ uint32_t state;
+
+ state= pc->state;
+
+ i=0;
+ if(!pc->frame_start_found){
+ for(i=0; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){
+ i++;
+ pc->frame_start_found=1;
+ break;
+ }
+ }
+ }
+
+ if(pc->frame_start_found){
+ for(; i<buf_size; i++){
+ state= (state<<8) | buf[i];
+ if((state&0xFFFFFF00) == 0x100){
+ if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
+ pc->frame_start_found=0;
+ pc->state=-1;
+ return i-3;
+ }
+ }
+ }
+ }
+ pc->state= state;
+ return END_NOT_FOUND;
+}
+
/* handle buffering and image synchronisation */
static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
- uint8_t *buf_end, *buf_ptr, *buf_start;
- int len, start_code_found, ret, code, start_code, input_size;
+ uint8_t *buf_end, *buf_ptr;
+ int ret, start_code, input_size;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
-
dprintf("fill_buffer\n");
*data_size = 0;
@@ -2192,6 +2224,13 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
return 0;
}
+ if(s2->flags&CODEC_FLAG_TRUNCATED){
+ int next= mpeg1_find_frame_end(s2, buf, buf_size);
+
+ if( ff_combine_frame(s2, next, &buf, &buf_size) < 0 )
+ return buf_size;
+ }
+
buf_ptr = buf;
buf_end = buf + buf_size;
@@ -2206,60 +2245,42 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
}
}
#endif
- while (buf_ptr < buf_end) {
- buf_start = buf_ptr;
+ for(;;) {
/* find start next code */
- code = find_start_code(&buf_ptr, buf_end, &s->header_state);
- if (code >= 0) {
- start_code_found = 1;
- } else {
- start_code_found = 0;
- }
- /* copy to buffer */
- len = buf_ptr - buf_start;
- if (len + (s->buf_ptr - s->buffer) > s->buffer_size) {
- /* data too big : flush */
- s->buf_ptr = s->buffer;
- if (start_code_found)
- s->start_code = code;
- } else {
- memcpy(s->buf_ptr, buf_start, len);
- s->buf_ptr += len;
- if( (!(s2->flags&CODEC_FLAG_TRUNCATED)) && (!start_code_found)
- && s->buf_ptr+4<s->buffer+s->buffer_size){
- start_code_found= 1;
- code= 0x1FF;
- s->header_state=0xFF;
- s->buf_ptr[0]=0;
- s->buf_ptr[1]=0;
- s->buf_ptr[2]=1;
- s->buf_ptr[3]=0xFF;
- s->buf_ptr+=4;
+ start_code = find_start_code(&buf_ptr, buf_end);
+ if (start_code < 0){
+ if (slice_end(avctx, picture)) {
+ if(s2->last_picture_ptr) //FIXME merge with the stuff in mpeg_decode_slice
+ *data_size = sizeof(AVPicture);
}
- if (start_code_found) {
+ return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
+ }
+
+ input_size = buf_end - buf_ptr;
+
+ if(avctx->debug & FF_DEBUG_STARTCODE){
+ printf("%3X at %d left %d\n", start_code, buf_ptr-buf, input_size);
+ }
+
/* prepare data for next start code */
- input_size = s->buf_ptr - s->buffer;
- start_code = s->start_code;
- s->buf_ptr = s->buffer;
- s->start_code = code;
switch(start_code) {
case SEQ_START_CODE:
- mpeg1_decode_sequence(avctx, s->buffer,
+ mpeg1_decode_sequence(avctx, buf_ptr,
input_size);
break;
case PICTURE_START_CODE:
/* we have a complete image : we try to decompress it */
mpeg1_decode_picture(avctx,
- s->buffer, input_size);
+ buf_ptr, input_size);
break;
case EXT_START_CODE:
mpeg_decode_extension(avctx,
- s->buffer, input_size);
+ buf_ptr, input_size);
break;
case USER_START_CODE:
mpeg_decode_user_data(avctx,
- s->buffer, input_size);
+ buf_ptr, input_size);
break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
@@ -2271,30 +2292,24 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
if(avctx->hurry_up && s2->pict_type==B_TYPE) break;
/* skip everything if we are in a hurry>=5 */
if(avctx->hurry_up>=5) break;
-
+
if (!s->mpeg_enc_ctx_allocated) break;
ret = mpeg_decode_slice(avctx, picture,
- start_code, s->buffer, input_size);
+ start_code, &buf_ptr, input_size);
+ emms_c();
- if (ret == DECODE_SLICE_EOP) {
- *data_size = sizeof(AVPicture);
- goto the_end;
- }else if(ret < 0){
- if(ret == DECODE_SLICE_ERROR)
+ if(ret < 0){
+ if(s2->resync_mb_x>=0 && s2->resync_mb_y>=0)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
-
- fprintf(stderr,"Error while decoding slice\n");
- if(ret==DECODE_SLICE_FATAL_ERROR) return -1;
+ if(ret==DECODE_SLICE_FATAL_ERROR) return -1;
+ }else{
+ ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, AC_END|DC_END|MV_END);
}
}
break;
}
- }
- }
}
- the_end:
- return buf_ptr - buf;
}
static int mpeg_decode_end(AVCodecContext *avctx)
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c
index 46d29c8db..d263c46d5 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.c
+++ b/src/libffmpeg/libavcodec/mpegvideo.c
@@ -136,7 +136,7 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16
}
#endif //CONFIG_ENCODERS
-void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable){
+void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
int i;
int end;
@@ -145,7 +145,7 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scan
for(i=0; i<64; i++){
int j;
j = src_scantable[i];
- st->permutated[i] = s->dsp.idct_permutation[j];
+ st->permutated[i] = permutation[j];
#ifdef ARCH_POWERPC
st->inverse[j] = i;
#endif
@@ -202,10 +202,10 @@ int DCT_common_init(MpegEncContext *s)
/* load & permutate scantables
note: only wmv uses differnt ones
*/
- ff_init_scantable(s, &s->inter_scantable , ff_zigzag_direct);
- ff_init_scantable(s, &s->intra_scantable , ff_zigzag_direct);
- ff_init_scantable(s, &s->intra_h_scantable, ff_alternate_horizontal_scan);
- ff_init_scantable(s, &s->intra_v_scantable, ff_alternate_vertical_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
s->picture_structure= PICT_FRAME;
@@ -1066,6 +1066,84 @@ void MPV_frame_end(MpegEncContext *s)
}
/**
+ * draws an line from (ex, ey) -> (sx, sy).
+ * @param w width of the image
+ * @param h height of the image
+ * @param stride stride/linesize of the image
+ * @param color color of the arrow
+ */
+static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
+ int t, x, y, 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);
+
+ buf[sy*stride + sx]+= color;
+
+ if(ABS(ex - sx) > ABS(ey - sy)){
+ if(sx > ex){
+ t=sx; sx=ex; ex=t;
+ t=sy; sy=ey; ey=t;
+ }
+ buf+= sx + sy*stride;
+ ex-= sx;
+ f= ((ey-sy)<<16)/ex;
+ for(x= 0; x <= ex; x++){
+ y= ((x*f) + (1<<15))>>16;
+ buf[y*stride + x]+= color;
+ }
+ }else{
+ if(sy > ey){
+ t=sx; sx=ex; ex=t;
+ t=sy; sy=ey; ey=t;
+ }
+ buf+= sx + sy*stride;
+ ey-= sy;
+ if(ey) f= ((ex-sx)<<16)/ey;
+ else f= 0;
+ for(y= 0; y <= ey; y++){
+ x= ((y*f) + (1<<15))>>16;
+ buf[y*stride + x]+= color;
+ }
+ }
+}
+
+/**
+ * draws an arrow from (ex, ey) -> (sx, sy).
+ * @param w width of the image
+ * @param h height of the image
+ * @param stride stride/linesize of the image
+ * @param color color of the arrow
+ */
+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);
+
+ dx= ex - sx;
+ dy= ey - sy;
+
+ if(dx*dx + dy*dy > 3*3){
+ int rx= dx + dy;
+ int ry= -dx + dy;
+ int length= ff_sqrt((rx*rx + ry*ry)<<8);
+
+ //FIXME subpixel accuracy
+ rx= ROUNDED_DIV(rx*3<<4, length);
+ ry= ROUNDED_DIV(ry*3<<4, length);
+
+ draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
+ draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
+ }
+ draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
+}
+
+/**
* prints debuging info for the given picture.
*/
void ff_print_debug_info(MpegEncContext *s, Picture *pict){
@@ -1139,6 +1217,39 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){
printf("\n");
}
}
+
+ if((s->avctx->debug&FF_DEBUG_VIS_MV) && s->motion_val){
+ const int shift= 1 + s->quarter_sample;
+ int mb_y;
+ uint8_t *ptr= pict->data[0];
+ s->low_delay=0; //needed to see the vectors without trashing the buffers
+
+ for(mb_y=0; mb_y<s->mb_height; mb_y++){
+ int mb_x;
+ for(mb_x=0; mb_x<s->mb_width; mb_x++){
+ const int mb_index= mb_x + mb_y*s->mb_stride;
+ if(IS_8X8(s->current_picture.mb_type[mb_index])){
+ int i;
+ for(i=0; i<4; i++){
+ int sx= mb_x*16 + 4 + 8*(i&1);
+ int sy= mb_y*16 + 4 + 8*(i>>1);
+ int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2);
+ int mx= (s->motion_val[xy][0]>>shift) + sx;
+ int my= (s->motion_val[xy][1]>>shift) + sy;
+ draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
+ }
+ }else{
+ int sx= mb_x*16 + 8;
+ int sy= mb_y*16 + 8;
+ int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2);
+ int mx= (s->motion_val[xy][0]>>shift) + sx;
+ int my= (s->motion_val[xy][1]>>shift) + sy;
+ draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
+ }
+ s->mbskip_table[mb_index]=0;
+ }
+ }
+ }
}
#ifdef CONFIG_ENCODERS
@@ -2817,7 +2928,8 @@ int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size)
pc->index += *buf_size;
return -1;
}
-
+
+ *buf_size=
pc->overread_index= pc->index + next;
/* append to buffer */
@@ -2827,7 +2939,6 @@ int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size)
memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
pc->index = 0;
*buf= pc->buffer;
- *buf_size= pc->last_index + next;
}
/* store overread bytes */
@@ -4113,18 +4224,6 @@ static void dct_unquantize_h263_c(MpegEncContext *s,
}
-char ff_get_pict_type_char(int pict_type){
- switch(pict_type){
- case I_TYPE: return 'I';
- case P_TYPE: return 'P';
- case B_TYPE: return 'B';
- case S_TYPE: return 'S';
- case SI_TYPE:return 'i';
- case SP_TYPE:return 'p';
- default: return '?';
- }
-}
-
static const AVOption mpeg4_options[] =
{
AVOPTION_CODEC_INT("bitrate", "desired video bitrate", bit_rate, 4, 240000000, 800000),
diff --git a/src/libffmpeg/libavcodec/mpegvideo.h b/src/libffmpeg/libavcodec/mpegvideo.h
index 2cbc0ef19..c09b6a6f3 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.h
+++ b/src/libffmpeg/libavcodec/mpegvideo.h
@@ -706,11 +706,10 @@ void MPV_common_init_ppc(MpegEncContext *s);
extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length);
void ff_clean_intra_table_entries(MpegEncContext *s);
-void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable);
+void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h,
int src_x, int src_y, int w, int h);
-char ff_get_pict_type_char(int pict_type);
#define END_NOT_FOUND -100
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
void ff_print_debug_info(MpegEncContext *s, Picture *pict);
diff --git a/src/libffmpeg/libavcodec/msmpeg4.c b/src/libffmpeg/libavcodec/msmpeg4.c
index 817fdeaf3..72481e325 100644
--- a/src/libffmpeg/libavcodec/msmpeg4.c
+++ b/src/libffmpeg/libavcodec/msmpeg4.c
@@ -78,8 +78,6 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
-extern uint32_t inverse[256];
-
#ifdef DEBUG
int intra_count = 0;
@@ -182,10 +180,10 @@ static void common_init(MpegEncContext * s)
if(s->msmpeg4_version>=4){
- ff_init_scantable(s, &s->intra_scantable , wmv1_scantable[1]);
- ff_init_scantable(s, &s->intra_h_scantable, wmv1_scantable[2]);
- ff_init_scantable(s, &s->intra_v_scantable, wmv1_scantable[3]);
- ff_init_scantable(s, &s->inter_scantable , wmv1_scantable[0]);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , wmv1_scantable[1]);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, wmv1_scantable[2]);
+ ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, wmv1_scantable[3]);
+ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , wmv1_scantable[0]);
}
//Note the default tables are set in common_init in mpegvideo.c
@@ -550,6 +548,7 @@ void msmpeg4_encode_mb(MpegEncContext * s,
put_bits(&s->pb, 1, 1);
s->last_bits++;
s->misc_bits++;
+ s->skip_count++;
return;
}
@@ -652,6 +651,7 @@ void msmpeg4_encode_mb(MpegEncContext * s,
msmpeg4_encode_block(s, block[i], i);
}
s->i_tex_bits += get_bits_diff(s);
+ s->i_count++;
}
}
@@ -697,7 +697,7 @@ static int get_dc(uint8_t *src, int stride, int scale)
sum+=src[x + y*stride];
}
}
- return (sum + (scale>>1))/scale;
+ return FASTDIV((sum + (scale>>1)), scale);
}
/* dir = 0: left, dir = 1: top prediction */
@@ -761,9 +761,9 @@ static inline int msmpeg4_pred_dc(MpegEncContext * s, int n,
b = (b + (8 >> 1)) / 8;
c = (c + (8 >> 1)) / 8;
} else {
- a = (a + (scale >> 1)) / scale;
- b = (b + (scale >> 1)) / scale;
- c = (c + (scale >> 1)) / scale;
+ a = FASTDIV((a + (scale >> 1)), scale);
+ b = FASTDIV((b + (scale >> 1)), scale);
+ c = FASTDIV((c + (scale >> 1)), scale);
}
#endif
/* XXX: WARNING: they did not choose the same test as MPEG4. This
@@ -1479,10 +1479,12 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
return pred;
sign = get_bits1(&s->gb);
shift = f_code - 1;
- val = (code - 1) << shift;
- if (shift > 0)
+ val = code;
+ if (shift) {
+ val = (val - 1) << shift;
val |= get_bits(&s->gb, shift);
- val++;
+ val++;
+ }
if (sign)
val = -val;
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
index d48332ba9..32e881b70 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -19,6 +19,9 @@
*/
#include "../dsputil.h"
+
+#include "gcc_fixes.h"
+
#include "dsputil_altivec.h"
#ifdef CONFIG_DARWIN
@@ -303,11 +306,8 @@ int pix_abs8x8_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
vector signed int sumdiffs;
sad = (vector unsigned int)vec_splat_u32(0);
-#ifdef CONFIG_DARWIN
- permclear = (vector unsigned char)(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
-#else
- permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
-#endif
+
+ permclear = (vector unsigned char)AVV(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
for(i=0;i<8;i++) {
/* Read potentially unaligned pixels into t1 and t2
@@ -387,11 +387,9 @@ int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
vector signed int sumsqr;
sum = (vector unsigned int)vec_splat_u32(0);
-#ifdef CONFIG_DARWIN
- permclear = (vector unsigned char)(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
-#else
- permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
-#endif
+
+ permclear = (vector unsigned char)AVV(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
+
for(i=0;i<8;i++) {
/* Read potentially unaligned pixels into t1 and t2
diff --git a/src/libffmpeg/libavcodec/ppc/fft_altivec.c b/src/libffmpeg/libavcodec/ppc/fft_altivec.c
index 992be5b8e..75c95bb87 100644
--- a/src/libffmpeg/libavcodec/ppc/fft_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/fft_altivec.c
@@ -20,6 +20,8 @@
*/
#include "../dsputil.h"
+#include "gcc_fixes.h"
+
#include "dsputil_altivec.h"
/*
diff --git a/src/libffmpeg/libavcodec/ppc/gcc_fixes.h b/src/libffmpeg/libavcodec/ppc/gcc_fixes.h
new file mode 100644
index 000000000..855a5b4f7
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ppc/gcc_fixes.h
@@ -0,0 +1,85 @@
+/*
+ * gcc fixes for altivec.
+ * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3)
+ * and to stay somewhat compatible with Darwin.
+ */
+
+#ifndef _GCC_FIXES_
+#define _GCC_FIXES_
+
+#ifdef HAVE_ALTIVEC_H
+#include <altivec.h>
+#endif
+
+#ifdef CONFIG_DARWIN
+#define AVV(x...) (x)
+#else
+#define AVV(x...) {x}
+
+#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
+
+/* This code was provided to me by Bartosch Pixa
+ * as a separate header file (broken_mergel.h).
+ * thanks to lu_zero for the workaround.
+ *
+ * See this mail for more information:
+ * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
+ */
+
+static inline vector signed char my_vmrglb (vector signed char const A,
+ vector signed char const B)
+{
+ static const vector unsigned char lowbyte = {
+ 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
+ 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
+ };
+ return vec_perm (A, B, lowbyte);
+}
+
+static inline vector signed short my_vmrglh (vector signed short const A,
+ vector signed short const B)
+{
+ static const vector unsigned char lowhalf = {
+ 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
+ 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
+ };
+ return vec_perm (A, B, lowhalf);
+}
+
+static inline vector signed int my_vmrglw (vector signed int const A,
+ vector signed int const B)
+{
+ static const vector unsigned char lowword = {
+ 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
+ 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
+ };
+ return vec_perm (A, B, lowword);
+}
+/*#define my_vmrglb my_vmrglb
+#define my_vmrglh my_vmrglh
+#define my_vmrglw my_vmrglw
+*/
+#undef vec_mergel
+
+#define vec_mergel(a1, a2) \
+__ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
+ ((vector signed char) my_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
+__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
+ ((vector unsigned char) my_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
+__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
+ ((vector signed short) my_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
+__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
+ ((vector unsigned short) my_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
+__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
+ ((vector float) my_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
+__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
+ ((vector signed int) my_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
+__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
+ ((vector unsigned int) my_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
+ __altivec_link_error_invalid_argument ())))))))
+
+#endif
+
+#endif /* CONFIG_DARWIN */
+
+#endif /* _GCC_FIXES_ */
diff --git a/src/libffmpeg/libavcodec/ppc/gmc_altivec.c b/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
index 515a766d7..18d52bbc5 100644
--- a/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/gmc_altivec.c
@@ -20,6 +20,8 @@
#include "../dsputil.h"
+#include "gcc_fixes.h"
+
#include "dsputil_altivec.h"
/*
diff --git a/src/libffmpeg/libavcodec/ppc/idct_altivec.c b/src/libffmpeg/libavcodec/ppc/idct_altivec.c
index 13df78f32..f8a8aa678 100644
--- a/src/libffmpeg/libavcodec/ppc/idct_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/idct_altivec.c
@@ -38,6 +38,9 @@
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#include "../dsputil.h"
+
+#include "gcc_fixes.h"
+
#include "dsputil_altivec.h"
#define vector_s16_t vector signed short
@@ -152,24 +155,13 @@
vx7 = vec_sra (vy7, shift);
-#ifdef CONFIG_DARWIN
-static const vector_s16_t constants[5] = {
- (vector_s16_t)(23170, 13573, 6518, 21895, -23170, -21895, 32, 31),
- (vector_s16_t)(16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725),
- (vector_s16_t)(22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521),
- (vector_s16_t)(21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692),
- (vector_s16_t)(19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722)
-};
-#else
-// broken gcc
static const vector_s16_t constants[5] = {
- (vector_s16_t){23170, 13573, 6518, 21895, -23170, -21895, 32, 31},
- (vector_s16_t){16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725},
- (vector_s16_t){22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521},
- (vector_s16_t){21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692},
- (vector_s16_t){19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722}
+ (vector_s16_t) AVV(23170, 13573, 6518, 21895, -23170, -21895, 32, 31),
+ (vector_s16_t) AVV(16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725),
+ (vector_s16_t) AVV(22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521),
+ (vector_s16_t) AVV(21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692),
+ (vector_s16_t) AVV(19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722)
};
-#endif
void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)
{
diff --git a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
index 95558a6be..bbf9c4433 100644
--- a/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/mpegvideo_altivec.c
@@ -15,11 +15,14 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
#include <stdlib.h>
#include <stdio.h>
#include "../dsputil.h"
#include "../mpegvideo.h"
+
+#include "gcc_fixes.h"
+
#include "dsputil_altivec.h"
// Swaps two variables (used for altivec registers)
diff --git a/src/libffmpeg/libavcodec/ra144.c b/src/libffmpeg/libavcodec/ra144.c
new file mode 100644
index 000000000..443db6e87
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ra144.c
@@ -0,0 +1,2918 @@
+/*
+ * Real Audio 1.0 (14.4K)
+ * Copyright (c) 2003 the ffmpeg project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "avcodec.h"
+
+#define DATABLOCK1 20 /* size of 14.4 input block in bytes */
+#define DATACHUNK1 1440 /* size of 14.4 input chunk in bytes */
+#define AUDIOBLOCK 160 /* size of output block in 16-bit words (320 bytes) */
+#define AUDIOBUFFER 12288 /* size of output buffer in 16-bit words (24576 bytes) */
+/* consts */
+#define NBLOCKS 4 /* number of segments within a block */
+#define BLOCKSIZE 40 /* (quarter) block size in 16-bit words (80 bytes) */
+#define HALFBLOCK 20 /* BLOCKSIZE/2 */
+#define BUFFERSIZE 146 /* for do_output */
+
+
+/* internal globals */
+typedef struct {
+ unsigned int resetflag, val, oldval;
+ unsigned int unpacked[28]; /* buffer for unpacked input */
+ unsigned int *iptr; /* pointer to current input (from unpacked) */
+ unsigned int gval;
+ unsigned short *gsp;
+ unsigned int gbuf1[8];
+ unsigned short gbuf2[120];
+ signed short output_buffer[40];
+ unsigned int *decptr; /* decoder ptr */
+ signed short *decsp;
+
+ /* the swapped buffers */
+ unsigned int swapb1a[10];
+ unsigned int swapb2a[10];
+ unsigned int swapb1b[10];
+ unsigned int swapb2b[10];
+ unsigned int *swapbuf1;
+ unsigned int *swapbuf2;
+ unsigned int *swapbuf1alt;
+ unsigned int *swapbuf2alt;
+
+ unsigned int buffer[5];
+ unsigned short int buffer_2[148];
+ unsigned short int buffer_a[40];
+ unsigned short int buffer_b[40];
+ unsigned short int buffer_c[40];
+ unsigned short int buffer_d[40];
+
+ unsigned short int work[50];
+ unsigned short *sptr;
+
+ int buffer1[10];
+ int buffer2[10];
+
+ signed short wavtable1[2304];
+ unsigned short wavtable2[2304];
+} Real144_internal;
+
+/* 14.4 data tables */
+const unsigned short sqrt_table[4096]={
+0x0000,0x0400,0x05a8,0x06ed,0x0800,0x08f1,0x09cc,0x0a95,
+0x0b50,0x0c00,0x0ca6,0x0d44,0x0ddb,0x0e6c,0x0ef7,0x0f7d,
+0x1000,0x107e,0x10f8,0x116f,0x11e3,0x1254,0x12c2,0x132e,
+0x1398,0x1400,0x1465,0x14c8,0x152a,0x158a,0x15e8,0x1645,
+0x16a0,0x16fa,0x1752,0x17aa,0x1800,0x1854,0x18a8,0x18fa,
+0x194c,0x199c,0x19ec,0x1a3a,0x1a88,0x1ad5,0x1b21,0x1b6c,
+0x1bb6,0x1c00,0x1c48,0x1c90,0x1cd8,0x1d1e,0x1d64,0x1daa,
+0x1dee,0x1e33,0x1e76,0x1eb9,0x1efb,0x1f3d,0x1f7e,0x1fbf,
+0x2000,0x203f,0x207f,0x20bd,0x20fc,0x2139,0x2177,0x21b4,
+0x21f0,0x222d,0x2268,0x22a4,0x22df,0x2319,0x2353,0x238d,
+0x23c6,0x2400,0x2438,0x2471,0x24a9,0x24e0,0x2518,0x254f,
+0x2585,0x25bc,0x25f2,0x2628,0x265d,0x2693,0x26c8,0x26fc,
+0x2731,0x2765,0x2799,0x27cc,0x2800,0x2833,0x2865,0x2898,
+0x28ca,0x28fc,0x292e,0x2960,0x2991,0x29c2,0x29f3,0x2a24,
+0x2a54,0x2a85,0x2ab5,0x2ae5,0x2b14,0x2b44,0x2b73,0x2ba2,
+0x2bd1,0x2c00,0x2c2e,0x2c5c,0x2c8a,0x2cb8,0x2ce6,0x2d13,
+0x2d41,0x2d6e,0x2d9b,0x2dc8,0x2df4,0x2e21,0x2e4d,0x2e79,
+0x2ea5,0x2ed1,0x2efd,0x2f28,0x2f54,0x2f7f,0x2faa,0x2fd5,
+0x3000,0x302a,0x3055,0x307f,0x30a9,0x30d3,0x30fd,0x3127,
+0x3150,0x317a,0x31a3,0x31cc,0x31f5,0x321e,0x3247,0x3270,
+0x3298,0x32c1,0x32e9,0x3311,0x3339,0x3361,0x3389,0x33b0,
+0x33d8,0x3400,0x3427,0x344e,0x3475,0x349c,0x34c3,0x34ea,
+0x3510,0x3537,0x355d,0x3584,0x35aa,0x35d0,0x35f6,0x361c,
+0x3642,0x3667,0x368d,0x36b2,0x36d8,0x36fd,0x3722,0x3747,
+0x376c,0x3791,0x37b6,0x37db,0x3800,0x3824,0x3848,0x386d,
+0x3891,0x38b5,0x38d9,0x38fd,0x3921,0x3945,0x3969,0x398c,
+0x39b0,0x39d3,0x39f7,0x3a1a,0x3a3d,0x3a60,0x3a83,0x3aa6,
+0x3ac9,0x3aec,0x3b0f,0x3b31,0x3b54,0x3b76,0x3b99,0x3bbb,
+0x3bdd,0x3c00,0x3c22,0x3c44,0x3c66,0x3c87,0x3ca9,0x3ccb,
+0x3ced,0x3d0e,0x3d30,0x3d51,0x3d72,0x3d94,0x3db5,0x3dd6,
+0x3df7,0x3e18,0x3e39,0x3e5a,0x3e7b,0x3e9c,0x3ebc,0x3edd,
+0x3efd,0x3f1e,0x3f3e,0x3f5f,0x3f7f,0x3f9f,0x3fbf,0x3fdf,
+0x4000,0x401f,0x403f,0x405f,0x407f,0x409f,0x40be,0x40de,
+0x40fe,0x411d,0x413c,0x415c,0x417b,0x419a,0x41ba,0x41d9,
+0x41f8,0x4217,0x4236,0x4255,0x4273,0x4292,0x42b1,0x42d0,
+0x42ee,0x430d,0x432b,0x434a,0x4368,0x4387,0x43a5,0x43c3,
+0x43e1,0x4400,0x441e,0x443c,0x445a,0x4478,0x4495,0x44b3,
+0x44d1,0x44ef,0x450c,0x452a,0x4548,0x4565,0x4583,0x45a0,
+0x45be,0x45db,0x45f8,0x4615,0x4633,0x4650,0x466d,0x468a,
+0x46a7,0x46c4,0x46e1,0x46fe,0x471b,0x4737,0x4754,0x4771,
+0x478d,0x47aa,0x47c7,0x47e3,0x4800,0x481c,0x4838,0x4855,
+0x4871,0x488d,0x48a9,0x48c6,0x48e2,0x48fe,0x491a,0x4936,
+0x4952,0x496e,0x498a,0x49a5,0x49c1,0x49dd,0x49f9,0x4a14,
+0x4a30,0x4a4b,0x4a67,0x4a83,0x4a9e,0x4ab9,0x4ad5,0x4af0,
+0x4b0b,0x4b27,0x4b42,0x4b5d,0x4b78,0x4b93,0x4bae,0x4bca,
+0x4be5,0x4c00,0x4c1a,0x4c35,0x4c50,0x4c6b,0x4c86,0x4ca1,
+0x4cbb,0x4cd6,0x4cf1,0x4d0b,0x4d26,0x4d40,0x4d5b,0x4d75,
+0x4d90,0x4daa,0x4dc4,0x4ddf,0x4df9,0x4e13,0x4e2d,0x4e48,
+0x4e62,0x4e7c,0x4e96,0x4eb0,0x4eca,0x4ee4,0x4efe,0x4f18,
+0x4f32,0x4f4c,0x4f65,0x4f7f,0x4f99,0x4fb3,0x4fcc,0x4fe6,
+0x5000,0x5019,0x5033,0x504c,0x5066,0x507f,0x5099,0x50b2,
+0x50cb,0x50e5,0x50fe,0x5117,0x5130,0x514a,0x5163,0x517c,
+0x5195,0x51ae,0x51c7,0x51e0,0x51f9,0x5212,0x522b,0x5244,
+0x525d,0x5276,0x528f,0x52a7,0x52c0,0x52d9,0x52f2,0x530a,
+0x5323,0x533c,0x5354,0x536d,0x5385,0x539e,0x53b6,0x53cf,
+0x53e7,0x5400,0x5418,0x5430,0x5449,0x5461,0x5479,0x5491,
+0x54a9,0x54c2,0x54da,0x54f2,0x550a,0x5522,0x553a,0x5552,
+0x556a,0x5582,0x559a,0x55b2,0x55ca,0x55e2,0x55fa,0x5611,
+0x5629,0x5641,0x5659,0x5670,0x5688,0x56a0,0x56b7,0x56cf,
+0x56e6,0x56fe,0x5716,0x572d,0x5745,0x575c,0x5773,0x578b,
+0x57a2,0x57ba,0x57d1,0x57e8,0x5800,0x5817,0x582e,0x5845,
+0x585c,0x5874,0x588b,0x58a2,0x58b9,0x58d0,0x58e7,0x58fe,
+0x5915,0x592c,0x5943,0x595a,0x5971,0x5988,0x599f,0x59b5,
+0x59cc,0x59e3,0x59fa,0x5a11,0x5a27,0x5a3e,0x5a55,0x5a6b,
+0x5a82,0x5a99,0x5aaf,0x5ac6,0x5adc,0x5af3,0x5b09,0x5b20,
+0x5b36,0x5b4d,0x5b63,0x5b7a,0x5b90,0x5ba6,0x5bbd,0x5bd3,
+0x5be9,0x5c00,0x5c16,0x5c2c,0x5c42,0x5c58,0x5c6f,0x5c85,
+0x5c9b,0x5cb1,0x5cc7,0x5cdd,0x5cf3,0x5d09,0x5d1f,0x5d35,
+0x5d4b,0x5d61,0x5d77,0x5d8d,0x5da3,0x5db9,0x5dce,0x5de4,
+0x5dfa,0x5e10,0x5e26,0x5e3b,0x5e51,0x5e67,0x5e7c,0x5e92,
+0x5ea8,0x5ebd,0x5ed3,0x5ee9,0x5efe,0x5f14,0x5f29,0x5f3f,
+0x5f54,0x5f6a,0x5f7f,0x5f95,0x5faa,0x5fbf,0x5fd5,0x5fea,
+0x6000,0x6015,0x602a,0x603f,0x6055,0x606a,0x607f,0x6094,
+0x60aa,0x60bf,0x60d4,0x60e9,0x60fe,0x6113,0x6128,0x613d,
+0x6152,0x6168,0x617d,0x6192,0x61a7,0x61bb,0x61d0,0x61e5,
+0x61fa,0x620f,0x6224,0x6239,0x624e,0x6263,0x6277,0x628c,
+0x62a1,0x62b6,0x62ca,0x62df,0x62f4,0x6309,0x631d,0x6332,
+0x6347,0x635b,0x6370,0x6384,0x6399,0x63ad,0x63c2,0x63d7,
+0x63eb,0x6400,0x6414,0x6428,0x643d,0x6451,0x6466,0x647a,
+0x648e,0x64a3,0x64b7,0x64cb,0x64e0,0x64f4,0x6508,0x651d,
+0x6531,0x6545,0x6559,0x656e,0x6582,0x6596,0x65aa,0x65be,
+0x65d2,0x65e6,0x65fa,0x660f,0x6623,0x6637,0x664b,0x665f,
+0x6673,0x6687,0x669b,0x66af,0x66c3,0x66d6,0x66ea,0x66fe,
+0x6712,0x6726,0x673a,0x674e,0x6761,0x6775,0x6789,0x679d,
+0x67b1,0x67c4,0x67d8,0x67ec,0x6800,0x6813,0x6827,0x683b,
+0x684e,0x6862,0x6875,0x6889,0x689d,0x68b0,0x68c4,0x68d7,
+0x68eb,0x68fe,0x6912,0x6925,0x6939,0x694c,0x6960,0x6973,
+0x6986,0x699a,0x69ad,0x69c1,0x69d4,0x69e7,0x69fb,0x6a0e,
+0x6a21,0x6a35,0x6a48,0x6a5b,0x6a6e,0x6a82,0x6a95,0x6aa8,
+0x6abb,0x6ace,0x6ae2,0x6af5,0x6b08,0x6b1b,0x6b2e,0x6b41,
+0x6b54,0x6b67,0x6b7a,0x6b8d,0x6ba1,0x6bb4,0x6bc7,0x6bda,
+0x6bed,0x6c00,0x6c12,0x6c25,0x6c38,0x6c4b,0x6c5e,0x6c71,
+0x6c84,0x6c97,0x6caa,0x6cbc,0x6ccf,0x6ce2,0x6cf5,0x6d08,
+0x6d1a,0x6d2d,0x6d40,0x6d53,0x6d65,0x6d78,0x6d8b,0x6d9e,
+0x6db0,0x6dc3,0x6dd6,0x6de8,0x6dfb,0x6e0d,0x6e20,0x6e33,
+0x6e45,0x6e58,0x6e6a,0x6e7d,0x6e8f,0x6ea2,0x6eb4,0x6ec7,
+0x6ed9,0x6eec,0x6efe,0x6f11,0x6f23,0x6f36,0x6f48,0x6f5a,
+0x6f6d,0x6f7f,0x6f92,0x6fa4,0x6fb6,0x6fc9,0x6fdb,0x6fed,
+0x7000,0x7012,0x7024,0x7036,0x7049,0x705b,0x706d,0x707f,
+0x7091,0x70a4,0x70b6,0x70c8,0x70da,0x70ec,0x70fe,0x7110,
+0x7123,0x7135,0x7147,0x7159,0x716b,0x717d,0x718f,0x71a1,
+0x71b3,0x71c5,0x71d7,0x71e9,0x71fb,0x720d,0x721f,0x7231,
+0x7243,0x7255,0x7267,0x7279,0x728a,0x729c,0x72ae,0x72c0,
+0x72d2,0x72e4,0x72f5,0x7307,0x7319,0x732b,0x733d,0x734e,
+0x7360,0x7372,0x7384,0x7395,0x73a7,0x73b9,0x73ca,0x73dc,
+0x73ee,0x7400,0x7411,0x7423,0x7434,0x7446,0x7458,0x7469,
+0x747b,0x748c,0x749e,0x74b0,0x74c1,0x74d3,0x74e4,0x74f6,
+0x7507,0x7519,0x752a,0x753c,0x754d,0x755f,0x7570,0x7581,
+0x7593,0x75a4,0x75b6,0x75c7,0x75d8,0x75ea,0x75fb,0x760d,
+0x761e,0x762f,0x7641,0x7652,0x7663,0x7674,0x7686,0x7697,
+0x76a8,0x76ba,0x76cb,0x76dc,0x76ed,0x76fe,0x7710,0x7721,
+0x7732,0x7743,0x7754,0x7766,0x7777,0x7788,0x7799,0x77aa,
+0x77bb,0x77cc,0x77dd,0x77ee,0x7800,0x7811,0x7822,0x7833,
+0x7844,0x7855,0x7866,0x7877,0x7888,0x7899,0x78aa,0x78bb,
+0x78cc,0x78dd,0x78ee,0x78fe,0x790f,0x7920,0x7931,0x7942,
+0x7953,0x7964,0x7975,0x7986,0x7996,0x79a7,0x79b8,0x79c9,
+0x79da,0x79eb,0x79fb,0x7a0c,0x7a1d,0x7a2e,0x7a3e,0x7a4f,
+0x7a60,0x7a71,0x7a81,0x7a92,0x7aa3,0x7ab3,0x7ac4,0x7ad5,
+0x7ae5,0x7af6,0x7b07,0x7b17,0x7b28,0x7b39,0x7b49,0x7b5a,
+0x7b6b,0x7b7b,0x7b8c,0x7b9c,0x7bad,0x7bbd,0x7bce,0x7bde,
+0x7bef,0x7c00,0x7c10,0x7c21,0x7c31,0x7c41,0x7c52,0x7c62,
+0x7c73,0x7c83,0x7c94,0x7ca4,0x7cb5,0x7cc5,0x7cd5,0x7ce6,
+0x7cf6,0x7d07,0x7d17,0x7d27,0x7d38,0x7d48,0x7d58,0x7d69,
+0x7d79,0x7d89,0x7d9a,0x7daa,0x7dba,0x7dcb,0x7ddb,0x7deb,
+0x7dfb,0x7e0c,0x7e1c,0x7e2c,0x7e3c,0x7e4d,0x7e5d,0x7e6d,
+0x7e7d,0x7e8d,0x7e9e,0x7eae,0x7ebe,0x7ece,0x7ede,0x7eee,
+0x7efe,0x7f0f,0x7f1f,0x7f2f,0x7f3f,0x7f4f,0x7f5f,0x7f6f,
+0x7f7f,0x7f8f,0x7f9f,0x7faf,0x7fbf,0x7fcf,0x7fdf,0x7fef,
+0x8000,0x800f,0x801f,0x802f,0x803f,0x804f,0x805f,0x806f,
+0x807f,0x808f,0x809f,0x80af,0x80bf,0x80cf,0x80df,0x80ef,
+0x80ff,0x810e,0x811e,0x812e,0x813e,0x814e,0x815e,0x816d,
+0x817d,0x818d,0x819d,0x81ad,0x81bc,0x81cc,0x81dc,0x81ec,
+0x81fc,0x820b,0x821b,0x822b,0x823b,0x824a,0x825a,0x826a,
+0x8279,0x8289,0x8299,0x82a8,0x82b8,0x82c8,0x82d7,0x82e7,
+0x82f7,0x8306,0x8316,0x8326,0x8335,0x8345,0x8354,0x8364,
+0x8374,0x8383,0x8393,0x83a2,0x83b2,0x83c1,0x83d1,0x83e0,
+0x83f0,0x8400,0x840f,0x841f,0x842e,0x843e,0x844d,0x845c,
+0x846c,0x847b,0x848b,0x849a,0x84aa,0x84b9,0x84c9,0x84d8,
+0x84e7,0x84f7,0x8506,0x8516,0x8525,0x8534,0x8544,0x8553,
+0x8562,0x8572,0x8581,0x8591,0x85a0,0x85af,0x85be,0x85ce,
+0x85dd,0x85ec,0x85fc,0x860b,0x861a,0x862a,0x8639,0x8648,
+0x8657,0x8667,0x8676,0x8685,0x8694,0x86a3,0x86b3,0x86c2,
+0x86d1,0x86e0,0x86ef,0x86ff,0x870e,0x871d,0x872c,0x873b,
+0x874a,0x8759,0x8769,0x8778,0x8787,0x8796,0x87a5,0x87b4,
+0x87c3,0x87d2,0x87e1,0x87f0,0x8800,0x880f,0x881e,0x882d,
+0x883c,0x884b,0x885a,0x8869,0x8878,0x8887,0x8896,0x88a5,
+0x88b4,0x88c3,0x88d2,0x88e1,0x88f0,0x88ff,0x890e,0x891c,
+0x892b,0x893a,0x8949,0x8958,0x8967,0x8976,0x8985,0x8994,
+0x89a3,0x89b2,0x89c0,0x89cf,0x89de,0x89ed,0x89fc,0x8a0b,
+0x8a19,0x8a28,0x8a37,0x8a46,0x8a55,0x8a64,0x8a72,0x8a81,
+0x8a90,0x8a9f,0x8aad,0x8abc,0x8acb,0x8ada,0x8ae8,0x8af7,
+0x8b06,0x8b15,0x8b23,0x8b32,0x8b41,0x8b50,0x8b5e,0x8b6d,
+0x8b7c,0x8b8a,0x8b99,0x8ba8,0x8bb6,0x8bc5,0x8bd4,0x8be2,
+0x8bf1,0x8c00,0x8c0e,0x8c1d,0x8c2b,0x8c3a,0x8c49,0x8c57,
+0x8c66,0x8c74,0x8c83,0x8c91,0x8ca0,0x8caf,0x8cbd,0x8ccc,
+0x8cda,0x8ce9,0x8cf7,0x8d06,0x8d14,0x8d23,0x8d31,0x8d40,
+0x8d4e,0x8d5d,0x8d6b,0x8d7a,0x8d88,0x8d97,0x8da5,0x8db4,
+0x8dc2,0x8dd1,0x8ddf,0x8ded,0x8dfc,0x8e0a,0x8e19,0x8e27,
+0x8e36,0x8e44,0x8e52,0x8e61,0x8e6f,0x8e7d,0x8e8c,0x8e9a,
+0x8ea9,0x8eb7,0x8ec5,0x8ed4,0x8ee2,0x8ef0,0x8eff,0x8f0d,
+0x8f1b,0x8f2a,0x8f38,0x8f46,0x8f54,0x8f63,0x8f71,0x8f7f,
+0x8f8e,0x8f9c,0x8faa,0x8fb8,0x8fc7,0x8fd5,0x8fe3,0x8ff1,
+0x9000,0x900e,0x901c,0x902a,0x9038,0x9047,0x9055,0x9063,
+0x9071,0x907f,0x908d,0x909c,0x90aa,0x90b8,0x90c6,0x90d4,
+0x90e2,0x90f0,0x90ff,0x910d,0x911b,0x9129,0x9137,0x9145,
+0x9153,0x9161,0x916f,0x917e,0x918c,0x919a,0x91a8,0x91b6,
+0x91c4,0x91d2,0x91e0,0x91ee,0x91fc,0x920a,0x9218,0x9226,
+0x9234,0x9242,0x9250,0x925e,0x926c,0x927a,0x9288,0x9296,
+0x92a4,0x92b2,0x92c0,0x92ce,0x92dc,0x92ea,0x92f8,0x9306,
+0x9314,0x9321,0x932f,0x933d,0x934b,0x9359,0x9367,0x9375,
+0x9383,0x9391,0x939f,0x93ac,0x93ba,0x93c8,0x93d6,0x93e4,
+0x93f2,0x9400,0x940d,0x941b,0x9429,0x9437,0x9445,0x9452,
+0x9460,0x946e,0x947c,0x948a,0x9497,0x94a5,0x94b3,0x94c1,
+0x94cf,0x94dc,0x94ea,0x94f8,0x9506,0x9513,0x9521,0x952f,
+0x953c,0x954a,0x9558,0x9566,0x9573,0x9581,0x958f,0x959c,
+0x95aa,0x95b8,0x95c5,0x95d3,0x95e1,0x95ee,0x95fc,0x960a,
+0x9617,0x9625,0x9633,0x9640,0x964e,0x965c,0x9669,0x9677,
+0x9684,0x9692,0x96a0,0x96ad,0x96bb,0x96c8,0x96d6,0x96e4,
+0x96f1,0x96ff,0x970c,0x971a,0x9727,0x9735,0x9742,0x9750,
+0x975d,0x976b,0x9779,0x9786,0x9794,0x97a1,0x97af,0x97bc,
+0x97ca,0x97d7,0x97e5,0x97f2,0x9800,0x980d,0x981a,0x9828,
+0x9835,0x9843,0x9850,0x985e,0x986b,0x9879,0x9886,0x9893,
+0x98a1,0x98ae,0x98bc,0x98c9,0x98d6,0x98e4,0x98f1,0x98ff,
+0x990c,0x9919,0x9927,0x9934,0x9942,0x994f,0x995c,0x996a,
+0x9977,0x9984,0x9992,0x999f,0x99ac,0x99ba,0x99c7,0x99d4,
+0x99e2,0x99ef,0x99fc,0x9a09,0x9a17,0x9a24,0x9a31,0x9a3f,
+0x9a4c,0x9a59,0x9a66,0x9a74,0x9a81,0x9a8e,0x9a9b,0x9aa9,
+0x9ab6,0x9ac3,0x9ad0,0x9ade,0x9aeb,0x9af8,0x9b05,0x9b12,
+0x9b20,0x9b2d,0x9b3a,0x9b47,0x9b54,0x9b62,0x9b6f,0x9b7c,
+0x9b89,0x9b96,0x9ba3,0x9bb1,0x9bbe,0x9bcb,0x9bd8,0x9be5,
+0x9bf2,0x9c00,0x9c0d,0x9c1a,0x9c27,0x9c34,0x9c41,0x9c4e,
+0x9c5b,0x9c68,0x9c75,0x9c83,0x9c90,0x9c9d,0x9caa,0x9cb7,
+0x9cc4,0x9cd1,0x9cde,0x9ceb,0x9cf8,0x9d05,0x9d12,0x9d1f,
+0x9d2c,0x9d39,0x9d46,0x9d53,0x9d60,0x9d6d,0x9d7a,0x9d87,
+0x9d94,0x9da1,0x9dae,0x9dbb,0x9dc8,0x9dd5,0x9de2,0x9def,
+0x9dfc,0x9e09,0x9e16,0x9e23,0x9e30,0x9e3d,0x9e4a,0x9e57,
+0x9e64,0x9e71,0x9e7e,0x9e8b,0x9e98,0x9ea4,0x9eb1,0x9ebe,
+0x9ecb,0x9ed8,0x9ee5,0x9ef2,0x9eff,0x9f0c,0x9f18,0x9f25,
+0x9f32,0x9f3f,0x9f4c,0x9f59,0x9f66,0x9f72,0x9f7f,0x9f8c,
+0x9f99,0x9fa6,0x9fb3,0x9fbf,0x9fcc,0x9fd9,0x9fe6,0x9ff3,
+0xa000,0xa00c,0xa019,0xa026,0xa033,0xa03f,0xa04c,0xa059,
+0xa066,0xa073,0xa07f,0xa08c,0xa099,0xa0a6,0xa0b2,0xa0bf,
+0xa0cc,0xa0d9,0xa0e5,0xa0f2,0xa0ff,0xa10b,0xa118,0xa125,
+0xa132,0xa13e,0xa14b,0xa158,0xa164,0xa171,0xa17e,0xa18a,
+0xa197,0xa1a4,0xa1b0,0xa1bd,0xa1ca,0xa1d6,0xa1e3,0xa1f0,
+0xa1fc,0xa209,0xa216,0xa222,0xa22f,0xa23c,0xa248,0xa255,
+0xa261,0xa26e,0xa27b,0xa287,0xa294,0xa2a0,0xa2ad,0xa2ba,
+0xa2c6,0xa2d3,0xa2df,0xa2ec,0xa2f8,0xa305,0xa312,0xa31e,
+0xa32b,0xa337,0xa344,0xa350,0xa35d,0xa369,0xa376,0xa382,
+0xa38f,0xa39b,0xa3a8,0xa3b5,0xa3c1,0xa3ce,0xa3da,0xa3e7,
+0xa3f3,0xa400,0xa40c,0xa418,0xa425,0xa431,0xa43e,0xa44a,
+0xa457,0xa463,0xa470,0xa47c,0xa489,0xa495,0xa4a2,0xa4ae,
+0xa4ba,0xa4c7,0xa4d3,0xa4e0,0xa4ec,0xa4f9,0xa505,0xa511,
+0xa51e,0xa52a,0xa537,0xa543,0xa54f,0xa55c,0xa568,0xa574,
+0xa581,0xa58d,0xa59a,0xa5a6,0xa5b2,0xa5bf,0xa5cb,0xa5d7,
+0xa5e4,0xa5f0,0xa5fc,0xa609,0xa615,0xa621,0xa62e,0xa63a,
+0xa646,0xa653,0xa65f,0xa66b,0xa678,0xa684,0xa690,0xa69d,
+0xa6a9,0xa6b5,0xa6c1,0xa6ce,0xa6da,0xa6e6,0xa6f2,0xa6ff,
+0xa70b,0xa717,0xa724,0xa730,0xa73c,0xa748,0xa754,0xa761,
+0xa76d,0xa779,0xa785,0xa792,0xa79e,0xa7aa,0xa7b6,0xa7c3,
+0xa7cf,0xa7db,0xa7e7,0xa7f3,0xa800,0xa80c,0xa818,0xa824,
+0xa830,0xa83c,0xa849,0xa855,0xa861,0xa86d,0xa879,0xa885,
+0xa892,0xa89e,0xa8aa,0xa8b6,0xa8c2,0xa8ce,0xa8da,0xa8e6,
+0xa8f3,0xa8ff,0xa90b,0xa917,0xa923,0xa92f,0xa93b,0xa947,
+0xa953,0xa960,0xa96c,0xa978,0xa984,0xa990,0xa99c,0xa9a8,
+0xa9b4,0xa9c0,0xa9cc,0xa9d8,0xa9e4,0xa9f0,0xa9fc,0xaa09,
+0xaa15,0xaa21,0xaa2d,0xaa39,0xaa45,0xaa51,0xaa5d,0xaa69,
+0xaa75,0xaa81,0xaa8d,0xaa99,0xaaa5,0xaab1,0xaabd,0xaac9,
+0xaad5,0xaae1,0xaaed,0xaaf9,0xab05,0xab11,0xab1d,0xab29,
+0xab35,0xab41,0xab4d,0xab58,0xab64,0xab70,0xab7c,0xab88,
+0xab94,0xaba0,0xabac,0xabb8,0xabc4,0xabd0,0xabdc,0xabe8,
+0xabf4,0xac00,0xac0b,0xac17,0xac23,0xac2f,0xac3b,0xac47,
+0xac53,0xac5f,0xac6b,0xac76,0xac82,0xac8e,0xac9a,0xaca6,
+0xacb2,0xacbe,0xacc9,0xacd5,0xace1,0xaced,0xacf9,0xad05,
+0xad11,0xad1c,0xad28,0xad34,0xad40,0xad4c,0xad57,0xad63,
+0xad6f,0xad7b,0xad87,0xad92,0xad9e,0xadaa,0xadb6,0xadc2,
+0xadcd,0xadd9,0xade5,0xadf1,0xadfd,0xae08,0xae14,0xae20,
+0xae2c,0xae37,0xae43,0xae4f,0xae5b,0xae66,0xae72,0xae7e,
+0xae8a,0xae95,0xaea1,0xaead,0xaeb8,0xaec4,0xaed0,0xaedc,
+0xaee7,0xaef3,0xaeff,0xaf0a,0xaf16,0xaf22,0xaf2e,0xaf39,
+0xaf45,0xaf51,0xaf5c,0xaf68,0xaf74,0xaf7f,0xaf8b,0xaf97,
+0xafa2,0xafae,0xafba,0xafc5,0xafd1,0xafdd,0xafe8,0xaff4,
+0xb000,0xb00b,0xb017,0xb022,0xb02e,0xb03a,0xb045,0xb051,
+0xb05c,0xb068,0xb074,0xb07f,0xb08b,0xb097,0xb0a2,0xb0ae,
+0xb0b9,0xb0c5,0xb0d0,0xb0dc,0xb0e8,0xb0f3,0xb0ff,0xb10a,
+0xb116,0xb121,0xb12d,0xb139,0xb144,0xb150,0xb15b,0xb167,
+0xb172,0xb17e,0xb189,0xb195,0xb1a0,0xb1ac,0xb1b8,0xb1c3,
+0xb1cf,0xb1da,0xb1e6,0xb1f1,0xb1fd,0xb208,0xb214,0xb21f,
+0xb22b,0xb236,0xb242,0xb24d,0xb259,0xb264,0xb270,0xb27b,
+0xb286,0xb292,0xb29d,0xb2a9,0xb2b4,0xb2c0,0xb2cb,0xb2d7,
+0xb2e2,0xb2ee,0xb2f9,0xb305,0xb310,0xb31b,0xb327,0xb332,
+0xb33e,0xb349,0xb355,0xb360,0xb36b,0xb377,0xb382,0xb38e,
+0xb399,0xb3a4,0xb3b0,0xb3bb,0xb3c7,0xb3d2,0xb3dd,0xb3e9,
+0xb3f4,0xb400,0xb40b,0xb416,0xb422,0xb42d,0xb438,0xb444,
+0xb44f,0xb45a,0xb466,0xb471,0xb47c,0xb488,0xb493,0xb49f,
+0xb4aa,0xb4b5,0xb4c1,0xb4cc,0xb4d7,0xb4e2,0xb4ee,0xb4f9,
+0xb504,0xb510,0xb51b,0xb526,0xb532,0xb53d,0xb548,0xb554,
+0xb55f,0xb56a,0xb575,0xb581,0xb58c,0xb597,0xb5a3,0xb5ae,
+0xb5b9,0xb5c4,0xb5d0,0xb5db,0xb5e6,0xb5f1,0xb5fd,0xb608,
+0xb613,0xb61e,0xb62a,0xb635,0xb640,0xb64b,0xb657,0xb662,
+0xb66d,0xb678,0xb684,0xb68f,0xb69a,0xb6a5,0xb6b0,0xb6bc,
+0xb6c7,0xb6d2,0xb6dd,0xb6e8,0xb6f4,0xb6ff,0xb70a,0xb715,
+0xb720,0xb72c,0xb737,0xb742,0xb74d,0xb758,0xb763,0xb76f,
+0xb77a,0xb785,0xb790,0xb79b,0xb7a6,0xb7b2,0xb7bd,0xb7c8,
+0xb7d3,0xb7de,0xb7e9,0xb7f4,0xb800,0xb80b,0xb816,0xb821,
+0xb82c,0xb837,0xb842,0xb84d,0xb858,0xb864,0xb86f,0xb87a,
+0xb885,0xb890,0xb89b,0xb8a6,0xb8b1,0xb8bc,0xb8c7,0xb8d3,
+0xb8de,0xb8e9,0xb8f4,0xb8ff,0xb90a,0xb915,0xb920,0xb92b,
+0xb936,0xb941,0xb94c,0xb957,0xb962,0xb96d,0xb978,0xb983,
+0xb98f,0xb99a,0xb9a5,0xb9b0,0xb9bb,0xb9c6,0xb9d1,0xb9dc,
+0xb9e7,0xb9f2,0xb9fd,0xba08,0xba13,0xba1e,0xba29,0xba34,
+0xba3f,0xba4a,0xba55,0xba60,0xba6b,0xba76,0xba81,0xba8c,
+0xba97,0xbaa2,0xbaad,0xbab8,0xbac3,0xbace,0xbad8,0xbae3,
+0xbaee,0xbaf9,0xbb04,0xbb0f,0xbb1a,0xbb25,0xbb30,0xbb3b,
+0xbb46,0xbb51,0xbb5c,0xbb67,0xbb72,0xbb7d,0xbb88,0xbb92,
+0xbb9d,0xbba8,0xbbb3,0xbbbe,0xbbc9,0xbbd4,0xbbdf,0xbbea,
+0xbbf5,0xbc00,0xbc0a,0xbc15,0xbc20,0xbc2b,0xbc36,0xbc41,
+0xbc4c,0xbc57,0xbc61,0xbc6c,0xbc77,0xbc82,0xbc8d,0xbc98,
+0xbca3,0xbcad,0xbcb8,0xbcc3,0xbcce,0xbcd9,0xbce4,0xbcef,
+0xbcf9,0xbd04,0xbd0f,0xbd1a,0xbd25,0xbd30,0xbd3a,0xbd45,
+0xbd50,0xbd5b,0xbd66,0xbd70,0xbd7b,0xbd86,0xbd91,0xbd9c,
+0xbda6,0xbdb1,0xbdbc,0xbdc7,0xbdd2,0xbddc,0xbde7,0xbdf2,
+0xbdfd,0xbe08,0xbe12,0xbe1d,0xbe28,0xbe33,0xbe3d,0xbe48,
+0xbe53,0xbe5e,0xbe68,0xbe73,0xbe7e,0xbe89,0xbe93,0xbe9e,
+0xbea9,0xbeb4,0xbebe,0xbec9,0xbed4,0xbedf,0xbee9,0xbef4,
+0xbeff,0xbf0a,0xbf14,0xbf1f,0xbf2a,0xbf34,0xbf3f,0xbf4a,
+0xbf55,0xbf5f,0xbf6a,0xbf75,0xbf7f,0xbf8a,0xbf95,0xbf9f,
+0xbfaa,0xbfb5,0xbfbf,0xbfca,0xbfd5,0xbfdf,0xbfea,0xbff5,
+0xc000,0xc00a,0xc015,0xc01f,0xc02a,0xc035,0xc03f,0xc04a,
+0xc055,0xc05f,0xc06a,0xc075,0xc07f,0xc08a,0xc095,0xc09f,
+0xc0aa,0xc0b5,0xc0bf,0xc0ca,0xc0d4,0xc0df,0xc0ea,0xc0f4,
+0xc0ff,0xc109,0xc114,0xc11f,0xc129,0xc134,0xc13e,0xc149,
+0xc154,0xc15e,0xc169,0xc173,0xc17e,0xc189,0xc193,0xc19e,
+0xc1a8,0xc1b3,0xc1bd,0xc1c8,0xc1d3,0xc1dd,0xc1e8,0xc1f2,
+0xc1fd,0xc207,0xc212,0xc21d,0xc227,0xc232,0xc23c,0xc247,
+0xc251,0xc25c,0xc266,0xc271,0xc27b,0xc286,0xc290,0xc29b,
+0xc2a5,0xc2b0,0xc2bb,0xc2c5,0xc2d0,0xc2da,0xc2e5,0xc2ef,
+0xc2fa,0xc304,0xc30f,0xc319,0xc324,0xc32e,0xc339,0xc343,
+0xc34e,0xc358,0xc363,0xc36d,0xc377,0xc382,0xc38c,0xc397,
+0xc3a1,0xc3ac,0xc3b6,0xc3c1,0xc3cb,0xc3d6,0xc3e0,0xc3eb,
+0xc3f5,0xc400,0xc40a,0xc414,0xc41f,0xc429,0xc434,0xc43e,
+0xc449,0xc453,0xc45d,0xc468,0xc472,0xc47d,0xc487,0xc492,
+0xc49c,0xc4a6,0xc4b1,0xc4bb,0xc4c6,0xc4d0,0xc4da,0xc4e5,
+0xc4ef,0xc4fa,0xc504,0xc50e,0xc519,0xc523,0xc52e,0xc538,
+0xc542,0xc54d,0xc557,0xc562,0xc56c,0xc576,0xc581,0xc58b,
+0xc595,0xc5a0,0xc5aa,0xc5b4,0xc5bf,0xc5c9,0xc5d4,0xc5de,
+0xc5e8,0xc5f3,0xc5fd,0xc607,0xc612,0xc61c,0xc626,0xc631,
+0xc63b,0xc645,0xc650,0xc65a,0xc664,0xc66f,0xc679,0xc683,
+0xc68e,0xc698,0xc6a2,0xc6ac,0xc6b7,0xc6c1,0xc6cb,0xc6d6,
+0xc6e0,0xc6ea,0xc6f5,0xc6ff,0xc709,0xc713,0xc71e,0xc728,
+0xc732,0xc73d,0xc747,0xc751,0xc75b,0xc766,0xc770,0xc77a,
+0xc784,0xc78f,0xc799,0xc7a3,0xc7ae,0xc7b8,0xc7c2,0xc7cc,
+0xc7d7,0xc7e1,0xc7eb,0xc7f5,0xc800,0xc80a,0xc814,0xc81e,
+0xc828,0xc833,0xc83d,0xc847,0xc851,0xc85c,0xc866,0xc870,
+0xc87a,0xc884,0xc88f,0xc899,0xc8a3,0xc8ad,0xc8b7,0xc8c2,
+0xc8cc,0xc8d6,0xc8e0,0xc8ea,0xc8f5,0xc8ff,0xc909,0xc913,
+0xc91d,0xc928,0xc932,0xc93c,0xc946,0xc950,0xc95a,0xc965,
+0xc96f,0xc979,0xc983,0xc98d,0xc997,0xc9a2,0xc9ac,0xc9b6,
+0xc9c0,0xc9ca,0xc9d4,0xc9df,0xc9e9,0xc9f3,0xc9fd,0xca07,
+0xca11,0xca1b,0xca26,0xca30,0xca3a,0xca44,0xca4e,0xca58,
+0xca62,0xca6c,0xca76,0xca81,0xca8b,0xca95,0xca9f,0xcaa9,
+0xcab3,0xcabd,0xcac7,0xcad1,0xcadc,0xcae6,0xcaf0,0xcafa,
+0xcb04,0xcb0e,0xcb18,0xcb22,0xcb2c,0xcb36,0xcb40,0xcb4a,
+0xcb55,0xcb5f,0xcb69,0xcb73,0xcb7d,0xcb87,0xcb91,0xcb9b,
+0xcba5,0xcbaf,0xcbb9,0xcbc3,0xcbcd,0xcbd7,0xcbe1,0xcbeb,
+0xcbf5,0xcc00,0xcc0a,0xcc14,0xcc1e,0xcc28,0xcc32,0xcc3c,
+0xcc46,0xcc50,0xcc5a,0xcc64,0xcc6e,0xcc78,0xcc82,0xcc8c,
+0xcc96,0xcca0,0xccaa,0xccb4,0xccbe,0xccc8,0xccd2,0xccdc,
+0xcce6,0xccf0,0xccfa,0xcd04,0xcd0e,0xcd18,0xcd22,0xcd2c,
+0xcd36,0xcd40,0xcd4a,0xcd54,0xcd5e,0xcd68,0xcd72,0xcd7c,
+0xcd86,0xcd90,0xcd99,0xcda3,0xcdad,0xcdb7,0xcdc1,0xcdcb,
+0xcdd5,0xcddf,0xcde9,0xcdf3,0xcdfd,0xce07,0xce11,0xce1b,
+0xce25,0xce2f,0xce39,0xce43,0xce4c,0xce56,0xce60,0xce6a,
+0xce74,0xce7e,0xce88,0xce92,0xce9c,0xcea6,0xceb0,0xceba,
+0xcec3,0xcecd,0xced7,0xcee1,0xceeb,0xcef5,0xceff,0xcf09,
+0xcf13,0xcf1d,0xcf26,0xcf30,0xcf3a,0xcf44,0xcf4e,0xcf58,
+0xcf62,0xcf6c,0xcf75,0xcf7f,0xcf89,0xcf93,0xcf9d,0xcfa7,
+0xcfb1,0xcfbb,0xcfc4,0xcfce,0xcfd8,0xcfe2,0xcfec,0xcff6,
+0xd000,0xd009,0xd013,0xd01d,0xd027,0xd031,0xd03b,0xd044,
+0xd04e,0xd058,0xd062,0xd06c,0xd076,0xd07f,0xd089,0xd093,
+0xd09d,0xd0a7,0xd0b0,0xd0ba,0xd0c4,0xd0ce,0xd0d8,0xd0e1,
+0xd0eb,0xd0f5,0xd0ff,0xd109,0xd112,0xd11c,0xd126,0xd130,
+0xd13a,0xd143,0xd14d,0xd157,0xd161,0xd16b,0xd174,0xd17e,
+0xd188,0xd192,0xd19b,0xd1a5,0xd1af,0xd1b9,0xd1c3,0xd1cc,
+0xd1d6,0xd1e0,0xd1ea,0xd1f3,0xd1fd,0xd207,0xd211,0xd21a,
+0xd224,0xd22e,0xd238,0xd241,0xd24b,0xd255,0xd25f,0xd268,
+0xd272,0xd27c,0xd285,0xd28f,0xd299,0xd2a3,0xd2ac,0xd2b6,
+0xd2c0,0xd2c9,0xd2d3,0xd2dd,0xd2e7,0xd2f0,0xd2fa,0xd304,
+0xd30d,0xd317,0xd321,0xd32b,0xd334,0xd33e,0xd348,0xd351,
+0xd35b,0xd365,0xd36e,0xd378,0xd382,0xd38b,0xd395,0xd39f,
+0xd3a8,0xd3b2,0xd3bc,0xd3c6,0xd3cf,0xd3d9,0xd3e3,0xd3ec,
+0xd3f6,0xd400,0xd409,0xd413,0xd41c,0xd426,0xd430,0xd439,
+0xd443,0xd44d,0xd456,0xd460,0xd46a,0xd473,0xd47d,0xd487,
+0xd490,0xd49a,0xd4a3,0xd4ad,0xd4b7,0xd4c0,0xd4ca,0xd4d4,
+0xd4dd,0xd4e7,0xd4f0,0xd4fa,0xd504,0xd50d,0xd517,0xd521,
+0xd52a,0xd534,0xd53d,0xd547,0xd551,0xd55a,0xd564,0xd56d,
+0xd577,0xd581,0xd58a,0xd594,0xd59d,0xd5a7,0xd5b0,0xd5ba,
+0xd5c4,0xd5cd,0xd5d7,0xd5e0,0xd5ea,0xd5f4,0xd5fd,0xd607,
+0xd610,0xd61a,0xd623,0xd62d,0xd637,0xd640,0xd64a,0xd653,
+0xd65d,0xd666,0xd670,0xd679,0xd683,0xd68c,0xd696,0xd6a0,
+0xd6a9,0xd6b3,0xd6bc,0xd6c6,0xd6cf,0xd6d9,0xd6e2,0xd6ec,
+0xd6f5,0xd6ff,0xd708,0xd712,0xd71b,0xd725,0xd72f,0xd738,
+0xd742,0xd74b,0xd755,0xd75e,0xd768,0xd771,0xd77b,0xd784,
+0xd78e,0xd797,0xd7a1,0xd7aa,0xd7b4,0xd7bd,0xd7c7,0xd7d0,
+0xd7da,0xd7e3,0xd7ed,0xd7f6,0xd800,0xd809,0xd812,0xd81c,
+0xd825,0xd82f,0xd838,0xd842,0xd84b,0xd855,0xd85e,0xd868,
+0xd871,0xd87b,0xd884,0xd88e,0xd897,0xd8a0,0xd8aa,0xd8b3,
+0xd8bd,0xd8c6,0xd8d0,0xd8d9,0xd8e3,0xd8ec,0xd8f5,0xd8ff,
+0xd908,0xd912,0xd91b,0xd925,0xd92e,0xd938,0xd941,0xd94a,
+0xd954,0xd95d,0xd967,0xd970,0xd979,0xd983,0xd98c,0xd996,
+0xd99f,0xd9a9,0xd9b2,0xd9bb,0xd9c5,0xd9ce,0xd9d8,0xd9e1,
+0xd9ea,0xd9f4,0xd9fd,0xda07,0xda10,0xda19,0xda23,0xda2c,
+0xda35,0xda3f,0xda48,0xda52,0xda5b,0xda64,0xda6e,0xda77,
+0xda81,0xda8a,0xda93,0xda9d,0xdaa6,0xdaaf,0xdab9,0xdac2,
+0xdacb,0xdad5,0xdade,0xdae8,0xdaf1,0xdafa,0xdb04,0xdb0d,
+0xdb16,0xdb20,0xdb29,0xdb32,0xdb3c,0xdb45,0xdb4e,0xdb58,
+0xdb61,0xdb6a,0xdb74,0xdb7d,0xdb86,0xdb90,0xdb99,0xdba2,
+0xdbac,0xdbb5,0xdbbe,0xdbc8,0xdbd1,0xdbda,0xdbe4,0xdbed,
+0xdbf6,0xdc00,0xdc09,0xdc12,0xdc1b,0xdc25,0xdc2e,0xdc37,
+0xdc41,0xdc4a,0xdc53,0xdc5d,0xdc66,0xdc6f,0xdc78,0xdc82,
+0xdc8b,0xdc94,0xdc9e,0xdca7,0xdcb0,0xdcb9,0xdcc3,0xdccc,
+0xdcd5,0xdcde,0xdce8,0xdcf1,0xdcfa,0xdd04,0xdd0d,0xdd16,
+0xdd1f,0xdd29,0xdd32,0xdd3b,0xdd44,0xdd4e,0xdd57,0xdd60,
+0xdd69,0xdd73,0xdd7c,0xdd85,0xdd8e,0xdd98,0xdda1,0xddaa,
+0xddb3,0xddbd,0xddc6,0xddcf,0xddd8,0xdde2,0xddeb,0xddf4,
+0xddfd,0xde06,0xde10,0xde19,0xde22,0xde2b,0xde35,0xde3e,
+0xde47,0xde50,0xde59,0xde63,0xde6c,0xde75,0xde7e,0xde87,
+0xde91,0xde9a,0xdea3,0xdeac,0xdeb5,0xdebf,0xdec8,0xded1,
+0xdeda,0xdee3,0xdeed,0xdef6,0xdeff,0xdf08,0xdf11,0xdf1a,
+0xdf24,0xdf2d,0xdf36,0xdf3f,0xdf48,0xdf52,0xdf5b,0xdf64,
+0xdf6d,0xdf76,0xdf7f,0xdf89,0xdf92,0xdf9b,0xdfa4,0xdfad,
+0xdfb6,0xdfbf,0xdfc9,0xdfd2,0xdfdb,0xdfe4,0xdfed,0xdff6,
+0xe000,0xe009,0xe012,0xe01b,0xe024,0xe02d,0xe036,0xe03f,
+0xe049,0xe052,0xe05b,0xe064,0xe06d,0xe076,0xe07f,0xe088,
+0xe092,0xe09b,0xe0a4,0xe0ad,0xe0b6,0xe0bf,0xe0c8,0xe0d1,
+0xe0db,0xe0e4,0xe0ed,0xe0f6,0xe0ff,0xe108,0xe111,0xe11a,
+0xe123,0xe12c,0xe136,0xe13f,0xe148,0xe151,0xe15a,0xe163,
+0xe16c,0xe175,0xe17e,0xe187,0xe190,0xe199,0xe1a3,0xe1ac,
+0xe1b5,0xe1be,0xe1c7,0xe1d0,0xe1d9,0xe1e2,0xe1eb,0xe1f4,
+0xe1fd,0xe206,0xe20f,0xe218,0xe221,0xe22b,0xe234,0xe23d,
+0xe246,0xe24f,0xe258,0xe261,0xe26a,0xe273,0xe27c,0xe285,
+0xe28e,0xe297,0xe2a0,0xe2a9,0xe2b2,0xe2bb,0xe2c4,0xe2cd,
+0xe2d6,0xe2df,0xe2e8,0xe2f1,0xe2fa,0xe303,0xe30c,0xe315,
+0xe31f,0xe328,0xe331,0xe33a,0xe343,0xe34c,0xe355,0xe35e,
+0xe367,0xe370,0xe379,0xe382,0xe38b,0xe394,0xe39d,0xe3a6,
+0xe3af,0xe3b8,0xe3c1,0xe3ca,0xe3d3,0xe3dc,0xe3e5,0xe3ee,
+0xe3f7,0xe400,0xe408,0xe411,0xe41a,0xe423,0xe42c,0xe435,
+0xe43e,0xe447,0xe450,0xe459,0xe462,0xe46b,0xe474,0xe47d,
+0xe486,0xe48f,0xe498,0xe4a1,0xe4aa,0xe4b3,0xe4bc,0xe4c5,
+0xe4ce,0xe4d7,0xe4e0,0xe4e9,0xe4f2,0xe4fa,0xe503,0xe50c,
+0xe515,0xe51e,0xe527,0xe530,0xe539,0xe542,0xe54b,0xe554,
+0xe55d,0xe566,0xe56f,0xe578,0xe580,0xe589,0xe592,0xe59b,
+0xe5a4,0xe5ad,0xe5b6,0xe5bf,0xe5c8,0xe5d1,0xe5da,0xe5e3,
+0xe5eb,0xe5f4,0xe5fd,0xe606,0xe60f,0xe618,0xe621,0xe62a,
+0xe633,0xe63c,0xe644,0xe64d,0xe656,0xe65f,0xe668,0xe671,
+0xe67a,0xe683,0xe68c,0xe694,0xe69d,0xe6a6,0xe6af,0xe6b8,
+0xe6c1,0xe6ca,0xe6d3,0xe6db,0xe6e4,0xe6ed,0xe6f6,0xe6ff,
+0xe708,0xe711,0xe71a,0xe722,0xe72b,0xe734,0xe73d,0xe746,
+0xe74f,0xe758,0xe760,0xe769,0xe772,0xe77b,0xe784,0xe78d,
+0xe795,0xe79e,0xe7a7,0xe7b0,0xe7b9,0xe7c2,0xe7cb,0xe7d3,
+0xe7dc,0xe7e5,0xe7ee,0xe7f7,0xe800,0xe808,0xe811,0xe81a,
+0xe823,0xe82c,0xe834,0xe83d,0xe846,0xe84f,0xe858,0xe861,
+0xe869,0xe872,0xe87b,0xe884,0xe88d,0xe895,0xe89e,0xe8a7,
+0xe8b0,0xe8b9,0xe8c1,0xe8ca,0xe8d3,0xe8dc,0xe8e5,0xe8ed,
+0xe8f6,0xe8ff,0xe908,0xe911,0xe919,0xe922,0xe92b,0xe934,
+0xe93c,0xe945,0xe94e,0xe957,0xe960,0xe968,0xe971,0xe97a,
+0xe983,0xe98b,0xe994,0xe99d,0xe9a6,0xe9ae,0xe9b7,0xe9c0,
+0xe9c9,0xe9d2,0xe9da,0xe9e3,0xe9ec,0xe9f5,0xe9fd,0xea06,
+0xea0f,0xea18,0xea20,0xea29,0xea32,0xea3b,0xea43,0xea4c,
+0xea55,0xea5e,0xea66,0xea6f,0xea78,0xea80,0xea89,0xea92,
+0xea9b,0xeaa3,0xeaac,0xeab5,0xeabe,0xeac6,0xeacf,0xead8,
+0xeae0,0xeae9,0xeaf2,0xeafb,0xeb03,0xeb0c,0xeb15,0xeb1d,
+0xeb26,0xeb2f,0xeb38,0xeb40,0xeb49,0xeb52,0xeb5a,0xeb63,
+0xeb6c,0xeb74,0xeb7d,0xeb86,0xeb8f,0xeb97,0xeba0,0xeba9,
+0xebb1,0xebba,0xebc3,0xebcb,0xebd4,0xebdd,0xebe5,0xebee,
+0xebf7,0xec00,0xec08,0xec11,0xec1a,0xec22,0xec2b,0xec34,
+0xec3c,0xec45,0xec4e,0xec56,0xec5f,0xec68,0xec70,0xec79,
+0xec82,0xec8a,0xec93,0xec9c,0xeca4,0xecad,0xecb5,0xecbe,
+0xecc7,0xeccf,0xecd8,0xece1,0xece9,0xecf2,0xecfb,0xed03,
+0xed0c,0xed15,0xed1d,0xed26,0xed2e,0xed37,0xed40,0xed48,
+0xed51,0xed5a,0xed62,0xed6b,0xed74,0xed7c,0xed85,0xed8d,
+0xed96,0xed9f,0xeda7,0xedb0,0xedb8,0xedc1,0xedca,0xedd2,
+0xeddb,0xede4,0xedec,0xedf5,0xedfd,0xee06,0xee0f,0xee17,
+0xee20,0xee28,0xee31,0xee3a,0xee42,0xee4b,0xee53,0xee5c,
+0xee65,0xee6d,0xee76,0xee7e,0xee87,0xee8f,0xee98,0xeea1,
+0xeea9,0xeeb2,0xeeba,0xeec3,0xeecc,0xeed4,0xeedd,0xeee5,
+0xeeee,0xeef6,0xeeff,0xef08,0xef10,0xef19,0xef21,0xef2a,
+0xef32,0xef3b,0xef43,0xef4c,0xef55,0xef5d,0xef66,0xef6e,
+0xef77,0xef7f,0xef88,0xef90,0xef99,0xefa2,0xefaa,0xefb3,
+0xefbb,0xefc4,0xefcc,0xefd5,0xefdd,0xefe6,0xefee,0xeff7,
+0xf000,0xf008,0xf011,0xf019,0xf022,0xf02a,0xf033,0xf03b,
+0xf044,0xf04c,0xf055,0xf05d,0xf066,0xf06e,0xf077,0xf07f,
+0xf088,0xf090,0xf099,0xf0a1,0xf0aa,0xf0b2,0xf0bb,0xf0c3,
+0xf0cc,0xf0d4,0xf0dd,0xf0e5,0xf0ee,0xf0f6,0xf0ff,0xf107,
+0xf110,0xf118,0xf121,0xf129,0xf132,0xf13a,0xf143,0xf14b,
+0xf154,0xf15c,0xf165,0xf16d,0xf176,0xf17e,0xf187,0xf18f,
+0xf198,0xf1a0,0xf1a9,0xf1b1,0xf1ba,0xf1c2,0xf1cb,0xf1d3,
+0xf1dc,0xf1e4,0xf1ec,0xf1f5,0xf1fd,0xf206,0xf20e,0xf217,
+0xf21f,0xf228,0xf230,0xf239,0xf241,0xf24a,0xf252,0xf25a,
+0xf263,0xf26b,0xf274,0xf27c,0xf285,0xf28d,0xf296,0xf29e,
+0xf2a6,0xf2af,0xf2b7,0xf2c0,0xf2c8,0xf2d1,0xf2d9,0xf2e1,
+0xf2ea,0xf2f2,0xf2fb,0xf303,0xf30c,0xf314,0xf31c,0xf325,
+0xf32d,0xf336,0xf33e,0xf347,0xf34f,0xf357,0xf360,0xf368,
+0xf371,0xf379,0xf381,0xf38a,0xf392,0xf39b,0xf3a3,0xf3ac,
+0xf3b4,0xf3bc,0xf3c5,0xf3cd,0xf3d6,0xf3de,0xf3e6,0xf3ef,
+0xf3f7,0xf400,0xf408,0xf410,0xf419,0xf421,0xf429,0xf432,
+0xf43a,0xf443,0xf44b,0xf453,0xf45c,0xf464,0xf46d,0xf475,
+0xf47d,0xf486,0xf48e,0xf496,0xf49f,0xf4a7,0xf4b0,0xf4b8,
+0xf4c0,0xf4c9,0xf4d1,0xf4d9,0xf4e2,0xf4ea,0xf4f2,0xf4fb,
+0xf503,0xf50c,0xf514,0xf51c,0xf525,0xf52d,0xf535,0xf53e,
+0xf546,0xf54e,0xf557,0xf55f,0xf567,0xf570,0xf578,0xf580,
+0xf589,0xf591,0xf599,0xf5a2,0xf5aa,0xf5b2,0xf5bb,0xf5c3,
+0xf5cb,0xf5d4,0xf5dc,0xf5e4,0xf5ed,0xf5f5,0xf5fd,0xf606,
+0xf60e,0xf616,0xf61f,0xf627,0xf62f,0xf638,0xf640,0xf648,
+0xf651,0xf659,0xf661,0xf66a,0xf672,0xf67a,0xf682,0xf68b,
+0xf693,0xf69b,0xf6a4,0xf6ac,0xf6b4,0xf6bd,0xf6c5,0xf6cd,
+0xf6d6,0xf6de,0xf6e6,0xf6ee,0xf6f7,0xf6ff,0xf707,0xf710,
+0xf718,0xf720,0xf728,0xf731,0xf739,0xf741,0xf74a,0xf752,
+0xf75a,0xf762,0xf76b,0xf773,0xf77b,0xf784,0xf78c,0xf794,
+0xf79c,0xf7a5,0xf7ad,0xf7b5,0xf7bd,0xf7c6,0xf7ce,0xf7d6,
+0xf7de,0xf7e7,0xf7ef,0xf7f7,0xf800,0xf808,0xf810,0xf818,
+0xf821,0xf829,0xf831,0xf839,0xf842,0xf84a,0xf852,0xf85a,
+0xf863,0xf86b,0xf873,0xf87b,0xf883,0xf88c,0xf894,0xf89c,
+0xf8a4,0xf8ad,0xf8b5,0xf8bd,0xf8c5,0xf8ce,0xf8d6,0xf8de,
+0xf8e6,0xf8ef,0xf8f7,0xf8ff,0xf907,0xf90f,0xf918,0xf920,
+0xf928,0xf930,0xf939,0xf941,0xf949,0xf951,0xf959,0xf962,
+0xf96a,0xf972,0xf97a,0xf982,0xf98b,0xf993,0xf99b,0xf9a3,
+0xf9ab,0xf9b4,0xf9bc,0xf9c4,0xf9cc,0xf9d4,0xf9dd,0xf9e5,
+0xf9ed,0xf9f5,0xf9fd,0xfa06,0xfa0e,0xfa16,0xfa1e,0xfa26,
+0xfa2f,0xfa37,0xfa3f,0xfa47,0xfa4f,0xfa58,0xfa60,0xfa68,
+0xfa70,0xfa78,0xfa80,0xfa89,0xfa91,0xfa99,0xfaa1,0xfaa9,
+0xfab1,0xfaba,0xfac2,0xfaca,0xfad2,0xfada,0xfae2,0xfaeb,
+0xfaf3,0xfafb,0xfb03,0xfb0b,0xfb13,0xfb1c,0xfb24,0xfb2c,
+0xfb34,0xfb3c,0xfb44,0xfb4c,0xfb55,0xfb5d,0xfb65,0xfb6d,
+0xfb75,0xfb7d,0xfb85,0xfb8e,0xfb96,0xfb9e,0xfba6,0xfbae,
+0xfbb6,0xfbbe,0xfbc7,0xfbcf,0xfbd7,0xfbdf,0xfbe7,0xfbef,
+0xfbf7,0xfc00,0xfc08,0xfc10,0xfc18,0xfc20,0xfc28,0xfc30,
+0xfc38,0xfc40,0xfc49,0xfc51,0xfc59,0xfc61,0xfc69,0xfc71,
+0xfc79,0xfc81,0xfc8a,0xfc92,0xfc9a,0xfca2,0xfcaa,0xfcb2,
+0xfcba,0xfcc2,0xfcca,0xfcd2,0xfcdb,0xfce3,0xfceb,0xfcf3,
+0xfcfb,0xfd03,0xfd0b,0xfd13,0xfd1b,0xfd23,0xfd2c,0xfd34,
+0xfd3c,0xfd44,0xfd4c,0xfd54,0xfd5c,0xfd64,0xfd6c,0xfd74,
+0xfd7c,0xfd84,0xfd8d,0xfd95,0xfd9d,0xfda5,0xfdad,0xfdb5,
+0xfdbd,0xfdc5,0xfdcd,0xfdd5,0xfddd,0xfde5,0xfded,0xfdf5,
+0xfdfd,0xfe06,0xfe0e,0xfe16,0xfe1e,0xfe26,0xfe2e,0xfe36,
+0xfe3e,0xfe46,0xfe4e,0xfe56,0xfe5e,0xfe66,0xfe6e,0xfe76,
+0xfe7e,0xfe86,0xfe8e,0xfe97,0xfe9f,0xfea7,0xfeaf,0xfeb7,
+0xfebf,0xfec7,0xfecf,0xfed7,0xfedf,0xfee7,0xfeef,0xfef7,
+0xfeff,0xff07,0xff0f,0xff17,0xff1f,0xff27,0xff2f,0xff37,
+0xff3f,0xff47,0xff4f,0xff57,0xff5f,0xff67,0xff6f,0xff77,
+0xff7f,0xff87,0xff8f,0xff97,0xff9f,0xffa7,0xffaf,0xffb7,
+0xffbf,0xffc7,0xffcf,0xffd7,0xffdf,0xffe7,0xffef,0xfff7};
+
+const signed short wavtable1[2304]={
+0x021d,0x03bc,0x0300,0xfc0d,0xfcd5,0xfd33,0xfdc5,0xfc83,
+0xfdc0,0x036d,0x0245,0x0238,0xfc1b,0xfc31,0xfd7a,0xfd10,
+0xfd6b,0xfd88,0x02a3,0x0313,0x027b,0xfdf9,0xfcba,0xfc2f,
+0xfc86,0xfda3,0xfceb,0x0270,0x02dc,0x029c,0xfc83,0xfcd1,
+0xfc44,0xfd06,0xfdf5,0xfc97,0x026f,0x0347,0x02b9,0xfc02,
+0xfcaf,0xfdc5,0xfd09,0xfd50,0xfc4b,0x0280,0x02b5,0x03df,
+0xfc9d,0xfd95,0xfd61,0xfce0,0xfc54,0xfc41,0x039d,0x02af,
+0x0260,0xfd93,0xfddb,0xfccf,0xfcbb,0xfc64,0xfd2e,0x0228,
+0x031d,0x023c,0xfca3,0xfd97,0xfc84,0xfdac,0xfd93,0xfd80,
+0x0217,0x0340,0x031f,0xfc99,0xfcbc,0xfd77,0xfdd0,0xfd5c,
+0xfd90,0x02fa,0x025d,0x0241,0xfc7a,0xfca5,0xfd56,0xfdc8,
+0xfd34,0xfd76,0x0340,0x0231,0x03eb,0xfc6f,0xfcd1,0xfdda,
+0xfd5c,0xfd98,0xfc2a,0x024e,0x02af,0x024c,0xfce7,0xfd59,
+0xfcea,0xfd57,0xfc65,0xfd5b,0x0286,0x0385,0x02dc,0xfdc7,
+0xfc64,0xfd7b,0xfcd0,0xfce6,0xfdf4,0x033c,0x02b1,0x0380,
+0xfdd3,0xfd2b,0xfda5,0xfd62,0xfc61,0xfcf0,0x036b,0x0270,
+0x0350,0xfdeb,0xfd2b,0xfdfc,0xfd14,0xfd08,0xfd42,0x023b,
+0x03ae,0x03fe,0xfdf2,0xfdc6,0xfc53,0xfd82,0xfc9c,0xfc04,
+0x0338,0x02e0,0x0283,0xfdaf,0xfdfb,0xfc63,0xfd69,0xfdee,
+0xfcd8,0x0205,0x02fd,0x0200,0xfcfa,0xfdfa,0xfd01,0xfdf5,
+0xfdc4,0xfdff,0x0232,0x038c,0x02f9,0xfc1b,0xfcbc,0xfd5d,
+0xfd97,0xfcdb,0xfdca,0x02b6,0x0391,0x02a3,0xfd95,0xfc6c,
+0xfda5,0xfc53,0xfcd1,0xfc85,0x02c0,0x020c,0x02a0,0xfd2e,
+0xfc63,0xfd4f,0xfc37,0xfde6,0xfc8d,0x02d1,0x02f5,0x022e,
+0xfdea,0xfcee,0xfcc6,0xfc06,0xfdcf,0xfda0,0x0374,0x0227,
+0x0279,0xfc49,0xfdde,0xfd57,0xfd05,0xfdb0,0xfcf0,0x022e,
+0x03ef,0x034e,0xfddb,0xfc65,0xfcc0,0xfda0,0xfc21,0xfd45,
+0x03a4,0x02ea,0x0309,0xfd59,0xfd3d,0xfdca,0xfcaf,0xfde0,
+0xfdb3,0x0236,0x0336,0x039e,0xfc72,0xfdff,0xfd18,0xfd8d,
+0xfd6d,0xfcb9,0x0265,0x0303,0x0263,0xfc64,0xfd25,0xfc67,
+0xfd23,0xfdbb,0xfd27,0x02e1,0x029f,0x03f0,0xfc39,0xfd2a,
+0xfd6b,0xfded,0xfc90,0xfc1f,0x028b,0x0252,0x0243,0xfd0b,
+0xfd1f,0xfd5f,0xfcc2,0xfd4d,0xfd71,0x0321,0x027c,0x0234,
+0xfc1c,0xfc8d,0xfd42,0xfd8e,0xfce8,0xfd92,0x0354,0x038e,
+0x02cf,0xfd0b,0xfda9,0xfd81,0xfd3b,0xfcd7,0xfc0c,0x03e6,
+0x0266,0x023f,0xfda9,0xfdcf,0xfd4d,0xfc32,0xfd1f,0xfd79,
+0x0299,0x03a7,0x0274,0xfda1,0xfcd0,0xfdc2,0xfca1,0xfcaa,
+0xfcfd,0x0277,0x0254,0x033d,0xfd21,0xfc01,0xfc3a,0xfcf6,
+0xfd4a,0xfd60,0x0284,0x039e,0x020e,0xfdb9,0xfd69,0xfc47,
+0xfcd5,0xfcba,0xfde2,0x036f,0x03dc,0x0265,0xfcb0,0xfdf2,
+0xfdb0,0xfd0d,0xfc47,0xfd22,0x03ad,0x02b4,0x02b5,0xfd83,
+0xfd82,0xfc55,0xfc9e,0xfc57,0xfc54,0x0235,0x02a0,0x0240,
+0xfd1a,0xfd83,0xfd0b,0xfd8f,0xfc8e,0xfd77,0x0223,0x0274,
+0x02e4,0xfd61,0xfce9,0xfc73,0xfdb7,0xfcfd,0xfde9,0x027f,
+0x0214,0x0219,0xfd67,0xfd61,0xfdd1,0xfce2,0xfdd6,0xfdcc,
+0x03bb,0x025c,0x0256,0xfdcc,0xfdd2,0xfd3e,0xfc85,0xfd36,
+0xfd45,0x0232,0x0244,0x0384,0xfd83,0xfc23,0xfc03,0xfd97,
+0xfd6e,0xfce9,0x025b,0x0383,0x026d,0xfdee,0xfd23,0xfddf,
+0xfd38,0xfceb,0xfd0d,0x02ea,0x0215,0x0270,0xfcf8,0xfc73,
+0xfd76,0xfde1,0xfdd5,0xfd07,0x02d9,0x0202,0x02df,0xfd23,
+0xfdf5,0xfd1d,0xfdf9,0xfdfb,0xfdf0,0x0355,0x0227,0x02b4,
+0xfc69,0xfdbf,0xfd17,0xfd39,0xfdaf,0xfc58,0x03b5,0x03fa,
+0x03ec,0xfc50,0xfc5d,0xfc19,0xfc90,0xfc0b,0xfc27,0x0220,
+0x03dc,0x02df,0xfdf3,0xfcf3,0xfd3a,0xfdbe,0xfc46,0xfdf0,
+0x0315,0x030e,0x0335,0xfda5,0xfd87,0xfd8c,0xfda0,0xfdaa,
+0xfd6d,0x0381,0x0204,0x02f2,0xfc76,0xfd6b,0xfd07,0xfcee,
+0xfdf7,0xfdd4,0x0205,0x02be,0x033c,0xfd3a,0xfcbb,0xfdc8,
+0xfdf5,0xfc3d,0xfd62,0x024a,0x0332,0x02fb,0xfc57,0xfc96,
+0xfd9f,0xfd60,0xfd72,0xfdc8,0x038b,0x028c,0x0250,0xfdbe,
+0xfdf3,0xfd0e,0xfcdc,0xfcc2,0xfd52,0x0210,0x028c,0x0282,
+0xfd5f,0xfd69,0xfcce,0xfdde,0xfcc2,0xfcda,0x0213,0x02c4,
+0x030c,0xfd20,0xfcd5,0xfde4,0xfdd8,0xfc2b,0xfdad,0x029a,
+0x0271,0x02d7,0xfcd3,0xfc4e,0xfc88,0xfc9d,0xfd05,0xfdfc,
+0x03b3,0x02d7,0x022a,0xfd5f,0xfe00,0xfced,0xfc95,0xfdfb,
+0xfda9,0x0225,0x0291,0x03d5,0xfd3f,0xfdf2,0xfd8a,0xfdb3,
+0xfcb5,0xfc53,0x025d,0x0398,0x0354,0xfde0,0xfc10,0xfd02,
+0xfd34,0xfcc5,0xfd3b,0x0270,0x026b,0x03d7,0xfd0d,0xfda9,
+0xfdad,0xfd07,0xfd12,0xfc50,0x025d,0x038d,0x0223,0xfde7,
+0xfd7a,0xfc35,0xfd35,0xfcd9,0xfdb8,0x02b2,0x03a7,0x0204,
+0xfd89,0xfd47,0xfc50,0xfc5c,0xfca9,0xfdf7,0x02bc,0x0264,
+0x0355,0xfcba,0xfdb8,0xfc03,0xfc41,0xfd24,0xfd39,0x02ff,
+0x0340,0x023e,0xfd91,0xfca3,0xfc5b,0xfdc1,0xfd5c,0xfd7d,
+0x020b,0x0382,0x039b,0xfc69,0xfc4f,0xfcd6,0xfde8,0xfceb,
+0xfcbf,0x02d2,0x03be,0x02b3,0xfd5c,0xfc30,0xfd79,0xfc04,
+0xfc80,0xfc59,0x0265,0x0303,0x03a0,0xfc64,0xfdd4,0xfd44,
+0xfd22,0xfdbb,0xfcb6,0x02f6,0x02f5,0x0248,0xfdcf,0xfc9e,
+0xfc9f,0xfdce,0xfdd0,0xfd65,0x0200,0x0237,0x0241,0xfdc9,
+0xfdbf,0xfd81,0xfe00,0xfd8c,0xfd76,0x0267,0x027e,0x02ba,
+0xfd02,0xfcb9,0xfc99,0xfd1d,0xfce5,0xfc46,0x023e,0x0282,
+0x024d,0xfd30,0xfd6c,0xfd1d,0xfd7c,0xfcda,0xfd5b,0x03e1,
+0x02aa,0x036e,0xfd6a,0xfcac,0xfdb7,0xfc3d,0xfc72,0xfd0f,
+0x021b,0x037a,0x0391,0xfc55,0xfc3d,0xfce5,0xfdc7,0xfcf9,
+0xfcd1,0x02b6,0x03a0,0x0220,0xfd8b,0xfd1e,0xfc25,0xfc53,
+0xfcb6,0xfdbe,0x0325,0x0258,0x02a8,0xfc50,0xfde9,0xfce2,
+0xfd87,0xfd40,0xfc77,0x021c,0x03b7,0x030e,0xfc14,0xfcc7,
+0xfd29,0xfdc6,0xfc8c,0xfdab,0x0330,0x03b6,0x024e,0xfd0b,
+0xfc53,0xfddc,0xfd76,0xfc8f,0xfd57,0x03bb,0x034f,0x032b,
+0xfcea,0xfd0b,0xfd61,0xfc85,0xfd44,0xfd7d,0x0223,0x0373,
+0x022c,0xfc4f,0xfdad,0xfc40,0xfdb6,0xfd06,0xfda3,0x028c,
+0x0378,0x025c,0xfdcb,0xfcfe,0xfdf4,0xfcc1,0xfcfe,0xfd37,
+0x035f,0x0249,0x0357,0xfc26,0xfd2f,0xfc2e,0xfd29,0xfd64,
+0xfd35,0x03ff,0x03e5,0x0204,0xfc1b,0xfdfc,0xfc12,0xfc01,
+0xfc34,0xfdf8,0x03a4,0x0266,0x0280,0xfdd0,0xfdb9,0xfcff,
+0xfcae,0xfd1e,0xfce0,0x0273,0x0234,0x023d,0xfd4d,0xfd42,
+0xfd89,0xfcff,0xfd93,0xfd7f,0x036c,0x0384,0x02d4,0xfcfe,
+0xfd94,0xfd83,0xfd12,0xfce8,0xfe00,0x0203,0x0359,0x0380,
+0xfca1,0xfc7a,0xfd12,0xfdf9,0xfd32,0xfcf0,0x0287,0x03b9,
+0x036f,0xfda6,0xfdd5,0xfcce,0xfccf,0xfc88,0xfd0d,0x0326,
+0x0356,0x0359,0xfd60,0xfd5d,0xfd35,0xfd86,0xfd38,0xfd32,
+0x0221,0x0247,0x0277,0xfd93,0xfd60,0xfd31,0xfdbb,0xfd68,
+0xfcf6,0x0291,0x0259,0x02ef,0xfcfc,0xfc3d,0xfc8e,0xfcb5,
+0xfd3d,0xfdda,0x02e4,0x0389,0x031b,0xfd72,0xfdc1,0xfd40,
+0xfde9,0xfcdf,0xfd96,0x0349,0x03f8,0x0238,0xfcbd,0xfc5a,
+0xfdcc,0xfd4d,0xfc0f,0xfd89,0x02eb,0x024d,0x03d7,0xfca3,
+0xfd32,0xfdca,0xfddf,0xfd59,0xfc4f,0x036e,0x0265,0x020e,
+0xfdf2,0xfc7a,0xfd8a,0xfd0f,0xfd20,0xfde4,0x0360,0x02d3,
+0x030b,0xfd9e,0xfd6f,0xfdda,0xfd27,0xfc02,0xfdb0,0x0216,
+0x02a2,0x0306,0xfd41,0xfcd8,0xfc05,0xfdd3,0xfc89,0xfdb6,
+0x03b6,0x0289,0x03ab,0xfda6,0xfc99,0xfdad,0xfc8f,0xfcc8,
+0xfca3,0x024e,0x02bf,0x0383,0xfcd5,0xfdfa,0xfd96,0xfd58,
+0xfc3a,0xfcea,0x026a,0x020f,0x0243,0xfd83,0xfd44,0xfdab,
+0xfd16,0xfde1,0xfd6f,0x02d5,0x0287,0x03cc,0xfc6b,0xfd4f,
+0xfd99,0xfdff,0xfcce,0xfc64,0x0281,0x0287,0x02c3,0xfcd6,
+0xfc8b,0xfc83,0xfcdd,0xfccf,0xfc30,0x02da,0x0297,0x0284,
+0xfc4e,0xfc68,0xfcbd,0xfdf7,0xfca4,0xfcd4,0x0327,0x023c,
+0x0242,0xfc7a,0xfc70,0xfd7a,0xfd83,0xfd81,0xfd73,0x036f,
+0x0263,0x0335,0xfdf4,0xfd3f,0xfc2d,0xfd0d,0xfd27,0xfd6e,
+0x029b,0x02d9,0x0349,0xfc49,0xfddb,0xfda9,0xfc99,0xfdf9,
+0xfd4c,0x030e,0x0249,0x02ef,0xfc81,0xfdc2,0xfca5,0xfdaa,
+0xfd62,0xfdd9,0x0322,0x02dd,0x03d0,0xfdc2,0xfd03,0xfd45,
+0xfd8c,0xfdf3,0xfc5d,0x0352,0x0367,0x02c4,0xfd2c,0xfdb4,
+0xfda6,0xfd3e,0xfd1a,0xfc2d,0x0366,0x02e7,0x02c0,0xfd88,
+0xfdaa,0xfc01,0xfd1d,0xfde4,0xfc36,0x03ad,0x0383,0x0249,
+0xfcc5,0xfde6,0xfdfe,0xfc9e,0xfcea,0xfd63,0x03af,0x0278,
+0x036b,0xfdba,0xfcda,0xfde3,0xfc9b,0xfcf3,0xfd13,0x03ff,
+0x02dc,0x027e,0xfd25,0xfd83,0xfc70,0xfc02,0xfdf5,0xfce5,
+0x030a,0x02f1,0x028f,0xfdc3,0xfc1b,0xfc3b,0xfdb0,0xfdd6,
+0xfcb9,0x034b,0x03b1,0x03b1,0xfcf5,0xfcf5,0xfc97,0xfd4a,
+0xfc97,0xfc97,0x03ae,0x03c9,0x023c,0xfc84,0xfdf1,0xfde2,
+0xfc9d,0xfc6a,0xfd80,0x03f0,0x022f,0x0356,0xfdd9,0xfcb7,
+0xfc5a,0xfc1f,0xfd9c,0xfd38,0x0364,0x02d9,0x0313,0xfd96,
+0xfd64,0xfdd0,0xfd1f,0xfdf9,0xfda3,0x03ca,0x02ae,0x0223,
+0xfd76,0xfdfa,0xfd23,0xfc69,0xfc69,0xfdb7,0x0217,0x027b,
+0x02a2,0xfd68,0xfd3f,0xfcbc,0xfdd0,0xfcec,0xfc89,0x0230,
+0x027c,0x033c,0xfd48,0xfc75,0xfdfe,0xfd9b,0xfcea,0xfd62,
+0x03e2,0x0250,0x0341,0xfdc1,0xfcd7,0xfc3c,0xfc3a,0xfd52,
+0xfd5b,0x0224,0x026d,0x02b6,0xfd67,0xfd19,0xfcb5,0xfdb5,
+0xfd0d,0xfc52,0x0226,0x0321,0x03bb,0xfca3,0xfdff,0xfd14,
+0xfdb1,0xfd8d,0xfc84,0x0246,0x020a,0x0286,0xfdae,0xfd21,
+0xfd6d,0xfd69,0xfdeb,0xfcd1,0x025e,0x0271,0x0332,0xfd1d,
+0xfc37,0xfc19,0xfd33,0xfd05,0xfd71,0x026f,0x024f,0x036a,
+0xfd30,0xfded,0xfc0e,0xfd0a,0xfd55,0xfd16,0x029d,0x0217,
+0x03e9,0xfd44,0xfd72,0xfdf5,0xfc94,0xfdd1,0xfc2d,0x02bd,
+0x03aa,0x0250,0xfd7e,0xfcd6,0xfde2,0xfc40,0xfca4,0xfd54,
+0x039d,0x0334,0x02e2,0xfd1b,0xfd65,0xfdb0,0xfcbd,0xfd6f,
+0xfdeb,0x02df,0x0316,0x0220,0xfdc9,0xfcf3,0xfcb8,0xfdf1,
+0xfd9e,0xfdbe,0x023f,0x0314,0x02a2,0xfc8a,0xfd0a,0xfdf9,
+0xfd79,0xfda1,0xfc88,0x028f,0x030f,0x0210,0xfc15,0xfd5b,
+0xfcd7,0xfcb8,0xfda9,0xfddf,0x020f,0x0201,0x02a5,0xfdef,
+0xfd45,0xfd59,0xfde0,0xfdfe,0xfc7f,0x030e,0x0354,0x03ac,
+0xfd75,0xfd32,0xfcf1,0xfdab,0xfd3b,0xfca1,0x0242,0x038e,
+0x0201,0xfdfe,0xfdbb,0xfc6e,0xfd72,0xfcd7,0xfdfd,0x02b4,
+0x0372,0x02de,0xfdac,0xfc1f,0xfd88,0xfc57,0xfd09,0xfdf2,
+0x024a,0x02ab,0x02cb,0xfcf2,0xfcce,0xfc46,0xfd62,0xfc71,
+0xfc19,0x02e3,0x0261,0x02cd,0xfc90,0xfdfa,0xfcaa,0xfdea,
+0xfd2b,0xfc12,0x030a,0x0305,0x02b9,0xfdb4,0xfdee,0xfdf1,
+0xfdb0,0xfdb8,0xfc49,0x039a,0x0311,0x032d,0xfd3d,0xfd24,
+0xfd90,0xfcc2,0xfda6,0xfd7a,0x02fe,0x028b,0x03d8,0xfc32,
+0xfd20,0xfd8e,0xfdc3,0xfcc5,0xfc4e,0x03d2,0x0254,0x0203,
+0xfdc7,0xfc28,0xfda8,0xfc5a,0xfd4a,0xfdfa,0x0217,0x02f5,
+0x021c,0xfce8,0xfdcb,0xfce1,0xfdd0,0xfdd1,0xfdc5,0x0296,
+0x02af,0x024d,0xfc86,0xfd06,0xfce9,0xfca7,0xfc64,0xfd5a,
+0x022a,0x0218,0x03d3,0xfdbc,0xfdee,0xfe00,0xfda7,0xfdcf,
+0xfc58,0x02d3,0x03d6,0x02b2,0xfd4a,0xfc30,0xfd6a,0xfc02,
+0xfc51,0xfc5c,0x03a8,0x03bc,0x020f,0xfc95,0xfc3b,0xfc26,
+0xfca8,0xfc82,0xfde1,0x024e,0x03ea,0x0223,0xfdbf,0xfd89,
+0xfde8,0xfd58,0xfc2c,0xfdb6,0x0205,0x028d,0x0339,0xfd6c,
+0xfcbf,0xfdf2,0xfdf6,0xfcbe,0xfd68,0x0340,0x0250,0x03ce,
+0xfc3c,0xfce8,0xfdcc,0xfd5b,0xfd52,0xfc60,0x0200,0x03bd,
+0x0387,0xfc43,0xfc79,0xfcb4,0xfe00,0xfc82,0xfce4,0x0277,
+0x0221,0x038a,0xfd60,0xfdd2,0xfc3b,0xfcf7,0xfdbb,0xfcde,
+0x0202,0x02d0,0x0289,0xfd2d,0xfd74,0xfc6f,0xfdfc,0xfc0c,
+0xfcc8,0x0254,0x02a7,0x02b6,0xfcea,0xfcd9,0xfc68,0xfd4b,
+0xfc7c,0xfc54,0x0269,0x02e4,0x03d3,0xfc84,0xfdb2,0xfd3c,
+0xfd19,0xfde9,0xfc58,0x02c7,0x02ad,0x036d,0xfc48,0xfd9f,
+0xfdb5,0xfc25,0xfc6b,0xfd10,0x028f,0x0343,0x0350,0xfdea,
+0xfde2,0xfd4d,0xfcba,0xfd57,0xfd42,0x02f2,0x0347,0x02ba,
+0xfd96,0xfdfd,0xfdc3,0xfdd4,0xfd50,0xfc46,0x0367,0x0203,
+0x0301,0xfc93,0xfd71,0xfcfa,0xfd1a,0xfdfa,0xfdbe,0x03bb,
+0x0354,0x023d,0xfce5,0xfde9,0xfc45,0xfc84,0xfd3b,0xfd7d,
+0x0280,0x035b,0x024b,0xfde7,0xfd21,0xfc26,0xfcdf,0xfd2f,
+0xfd5e,0x0318,0x035f,0x022a,0xfd65,0xfca6,0xfc59,0xfd9c,
+0xfd29,0xfda7,0x034b,0x02c4,0x02aa,0xfdb9,0xfdce,0xfc50,
+0xfd4a,0xfc2d,0xfc72,0x03cb,0x0300,0x0228,0xfd28,0xfdf4,
+0xfcc3,0xfc67,0xfdc0,0xfdac,0x037b,0x0218,0x02b2,0xfc59,
+0xfda7,0xfd2c,0xfcf8,0xfdcd,0xfc5d,0x03f8,0x0230,0x0297,
+0xfdd4,0xfd6d,0xfd29,0xfc0f,0xfd9a,0xfca4,0x021f,0x0366,
+0x02a2,0xfc64,0xfd34,0xfdc3,0xfdbf,0xfd1d,0xfc87,0x0259,
+0x03e7,0x0249,0xfdb6,0xfd52,0xfdc5,0xfd3f,0xfc31,0xfd64,
+0x03b1,0x03c6,0x0379,0xfc84,0xfccb,0xfcb8,0xfc98,0xfc70,
+0xfcfb,0x0211,0x0390,0x0309,0xfc51,0xfcdc,0xfd4c,0xfddd,
+0xfcd4,0xfdb2,0x023e,0x03fc,0x02ca,0xfdc4,0xfcdf,0xfd39,
+0xfd7d,0xfc08,0xfc1b,0x0261,0x039a,0x03a4,0xfddb,0xfdd5,
+0xfcb8,0xfd2b,0xfcc1,0xfcb0,0x0256,0x030a,0x03a1,0xfc73,
+0xfde1,0xfd3d,0xfd46,0xfdb0,0xfcb4,0x028b,0x0304,0x02e8,
+0xfc2a,0xfc4d,0xfdcf,0xfcc5,0xfdba,0xfde3,0x02b3,0x03bd,
+0x02d2,0xfd7a,0xfc30,0xfd5d,0xfc5a,0xfc82,0xfc04,0x02d9,
+0x02fe,0x03d8,0xfdde,0xfd43,0xfd20,0xfdf8,0xfdc3,0xfc4f,
+0x0223,0x0207,0x0278,0xfdd5,0xfd5d,0xfd80,0xfdb7,0xfdf2,
+0xfcf4,0x0247,0x0214,0x039a,0xfda1,0xfdf3,0xfc40,0xfd68,
+0xfdd6,0xfcc1,0x0279,0x03e3,0x025b,0xfd99,0xfd17,0xfdb6,
+0xfcf1,0xfc38,0xfd3a,0x02a5,0x023b,0x036a,0xfd0b,0xfdbe,
+0xfc2f,0xfc80,0xfd82,0xfd15,0x025a,0x0221,0x029a,0xfd7f,
+0xfcf1,0xfd3b,0xfd3c,0xfdbc,0xfc9e,0x0273,0x021e,0x036b,
+0xfd67,0xfde8,0xfc60,0xfcff,0xfdc1,0xfd14,0x02a0,0x03d7,
+0x0256,0xfd7b,0xfcee,0xfdc1,0xfc8e,0xfc50,0xfd44,0x02b4,
+0x03d3,0x02da,0xfd6a,0xfc24,0xfd46,0xfc57,0xfc57,0xfdf7,
+0x029c,0x027a,0x0368,0xfcc5,0xfdc7,0xfde4,0xfc99,0xfcef,
+0xfd1a,0x02c7,0x02c2,0x02a2,0xfc2a,0xfc57,0xfc5d,0xfc24,
+0xfc31,0xfc87,0x02e3,0x03d1,0x0253,0xfd3e,0xfca4,0xfdc8,
+0xfdea,0xfc5c,0xfd4d,0x02f7,0x0389,0x02fb,0xfd61,0xfdca,
+0xfd5d,0xfdcd,0xfce1,0xfdc7,0x02f4,0x0246,0x02fb,0xfca4,
+0xfdcd,0xfc9c,0xfdd2,0xfd69,0xfdc8,0x02ec,0x03f5,0x038c,
+0xfd1b,0xfd68,0xfc7e,0xfddd,0xfc16,0xfcdb,0x0324,0x03a9,
+0x03b6,0xfd20,0xfd16,0xfc9b,0xfd89,0xfca6,0xfc8e,0x0311,
+0x021f,0x03e6,0xfcbf,0xfd02,0xfdef,0xfda6,0xfdc0,0xfc33,
+0x03e7,0x02ac,0x03ae,0xfd64,0xfc68,0xfd8a,0xfc31,0xfc6d,
+0xfc9c,0x0272,0x0279,0x03e4,0xfcfa,0xfd9f,0xfd98,0xfd03,
+0xfcf1,0xfc36,0x0272,0x0237,0x0343,0xfd4b,0xfc03,0xfc63,
+0xfd03,0xfd8c,0xfd57,0x02e3,0x023b,0x03cd,0xfcc7,0xfd42,
+0xfde1,0xfdeb,0xfd83,0xfc63,0x028f,0x0301,0x02c3,0xfc28,
+0xfc76,0xfded,0xfcb9,0xfdbf,0xfc2e,0x02be,0x03b8,0x023b,
+0xfd73,0xfcef,0xfdec,0xfc3c,0xfc8a,0xfd82,0x02d7,0x02c8,
+0x0202,0xfc0c,0xfd26,0xfd35,0xfdfc,0xfc22,0xfdfc,0x02e8,
+0x02ae,0x02e5,0xfc1a,0xfde5,0xfc1e,0xfde3,0xfc67,0xfde8,
+0x02db,0x0228,0x02ca,0xfceb,0xfc03,0xfcfc,0xfdf6,0xfdac,
+0xfc1a,0x0338,0x03df,0x02d6,0xfce2,0xfdb7,0xfd41,0xfd68,
+0xfc41,0xfdfd,0x031b,0x0267,0x0220,0xfc45,0xfcb4,0xfd73,
+0xfd97,0xfd1e,0xfdbe,0x0366,0x023f,0x0338,0xfc2e,0xfd44,
+0xfc62,0xfd1d,0xfd7a,0xfd68,0x0323,0x0340,0x039b,0xfd73,
+0xfd2c,0xfd12,0xfd8a,0xfd5b,0xfcc0,0x0333,0x0347,0x0213,
+0xfd61,0xfcaf,0xfc99,0xfd71,0xfd50,0xfdda,0x0377,0x0312,
+0x0354,0xfd57,0xfd1e,0xfd72,0xfcff,0xfda5,0xfd3b,0x03a5,
+0x02fc,0x023a,0xfd48,0xfdf9,0xfcad,0xfcae,0xfdc6,0xfd86,
+0x02cc,0x038a,0x028e,0xfd86,0xfc6c,0xfdbd,0xfc15,0xfcde,
+0xfcbb,0x0310,0x0324,0x0233,0xfd98,0xfca0,0xfc8b,0xfda7,
+0xfd89,0xfd94,0x0306,0x0217,0x036c,0xfcd7,0xfd6a,0xfc6d,
+0xfdb7,0xfdd1,0xfd13,0x0327,0x0256,0x0289,0xfc51,0xfc01,
+0xfd0a,0xfd84,0xfd45,0xfcca,0x0331,0x02f7,0x02ce,0xfda2,
+0xfdc3,0xfdeb,0xfd74,0xfdcd,0xfc10,0x033f,0x03e1,0x034e,
+0xfcda,0xfd51,0xfccb,0xfd5d,0xfc3d,0xfd45,0x035a,0x0237,
+0x025d,0xfc49,0xfc09,0xfd62,0xfd30,0xfd8c,0xfd34,0x036c,
+0x03f4,0x028b,0xfc9e,0xfdd3,0xfd7d,0xfd12,0xfc17,0xfcc5,
+0x0354,0x0224,0x0225,0xfc6f,0xfc6e,0xfdb4,0xfd3a,0xfdb5,
+0xfdb3,0x037f,0x03f0,0x0367,0xfc8f,0xfd07,0xfca6,0xfcf2,
+0xfc1f,0xfd1b,0x037c,0x03e8,0x024f,0xfc98,0xfdfd,0xfdbe,
+0xfcf7,0xfc2f,0xfd55,0x03a7,0x0204,0x0344,0xfc50,0xfd04,
+0xfcb4,0xfca9,0xfdf7,0xfd56,0x03a3,0x0264,0x0308,0xfdd3,
+0xfd3e,0xfc5f,0xfcb1,0xfd23,0xfdb3,0x03c8,0x0266,0x0330,
+0xfdbb,0xfcfd,0xfc2c,0xfc6d,0xfd1e,0xfd75,0x020c,0x0309,
+0x02cf,0xfce4,0xfd1f,0xfdde,0xfde7,0xfdb2,0xfc0c,0x0225,
+0x02b6,0x0312,0xfd18,0xfcb5,0xfdeb,0xfdb3,0xfc53,0xfda5,
+0x0372,0x02f2,0x0216,0xfd77,0xfc68,0xfced,0xfd09,0xfdd5,
+0xfdd3,0x0255,0x0345,0x02fe,0xfc2f,0xfc81,0xfd8d,0xfd47,
+0xfd54,0xfdc2,0x027b,0x03ba,0x02c0,0xfdb0,0xfc97,0xfd70,
+0xfcec,0xfc86,0xfc37,0x0323,0x0226,0x031e,0xfca1,0xfd8e,
+0xfca6,0xfd8a,0xfdb1,0xfd92,0x02bb,0x028e,0x031e,0xfc82,
+0xfddf,0xfc03,0xfc46,0xfcbb,0xfd92,0x039c,0x02ff,0x02e2,
+0xfd4b,0xfd66,0xfdd7,0xfcbe,0xfdc1,0xfded,0x03ca,0x02a3,
+0x0260,0xfd81,0xfdc0,0xfcdf,0xfc69,0xfc86,0xfd2e,0x0278,
+0x02c2,0x02ac,0xfc97,0xfcb4,0xfc50,0xfcf4,0xfc30,0xfc6e,
+0x035a,0x02ff,0x0233,0xfd7d,0xfc4f,0xfcb4,0xfd31,0xfdc2,
+0xfd94,0x020f,0x02fd,0x02be,0xfcec,0xfd2c,0xfdf3,0xfde1,
+0xfdc4,0xfc3c,0x022f,0x039c,0x03eb,0xfc0f,0xfddd,0xfc77,
+0xfd9e,0xfcbf,0xfc29,0x026a,0x020c,0x0263,0xfd87,0xfd1e,
+0xfd8f,0xfd15,0xfde8,0xfd27,0x03e7,0x03ae,0x03c3,0xfc68,
+0xfc54,0xfc8a,0xfc30,0xfc9d,0xfc77,0x0223,0x0359,0x03a7,
+0xfc6c,0xfc19,0xfcf1,0xfdb8,0xfd32,0xfcaa,0x02de,0x039e,
+0x0239,0xfd67,0xfcce,0xfdfd,0xfdf1,0xfcba,0xfd86,0x03c7,
+0x02ea,0x0227,0xfd3f,0xfdf8,0xfcdc,0xfc6f,0xfde0,0xfdaf,
+0x0342,0x0279,0x0371,0xfdfd,0xfd32,0xfddf,0xfd59,0xfcf1,
+0xfd0a,0x03ad,0x02bd,0x02d7,0xfd7b,0xfd64,0xfc1b,0xfc9f,
+0xfc3f,0xfdfc,0x03b1,0x0234,0x027c,0xfdf7,0xfdb5,0xfd43,
+0xfc97,0xfd91,0xfcea,0x0200,0x0233,0x0319,0xfdcd,0xfce6,
+0xfc97,0xfe00,0xfd95,0xfd99,0x03d8,0x022c,0x023a,0xfdea,
+0xfddc,0xfd94,0xfc4f,0xfda4,0xfd84,0x03d8,0x021c,0x02e4,
+0xfdf9,0xfd38,0xfcf2,0xfc4e,0xfdc6,0xfde8,0x020f,0x02fc,
+0x036a,0xfced,0xfc7b,0xfd74,0xfde1,0xfdc6,0xfd15,0x0212,
+0x0298,0x03f6,0xfd50,0xfdf3,0xfd6e,0xfddb,0xfca2,0xfc13,
+0x0222,0x0203,0x0209,0xfdda,0xfdd4,0xfdf3,0xfdb8,0xfdf9,
+0xfded,0x022a,0x03a6,0x02a0,0xfc0d,0xfd28,0xfd9b,0xfda8,
+0xfcac,0xfc8e,0x0256,0x03b1,0x022c,0xfdd8,0xfd76,0xfdff,
+0xfd44,0xfc98,0xfda5,0x0273,0x0213,0x02dd,0xfd75,0xfc7d,
+0xfd08,0xfcff,0xfdd9,0xfdf3,0x0240,0x03fc,0x03f6,0xfdc2,
+0xfdc5,0xfc0d,0xfd76,0xfc08,0xfc13,0x026f,0x039c,0x0252,
+0xfdcd,0xfd2c,0xfde7,0xfd09,0xfcbd,0xfd4d,0x02a6,0x038d,
+0x025b,0xfda6,0xfce0,0xfde8,0xfc7d,0xfcd9,0xfd38,0x032e,
+0x02e8,0x021f,0xfdb0,0xfc9f,0xfcea,0xfd78,0xfde3,0xfdbf};
+
+const unsigned short wavtable2[2304]={
+0x0e,0x0e,0x0e,0x14,0x14,0x13,0x15,0x14,0x14,0x0e,0x0e,0x0e,
+0x14,0x14,0x14,0x14,0x15,0x15,0x0e,0x0d,0x0e,0x12,0x14,0x13,
+0x15,0x12,0x15,0x0d,0x0d,0x0e,0x12,0x13,0x13,0x13,0x12,0x15,
+0x0d,0x0e,0x0d,0x13,0x12,0x12,0x13,0x14,0x13,0x0d,0x0e,0x0f,
+0x13,0x13,0x14,0x13,0x15,0x16,0x0d,0x0d,0x0d,0x11,0x11,0x12,
+0x12,0x13,0x13,0x0c,0x0e,0x0d,0x12,0x11,0x13,0x11,0x14,0x13,
+0x0d,0x0d,0x0d,0x12,0x12,0x11,0x13,0x12,0x12,0x0d,0x0d,0x0c,
+0x12,0x11,0x11,0x12,0x13,0x11,0x0d,0x0c,0x0d,0x11,0x11,0x10,
+0x12,0x11,0x12,0x0c,0x0d,0x0c,0x11,0x10,0x11,0x11,0x13,0x11,
+0x0c,0x0d,0x0d,0x10,0x11,0x11,0x11,0x12,0x12,0x0c,0x0d,0x0d,
+0x10,0x10,0x11,0x10,0x13,0x12,0x0c,0x0c,0x0d,0x0f,0x10,0x10,
+0x10,0x11,0x12,0x0b,0x0d,0x0d,0x0f,0x0f,0x11,0x0f,0x12,0x12,
+0x0d,0x0c,0x0d,0x10,0x11,0x11,0x12,0x10,0x13,0x0c,0x0c,0x0c,
+0x10,0x10,0x10,0x11,0x10,0x11,0x0d,0x0c,0x0c,0x11,0x11,0x0f,
+0x13,0x10,0x10,0x0d,0x0c,0x0b,0x10,0x10,0x0e,0x13,0x10,0x0f,
+0x0c,0x0c,0x0c,0x10,0x10,0x10,0x11,0x11,0x11,0x0c,0x0d,0x0b,
+0x10,0x0f,0x10,0x11,0x12,0x0f,0x0c,0x0c,0x0b,0x10,0x0e,0x0f,
+0x10,0x11,0x0f,0x0b,0x0d,0x0c,0x0f,0x0f,0x10,0x0f,0x12,0x10,
+0x0c,0x0c,0x0c,0x0f,0x0f,0x0f,0x10,0x10,0x10,0x0b,0x0c,0x0c,
+0x0f,0x0e,0x0f,0x0f,0x10,0x10,0x0b,0x0c,0x0c,0x0f,0x0f,0x10,
+0x0f,0x10,0x11,0x0b,0x0c,0x0d,0x0f,0x0f,0x10,0x0e,0x11,0x12,
+0x0b,0x0c,0x0b,0x0f,0x0e,0x0f,0x0f,0x11,0x0f,0x0b,0x0c,0x0b,
+0x0f,0x0e,0x0f,0x0e,0x11,0x0f,0x0b,0x0d,0x0c,0x0f,0x0e,0x10,
+0x0e,0x12,0x11,0x0b,0x0c,0x0c,0x0e,0x0e,0x10,0x0e,0x11,0x11,
+0x0c,0x0c,0x0c,0x0f,0x10,0x0f,0x11,0x10,0x11,0x0c,0x0b,0x0c,
+0x0f,0x10,0x0f,0x11,0x0f,0x10,0x0c,0x0c,0x0b,0x0f,0x0f,0x0f,
+0x11,0x10,0x0f,0x0c,0x0c,0x0b,0x0f,0x0e,0x0e,0x10,0x10,0x0f,
+0x0d,0x0b,0x0b,0x0f,0x0f,0x0e,0x12,0x0f,0x0f,0x0c,0x0b,0x0a,
+0x0f,0x0e,0x0d,0x11,0x0f,0x0d,0x0b,0x0b,0x0b,0x0e,0x0e,0x0e,
+0x0f,0x0f,0x0e,0x0b,0x0b,0x0a,0x0e,0x0d,0x0d,0x0f,0x0f,0x0d,
+0x0c,0x0b,0x0c,0x0e,0x0f,0x0f,0x10,0x0f,0x11,0x0b,0x0b,0x0c,
+0x0e,0x0f,0x0f,0x0f,0x0f,0x10,0x0b,0x0c,0x0b,0x0e,0x0e,0x0e,
+0x0f,0x10,0x0f,0x0b,0x0b,0x0b,0x0e,0x0e,0x0e,0x0e,0x0f,0x0f,
+0x0b,0x0b,0x0c,0x0e,0x0e,0x0f,0x0e,0x0f,0x10,0x0b,0x0b,0x0c,
+0x0e,0x0e,0x0f,0x0e,0x0f,0x11,0x0b,0x0c,0x0c,0x0e,0x0e,0x0f,
+0x0e,0x10,0x10,0x0a,0x0c,0x0c,0x0d,0x0e,0x0f,0x0d,0x10,0x10,
+0x0b,0x0c,0x0b,0x0e,0x0d,0x0e,0x0e,0x10,0x0e,0x0b,0x0b,0x0b,
+0x0e,0x0d,0x0e,0x0e,0x0f,0x0e,0x0a,0x0c,0x0b,0x0e,0x0d,0x0e,
+0x0d,0x11,0x0e,0x0a,0x0c,0x0b,0x0e,0x0d,0x0e,0x0d,0x10,0x0e,
+0x0b,0x0b,0x0b,0x0d,0x0d,0x0e,0x0e,0x0f,0x0f,0x0a,0x0b,0x0b,
+0x0d,0x0d,0x0e,0x0d,0x0f,0x0f,0x0a,0x0b,0x0c,0x0d,0x0e,0x0e,
+0x0d,0x0f,0x10,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x0d,0x0f,0x10,
+0x0b,0x0c,0x0b,0x0e,0x0d,0x0f,0x0e,0x10,0x0f,0x0a,0x0c,0x0c,
+0x0e,0x0d,0x0f,0x0d,0x11,0x10,0x0a,0x0d,0x0c,0x0e,0x0e,0x10,
+0x0d,0x12,0x10,0x0a,0x0c,0x0d,0x0e,0x0e,0x10,0x0d,0x11,0x12,
+0x0a,0x0c,0x0b,0x0d,0x0d,0x0f,0x0d,0x10,0x0f,0x0a,0x0c,0x0b,
+0x0d,0x0d,0x0f,0x0d,0x10,0x0f,0x0a,0x0c,0x0c,0x0e,0x0d,0x10,
+0x0d,0x11,0x10,0x0a,0x0c,0x0c,0x0d,0x0e,0x10,0x0c,0x10,0x11,
+0x0c,0x0b,0x0c,0x0f,0x10,0x0e,0x11,0x0e,0x10,0x0c,0x0b,0x0b,
+0x0e,0x0f,0x0d,0x11,0x0e,0x0f,0x0b,0x0b,0x0c,0x0e,0x0e,0x0e,
+0x0f,0x0e,0x10,0x0b,0x0b,0x0b,0x0d,0x0e,0x0e,0x0e,0x0e,0x0f,
+0x0b,0x0a,0x0b,0x0d,0x0e,0x0d,0x0f,0x0d,0x0f,0x0b,0x0a,0x0b,
+0x0d,0x0e,0x0d,0x0f,0x0d,0x0f,0x0c,0x0a,0x0a,0x0e,0x0e,0x0c,
+0x11,0x0d,0x0d,0x0c,0x0a,0x0a,0x0d,0x0d,0x0b,0x10,0x0d,0x0c,
+0x0b,0x0b,0x0b,0x0e,0x0e,0x0d,0x0f,0x0e,0x0e,0x0b,0x0b,0x0a,
+0x0d,0x0d,0x0d,0x0f,0x0e,0x0d,0x0b,0x0b,0x0a,0x0e,0x0c,0x0d,
+0x0e,0x0f,0x0d,0x0a,0x0c,0x0a,0x0e,0x0c,0x0d,0x0d,0x10,0x0c,
+0x0b,0x0b,0x0b,0x0d,0x0e,0x0d,0x0e,0x0e,0x0f,0x0b,0x0b,0x0b,
+0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0a,0x0b,0x0b,0x0d,0x0d,0x0e,
+0x0d,0x0e,0x0f,0x0a,0x0b,0x0b,0x0c,0x0d,0x0d,0x0d,0x0e,0x0f,
+0x0b,0x0a,0x0b,0x0d,0x0d,0x0d,0x0e,0x0d,0x0e,0x0b,0x0b,0x0a,
+0x0d,0x0c,0x0d,0x0e,0x0e,0x0d,0x0b,0x0a,0x0a,0x0c,0x0c,0x0c,
+0x0e,0x0d,0x0d,0x0a,0x0a,0x0a,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,
+0x0b,0x0b,0x0a,0x0d,0x0c,0x0c,0x0e,0x0e,0x0c,0x0a,0x0b,0x0a,
+0x0d,0x0c,0x0c,0x0d,0x0e,0x0c,0x0a,0x0b,0x0a,0x0c,0x0b,0x0c,
+0x0d,0x0e,0x0c,0x0a,0x0b,0x0a,0x0c,0x0b,0x0c,0x0c,0x0e,0x0c,
+0x0a,0x0a,0x0b,0x0c,0x0d,0x0d,0x0d,0x0d,0x0f,0x0a,0x0a,0x0b,
+0x0c,0x0d,0x0d,0x0d,0x0d,0x0e,0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,
+0x0c,0x0e,0x0e,0x0a,0x0b,0x0b,0x0c,0x0d,0x0d,0x0c,0x0e,0x0f,
+0x0a,0x0a,0x0b,0x0c,0x0c,0x0c,0x0c,0x0d,0x0e,0x0a,0x0a,0x0a,
+0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,
+0x0c,0x0d,0x0e,0x09,0x0a,0x0b,0x0b,0x0c,0x0d,0x0b,0x0d,0x0e,
+0x0b,0x0b,0x0b,0x0d,0x0d,0x0d,0x0e,0x0f,0x0e,0x0a,0x0b,0x0b,
+0x0d,0x0c,0x0d,0x0d,0x0f,0x0e,0x0a,0x0b,0x0a,0x0d,0x0c,0x0d,
+0x0d,0x0f,0x0d,0x0a,0x0b,0x0b,0x0d,0x0c,0x0d,0x0c,0x0f,0x0e,
+0x0a,0x0b,0x0b,0x0d,0x0d,0x0e,0x0d,0x0f,0x0f,0x0a,0x0b,0x0b,
+0x0d,0x0d,0x0e,0x0c,0x0f,0x0f,0x0a,0x0b,0x0b,0x0d,0x0d,0x0e,
+0x0c,0x0f,0x0f,0x0a,0x0b,0x0c,0x0c,0x0d,0x0f,0x0c,0x0f,0x10,
+0x0a,0x0c,0x0b,0x0e,0x0c,0x0e,0x0d,0x10,0x0e,0x0a,0x0c,0x0b,
+0x0e,0x0c,0x0f,0x0c,0x11,0x0e,0x0a,0x0c,0x0c,0x0d,0x0d,0x0f,
+0x0c,0x10,0x10,0x0a,0x0d,0x0c,0x0e,0x0d,0x10,0x0c,0x12,0x11,
+0x0a,0x0c,0x0b,0x0d,0x0c,0x0f,0x0c,0x10,0x0f,0x0a,0x0c,0x0b,
+0x0d,0x0c,0x0e,0x0c,0x10,0x0f,0x0a,0x0c,0x0c,0x0d,0x0d,0x0f,
+0x0c,0x11,0x10,0x0a,0x0c,0x0c,0x0d,0x0d,0x10,0x0c,0x10,0x11,
+0x0a,0x0c,0x0a,0x0d,0x0c,0x0e,0x0c,0x10,0x0d,0x0a,0x0c,0x0b,
+0x0d,0x0c,0x0e,0x0c,0x10,0x0e,0x0a,0x0c,0x0a,0x0d,0x0b,0x0d,
+0x0c,0x10,0x0d,0x0a,0x0b,0x0b,0x0c,0x0c,0x0e,0x0c,0x0f,0x0e,
+0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0c,0x0e,0x0e,0x0a,0x0b,0x0b,
+0x0c,0x0c,0x0e,0x0c,0x0f,0x0f,0x09,0x0b,0x0b,0x0c,0x0c,0x0e,
+0x0b,0x0f,0x0f,0x09,0x0b,0x0c,0x0c,0x0d,0x0e,0x0b,0x0f,0x10,
+0x0a,0x0c,0x0b,0x0d,0x0c,0x0f,0x0c,0x11,0x0e,0x09,0x0c,0x0b,
+0x0d,0x0c,0x0f,0x0b,0x11,0x0f,0x09,0x0c,0x0c,0x0d,0x0c,0x0f,
+0x0b,0x10,0x10,0x09,0x0c,0x0c,0x0d,0x0d,0x10,0x0b,0x11,0x11,
+0x09,0x0c,0x0b,0x0d,0x0c,0x0f,0x0b,0x11,0x0e,0x09,0x0c,0x0c,
+0x0d,0x0c,0x10,0x0b,0x11,0x10,0x09,0x0c,0x0c,0x0d,0x0c,0x0f,
+0x0b,0x11,0x10,0x09,0x0d,0x0c,0x0d,0x0d,0x10,0x0b,0x12,0x11,
+0x0c,0x0a,0x0b,0x0d,0x0e,0x0c,0x10,0x0c,0x0e,0x0b,0x0a,0x0a,
+0x0c,0x0d,0x0c,0x0e,0x0c,0x0d,0x0a,0x0a,0x0b,0x0c,0x0d,0x0c,
+0x0d,0x0c,0x0f,0x0a,0x0a,0x0a,0x0c,0x0c,0x0c,0x0d,0x0c,0x0d,
+0x0b,0x09,0x0a,0x0c,0x0d,0x0b,0x0f,0x0b,0x0d,0x0b,0x0a,0x0a,
+0x0c,0x0c,0x0b,0x0e,0x0c,0x0c,0x0a,0x0a,0x09,0x0b,0x0b,0x0b,
+0x0d,0x0c,0x0b,0x0a,0x0a,0x09,0x0b,0x0b,0x0a,0x0d,0x0c,0x0a,
+0x0a,0x0a,0x0a,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0a,0x0a,0x0a,
+0x0c,0x0b,0x0c,0x0c,0x0d,0x0d,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,
+0x0c,0x0c,0x0d,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,
+0x0a,0x0a,0x0a,0x0c,0x0b,0x0b,0x0c,0x0d,0x0c,0x0a,0x0a,0x09,
+0x0b,0x0b,0x0b,0x0c,0x0d,0x0b,0x09,0x0a,0x09,0x0b,0x0a,0x0b,
+0x0b,0x0c,0x0b,0x09,0x0a,0x09,0x0b,0x0a,0x0b,0x0b,0x0d,0x0b,
+0x0a,0x09,0x0b,0x0b,0x0c,0x0b,0x0d,0x0b,0x0e,0x0a,0x0a,0x0a,
+0x0b,0x0c,0x0b,0x0d,0x0c,0x0d,0x0a,0x0a,0x0a,0x0b,0x0c,0x0c,
+0x0c,0x0c,0x0d,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0d,
+0x0a,0x09,0x0a,0x0b,0x0c,0x0a,0x0d,0x0b,0x0c,0x0a,0x09,0x0a,
+0x0b,0x0b,0x0a,0x0c,0x0b,0x0c,0x09,0x0a,0x0a,0x0b,0x0b,0x0b,
+0x0b,0x0c,0x0c,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,
+0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0b,0x0d,0x0d,0x09,0x0a,0x0a,
+0x0b,0x0b,0x0c,0x0b,0x0d,0x0d,0x09,0x0a,0x0b,0x0b,0x0b,0x0c,
+0x0b,0x0c,0x0e,0x09,0x0a,0x0b,0x0b,0x0b,0x0c,0x0b,0x0d,0x0e,
+0x09,0x0a,0x0a,0x0a,0x0a,0x0b,0x0b,0x0c,0x0c,0x09,0x0a,0x0a,
+0x0a,0x0a,0x0b,0x0a,0x0c,0x0d,0x09,0x09,0x0a,0x0a,0x0a,0x0b,
+0x0a,0x0b,0x0c,0x09,0x0a,0x0a,0x0a,0x0a,0x0c,0x0a,0x0c,0x0d,
+0x0a,0x0b,0x0a,0x0c,0x0c,0x0d,0x0d,0x0e,0x0d,0x0a,0x0b,0x0a,
+0x0c,0x0c,0x0d,0x0c,0x0e,0x0d,0x0a,0x0b,0x0a,0x0c,0x0b,0x0d,
+0x0c,0x0f,0x0d,0x0a,0x0b,0x0a,0x0c,0x0b,0x0d,0x0c,0x0e,0x0d,
+0x0a,0x0a,0x0a,0x0c,0x0b,0x0c,0x0c,0x0d,0x0d,0x0a,0x0a,0x0a,
+0x0b,0x0b,0x0c,0x0c,0x0d,0x0d,0x09,0x0b,0x0a,0x0c,0x0b,0x0c,
+0x0b,0x0e,0x0d,0x09,0x0b,0x0a,0x0b,0x0b,0x0c,0x0b,0x0e,0x0d,
+0x0a,0x0b,0x0b,0x0c,0x0c,0x0d,0x0c,0x0e,0x0e,0x09,0x0b,0x0b,
+0x0c,0x0c,0x0d,0x0b,0x0e,0x0e,0x09,0x0b,0x0b,0x0b,0x0c,0x0d,
+0x0b,0x0e,0x0f,0x09,0x0b,0x0c,0x0b,0x0c,0x0e,0x0b,0x0e,0x10,
+0x09,0x0b,0x0b,0x0c,0x0b,0x0d,0x0b,0x0e,0x0e,0x09,0x0b,0x0b,
+0x0c,0x0c,0x0d,0x0b,0x0e,0x0e,0x09,0x0b,0x0b,0x0b,0x0c,0x0d,
+0x0b,0x0e,0x0f,0x09,0x0b,0x0c,0x0b,0x0c,0x0e,0x0a,0x0e,0x10,
+0x09,0x0b,0x0a,0x0c,0x0b,0x0d,0x0b,0x0f,0x0d,0x09,0x0b,0x0b,
+0x0c,0x0b,0x0e,0x0b,0x0f,0x0e,0x09,0x0c,0x0a,0x0c,0x0b,0x0d,
+0x0b,0x10,0x0d,0x09,0x0b,0x0b,0x0c,0x0b,0x0e,0x0b,0x0f,0x0e,
+0x09,0x0b,0x0b,0x0c,0x0c,0x0e,0x0b,0x0f,0x0f,0x09,0x0b,0x0c,
+0x0c,0x0c,0x0f,0x0b,0x0f,0x10,0x09,0x0c,0x0b,0x0c,0x0c,0x0e,
+0x0b,0x10,0x0f,0x09,0x0c,0x0c,0x0c,0x0d,0x0f,0x0b,0x10,0x10,
+0x09,0x0c,0x0b,0x0d,0x0b,0x0e,0x0b,0x11,0x0e,0x09,0x0c,0x0b,
+0x0d,0x0c,0x0f,0x0b,0x11,0x0f,0x09,0x0c,0x0b,0x0c,0x0c,0x0e,
+0x0a,0x10,0x0f,0x09,0x0c,0x0c,0x0c,0x0c,0x0f,0x0a,0x10,0x10,
+0x09,0x0c,0x0b,0x0d,0x0b,0x0f,0x0a,0x11,0x0e,0x09,0x0d,0x0c,
+0x0d,0x0c,0x10,0x0a,0x12,0x10,0x09,0x0d,0x0c,0x0d,0x0c,0x10,
+0x0a,0x12,0x10,0x09,0x0c,0x0d,0x0d,0x0d,0x10,0x0a,0x11,0x12,
+0x0a,0x0b,0x0a,0x0c,0x0b,0x0c,0x0c,0x0f,0x0c,0x09,0x0b,0x0a,
+0x0c,0x0a,0x0c,0x0b,0x0f,0x0c,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,
+0x0b,0x0d,0x0c,0x09,0x0a,0x0a,0x0b,0x0a,0x0b,0x0a,0x0d,0x0c,
+0x09,0x0b,0x0a,0x0c,0x0b,0x0c,0x0b,0x0e,0x0d,0x09,0x0b,0x0a,
+0x0b,0x0b,0x0c,0x0b,0x0e,0x0d,0x09,0x0b,0x0a,0x0c,0x0b,0x0d,
+0x0a,0x0f,0x0d,0x09,0x0b,0x0b,0x0c,0x0b,0x0e,0x0a,0x0f,0x0e,
+0x09,0x0a,0x0a,0x0b,0x0b,0x0c,0x0a,0x0d,0x0d,0x09,0x0b,0x0a,
+0x0b,0x0a,0x0c,0x0a,0x0e,0x0c,0x09,0x0a,0x0a,0x0b,0x0b,0x0c,
+0x0a,0x0d,0x0d,0x09,0x0a,0x0b,0x0b,0x0b,0x0d,0x0a,0x0d,0x0e,
+0x09,0x0b,0x0b,0x0b,0x0b,0x0d,0x0a,0x0e,0x0e,0x09,0x0b,0x0b,
+0x0b,0x0c,0x0e,0x0a,0x0e,0x0f,0x09,0x0b,0x0b,0x0b,0x0b,0x0d,
+0x0a,0x0e,0x0e,0x09,0x0b,0x0b,0x0b,0x0b,0x0e,0x0a,0x0e,0x0f,
+0x09,0x0c,0x0a,0x0c,0x0b,0x0d,0x0b,0x10,0x0d,0x09,0x0c,0x0a,
+0x0c,0x0b,0x0e,0x0a,0x10,0x0d,0x09,0x0b,0x0b,0x0c,0x0b,0x0e,
+0x0a,0x0f,0x0e,0x09,0x0b,0x0b,0x0c,0x0c,0x0e,0x0a,0x0f,0x0f,
+0x09,0x0c,0x0b,0x0c,0x0b,0x0e,0x0a,0x10,0x0f,0x09,0x0c,0x0c,
+0x0c,0x0c,0x0f,0x0a,0x10,0x10,0x09,0x0c,0x0b,0x0d,0x0c,0x0f,
+0x0a,0x11,0x0f,0x09,0x0d,0x0c,0x0d,0x0c,0x10,0x0a,0x12,0x11,
+0x09,0x0b,0x0a,0x0c,0x0b,0x0d,0x0a,0x0f,0x0d,0x09,0x0c,0x0b,
+0x0c,0x0b,0x0e,0x0a,0x10,0x0e,0x09,0x0c,0x0b,0x0c,0x0b,0x0e,
+0x0a,0x10,0x0f,0x09,0x0b,0x0c,0x0c,0x0c,0x0f,0x0a,0x0f,0x10,
+0x09,0x0c,0x0b,0x0c,0x0b,0x0f,0x0a,0x11,0x0e,0x09,0x0c,0x0c,
+0x0c,0x0c,0x10,0x0a,0x11,0x10,0x08,0x0c,0x0b,0x0c,0x0b,0x0e,
+0x09,0x10,0x0f,0x08,0x0c,0x0c,0x0c,0x0c,0x0f,0x09,0x11,0x10,
+0x0a,0x09,0x09,0x0a,0x0b,0x0a,0x0c,0x0a,0x0b,0x09,0x09,0x09,
+0x0a,0x0a,0x09,0x0b,0x0a,0x0a,0x09,0x0a,0x09,0x0a,0x0a,0x0a,
+0x0b,0x0c,0x0b,0x09,0x09,0x09,0x0a,0x09,0x0a,0x0a,0x0b,0x0a,
+0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x09,0x09,0x0a,
+0x09,0x0a,0x0a,0x0a,0x0a,0x0c,0x09,0x09,0x09,0x09,0x09,0x0a,
+0x0a,0x0b,0x0b,0x08,0x09,0x09,0x09,0x09,0x0a,0x09,0x0b,0x0b,
+0x09,0x0a,0x09,0x0a,0x0a,0x0b,0x0a,0x0c,0x0b,0x08,0x0a,0x09,
+0x0a,0x09,0x0a,0x09,0x0c,0x0b,0x08,0x0a,0x0a,0x0a,0x09,0x0b,
+0x09,0x0c,0x0c,0x08,0x09,0x0a,0x09,0x0a,0x0b,0x09,0x0b,0x0d,
+0x09,0x09,0x09,0x09,0x09,0x09,0x0a,0x0a,0x0a,0x07,0x08,0x08,
+0x07,0x07,0x07,0x07,0x08,0x08,0x08,0x0a,0x09,0x09,0x09,0x0a,
+0x08,0x0c,0x0b,0x08,0x09,0x09,0x08,0x08,0x0a,0x08,0x0a,0x0b,
+0x09,0x0b,0x0a,0x0b,0x0a,0x0c,0x0a,0x0f,0x0c,0x09,0x0b,0x0a,
+0x0b,0x0a,0x0d,0x0a,0x0f,0x0c,0x09,0x0a,0x0a,0x0a,0x0a,0x0c,
+0x0a,0x0d,0x0d,0x08,0x0a,0x0b,0x0a,0x0b,0x0d,0x09,0x0d,0x0e,
+0x09,0x0b,0x0a,0x0b,0x0a,0x0d,0x0a,0x0f,0x0d,0x09,0x0b,0x0b,
+0x0b,0x0b,0x0e,0x0a,0x0f,0x0e,0x08,0x0b,0x0b,0x0b,0x0b,0x0d,
+0x09,0x0e,0x0e,0x08,0x0b,0x0c,0x0b,0x0b,0x0e,0x09,0x0f,0x10,
+0x08,0x0a,0x09,0x0a,0x09,0x0b,0x09,0x0d,0x0b,0x08,0x0b,0x0a,
+0x0b,0x0a,0x0c,0x09,0x0e,0x0d,0x08,0x0b,0x0a,0x0a,0x0a,0x0c,
+0x09,0x0e,0x0d,0x08,0x0a,0x0b,0x0a,0x0b,0x0d,0x09,0x0d,0x0e,
+0x08,0x0c,0x0b,0x0b,0x0a,0x0e,0x09,0x10,0x0e,0x08,0x0c,0x0b,
+0x0b,0x0b,0x0e,0x09,0x10,0x0f,0x08,0x0b,0x0a,0x0a,0x0a,0x0c,
+0x09,0x0e,0x0d,0x08,0x0b,0x0a,0x0a,0x0a,0x0d,0x08,0x0e,0x0d};
+
+const signed short etable1[5120]={
+0x0026,0xfffc,0x000f,0xfffc,0x000e,0xfff3,0x000c,0xfff5,
+0xfffe,0xfffa,0xfffa,0xfff5,0xffd3,0xfff0,0xfff5,0xfff3,
+0xfff9,0x0006,0xfff4,0x0004,0xffec,0x0003,0xfff0,0x000c,
+0xffff,0x000c,0x002e,0x0018,0x0000,0x0021,0xfffd,0x0009,
+0xfff4,0xfff4,0xfff8,0xfff9,0x0011,0xfffa,0x0000,0xfffe,
+0x003c,0xfff0,0x0003,0xffea,0x000a,0xffe0,0x0000,0xffe4,
+0xffef,0xffee,0xfffd,0xffe7,0xffdb,0xffe9,0xfff6,0x0003,
+0x0002,0x0003,0x0000,0x0003,0xfff2,0x0000,0xfff2,0xffff,
+0x0000,0x0002,0x0020,0x0009,0xffff,0x0019,0x0007,0x000d,
+0xfffb,0x000d,0x0008,0x0001,0x0002,0x0008,0xfff6,0x0006,
+0x001b,0xfff4,0x001c,0xfffe,0x0006,0xfff9,0x000f,0x0009,
+0xfff5,0x0001,0xfff3,0xfff5,0xffd8,0x0004,0xffe3,0xfff2,
+0xffed,0xfffb,0xffe9,0xfff8,0xffe2,0xfff3,0xffef,0x0000,
+0xfff2,0x000c,0x0022,0x0014,0xfffe,0x0019,0x0002,0xfff0,
+0xfffc,0xfff4,0x000f,0x0010,0x001d,0x0007,0x0018,0x000a,
+0x0031,0xffe8,0x0010,0xffec,0x0002,0xffe6,0x0002,0xfff9,
+0xffe7,0xfff6,0xfff5,0xffe7,0xffe0,0xfffd,0xffe5,0x0002,
+0xfff8,0xfff8,0xfff5,0xfff7,0xffe8,0xffef,0xfff0,0xfff2,
+0xfff3,0x0002,0x0014,0x0005,0xfffc,0x0011,0x000e,0xfff4,
+0x0003,0x000d,0x0021,0x0019,0x000e,0x0017,0x000f,0x0013,
+0x002e,0xfffa,0x0015,0x0008,0xfffe,0xfff0,0xfffb,0xfff8,
+0xfff5,0x0004,0x0008,0x000f,0xffe8,0x0004,0xfffe,0xffe6,
+0xfffd,0xfff0,0xfff0,0xfff2,0xfff7,0xfffe,0xffff,0x0004,
+0x0013,0x0007,0x0024,0x0011,0x0009,0x000d,0x0000,0x001f,
+0xfffb,0xfff4,0x0007,0xfff8,0x000b,0xfff1,0xfff3,0xfffc,
+0x0044,0xffee,0x0009,0xfff7,0xfffa,0xffdd,0xffee,0xffe7,
+0xffe6,0xfff9,0x000a,0x0001,0xfff0,0xfffd,0xffff,0xfff7,
+0x0006,0xffed,0xfffc,0xfff1,0xfffc,0xfffa,0x0000,0xfff8,
+0x0014,0xfffe,0x0017,0x0002,0x0007,0x0005,0x000c,0x0023,
+0x0001,0x000d,0x0018,0x0000,0xfffd,0x0000,0xffea,0x0004,
+0x0023,0xfff2,0x0022,0x000a,0xfff6,0xfff6,0xffff,0x000c,
+0xffec,0x000c,0x0000,0x000f,0xffee,0x0018,0xffec,0xffe5,
+0xfff2,0xffe4,0xffe5,0xffe5,0xffec,0xffed,0xfffe,0xfff8,
+0x0005,0x0007,0x0019,0x000d,0x0005,0x0005,0x0006,0x0005,
+0x0002,0xfff4,0x001f,0x000f,0x0017,0xffff,0x000c,0x0008,
+0x0039,0xffe6,0x0016,0xfff9,0xfff2,0xffe4,0xfff2,0xfffd,
+0xffdd,0x0000,0x0003,0x0001,0xfff5,0x0010,0xffee,0xfff6,
+0xfffc,0xffe1,0xfff1,0xffe4,0xfff2,0xffe9,0xffff,0xffeb,
+0x0007,0xfffe,0x000b,0xffff,0x0003,0xffff,0x0012,0x0009,
+0x000a,0x000d,0x0031,0x0018,0x0008,0x000e,0x0002,0x0010,
+0x0019,0x000f,0x0016,0x000b,0x0012,0x0004,0x000f,0xffea,
+0x0008,0xfffe,0xffef,0xfff7,0xffd0,0xffec,0xffe2,0xffef,
+0xfff0,0x000b,0xffff,0x0010,0x0002,0x000a,0xfffb,0x001a,
+0xfffe,0xfffc,0x0016,0x0000,0x0002,0x000a,0xfffa,0x000d,
+0xfff2,0x000a,0xffe9,0x0000,0x000a,0xfffe,0x0001,0x0000,
+0x002f,0x0003,0x000b,0xfffa,0x000f,0xfff3,0x0002,0xffda,
+0xfffa,0xfff3,0xfff1,0xffea,0xffd8,0xffe4,0xffe4,0x0000,
+0xfffb,0x0008,0x000a,0x000f,0x0007,0x0007,0xfffc,0x000d,
+0xffff,0xfff2,0x0009,0xfff2,0x0000,0x0002,0x0004,0x0012,
+0xfff9,0x0024,0xfffa,0x0008,0xfffd,0x000d,0xfff9,0x0008,
+0x000e,0x0007,0x0024,0x000d,0x000a,0x000a,0x0012,0x0000,
+0x0000,0x0005,0xffe7,0xfff8,0xffd5,0x0000,0xffd0,0xffee,
+0xffe5,0x0000,0xfff4,0x0003,0xfff9,0xfffa,0xfff9,0x000d,
+0xfff1,0xfffb,0x000b,0xfffd,0x0000,0x0002,0x0000,0xfff4,
+0xfffa,0x000a,0x0000,0x0017,0x0016,0x000b,0x001a,0x000c,
+0x0024,0xfffb,0x0018,0xfffc,0x0007,0xfff9,0x0006,0xffef,
+0xfff2,0xfffb,0xffea,0xffea,0xffdd,0xfff8,0xffd2,0xffff,
+0xffef,0xfffd,0x0000,0x0002,0xfffe,0xfff6,0xfffb,0x0000,
+0xfff2,0xfff1,0xfffe,0xffee,0xfffe,0xfffc,0x000b,0xfff9,
+0x0001,0x0024,0x0012,0x0020,0x0007,0x001b,0x0011,0x0014,
+0x0021,0x000d,0x001d,0x0018,0x0001,0x0001,0xfffe,0xffee,
+0x0000,0x0009,0xfffd,0x0011,0xffe5,0x0000,0xffeb,0xffe2,
+0xfff4,0xfff5,0xfffb,0xfffe,0x000c,0x0004,0x0009,0x0013,
+0x0012,0xfff7,0x000d,0xfffa,0x000b,0xfff8,0xfffe,0x0023,
+0xfff8,0x000a,0xfff9,0xffff,0x0004,0xfff5,0xfff6,0xfffe,
+0x0037,0x0001,0x0011,0x0006,0xffff,0xfff0,0xfff1,0xffdd,
+0xfff1,0xfffe,0x0000,0x0004,0xffed,0xfff8,0xffec,0xfff3,
+0xffff,0xfff2,0x0007,0xfffd,0x0012,0x0000,0x000a,0x0005,
+0x0013,0xffed,0x0000,0xffeb,0x0008,0xfff0,0x0009,0x0027,
+0x0000,0x0024,0x000a,0x0007,0xfff7,0x0004,0xffec,0x0005,
+0x0016,0x0005,0x002a,0x001a,0xfffa,0x0008,0x0001,0x0002,
+0xfff7,0x0011,0xfff6,0x0012,0xffeb,0x0013,0xffd9,0xffe1,
+0xffe9,0xffe9,0xfff0,0xfff1,0x0002,0xfff4,0x0007,0x0006,
+0x0005,0xfff7,0x0001,0xfff6,0x0007,0xfff0,0x0004,0x0009,
+0x0000,0x000a,0x0011,0x0016,0x0010,0x0002,0x000e,0x0009,
+0x002c,0xfffa,0x001e,0x0008,0xfff7,0xfff6,0xfff5,0xfff2,
+0xffe9,0x0005,0xfff8,0x0004,0xfff2,0x000c,0xffdb,0xfff2,
+0xfff4,0xffe6,0xfffc,0xfff0,0x0008,0xfff0,0x0009,0xfff9,
+0x0006,0xffed,0xfff4,0xffe7,0x0005,0xffe8,0x000f,0x000d,
+0x0008,0x0024,0x0022,0x001f,0x0001,0x0012,0x0004,0x0012,
+0xfffd,0xfffb,0xfff7,0xfff9,0x000f,0xffff,0x0005,0x000d,
+0x0002,0x000c,0x0005,0x0002,0xffeb,0xffe9,0xfffe,0xfff0,
+0x0000,0x0005,0xfffa,0x000d,0xffe9,0x0003,0xffe0,0x000a,
+0xfff1,0x0008,0x002c,0x001c,0x0009,0x0025,0xfffe,0x000d,
+0xfff7,0xfff1,0xfff4,0xffe5,0xfff9,0xfff4,0x0000,0xfff5,
+0x0012,0xffef,0xffeb,0xffe7,0x000b,0xffed,0xfffa,0xfffd,
+0xfff5,0x0000,0x0007,0xfff5,0xfff3,0xffe1,0xffff,0x0000,
+0x0009,0x0001,0x0005,0x000c,0xffee,0x0000,0xffe1,0xfffe,
+0xfff3,0xffff,0x001e,0x000e,0x0007,0x001d,0x0009,0x0012,
+0xffff,0x000a,0x0004,0xffee,0xffea,0x0003,0xfff6,0xfffe,
+0xfff3,0xfff3,0x0003,0xfffb,0x0007,0x0004,0x0009,0x0022,
+0xfffb,0x0014,0xfffe,0x0003,0xfff0,0xfffd,0xffec,0xffef,
+0xfff5,0xfff9,0xffef,0x0000,0xffde,0xfff3,0xffdf,0xfffe,
+0xffe4,0x0008,0x0020,0x0018,0x0005,0x001d,0x0003,0xfff4,
+0x0000,0xfff1,0x000b,0xfffd,0x0003,0x0002,0x0018,0x0001,
+0x0008,0xffe7,0xfff8,0xffe9,0x0003,0xfff3,0xfffd,0x0011,
+0xffec,0x0008,0x0000,0xfff6,0xfff8,0xfff5,0xffee,0x0000,
+0xffff,0xfff6,0xfffb,0x0000,0xffe4,0xffef,0xffe0,0xfff1,
+0xffe6,0xffff,0x0013,0x0009,0x0003,0x0015,0x000f,0xfff9,
+0x0006,0x0009,0x001d,0x0005,0xfff6,0x0011,0x000f,0x0009,
+0x0004,0xfffa,0xfffd,0x0005,0xffff,0xfffc,0xfff5,0x0010,
+0xfffa,0x0017,0x0013,0x001d,0x0000,0xfffd,0x0006,0xffe2,
+0x0003,0xffef,0xfff6,0xfffb,0xfff3,0xfffe,0xffef,0x0003,
+0x0005,0x0003,0x0023,0x0015,0x0011,0x0011,0x0002,0x0023,
+0xfffe,0xfff1,0x0003,0xffe4,0xfff3,0xffeb,0xfff3,0xfff3,
+0x001a,0xffed,0xfff1,0xfff4,0xfffb,0xffea,0xffe8,0x0000,
+0xffeb,0x000c,0x0015,0x000f,0x0008,0xfff5,0x0007,0xfff4,
+0x000e,0xffec,0x0002,0xfffa,0xfff9,0xfffa,0xfff0,0xfff7,
+0x0006,0xfffb,0x0015,0x0007,0x000f,0x000a,0x000d,0x0027,
+0x0005,0x000a,0x0014,0xffed,0xffe4,0xfffb,0xffea,0xfffb,
+0xfffb,0xfff1,0x0009,0x0007,0xfff7,0x0002,0xfff8,0x0025,
+0xfff2,0x001f,0x000b,0x001d,0x0005,0x0010,0xfff5,0xffe2,
+0xfff9,0xffe3,0xffeb,0xffee,0xffe9,0xffed,0xffee,0xfff7,
+0xfff9,0x0003,0x0017,0x0011,0x000e,0x0009,0x0008,0x0009,
+0x0006,0xfff1,0x001b,0xfffc,0xfffe,0xfffa,0x000c,0xffff,
+0x0010,0xffe5,0xfffe,0xfff6,0xfff3,0xfff0,0xffec,0x0014,
+0xffe3,0x0014,0x000e,0x0010,0x000d,0x0008,0xfff7,0xfff3,
+0x0002,0xffdf,0xfff7,0xffed,0xffef,0xffe9,0xffef,0xffea,
+0xfffa,0xfffa,0x0009,0x0002,0x000c,0x0002,0x0014,0x000d,
+0x000d,0x000a,0x002d,0x0004,0xfff0,0x0008,0x0002,0x0007,
+0xfff0,0x000e,0xfffe,0x0008,0x0014,0x0011,0x0009,0x0002,
+0x000e,0x0010,0xfffa,0x0005,0xffe8,0xffe4,0xffeb,0xffec,
+0xfff8,0x0009,0x0004,0x0019,0xffff,0x000b,0xffea,0x0018,
+0xfff1,0xfff8,0x0015,0x0005,0x000b,0x000e,0xfffb,0x0012,
+0xfff5,0x0007,0xffe5,0xffec,0xfff2,0xfff9,0x0001,0xfff7,
+0x0006,0x0002,0xfff2,0xfff7,0x0010,0xffff,0xfffd,0xfff2,
+0x0000,0x0005,0xfffd,0xfff8,0xfff0,0xffdc,0xffed,0xfffd,
+0x0001,0x0006,0x0011,0x0018,0x0004,0x0007,0xffeb,0x000b,
+0xfff2,0xffee,0x0007,0xfff7,0x0009,0x0007,0x0006,0x0016,
+0xfffd,0x0021,0xfff6,0xfff5,0xffe4,0x0007,0xfff9,0x0000,
+0xffe6,0x0006,0x000b,0x000a,0x000c,0x0017,0x000c,0x0017,
+0x0005,0x0018,0xfff3,0x0005,0xffed,0xfff8,0xffda,0xffeb,
+0xffec,0xfffe,0xfffa,0x000c,0xfff5,0xfffb,0xffe9,0x000b,
+0xffe3,0xfff7,0x0009,0x0000,0x0007,0x0006,0x0001,0xfff9,
+0xfffe,0x0007,0xfffd,0x0003,0xfffe,0x0006,0x001b,0x0003,
+0xfffc,0xfffa,0x0000,0xfff9,0x0008,0x0004,0x0000,0x0006,
+0xfff7,0x000d,0xfff5,0xfff9,0xfff5,0xfff1,0xffdb,0xfffc,
+0xfff7,0xfffb,0x0005,0x000b,0xfffb,0xfff7,0xffea,0xffff,
+0xffe5,0xffee,0xfffc,0xfff2,0x0005,0x0000,0x000c,0xfffd,
+0x0004,0x0020,0x000e,0x000c,0xffef,0x0016,0x0011,0x000b,
+0xfff8,0x000c,0x0003,0x0015,0x0003,0x000e,0xfff8,0x0005,
+0x0004,0x001c,0x0007,0x0020,0xfffe,0xfff8,0xfff4,0xffde,
+0xfffc,0xfff4,0x0001,0x0006,0x0009,0x0004,0xfff9,0x0011,
+0x0004,0xfff3,0x000b,0xffff,0x0013,0xfffc,0x0000,0x0027,
+0xfffc,0x0007,0xfff5,0xffeb,0xffec,0xfff0,0xfff6,0xfff5,
+0x000d,0x0000,0xfff8,0x0003,0x0000,0xfffc,0xffeb,0xfff5,
+0xfff7,0x0010,0x000a,0x0012,0x0005,0xfff0,0xfff6,0xfff0,
+0x0005,0xfff1,0x000d,0x0005,0x000f,0x0001,0xfffa,0x0004,
+0x0006,0xffe9,0xfffe,0xfff0,0x0011,0xfff4,0x000a,0x002c,
+0x0003,0x0021,0x0006,0xfff4,0xffde,0xffff,0xffec,0xfffd,
+0xffee,0x0004,0x0011,0x0017,0xfffc,0x0014,0xfffc,0x001a,
+0xfffd,0x0024,0x0000,0x0020,0x0002,0x000c,0xffe3,0xffde,
+0xfff0,0xffe8,0xfff6,0xfffa,0x0000,0xfff4,0xfff8,0x0004,
+0xfff8,0xfff3,0x0000,0xfffa,0x0010,0xfff4,0x0005,0x000d,
+0x0003,0x0007,0x000d,0x0003,0xfff8,0xfffe,0x000e,0x0000,
+0x0003,0xfff9,0x0005,0x0005,0xfff8,0x0002,0xffef,0x0009,
+0xffee,0x0018,0x0002,0x0013,0x000a,0x0004,0xffe4,0xffef,
+0xfffb,0xffe4,0x0002,0xfff9,0x0004,0xfff1,0xfff9,0xfff8,
+0xfffa,0xffe9,0xfff3,0xffeb,0x000e,0xffec,0x0011,0x0012,
+0x000b,0x0021,0x001e,0x000b,0xffe9,0x000d,0x0005,0x0009,
+0x003c,0x000a,0x0007,0xffff,0x0009,0xfff8,0x0006,0xfff3,
+0x0002,0xfff1,0xffff,0xfff6,0xfff3,0xfff5,0x000f,0x0000,
+0x0006,0x0009,0xffff,0x0000,0xfff3,0x0001,0xfff5,0xfffd,
+0xfff3,0x0015,0x000d,0x001a,0xfff9,0x001f,0xfff6,0xfff9,
+0xfff0,0xffdf,0xffe1,0xfff6,0x0016,0xfff8,0x0001,0xfffe,
+0x0052,0xffff,0xfffc,0xffed,0x0006,0xffe5,0xfffa,0xffe3,
+0xfff4,0xffe6,0x0001,0xffe8,0xfffb,0xffee,0x0011,0x0011,
+0x0011,0x0006,0x000a,0x0000,0xfff9,0xfffe,0xfff7,0xfff0,
+0xfff4,0x000b,0x0000,0x000b,0xfff7,0x0017,0x0000,0xfffd,
+0xfff8,0xfff8,0xfff3,0xffff,0x0008,0x0007,0xfff9,0x0006,
+0x0031,0x0002,0x0015,0x0000,0x0001,0xfffe,0x0009,0x0008,
+0xfffa,0xfffa,0xfff8,0xfff6,0xfff8,0x0009,0xfffe,0x0000,
+0xfffc,0xfffe,0xfff3,0xfff4,0xffe9,0xfff1,0xfff4,0xfff0,
+0xffe6,0x0015,0x0002,0x0015,0xfff5,0x0017,0xfffc,0xffdf,
+0xfff9,0xffdf,0xfffa,0x000d,0x0022,0x0005,0x001b,0x000a,
+0x0047,0xfff6,0x0009,0xffef,0xffff,0xffec,0xfffd,0xfff8,
+0xffeb,0xffee,0xfffa,0xffe8,0x0000,0x0001,0x0000,0x0010,
+0x0006,0xfffb,0x0000,0xfff3,0xffef,0xffed,0xfff5,0xffe3,
+0xffe7,0x000b,0xfff5,0x0006,0xfff3,0x000f,0x0007,0xffe3,
+0x0000,0xfff8,0x000b,0x0016,0x0014,0x0015,0x0011,0x0012,
+0x0043,0x0008,0x000e,0x000b,0xfff9,0xfff5,0xfff5,0xfff7,
+0xfff9,0xfffd,0x000d,0x0010,0x0008,0x0009,0x0018,0xfff4,
+0x000a,0xfff3,0xfffb,0xffef,0xfffe,0xfffc,0x0003,0xfff6,
+0x0006,0x0011,0x0004,0x0013,0x0000,0x000b,0xfffa,0x000d,
+0xfff7,0xffdf,0xfff2,0xfff6,0x0010,0xffef,0xfff6,0xfffc,
+0x005a,0xfffd,0x0002,0xfffa,0xfff6,0xffe3,0xffe8,0xffe6,
+0xffeb,0xfff1,0x000f,0x0002,0x0010,0x0001,0x0019,0x0004,
+0x0015,0xfff0,0x0006,0xffee,0x0003,0xfff8,0x0005,0xffe8,
+0x0008,0x0007,0xfff7,0x0004,0xffff,0x0003,0x0005,0x0012,
+0xffff,0xfff9,0x0002,0xffff,0x0002,0xffff,0xffed,0x0003,
+0x0039,0x0000,0x001b,0x000d,0xfff2,0xfffb,0xfff9,0x000b,
+0xfff1,0x0004,0x0005,0x0010,0x000d,0x001d,0x0006,0xfff3,
+0x0000,0xffe7,0xfff0,0xffe1,0xfff4,0xffea,0x0002,0xffe9,
+0xfffa,0x0010,0xfff9,0x000e,0xfffe,0x0003,0x0000,0xfff4,
+0x0000,0xffdf,0x0009,0x000d,0x001c,0xfffd,0x000e,0x0007,
+0x004f,0xfff5,0x000f,0xfffc,0xffee,0xffe9,0xffec,0xfffb,
+0xffe2,0xfff9,0x0007,0x0002,0x0015,0x0015,0x0008,0x0003,
+0x000a,0xffe4,0xfffc,0xffe1,0xfffa,0xffe7,0x0003,0xffdb,
+0xfffc,0x0007,0xffec,0x0000,0xfffc,0xfffc,0x000b,0xfff9,
+0x0006,0xfff8,0x001b,0x0016,0x000e,0x000c,0x0005,0x0010,
+0x002f,0x001e,0x000f,0x000e,0x000e,0x0009,0x0009,0xffe9,
+0x000d,0xfff6,0xfff4,0xfff9,0xfff0,0xfff1,0xfffd,0xfffd,
+0xffff,0x000e,0x0009,0x000c,0x0009,0x0008,0x0000,0x000a,
+0xfff2,0x0004,0xfff7,0x0002,0xfffb,0x0008,0xfff3,0xfffd,
+0xffee,0xfff6,0xffd3,0xfffd,0x0010,0xfffc,0x0004,0x0000,
+0x0045,0x0011,0x0003,0xfffd,0x000a,0xfff8,0xfffd,0xffd8,
+0xffff,0xffeb,0xfff6,0xffeb,0xfff8,0xffe9,0xffff,0x000d,
+0x0008,0x000b,0x0015,0x000b,0x000f,0x0004,0x0000,0xfffe,
+0xfff3,0xfffb,0xffe9,0xfff4,0xfff9,0x0000,0xffff,0x0000,
+0xfff6,0x000e,0xffe4,0x0005,0x0001,0x000b,0xfffb,0x0007,
+0x0024,0x0015,0x001c,0x0010,0x0006,0x0010,0x000c,0xfffe,
+0x0004,0xfffe,0xffec,0xfff9,0xfff5,0x0004,0xffec,0xfffc,
+0xfff4,0x0002,0xffff,0x0000,0x0000,0xfff8,0xfffe,0xfffe,
+0xffe5,0x0004,0xffeb,0xfffe,0xfff7,0x0000,0xfffa,0xffe3,
+0xfff7,0xfff6,0xffeb,0x0015,0x001c,0x000a,0x001d,0x000b,
+0x003a,0x0009,0x0010,0xffff,0x0002,0xfffe,0x0000,0xffed,
+0xfff6,0xfff3,0xffef,0xffeb,0xfffd,0xfffd,0xffed,0x000c,
+0xfffe,0x0000,0x000a,0xffff,0x0005,0xfff4,0x0000,0xfff1,
+0xffe6,0xfffb,0xffde,0xfff0,0xfff5,0xfff9,0x0004,0xffe7,
+0xfffe,0x000e,0xfffd,0x001d,0x000d,0x0019,0x0014,0x0014,
+0x0037,0x001c,0x0015,0x001b,0xfffe,0x0007,0xfff8,0xffec,
+0x0004,0x0001,0x0001,0x0012,0x0005,0x0004,0x0005,0xfff0,
+0x0002,0xfff8,0x0005,0xfffb,0x0013,0x0002,0x000e,0x0003,
+0x0006,0x0000,0xffee,0xfffc,0x0002,0xfff5,0xfff8,0x0012,
+0xfff5,0xfff6,0xffe3,0xfffd,0x000a,0xfff3,0xfff8,0xfffd,
+0x004d,0x0010,0x0009,0x0009,0xfffa,0xfff5,0xffeb,0xffdb,
+0xfff6,0xfff6,0x0004,0x0005,0x000d,0xfffd,0x0007,0x0000,
+0x000d,0xfff5,0x0011,0xfffa,0x0019,0xffff,0x000f,0xfff7,
+0x0007,0xfff7,0xffe0,0xffed,0x0000,0xffee,0x0002,0x0016,
+0xfffd,0x000f,0xfff4,0x0005,0xfffc,0x0002,0xffef,0x0005,
+0x002c,0x0014,0x0022,0x001d,0xfff6,0x000d,0xfffc,0x0000,
+0xfffc,0x0009,0xfffb,0x0013,0x000a,0x0018,0xfff5,0xffef,
+0xfff8,0xffec,0xfffb,0xffed,0x0009,0xfff2,0x000c,0xfff7,
+0xfffa,0x0000,0xffe2,0xfff7,0x0000,0xffed,0xfffe,0xfff9,
+0xfffe,0xfff6,0xfffb,0x0014,0x0015,0x0001,0x0011,0x0009,
+0x0042,0x0008,0x0017,0x000b,0xfff2,0xfffb,0xffef,0xfff0,
+0xffed,0xfffe,0xfffd,0x0005,0x0012,0x0011,0xfff6,0x0000,
+0x0001,0xffe9,0x0006,0xffec,0x000f,0xffee,0x000e,0xffea,
+0xfffb,0xfff6,0xffd4,0xffe9,0xfffe,0xffe6,0x0009,0xfffd,
+0x0004,0x000e,0x000c,0x001d,0x0007,0x0010,0x0007,0x0012,
+0x0012,0x0009,0xffef,0xfffc,0x000b,0x0003,0x0000,0x000b,
+0x0007,0x0004,0x000a,0x0003,0x000a,0xffee,0x0018,0xfffd,
+0x000e,0x0007,0x0004,0x000a,0xfff0,0x0001,0xffe5,0xfffc,
+0xffe5,0x0011,0x000c,0x001e,0x0000,0x0023,0xfff7,0xfffd,
+0xfff4,0xffdc,0xffdd,0xffe2,0xfffe,0xfff3,0x0002,0xfff5,
+0x0028,0xfffe,0xffe3,0xffea,0x0007,0xfff2,0xfff4,0xfffb,
+0xfff9,0xfff9,0x000c,0xfff7,0x0012,0xffe6,0x001a,0x000e,
+0x0018,0x0004,0x0010,0x0009,0xfff6,0xfffe,0xffe6,0xffee,
+0xffe6,0x0007,0xffff,0x000f,0xffff,0x001b,0x0002,0x0000,
+0xfffc,0xfff5,0xffef,0xffeb,0xfff0,0x0001,0xfff9,0xfffd,
+0x0008,0x0001,0xfffd,0xfffe,0x0003,0x000a,0x0003,0x0020,
+0xffff,0x000c,0x0002,0x0004,0x000f,0x0001,0x0007,0xfffd,
+0x0002,0xfffc,0xfffa,0xfffd,0xffe6,0xfff1,0xffe3,0xffef,
+0xffd8,0x0011,0x0000,0x001a,0xfffe,0x001b,0xfffe,0xffe3,
+0xfffc,0xffdc,0xfff6,0xfffa,0x0009,0x0000,0x001b,0x0000,
+0x001e,0xfff5,0xfff1,0xffec,0x0000,0xfff8,0xfff7,0x000f,
+0xfff1,0x0000,0x0005,0xfff7,0x0017,0xfffa,0x0008,0x000d,
+0x000d,0xfff9,0x0005,0xfffd,0xffec,0xffed,0xffe5,0xffe1,
+0xffd9,0x0007,0xfff3,0x000b,0xfffc,0x0013,0x0008,0xffe7,
+0x0003,0xfff5,0x0007,0x0002,0xfffc,0x0010,0x0012,0x0009,
+0x001a,0x0007,0xfff5,0x0008,0xfffb,0x0001,0xffef,0x000e,
+0xffff,0x000f,0x0018,0x001e,0x0020,0x0001,0x0021,0xfff0,
+0x0012,0xfff2,0x0000,0xfff8,0xfffa,0xfffc,0xfff4,0xfff4,
+0xfffa,0x000d,0x0002,0x0017,0x0008,0x000f,0xfffc,0x0011,
+0xfffb,0xffdc,0xffee,0xffe2,0xfff8,0xffea,0xfff6,0xfff2,
+0x0030,0xfffc,0xffe9,0xfff7,0xfff7,0xffef,0xffe2,0xfffe,
+0xfff0,0x0003,0x001a,0x0010,0x0028,0xfffa,0x0023,0x0001,
+0x001c,0xffef,0x000c,0xfff7,0x0000,0xfff8,0xfff5,0xffe7,
+0xfffb,0x0003,0xfff6,0x0008,0x0006,0x0007,0x0006,0x0016,
+0x0001,0xfff5,0xffff,0xffeb,0xffea,0xfff9,0xffed,0xfffb,
+0x000f,0x0000,0x0002,0x000a,0xfff3,0x0007,0xfff2,0x0023,
+0xfff6,0x0017,0x0010,0x001f,0x0025,0x0015,0x0010,0xffef,
+0x0006,0xffe6,0xfff6,0xffeb,0xfff0,0xffeb,0xfff3,0xffe7,
+0xffed,0x000d,0xfff8,0x0013,0x0005,0x0007,0x0001,0xfff8,
+0x0002,0xffdc,0x0005,0xfffa,0x0003,0xfff8,0x000f,0xffff,
+0x0025,0xfff4,0xfff7,0xfff9,0xffef,0xfff5,0xffe6,0x0012,
+0xffe7,0x000c,0x0013,0x0011,0x002d,0x000e,0x0011,0x0000,
+0x0011,0xffe2,0x0001,0xffea,0xfff6,0xffe7,0xfff4,0xffda,
+0xffee,0x0003,0xffea,0x0004,0x0003,0x0000,0x000d,0xfffd,
+0x000a,0xfff5,0x0017,0x0002,0xfff6,0x0007,0x0005,0x0007,
+0x0005,0x001d,0xfff7,0x000b,0x000f,0x0016,0x0003,0x0000,
+0x0012,0x0008,0xffff,0x0006,0x0007,0xffe9,0x0006,0xfffa,
+0x0005,0x000c,0x000f,0x0015,0x0005,0x0008,0xffef,0x0009,
+0xffe4,0x0000,0xfff5,0x0006,0x0002,0x000c,0xfff5,0x0000,
+0xfff2,0xfff3,0xffcf,0xffea,0xfff8,0xfff7,0x0004,0xfff7,
+0x001b,0x0010,0xffeb,0xfffa,0x000c,0x0003,0xfff7,0xfff0,
+0x0003,0xfffe,0x0001,0xfff9,0x000f,0xffe1,0x0007,0x000a,
+0x0010,0x0009,0x001b,0x0015,0x000b,0x0005,0xfff0,0xfffd,
+0xffe6,0xfff7,0xffe8,0xfff9,0x0000,0x0004,0x0000,0x0004,
+0xfffa,0x000b,0xffe0,0xfff2,0xffe9,0x0006,0xfffb,0xffff,
+0xfffc,0x0014,0x0003,0x000d,0x0008,0x001c,0x0006,0x0015,
+0x000a,0x0010,0xfff8,0x0007,0x000c,0xfffd,0xfff5,0xfff9,
+0xfffb,0x0000,0x0004,0x0008,0xfffc,0xfff8,0xffee,0xfffd,
+0xffd7,0x0000,0xffea,0x0002,0x0000,0x0004,0xfffb,0xffe7,
+0xfffa,0xfff2,0xffe7,0x0001,0x0002,0x0004,0x001d,0x0002,
+0x0011,0x0008,0xfff8,0xfffc,0x0004,0x000a,0xfffa,0x0005,
+0xfffc,0x0005,0xfffa,0xfffa,0x0014,0xfff6,0xfff7,0x0009,
+0x0004,0xfffe,0x0010,0x0007,0x0001,0xfff4,0xffef,0xfff0,
+0xffd9,0xfff7,0xffdc,0xfff4,0xfffe,0xfffd,0x0006,0xffeb,
+0x0001,0x000b,0xfff9,0x000a,0xfff5,0x0014,0x0014,0x000b,
+0x000d,0x001b,0xfffd,0x0018,0xffff,0x0013,0xfff2,0x0003,
+0x0009,0x0014,0x000c,0x0021,0x001d,0xfffd,0x000f,0xffec,
+0x0009,0xfff7,0x000b,0x0003,0x0010,0x0002,0xfffe,0x0002,
+0xfff9,0xfffd,0xffec,0x0000,0x000a,0xfff9,0xfff9,0x0016,
+0xfff9,0xfff3,0xffdf,0xffe9,0xfff2,0xffee,0xfff9,0xfff4,
+0x0023,0x000f,0xfff1,0x0006,0xfffc,0x0001,0xffe5,0xfff4,
+0xfffb,0x0008,0x000f,0x0013,0x0025,0xfff5,0x0010,0xfffe,
+0x0014,0xfff4,0x0017,0x0002,0x0016,0xffff,0xffff,0xfff5,
+0xfffb,0xfff3,0xffde,0xfff2,0x0008,0xfff2,0x0004,0x001a,
+0x0000,0x000b,0xfff0,0xfff2,0xffe3,0xfffe,0xffef,0xfffd,
+0x0003,0x0013,0x0009,0x001a,0xfff8,0x001a,0xfff6,0x0018,
+0x0000,0x001c,0x0005,0x0021,0x0022,0x0011,0xfffe,0xffec,
+0xffff,0xffea,0x0000,0xfff6,0x0006,0xfff2,0xfffd,0xfff6,
+0xffec,0xfffc,0xffe0,0xfffc,0x0007,0xfff1,0x0000,0xfffd,
+0x0000,0xfff3,0xfff7,0x0000,0xfffd,0xfffc,0x0011,0x0000,
+0x0019,0x0007,0xfffe,0x0008,0xfff4,0x0007,0xffe9,0x0008,
+0xfff3,0x0010,0x0007,0x0014,0x002a,0x0009,0x0000,0xfffd,
+0x0009,0xffe7,0x000c,0xfff6,0x000c,0xffee,0xfffe,0xffe8,
+0xffed,0xfff3,0xffd2,0xffed,0x0005,0xffea,0x000a,0x0000,
+0x0008,0x000b,0x0008,0x0009,0xffef,0x000b,0x0007,0x0008,
+0xffe7,0xfff9,0x0002,0xfff8,0x000c,0xfff9,0x0017,0xfff8,
+0x000d,0xfff0,0xfff9,0xffec,0xffd6,0xfff7,0x0000,0x0003,
+0xfff7,0x0019,0xfff4,0x000a,0xfff4,0x0012,0x0002,0x0018,
+0x0013,0x000d,0x002e,0x0013,0xfffb,0x0016,0xfff6,0x0000,
+0xfff8,0xfff5,0xfff8,0xfff7,0x0011,0xfff5,0xfff9,0xfff8,
+0xfffd,0xffed,0xfff7,0xffe6,0x0008,0xffe6,0x000a,0xffe8,
+0x0000,0xffe4,0xfffb,0xffdf,0xffde,0xffef,0x0002,0x0014,
+0x0001,0x0016,0x0000,0x000a,0xfffa,0x000e,0x0003,0x000a,
+0x0014,0x0004,0x0020,0x0004,0xfff9,0x000f,0x0000,0x0003,
+0x0000,0x000d,0x0009,0x0000,0x0003,0x0004,0xffef,0x0000,
+0xffdd,0xfff1,0x000f,0xfffa,0x0004,0xffff,0x001b,0x000c,
+0x0005,0xfff8,0xfff1,0xffed,0xffdb,0x000b,0xfff0,0x0002,
+0xffec,0x000c,0xffe9,0xfffe,0xffea,0x0001,0x0001,0x000b,
+0x0005,0x000d,0x0022,0x000e,0xfff8,0x000e,0xfffc,0xffe6,
+0x0000,0xfff5,0x0010,0x000e,0x001d,0x0002,0x0011,0x0003,
+0xfff3,0xffe5,0x0003,0xffe8,0x0001,0xffed,0x000e,0xfffd,
+0xfff7,0xffec,0xfff4,0xffdf,0xffe3,0x0003,0xfff1,0x0014,
+0xfff7,0x0009,0xfff5,0xfffd,0xfff0,0xfffe,0x0002,0xfffe,
+0x0007,0x0003,0x0014,0x0000,0xfff6,0x0007,0x0007,0xffea,
+0x0007,0x000d,0x0021,0x0017,0x000e,0x0012,0x0007,0x000c,
+0xffef,0xfff8,0x0008,0x0004,0xfffc,0xfff6,0x0006,0xfffb,
+0x0004,0xfffb,0x0006,0x0006,0xffec,0x000a,0x0009,0xfff7,
+0xfffc,0x0002,0xfff0,0xfff9,0xffff,0x000c,0x0011,0x0010,
+0x0027,0x0009,0x0024,0x000c,0x0002,0x0003,0xfffa,0x0015,
+0xffff,0xfff5,0x0007,0xfff6,0x000b,0xffec,0xffec,0xfff5,
+0x0004,0xffec,0xfffd,0xfff3,0xfff8,0xffe4,0xfffa,0xffeb,
+0xfff6,0xfff0,0x0008,0xfff9,0xfff4,0x0003,0x000b,0x0007,
+0x0005,0x0000,0xfffc,0xfff8,0x0004,0x0008,0x0012,0x0003,
+0x0029,0x0000,0x0016,0xfffe,0x0000,0xfffc,0x0005,0x0019,
+0x0006,0x000e,0x0019,0xffff,0xfffe,0xfffc,0xffe3,0xfffe,
+0xffe5,0xfff0,0x0015,0x0006,0xfff4,0xfffd,0x0009,0x0010,
+0xfffd,0x0002,0xffff,0x0007,0xfff1,0x001f,0xfff9,0xfff6,
+0xfff0,0xfff7,0xffe5,0xffeb,0xfff5,0xfffb,0x0010,0x0003,
+0x001a,0x0009,0x0018,0x0007,0x0000,0xfffc,0x0000,0xfffc,
+0x0006,0xfff5,0x0020,0x000e,0x0017,0xfffa,0x0005,0x0001,
+0xfffb,0xffe3,0x0009,0xfff5,0xfff1,0xffea,0xfffd,0x0000,
+0xffee,0xfff8,0x0001,0xfffa,0xfff9,0x0017,0xfffa,0x0006,
+0xfffb,0xfff4,0xfff1,0xffeb,0xfffb,0xfff8,0x0011,0xfff7,
+0x001c,0x0000,0x000b,0xfffa,0xfffe,0xfff4,0x000b,0x0000,
+0x000e,0x000d,0x0031,0x0016,0x0008,0x0009,0xfffc,0x0009,
+0xffdb,0x000c,0x0009,0x0007,0x0011,0x000b,0x001a,0xffee,
+0x0019,0xfff4,0xffed,0xffef,0xffd3,0xfff2,0xffef,0x0000,
+0xffef,0x001e,0xffff,0x0016,0x000a,0x0019,0x000c,0x0026,
+0x0012,0xfffd,0x0016,0xfffc,0xfffd,0x0000,0xfff3,0x0003,
+0xfff6,0x000b,0xffe9,0xfffe,0x000a,0xfff9,0xfffb,0xfff9,
+0xfff1,0x0000,0xfffe,0xfff6,0x000d,0xfff9,0x000e,0xffdd,
+0x000a,0xffe9,0xfff0,0xffe1,0xffdb,0xffeb,0xfff0,0x0011,
+0xfffa,0x001a,0x000a,0x0015,0x0010,0x0015,0x000d,0x0019,
+0x0013,0xfff3,0x0008,0xffed,0xfffb,0xfff9,0xffff,0x0008,
+0xfffe,0x0024,0xfffb,0x0006,0xfffd,0x0008,0xfff1,0x0001,
+0xffd0,0x0004,0x0017,0x0009,0x0009,0x0011,0x001e,0x0002,
+0x0010,0xfffd,0xffe6,0xfff0,0xffd8,0x0006,0xffdd,0xffff,
+0xffe4,0x0011,0xfff4,0x0009,0x0000,0x0008,0x000b,0x0019,
+0x0005,0xfffd,0x000a,0xfff8,0xfffa,0xfff9,0xfffa,0xffea,
+0xffff,0x000b,0x0001,0x0015,0x0016,0x0007,0x0013,0x0005,
+0xffe6,0xfff9,0x000b,0xfff8,0x0005,0xffff,0x0011,0xfff2,
+0x0001,0xfff1,0xffe8,0xffe2,0xffe0,0xffff,0xffdf,0x0010,
+0xffee,0x000e,0x0000,0x0008,0x0006,0x0004,0x000c,0x000c,
+0x0006,0xfff3,0xfffe,0xffe9,0xfff8,0xfff1,0x0004,0xffef,
+0x0005,0x0024,0x0012,0x001e,0x0008,0x0016,0x000a,0x000e,
+0xffe2,0x000b,0x000f,0x0014,0x0000,0x0008,0x0009,0xfff1,
+0x000f,0x0000,0xfffb,0x0009,0xffe9,0x0006,0xfff8,0xfff3,
+0xfff3,0x0007,0xfffb,0x0003,0x0014,0x0013,0x001b,0x001f,
+0x0027,0xfff9,0x000d,0xfff5,0x0004,0xffed,0xfff8,0x0019,
+0xfffd,0x000b,0xfff9,0xfffe,0x0004,0xfff0,0xffee,0xfff7,
+0xfff8,0xffff,0x0003,0x0002,0xfffd,0xfff6,0xfffd,0xffe0,
+0x0001,0xfff4,0xfffe,0xfffc,0xfff1,0xffff,0xfff9,0x0003,
+0xfffe,0x0004,0x0006,0x0003,0x001a,0x000f,0x001d,0x0011,
+0x0028,0xffef,0x0000,0xffe6,0x0002,0xffe5,0x0002,0x001d,
+0x0004,0x0024,0x000a,0x0006,0xfff7,0x0000,0xffe5,0x0000,
+0xffd8,0x0002,0x001d,0x0016,0xfff9,0x000e,0x000c,0x0005,
+0x0007,0x0007,0xfff4,0x0009,0xffee,0x001a,0xffe6,0xfff2,
+0xffe8,0xfffc,0xfff0,0xfff7,0x000a,0x0002,0x001a,0x0012,
+0x001a,0xfff9,0x0001,0xfff1,0x0001,0xffe5,0xfffe,0x0000,
+0x0004,0x000b,0x0011,0x0015,0x0010,0xffff,0x0007,0x0003,
+0xffee,0xfff7,0x0011,0x0004,0xfff5,0xfffd,0x0000,0xfff5,
+0xfff9,0xfffc,0xfff6,0xfffd,0xfff6,0x0012,0xffe8,0x0003,
+0xfff2,0xfff9,0xfffc,0xfff6,0x0010,0xffff,0x001b,0x0004,
+0x001b,0xffef,0xfff4,0xffe2,0x0000,0xffdd,0x0009,0x0003,
+0x000c,0x0024,0x0023,0x001e,0x0002,0x000d,0xfffe,0x000b,
+0xffbe,0xfff8,0xffe9,0xfff5,0x000e,0x0005,0x0011,0x0010,
+0x0013,0x0002,0x0003,0xfffb,0xffee,0xffef,0x000a,0x0000,
+0xffff,0x0017,0xfffa,0x0014,0xfff1,0x0012,0xfff2,0x0016,
+0x0005,0x000a,0x002c,0x0017,0x0002,0x001a,0xfff7,0x0003,
+0xfffc,0xfff2,0xfff4,0xffe3,0xfff9,0xfff0,0xfff9,0xffee,
+0xffd4,0xffec,0xffde,0xffe3,0x000a,0xfff3,0x0004,0x0000,
+0x0004,0xfff7,0x0005,0xffed,0xfff6,0xffe8,0x000b,0x0011,
+0x0008,0x0014,0x0005,0x0013,0xfff7,0x000e,0xfff4,0x0009,
+0x0006,0x0000,0x001e,0x0009,0x0000,0x0013,0x0002,0x0007,
+0x0002,0x000a,0x0005,0xffec,0xffeb,0xffff,0xffef,0xfff7,
+0xffb3,0xfff0,0xfff7,0xfff7,0x0006,0x000b,0x0015,0x0025,
+0x000a,0x000a,0xfffc,0xfffb,0xfff3,0x0003,0xfff9,0x0000,
+0xfff3,0x000b,0xffef,0x0006,0xffe7,0x0001,0xfff1,0x0009,
+0xfff9,0x0009,0x0020,0x0013,0x0000,0x0012,0xfffe,0xffea,
+0x0003,0xfff1,0x000c,0xfffb,0x0004,0xfffe,0x0011,0xfffb,
+0xffc9,0xffe4,0xffeb,0xffe5,0x0002,0xfff9,0x0008,0x0014,
+0xfffc,0xffff,0xffff,0xffee,0xfffb,0xfffc,0xfffb,0x0010,
+0xfffe,0x0008,0xfffb,0x0005,0xffed,0xfffe,0xfff2,0xfffd,
+0xfffa,0x0000,0x0012,0x0004,0xfffe,0x000b,0x0008,0xffee,
+0x000b,0x000a,0x001d,0x0003,0xfff6,0x000d,0x0008,0x0003,
+0xffc6,0xfff7,0xfff0,0x0001,0xfffe,0x0002,0x0000,0x0013,
+0x000a,0x000d,0x0011,0x0015,0x0003,0x0003,0x0013,0xfff4,
+0x0002,0x0000,0xfff6,0x0001,0xfffb,0x000c,0x0000,0x000f,
+0x001a,0x0005,0x0022,0x0010,0x000b,0x0007,0xfffc,0x0019,
+0x0002,0xfff2,0x0003,0xffe3,0xfff3,0xffe7,0xffec,0xffec,
+0xffdc,0xffeb,0xffe4,0xfff0,0xfffa,0xfff0,0xfff4,0x0002,
+0xfffc,0x0002,0x0014,0x0007,0x000b,0xfffc,0x0014,0x0004,
+0x000c,0xfffe,0x0001,0x0000,0x0000,0x0008,0x0002,0x0002,
+0x001b,0xfffc,0x0015,0x0002,0x0009,0x0000,0x0006,0x001d,
+0x0009,0x000a,0x0015,0xffeb,0xffe4,0xfff6,0xffe3,0xfff5,
+0xffbb,0xffef,0xfffd,0x0003,0xfff6,0x0008,0x0003,0x0028,
+0x0001,0x0015,0x000a,0x0015,0x0008,0x0017,0x0001,0xfff3,
+0xfff8,0xfff5,0xffeb,0xfff5,0xfff1,0xfffc,0x0000,0x0002,
+0x000d,0x0005,0x0017,0x000c,0x0007,0x0000,0x0001,0x0000,
+0x000a,0xfff2,0x001c,0xfffb,0xffff,0xfff5,0x0005,0xfff9,
+0xffd1,0xffe2,0xfff1,0xfff2,0xfff2,0xfff7,0xfff7,0x0017,
+0xfff3,0x000a,0x000c,0x0007,0x0010,0x000f,0x0003,0x0003,
+0x0001,0xfff2,0xfff7,0xfff4,0xfff7,0xfff8,0x0000,0xfff6,
+0x000e,0xfffc,0x0009,0xfffe,0x0005,0xfff8,0x000d,0x0003,
+0x0012,0x000a,0x002d,0x0003,0xfff0,0x0004,0xfffc,0x0000,
+0xffb1,0x000b,0xfff1,0x0004,0x0012,0x0017,0x0014,0x0005,
+0x001e,0x0007,0xfff9,0xfffe,0xffeb,0xffeb,0xfff8,0xfffd,
+0xfff6,0x001c,0x0004,0x001f,0x0006,0x0019,0xfffd,0x0025,
+0x0004,0xfff9,0x0014,0x0000,0x0004,0x0004,0xfff5,0x0007,
+0xfffa,0x0008,0xffe5,0xffea,0xfff2,0xfff4,0xfffb,0xfff0,
+0xffc7,0x0000,0xffe5,0xfff3,0x000e,0x0005,0x0007,0xfff5,
+0x000f,0xfffc,0xfffb,0xfff0,0xfff3,0xffe3,0xfffa,0x000d,
+0x0000,0x0019,0x0010,0x001f,0x000c,0x0016,0xfffe,0x0017,
+0x0006,0xfff0,0x0007,0xfff2,0x0002,0xfffd,0x0000,0x000c,
+0x0000,0x0021,0xfff7,0xfff3,0xffe4,0x0003,0xfff2,0xfff9,
+0xffa6,0x0003,0xfffe,0x0006,0x000a,0x001d,0x0018,0x001a,
+0x0015,0x000f,0xfff1,0xfffe,0xfff0,0xffff,0xffe7,0xfffc,
+0xffeb,0x0010,0xfffa,0x0012,0xfffd,0x0008,0xfffb,0x0018,
+0xfff8,0xfff9,0x0009,0xfffc,0x0001,0xfffd,0xfffb,0xffee,
+0x0001,0x0007,0xfffe,0x0001,0xfffe,0x0001,0x0013,0xfffd,
+0xffbd,0xfff8,0xfff2,0xfff5,0x0007,0x000b,0x000b,0x0009,
+0x0007,0x0003,0xfff3,0xfff0,0xfff8,0xfff7,0xffe8,0x000c,
+0xfff6,0x000d,0x0005,0x0011,0x0002,0x0004,0xfffd,0x000a,
+0xfffa,0xffef,0xfffc,0xffed,0x0000,0xfff5,0x0006,0xfff3,
+0x0009,0x0021,0x000e,0x000a,0xfff0,0x0011,0x000a,0x0004,
+0xffb9,0x000a,0xfff7,0x0011,0x0001,0x0014,0x0003,0x0008,
+0x0015,0x0012,0x0006,0x0018,0x0000,0xffff,0x0000,0xfff0,
+0xfffa,0x0005,0x0000,0x000d,0x0011,0x0013,0x000b,0x001d,
+0x0019,0xfff5,0x000b,0xfffa,0x000d,0xfff1,0xfff9,0x001d,
+0x0000,0x0008,0xfff5,0xffea,0xffec,0xffeb,0xffef,0xffee,
+0xffcf,0xfffe,0xffeb,0x0000,0xffff,0x0002,0xfff7,0xfff8,
+0x0006,0x0006,0x0008,0x000a,0x0008,0xfff7,0x0002,0x0000,
+0x0004,0x0002,0x000d,0x000c,0x0017,0x000f,0x000c,0x0010,
+0x001a,0xffeb,0xfffe,0xffeb,0x000b,0xffe9,0x0004,0x0021,
+0x0007,0x0021,0x0006,0xfff3,0xffde,0xfffb,0xffe5,0xfff6,
+0xffae,0x0001,0x0004,0x0013,0xfffa,0x001b,0x0006,0x001d,
+0x000c,0x001a,0xffff,0x0018,0x0005,0x0012,0xffef,0xffef,
+0xffef,0xfffa,0xfff6,0x0000,0x0007,0x0002,0x0009,0x0010,
+0x000c,0xfff5,0x0000,0xfff5,0x0009,0xffe9,0x0000,0x0003,
+0x0008,0x0008,0x000d,0x0001,0xfff8,0xfff9,0x0007,0xfffa,
+0xffc4,0xfff6,0xfff9,0x0001,0xfff7,0x0008,0xfffa,0x000d,
+0xfffe,0x000f,0x0001,0x000a,0x000d,0x000b,0xfff1,0x0000,
+0xfffa,0xfff7,0x0001,0x0000,0x000d,0xffff,0x000b,0x0003,
+0x000d,0xffeb,0xfff3,0xffe6,0x0007,0xffe1,0x000a,0x0007,
+0x0010,0x0021,0x001f,0x000a,0xffea,0x0008,0xffff,0x0002,
+0xfffd,0x0007,0xfffb,0xfffb,0x0008,0xfffe,0x0011,0xfff7,
+0x0012,0xffe8,0xfffe,0xffed,0xfff6,0xfffc,0x001c,0x0011,
+0x0005,0x001c,0xfffe,0x0007,0xfffc,0x000f,0x0007,0x0008,
+0x0006,0x0017,0x000d,0x0015,0xfff2,0x0014,0xffef,0xffee,
+0xfff5,0xffdf,0xffe2,0xfff5,0x0017,0xfff3,0xfffb,0xfff7,
+0x0012,0xfffc,0xffef,0xffe9,0x0004,0xffec,0x0004,0xffe6,
+0x0003,0xffdc,0x0000,0xffe0,0xfffe,0xfff4,0x001d,0x0022,
+0x0010,0x0018,0x000a,0x0006,0x0000,0x000c,0x0008,0xfffc,
+0x0008,0x000d,0x0000,0x0006,0xfff0,0x000c,0xfffb,0xfff3,
+0xfffd,0xfff9,0xfff3,0xfffd,0x0008,0x0002,0xfff2,0x0000,
+0xfff3,0x0000,0x0008,0xfffd,0x0000,0x0004,0x0015,0x000b,
+0x0009,0xfff0,0xfff6,0xffee,0xfffb,0x0010,0x000a,0x0010,
+0xfffb,0x000f,0xfff3,0xfffb,0xfff1,0xffff,0x0006,0xfffc,
+0xfffa,0x0017,0x0002,0x0010,0xffef,0x000c,0xfff6,0xffd4,
+0xfffd,0xffdf,0xfffa,0x000c,0x0022,0x0001,0x0014,0x0003,
+0x0008,0xfff4,0xfffd,0xffeb,0xfffd,0xfff2,0x0008,0xfffb,
+0xfffc,0xffe4,0xfff9,0xffe0,0x0002,0x0008,0x000c,0x0022,
+0x0004,0x000c,0xffff,0xfffa,0xfff7,0xfffc,0x0007,0xffef,
+0xfffc,0x000d,0xfff5,0x0001,0xffed,0x0004,0x0000,0xffd9,
+0x0004,0xfff9,0x000b,0x0015,0x0014,0x0010,0x000a,0x000b,
+0x0004,0x0006,0x0000,0x0007,0xfff8,0xfffc,0x0000,0xfffa,
+0x0009,0xfff3,0x000b,0x0007,0x000b,0x000f,0x0025,0x0004,
+0x0009,0x0005,0xfffb,0xfff5,0x0005,0x0009,0x0016,0x0001,
+0x001b,0x0012,0x0004,0x000e,0xfffb,0x0000,0xfff4,0x0003,
+0xfffc,0xffe0,0xfff2,0xfff4,0x0011,0xffea,0xffef,0xfff5,
+0x001a,0xfffa,0xfff5,0xfff6,0xfff4,0xffe9,0xfff4,0xffe9,
+0xfffb,0xffe8,0x000d,0xfffb,0x0013,0x0008,0x0026,0x0015,
+0x0014,0x0002,0x0006,0xfff4,0x000b,0x0005,0x0017,0xfff5,
+0x001d,0x0009,0xfff7,0x0000,0xfff9,0xfffa,0xffff,0x0007,
+0x0002,0xfff9,0x0003,0xfffd,0x0002,0xfffa,0xffe5,0xfffd,
+0xfffa,0xfffe,0x000e,0x0009,0xfff0,0x0001,0x0003,0x000e,
+0x0000,0xfffb,0x0003,0x0008,0x0010,0x0024,0x0013,0x0003,
+0xffff,0xfffa,0xffef,0xffe8,0xfffc,0xfff9,0x0015,0xfff5,
+0x000e,0x0012,0xfff9,0x0009,0xfff7,0xfff9,0xfffa,0xffea,
+0x0003,0xffdf,0x000a,0x000b,0x001c,0xfff9,0x0007,0x0000,
+0x0010,0xfff2,0x0002,0xfff8,0xffec,0xffef,0xfff7,0xfffe,
+0xfff2,0xfff0,0x0006,0xfffb,0x0018,0x001c,0x0015,0x0014,
+0x0008,0xfff7,0xfffc,0xffe7,0x0001,0xfff5,0x0016,0xffe8,
+0x000f,0x0008,0xffeb,0xfffb,0xfff5,0xfff2,0x0005,0xffee,
+0x000b,0xfff9,0x001b,0x0014,0x000e,0x0007,0xffff,0x0009,
+0xfff0,0x001b,0x0002,0x000a,0x000d,0x0010,0x0014,0xffec,
+0x001d,0xffec,0xfff2,0xfff0,0xfff3,0xfff8,0x0009,0x000d,
+0xfffe,0x0021,0x0009,0x0013,0x0011,0x0017,0x0011,0x0016,
+0x0006,0x0006,0xfff7,0xfffe,0xfff4,0xfffe,0xffec,0xfff3,
+0xfff3,0xfff6,0xffd3,0xfffc,0x0010,0xfff8,0xfffe,0xfff9,
+0x0005,0x000f,0xfff7,0xfff9,0x0009,0xfffe,0x0008,0xffdb,
+0x000e,0xffe1,0xfff5,0xffe3,0xfffb,0xfff0,0x000b,0x001e,
+0x0007,0x001d,0x0015,0x0012,0x0017,0x0013,0x0012,0x0009,
+0x0007,0xfffd,0xffe9,0xffef,0xfff2,0xfff7,0xfff8,0xfff7,
+0xfffa,0x000f,0xffe5,0x0004,0x0002,0x0006,0xfff4,0x0001,
+0xffe6,0x0013,0x000f,0x000c,0x0005,0x0016,0x0018,0x0000,
+0x0015,0xfff4,0xffeb,0xfff1,0xfff8,0x000b,0xfff9,0x000c,
+0xfff2,0x0014,0xfffe,0x0006,0x0007,0x0006,0x0010,0x0009,
+0xfffa,0x0005,0xffeb,0xfff9,0xfff1,0xfff6,0xfff3,0xffd9,
+0xfffb,0xfff6,0xffec,0x0013,0x001c,0x0005,0x0016,0x0005,
+0xfffc,0x0006,0x0003,0xfffb,0x0001,0x0004,0x000b,0xfff0,
+0x0006,0xffe9,0xffed,0xffe3,0x0000,0x0003,0xfffa,0x001e,
+0xfffd,0x0011,0x000a,0x0005,0x000d,0x0002,0x0011,0xfffd,
+0xfffb,0xfffd,0xffdd,0xffeb,0xffef,0xffef,0xfffe,0xffdd,
+0x0002,0x000f,0xfffd,0x001c,0x000d,0x0015,0x000d,0x000d,
+0xfff8,0x0019,0x0008,0x0017,0xfffd,0x000d,0x0003,0xffef,
+0x0014,0xfff8,0x0000,0x000a,0x0008,0x000b,0x0012,0x0000,
+0x0001,0x000a,0x0005,0x0000,0x001c,0x0011,0x0020,0x000f,
+0x001a,0x0001,0xffed,0xfff7,0xfffd,0xffeb,0xfff1,0x0007,
+0xfffa,0xfff7,0xffe3,0xfffb,0x000a,0xffef,0xfff1,0xfff7,
+0x000d,0x000d,0xfffd,0x0005,0xfff9,0xfffc,0xfff7,0xffde,
+0x0005,0xffec,0x0002,0xfffd,0x0010,0x0003,0x0014,0x0011,
+0x000b,0x0007,0x0011,0x0000,0x0022,0x000d,0x0021,0x0002,
+0x001c,0xfff8,0xffe0,0xffe8,0xfffb,0xffe3,0xfffd,0x000c,
+0x0000,0x000f,0xfff5,0x0003,0xfffd,0xfffe,0xffe8,0xffff,
+0xffee,0x0011,0x0015,0x0019,0xfff5,0x0013,0x0006,0x0003,
+0x000b,0x0000,0xfff9,0x000b,0x000d,0x001f,0x0001,0x0000,
+0xfff7,0xffff,0xfffb,0xfff4,0x0012,0x0000,0x001f,0x0002,
+0x000d,0x0001,0xffe2,0xfff2,0xfff9,0xffe3,0xfff7,0xffee,
+0x0001,0xfff6,0xfffc,0x0012,0x0016,0xfffd,0x000a,0x0002,
+0x0003,0x0005,0x0009,0x0007,0xfff1,0x0001,0xfffb,0xfff3,
+0xfffe,0xfff4,0xfffb,0xfffe,0x0015,0x0017,0x0002,0x0010,
+0x0000,0xfffb,0x0006,0xfff3,0x0017,0xfffd,0x0020,0xfff6,
+0x000f,0xfff8,0xffd4,0xffe4,0xfff7,0xffdb,0x0002,0xfff3,
+0x0009,0x000f,0x000c,0x001b,0x0007,0x000c,0x0000,0x000b,
+0xffd4,0x0006,0xffe2,0xfff8,0x0009,0x000a,0x000b,0x000e,
+0x0017,0xfffb,0x0008,0xfffc,0x000e,0xfff4,0x0025,0x000e,
+0x000c,0x001a,0x0004,0x0010,0xfff8,0x0010,0xfff7,0x0007,
+0xfffa,0x0013,0x000c,0x0019,0xfffb,0x0018,0xfff1,0xfff3,
+0xfff8,0xffdc,0xffde,0xffe1,0xffff,0xffee,0xfffc,0xffee,
+0xffea,0xfffb,0xffd6,0xffe6,0x0006,0xfff8,0xffff,0xfffe,
+0x0009,0xffef,0x000a,0xffee,0x0015,0xffed,0x0027,0x001f,
+0x0017,0x0017,0x0010,0x000f,0xfffe,0x000c,0xfff9,0xfffa,
+0xfffb,0x0009,0xffff,0x000a,0xfff9,0x0010,0xfffc,0xfff7,
+0x0000,0xfff6,0xffef,0xffea,0xfff0,0xfffe,0xfff2,0xfff7,
+0xffc9,0xffff,0xffef,0xfffa,0x0001,0x0010,0x000f,0x0023,
+0x000f,0x0002,0x0000,0xfffc,0x0013,0x0008,0x0014,0x000d,
+0x0001,0x000e,0xfff9,0x0003,0xffee,0x0000,0xfff6,0xfffb,
+0xffed,0x0013,0x0000,0x0015,0xfff8,0x0010,0xfff7,0xffd9,
+0x0000,0xffdc,0xfff6,0xfff9,0x0009,0xfffc,0x0014,0xfffb,
+0xffdf,0xfff3,0xffe3,0xffe8,0xffff,0xffff,0x0002,0x0012,
+0x0000,0xfff7,0x0003,0xffef,0x001b,0x0000,0x0015,0x001e,
+0x000c,0x000b,0x0005,0x0002,0xfff4,0xfffc,0xfff7,0xffed,
+0xffee,0x0009,0xfff3,0x0006,0xfff5,0x0008,0x0002,0xffdd,
+0x0008,0xfff6,0x0007,0x0001,0xfffc,0x000b,0x000a,0x0002,
+0xffdc,0x0005,0xffe8,0x0004,0xfff9,0x0007,0xfffa,0x0011,
+0x000e,0x0005,0x0016,0x0016,0x0023,0x0008,0x002e,0x0001,
+0x0011,0x0003,0x0000,0xfffe,0x0002,0x000a,0x0005,0x0000,
+0x000e,0x000f,0x0002,0x0012,0x0002,0x0004,0xfff5,0x0007,
+0xffff,0xffdc,0xffee,0xffe0,0xfff9,0xffe5,0xffef,0xffec,
+0xfff2,0xfff9,0xffdc,0xfff3,0xfff6,0xfff6,0xffee,0x0000,
+0x0000,0xfffb,0x0019,0x0008,0x002b,0x0000,0x0030,0x0012,
+0x001b,0x0000,0x000c,0xfffd,0x0007,0x0006,0x0007,0xfff3,
+0x000f,0x0005,0xfff5,0x0003,0x0000,0xfffe,0x0000,0x000c,
+0x0006,0xfff6,0x0000,0xffe9,0xffea,0xfff5,0xffe6,0xfff4,
+0xffd1,0xfffd,0xfff5,0x0006,0xfff1,0x000d,0xfffe,0x0026,
+0x0006,0x000d,0x000f,0x0016,0x0028,0x001c,0x001c,0x0000,
+0x0005,0xfff8,0xfff6,0xfff1,0xfff9,0xfff9,0x0004,0xfff3,
+0x0001,0x000e,0xfff7,0x000e,0x0000,0xfffe,0xfffc,0xffee,
+0x0007,0xffdc,0x0006,0xfff8,0x0003,0xfff3,0x0007,0xfff8,
+0xffe7,0xfff1,0xffea,0xfff5,0xffee,0xfffc,0xfff1,0x0016,
+0xfff8,0x0002,0x0011,0x0009,0x0030,0x0014,0x001e,0x0011,
+0x0010,0xfff5,0x0001,0xfff0,0xfffe,0xfff6,0x0005,0xffe6,
+0x0002,0x0004,0xffea,0x0000,0xfffe,0xfff6,0x0006,0xfff3,
+0x000e,0xfff6,0x0017,0x0000,0xfff6,0x0002,0xffff,0x0000,
+0xffc7,0x001a,0xffea,0x0007,0x000e,0x001c,0x000e,0x0003,
+0x0023,0x0000,0xfffd,0xffff,0x000b,0xfff0,0x0012,0x000a,
+0x0004,0x001f,0x000f,0x001c,0x000e,0x0017,0x0001,0x0015,
+0xfff9,0x0002,0xfff5,0x0001,0xfffd,0x0001,0xffee,0xfff7,
+0xfff6,0xfff3,0xffcf,0xffe8,0xfff8,0xfff2,0xfffe,0xfff0,
+0xffdd,0x000e,0xffde,0xfff6,0x000a,0x000a,0x0001,0xfff4,
+0x0014,0xfff4,0x0000,0xfff1,0x0012,0xffe8,0x0014,0x001b,
+0x000e,0x001c,0x001b,0x001b,0x0014,0x0013,0x0002,0x0008,
+0xfffb,0xfff9,0xffe7,0xfff3,0xfffb,0xfffb,0xfffa,0xfffb,
+0xfffe,0x000c,0xffe1,0xfff1,0xffe9,0x0001,0xfff4,0xfff8,
+0xffbc,0x0012,0xfff7,0x0009,0x0006,0x0023,0x0012,0x0019,
+0x001a,0x0007,0xfff6,0xffff,0x0010,0x0003,0x0001,0x0009,
+0xfffa,0x0013,0x0004,0x000f,0x0004,0x0006,0x0000,0x0008,
+0xffec,0x0002,0xffe9,0xfffe,0xfff9,0xfffb,0xfff4,0xffdd,
+0xffff,0xfff3,0xffe8,0x0000,0x0003,0x0000,0x0016,0xfffc,
+0xffd2,0x0006,0xffeb,0xfff8,0x0002,0x0010,0x0005,0x0008,
+0x000b,0xfffc,0xfff8,0xfff1,0x0018,0xfffc,0x0002,0x001a,
+0x0003,0x0010,0x0010,0x000e,0x0009,0x0002,0x0001,0xfffc,
+0xffed,0xfff9,0xffdc,0xffef,0xfff7,0xfff3,0x0000,0xffe1,
+0x0005,0x000c,0xfff9,0x0008,0xfff5,0x000f,0x000d,0x0004,
+0xffcf,0x0018,0xfff0,0x0014,0xfffe,0x001a,0xfffe,0x0007,
+0x0019,0x000a,0x000b,0x0019,0x0020,0x0003,0x001b,0xfffe,
+0x0008,0x0008,0x000b,0x0009,0x0018,0x0011,0x0010,0x000e,
+0x000d,0xfffe,0xffec,0xfffb,0x0004,0xffef,0xfff2,0x000c,
+0xfffd,0xfff3,0xffdf,0xffe7,0xfff2,0xffe9,0xfff1,0xffed,
+0xffe5,0x000c,0xffe4,0x0002,0xfffa,0x0007,0xfff1,0xfff7,
+0x000b,0xffff,0x000d,0x000b,0x0028,0xfffc,0x001d,0x000e,
+0x0013,0x0005,0x0017,0x0008,0x001e,0x000d,0x0011,0x0000,
+0x000e,0xfff4,0xffde,0xffec,0x0002,0xffe7,0xfffe,0x0010,
+0x0004,0x000c,0xfff1,0xfff0,0xffe3,0xfff9,0xffe8,0xfff6,
+0xffc4,0x0010,0xfffd,0x0016,0xfff6,0x0020,0x0000,0x001c,
+0x0011,0x0012,0x0003,0x0019,0x0025,0x0017,0x000a,0xfffd,
+0xfffe,0xfffd,0x0000,0xfffd,0x000e,0x0000,0x000e,0x0001,
+0x0000,0xfffe,0xffe0,0xfff7,0x0001,0xffe7,0xfff9,0xfff3,
+0x0005,0xfff3,0xfff8,0xffff,0xfffe,0xfff8,0x000a,0xfffa,
+0xffda,0x0004,0xfff1,0x0004,0xfff2,0x000d,0xfff4,0x000b,
+0x0002,0x0006,0x0006,0x000b,0x002d,0x0010,0x000b,0x000d,
+0x0007,0xfffa,0x000c,0xfffc,0x0014,0xfffd,0x0010,0xfff4,
+0x0001,0xfff4,0xffd2,0xffe8,0x0000,0xffdf,0x0003,0xfff7,
+0x000c,0x000c,0x0008,0x0007,0xffef,0x0006,0x0000,0x0002};
+
+const signed short etable2[5120]={
+0x0049,0xffe0,0xffc4,0xfff1,0xffe6,0x003b,0x0002,0xffdf,
+0x001e,0xfff6,0xfffd,0xffef,0x0008,0x001e,0xffff,0xffe6,
+0xfffc,0xffea,0x000a,0x0010,0xffdc,0xfffb,0xfff5,0x0038,
+0x0025,0x0006,0xfff6,0xfffb,0xfff3,0xfffd,0x0006,0xfffb,
+0x000b,0x0004,0xffed,0xfffb,0xfff0,0x0029,0x0018,0x000d,
+0x0004,0xfff5,0xffdb,0x0017,0xfffb,0x002e,0xfffe,0xffe3,
+0xfffb,0xffd9,0xffeb,0xfff7,0x0000,0x0031,0x000c,0xfff7,
+0xfff0,0xffe6,0x0016,0x000f,0xffd3,0xffec,0xfffb,0x0028,
+0x0016,0x0011,0xffe6,0x001f,0xfff2,0x0002,0xfff2,0x000a,
+0x001e,0x0014,0xffe5,0xfff7,0xffd9,0x0027,0x0012,0x0005,
+0x0022,0xffe7,0xffd0,0xffe4,0xfff5,0x0022,0xfffe,0xffd7,
+0x0009,0xfff9,0xffef,0x0015,0x0014,0x0018,0xffef,0xffdf,
+0x0000,0xffe8,0x000a,0x002a,0x0003,0xfffb,0x000a,0x002a,
+0x000b,0x0008,0xfffd,0x0003,0x0010,0x0009,0x0016,0xfffe,
+0x0000,0xffdf,0xfff6,0x0012,0x0007,0x003a,0x000a,0x001c,
+0xffde,0xfffc,0xffe7,0x000a,0x0009,0x0015,0xfff9,0xffdc,
+0xffe6,0xffdc,0xffdd,0x001c,0x000c,0x002a,0xfffd,0xfff0,
+0xfff4,0xffe4,0x0015,0x002a,0xfffb,0xffeb,0x0010,0x001a,
+0xfffc,0x0013,0xffed,0x0027,0x000f,0x000f,0x0001,0x000d,
+0x0013,0xffef,0xffef,0x000e,0xfff1,0x0037,0x0004,0x0013,
+0x001c,0xffec,0xffcd,0xfff2,0xfffa,0x0007,0x0000,0xffe6,
+0x001b,0xfffc,0x0012,0xffd8,0xfffa,0x0010,0xffff,0xfff1,
+0x0000,0xffc9,0xfffb,0xfff0,0xffed,0x000e,0xfffd,0x0031,
+0x000e,0x0001,0xffea,0xffe2,0xfff4,0x0000,0x0018,0x000f,
+0x0009,0xffef,0xffd3,0xffe3,0x0004,0x001c,0x0033,0x0023,
+0xffd8,0x0000,0xffe4,0x0018,0x000e,0xfffb,0xfffc,0xffeb,
+0xfff9,0xffdf,0x0000,0xffe0,0xfff1,0x0023,0x000c,0x0001,
+0xfff5,0xffc6,0x0005,0xfff0,0xffe4,0x0000,0x0001,0x0021,
+0x0000,0x000b,0xffd9,0x0005,0xfff2,0x0006,0x0003,0x001f,
+0x001c,0xffff,0xffcb,0xffdf,0xffed,0x0019,0x002e,0x001a,
+0xfff5,0xfff2,0xffd9,0xffe5,0x0009,0xffef,0xfffc,0xffdf,
+0x0006,0x0000,0x0004,0xffff,0x0005,0x000a,0xffef,0xffea,
+0x0005,0xffc7,0xfffb,0x0009,0x0014,0x000d,0x0012,0x0023,
+0xfff5,0x0003,0xfff0,0xffea,0x0011,0x000d,0x0028,0x0013,
+0xffff,0xffc9,0xffdd,0xfffb,0x001b,0x002c,0x0025,0x0031,
+0xffb0,0x0006,0xfff0,0x000b,0x001e,0xffe2,0xfff7,0xffe4,
+0xffe4,0xffe3,0xfff3,0x0006,0xfffe,0x001c,0xfffd,0xfffb,
+0xfff9,0xffc4,0x0005,0x0009,0x000b,0xffff,0x0018,0x0013,
+0xffe5,0x000d,0xffe0,0x000d,0x000f,0x0013,0x0013,0x0023,
+0x0011,0xffd9,0xffd5,0xfff7,0x0004,0x002a,0x0020,0x0029,
+0x004e,0xffeb,0xffd5,0x0004,0xffda,0x0011,0x0011,0xfffb,
+0x0037,0x0018,0xfff1,0xffdc,0x000e,0x0004,0x0018,0xffe8,
+0x000c,0x0005,0x0011,0x001f,0xffca,0xfffb,0xfffe,0x001b,
+0x002b,0xfff4,0x0002,0x0009,0xfff7,0xfff1,0x0016,0xfffd,
+0x001c,0x0015,0xffec,0x0003,0x0014,0x001c,0x0009,0xfffb,
+0x0009,0xffff,0xffec,0x002b,0xffef,0x0003,0x000c,0x0000,
+0x0014,0xfffc,0xffdf,0xffe3,0x0006,0x0016,0x0026,0xfff9,
+0x0000,0x0001,0x001d,0x001e,0xffc1,0xffeb,0x0003,0x000b,
+0x001b,0xffff,0xfff2,0x002d,0xfff6,0xfff7,0x0001,0x000c,
+0x002f,0x0025,0xffe4,0x0000,0xfffe,0x001a,0x0004,0xfff3,
+0x0027,0xfff2,0xffe2,0xfff8,0xffea,0xfff8,0x000c,0xfff4,
+0x0022,0x001b,0xffe3,0x0002,0x001a,0xfffe,0x0008,0xffe1,
+0x0010,0x0003,0x0011,0x0039,0xfff2,0xfffa,0x0013,0x000d,
+0x0010,0xfff6,0x0008,0x0011,0x0014,0xfffe,0x0026,0x0000,
+0x0011,0xfff0,0xfff5,0x001b,0x002c,0x002d,0xfffc,0x0008,
+0xffe3,0x0005,0xfff9,0x001e,0xffff,0xffeb,0x0007,0xfff9,
+0x0000,0x0000,0xffd1,0x0009,0x0012,0x000f,0x0016,0xfff2,
+0x0004,0x0000,0x001c,0x0039,0xffe9,0xffeb,0x0019,0xfffe,
+0x0001,0x0000,0xfff9,0x0035,0x0013,0x0003,0x0011,0x000f,
+0x0024,0x0000,0xffed,0x0018,0x0015,0x002b,0xfff7,0x0000,
+0x0021,0xfff6,0xffde,0x0005,0xffef,0xffdd,0x000f,0x0001,
+0x0035,0x001e,0x0006,0xffc5,0x0000,0xfff6,0x0018,0xfff3,
+0x0011,0xffe5,0x0001,0xffff,0xffdb,0x000d,0x0004,0x0014,
+0x0014,0xffee,0xfff6,0xfff0,0xfff8,0xfff5,0x0027,0x0012,
+0x001a,0x0000,0xffd2,0xffec,0x0029,0x000f,0x0025,0x000f,
+0xffdd,0x000a,0xfff5,0x002c,0x0003,0xffd0,0x000a,0x0006,
+0x0011,0x0002,0xfff5,0xffcd,0xfff8,0x0008,0x0026,0x0003,
+0x0004,0xffe1,0x000c,0xfffe,0xffd2,0xffff,0x000a,0x0004,
+0x0005,0xfff9,0xffe6,0x0013,0xfff6,0xfffb,0x0012,0x0022,
+0x002d,0x000f,0xffca,0xffe8,0x0012,0x000d,0x001f,0x0007,
+0xfffb,0xfffd,0xffeb,0xfff9,0xfffe,0xffc4,0x000a,0xfffb,
+0x0020,0x0022,0xfff9,0xffec,0x000b,0xfff0,0x0008,0xffec,
+0x0015,0xffe3,0x0001,0x0018,0x0002,0x000d,0x001b,0x0006,
+0xfffb,0xfff1,0xfffd,0xfff8,0x0015,0x0001,0x0037,0x0015,
+0x000f,0xffda,0xffdb,0x0003,0x0041,0x0020,0x0017,0x001e,
+0xffb6,0x0011,0x0000,0x001f,0x0012,0xffb7,0x0005,0x0000,
+0xfffd,0x0005,0xffe7,0xfff4,0x0003,0x0001,0x0016,0xfffd,
+0x0009,0xffdf,0x000c,0x0018,0xfffa,0xfffe,0x0021,0xfff7,
+0xffeb,0xfffb,0xffec,0x001b,0x0013,0x0007,0x0022,0x0025,
+0x0022,0xffea,0xffd4,0x0000,0x0029,0x001d,0x0011,0x0015,
+0x004c,0xffdd,0xffe1,0xffe4,0xffcf,0x002b,0xffd8,0x0000,
+0x001d,0xfff2,0x0008,0x0005,0x000a,0x0012,0xffe6,0xffd2,
+0x0000,0x0007,0x0006,0x0003,0xffe7,0xfff9,0xfffe,0x0028,
+0x001c,0x000e,0x0012,0xfffd,0xffe5,0xffe4,0xfff8,0xffd3,
+0xfff3,0x0022,0xfff3,0xffe5,0xfff1,0x001f,0x000c,0x0003,
+0x0007,0xfff1,0xfff7,0x0009,0xffe4,0x001d,0xffd3,0x0005,
+0xfffa,0xffd5,0xfff7,0x000c,0x0002,0x0024,0xfff4,0xffe2,
+0xfff5,0x0003,0x0011,0x0003,0xffde,0xffea,0x0003,0x0018,
+0x000c,0x0018,0x0002,0x0020,0xffe4,0xffea,0xffe3,0xffe3,
+0x0005,0x0032,0xffeb,0xffe1,0xffda,0x001d,0x0007,0xfffb,
+0x0024,0xffe3,0xffed,0xffd7,0xffde,0x0012,0xffd3,0xfffa,
+0x0008,0xfff6,0xfffb,0x002b,0x0017,0x000b,0xffd6,0xffcb,
+0x0005,0x0005,0x0006,0x001e,0x000e,0xfff8,0x0014,0x001a,
+0x0001,0x0010,0x0019,0x0004,0x0003,0xfff1,0x0007,0xffd7,
+0xffe9,0xfffd,0xfffc,0xfffd,0x0008,0x0030,0xffff,0x0011,
+0xffe0,0xfff8,0x0003,0xfffe,0xfff3,0x0004,0xffce,0xffff,
+0xffe5,0xffd9,0xffe9,0x0033,0x000f,0x001e,0xffe5,0xffdb,
+0xfff9,0x0001,0x0011,0x001d,0x0005,0xffe9,0x0019,0x000a,
+0xfff2,0x001a,0x0008,0x0029,0x0001,0xfff7,0xfff3,0xffe6,
+0xfffb,0x000c,0xfff4,0xfff9,0xfff2,0x002d,0xfffa,0x0009,
+0x001f,0xffe8,0xffe9,0xffe5,0xffe3,0xfff7,0xffd5,0x0008,
+0x001a,0xfff9,0x001e,0xffef,0xfffc,0x0003,0xffe6,0xffdd,
+0x0005,0xffe8,0xfff6,0xffe4,0xfff7,0x000c,0x0005,0x0021,
+0x0005,0x0008,0x0005,0xffe3,0xffe6,0xffe8,0x0009,0xffe9,
+0xfff2,0x000c,0xffd9,0xffcc,0x0005,0x0012,0x0027,0x0018,
+0xffdb,0xfffd,0x0000,0x000a,0xfff9,0xffea,0xffd0,0x000c,
+0xfff8,0xffdc,0x000c,0xfff7,0xfff4,0x0016,0xfff4,0xffed,
+0xfffa,0xffe4,0x0000,0xffe3,0xffee,0xfffd,0x000b,0x0011,
+0xfff6,0x0012,0xfff6,0x0007,0xffe5,0xffee,0xfff5,0xfff9,
+0x0003,0x001c,0xffd1,0xffc9,0xffee,0x000f,0x0022,0x0010,
+0xfff8,0xffef,0xfff6,0xffd8,0xfff3,0xffde,0xffd1,0x0000,
+0x0005,0xfffc,0x0010,0x0015,0x0008,0xfffe,0xffd6,0xffd5,
+0x000a,0xffe6,0xfff6,0xfffe,0x001f,0x000b,0x001b,0x0013,
+0xffeb,0x000a,0x000c,0xffec,0x0003,0xfff5,0x0019,0xffec,
+0xffe7,0xffe7,0xffe3,0xffe4,0x001c,0x0022,0x0019,0x0026,
+0xffb3,0x0002,0x000b,0xffff,0x0007,0xffd1,0xffcc,0x0005,
+0xffe3,0xffdf,0xffff,0x001c,0x0000,0x000f,0xffe4,0xffe6,
+0xfffe,0xffe2,0x0000,0xfffe,0x0016,0xfffc,0x0021,0x0003,
+0xffdc,0x0015,0xfffd,0x000f,0x0002,0xfffb,0x0004,0xfffc,
+0xfffa,0xfff7,0xffdb,0xffe1,0x0005,0x0020,0x0014,0x001e,
+0x0051,0xffe7,0xfff2,0xfff8,0xffc3,0x0000,0xffe7,0x001c,
+0x0036,0x0014,0xfffd,0xfff2,0x0011,0xfff8,0x0000,0xffd4,
+0x0010,0x0023,0x000d,0x0012,0xffd5,0xfff9,0x0006,0x000b,
+0x0021,0xfffc,0x001e,0x000b,0xffea,0xffd8,0x0006,0xffd5,
+0x0003,0x0032,0xfff2,0xffee,0x0016,0x0012,0xffff,0xfff0,
+0x000c,0xfffc,0x0008,0x001d,0xffd9,0xfff4,0xffe2,0x0021,
+0x0013,0xfff8,0xffeb,0xfffa,0x0008,0x0009,0x000d,0xffe4,
+0x0004,0x001f,0x0018,0x0012,0xffcc,0xffe9,0x000c,0xfffc,
+0x0012,0x0005,0x000e,0x002f,0xffe8,0xffde,0xfff2,0xffe5,
+0x0016,0x0042,0xffea,0xffea,0xffff,0x0010,0xfffa,0xffe8,
+0x0029,0xffee,0xfffe,0xffeb,0xffd3,0xffe8,0xffe2,0x0015,
+0x0021,0x0018,0xffef,0x0018,0x001d,0xfff1,0xfff0,0xffcd,
+0x0015,0x0021,0x000d,0x002d,0xfffd,0xfff8,0x001c,0xfffe,
+0x0007,0xfffe,0x0025,0x0013,0x0007,0xffe5,0x0016,0xffd9,
+0xfff9,0x000c,0xfffb,0x0005,0x002d,0x0023,0xfff1,0xffff,
+0xffe5,0x0001,0x0014,0x0011,0xffe8,0xffda,0xffdd,0x001a,
+0xffff,0xfffc,0xffdd,0x0020,0x0015,0x0003,0xfffe,0xffdd,
+0x0008,0x001d,0x0018,0x002c,0xfff4,0xffe8,0x0022,0xffee,
+0xfff8,0x0007,0x0015,0x0037,0x0005,0xffeb,0x0002,0xffe9,
+0x000b,0x001c,0xfff3,0x0001,0x0016,0x0021,0xffeb,0xfff6,
+0x0024,0xfff3,0xfffb,0xfff9,0xffd8,0xffcd,0xffe4,0x0024,
+0x0034,0x001b,0x0012,0xffdc,0x0002,0xffea,0x0000,0xffdf,
+0x0015,0x0002,0xfffd,0xfff3,0xffe6,0x000b,0x000e,0x0004,
+0x000a,0xfff6,0x0012,0xfff2,0xffea,0xffdc,0x0018,0xffeb,
+0x0001,0x001c,0xffd8,0xffd6,0x002a,0x0005,0x0019,0x0005,
+0xffe0,0x0006,0x0011,0x001f,0xffed,0xffbf,0xffdf,0x0029,
+0x0010,0xffff,0x0000,0xffe3,0xfffa,0xfffc,0x000d,0xffef,
+0x0009,0xffff,0x0008,0xfff2,0xffdd,0xfffd,0x0013,0xfff5,
+0xfffc,0x0000,0x0001,0x0015,0xffe9,0xffe2,0x0003,0xfffb,
+0x0014,0x002c,0xffd0,0xffd2,0x0013,0x0003,0x0014,0xfffd,
+0xfffd,0xfff9,0x0006,0xffec,0xffe7,0xffb3,0xffe0,0x001d,
+0x001f,0x001e,0x0004,0x0002,0x000e,0xffe3,0xfff0,0xffd8,
+0x001a,0x0000,0xfffd,0x000c,0x000d,0x000a,0x0024,0xfff7,
+0xfff1,0xfff8,0x0018,0xfffa,0x0007,0xffea,0x0028,0xffef,
+0xfff8,0xfff7,0xffe1,0xffee,0x0042,0x0016,0x000b,0x0013,
+0xffb8,0x000d,0x001d,0x0012,0xfffc,0xffa6,0xffdb,0x0022,
+0xfffc,0x0001,0xfff3,0x0009,0x0006,0xfff5,0xfffe,0xffe8,
+0x000d,0xfffd,0x0007,0x000b,0x0004,0xfffc,0x002a,0xffe7,
+0xffe1,0x0001,0x0008,0x001d,0x0006,0xffef,0x0013,0xfffe,
+0x000a,0x0006,0xffda,0xffea,0x002a,0x0013,0x0006,0x000b,
+0x0074,0xffec,0xffbc,0xffe2,0xffe4,0x0053,0x001c,0xffee,
+0x0020,0xffea,0xfff3,0xffeb,0x0005,0x001c,0x0005,0xfff9,
+0xffe8,0xfff8,0xffea,0x0011,0xffe9,0x001e,0xffe7,0x002d,
+0x000f,0xfff7,0xfff5,0xffee,0x0016,0xfff6,0x0004,0xfffe,
+0x0013,0xfff4,0x0017,0x0003,0xffd5,0x0002,0x000c,0xfffc,
+0x002f,0x0000,0xffd3,0x0007,0xfff9,0x0045,0x0017,0xfff3,
+0xfffe,0xffcd,0xffe0,0xfff2,0xfffd,0x002f,0x0013,0x0008,
+0xffdb,0xfff5,0xfff6,0x0010,0xffe0,0x000f,0xffed,0x001d,
+0x0000,0x0001,0xffe4,0x0012,0x0014,0xfffc,0xfff0,0x000d,
+0x0026,0x0003,0x000f,0x0000,0xffbe,0x0000,0x0007,0xfff3,
+0x004d,0xfff3,0xffc8,0xffd5,0xfff3,0x0039,0x0017,0xffe6,
+0x000b,0xffed,0xffe5,0x0010,0x0011,0x0016,0xfff6,0xfff1,
+0xffed,0xfff6,0xffea,0x002b,0x0010,0x001e,0xfffe,0x001f,
+0xfff5,0xfffa,0xfffb,0xfff7,0x0034,0x0002,0x0014,0x0000,
+0x0008,0xffce,0x0021,0x001b,0xffed,0x0013,0xffff,0x0009,
+0x0008,0x0006,0xffdf,0xfffc,0x0007,0x002c,0x0012,0xffeb,
+0xffe9,0xffd0,0xffd2,0x0018,0x0009,0x0028,0x0003,0x0001,
+0xffe0,0xfff3,0xfff5,0x002b,0x0007,0x000e,0x0003,0x000f,
+0xffe6,0x0003,0xffeb,0x001a,0x0032,0x0008,0x0000,0x0010,
+0x001b,0xffde,0x0019,0x0017,0xffd5,0x0011,0xfffa,0x0001,
+0x0047,0xfff7,0xffc5,0xffe3,0xfff8,0x001e,0x001a,0xfff5,
+0x001e,0xfff0,0x0008,0xffd4,0xfff7,0x000e,0x0005,0x0002,
+0xffed,0xffd8,0xffda,0xfff1,0xfff9,0x0032,0xffef,0x0026,
+0xfff9,0xfff2,0xffe8,0xffd5,0x0016,0xfffa,0x0016,0x0013,
+0x0011,0xffde,0xfffe,0xffec,0xffe9,0xfff6,0x0027,0x0010,
+0x0002,0x000b,0xffdc,0x0009,0x000d,0x0011,0x0015,0xfffa,
+0xfffb,0xffd3,0xfff6,0xffdc,0xffee,0x0021,0x0013,0x0013,
+0xffe1,0xffd4,0xffe5,0xfff1,0xfff0,0x0022,0xfff5,0x0016,
+0xffea,0xfffc,0xffd8,0xfff9,0x0015,0x0000,0x0001,0x0023,
+0x0024,0xffee,0xfff6,0xffe8,0xffd2,0xfff4,0x0022,0x0008,
+0x0020,0xfffe,0xffd1,0xffd6,0x0007,0x0005,0x0015,0xffee,
+0x0009,0xfff4,0xfffb,0xfffb,0x0002,0x0008,0xfff6,0xfffc,
+0xfff2,0xffd6,0xffda,0x000a,0x0021,0x0031,0x0005,0x0018,
+0xffdf,0xfff4,0xffef,0xffdd,0x0034,0x0006,0x0026,0x0016,
+0x0007,0xffb8,0x0007,0x0003,0x0000,0x0006,0x0019,0x001e,
+0xffdc,0x0012,0xffe8,0xfffd,0x001c,0xfff9,0x0010,0xfff3,
+0xffe6,0xffd7,0xffe8,0x0001,0xfffb,0x001a,0x0003,0x000c,
+0xffe5,0xffd2,0xffe5,0x000a,0x0018,0x0022,0x000a,0x0008,
+0xffcf,0xfffe,0xffde,0x0000,0x0033,0x000c,0x0011,0x0026,
+0x0019,0xffc8,0x0000,0x0000,0xffea,0x0003,0x0014,0x0016,
+0x0079,0xfff7,0xffce,0xfff6,0xffd8,0x0028,0x002b,0x0009,
+0x003a,0x000c,0xffe7,0xffd7,0x000b,0x0002,0x001f,0xfffb,
+0xfff8,0x0013,0xfff1,0x0020,0xffd7,0x001e,0xfff0,0x0010,
+0x0014,0xffe4,0x0000,0xfffd,0x001a,0xffea,0x0013,0x0000,
+0x0024,0x0004,0x0016,0x000c,0xfffa,0xfff7,0xffff,0xffe8,
+0x0034,0x000a,0xffe5,0x001b,0xffee,0x001a,0x0026,0x000e,
+0x0017,0xfff0,0xffd4,0xffdf,0x0003,0x0014,0x002d,0x000a,
+0xffec,0x000f,0xfffd,0x001f,0xffce,0x000e,0xfff6,0x0000,
+0x0005,0xffef,0xfff1,0x0020,0x0018,0xfff0,0xffff,0x000f,
+0x0037,0x0014,0x000e,0x0008,0xffe3,0xfff4,0xfff9,0xffe0,
+0x0052,0xfffd,0xffda,0xffe9,0xffe8,0x000f,0x0026,0x0002,
+0x0025,0x000f,0xffd9,0xfffe,0x0017,0xfffc,0x000f,0xfff4,
+0xfffd,0x0011,0xfff1,0x003a,0xffff,0x001d,0x0006,0x0002,
+0xfffb,0xffe6,0x0007,0x0004,0x0038,0xfff7,0x0023,0x0003,
+0x0019,0xffdf,0x0020,0x0024,0x0011,0x0007,0xfff1,0xfff7,
+0x000d,0x0011,0xfff1,0x000f,0xfffd,0x0001,0x0021,0x0007,
+0x0001,0xfff4,0xffc6,0x0005,0x000f,0x000d,0x001d,0x0003,
+0xfff0,0x000d,0xfffc,0x0039,0xfff6,0x000d,0x000b,0xfff3,
+0xffeb,0xfff1,0xfff7,0x0028,0x0037,0xfffd,0x000e,0x0013,
+0x002c,0xffef,0x0018,0x0020,0xfffb,0x0004,0xffeb,0xffee,
+0x004c,0x0001,0xffd7,0xfff7,0xffed,0xfff4,0x0029,0x0011,
+0x0037,0x0012,0xfffd,0xffc1,0xfffd,0xfff4,0x001e,0x0005,
+0xfffd,0xfff4,0xffe1,0x0000,0xffe8,0x0031,0xfff8,0x0009,
+0xffff,0xffdf,0xfff4,0xffe3,0x001b,0xffee,0x0025,0x0015,
+0x0022,0xffef,0xfffd,0xfff5,0x000e,0xffe9,0x0019,0xfffe,
+0x0007,0x0016,0xffee,0x001d,0x0001,0xffe7,0x0024,0x0015,
+0x0014,0xfff7,0xffea,0xffc8,0xfff5,0x0006,0x002d,0x0015,
+0xfff1,0xfff0,0xffec,0xffff,0xffdf,0x0022,0xfffe,0xfffa,
+0xffef,0xffe9,0xffe4,0x0006,0x0019,0xfff4,0x0010,0x0025,
+0x0035,0xffff,0xfff5,0xfff1,0xfff8,0xffe7,0x0014,0xfff5,
+0x0025,0x0008,0xffe3,0xffea,0xfffc,0xffdb,0x0024,0x0009,
+0x0022,0x0016,0xffef,0xffe8,0x0008,0xffee,0x000f,0xfffe,
+0x0001,0xfff2,0xffe1,0x0019,0x000f,0x0030,0x000d,0xfffc,
+0xffe4,0xffe1,0xfffb,0xffeb,0x0039,0xfffc,0x0035,0x0018,
+0x0017,0xffc9,0x0006,0x000c,0x0025,0xfffa,0x000b,0x000b,
+0xffe1,0x001c,0xfffa,0x0010,0x0010,0xffce,0x001f,0x000e,
+0x0000,0xfffa,0xffdc,0xffef,0x0000,0x0000,0x001d,0x000e,
+0xfff5,0xffee,0xffec,0x0019,0x0006,0x0021,0x0013,0xffec,
+0xffd5,0xffeb,0xffeb,0x000e,0x0037,0x0000,0x0020,0x0028,
+0x002a,0xffd9,0xffff,0x0008,0x000e,0xfff8,0x0006,0x0003,
+0x0077,0xffe8,0xffd9,0xffd4,0xffcd,0x0042,0xfff2,0x000f,
+0x001f,0xffe6,0xffff,0x0000,0x0007,0x0010,0xffed,0xffe4,
+0xffed,0x0016,0xffe6,0x0004,0xfff3,0x001c,0xfff0,0x001d,
+0x0005,0xffff,0x0010,0xfff0,0x0008,0xffdd,0xfff6,0xffd6,
+0xfffc,0x0011,0x001d,0xffed,0xffd6,0xfff9,0x0000,0xfff1,
+0x0032,0xfffd,0xfff0,0xfffb,0xffe2,0x0035,0xffed,0x0014,
+0xfffd,0xffc9,0xffed,0x0008,0x0000,0x0022,0xfffb,0xfff5,
+0xffe0,0x0012,0xfff1,0x0004,0xffea,0x000d,0xfff6,0x000d,
+0xfff7,0x0008,0x0000,0x0013,0x0007,0xffe3,0xffe1,0xffe6,
+0x000d,0x0021,0x0015,0xffea,0xffbf,0xfff7,0xfffc,0xffe9,
+0x004f,0xffef,0xffe5,0xffc8,0xffdc,0x0029,0xffed,0x0008,
+0x000a,0xffea,0xfff1,0x0027,0x0014,0x0009,0xffdd,0xffdd,
+0xfff1,0x0014,0xffe6,0x001f,0x001a,0x001b,0x0006,0x000f,
+0xffec,0x0000,0x0017,0xfff8,0x0026,0xffea,0x0005,0xffda,
+0xfff1,0xffec,0x0027,0x0004,0xffee,0x0009,0xfff3,0xffff,
+0x000a,0x0003,0xfffc,0xffee,0xfff1,0x001b,0xffe8,0x000d,
+0xffe8,0xffcd,0xffde,0x002f,0x000c,0x001c,0xffeb,0xffed,
+0xffe5,0x0010,0xfff1,0x001e,0x0011,0x000c,0x000c,0x0000,
+0xffdc,0x000a,0x0007,0x001b,0x0025,0xfff0,0xfff1,0xffea,
+0x0003,0xfffc,0x001f,0x0001,0xffd6,0x0007,0xffee,0xfff7,
+0x004a,0xfff4,0xffe2,0xffd6,0xffe2,0x000e,0xfff0,0x0017,
+0x001d,0xffed,0x0014,0xffeb,0xfff9,0x0001,0xffed,0xffef,
+0xfff2,0xfff6,0xffd5,0xffe5,0x0003,0x0030,0xfff8,0x0016,
+0xfff0,0xfff9,0x0004,0xffd6,0x0009,0xffe1,0x0006,0xffec,
+0xfffa,0xfffc,0x0003,0xffd5,0xffea,0xffec,0x001c,0x0005,
+0x0005,0x0007,0xfff9,0xfffc,0xfff7,0x0000,0xffeb,0x001c,
+0xfffa,0xffd0,0x0002,0xfff2,0xfff1,0x0014,0xfffb,0x0000,
+0xffe5,0xfff2,0xffe0,0xffe4,0xfffb,0x0020,0xfffe,0x0006,
+0xffe0,0x0003,0xfff4,0xfffb,0x0008,0xffe7,0xfff2,0xfffc,
+0x000c,0x000b,0xfffc,0xffd1,0xffd3,0xffea,0x0016,0xfffe,
+0x0022,0xfffa,0xffee,0xffc9,0xfff1,0xfff5,0xffeb,0x0010,
+0x0008,0xfff0,0x0006,0x0010,0x0005,0xfffc,0xffdd,0xffe8,
+0xfff6,0xfff4,0xffd5,0xffff,0x002b,0x002f,0x000e,0x0008,
+0xffd5,0xfffb,0x000a,0xffde,0x0027,0xffee,0x0016,0xfff0,
+0xffef,0xffd6,0x000d,0xffed,0x0001,0xfffd,0x000e,0x0014,
+0xffde,0x000e,0x0004,0xffef,0x0005,0xffe8,0xffe6,0x0014,
+0xffe5,0xffd3,0xfff4,0x0018,0xfffe,0x000d,0xffeb,0xfff8,
+0xffea,0xfff0,0xffe0,0xfffe,0x0022,0x001f,0x0014,0xfff9,
+0xffc6,0x0005,0xfffb,0x0002,0x0026,0xfff4,0x0002,0xffff,
+0x0001,0xffe6,0x0005,0xffe9,0xffeb,0xfffa,0x0008,0x000b,
+0x007c,0xfff3,0xffeb,0xffe9,0xffc2,0x0017,0x0000,0x002b,
+0x0039,0x0008,0xfff3,0xffee,0x000e,0xfff6,0x0006,0xffe6,
+0xfffd,0x0031,0xffed,0x0013,0xffe1,0x001b,0xfff9,0x0000,
+0x000b,0xffec,0x001d,0xffff,0x000c,0xffd1,0x0004,0xffd9,
+0x000b,0x0022,0x001c,0xfff7,0xfffb,0xffed,0xfff3,0xffde,
+0x0037,0x0006,0x0001,0x000e,0xffd7,0x000a,0xfffc,0x0030,
+0x0016,0xffec,0xffe1,0xfff6,0x0005,0x0007,0x0014,0xfff7,
+0xfff0,0x002d,0xfff8,0x0013,0xffd8,0x000c,0xffff,0xfff1,
+0xfffc,0xfff6,0x000c,0x0022,0x000b,0xffd7,0xfff0,0xffe8,
+0x001e,0x0031,0x0014,0xfff3,0xffe4,0xffea,0xffee,0xffd5,
+0x0054,0xfffa,0xfff7,0xffdc,0xffd1,0xffff,0xfffc,0x0024,
+0x0024,0x000c,0xffe5,0x0014,0x001a,0xffef,0xfff7,0xffdf,
+0x0001,0x002f,0xffed,0x002e,0x0009,0x001b,0x000f,0xfff3,
+0xfff1,0xffee,0x0023,0x0006,0x002a,0xffdf,0x0014,0xffdc,
+0x0001,0xfffc,0x0026,0x000e,0x0012,0xfffe,0xffe5,0xffec,
+0x000f,0x000d,0x000d,0x0001,0xffe6,0xfff2,0xfff7,0x0029,
+0x0001,0xfff0,0xffd2,0x001b,0x0012,0x0001,0x0004,0xfff0,
+0xfff5,0x002b,0xfff8,0x002d,0x0000,0x000b,0x0015,0xffe3,
+0xffe2,0xfff8,0x0013,0x002a,0x0029,0xffe4,0x0000,0xffec,
+0x0014,0x000b,0x001e,0x000a,0xfffc,0xfffb,0xffe0,0xffe4,
+0x004f,0xfffe,0xfff4,0xffea,0xffd6,0xffe4,0xffff,0x0033,
+0x0036,0x000f,0x0008,0xffd7,0x0000,0xffe8,0x0006,0xfff1,
+0x0001,0x0011,0xffdc,0xfff4,0xfff2,0x002f,0x0000,0xfffa,
+0xfff5,0xffe6,0x0010,0xffe5,0x000d,0xffd5,0x0016,0xffee,
+0x000a,0x000c,0x0002,0xffde,0x000f,0xffdf,0x000d,0xfff3,
+0x000a,0x0012,0x000a,0x000f,0xffeb,0xffd7,0xfffa,0x0038,
+0x0013,0xfff3,0xfff7,0xffdf,0xfff7,0xfffa,0x0014,0x0001,
+0xfff5,0x000d,0xffe8,0xfff3,0xffe9,0x0020,0x0006,0xffea,
+0xffe6,0xfff1,0x0000,0x0008,0x000c,0xffdb,0x0001,0xfffe,
+0x001c,0x001b,0xfffb,0xffdb,0xfff9,0xffdd,0x0008,0xffeb,
+0x0027,0x0004,0x0000,0xffdd,0xffe5,0xffcb,0xfffa,0x002c,
+0x0021,0x0012,0xfffb,0xfffe,0x000b,0xffe1,0xfff7,0xffea,
+0x0006,0x000f,0xffdc,0x000d,0x0019,0x002e,0x0017,0xffec,
+0xffdb,0xffe8,0x0017,0xffed,0x002b,0xffe3,0x0026,0xfff2,
+0x0000,0xffe6,0x000c,0xfff6,0x0026,0xfff0,0x0000,0x0000,
+0xffe3,0x0019,0x0016,0x0002,0xfffa,0xffbd,0xfff5,0x0031,
+0xffff,0xfff6,0xffe8,0x0005,0x0003,0xfff3,0x0004,0xfffb,
+0xfffa,0x000b,0xffe7,0x000c,0x0010,0x001f,0x001c,0xffdc,
+0xffcb,0xfff3,0x0006,0x0010,0x002a,0xffe8,0x0011,0x0001,
+0x0012,0xfff6,0x0004,0xfff3,0x000f,0xffee,0xfffb,0xfff9,
+0x001d,0xffe7,0xffea,0xfffe,0x0006,0x0043,0x000b,0xffcf,
+0x0001,0x000a,0x0018,0xfffb,0xfffd,0x000d,0xfffc,0x0005,
+0x0006,0xfff5,0x0019,0xfff4,0xfff0,0xffe1,0xffe4,0x0024,
+0x0035,0x000d,0xfffa,0xfff0,0xffd6,0x0018,0xffef,0xffff,
+0xffee,0x000a,0xfffc,0x000d,0xfff1,0x0012,0x0005,0x0007,
+0xffd9,0xfffc,0x0000,0x0023,0x001b,0x0035,0x0006,0xffd4,
+0xffdf,0xffee,0x0005,0x0002,0xfff5,0x001f,0x0009,0x0016,
+0xfffa,0xfff1,0x0024,0xfff3,0xffe7,0xffd2,0xffe9,0x0014,
+0x0025,0x0018,0xffe9,0x0013,0xffd5,0x001d,0xffda,0x000e,
+0x0000,0x001a,0xfff4,0x000a,0xffda,0x0010,0x0000,0x0000,
+0xfff6,0xffee,0xfff6,0xfff1,0x0015,0x0029,0x0006,0xffc8,
+0xffed,0x000d,0x0009,0x0021,0x0009,0x0006,0xffec,0xffff,
+0x000b,0xfff3,0x0018,0x000d,0x0017,0xffe0,0xfffa,0x0016,
+0x001a,0x000f,0x0000,0xfff8,0xfff4,0x0025,0xffff,0x0002,
+0xffe4,0xffe5,0x0005,0x0025,0x0007,0x0023,0xfff8,0x0015,
+0xffb1,0x0002,0x000c,0x0016,0x002a,0x001c,0x0001,0xffcd,
+0xffca,0xfff1,0xfff8,0x0029,0x0000,0x0018,0xfffa,0x000f,
+0xffff,0xffef,0x0024,0x000c,0x000e,0xffd1,0x0000,0x0006,
+0x000b,0x001a,0xfff0,0x001b,0xfff3,0x002b,0xffea,0x0012,
+0xfff6,0xfff4,0xfffe,0x0022,0xfff1,0x0021,0xfff3,0x000d,
+0xfff1,0xfff3,0xfff3,0xffff,0x001a,0x000e,0x0009,0xffd7,
+0xffff,0x0010,0x002e,0xffe5,0xffee,0xffff,0xfffc,0x0010,
+0x000b,0xffd5,0x0008,0xffd3,0x0000,0xfff5,0xffeb,0x001d,
+0x001e,0x0008,0xffed,0xffd6,0xffd7,0x001c,0x0000,0x0014,
+0xffec,0xfff5,0xffe2,0xfff6,0x0004,0x0005,0x0020,0x001c,
+0xffac,0x0006,0x0009,0x0024,0x002f,0x0001,0x0004,0xffdc,
+0xffdc,0xfff4,0x001b,0xffec,0xffe6,0x0011,0x0009,0x0021,
+0xffff,0xffd1,0x0013,0xffd2,0xfff7,0xffe5,0xfff1,0x000d,
+0x000f,0x0012,0xffdd,0xfffa,0xffd6,0x0021,0xffec,0x0024,
+0xffff,0x0004,0xffda,0xfff2,0xffee,0x0002,0x001b,0x0014,
+0xffc9,0xfffa,0xffff,0xfff2,0x0029,0xfff6,0x0004,0xffd0,
+0xffea,0x0014,0x001f,0x000a,0xfffb,0xfff9,0xffec,0x0009,
+0x0010,0xffd3,0x0008,0xffed,0x0028,0xfff4,0x0001,0x000f,
+0x0004,0x000a,0xfff4,0xffde,0xfff5,0x0029,0x0010,0x0018,
+0xffe2,0xffcf,0xffec,0x000d,0x001c,0x0016,0x0012,0x002b,
+0xff84,0x000d,0x0015,0x0017,0x003e,0xffe9,0x0000,0xffd5,
+0xffc7,0xfff8,0x000d,0x0012,0xfff2,0x000a,0xfffa,0x001a,
+0x0003,0xffcf,0x0013,0xffed,0x001f,0xffe5,0x0007,0x0000,
+0xfff5,0x0014,0xffe3,0x0001,0xfff4,0x002f,0xfffc,0x0027,
+0xfff5,0xffde,0xffe4,0x0009,0x0005,0x0013,0x000d,0x0022,
+0x0022,0xfff2,0xfffc,0x0011,0xfffb,0x0018,0x001a,0xffec,
+0x001b,0x002d,0x000c,0xffe8,0x0002,0xfff3,0x0015,0x0008,
+0x0016,0x0010,0x0020,0x0002,0xffde,0xffe1,0xffec,0x0007,
+0x003a,0xfffb,0x0005,0xfffe,0xffda,0x000c,0xfffe,0x0001,
+0xffff,0x001a,0xfffb,0x0017,0x0015,0x0006,0xfff8,0xfff5,
+0xffde,0x0006,0x0012,0x0037,0x000f,0x000b,0x0015,0xfff0,
+0xfff8,0x0010,0xfffa,0xfff0,0xfffb,0x0004,0x0023,0x0018,
+0x000a,0x000c,0x002b,0x0001,0xffd5,0xffd1,0xfff2,0xfff8,
+0x002b,0x0005,0xfff6,0x0022,0xffd9,0x0012,0xffea,0x0010,
+0x0011,0x002a,0xfff3,0x0013,0xffff,0x0003,0xfff2,0xffec,
+0xfffb,0xfff9,0x0007,0x0004,0x0009,0x0000,0x0015,0xffe4,
+0x0006,0x0030,0xfffe,0x000e,0x000f,0xffec,0x0005,0x0000,
+0x001b,0x000e,0x0020,0x001c,0x0005,0xffe0,0x0002,0xfffa,
+0x0020,0xfffd,0x000c,0x0005,0xfff8,0x0019,0x000e,0x0004,
+0xfff4,0xfff5,0x0004,0x002f,0x002d,0x0016,0xffea,0x0002,
+0xffb6,0x000c,0x001e,0x002a,0x001e,0xfff2,0x0010,0xffe9,
+0xffe3,0x0013,0xffec,0x0015,0x0007,0xffff,0x0013,0x0011,
+0x000e,0x000a,0x002b,0x001b,0xfffd,0xffd0,0x0008,0xffea,
+0x0010,0x0007,0xfffc,0x002a,0xfff7,0x001f,0xfffa,0x0014,
+0x0006,0x0004,0xfffd,0x002b,0x0016,0x0014,0xffe4,0xfffb,
+0xfff6,0xfffd,0x0004,0x0012,0x000f,0xffe5,0x0018,0xfff3,
+0x0018,0x0033,0x0022,0xffd1,0xfff4,0xffe4,0x0015,0x0013,
+0x001b,0xfff0,0x000f,0xffe2,0xffef,0xfff4,0xfff4,0x0000,
+0x0024,0xfff6,0xfff9,0xffe5,0xffdb,0x0010,0x000f,0x0016,
+0xfffd,0x0004,0xffe1,0xffff,0x002a,0xfff9,0x0012,0x0009,
+0xffb1,0x0011,0x001b,0x0038,0x0024,0xffd7,0x0013,0xfff8,
+0xfff6,0x0016,0x000f,0xffd9,0xffec,0xfff7,0x0023,0x0023,
+0x000f,0xffec,0x001a,0xffe1,0xffe6,0xffe5,0xfffa,0xfff1,
+0x0014,0x0000,0xffe9,0x0008,0xffda,0x0016,0xfffb,0x0026,
+0x000f,0x0014,0xffd9,0xfffc,0x0012,0xfff7,0x000d,0x0001,
+0xffce,0x0003,0x0010,0x0005,0x001e,0xffcb,0x0013,0xffec,
+0x0003,0x0037,0x0013,0xfff8,0x0000,0xffde,0x0005,0x000b,
+0x0020,0xffee,0x000f,0xfffc,0x0016,0xfff3,0x000a,0xfff3,
+0x0009,0xfff8,0x0000,0xffed,0xfff9,0x001d,0x001f,0x001a,
+0xfff3,0xffdf,0xffeb,0x0016,0x0041,0x0009,0x0004,0x0017,
+0xff89,0x0018,0x0027,0x002c,0x0033,0xffbe,0x000e,0xfff1,
+0xffe1,0x001a,0x0001,0x0000,0xfff9,0xfff0,0x0013,0x001c,
+0x0013,0xffea,0x001a,0xfffc,0x000d,0xffe4,0x0010,0xffe3,
+0xfffb,0x0001,0xfff0,0x0010,0xfff8,0x0023,0x000a,0x002a,
+0x0004,0xffef,0xffe3,0x0013,0x002a,0x0007,0x0000,0x000f,
+0x001f,0xffe4,0x0006,0xfff0,0xfff0,0x0032,0xffe1,0xfff2,
+0x0000,0x0006,0x0024,0x0011,0x0000,0x0000,0xffe3,0xfff2,
+0x000b,0x0012,0x0014,0xffe7,0xfffa,0xffdf,0xffed,0x0014,
+0x002b,0x0015,0x0015,0xfff2,0xffc9,0x0000,0xffe0,0xffd8,
+0xffd6,0x0027,0x0001,0xfff8,0xfff2,0x0008,0xfffa,0xfffd,
+0xffdb,0xfff8,0x001d,0x0016,0x0004,0x0025,0xffdc,0xfff7,
+0xffde,0xffea,0x0011,0x0018,0xfff8,0x0012,0xfff1,0x0002,
+0xffff,0x000e,0x001f,0xffe7,0xfff1,0xffd0,0xfff3,0x0004,
+0x001c,0x001f,0x0005,0x0015,0xffc7,0x0004,0xffcb,0xffe8,
+0xffe9,0x0037,0xfffa,0xfff4,0xffdb,0x0006,0xfff5,0xfff5,
+0xfff9,0xffea,0x0012,0xffe3,0xffff,0x0019,0xffdc,0xffeb,
+0xffec,0x0009,0x0016,0x0038,0x000b,0xfffa,0xffd3,0xffeb,
+0x000f,0x0010,0x0014,0x0001,0x0021,0xffde,0x0002,0x0006,
+0x0011,0x0017,0x001c,0xfffa,0xffe7,0x000c,0xfff0,0xffdb,
+0xffcb,0x0001,0x000b,0x000f,0x0008,0x0019,0xffec,0x000b,
+0xffb4,0xffff,0x0029,0x0009,0x0013,0x000c,0xffd7,0xffef,
+0xffc9,0xffee,0x0003,0x003f,0x0003,0x000c,0xffe2,0xfffb,
+0x0003,0x000c,0x001f,0x0000,0x0018,0xffcf,0x0008,0xfff7,
+0x0001,0x0021,0x000c,0x001d,0xffe5,0x0012,0xffdb,0xffeb,
+0xffde,0x0011,0x0003,0x000b,0xfff2,0x0017,0xffe7,0x0002,
+0xfff3,0xffef,0x000f,0xfff1,0x0003,0xffff,0xffdf,0xfff9,
+0xffff,0x000c,0x003a,0xfffb,0xfff1,0xfff3,0xffe3,0xfffd,
+0x0010,0xfff3,0x0004,0xffc7,0x000a,0xfff3,0xfff5,0x000d,
+0x0015,0x000f,0x0009,0xffd8,0xffc9,0x0003,0xfff2,0xffed,
+0xffd4,0x0011,0xffe8,0xffe0,0x0005,0xfffc,0x0015,0x0012,
+0xffae,0x0003,0x0026,0x0017,0x0018,0xfff1,0xffda,0xfffe,
+0xffdb,0xfff1,0x0027,0x0002,0xffe9,0x0004,0xfff1,0x000c,
+0x0003,0xffef,0x000f,0xffc6,0x0001,0xffe3,0xfffa,0xfffe,
+0x0005,0x001a,0xfff9,0xfffc,0xffc8,0x0009,0xffdd,0xfffd,
+0xffe7,0x0021,0xffe0,0xffdc,0xffef,0xfff9,0x000f,0x0009,
+0xffcc,0xfff6,0x001b,0xffe5,0x0012,0xffe6,0xffda,0xfff2,
+0xffe9,0x0010,0x002c,0x0021,0xfffd,0xffec,0xffd3,0xfff6,
+0x0014,0xfff1,0x0003,0xffe1,0x0032,0xfff2,0x000a,0x0000,
+0xfffb,0x0011,0x000f,0xffe0,0xffe8,0x0010,0x0001,0xfff1,
+0xffc9,0xffec,0xfff2,0xfff8,0x001d,0x000c,0x0007,0x0020,
+0xff87,0x0009,0x0032,0x000a,0x0028,0xffd8,0xffd5,0xfff7,
+0xffc6,0xfff4,0x0019,0x0029,0xfff5,0xfffe,0xffe1,0x0005,
+0x0008,0xffed,0x000f,0xffe0,0x0029,0xffe2,0x0010,0xfff0,
+0xffec,0x001c,0x0000,0x0003,0xffe6,0x0016,0xffed,0x0000,
+0xffdc,0xfffc,0xffea,0xfff4,0x0006,0x0009,0x0001,0x0018,
+0x0024,0xffee,0x0018,0x0003,0xffe4,0x0007,0xfff0,0x000d,
+0x001a,0x0029,0x0018,0xffff,0x0005,0xffe6,0xfffd,0xfff4,
+0x001b,0x002e,0x001b,0xfff6,0xffe8,0xffde,0xfff6,0xfff8,
+0x0031,0x0002,0x0022,0x0000,0xffcd,0xfff4,0xffef,0xffda,
+0xffe7,0x0038,0x0000,0x0000,0x0016,0xfffd,0xffec,0xffea,
+0xffe0,0x0002,0x002f,0x002a,0xfff9,0xfffb,0xffeb,0x0012,
+0xfff7,0x000c,0x0005,0x0005,0xfffe,0xfff8,0x000a,0x0004,
+0x000e,0x002a,0x0026,0xfff6,0xffdf,0xffcf,0xfffb,0xffe8,
+0x0021,0x000c,0x0011,0x0023,0xffcc,0xfffa,0xffda,0xffea,
+0xfff9,0x0048,0xfff9,0xfffd,0x0000,0xfffa,0xffe7,0xffe2,
+0xfffe,0xfff5,0x0024,0xfff7,0xfff3,0xffef,0xffeb,0x0006,
+0x0005,0x002d,0x000a,0x0024,0x0012,0xffdf,0xffed,0xffed,
+0x001f,0x002c,0x001b,0x000f,0x0010,0xffde,0x000b,0xffea,
+0x0016,0x0004,0x0028,0x0007,0xffeb,0x0000,0xffff,0xffdd,
+0xffdc,0x0012,0x000a,0x0018,0x002e,0x000c,0xffde,0xfff8,
+0xffb9,0x0009,0x003b,0x001d,0x0008,0xffe2,0xffe6,0x000b,
+0xffe2,0x0010,0xfff8,0x002c,0x0009,0xfff2,0xfffb,0xfffe,
+0x0013,0x0028,0x0026,0x000f,0x0007,0xffce,0x0011,0xffda,
+0x0007,0x000e,0x0018,0x002b,0xffea,0x0006,0xffea,0xffed,
+0xffef,0x0022,0x0002,0x0014,0x0017,0x000a,0xffd9,0xfff0,
+0xfff8,0xfffa,0x0021,0x0004,0xfff9,0xffd4,0xffee,0x0015,
+0x0017,0x0030,0x002e,0xffe8,0xfff7,0xffd8,0xfffd,0xffff,
+0x0020,0x000d,0x000b,0xffd5,0xfff9,0xfff2,0xfffd,0xfff1,
+0x001a,0xfffd,0x0015,0xffe6,0xffce,0xfff8,0x0000,0xfff0,
+0xffe5,0x0022,0xffe7,0xffe9,0x002b,0xffef,0x0006,0xffff,
+0xffb3,0x000d,0x0038,0x002b,0x000d,0xffc7,0xffe9,0x001a,
+0xfff5,0x0013,0x001b,0xfff0,0xffef,0xffea,0x000a,0x000f,
+0x0013,0x000a,0x0016,0xffd5,0xfff0,0xffe2,0x0002,0xffe1,
+0x000b,0x0006,0x0005,0x0009,0xffcc,0xfffe,0xffec,0x0000,
+0xfff8,0x0032,0xffdf,0xffe5,0x0013,0xffed,0x0001,0xfff7,
+0xffd1,0x0000,0x002d,0xfff9,0x0007,0xffbb,0xffe9,0x000d,
+0x0002,0x0033,0x0020,0x000e,0x0003,0xffd1,0xffed,0xfff8,
+0x0025,0x000b,0x000a,0xfff0,0x0020,0xfff1,0x0013,0xffe3,
+0x0000,0xffff,0x001c,0xffee,0xffec,0x0004,0x0010,0xfff3,
+0xffda,0xfffd,0xfff1,0x0000,0x0042,0x0000,0xfff9,0x000d,
+0xff8c,0x0014,0x0044,0x001e,0x001c,0xffad,0xffe4,0x0012,
+0xffe0,0x0016,0x000d,0x0015,0xfffb,0xffe4,0xfffb,0x0007,
+0x0018,0x0008,0x0016,0xffef,0x0017,0xffe2,0x0019,0xffd3,
+0xfff1,0x0009,0x000b,0x0012,0xffea,0x000a,0xfffc,0x0002,
+0xffed,0x000c,0xffe9,0xfffd,0x002b,0xfffe,0xfff4,0x0004,
+0x0048,0xfff3,0xffe3,0xffee,0x0004,0x005a,0x0025,0xffde,
+0x0004,0xffff,0x000d,0xfff7,0xfffa,0x000b,0x0002,0x0018,
+0xfff3,0x0003,0xfff9,0xfff5,0xfffc,0x0004,0xffd6,0x0019,
+0x001f,0xffff,0xfff8,0xffe3,0xfffa,0x0011,0xffed,0x0002,
+0xfff6,0xfffa,0x0026,0x0016,0xffd6,0xffed,0xfffa,0xfff5,
+0x0003,0x0007,0xfffa,0x0014,0x0019,0x004d,0x0020,0xffe3,
+0xffe1,0xffe2,0xfffc,0xfffe,0xfff2,0x001d,0x0010,0x0028,
+0xffe6,0x0000,0x0003,0xfff4,0xfff3,0xfff6,0xffdc,0x0009,
+0x000f,0x0008,0xffe8,0x0006,0xfff9,0x0016,0xffd8,0x0011,
+0x0008,0x0009,0x001f,0x0012,0xffbe,0xffea,0xfff5,0xffed,
+0x0020,0xfffa,0xffef,0xffe1,0x0013,0x0041,0x0021,0xffd7,
+0xfff0,0x0001,0x0000,0x001d,0x0006,0x0004,0xfff3,0x0011,
+0xfff7,0x0001,0xfff8,0x000e,0x0023,0x0003,0xffed,0x000b,
+0x0004,0x0000,0xffff,0xffeb,0x0017,0x001e,0xfffd,0x0005,
+0xffec,0xffd4,0x0030,0x002e,0xffed,0xfffd,0xffec,0x0003,
+0xffdc,0x000d,0x0005,0x0007,0x0028,0x0033,0x001c,0xffdc,
+0xffcc,0xffe5,0xffee,0x0024,0xfffe,0x0016,0x0000,0x0021,
+0xffeb,0xfffe,0x0003,0x000d,0x001a,0xfff5,0xfff2,0xfffc,
+0xfff6,0x000a,0xffee,0x000e,0x0016,0x0024,0xffe8,0x0015,
+0xffff,0xffe4,0x0028,0x002a,0xffd6,0xfffb,0xffe7,0xfffb,
+0x001b,0xffff,0xffec,0xffef,0x0018,0x0026,0x0023,0xffe6,
+0x0001,0x0004,0x0023,0xffe0,0xffeb,0xfffd,0x0002,0x0023,
+0xfff8,0xffe3,0xffe8,0xffd4,0x000c,0x0018,0xffde,0x0012,
+0x0008,0xfff9,0xffeb,0xffc9,0xfffb,0x0015,0xfffe,0x0017,
+0xfff5,0xffe4,0x000d,0xffff,0xffea,0xffdf,0x0015,0x000a,
+0xffd7,0x0012,0x0002,0x0015,0x002d,0x0018,0x001e,0xffeb,
+0xffdf,0xffe8,0x0011,0xffe8,0xffe3,0x000f,0x0010,0x0033,
+0xffeb,0xffdf,0xfff3,0xffd3,0x0003,0x0008,0xffe4,0x0002,
+0xfff9,0x0002,0xffdb,0xffed,0xfff9,0x001b,0xffea,0x0027,
+0x0007,0xfff4,0x0005,0xfffb,0xffd3,0xffdd,0x000f,0x0001,
+0xfff4,0x0004,0xfff8,0xffe3,0x0027,0x000c,0x001e,0xffdf,
+0xffed,0x0008,0x0015,0x0006,0xfff8,0xfff7,0xfff3,0x001c,
+0xfffc,0xffe1,0xffe8,0xffee,0x0034,0x0017,0xfff4,0x0004,
+0xffee,0xfffb,0xfff2,0xffd1,0x0018,0x0022,0x000e,0x001b,
+0xffea,0xffbe,0x0016,0x0016,0x0001,0xfff0,0x0006,0x0018,
+0xffaf,0x0019,0x000e,0x0008,0x003d,0x0000,0x0019,0xffe4,
+0xffca,0xffec,0x0003,0x000e,0xffef,0x0008,0x0000,0x002c,
+0xfff0,0xffdd,0xfff3,0xffee,0x002b,0x0007,0xfffa,0xfff5,
+0xffdf,0x0004,0xffe2,0xfff5,0x0016,0x0028,0xfffa,0x002b,
+0xfffd,0xffce,0x000e,0x0012,0xffea,0xffee,0x0001,0x0010,
+0x004d,0xfffe,0xfff5,0x0001,0xfff9,0x002f,0x0034,0xfffb,
+0x001d,0x0021,0x0001,0xffe4,0x0000,0xfff1,0x001c,0x001a,
+0x0002,0x001e,0x0000,0x0002,0xffea,0x0004,0xffdf,0xfffd,
+0x0024,0xffeb,0x0003,0xfff1,0xfffe,0x0005,0xfffc,0x0004,
+0x0006,0x0009,0x0025,0x001f,0xfffb,0xffe0,0xffec,0xffe2,
+0x0008,0x0011,0x000a,0x0028,0x000d,0x0022,0x002f,0x0000,
+0xfffb,0x0004,0xfff0,0xffeb,0xfff8,0x0002,0x002a,0x002b,
+0xfff6,0x001a,0x000a,0x0002,0xffe1,0xfff5,0xffe5,0xffed,
+0x0015,0xfff6,0xfff4,0x0014,0xfffd,0x000b,0xffe7,0x0014,
+0x0019,0x0019,0x001d,0x001c,0xffe4,0xffde,0xffe7,0xffda,
+0x0025,0x0003,0x0000,0xfff6,0x0007,0x0016,0x0030,0xfff4,
+0x0008,0x0024,0xfff4,0x0009,0x000c,0xffea,0x000c,0x0013,
+0x0006,0x001c,0x0000,0x001d,0x0012,0x0003,0xfff5,0xffef,
+0x000a,0xffee,0x000a,0xfff9,0x001b,0x0012,0x000b,0x0007,
+0xfffd,0xffe4,0x002f,0x0037,0x0012,0xfff1,0xffde,0xfff0,
+0xffe1,0x0018,0x0017,0x001b,0x001d,0x0009,0x002b,0xfff8,
+0xffe6,0x0007,0xffe2,0x0011,0x0004,0xfffd,0x001a,0x0023,
+0xfffb,0x0018,0x000a,0x001c,0x0009,0xfff4,0xfffb,0xffdf,
+0xfffb,0xfff8,0xfffb,0x001d,0x001a,0x0018,0xfff7,0x0017,
+0x000e,0xfff4,0x0027,0x0034,0xfffb,0xffee,0xffd9,0xffe8,
+0x0020,0x0008,0xfffd,0x0002,0x000d,0xfffc,0x0032,0x0001,
+0x001b,0x0027,0x0017,0xffcd,0xfff1,0xffe2,0x001b,0x0025,
+0x0007,0xffff,0xffef,0xffe3,0xfffb,0x0017,0xffe7,0xfff6,
+0x000e,0xffe6,0xfff8,0xffd7,0xffff,0x0009,0x000d,0x001a,
+0x0005,0xfff4,0x000c,0x0007,0x000e,0xffd3,0x0006,0xfff7,
+0xffdc,0x001d,0x0013,0x0029,0x0022,0xffee,0x002d,0x0006,
+0xfff8,0x000a,0x0005,0xffd5,0xffe9,0xfff5,0x002a,0x0035,
+0xfffb,0xfffb,0xfffa,0xffe2,0xfff2,0x0008,0xffec,0xffe6,
+0xffff,0xfff0,0xffe7,0xfffc,0xfffd,0x000f,0xfff9,0x0029,
+0x0017,0x0003,0x0004,0x0003,0xfff8,0xffd0,0x0001,0xffef,
+0xfff9,0x000f,0x0009,0xfff7,0x001c,0xffe3,0x002d,0xfffb,
+0x0006,0x002b,0x0009,0xfff4,0xfffe,0xffdc,0x000c,0x001e,
+0x000b,0xfffd,0xffef,0xfffd,0x0022,0x0016,0xfffd,0xffe8,
+0xfff4,0xffe8,0xfffe,0xffe0,0x001c,0x0016,0x001d,0x001d,
+0xfffb,0xffce,0x0015,0x001f,0x0026,0xffe3,0xfff9,0x0005,
+0xffb4,0x0023,0x001f,0x001c,0x0031,0xffd5,0x0028,0x0000,
+0xffe3,0x000e,0xfff8,0xfffb,0xfff6,0xffee,0x001a,0x002e,
+0x0000,0xfff9,0xfffa,0xfffd,0x0019,0x0007,0x0002,0xffd8,
+0xffe4,0xfff2,0xffee,0x0003,0x001b,0x001c,0x0008,0x002d,
+0x000d,0xffde,0x000d,0x001b,0x000f,0xffe1,0xfff4,0xfffd,
+0x004a,0xffef,0x0000,0xffe1,0xffee,0x0049,0xfffb,0x0000,
+0x0003,0xfffb,0x0019,0x000c,0xfffd,0xffff,0xffea,0x0003,
+0xfff7,0x0021,0xfff4,0xffe8,0x0006,0x0002,0xffdf,0x0009,
+0x0015,0x0005,0x0014,0xffe5,0xffed,0xfff9,0xffde,0xffdb,
+0xffde,0x0016,0x002c,0x0000,0xffd7,0xffe3,0xffef,0xffeb,
+0x0005,0x0003,0x0015,0x0007,0x0002,0x003c,0xfff6,0x0005,
+0xffe0,0xffde,0x0007,0x0014,0xfff5,0x0010,0xfff8,0x0014,
+0xffeb,0x001d,0xffff,0xffe8,0xfffe,0xfff3,0xffe5,0xfffa,
+0x0005,0x000f,0x0003,0x0008,0xffeb,0xffff,0xffc9,0xffeb,
+0xfff1,0x0026,0x0025,0xfffd,0xffbf,0xffe0,0xffe9,0xffe2,
+0x0023,0xfff6,0x000b,0xffd4,0xfffd,0x0030,0xfff6,0xfffa,
+0xffef,0xfffe,0x000b,0x0033,0x0008,0xfff8,0xffda,0xfffd,
+0xfffc,0x001f,0xfff4,0x0002,0x002e,0x0001,0xfff6,0xfffc,
+0xfffb,0x0007,0x001a,0xffed,0x000a,0x0005,0xffee,0xffde,
+0xffd3,0xfff1,0x0036,0x0018,0xffee,0xfff3,0xffe1,0xfff9,
+0xffdf,0x000a,0x0022,0xfffb,0x0011,0x0023,0xfff1,0xffff,
+0xffcb,0xffe2,0xfffa,0x003b,0x0000,0x000a,0xffe8,0x000d,
+0xffef,0x001b,0xffff,0x0001,0x0025,0xfff3,0xfffc,0xffec,
+0xffec,0x0012,0x000a,0x0010,0x0008,0x000b,0xffd9,0xffee,
+0xffe6,0x0000,0x002e,0x0014,0xffd7,0xfff1,0xffdb,0xfff1,
+0x001d,0xfffb,0x0007,0xffe2,0x0001,0x0015,0xfff9,0x0007,
+0x0000,0x0000,0x002f,0xfff7,0xffee,0xfff1,0xffea,0x000e,
+0xfffc,0x0000,0xffe4,0xffc7,0x0017,0x0015,0xffe7,0x0002,
+0xffff,0x0000,0x0007,0xffcb,0xffed,0xfffd,0xffef,0xfff1,
+0xffdc,0x0000,0x0013,0xffe8,0xffeb,0xffd5,0x0009,0x0000,
+0xffd9,0x000e,0x001e,0x0008,0x0016,0x0008,0xfff4,0x000c,
+0xffde,0xffe5,0x001d,0xfffe,0xffe6,0x0002,0xfff8,0x001f,
+0xfff0,0xfffd,0xffef,0xffc7,0x000e,0x0006,0xffed,0xfff3,
+0xfff0,0x000a,0xfff8,0xffef,0xffec,0x0002,0xffda,0x0000,
+0xffef,0x0010,0x000b,0xffe5,0xffd4,0xffd3,0x0004,0xfff8,
+0xfff7,0x0001,0x0014,0xffd5,0x0011,0xfffd,0xfff4,0x0000,
+0xffec,0x0004,0x0021,0x001d,0xfffa,0xffea,0xffda,0x0007,
+0x0000,0xffff,0xffe3,0xffe2,0x003f,0x0015,0xfffd,0xfff5,
+0xffe5,0x0001,0x000e,0xffd3,0x000a,0x0009,0xffff,0xfff4,
+0xffd1,0xffdb,0x001c,0x0000,0x0002,0xffe6,0xfffc,0x000d,
+0xffb2,0x0015,0x002b,0xfffc,0x0026,0xffef,0xffef,0x0005,
+0xffc9,0xffe8,0x000f,0x0024,0xfff2,0xfffc,0xffe8,0x0018,
+0xfff4,0xfffb,0xffef,0xffe1,0x0036,0x0005,0x0002,0xffe5,
+0xffd5,0x000c,0xfffe,0xfff7,0x0009,0x000f,0xffea,0x0003,
+0xffe4,0xffeb,0x0014,0xfffd,0xffec,0xffe4,0xfff7,0x0005,
+0x0050,0xfffa,0x0010,0xfff5,0xffe2,0x001e,0x0009,0x001c,
+0x001c,0x001d,0x000d,0xfffa,0x0002,0xffe4,0x0003,0x0005,
+0x0007,0x003c,0xfffb,0xfff7,0xfff5,0x0001,0xffe8,0xffed,
+0x001b,0xfff3,0x0020,0xfff3,0xfff1,0xffed,0xffed,0xffdd,
+0xffef,0x0027,0x002b,0x0009,0xfffc,0xffd6,0xffe0,0xffd7,
+0x000b,0x000e,0x0027,0x001b,0xfff7,0x0011,0x0004,0x0021,
+0xfffa,0x0000,0xfffc,0x0001,0xfffb,0xfff6,0x0011,0x0016,
+0xfffb,0x0039,0x0005,0xfff7,0xffec,0xfff3,0xffee,0xffdd,
+0x000b,0xfffd,0x0010,0x0016,0xffef,0xfff3,0xffd8,0xffed,
+0x0001,0x0037,0x0023,0x0005,0xffe5,0xffd4,0xffdb,0xffcf,
+0x0028,0x0000,0x001c,0xffe8,0xfff2,0x0005,0x0004,0x0015,
+0x0007,0x0021,0x0000,0x0020,0x000f,0xffdd,0xfff4,0xffff,
+0x000b,0x003a,0xfffb,0x0010,0x001c,0x0000,0xffff,0xffdf,
+0x0000,0xfff5,0x0027,0xfffb,0x000e,0xfffa,0xfffd,0xffe1,
+0xffe4,0x0001,0x0035,0x0021,0x0013,0xffe7,0xffd2,0xffe6,
+0xffe4,0x0014,0x0033,0x000e,0x0006,0xfff9,0x0000,0x001a,
+0xffe5,0x0004,0xffee,0x0028,0x0006,0xfff0,0x0001,0x000f,
+0x0000,0x0037,0x0005,0x0010,0x0013,0xfff2,0x0003,0xffcf,
+0xfff2,0xffff,0x0016,0x001e,0x000c,0x0000,0xffe8,0xfff1,
+0xfff7,0x0011,0x002d,0x001d,0xfffc,0xffe4,0xffcd,0xffdd,
+0x0022,0x0004,0x0019,0xfff6,0xfff7,0xffeb,0x0007,0x0024,
+0x001a,0x0024,0x0023,0xffe4,0xfff4,0xffd6,0x0003,0x0010,
+0x000c,0x001c,0xffeb,0xffd6,0x0005,0x0015,0xfff0,0xffe6,
+0x0004,0xffed,0x0013,0xffd9,0xfff1,0xfff1,0xffff,0xfff3,
+0xffed,0x0011,0x0011,0xfff2,0x000f,0xffc9,0xfffc,0xffed,
+0xffde,0x0019,0x0030,0x001c,0x000b,0xffde,0x0002,0x0029,
+0xfff7,0x0007,0x0011,0xffeb,0xffec,0xffe8,0x0011,0x0021,
+0x0000,0x0018,0xfff6,0xffd6,0xfffd,0x0005,0xfff6,0xffd6,
+0xfff5,0xfff8,0x0003,0xfffd,0xfff0,0xfff7,0xffea,0x0002,
+0x0000,0x0021,0x000a,0xffee,0xfff9,0xffc6,0xfff6,0xffe4,
+0xfffc,0x000b,0x0025,0xffe9,0x0005,0xffd2,0x0002,0x001d,
+0x0005,0x0027,0x0015,0x0009,0x0000,0xffcf,0xfff4,0x0009,
+0x0010,0x001a,0xffea,0xfff1,0x002d,0x0014,0x0005,0xffd8,
+0xffea,0xffef,0x001a,0xffe1,0x000e,0xfffe,0x000e,0xfff6,
+0xffe2,0xffec,0x001b,0x0009,0x0027,0xffd9,0xffee,0xfffb,
+0xffb7,0x0020,0x003c,0x000f,0x001a,0xffc5,0xfffe,0x0021,
+0xffe2,0x000a,0x0003,0x0011,0xfff8,0xffe2,0x0001,0x001a,
+0x0004,0x0016,0xfff6,0xfff0,0x0024,0x0005,0x000b,0xffc8,
+0xffdb,0xfffa,0x000a,0x0005,0x000d,0x0003,0xfffa,0x0005,
+0xfff5,0xfffc,0x0013,0x0005,0x0010,0xffd7,0xffe8,0xfff3};
+
+const unsigned long ftable1[128]={
+0x4cc9f,0x482af,0x47bd8,0x44700,0x5238b,0x47377,0x4898a,0x411fd,
+0x4f8b7,0x4a7d5,0x4bd1b,0x47feb,0x5554b,0x49414,0x4c9d4,0x4403c,
+0x4fa57,0x550c5,0x4ea1c,0x54c6e,0x51f27,0x4ff8f,0x4cab5,0x4bbb6,
+0x53e58,0x5a5e8,0x5551f,0x5d6ff,0x56499,0x540f7,0x528e8,0x51740,
+0x4cdba,0x459db,0x4a644,0x4445b,0x4e123,0x423bc,0x480ed,0x3ed60,
+0x5292b,0x49d33,0x51d8c,0x49f1d,0x53cc4,0x45a9d,0x4e88c,0x43073,
+0x4d3a1,0x4e583,0x4f702,0x5182e,0x4b81f,0x47291,0x49dc4,0x46541,
+0x5434b,0x55bc1,0x5a27e,0x5d510,0x51ba0,0x4c587,0x51f83,0x4d45f,
+0x4d45f,0x51f83,0x4c587,0x51ba0,0x5d510,0x5a27e,0x55bc1,0x5434b,
+0x46541,0x49dc4,0x47291,0x4b81f,0x5182e,0x4f702,0x4e583,0x4d3a1,
+0x43073,0x4e88c,0x45a9d,0x53cc4,0x49f1d,0x51d8c,0x49d33,0x5292b,
+0x3ed60,0x480ed,0x423bc,0x4e123,0x4445b,0x4a644,0x459db,0x4cdba,
+0x51740,0x528e8,0x540f7,0x56499,0x5d6ff,0x5551f,0x5a5e8,0x53e58,
+0x4bbb6,0x4cab5,0x4ff8f,0x51f27,0x54c6e,0x4ea1c,0x550c5,0x4fa57,
+0x4403c,0x4c9d4,0x49414,0x5554b,0x47feb,0x4bd1b,0x4a7d5,0x4f8b7,
+0x411fd,0x4898a,0x47377,0x5238b,0x44700,0x47bd8,0x482af,0x4cc9f};
+
+const unsigned long ftable2[128]={
+0x2f8e9,0x3444d,0x3637b,0x3608d,0x3372e,0x33ab9,0x33946,0x2f157,
+0x307a1,0x36a4d,0x380c9,0x39279,0x332c0,0x34673,0x33a8a,0x2fec4,
+0x2ecea,0x36011,0x34bb0,0x37829,0x36353,0x39c4a,0x35f32,0x33352,
+0x2cb99,0x33db5,0x3221f,0x3595c,0x31b84,0x35804,0x31d79,0x3075f,
+0x27f6f,0x2f99d,0x2d6c9,0x3369b,0x2df25,0x34928,0x3018c,0x32129,
+0x28cb2,0x31e5c,0x2eebd,0x36c4e,0x2e2a3,0x3601f,0x30a58,0x33aa8,
+0x28cee,0x336a2,0x2e69d,0x37dcd,0x323b6,0x3fa08,0x34b2d,0x3acd3,
+0x27abc,0x3214b,0x2cff6,0x3695f,0x2f09d,0x3ae92,0x315ba,0x37761,
+0x37761,0x315ba,0x3ae92,0x2f09d,0x3695f,0x2cff6,0x3214b,0x27abc,
+0x3acd3,0x34b2d,0x3fa08,0x323b6,0x37dcd,0x2e69d,0x336a2,0x28cee,
+0x33aa8,0x30a58,0x3601f,0x2e2a3,0x36c4e,0x2eebd,0x31e5c,0x28cb2,
+0x32129,0x3018c,0x34928,0x2df25,0x3369b,0x2d6c9,0x2f99d,0x27f6f,
+0x3075f,0x31d79,0x35804,0x31b84,0x3595c,0x3221f,0x33db5,0x2cb99,
+0x33352,0x35f32,0x39c4a,0x36353,0x37829,0x34bb0,0x36011,0x2ecea,
+0x2fec4,0x33a8a,0x34673,0x332c0,0x39279,0x380c9,0x36a4d,0x307a1,
+0x2f157,0x33946,0x33ab9,0x3372e,0x3608d,0x3637b,0x3444d,0x2f8e9};
+
+static const short decodetable1[63]={
+0x0000,0x0006,0x0010,0x0012,0x0014,0x0017,0x0019,0x001d,
+0x0020,0x0024,0x0029,0x002e,0x0033,0x0039,0x0041,0x0049,
+0x0051,0x005b,0x0067,0x0073,0x0081,0x0091,0x00a3,0x00b7,
+0x00cd,0x00e6,0x0103,0x0122,0x0146,0x016d,0x019a,0x01cc,
+0x0204,0x0243,0x028a,0x02da,0x0333,0x0397,0x0407,0x0485,
+0x0512,0x05b0,0x0662,0x0729,0x0809,0x0904,0x0a1e,0x0b5a,
+0x0cbd,0x0e4b,0x1009,0x11fe,0x1430,0x16a7,0x196b,0x1c85,
+0x2000,0x23e7,0x2849,0x2d33,0x32b7,0x38e7,0x3fd9};
+
+static const short decodetable2[127]={
+0xf037,0xf043,0xf04e,0xf058,0xf062,0xf06c,0xf077,0xf082,
+0xf08e,0xf09a,0xf0a6,0xf0b2,0xf0be,0xf0cc,0xf0d9,0xf0e6,
+0xf0f4,0xf101,0xf10f,0xf11e,0xf12d,0xf13d,0xf14c,0xf15c,
+0xf16d,0xf17d,0xf18d,0xf19d,0xf1ae,0xf1bf,0xf1d1,0xf1e3,
+0xf1f6,0xf20a,0xf21d,0xf232,0xf247,0xf25d,0xf274,0xf28c,
+0xf2a4,0xf2bc,0xf2d4,0xf2ee,0xf307,0xf321,0xf33c,0xf358,
+0xf374,0xf391,0xf3af,0xf3ce,0xf3ee,0xf410,0xf433,0xf459,
+0xf480,0xf4a9,0xf4d1,0xf4ff,0xf52c,0xf55c,0xf58c,0xf5c4,
+0xf5fb,0xf637,0xf673,0xf6ad,0xf6e8,0xf727,0xf766,0xf7a7,
+0xf7e8,0xf82a,0xf86b,0xf8ae,0xf8f0,0xf93a,0xf984,0xf9d0,
+0xfa1c,0xfa6c,0xfabc,0xfb0d,0xfb5f,0xfbbe,0xfc1e,0xfc80,
+0xfce2,0xfd45,0xfda8,0xfe19,0xfe8a,0xff0e,0xff92,0x0015,
+0x0098,0x012c,0x01bf,0x0248,0x02d0,0x0353,0x03d6,0x0451,
+0x04cd,0x053e,0x05b0,0x0621,0x0692,0x0707,0x077c,0x07e7,
+0x0852,0x08c2,0x0931,0x09aa,0x0a23,0x0aa4,0x0b25,0x0baa,
+0x0c2e,0x0ca8,0x0d23,0x0d93,0x0e04,0x0e75,0x0ee6};
+
+static const short decodetable3[63]={
+0xf3ed,0xf54d,0xf6ae,0xf7af,0xf8b1,0xf990,0xfa6f,0xfb39,
+0xfc03,0xfcbd,0xfd77,0xfe1d,0xfec4,0xff58,0xffec,0x007b,
+0x010b,0x0196,0x0220,0x02a5,0x032a,0x03a9,0x0429,0x04a1,
+0x0519,0x058c,0x05fe,0x066d,0x06dc,0x0747,0x07b2,0x0817,
+0x087b,0x08d9,0x0937,0x0990,0x09e8,0x0a3a,0x0a8c,0x0ad9,
+0x0b26,0x0b6d,0x0bb4,0x0bf8,0x0c3d,0x0c7e,0x0cbf,0x0cfc,
+0x0d3a,0x0d72,0x0dab,0x0ddf,0x0e13,0x0e44,0x0e75,0x0ea1,
+0x0ecd,0x0ef5,0x0f1e,0x0f44,0x0f6b,0x0f8f,0x0fb4};
+
+static const short decodetable4[63]={
+0xf23b,0xf2ae,0xf321,0xf38c,0xf3f7,0xf457,0xf4b6,0xf517,
+0xf578,0xf5d5,0xf631,0xf68d,0xf6e8,0xf742,0xf79b,0xf7f0,
+0xf845,0xf896,0xf8e7,0xf937,0xf986,0xf9d6,0xfa26,0xfa74,
+0xfac3,0xfb0f,0xfb5c,0xfbaa,0xfbf8,0xfc46,0xfc94,0xfce2,
+0xfd2f,0xfd7f,0xfdcf,0xfe22,0xfe76,0xfec9,0xff1c,0xff73,
+0xffca,0x0020,0x0077,0x00d0,0x0128,0x0186,0x01e4,0x0248,
+0x02ab,0x0315,0x037f,0x03f1,0x0463,0x04e0,0x055d,0x05e8,
+0x0673,0x0710,0x07ad,0x0872,0x0938,0x0a2f,0x0b26};
+
+static const short decodetable5[31]={
+0xf8cb,0xfa55,0xfbdf,0xfcea,0xfdf6,0xfed4,0xffb3,0x006f,
+0x012d,0x01da,0x0287,0x032b,0x03cf,0x046a,0x0505,0x059a,
+0x062e,0x06bf,0x0751,0x07e2,0x0873,0x0904,0x0994,0x0a22,
+0x0aaf,0x0b3c,0x0bc9,0x0c56,0x0ce3,0x0d6a,0x0df1};
+
+static const short decodetable6[31]={
+0xf57d,0xf679,0xf775,0xf83d,0xf904,0xf9b5,0xfa65,0xfb04,
+0xfba2,0xfc2f,0xfcbb,0xfd40,0xfdc5,0xfe44,0xfec4,0xff44,
+0xffc5,0x0047,0x00c9,0x0150,0x01d6,0x0266,0x02f7,0x0396,
+0x0435,0x04f3,0x05b1,0x0692,0x0774,0x0899,0x09bf};
+
+static const short decodetable7[15]={
+0xfaa4,0xfc65,0xfe26,0xff56,0x0085,0x017f,0x0278,0x0362,
+0x044c,0x0537,0x0623,0x071f,0x081b,0x0946,0x0a70};
+
+static const short decodetable8[15]={
+0xf6ab,0xf7d8,0xf905,0xfa1b,0xfb31,0xfc32,0xfd33,0xfe22,
+0xff11,0xfffe,0x00ea,0x01f6,0x0302,0x0462,0x05c2};
+
+static const short decodetable9[15]={
+0xf9df,0xfb3f,0xfca0,0xfdbc,0xfed8,0xffd1,0x00c8,0x01b3,
+0x029e,0x038f,0x047f,0x0596,0x06ad,0x07ff,0x0951};
+
+static const short decodetable10[15]={
+0xf768,0xf890,0xf9b8,0xfac9,0xfbda,0xfcd0,0xfdc7,0xfea8,
+0xff88,0x006c,0x0152,0x0258,0x035f,0x04da,0x0655};
+
+static const short decodetable11[7]={
+0xfd97,0xff2b,0x00be,0x01f0,0x0322,0x0476,0x05cb};
+
+const short *decodetable[11]={
+decodetable1,decodetable2,decodetable3,decodetable4,decodetable5,
+decodetable6,decodetable7,decodetable8,decodetable9,decodetable10,
+decodetable11};
+
+
+static int ra144_decode_init(AVCodecContext * avctx)
+{
+ Real144_internal *glob=avctx->priv_data;
+
+ memset(glob,0,sizeof(Real144_internal));
+ glob->resetflag=1;
+ glob->swapbuf1=glob->swapb1a;
+ glob->swapbuf2=glob->swapb2a;
+ glob->swapbuf1alt=glob->swapb1b;
+ glob->swapbuf2alt=glob->swapb2b;
+
+ memcpy(glob->wavtable1,wavtable1,sizeof(wavtable1));
+ memcpy(glob->wavtable2,wavtable2,sizeof(wavtable2));
+
+ return 0;
+}
+
+static void final(Real144_internal *glob, short *i1, short *i2, void *out, int *statbuf, int len);
+static void add_wav(Real144_internal *glob, int n, int f, int m1, int m2, int m3, short *s1, short *s2, short *s3, short *dest);
+static int irms(short *data, int factor);
+static void rotate_block(short *source, short *target, int offset);
+/* lookup square roots in table */
+static int t_sqrt(unsigned int x)
+{
+ int s=0;
+ while (x>0xfff) { s++; x=x>>2; }
+ return (sqrt_table[x]<<s)<<2;
+}
+
+/* do 'voice' */
+static void do_voice(int *a1, int *a2)
+{
+ int buffer[10];
+ int *b1,*b2;
+ int x,y;
+ int *ptr,*tmp;
+
+ b1=buffer;
+ b2=a2;
+
+ for (x=0;x<10;x++) {
+ b1[x]=(*a1)<<4;
+
+ if(x>0) {
+ ptr=b2+x;
+ for (y=0;y<=x-1;y++)
+ b1[y]=(((*a1)*(*(--ptr)))>>12)+b2[y];
+ }
+ tmp=b1;
+ b1=b2;
+ b2=tmp;
+ a1++;
+ }
+ ptr=a2+10;
+ while (ptr>a2) (*a2++)>>=4;
+}
+
+
+/* do quarter-block output */
+static void do_output_subblock(Real144_internal *glob, int x)
+{
+ int a,b,c,d,e,f,g;
+
+ if (x==1) memset(glob->buffer,0,20);
+ if ((*glob->iptr)==0) a=0;
+ else a=(*glob->iptr)+HALFBLOCK-1;
+ glob->iptr++;
+ b=*(glob->iptr++);
+ c=*(glob->iptr++);
+ d=*(glob->iptr++);
+ if (a) rotate_block(glob->buffer_2,glob->buffer_a,a);
+ memcpy(glob->buffer_b,etable1+b*BLOCKSIZE,BLOCKSIZE*2);
+ e=((ftable1[b]>>4)*glob->gval)>>8;
+ memcpy(glob->buffer_c,etable2+c*BLOCKSIZE,BLOCKSIZE*2);
+ f=((ftable2[c]>>4)*glob->gval)>>8;
+ if (a) g=irms(glob->buffer_a,glob->gval)>>12;
+ else g=0;
+ add_wav(glob,d,a,g,e,f,glob->buffer_a,glob->buffer_b,glob->buffer_c,glob->buffer_d);
+ memmove(glob->buffer_2,glob->buffer_2+BLOCKSIZE,(BUFFERSIZE-BLOCKSIZE)*2);
+ memcpy(glob->buffer_2+BUFFERSIZE-BLOCKSIZE,glob->buffer_d,BLOCKSIZE*2);
+ final(glob,glob->gsp,glob->buffer_d,glob->output_buffer,glob->buffer,BLOCKSIZE);
+}
+
+/* rotate block */
+static void rotate_block(short *source, short *target, int offset)
+{
+ short *end;
+ short *ptr1;
+ short *ptr2;
+ short *ptr3;
+ ptr2=source+BUFFERSIZE;
+ ptr3=ptr1=ptr2-offset;
+ end=target+BLOCKSIZE;
+ while (target<end) {
+ *(target++)=*(ptr3++);
+ if (ptr3==ptr2) ptr3=ptr1;
+ }
+}
+
+/* inverse root mean square */
+static int irms(short *data, int factor)
+{
+ short *p1,*p2;
+ unsigned int sum;
+ p2=(p1=data)+BLOCKSIZE;
+ for (sum=0;p2>p1;p1++) sum+=(*p1)*(*p1);
+ if (sum==0) return 0; /* OOPS - division by zero */
+ return (0x20000000/(t_sqrt(sum)>>8))*factor;
+}
+
+/* multiply/add wavetable */
+static void add_wav(Real144_internal *glob, int n, int f, int m1, int m2, int m3, short *s1, short *s2, short *s3, short *dest)
+{
+ int a,b,c;
+ int x;
+ short *ptr,*ptr2;
+
+ ptr=glob->wavtable1+n*9;
+ ptr2=glob->wavtable2+n*9;
+ if (f!=0) {
+ a=((*ptr)*m1)>>((*ptr2)+1);
+ } else {
+ a=0;
+ }
+ ptr++;ptr2++;
+ b=((*ptr)*m2)>>((*ptr2)+1);
+ ptr++;ptr2++;
+ c=((*ptr)*m3)>>((*ptr2)+1);
+ ptr2=(ptr=dest)+BLOCKSIZE;
+ if (f!=0)
+ while (ptr<ptr2)
+ *(ptr++)=((*(s1++))*a+(*(s2++))*b+(*(s3++))*c)>>12;
+ else
+ while (ptr<ptr2)
+ *(ptr++)=((*(s2++))*b+(*(s3++))*c)>>12;
+}
+
+
+static void final(Real144_internal *glob, short *i1, short *i2, void *out, int *statbuf, int len)
+{
+ int x,sum;
+ int buffer[10];
+ short *ptr;
+ short *ptr2;
+
+ memcpy(glob->work,statbuf,20);
+ memcpy(glob->work+10,i2,len*2);
+
+ buffer[9]=i1[0];
+ buffer[8]=i1[1];
+ buffer[7]=i1[2];
+ buffer[6]=i1[3];
+ buffer[5]=i1[4];
+ buffer[4]=i1[5];
+ buffer[3]=i1[6];
+ buffer[2]=i1[7];
+ buffer[1]=i1[8];
+ buffer[0]=i1[9];
+
+ ptr2=(ptr=glob->work)+len;
+ while (ptr<ptr2) {
+ for(sum=0,x=0;x<=9;x++)
+ sum+=buffer[x]*(ptr[x]);
+ sum=sum>>12;
+ x=ptr[10]-sum;
+ if (x<-32768 || x>32767)
+ {
+ memset(out,0,len*2);
+ memset(statbuf,0,20);
+ return;
+ }
+ ptr[10]=x;
+ ptr++;
+ }
+ memcpy(out,ptr+10-len,len*2);
+ memcpy(statbuf,ptr,20);
+}
+
+/* Decode 20-byte input */
+static void unpack_input(unsigned char *input, unsigned int *output)
+{
+ unsigned int outbuffer[28];
+ unsigned short inbuffer[10];
+ unsigned int x;
+ unsigned int *ptr;
+
+ /* fix endianness */
+ for (x=0;x<20;x+=2)
+ inbuffer[x/2]=(input[x]<<8)+input[x+1];
+
+ /* unpack */
+ ptr=outbuffer;
+ *(ptr++)=27;
+ *(ptr++)=(inbuffer[0]>>10)&0x3f;
+ *(ptr++)=(inbuffer[0]>>5)&0x1f;
+ *(ptr++)=inbuffer[0]&0x1f;
+ *(ptr++)=(inbuffer[1]>>12)&0xf;
+ *(ptr++)=(inbuffer[1]>>8)&0xf;
+ *(ptr++)=(inbuffer[1]>>5)&7;
+ *(ptr++)=(inbuffer[1]>>2)&7;
+ *(ptr++)=((inbuffer[1]<<1)&6)|((inbuffer[2]>>15)&1);
+ *(ptr++)=(inbuffer[2]>>12)&7;
+ *(ptr++)=(inbuffer[2]>>10)&3;
+ *(ptr++)=(inbuffer[2]>>5)&0x1f;
+ *(ptr++)=((inbuffer[2]<<2)&0x7c)|((inbuffer[3]>>14)&3);
+ *(ptr++)=(inbuffer[3]>>6)&0xff;
+ *(ptr++)=((inbuffer[3]<<1)&0x7e)|((inbuffer[4]>>15)&1);
+ *(ptr++)=(inbuffer[4]>>8)&0x7f;
+ *(ptr++)=(inbuffer[4]>>1)&0x7f;
+ *(ptr++)=((inbuffer[4]<<7)&0x80)|((inbuffer[5]>>9)&0x7f);
+ *(ptr++)=(inbuffer[5]>>2)&0x7f;
+ *(ptr++)=((inbuffer[5]<<5)&0x60)|((inbuffer[6]>>11)&0x1f);
+ *(ptr++)=(inbuffer[6]>>4)&0x7f;
+ *(ptr++)=((inbuffer[6]<<4)&0xf0)|((inbuffer[7]>>12)&0xf);
+ *(ptr++)=(inbuffer[7]>>5)&0x7f;
+ *(ptr++)=((inbuffer[7]<<2)&0x7c)|((inbuffer[8]>>14)&3);
+ *(ptr++)=(inbuffer[8]>>7)&0x7f;
+ *(ptr++)=((inbuffer[8]<<1)&0xfe)|((inbuffer[9]>>15)&1);
+ *(ptr++)=(inbuffer[9]>>8)&0x7f;
+ *(ptr++)=(inbuffer[9]>>1)&0x7f;
+
+ *(output++)=outbuffer[11];
+ for (x=1;x<11;*(output++)=outbuffer[x++]);
+ ptr=outbuffer+12;
+ for (x=0;x<16;x+=4)
+ {
+ *(output++)=ptr[x];
+ *(output++)=ptr[x+2];
+ *(output++)=ptr[x+3];
+ *(output++)=ptr[x+1];
+ }
+}
+
+static unsigned int rms(int *data, int f)
+{
+ int *c;
+ int x;
+ int d;
+ unsigned int res;
+ int b;
+
+ c=data;
+ b=0;
+ res=0x10000;
+ for (x=0;x<10;x++)
+ {
+ res=(((0x1000000-(*c)*(*c))>>12)*res)>>12;
+ if (res==0) return 0;
+ if (res<=0x3fff)
+ {
+ while (res<=0x3fff)
+ {
+ b++;
+ res<<=2;
+ }
+ } else {
+ if (res>0x10000)
+ return 0; /* We're screwed, might as well go out with a bang. :P */
+ }
+ c++;
+ }
+ if (res>0) res=t_sqrt(res);
+
+ res>>=(b+10);
+ res=(res*f)>>10;
+ return res;
+}
+
+static void dec1(Real144_internal *glob, int *data, int *inp, int n, int f)
+{
+ short *ptr,*end;
+
+ *(glob->decptr++)=rms(data,f);
+ glob->decptr++;
+ end=(ptr=glob->decsp)+(n*10);
+ while (ptr<end) *(ptr++)=*(inp++);
+}
+
+static int eq(Real144_internal *glob, short *in, int *target)
+{
+ int retval;
+ int a;
+ int b;
+ int c;
+ unsigned int u;
+ short *sptr;
+ int *ptr1,*ptr2,*ptr3;
+ int *bp1,*bp2,*temp;
+
+ retval=0;
+ bp1=glob->buffer1;
+ bp2=glob->buffer2;
+ ptr2=(ptr3=glob->buffer2)+9;
+ sptr=in;
+ while (ptr2>=ptr3)
+ *(ptr3++)=*(sptr++);
+
+ target+=9;
+ a=bp2[9];
+ *target=a;
+ if (a+0x1000>0x1fff)
+ return 0; /* We're screwed, might as well go out with a bang. :P */
+ c=8;u=a;
+ while (c>=0)
+ {
+ if (u==0x1000) u++;
+ if (u==0xfffff000) u--;
+ b=0x1000-((u*u)>>12);
+ if (b==0) b++;
+ ptr2=bp1;
+ ptr1=(ptr3=bp2)+c;
+ for (u=0;u<=c;u++)
+ *(ptr2++)=((*(ptr3++)-(((*target)*(*(ptr1--)))>>12))*(0x1000000/b))>>12;
+ *(--target)=u=bp1[(c--)];
+ if ((u+0x1000)>0x1fff) retval=1;
+ temp=bp2;
+ bp2=bp1;
+ bp1=temp;
+ }
+ return retval;
+}
+
+static void dec2(Real144_internal *glob, int *data, int *inp, int n, int f, int *inp2, int l)
+{
+ unsigned int *ptr1,*ptr2;
+ int work[10];
+ int a,b;
+ int x;
+ int result;
+
+ if(l+1<NBLOCKS/2) a=NBLOCKS-(l+1);
+ else a=l+1;
+ b=NBLOCKS-a;
+ if (l==0)
+ {
+ glob->decsp=glob->sptr=glob->gbuf2;
+ glob->decptr=glob->gbuf1;
+ }
+ ptr1=inp;
+ ptr2=inp2;
+ for (x=0;x<10*n;x++)
+ *(glob->sptr++)=(a*(*ptr1++)+b*(*ptr2++))>>2;
+ result=eq(glob,glob->decsp,work);
+ if (result==1)
+ {
+ dec1(glob,data,inp,n,f);
+ } else {
+ *(glob->decptr++)=rms(work,f);
+ glob->decptr++;
+ }
+ glob->decsp+=n*10;
+}
+
+/* Uncompress one block (20 bytes -> 160*2 bytes) */
+static int ra144_decode_frame(AVCodecContext * avctx,
+ void *data, int *data_size,
+ uint8_t * buf, int buf_size)
+{
+ unsigned int a,b,c;
+ long s;
+ signed short *shptr;
+ unsigned int *lptr,*temp;
+ const short **dptr;
+ void *datao;
+ Real144_internal *glob=avctx->priv_data;
+
+ datao = data;
+ unpack_input(buf,glob->unpacked);
+
+ glob->iptr=glob->unpacked;
+ glob->val=decodetable[0][(*(glob->iptr++))<<1];
+
+ dptr=decodetable+1;
+ lptr=glob->swapbuf1;
+ while (lptr<glob->swapbuf1+10)
+ *(lptr++)=(*(dptr++))[(*(glob->iptr++))<<1];
+
+ do_voice(glob->swapbuf1,glob->swapbuf2);
+
+ a=t_sqrt(glob->val*glob->oldval)>>12;
+
+ for (c=0;c<NBLOCKS;c++) {
+ if (c==(NBLOCKS-1)) {
+ dec1(glob,glob->swapbuf1,glob->swapbuf2,3,glob->val);
+ } else {
+ if (c*2==(NBLOCKS-2)) {
+ if (glob->oldval<glob->val) {
+ dec2(glob,glob->swapbuf1,glob->swapbuf2,3,a,glob->swapbuf2alt,c);
+ } else {
+ dec2(glob,glob->swapbuf1alt,glob->swapbuf2alt,3,a,glob->swapbuf2,c);
+ }
+ } else {
+ if (c*2<(NBLOCKS-2)) {
+ dec2(glob,glob->swapbuf1alt,glob->swapbuf2alt,3,glob->oldval,glob->swapbuf2,c);
+ } else {
+ dec2(glob,glob->swapbuf1,glob->swapbuf2,3,glob->val,glob->swapbuf2alt,c);
+ }
+ }
+ }
+ }
+
+ /* do output */
+ for (b=0,c=0;c<4;c++) {
+ glob->gval=glob->gbuf1[c*2];
+ glob->gsp=glob->gbuf2+b;
+ do_output_subblock(glob,glob->resetflag);
+ glob->resetflag=0;
+
+ shptr=glob->output_buffer;
+ while (shptr<glob->output_buffer+BLOCKSIZE) {
+ s=*(shptr++)<<2;
+ *((int16_t *)data)=s;
+ if (s>32767) *((int16_t *)data)=32767;
+ if (s<-32767) *((int16_t *)data)=-32768;
+ ((int16_t *)data)++;
+ }
+ b+=30;
+ }
+
+ glob->oldval=glob->val;
+ temp=glob->swapbuf1alt;
+ glob->swapbuf1alt=glob->swapbuf1;
+ glob->swapbuf1=temp;
+ temp=glob->swapbuf2alt;
+ glob->swapbuf2alt=glob->swapbuf2;
+ glob->swapbuf2=temp;
+ *data_size=data-datao;
+ return 20;
+}
+
+
+AVCodec ra_144_decoder =
+{
+ "real_144",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_RA_144,
+ sizeof(Real144_internal),
+ ra144_decode_init,
+ NULL,
+ NULL,
+ ra144_decode_frame,
+};
diff --git a/src/libffmpeg/libavcodec/ra288.c b/src/libffmpeg/libavcodec/ra288.c
new file mode 100644
index 000000000..9bebfa88a
--- /dev/null
+++ b/src/libffmpeg/libavcodec/ra288.c
@@ -0,0 +1,451 @@
+/*
+ * RealAudio 2.0 (28.8K)
+ * Copyright (c) 2003 the ffmpeg project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "avcodec.h"
+
+typedef struct {
+ float history[8];
+ float output[40];
+ float pr1[36];
+ float pr2[10];
+ int phase, phasep;
+
+ float st1a[111],st1b[37],st1[37];
+ float st2a[38],st2b[11],st2[11];
+ float sb[41];
+ float lhist[10];
+} Real288_internal;
+
+const float amptable[8]={ 0.515625, 0.90234375, 1.57910156, 2.76342773,
+ -0.515625,-0.90234375,-1.57910156,-2.76342773 };
+
+const float codetable[640]={
+ 0.326171875, -1.4404296875, -0.6123046875, -0.8740234375, -1.24658203125,
+ -2.45703125, -2.23486328125, -0.51025390625, 1.419921875, 1.6201171875,
+ -1.37646484375, -1.30712890625, -0.462890625, -1.37939453125, -2.1728515625,
+ -3.26123046875, -0.166015625, 0.7236328125, -0.623046875, 0.6162109375,
+ -0.2744140625, -3.29931640625, 0.62548828125, 0.08740234375, -0.6220703125,
+ -1.2265625, -3.4814453125, -2.40478515625, 3.37548828125, 1.17724609375,
+ -1.2099609375, -0.076171875, 2.28662109375, -1.89111328125, 0,
+ -4.0078125, 1.044921875, -0.2333984375, -1.35986328125, 0.26025390625,
+ 0.92236328125, 1.34716796875, 0.67431640625, -3.39599609375, -2.88720703125,
+ 2.4814453125, -1.201171875, -2.8212890625, 0.87744140625, 0.27734375,
+ -1.078125, -1.61572265625, -2.20849609375, -3.044921875, -3.66455078125,
+ -1.32763671875, 2.1279296875, -1.458984375, -0.56103515625, 1.30078125,
+ 0.61474609375, 0.48583984375, 1.32373046875, -1.203125, -5.0732421875,
+ 0.8408203125, -3.69580078125, -1.3388671875, 1.06005859375, -1.13720703125,
+ 0.50390625, 0.36474609375, -0.4189453125, -3.8798828125, -6.27099609375,
+ 1.5166015625, 2.37109375, -2.04736328125, -1.24072265625, 0.50537109375,
+ 0.9091796875, -0.46875, -3.236328125, 0.2001953125, 2.8720703125,
+ -1.21728515625, -1.283203125, -1.953125, -0.029296875, 3.5166015625,
+ -1.3046875, 0.7060546875, 0.75, -1.87060546875, 0.60205078125,
+ -2.5888671875, 3.375, 0.77587890625, -2.04443359375, 1.78955078125,
+ -1.6875, -3.9892578125, -3.76416015625, 0.67578125, 2.2939453125,
+ -2.29443359375, -3.03173828125, -5.45703125, 3.95703125, 8.2177734375,
+ 0.4541015625, 3.419921875, 0.61962890625, -4.38330078125, 1.25341796875,
+ 2.27001953125, 5.763671875, 1.68017578125, -2.76220703125, 0.58544921875,
+ 1.2412109375, -0.08935546875, -4.32568359375, -3.89453125, 1.5771484375,
+ -1.40234375, -0.98193359375, -4.74267578125, -4.09423828125, 6.33935546875,
+ 1.5068359375, 1.044921875, -1.796875, -4.70849609375, -1.4140625,
+ -3.71533203125, 3.18115234375, -1.11474609375, -1.2314453125, 3.091796875,
+ -1.62744140625, -2.744140625, -4.4580078125, -5.43505859375, 2.70654296875,
+ -0.19873046875, -3.28173828125, -8.5283203125, -1.41064453125, 5.6484375,
+ 1.802734375, 3.318359375, -0.1279296875, -5.2958984375, -0.90625,
+ 3.55224609375, 6.544921875, -1.45947265625, -5.17333984375, 2.41015625,
+ 0.119140625, -1.08349609375, 1.296875, 1.84375, -2.642578125,
+ -1.97412109375, -2.8974609375, 1.04052734375, 0.42138671875, -1.3994140625,
+ -1.6123046875, 0.85107421875, -0.9794921875, -0.0625, -1.001953125,
+ -3.10595703125, 1.6318359375, -0.77294921875, -0.01025390625, 0.5576171875,
+ -1.87353515625, -0.89404296875, 3.12353515625, 1.24267578125, -1.390625,
+ -4.556640625, -3.1875, 2.59228515625, 0.9697265625, -1.09619140625,
+ -2.1923828125, 0.365234375, 0.94482421875, -1.47802734375, -0.24072265625,
+ -4.51904296875, 2.6201171875, 1.55908203125, -2.19384765625, 0.87109375,
+ 2.3359375, -0.1806640625, 0.9111328125, 0.51611328125, -0.92236328125,
+ 3.5849609375, -1.3134765625, -1.25830078125, 0.330078125, -0.29833984375,
+ -0.2451171875, 1.09130859375, -0.9033203125, -0.86767578125, -1.00048828125,
+ 0.49365234375, 1.89453125, -1.20361328125, 1.07861328125, -0.07421875,
+ 1.265625, 1.38134765625, 2.728515625, 1.38623046875, -3.5673828125,
+ -1.48876953125, -2.4013671875, 2.90771484375, 4.49267578125, -2.17138671875,
+ 0.34033203125, 1.908203125, 2.8310546875, -2.17333984375, -2.267578125,
+ -1.03564453125, 2.658203125, -1.2548828125, 0.15673828125, -0.5869140625,
+ 1.3896484375, -1.0185546875, 1.724609375, 0.2763671875, -0.345703125,
+ -2.08935546875, 0.4638671875, 2.431640625, 1.83056640625, 0.220703125,
+ -1.212890625, 1.7099609375, 0.83935546875, -0.0830078125, 0.1162109375,
+ -1.67724609375, 0.12841796875, 1.0322265625, -0.97900390625, 1.15283203125,
+ -3.5830078125, -0.58984375, 4.56396484375, -0.59375, -1.95947265625,
+ -6.5908203125, -0.21435546875, 3.919921875, -2.06640625, 0.17626953125,
+ -1.82080078125, 2.65283203125, 0.978515625, -2.30810546875, -0.61474609375,
+ -1.9462890625, 3.78076171875, 4.11572265625, -1.80224609375, -0.48193359375,
+ 2.5380859375, -0.20654296875, 0.5615234375, -0.62548828125, 0.3984375,
+ 3.61767578125, 2.00634765625, -1.92822265625, 1.3134765625, 0.0146484384313,
+ 0.6083984375, 1.49169921875, -0.01708984375, -0.6689453125, -0.1201171875,
+ -0.72705078125, 2.75146484375, -0.3310546875, -1.28271484375, 1.5478515625,
+ 2.3583984375, -2.23876953125, 0.98046875, -0.5185546875, 0.39013671875,
+ -0.06298828125, 0.35009765625, 2.2431640625, 7.29345703125, 5.2275390625,
+ 0.20361328125, 1.34716796875, 0.9033203125, -2.46923828125, -0.56298828125,
+ -1.89794921875, 3.59423828125, -2.81640625, 2.09228515625, 0.3251953125,
+ 0.70458984375, -0.4580078125, 0.009765625, -1.03466796875, -0.82861328125,
+ -1.8125, -1.6611328125, -1.080078125, 0.0537109375, 1.04296875,
+ -1.44140625, 0.005859375, -0.765625, -1.708984375, -0.90576171875,
+ -0.64208984375, -0.84521484375, 0.56640625, -0.2724609375, 0.83447265625,
+ 0.04296875, -2.23095703125, 0.0947265625, -0.2216796875, -1.44384765625,
+ -1.38623046875, -0.8134765625, -0.13330078125, 1.017578125, -0.07568359375,
+ -0.09228515625, -1.16015625, 0.81201171875, -0.5078125, -1.19580078125,
+ -1.3876953125, -0.66845703125, 0.310546875, -0.12109375, -1.30712890625,
+ 0.74072265625, 0.03857421875, -1.47119140625, -1.79150390625, -0.47509765625,
+ 0.93408203125, -1.21728515625, -2.59375, -0.36572265625, 0.62060546875,
+ -1.41748046875, -1.623046875, -1.833984375, -1.8017578125, -0.89306640625,
+ -1.42236328125, -0.75537109375, -1.34765625, -0.6865234375, 0.548828125,
+ 0.900390625, -0.8955078125, 0.22265625, 0.3447265625, -2.0859375,
+ 0.22802734375, -2.078125, -0.93212890625, 0.74267578125, 0.5537109375,
+ -0.06201171875, -0.4853515625, -0.31103515625, -0.72802734375, -3.1708984375,
+ 0.42626953125, -0.99853515625, -1.869140625, -1.36328125, -0.2822265625,
+ 1.12841796875, -0.88720703125, 1.28515625, -1.490234375, 0.9609375,
+ 0.31298828125, 0.5830078125, 0.92431640625, 2.00537109375, 3.0966796875,
+ -0.02197265625, 0.5849609375, 1.0546875, -0.70751953125, 1.07568359375,
+ -0.978515625, 0.83642578125, 1.7177734375, 1.294921875, 2.07568359375,
+ 1.43359375, -1.9375, 0.625, 0.06396484375, -0.720703125,
+ 1.38037109375, 0.00390625, -0.94140625, 1.2978515625, 1.71533203125,
+ 1.56201171875, -0.3984375, 1.31201171875, -0.85009765625, -0.68701171875,
+ 1.439453125, 1.96728515625, 0.1923828125, -0.12353515625, 0.6337890625,
+ 2.0927734375, 0.02490234375, -2.20068359375, -0.015625, -0.32177734375,
+ 1.90576171875, 2.7568359375, -2.728515625, -1.265625, 2.78662109375,
+ -0.2958984375, 0.6025390625, -0.78466796875, -2.53271484375, 0.32421875,
+ -0.25634765625, 1.767578125, -1.0703125, -1.23388671875, 0.83349609375,
+ 2.09814453125, -1.58740234375, -1.11474609375, 0.396484375, -1.10546875,
+ 2.81494140625, 0.2578125, -1.60498046875, 0.66015625, 0.81640625,
+ 1.33544921875, 0.60595703125, -0.53857421875, -1.59814453125, -1.66357421875,
+ 1.96923828125, 0.8046875, -1.44775390625, -0.5732421875, 0.705078125,
+ 0.0361328125, 0.4482421875, 0.97607421875, 0.44677734375, -0.5009765625,
+ -1.21875, -0.78369140625, 0.9931640625, 1.4404296875, 0.11181640625,
+ -1.05859375, 0.99462890625, 0.00732421921566,-0.6171875, -0.1015625,
+ -1.734375, 0.7470703125, 0.28369140625, 0.72802734375, 0.4697265625,
+ -1.27587890625, -1.1416015625, 1.76806640625, -0.7265625, -1.06689453125,
+ -0.85302734375, 0.03955078125, 2.7041015625, 0.69921875, -1.10205078125,
+ -0.49755859375, 0.42333984375, 0.1044921875, -1.115234375, -0.7373046875,
+ -0.822265625, 1.375, -0.11181640625, 1.24560546875, -0.67822265625,
+ 1.32177734375, 0.24609375, 0.23388671875, 1.35888671875, -0.49267578125,
+ 1.22900390625, -0.72607421875, -0.779296875, 0.30322265625, 0.94189453125,
+ -0.072265625, 1.0771484375, -2.09375, 0.630859375, -0.68408203125,
+ -0.25732421875, 0.60693359375, -1.33349609375, 0.93212890625, 0.625,
+ 1.04931640625, -0.73291015625, 1.80078125, 0.2978515625, -2.24169921875,
+ 1.6142578125, -1.64501953125, 0.91552734375, 1.775390625, -0.59423828125,
+ 1.2568359375, 1.22705078125, 0.70751953125, -1.5009765625, -2.43115234375,
+ 0.3974609375, 0.8916015625, -1.21923828125, 2.0673828125, -1.99072265625,
+ 0.8125, -0.107421875, 1.6689453125, 0.4892578125, 0.54443359375,
+ 0.38134765625, 0.8095703125, 1.91357421875, 2.9931640625, 1.533203125,
+ 0.560546875, 1.98486328125, 0.740234375, 0.39794921875, 0.09716796875,
+ 0.58154296875, 1.21533203125, 1.25048828125, 1.18212890625, 1.19287109375,
+ 0.3759765625, -2.88818359375, 2.69287109375, -0.1796875, -1.56201171875,
+ 0.5810546875, 0.51123046875, 1.8271484375, 3.38232421875, -1.02001953125,
+ 0.142578125, 1.51318359375, 2.103515625, -0.3701171875, -1.19873046875,
+ 0.25537109375, 1.91455078125, 1.974609375, 0.6767578125, 0.04150390625,
+ 2.13232421875, 0.4912109375, -0.611328125, -0.7158203125, -0.67529296875,
+ 1.880859375, 0.77099609375, -0.03759765625, 1.0078125, 0.423828125,
+ 2.49462890625, 1.42529296875, -0.0986328125, 0.17529296875, -0.24853515625,
+ 1.7822265625, 1.5654296875, 1.12451171875, 0.82666015625, 0.6328125,
+ 1.41845703125, -1.90771484375, 0.11181640625, -0.583984375, -1.138671875,
+ 2.91845703125, -1.75048828125, 0.39306640625, 1.86767578125, -1.5322265625,
+ 1.8291015625, -0.2958984375, 0.02587890625, -0.13134765625, -1.61181640625,
+ 0.2958984375, 0.9853515625, -0.642578125, 1.984375, 0.1943359375
+};
+
+const float table1[111]={
+ 0.576690972, 0.580838025, 0.585013986, 0.589219987, 0.59345597, 0.597723007,
+ 0.602020264, 0.606384277, 0.610748291, 0.615142822, 0.619598389, 0.624084473,
+ 0.628570557, 0.633117676, 0.637695313, 0.642272949, 0.646911621, 0.651580811,
+ 0.656280518, 0.66104126, 0.665802002, 0.670593262, 0.675445557, 0.680328369,
+ 0.685241699, 0.690185547, 0.695159912, 0.700164795, 0.705230713, 0.710327148,
+ 0.715454102, 0.720611572, 0.725830078, 0.731048584, 0.736328125, 0.741638184,
+ 0.747009277, 0.752380371, 0.7578125, 0.763305664, 0.768798828, 0.774353027,
+ 0.779937744, 0.785583496, 0.791229248, 0.796936035, 0.802703857, 0.808502197,
+ 0.814331055, 0.820220947, 0.826141357, 0.832092285, 0.838104248, 0.844146729,
+ 0.850250244, 0.856384277, 0.862548828, 0.868774414, 0.875061035, 0.881378174,
+ 0.88772583, 0.894134521, 0.900604248, 0.907104492, 0.913635254, 0.920227051,
+ 0.926879883, 0.933563232, 0.940307617, 0.94708252, 0.953918457, 0.96081543,
+ 0.96774292, 0.974731445, 0.981781006, 0.988861084, 0.994842529, 0.998565674,
+ 0.999969482, 0.99911499, 0.996002197, 0.990600586, 0.982910156, 0.973022461,
+ 0.960876465, 0.946533203, 0.930053711, 0.911437988, 0.89074707, 0.868041992,
+ 0.843322754, 0.816680908, 0.788208008, 0.757904053, 0.725891113, 0.692199707,
+ 0.656921387, 0.620178223, 0.582000732, 0.542480469, 0.501739502, 0.459838867,
+ 0.416900635, 0.373016357, 0.328277588, 0.282775879, 0.236663818, 0.189971924,
+ 0.142852783, 0.0954284668, 0.0477600098
+};
+
+const float table2[38]={
+ 0.505699992, 0.524200022, 0.54339999, 0.563300014, 0.583953857, 0.60534668,
+ 0.627502441, 0.650482178, 0.674316406, 0.699005127, 0.724578857, 0.75112915,
+ 0.778625488, 0.807128906, 0.836669922, 0.86730957, 0.899078369, 0.932006836,
+ 0.961486816, 0.982757568, 0.995635986, 1, 0.995819092, 0.983154297,
+ 0.96206665, 0.932769775, 0.895507813, 0.850585938, 0.798400879, 0.739379883,
+ 0.674072266, 0.602996826, 0.526763916, 0.446014404, 0.361480713, 0.273834229,
+ 0.183868408, 0.0923461914
+};
+
+const float table1a[36]={
+ 0.98828125, 0.976699829, 0.965254128, 0.953942537, 0.942763507, 0.931715488,
+ 0.920796931, 0.910006344, 0.899342179, 0.888803005, 0.878387332, 0.868093729,
+ 0.857920766, 0.847867012, 0.837931097, 0.828111589, 0.818407178, 0.808816493,
+ 0.799338162, 0.789970934, 0.780713439, 0.771564424, 0.762522638, 0.753586829,
+ 0.744755745, 0.736028135, 0.727402806, 0.718878567, 0.710454226, 0.702128589,
+ 0.693900526, 0.685768902, 0.677732527, 0.669790328, 0.66194123, 0.654184103
+};
+
+const float table2a[10]={
+ 0.90625, 0.821289063, 0.74432373, 0.674499512, 0.61126709,
+ 0.553955078, 0.50201416, 0.454956055, 0.41229248, 0.373657227
+};
+
+
+static int ra288_decode_init(AVCodecContext * avctx)
+{
+ Real288_internal *glob=avctx->priv_data;
+ memset(glob,0,sizeof(Real288_internal));
+ return 0;
+}
+
+static void prodsum(float *tgt, float *src, int len, int n);
+static void co(int n, int i, int j, float *in, float *out, float *st1, float *st2, const float *table);
+static int pred(float *in, float *tgt, int n);
+static void colmult(float *tgt, float *m1, const float *m2, int n);
+
+
+/* initial decode */
+static void unpack(unsigned short *tgt, unsigned char *src, int len)
+{
+ int x,y,z;
+ int n,temp;
+ int buffer[38];
+
+ for (x=0;x<len;tgt[x++]=0)
+ buffer[x]=9+(x&1);
+
+ for (x=y=z=0;x<38;x++) {
+ n=buffer[y]-z;
+ temp=src[x];
+ if (n<8) temp&=255>>(8-n);
+ tgt[y]+=temp<<z;
+ if (n<=8) {
+ tgt[++y]+=src[x]>>n;
+ z=8-n;
+ } else z+=8;
+ }
+}
+
+static void update(Real288_internal *glob)
+{
+ int x,y;
+ float buffer1[40],temp1[37];
+ float buffer2[8],temp2[11];
+
+ for (x=0,y=glob->phasep+5;x<40;buffer1[x++]=glob->output[(y++)%40]);
+ co(36,40,35,buffer1,temp1,glob->st1a,glob->st1b,table1);
+ if (pred(temp1,glob->st1,36))
+ colmult(glob->pr1,glob->st1,table1a,36);
+
+ for (x=0,y=glob->phase+1;x<8;buffer2[x++]=glob->history[(y++)%8]);
+ co(10,8,20,buffer2,temp2,glob->st2a,glob->st2b,table2);
+ if (pred(temp2,glob->st2,10))
+ colmult(glob->pr2,glob->st2,table2a,10);
+}
+
+/* Decode and produce output */
+static void decode(Real288_internal *glob, unsigned int input)
+{
+ unsigned int x,y;
+ float f;
+ double sum,sumsum;
+ float *p1,*p2;
+ float buffer[5];
+ const float *table;
+
+ for (x=36;x--;glob->sb[x+5]=glob->sb[x]);
+ for (x=5;x--;) {
+ p1=glob->sb+x;p2=glob->pr1;
+ for (sum=0,y=36;y--;sum-=(*(++p1))*(*(p2++)));
+ glob->sb[x]=sum;
+ }
+
+ f=amptable[input&7];
+ table=codetable+(input>>3)*5;
+
+ /* convert log and do rms */
+ for (sum=32,x=10;x--;sum-=glob->pr2[x]*glob->lhist[x]);
+ if (sum<0) sum=0; else if (sum>60) sum=60;
+
+ sumsum=exp(sum*0.1151292546497)*f; /* pow(10.0,sum/20)*f */
+ for (sum=0,x=5;x--;) { buffer[x]=table[x]*sumsum; sum+=buffer[x]*buffer[x]; }
+ if ((sum/=5)<1) sum=1;
+
+ /* shift and store */
+ for (x=10;--x;glob->lhist[x]=glob->lhist[x-1]);
+ *glob->lhist=glob->history[glob->phase]=10*log10(sum)-32;
+
+ for (x=1;x<5;x++) for (y=x;y--;buffer[x]-=glob->pr1[x-y-1]*buffer[y]);
+
+ /* output */
+ for (x=0;x<5;x++) {
+ f=glob->sb[4-x]+buffer[x];
+ if (f>4095) f=4095; else if (f<-4095) f=-4095;
+ glob->output[glob->phasep+x]=glob->sb[4-x]=f;
+ }
+}
+
+/* column multiply */
+static void colmult(float *tgt, float *m1, const float *m2, int n)
+{
+ while (n--)
+ *(tgt++)=(*(m1++))*(*(m2++));
+}
+
+static int pred(float *in, float *tgt, int n)
+{
+ int x,y;
+ float *p1,*p2;
+ double f0,f1,f2;
+ float temp;
+
+ if (in[n]==0) return 0;
+ if ((f0=*in)<=0) return 0;
+
+ for (x=1;;x++) {
+ if (n<x) return 1;
+
+ p1=in+x;
+ p2=tgt;
+ f1=*(p1--);
+ for (y=x;--y;f1+=(*(p1--))*(*(p2++)));
+
+ p1=tgt+x-1;
+ p2=tgt;
+ *(p1--)=f2=-f1/f0;
+ for (y=x>>1;y--;) {
+ temp=*p2+*p1*f2;
+ *(p1--)+=*p2*f2;
+ *(p2++)=temp;
+ }
+ if ((f0+=f1*f2)<0) return 0;
+ }
+}
+
+static void co(int n, int i, int j, float *in, float *out, float *st1, float *st2, const float *table)
+{
+ int a,b,c;
+ unsigned int x;
+ float *fp,*fp2;
+ float buffer1[37];
+ float buffer2[37];
+ float work[111];
+
+ /* rotate and multiply */
+ c=(b=(a=n+i)+j)-i;
+ fp=st1+i;
+ for (x=0;x<b;x++) {
+ if (x==c) fp=in;
+ work[x]=*(table++)*(*(st1++)=*(fp++));
+ }
+
+ prodsum(buffer1,work+n,i,n);
+ prodsum(buffer2,work+a,j,n);
+
+ for (x=0;x<=n;x++) {
+ *st2=*st2*(0.5625)+buffer1[x];
+ out[x]=*(st2++)+buffer2[x];
+ }
+ *out*=1.00390625; /* to prevent clipping */
+}
+
+/* product sum (lsf) */
+static void prodsum(float *tgt, float *src, int len, int n)
+{
+ unsigned int x;
+ float *p1,*p2;
+ double sum;
+
+ while (n>=0)
+ {
+ p1=(p2=src)-n;
+ for (sum=0,x=len;x--;sum+=(*p1++)*(*p2++));
+ tgt[n--]=sum;
+ }
+}
+
+#ifndef max
+#define max(a,b) ((a)>(b)?(a):(b))
+#endif
+
+/* Decode a block (celp) */
+static int ra288_decode_frame(AVCodecContext * avctx,
+ void *data, int *data_size,
+ uint8_t * buf, int buf_size)
+{
+ int x,y,z,bret;
+ unsigned short int buffer[buf_size];
+ unsigned char b[buf_size],*bp;
+ void *datao;
+ Real288_internal *glob=avctx->priv_data;
+ if(avctx->extradata_size>=6)
+ {
+ int w=avctx->block_align;
+ int h=((short*)(avctx->extradata))[1];
+ int cfs=((short*)(avctx->extradata))[3]; /* coded frame size */
+ int i,j;
+ if(buf_size<w*h) goto no_interleave;
+ bp = buf;
+ for (j = 0; j < h; j++)
+ for (i = 0; i < h/2; i++)
+ {
+ memcpy(&b[i*2*w+j*cfs], bp, cfs);
+ bp += cfs;
+ if(bp-buf>=buf_size) break;
+ }
+ bret=bp-buf;
+ bp = b;
+ }
+ else { no_interleave: bret=buf_size; bp = buf; }
+ datao = data;
+ z=0;
+ while(z<bret)
+ {
+ unpack(buffer,bp,32);
+ for (x=0;x<32;x++)
+ {
+ glob->phasep=(glob->phase=x&7)*5;
+ decode(glob,buffer[x]);
+ for (y=0;y<5;y++) *(((int16_t *)data)++)=8*glob->output[glob->phasep+y];
+ if (glob->phase==3) update(glob);
+ }
+ z+=32;
+ bp+=32;
+ }
+ *data_size = data - datao;
+ return bret;
+}
+
+AVCodec ra_288_decoder =
+{
+ "real_288",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_RA_288,
+ sizeof(Real288_internal),
+ ra288_decode_init,
+ NULL,
+ NULL,
+ ra288_decode_frame,
+};
diff --git a/src/libffmpeg/libavcodec/ratecontrol.c b/src/libffmpeg/libavcodec/ratecontrol.c
index 65efe0a49..80f65d924 100644
--- a/src/libffmpeg/libavcodec/ratecontrol.c
+++ b/src/libffmpeg/libavcodec/ratecontrol.c
@@ -668,7 +668,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s)
if(s->avctx->debug&FF_DEBUG_RC){
printf("%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",
- ff_get_pict_type_char(pict_type), qmin, q, qmax, picture_number, (int)wanted_bits/1000, (int)s->total_bits/1000,
+ av_get_pict_type_char(pict_type), qmin, q, qmax, picture_number, (int)wanted_bits/1000, (int)s->total_bits/1000,
br_compensation, short_term_q, s->frame_bits, pic->mb_var_sum, pic->mc_mb_var_sum, s->bit_rate/1000, (int)fps
);
}
diff --git a/src/libffmpeg/libavcodec/svq1.c b/src/libffmpeg/libavcodec/svq1.c
index dbebde0f7..e416f52da 100644
--- a/src/libffmpeg/libavcodec/svq1.c
+++ b/src/libffmpeg/libavcodec/svq1.c
@@ -24,9 +24,10 @@
/**
* @file svq1.c
- * svq1 decoder.
+ * Sorenson Vector Quantizer #1 (SVQ1) video decoder.
*/
+
//#define DEBUG_SVQ1
#include <stdio.h>
#include <stdlib.h>
@@ -38,20 +39,13 @@
#include "dsputil.h"
#include "mpegvideo.h"
#include "bswap.h"
-#define bit_buffer_t GetBitContext
-
-static inline unsigned int get_bit_cache(GetBitContext *s){
- OPEN_READER(re, s)
- UPDATE_CACHE(re, s)
- return GET_CACHE(re, s);
-// CLOSE_READER(re, s)
-}
-/* variable length (bit) code */
-typedef struct vlc_code_s {
- int16_t value :10,
- length :6;
-} vlc_code_t;
+static VLC svq1_block_type;
+static VLC svq1_motion_component;
+static VLC svq1_intra_multistage[6];
+static VLC svq1_inter_multistage[6];
+static VLC svq1_intra_mean;
+static VLC svq1_inter_mean;
#define MEDIAN(a,b,c) (((a < b) != (b >= c)) ? b : (((a < c) != (c > b)) ? c : a))
@@ -67,468 +61,76 @@ typedef struct svq1_pmv_s {
} svq1_pmv_t;
#include "svq1_cb.h"
-
-/* block type, codes 000 .. 1xx */
-static vlc_code_t svq1_block_type_table[8] = {
- { SVQ1_BLOCK_INTRA, 3 }, { SVQ1_BLOCK_INTER_4V, 3 },
- { SVQ1_BLOCK_INTER, 2 }, { SVQ1_BLOCK_INTER, 2 },
- { SVQ1_BLOCK_SKIP, 1 }, { SVQ1_BLOCK_SKIP, 1 },
- { SVQ1_BLOCK_SKIP, 1 }, { SVQ1_BLOCK_SKIP, 1 }
-};
-
-/* motion vector, codes 0000011 .. 011xxxx */
-static vlc_code_t svq1_motion_table_0[61] = {
- { 7, 8 }, { 6, 8 }, { 5, 8 }, { 4, 7 }, { 4, 7 },
- { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 },
- { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }
-};
-
-/* motion vector, codes 000000000010 ... 0000010111xx */
-static vlc_code_t svq1_motion_table_1[94] = {
- {32, 13}, {31, 13}, {30, 12}, {30, 12}, {29, 12}, {29, 12},
- {28, 12}, {28, 12}, {27, 12}, {27, 12}, {26, 12}, {26, 12}, {25, 12}, {25, 12},
- {24, 11}, {24, 11}, {24, 11}, {24, 11}, {23, 11}, {23, 11}, {23, 11}, {23, 11},
- {22, 11}, {22, 11}, {22, 11}, {22, 11}, {21, 11}, {21, 11}, {21, 11}, {21, 11},
- {20, 11}, {20, 11}, {20, 11}, {20, 11}, {19, 11}, {19, 11}, {19, 11}, {19, 11},
- {18, 11}, {18, 11}, {18, 11}, {18, 11}, {17, 11}, {17, 11}, {17, 11}, {17, 11},
- {16, 11}, {16, 11}, {16, 11}, {16, 11}, {15, 11}, {15, 11}, {15, 11}, {15, 11},
- {14, 11}, {14, 11}, {14, 11}, {14, 11}, {13, 11}, {13, 11}, {13, 11}, {13, 11},
- {12, 11}, {12, 11}, {12, 11}, {12, 11}, {11, 11}, {11, 11}, {11, 11}, {11, 11},
- {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10},
- { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10},
- { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10},
-};
-
-/* inter-coded vector codebook count tables, codes 000000 ... 111111 */
-static vlc_code_t svq1_inter_vector_tables[6][64] = {
- /* 4x2 vector, codes 0000xxx ... 11xxxxx */
- { { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 } },
-
- /* 4x4 vector, codes 0000xxx ... 11xxxxx */
- { { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 } },
-
- /* 8x4 vector, codes 00000xx ... 1xxxxxx */
- { { 6, 5 }, { 6, 5 }, { 5, 5 }, { 5, 5 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } },
-
- /* 8x8 vector, codes 00000xx ... 1xxxxxx */
- { { 6, 5 }, { 6, 5 }, { 5, 5 }, { 5, 5 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } },
-
- /* 16x8 vector, codes 00000xx ... 1xxxxxx */
- { { 6, 5 }, { 6, 5 }, { 5, 5 }, { 5, 5 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } },
-
- /* 16x16 vector, codes 000000x ... 1xxxxxx */
- { { 6, 6 }, { 5, 6 }, { 4, 5 }, { 4, 5 }, { 3, 5 }, { 3, 5 }, { 2, 5 }, { 2, 5 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } }
-};
-
-/* vector codebook count tables, codes 0000000 ... 1111111 */
-static vlc_code_t svq1_intra_vector_tables[6][128] = {
- /* 4x2 vector, codes 00000xx ... 1xxxxxx */
- { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 },
- { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 },
- { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 4x4 vector, codes 0000xxx ... 11xxxxx */
- { { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 } },
-
- /* 8x4 vector, codes 00000xx ... 1xxxxxx */
- { { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 },
- { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 },
- { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 8x8 vector, codes 000000x ... 1xxxxxx */
- { { 2, 6 }, { 2, 6 }, {-1, 6 }, {-1, 6 }, { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 },
- { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 },
- { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 16x8 vector, codes 000000x ... 1xxxxxx */
- { { 4, 6 }, { 4, 6 }, {-1, 6 }, {-1, 6 }, { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 },
- { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 16x16 vector, codes 0000000 ... 1xxxxxx */
- { { 5, 7 }, {-1, 7 }, { 4, 6 }, { 4, 6 }, { 6, 5 }, { 6, 5 }, { 6, 5 }, { 6, 5 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } }
-};
-
-/* intra mean value, codes 00100101 ... 1111xxxx */
-static vlc_code_t svq1_intra_mean_table_0[219] = {
- {135, 8 }, {136, 8 }, {165, 8 },
- {134, 8 }, {129, 8 }, {164, 8 }, {163, 8 }, {133, 8 }, {162, 8 }, {174, 8 }, {175, 8 },
- {161, 8 }, {160, 8 }, {159, 8 }, {158, 8 }, {157, 8 }, {156, 8 }, {155, 8 }, {154, 8 },
- {153, 8 }, {151, 8 }, {152, 8 }, {132, 8 }, {110, 8 }, {131, 8 }, {108, 8 }, {130, 8 },
- {166, 8 }, {105, 8 }, {104, 8 }, {103, 8 }, {127, 8 }, {101, 8 }, {167, 8 }, {168, 8 },
- { 98, 8 }, {128, 8 }, { 48, 8 }, { 95, 8 }, { 62, 8 }, { 93, 8 }, { 92, 8 }, { 91, 8 },
- { 90, 8 }, { 89, 8 }, { 60, 8 }, { 87, 8 }, { 86, 8 }, { 57, 8 }, { 84, 8 }, { 83, 8 },
- { 82, 8 }, { 81, 8 }, { 80, 8 }, { 79, 8 }, { 78, 8 }, { 77, 8 }, { 76, 8 }, { 75, 8 },
- { 74, 8 }, { 73, 8 }, { 72, 8 }, { 71, 8 }, { 70, 8 }, { 69, 8 }, { 68, 8 }, { 67, 8 },
- { 66, 8 }, { 65, 8 }, { 56, 8 }, { 63, 8 }, { 23, 8 }, { 61, 8 }, { 30, 8 }, { 59, 8 },
- { 58, 8 }, { 52, 8 }, { 29, 8 }, { 55, 8 }, { 54, 8 }, { 53, 8 }, { 50, 8 }, { 51, 8 },
- { 22, 8 }, { 49, 8 }, { 85, 7 }, { 85, 7 }, { 97, 7 }, { 97, 7 }, { 88, 7 }, { 88, 7 },
- { 64, 7 }, { 64, 7 }, { 94, 7 }, { 94, 7 }, {106, 7 }, {106, 7 }, {107, 7 }, {107, 7 },
- {109, 7 }, {109, 7 }, {111, 7 }, {111, 7 }, {112, 7 }, {112, 7 }, {113, 7 }, {113, 7 },
- {114, 7 }, {114, 7 }, {115, 7 }, {115, 7 }, {116, 7 }, {116, 7 }, {117, 7 }, {117, 7 },
- {118, 7 }, {118, 7 }, {119, 7 }, {119, 7 }, {120, 7 }, {120, 7 }, { 99, 7 }, { 99, 7 },
- {102, 7 }, {102, 7 }, { 28, 7 }, { 28, 7 }, {100, 7 }, {100, 7 }, { 96, 7 }, { 96, 7 },
- {139, 7 }, {139, 7 }, { 24, 7 }, { 24, 7 }, { 1, 7 }, { 1, 7 }, {138, 7 }, {138, 7 },
- {121, 7 }, {121, 7 }, {122, 7 }, {122, 7 }, {123, 7 }, {123, 7 }, {124, 7 }, {124, 7 },
- {125, 7 }, {125, 7 }, {126, 7 }, {126, 7 }, {137, 7 }, {137, 7 }, {140, 7 }, {140, 7 },
- {150, 7 }, {150, 7 }, {144, 7 }, {144, 7 }, {141, 7 }, {141, 7 }, {142, 7 }, {142, 7 },
- {143, 7 }, {143, 7 }, {145, 7 }, {145, 7 }, {147, 7 }, {147, 7 }, {146, 7 }, {146, 7 },
- { 27, 6 }, { 27, 6 }, { 27, 6 }, { 27, 6 }, {148, 6 }, {148, 6 }, {148, 6 }, {148, 6 },
- {149, 6 }, {149, 6 }, {149, 6 }, {149, 6 }, { 0, 6 }, { 0, 6 }, { 0, 6 }, { 0, 6 },
- { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 },
- { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 },
- { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 },
- { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }
-};
-
-/* intra mean value, codes 0000001101 ... 001001001x */
-static vlc_code_t svq1_intra_mean_table_1[135] = {
- {218, 10}, {219, 10}, {220, 10},
- {221, 10}, {222, 10}, {217, 10}, {230, 10}, {215, 10}, {208, 10}, {207, 10}, {206, 10},
- {214, 10}, {204, 10}, {223, 10}, {224, 10}, {225, 10}, {226, 10}, {227, 10}, {228, 10},
- {229, 10}, {213, 10}, {212, 10}, {231, 10}, {232, 10}, {211, 10}, {210, 10}, {236, 10},
- {209, 10}, {216, 10}, {205, 10}, { 18, 10}, {186, 9 }, {186, 9 }, {185, 9 }, {185, 9 },
- {184, 9 }, {184, 9 }, {182, 9 }, {182, 9 }, {183, 9 }, {183, 9 }, {180, 9 }, {180, 9 },
- {181, 9 }, {181, 9 }, {178, 9 }, {178, 9 }, {187, 9 }, {187, 9 }, {176, 9 }, {176, 9 },
- {188, 9 }, {188, 9 }, {179, 9 }, {179, 9 }, {173, 9 }, {173, 9 }, {172, 9 }, {172, 9 },
- {171, 9 }, {171, 9 }, {170, 9 }, {170, 9 }, {169, 9 }, {169, 9 }, {189, 9 }, {189, 9 },
- {190, 9 }, {190, 9 }, {191, 9 }, {191, 9 }, {192, 9 }, {192, 9 }, {193, 9 }, {193, 9 },
- {194, 9 }, {194, 9 }, {195, 9 }, {195, 9 }, {196, 9 }, {196, 9 }, {197, 9 }, {197, 9 },
- {198, 9 }, {198, 9 }, {200, 9 }, {200, 9 }, {201, 9 }, {201, 9 }, {202, 9 }, {202, 9 },
- {203, 9 }, {203, 9 }, {199, 9 }, {199, 9 }, {177, 9 }, {177, 9 }, { 40, 9 }, { 40, 9 },
- { 39, 9 }, { 39, 9 }, { 38, 9 }, { 38, 9 }, { 37, 9 }, { 37, 9 }, { 36, 9 }, { 36, 9 },
- { 35, 9 }, { 35, 9 }, { 34, 9 }, { 34, 9 }, { 33, 9 }, { 33, 9 }, { 32, 9 }, { 32, 9 },
- { 31, 9 }, { 31, 9 }, { 21, 9 }, { 21, 9 }, { 11, 9 }, { 11, 9 }, { 41, 9 }, { 41, 9 },
- { 45, 9 }, { 45, 9 }, { 44, 9 }, { 44, 9 }, { 42, 9 }, { 42, 9 }, { 43, 9 }, { 43, 9 },
- { 47, 9 }, { 47, 9 }, { 46, 9 }, { 46, 9 }
-};
-
-/* intra mean value, codes 00000000000001 ... 00000011001xxx */
-static vlc_code_t svq1_intra_mean_table_2[207] = {
- {255, 14}, { 14, 14}, { 13, 14}, { 17, 12}, { 17, 12}, { 17, 12}, { 17, 12},
- {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11},
- {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11},
- {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11},
- {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11},
- {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11},
- {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11},
- {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11},
- {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11},
- {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11},
- {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11},
- {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11},
- { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11},
- {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11},
- {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11},
- {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11},
- {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11},
- {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11},
- {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11},
- {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11},
- { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11},
- { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11},
- {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11},
- {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11},
- { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11},
- {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}
-};
-
-/* intra mean value, codes 00000000000000000000 ... 000000000000001xxxxx */
-static vlc_code_t svq1_intra_mean_table_3[64] = {
- { 6, 20}, { 3, 20}, { 4, 20}, { 5, 20}, { 7, 20}, { 8, 20}, { 9, 19}, { 9, 19},
- { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17},
- { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16},
- { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}
+#include "svq1_vlc.h"
+
+static const uint16_t checksum_table[256] = {
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
+ 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
+ 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
+ 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
+ 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
+ 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
+ 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
+ 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
+ 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
+ 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
+ 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
+ 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
+ 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
+ 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
+ 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
+ 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
+ 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
+ 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
+ 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+ 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
+ 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
+ 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
+ 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
+ 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
+ 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
+ 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
+ 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
+ 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
-/* inter mean value, codes 00001011 ... 1xxxxxxx */
-static vlc_code_t svq1_inter_mean_table_0[245] = {
- { 10, 8 }, { 12, 8 }, { 11, 8 }, {-11, 8 }, {-12, 8 },
- {-10, 8 }, { -9, 8 }, { -7, 7 }, { -7, 7 }, { -6, 7 }, { -6, 7 }, { 8, 7 }, { 8, 7 },
- { -8, 7 }, { -8, 7 }, { 9, 7 }, { 9, 7 }, { 6, 7 }, { 6, 7 }, { 7, 7 }, { 7, 7 },
- { -5, 6 }, { -5, 6 }, { -5, 6 }, { -5, 6 }, { -4, 6 }, { -4, 6 }, { -4, 6 }, { -4, 6 },
- { 5, 6 }, { 5, 6 }, { 5, 6 }, { 5, 6 }, { 4, 6 }, { 4, 6 }, { 4, 6 }, { 4, 6 },
- { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 },
- { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 },
- { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 },
- { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 },
- { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 },
- { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }
-};
-
-/* inter mean value, codes 000000010010 ... 00001011xxxx */
-static vlc_code_t svq1_inter_mean_table_1[158] = {
- {-30, 12}, {-31, 12}, {-32, 12}, {-33, 12}, { 31, 12}, {-34, 12},
- {-35, 12}, { 29, 12}, { 30, 12}, { 33, 12}, { 34, 12}, { 32, 12}, {-29, 11}, {-29, 11},
- {-28, 11}, {-28, 11}, { 28, 11}, { 28, 11}, {-27, 11}, {-27, 11}, {-26, 11}, {-26, 11},
- { 27, 11}, { 27, 11}, { 26, 11}, { 26, 11}, { 25, 11}, { 25, 11}, { 24, 11}, { 24, 11},
- { 23, 11}, { 23, 11}, { 22, 11}, { 22, 11}, {-24, 11}, {-24, 11}, {-25, 11}, {-25, 11},
- {-23, 10}, {-23, 10}, {-23, 10}, {-23, 10}, {-21, 10}, {-21, 10}, {-21, 10}, {-21, 10},
- {-20, 10}, {-20, 10}, {-20, 10}, {-20, 10}, {-19, 10}, {-19, 10}, {-19, 10}, {-19, 10},
- {-18, 10}, {-18, 10}, {-18, 10}, {-18, 10}, {-22, 10}, {-22, 10}, {-22, 10}, {-22, 10},
- { 19, 10}, { 19, 10}, { 19, 10}, { 19, 10}, { 21, 10}, { 21, 10}, { 21, 10}, { 21, 10},
- { 20, 10}, { 20, 10}, { 20, 10}, { 20, 10}, { 18, 10}, { 18, 10}, { 18, 10}, { 18, 10},
- {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 },
- {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 },
- { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 },
- { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 },
- { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 },
- { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 },
- { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 },
- {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 },
- {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 },
- {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }
-};
-
-/* inter mean value, codes 000000000010111 ... 0000000100011xx */
-static vlc_code_t svq1_inter_mean_table_2[121] = {
- { 61, 15},
- { 52, 15}, { 58, 15}, {-56, 15}, {-57, 15}, { 59, 15}, {-55, 15}, { 60, 15}, {-54, 15},
- { 53, 15}, {-62, 15}, {-60, 15}, {-59, 15}, {-58, 15}, { 57, 15}, { 56, 15}, {-53, 15},
- { 55, 15}, { 54, 15}, { 50, 14}, { 50, 14}, { 45, 14}, { 45, 14}, {-52, 14}, {-52, 14},
- {-51, 14}, {-51, 14}, {-50, 14}, {-50, 14}, { 46, 14}, { 46, 14}, {-49, 14}, {-49, 14},
- {-48, 14}, {-48, 14}, { 48, 14}, { 48, 14}, {-47, 14}, {-47, 14}, { 49, 14}, { 49, 14},
- {-45, 14}, {-45, 14}, {-44, 14}, {-44, 14}, { 47, 14}, { 47, 14}, { 51, 14}, { 51, 14},
- { 44, 14}, { 44, 14}, {-46, 14}, {-46, 14}, {-43, 13}, {-43, 13}, {-43, 13}, {-43, 13},
- {-42, 13}, {-42, 13}, {-42, 13}, {-42, 13}, {-41, 13}, {-41, 13}, {-41, 13}, {-41, 13},
- {-40, 13}, {-40, 13}, {-40, 13}, {-40, 13}, {-39, 13}, {-39, 13}, {-39, 13}, {-39, 13},
- {-38, 13}, {-38, 13}, {-38, 13}, {-38, 13}, {-37, 13}, {-37, 13}, {-37, 13}, {-37, 13},
- {-36, 13}, {-36, 13}, {-36, 13}, {-36, 13}, { 42, 13}, { 42, 13}, { 42, 13}, { 42, 13},
- { 36, 13}, { 36, 13}, { 36, 13}, { 36, 13}, { 43, 13}, { 43, 13}, { 43, 13}, { 43, 13},
- { 41, 13}, { 41, 13}, { 41, 13}, { 41, 13}, { 40, 13}, { 40, 13}, { 40, 13}, { 40, 13},
- { 35, 13}, { 35, 13}, { 35, 13}, { 35, 13}, { 39, 13}, { 39, 13}, { 39, 13}, { 39, 13},
- { 38, 13}, { 38, 13}, { 38, 13}, { 38, 13}, { 37, 13}, { 37, 13}, { 37, 13}, { 37, 13}
-};
-
-/* inter mean value, codes 000000000000100101 ... 0000000000101101xx */
-static vlc_code_t svq1_inter_mean_table_3[147] = {
- {111, 18}, {102, 18}, { 99, 18},
- {-86, 18}, { 97, 18}, {-97, 18}, { 96, 18}, {-95, 18}, {-76, 18}, {-77, 18}, {-78, 18},
- {-85, 18}, {-80, 18}, {-81, 18}, { 89, 18}, { 90, 18}, {-84, 18}, {-89, 18}, { 80, 18},
- {-90, 18}, {-88, 18}, { 92, 18}, { 93, 18}, { 95, 18}, {-109,18}, {-79, 17}, {-79, 17},
- {-83, 17}, {-83, 17}, {-75, 17}, {-75, 17}, {-74, 17}, {-74, 17}, {-73, 17}, {-73, 17},
- {-72, 17}, {-72, 17}, { 87, 17}, { 87, 17}, { 86, 17}, { 86, 17}, { 75, 17}, { 75, 17},
- { 85, 17}, { 85, 17}, { 84, 17}, { 84, 17}, { 81, 17}, { 81, 17}, { 79, 17}, { 79, 17},
- { 74, 17}, { 74, 17}, { 72, 17}, { 72, 17}, { 82, 17}, { 82, 17}, { 78, 17}, { 78, 17},
- { 83, 17}, { 83, 17}, { 76, 17}, { 76, 17}, { 73, 17}, { 73, 17}, { 77, 17}, { 77, 17},
- { 70, 16}, { 70, 16}, { 70, 16}, { 70, 16}, { 69, 16}, { 69, 16}, { 69, 16}, { 69, 16},
- { 64, 16}, { 64, 16}, { 64, 16}, { 64, 16}, {-68, 16}, {-68, 16}, {-68, 16}, {-68, 16},
- {-66, 16}, {-66, 16}, {-66, 16}, {-66, 16}, { 68, 16}, { 68, 16}, { 68, 16}, { 68, 16},
- {-69, 16}, {-69, 16}, {-69, 16}, {-69, 16}, { 65, 16}, { 65, 16}, { 65, 16}, { 65, 16},
- { 71, 16}, { 71, 16}, { 71, 16}, { 71, 16}, {-70, 16}, {-70, 16}, {-70, 16}, {-70, 16},
- {-65, 16}, {-65, 16}, {-65, 16}, {-65, 16}, {-67, 16}, {-67, 16}, {-67, 16}, {-67, 16},
- {-63, 16}, {-63, 16}, {-63, 16}, {-63, 16}, {-71, 16}, {-71, 16}, {-71, 16}, {-71, 16},
- { 67, 16}, { 67, 16}, { 67, 16}, { 67, 16}, {-61, 16}, {-61, 16}, {-61, 16}, {-61, 16},
- {-64, 16}, {-64, 16}, {-64, 16}, {-64, 16}, { 63, 16}, { 63, 16}, { 63, 16}, { 63, 16},
- { 62, 16}, { 62, 16}, { 62, 16}, { 62, 16}, { 66, 16}, { 66, 16}, { 66, 16}, { 66, 16}
-};
-
-/* inter mean value, codes 00000000000001001001 ... 0000000000001001001x */
-static vlc_code_t svq1_inter_mean_table_4[75] = {
- {142, 20}, {135, 20}, {125, 20}, {123, 20}, {122, 20}, {119, 20}, {117, 20},
- {113, 20}, {104, 20}, {103, 20}, {-120,20}, {-114,20}, {-108,20}, {-104,20}, {-102,20},
- {-101,20}, {-93, 20}, {-91, 19}, {-91, 19}, {-96, 19}, {-96, 19}, { 88, 19}, { 88, 19},
- { 91, 19}, { 91, 19}, { 94, 19}, { 94, 19}, {121, 19}, {121, 19}, {120, 19}, {120, 19},
- {-110,19}, {-110,19}, {118, 19}, {118, 19}, {115, 19}, {115, 19}, {114, 19}, {114, 19},
- {112, 19}, {112, 19}, {107, 19}, {107, 19}, {110, 19}, {110, 19}, {109, 19}, {109, 19},
- {108, 19}, {108, 19}, {-103,19}, {-103,19}, {106, 19}, {106, 19}, {105, 19}, {105, 19},
- {-100,19}, {-100,19}, {101, 19}, {101, 19}, {100, 19}, {100, 19}, {-99, 19}, {-99, 19},
- {-82, 19}, {-82, 19}, {-87, 19}, {-87, 19}, {-94, 19}, {-94, 19}, {-98, 19}, {-98, 19},
- { 98, 19}, { 98, 19}, {-92, 19}, {-92, 19}
-};
-
-/* inter mean value, codes 0000000000000000000000 ... 000000000000010010001x */
-static vlc_code_t svq1_inter_mean_table_5[292] = {
- {255, 22}, {254, 22}, {253, 22}, {252, 22}, {251, 22}, {250, 22}, {249, 22}, {248, 22},
- {247, 22}, {246, 22}, {245, 22}, {244, 22}, {243, 22}, {242, 22}, {241, 22}, {240, 22},
- {239, 22}, {238, 22}, {237, 22}, {236, 22}, {235, 22}, {234, 22}, {233, 22}, {232, 22},
- {231, 22}, {230, 22}, {229, 22}, {228, 22}, {227, 22}, {226, 22}, {225, 22}, {224, 22},
- {223, 22}, {222, 22}, {221, 22}, {220, 22}, {219, 22}, {218, 22}, {217, 22}, {216, 22},
- {215, 22}, {214, 22}, {213, 22}, {212, 22}, {211, 22}, {210, 22}, {209, 22}, {208, 22},
- {207, 22}, {206, 22}, {205, 22}, {204, 22}, {203, 22}, {202, 22}, {201, 22}, {200, 22},
- {199, 22}, {198, 22}, {197, 22}, {196, 22}, {195, 22}, {194, 22}, {193, 22}, {192, 22},
- {191, 22}, {190, 22}, {189, 22}, {188, 22}, {187, 22}, {186, 22}, {185, 22}, {184, 22},
- {183, 22}, {182, 22}, {181, 22}, {180, 22}, {179, 22}, {178, 22}, {177, 22}, {176, 22},
- {175, 22}, {174, 22}, {173, 22}, {172, 22}, {171, 22}, {170, 22}, {169, 22}, {168, 22},
- {167, 22}, {166, 22}, {-256,22}, {164, 22}, {-211,22}, {162, 22}, {161, 22}, {160, 22},
- {-210,22}, {-168,22}, {157, 22}, {156, 22}, {155, 22}, {154, 22}, {153, 22}, {152, 22},
- {151, 22}, {150, 22}, {149, 22}, {148, 22}, {147, 22}, {146, 22}, {145, 22}, {144, 22},
- {143, 22}, {-208,22}, {141, 22}, {140, 22}, {139, 22}, {-200,22}, {137, 22}, {136, 22},
- {-198,22}, {134, 22}, {133, 22}, {-196,22}, {-201,22}, {130, 22}, {129, 22}, {128, 22},
- {127, 22}, {126, 22}, {-195,22}, {124, 22}, {-167,22}, {-166,22}, {-165,22}, {-164,22},
- {-163,22}, {-162,22}, {-161,22}, {-180,22}, {-160,22}, {-159,22}, {-158,22}, {-157,22},
- {-156,22}, {-155,22}, {-154,22}, {-153,22}, {-152,22}, {-151,22}, {-150,22}, {-149,22},
- {-148,22}, {-147,22}, {-146,22}, {-145,22}, {-144,22}, {-143,22}, {-142,22}, {-141,22},
- {-140,22}, {-139,22}, {-138,22}, {-137,22}, {-136,22}, {-135,22}, {-134,22}, {-133,22},
- {-132,22}, {-131,22}, {-130,22}, {-129,22}, {-126,22}, {-125,22}, {-124,22}, {-123,22},
- {-122,22}, {-121,22}, {-118,22}, {-116,22}, {-115,22}, {-113,22}, {-112,22}, {-107,22},
- {-106,22}, {-169,22}, {-170,22}, {-171,22}, {-172,22}, {-173,22}, {-174,22}, {-175,22},
- {-176,22}, {-177,22}, {-178,22}, {-187,22}, {-179,22}, {-181,22}, {-182,22}, {-183,22},
- {-184,22}, {-185,22}, {-186,22}, {-235,22}, {-188,22}, {-189,22}, {-190,22}, {-191,22},
- {-192,22}, {-193,22}, {-194,22}, {-197,22}, {-255,22}, {-254,22}, {-253,22}, {-252,22},
- {-251,22}, {-250,22}, {-249,22}, {-248,22}, {-247,22}, {-246,22}, {-245,22}, {-244,22},
- {-243,22}, {-242,22}, {-241,22}, {-240,22}, {-239,22}, {-238,22}, {-237,22}, {-232,22},
- {-236,22}, {-234,22}, {-233,22}, {-217,22}, {-231,22}, {-230,22}, {-229,22}, {-228,22},
- {-227,22}, {-226,22}, {-225,22}, {-224,22}, {-223,22}, {-222,22}, {-221,22}, {-220,22},
- {-219,22}, {-216,22}, {-202,22}, {-205,22}, {-215,22}, {-214,22}, {-213,22}, {-204,22},
- {-212,22}, {-209,22}, {-218,22}, {-199,22}, {-207,22}, {-206,22}, {165, 21}, {165, 21},
- {131, 21}, {131, 21}, {163, 21}, {163, 21}, {-203,21}, {-203,21}, {116, 21}, {116, 21},
- {159, 21}, {159, 21}, {138, 21}, {138, 21}, {158, 21}, {158, 21}, {-105,21}, {-105,21},
- {-111,21}, {-111,21}, {132, 21}, {132, 21}, {128, 21}, {128, 21}, {-127,21}, {-127,21},
- {-119,21}, {-119,21}, {-117,21}, {-117,21}
+static const uint8_t string_table[256] = {
+ 0x00, 0xD5, 0x7F, 0xAA, 0xFE, 0x2B, 0x81, 0x54,
+ 0x29, 0xFC, 0x56, 0x83, 0xD7, 0x02, 0xA8, 0x7D,
+ 0x52, 0x87, 0x2D, 0xF8, 0xAC, 0x79, 0xD3, 0x06,
+ 0x7B, 0xAE, 0x04, 0xD1, 0x85, 0x50, 0xFA, 0x2F,
+ 0xA4, 0x71, 0xDB, 0x0E, 0x5A, 0x8F, 0x25, 0xF0,
+ 0x8D, 0x58, 0xF2, 0x27, 0x73, 0xA6, 0x0C, 0xD9,
+ 0xF6, 0x23, 0x89, 0x5C, 0x08, 0xDD, 0x77, 0xA2,
+ 0xDF, 0x0A, 0xA0, 0x75, 0x21, 0xF4, 0x5E, 0x8B,
+ 0x9D, 0x48, 0xE2, 0x37, 0x63, 0xB6, 0x1C, 0xC9,
+ 0xB4, 0x61, 0xCB, 0x1E, 0x4A, 0x9F, 0x35, 0xE0,
+ 0xCF, 0x1A, 0xB0, 0x65, 0x31, 0xE4, 0x4E, 0x9B,
+ 0xE6, 0x33, 0x99, 0x4C, 0x18, 0xCD, 0x67, 0xB2,
+ 0x39, 0xEC, 0x46, 0x93, 0xC7, 0x12, 0xB8, 0x6D,
+ 0x10, 0xC5, 0x6F, 0xBA, 0xEE, 0x3B, 0x91, 0x44,
+ 0x6B, 0xBE, 0x14, 0xC1, 0x95, 0x40, 0xEA, 0x3F,
+ 0x42, 0x97, 0x3D, 0xE8, 0xBC, 0x69, 0xC3, 0x16,
+ 0xEF, 0x3A, 0x90, 0x45, 0x11, 0xC4, 0x6E, 0xBB,
+ 0xC6, 0x13, 0xB9, 0x6C, 0x38, 0xED, 0x47, 0x92,
+ 0xBD, 0x68, 0xC2, 0x17, 0x43, 0x96, 0x3C, 0xE9,
+ 0x94, 0x41, 0xEB, 0x3E, 0x6A, 0xBF, 0x15, 0xC0,
+ 0x4B, 0x9E, 0x34, 0xE1, 0xB5, 0x60, 0xCA, 0x1F,
+ 0x62, 0xB7, 0x1D, 0xC8, 0x9C, 0x49, 0xE3, 0x36,
+ 0x19, 0xCC, 0x66, 0xB3, 0xE7, 0x32, 0x98, 0x4D,
+ 0x30, 0xE5, 0x4F, 0x9A, 0xCE, 0x1B, 0xB1, 0x64,
+ 0x72, 0xA7, 0x0D, 0xD8, 0x8C, 0x59, 0xF3, 0x26,
+ 0x5B, 0x8E, 0x24, 0xF1, 0xA5, 0x70, 0xDA, 0x0F,
+ 0x20, 0xF5, 0x5F, 0x8A, 0xDE, 0x0B, 0xA1, 0x74,
+ 0x09, 0xDC, 0x76, 0xA3, 0xF7, 0x22, 0x88, 0x5D,
+ 0xD6, 0x03, 0xA9, 0x7C, 0x28, 0xFD, 0x57, 0x82,
+ 0xFF, 0x2A, 0x80, 0x55, 0x01, 0xD4, 0x7E, 0xAB,
+ 0x84, 0x51, 0xFB, 0x2E, 0x7A, 0xAF, 0x05, 0xD0,
+ 0xAD, 0x78, 0xD2, 0x07, 0x53, 0x86, 0x2C, 0xF9
};
#define SVQ1_PROCESS_VECTOR()\
@@ -606,9 +208,8 @@ static vlc_code_t svq1_inter_mean_table_5[292] = {
mean -= (stages * 128);\
n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF);
-static int svq1_decode_block_intra (bit_buffer_t *bitbuf, uint8_t *pixels, int pitch ) {
+static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) {
uint32_t bit_cache;
- vlc_code_t *vlc;
uint8_t *list[63];
uint32_t *dst;
const uint32_t *codebook;
@@ -631,13 +232,7 @@ static int svq1_decode_block_intra (bit_buffer_t *bitbuf, uint8_t *pixels, int p
height = 1 << ((3 + level) /2);
/* get number of stages (-1 skips vector, 0 for mean only) */
- bit_cache = get_bit_cache (bitbuf);
-
- vlc = &svq1_intra_vector_tables[level][bit_cache >> (32 - 7)];
-
- /* flush bits */
- stages = vlc->value;
- skip_bits(bitbuf,vlc->length);
+ stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1;
if (stages == -1) {
for (y=0; y < height; y++) {
@@ -653,21 +248,7 @@ static int svq1_decode_block_intra (bit_buffer_t *bitbuf, uint8_t *pixels, int p
return -1; /* invalid vector */
}
- /* get mean value for vector */
- bit_cache = get_bit_cache (bitbuf);
-
- if (bit_cache >= 0x25000000)
- vlc = &svq1_intra_mean_table_0[(bit_cache >> (32 - 8)) - 37];
- else if (bit_cache >= 0x03400000)
- vlc = &svq1_intra_mean_table_1[(bit_cache >> (32 - 10)) - 13];
- else if (bit_cache >= 0x00040000)
- vlc = &svq1_intra_mean_table_2[(bit_cache >> (32 - 14)) - 1];
- else
- vlc = &svq1_intra_mean_table_3[bit_cache >> (32 - 20)];
-
- /* flush bits */
- mean = vlc->value;
- skip_bits(bitbuf,vlc->length);
+ mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3);
if (stages == 0) {
for (y=0; y < height; y++) {
@@ -682,9 +263,8 @@ static int svq1_decode_block_intra (bit_buffer_t *bitbuf, uint8_t *pixels, int p
return 0;
}
-static int svq1_decode_block_non_intra (bit_buffer_t *bitbuf, uint8_t *pixels, int pitch ) {
+static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, int pitch ) {
uint32_t bit_cache;
- vlc_code_t *vlc;
uint8_t *list[63];
uint32_t *dst;
const uint32_t *codebook;
@@ -707,13 +287,7 @@ static int svq1_decode_block_non_intra (bit_buffer_t *bitbuf, uint8_t *pixels, i
height = 1 << ((3 + level) /2);
/* get number of stages (-1 skips vector, 0 for mean only) */
- bit_cache = get_bit_cache (bitbuf);
-
- vlc = &svq1_inter_vector_tables[level][bit_cache >> (32 - 6)];
-
- /* flush bits */
- stages = vlc->value;
- skip_bits(bitbuf,vlc->length);
+ stages = get_vlc2(bitbuf, svq1_inter_multistage[level].table, 3, 2) - 1;
if (stages == -1) continue; /* skip vector */
@@ -724,25 +298,7 @@ static int svq1_decode_block_non_intra (bit_buffer_t *bitbuf, uint8_t *pixels, i
return -1; /* invalid vector */
}
- /* get mean value for vector */
- bit_cache = get_bit_cache (bitbuf);
-
- if (bit_cache >= 0x0B000000)
- vlc = &svq1_inter_mean_table_0[(bit_cache >> (32 - 8)) - 11];
- else if (bit_cache >= 0x01200000)
- vlc = &svq1_inter_mean_table_1[(bit_cache >> (32 - 12)) - 18];
- else if (bit_cache >= 0x002E0000)
- vlc = &svq1_inter_mean_table_2[(bit_cache >> (32 - 15)) - 23];
- else if (bit_cache >= 0x00094000)
- vlc = &svq1_inter_mean_table_3[(bit_cache >> (32 - 18)) - 37];
- else if (bit_cache >= 0x00049000)
- vlc = &svq1_inter_mean_table_4[(bit_cache >> (32 - 20)) - 73];
- else
- vlc = &svq1_inter_mean_table_5[bit_cache >> (32 - 22)];
-
- /* flush bits */
- mean = vlc->value;
- skip_bits(bitbuf,vlc->length);
+ mean = get_vlc2(bitbuf, svq1_inter_mean.table, 9, 3) - 256;
SVQ1_CALC_CODEBOOK_ENTRIES(svq1_inter_codebooks);
SVQ1_DO_CODEBOOK_NONINTRA()
@@ -750,40 +306,14 @@ static int svq1_decode_block_non_intra (bit_buffer_t *bitbuf, uint8_t *pixels, i
return 0;
}
-static int svq1_decode_motion_vector (bit_buffer_t *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {
- uint32_t bit_cache;
- vlc_code_t *vlc;
- int diff, sign;
+static int svq1_decode_motion_vector (GetBitContext *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {
+ int diff;
int i;
for (i=0; i < 2; i++) {
/* get motion code */
- bit_cache = get_bit_cache (bitbuf);
-
- if (!(bit_cache & 0xFFE00000))
- return -1; /* invalid vlc code */
-
- if (bit_cache & 0x80000000) {
- diff = 0;
-
- /* flush bit */
- skip_bits(bitbuf,1);
-
- } else {
- if (bit_cache >= 0x06000000) {
- vlc = &svq1_motion_table_0[(bit_cache >> (32 - 7)) - 3];
- } else {
- vlc = &svq1_motion_table_1[(bit_cache >> (32 - 12)) - 2];
- }
-
- /* decode motion vector differential */
- sign = (int) (bit_cache << (vlc->length - 1)) >> 31;
- diff = (vlc->value ^ sign) - sign;
-
- /* flush bits */
- skip_bits(bitbuf,vlc->length);
- }
+ diff = get_vlc2(bitbuf, svq1_motion_component.table, 7, 2) - 32;
/* add median of motion vector predictors and clip result */
if (i == 1)
@@ -810,7 +340,7 @@ static void svq1_skip_block (uint8_t *current, uint8_t *previous, int pitch, int
}
}
-static int svq1_motion_inter_block (MpegEncContext *s, bit_buffer_t *bitbuf,
+static int svq1_motion_inter_block (MpegEncContext *s, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous, int pitch,
svq1_pmv_t *motion, int x, int y) {
uint8_t *src;
@@ -862,7 +392,7 @@ static int svq1_motion_inter_block (MpegEncContext *s, bit_buffer_t *bitbuf,
return 0;
}
-static int svq1_motion_inter_4v_block (MpegEncContext *s, bit_buffer_t *bitbuf,
+static int svq1_motion_inter_4v_block (MpegEncContext *s, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous, int pitch,
svq1_pmv_t *motion,int x, int y) {
uint8_t *src;
@@ -952,19 +482,14 @@ static int svq1_motion_inter_4v_block (MpegEncContext *s, bit_buffer_t *bitbuf,
return 0;
}
-static int svq1_decode_delta_block (MpegEncContext *s, bit_buffer_t *bitbuf,
+static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf,
uint8_t *current, uint8_t *previous, int pitch,
svq1_pmv_t *motion, int x, int y) {
- uint32_t bit_cache;
uint32_t block_type;
int result = 0;
/* get block type */
- bit_cache = get_bit_cache (bitbuf);
-
- bit_cache >>= (32 - 3);
- block_type = svq1_block_type_table[bit_cache].value;
- skip_bits(bitbuf,svq1_block_type_table[bit_cache].length);
+ block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);
/* reset motion vectors */
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
@@ -1021,11 +546,50 @@ static struct { int width; int height; } svq1_frame_size_table[8] = {
{ 704, 576 }, { 240, 180 }, { 320, 240 }, { -1, -1 }
};
-static int svq1_decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {
+static uint16_t svq1_packet_checksum (uint8_t *data, int length, int value) {
+ int i;
+
+ for (i=0; i < length; i++) {
+ value = checksum_table[data[i] ^ (value >> 8)] ^ ((value & 0xFF) << 8);
+ }
+
+ return value;
+}
+
+static uint16_t svq1_component_checksum (uint16_t *pixels, int pitch,
+ int width, int height, int value) {
+ int x, y;
+
+ for (y=0; y < height; y++) {
+ for (x=0; x < width; x++) {
+ value = checksum_table[pixels[x] ^ (value >> 8)] ^ ((value & 0xFF) << 8);
+ }
+
+ pixels += pitch;
+ }
+
+ return value;
+}
+
+static void svq1_parse_string (GetBitContext *bitbuf, uint8_t *out) {
+ uint8_t seed;
+ int i;
+
+ out[0] = get_bits (bitbuf, 8);
+
+ seed = string_table[out[0]];
+
+ for (i=1; i < out[0]; i++) {
+ out[i] = get_bits (bitbuf, 8) ^ seed;
+ seed = string_table[out[i] ^ seed];
+ }
+}
+
+static int svq1_decode_frame_header (GetBitContext *bitbuf,MpegEncContext *s) {
int frame_size_code;
+ int temporal_reference;
- /* unknown field */
- get_bits (bitbuf, 8);
+ temporal_reference = get_bits (bitbuf, 8);
/* frame type */
s->pict_type= get_bits (bitbuf, 2)+1;
@@ -1036,11 +600,20 @@ static int svq1_decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {
/* unknown fields */
if (s->f_code == 0x50 || s->f_code == 0x60) {
- get_bits (bitbuf, 16);
+ int csum = get_bits (bitbuf, 16);
+
+ csum = svq1_packet_checksum ((uint8_t *)bitbuf->buffer, bitbuf->size_in_bits>>3, csum);
+
+// printf ("%s checksum (%02x) for packet data\n",
+// (csum == 0) ? "correct" : "incorrect", csum);
}
if ((s->f_code ^ 0x10) >= 0x50) {
- skip_bits(bitbuf,8*get_bits (bitbuf, 8));
+ char msg[256];
+
+ svq1_parse_string (bitbuf, (char *) msg);
+
+ printf ("embedded message: \"%s\"\n", (char *) msg);
}
get_bits (bitbuf, 2);
@@ -1066,8 +639,8 @@ static int svq1_decode_frame_header (bit_buffer_t *bitbuf,MpegEncContext *s) {
/* unknown fields */
if (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 1);
- get_bits (bitbuf, 1);
+ get_bits (bitbuf, 1); /* use packet checksum if (1) */
+ get_bits (bitbuf, 1); /* component checksums after image data if (1) */
if (get_bits (bitbuf, 2) != 0)
return -1;
@@ -1208,6 +781,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
static int svq1_decode_init(AVCodecContext *avctx)
{
MpegEncContext *s = avctx->priv_data;
+ int i;
s->avctx = avctx;
s->width = (avctx->width+3)&~3;
@@ -1217,6 +791,32 @@ static int svq1_decode_init(AVCodecContext *avctx)
avctx->has_b_frames= 1; // not true, but DP frames and these behave like unidirectional b frames
s->flags= avctx->flags;
if (MPV_common_init(s) < 0) return -1;
+
+ init_vlc(&svq1_block_type, 2, 4,
+ &svq1_block_type_vlc[0][1], 2, 1,
+ &svq1_block_type_vlc[0][0], 2, 1);
+
+ init_vlc(&svq1_motion_component, 7, 65,
+ &svq1_motion_component_vlc[0][1], 4, 2,
+ &svq1_motion_component_vlc[0][0], 4, 2);
+
+ for (i = 0; i < 6; i++) {
+ init_vlc(&svq1_intra_multistage[i], 3, 8,
+ &svq1_intra_multistage_vlc[i][0][1], 2, 1,
+ &svq1_intra_multistage_vlc[i][0][0], 2, 1);
+ init_vlc(&svq1_inter_multistage[i], 3, 8,
+ &svq1_inter_multistage_vlc[i][0][1], 2, 1,
+ &svq1_inter_multistage_vlc[i][0][0], 2, 1);
+ }
+
+ init_vlc(&svq1_intra_mean, 8, 256,
+ &svq1_intra_mean_vlc[0][1], 4, 2,
+ &svq1_intra_mean_vlc[0][0], 4, 2);
+
+ init_vlc(&svq1_inter_mean, 9, 512,
+ &svq1_inter_mean_vlc[0][1], 4, 2,
+ &svq1_inter_mean_vlc[0][0], 4, 2);
+
return 0;
}
diff --git a/src/libffmpeg/libavcodec/svq1_vlc.h b/src/libffmpeg/libavcodec/svq1_vlc.h
new file mode 100644
index 000000000..fa6efb860
--- /dev/null
+++ b/src/libffmpeg/libavcodec/svq1_vlc.h
@@ -0,0 +1,283 @@
+#ifndef SVQ1_VLC_H
+#define SVQ1_VLC_H
+
+/* values in this table range from 0..3; adjust retrieved value by +0 */
+static const uint8_t svq1_block_type_vlc[4][2] = {
+ /* { code, length } */
+ { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 }, { 0x0, 3 }
+
+};
+
+/* values in this table range from -32..32; adjust retrieved value by -32 */
+static const uint16_t svq1_motion_component_vlc[65][2] = {
+ /* { code, length } */
+ { 0x5, 13 }, { 0x7, 13 }, { 0x5, 12 }, { 0x7, 12 },
+ { 0x9, 12 }, { 0xB, 12 }, { 0xD, 12 }, { 0xF, 12 },
+ { 0x9, 11 }, { 0xB, 11 }, { 0xD, 11 }, { 0xF, 11 },
+ { 0x11, 11 }, { 0x13, 11 }, { 0x15, 11 }, { 0x17, 11 },
+ { 0x19, 11 }, { 0x1B, 11 }, { 0x1D, 11 }, { 0x1F, 11 },
+ { 0x21, 11 }, { 0x23, 11 }, { 0x13, 10 }, { 0x15, 10 },
+ { 0x17, 10 }, { 0x7, 8 }, { 0x9, 8 }, { 0xB, 8 },
+ { 0x7, 7 }, { 0x3, 5 }, { 0x3, 4 }, { 0x3, 3 },
+ { 0x1, 1 }, { 0x2, 3 }, { 0x2, 4 }, { 0x2, 5 },
+ { 0x6, 7 }, { 0xA, 8 }, { 0x8, 8 }, { 0x6, 8 },
+ { 0x16, 10 }, { 0x14, 10 }, { 0x12, 10 }, { 0x22, 11 },
+ { 0x20, 11 }, { 0x1E, 11 }, { 0x1C, 11 }, { 0x1A, 11 },
+ { 0x18, 11 }, { 0x16, 11 }, { 0x14, 11 }, { 0x12, 11 },
+ { 0x10, 11 }, { 0xE, 11 }, { 0xC, 11 }, { 0xA, 11 },
+ { 0x8, 11 }, { 0xE, 12 }, { 0xC, 12 }, { 0xA, 12 },
+ { 0x8, 12 }, { 0x6, 12 }, { 0x4, 12 }, { 0x6, 13 },
+ { 0x4, 13 }
+};
+
+/* values in this table range from -1..6; adjust retrieved value by -1 */
+static const uint8_t svq1_intra_multistage_vlc[6][8][2] = {
+ /* { code, length } */
+{
+ { 0x1, 5 }, { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 },
+ { 0x3, 4 }, { 0x2, 4 }, { 0x0, 5 }, { 0x1, 4 }
+},{
+ { 0x1, 4 }, { 0x3, 2 }, { 0x5, 3 }, { 0x4, 3 },
+ { 0x3, 3 }, { 0x2, 3 }, { 0x0, 4 }, { 0x1, 3 }
+},{
+ { 0x1, 5 }, { 0x1, 1 }, { 0x3, 3 }, { 0x0, 5 },
+ { 0x3, 4 }, { 0x2, 3 }, { 0x2, 4 }, { 0x1, 4 }
+},{
+ { 0x1, 6 }, { 0x1, 1 }, { 0x1, 2 }, { 0x0, 6 },
+ { 0x3, 4 }, { 0x2, 4 }, { 0x1, 5 }, { 0x1, 4 }
+},{
+ { 0x1, 6 }, { 0x1, 1 }, { 0x1, 2 }, { 0x3, 5 },
+ { 0x2, 5 }, { 0x0, 6 }, { 0x1, 5 }, { 0x1, 3 }
+},{
+ { 0x1, 7 }, { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 },
+ { 0x1, 4 }, { 0x1, 6 }, { 0x0, 7 }, { 0x1, 5 }
+}
+};
+
+/* values in this table range from -1..6; adjust retrieved value by -1 */
+static const uint8_t svq1_inter_multistage_vlc[6][8][2] = {
+ /* { code, length } */
+{
+ { 0x3, 2 }, { 0x5, 3 }, { 0x4, 3 }, { 0x3, 3 },
+ { 0x2, 3 }, { 0x1, 3 }, { 0x1, 4 }, { 0x0, 4 }
+},{
+ { 0x3, 2 }, { 0x5, 3 }, { 0x4, 3 }, { 0x3, 3 },
+ { 0x2, 3 }, { 0x1, 3 }, { 0x1, 4 }, { 0x0, 4 }
+},{
+ { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 }, { 0x3, 4 },
+ { 0x2, 4 }, { 0x1, 4 }, { 0x1, 5 }, { 0x0, 5 }
+},{
+ { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 }, { 0x3, 4 },
+ { 0x2, 4 }, { 0x1, 4 }, { 0x1, 5 }, { 0x0, 5 }
+},{
+ { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 }, { 0x3, 4 },
+ { 0x2, 4 }, { 0x1, 4 }, { 0x1, 5 }, { 0x0, 5 }
+},{
+ { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 }, { 0x3, 5 },
+ { 0x2, 5 }, { 0x1, 5 }, { 0x1, 6 }, { 0x0, 6 }
+}
+};
+
+/* values in this table range from 0..255; adjust retrieved value by +0 */
+static const uint16_t svq1_intra_mean_vlc[256][2] = {
+ /* { code, length } */
+ { 0x37, 6 }, { 0x56, 7 }, { 0x1, 17 }, { 0x1, 20 },
+ { 0x2, 20 }, { 0x3, 20 }, { 0x0, 20 }, { 0x4, 20 },
+ { 0x5, 20 }, { 0x3, 19 }, { 0x15, 11 }, { 0x42, 9 },
+ { 0x14, 11 }, { 0x3, 14 }, { 0x2, 14 }, { 0x1, 15 },
+ { 0x1, 16 }, { 0x1, 12 }, { 0x2B, 10 }, { 0x18, 11 },
+ { 0xC, 11 }, { 0x41, 9 }, { 0x78, 8 }, { 0x6C, 8 },
+ { 0x55, 7 }, { 0xF, 4 }, { 0xE, 4 }, { 0x34, 6 },
+ { 0x51, 7 }, { 0x72, 8 }, { 0x6E, 8 }, { 0x40, 9 },
+ { 0x3F, 9 }, { 0x3E, 9 }, { 0x3D, 9 }, { 0x3C, 9 },
+ { 0x3B, 9 }, { 0x3A, 9 }, { 0x39, 9 }, { 0x38, 9 },
+ { 0x37, 9 }, { 0x43, 9 }, { 0x46, 9 }, { 0x47, 9 },
+ { 0x45, 9 }, { 0x44, 9 }, { 0x49, 9 }, { 0x48, 9 },
+ { 0x4A, 8 }, { 0x79, 8 }, { 0x76, 8 }, { 0x77, 8 },
+ { 0x71, 8 }, { 0x75, 8 }, { 0x74, 8 }, { 0x73, 8 },
+ { 0x6A, 8 }, { 0x55, 8 }, { 0x70, 8 }, { 0x6F, 8 },
+ { 0x52, 8 }, { 0x6D, 8 }, { 0x4C, 8 }, { 0x6B, 8 },
+ { 0x40, 7 }, { 0x69, 8 }, { 0x68, 8 }, { 0x67, 8 },
+ { 0x66, 8 }, { 0x65, 8 }, { 0x64, 8 }, { 0x63, 8 },
+ { 0x62, 8 }, { 0x61, 8 }, { 0x60, 8 }, { 0x5F, 8 },
+ { 0x5E, 8 }, { 0x5D, 8 }, { 0x5C, 8 }, { 0x5B, 8 },
+ { 0x5A, 8 }, { 0x59, 8 }, { 0x58, 8 }, { 0x57, 8 },
+ { 0x56, 8 }, { 0x3D, 7 }, { 0x54, 8 }, { 0x53, 8 },
+ { 0x3F, 7 }, { 0x51, 8 }, { 0x50, 8 }, { 0x4F, 8 },
+ { 0x4E, 8 }, { 0x4D, 8 }, { 0x41, 7 }, { 0x4B, 8 },
+ { 0x53, 7 }, { 0x3E, 7 }, { 0x48, 8 }, { 0x4F, 7 },
+ { 0x52, 7 }, { 0x45, 8 }, { 0x50, 7 }, { 0x43, 8 },
+ { 0x42, 8 }, { 0x41, 8 }, { 0x42, 7 }, { 0x43, 7 },
+ { 0x3E, 8 }, { 0x44, 7 }, { 0x3C, 8 }, { 0x45, 7 },
+ { 0x46, 7 }, { 0x47, 7 }, { 0x48, 7 }, { 0x49, 7 },
+ { 0x4A, 7 }, { 0x4B, 7 }, { 0x4C, 7 }, { 0x4D, 7 },
+ { 0x4E, 7 }, { 0x58, 7 }, { 0x59, 7 }, { 0x5A, 7 },
+ { 0x5B, 7 }, { 0x5C, 7 }, { 0x5D, 7 }, { 0x44, 8 },
+ { 0x49, 8 }, { 0x29, 8 }, { 0x3F, 8 }, { 0x3D, 8 },
+ { 0x3B, 8 }, { 0x2C, 8 }, { 0x28, 8 }, { 0x25, 8 },
+ { 0x26, 8 }, { 0x5E, 7 }, { 0x57, 7 }, { 0x54, 7 },
+ { 0x5F, 7 }, { 0x62, 7 }, { 0x63, 7 }, { 0x64, 7 },
+ { 0x61, 7 }, { 0x65, 7 }, { 0x67, 7 }, { 0x66, 7 },
+ { 0x35, 6 }, { 0x36, 6 }, { 0x60, 7 }, { 0x39, 8 },
+ { 0x3A, 8 }, { 0x38, 8 }, { 0x37, 8 }, { 0x36, 8 },
+ { 0x35, 8 }, { 0x34, 8 }, { 0x33, 8 }, { 0x32, 8 },
+ { 0x31, 8 }, { 0x30, 8 }, { 0x2D, 8 }, { 0x2B, 8 },
+ { 0x2A, 8 }, { 0x27, 8 }, { 0x40, 8 }, { 0x46, 8 },
+ { 0x47, 8 }, { 0x26, 9 }, { 0x25, 9 }, { 0x24, 9 },
+ { 0x23, 9 }, { 0x22, 9 }, { 0x2E, 8 }, { 0x2F, 8 },
+ { 0x1F, 9 }, { 0x36, 9 }, { 0x1D, 9 }, { 0x21, 9 },
+ { 0x1B, 9 }, { 0x1C, 9 }, { 0x19, 9 }, { 0x1A, 9 },
+ { 0x18, 9 }, { 0x17, 9 }, { 0x16, 9 }, { 0x1E, 9 },
+ { 0x20, 9 }, { 0x27, 9 }, { 0x28, 9 }, { 0x29, 9 },
+ { 0x2A, 9 }, { 0x2B, 9 }, { 0x2C, 9 }, { 0x2D, 9 },
+ { 0x2E, 9 }, { 0x2F, 9 }, { 0x30, 9 }, { 0x35, 9 },
+ { 0x31, 9 }, { 0x32, 9 }, { 0x33, 9 }, { 0x34, 9 },
+ { 0x19, 10 }, { 0x2A, 10 }, { 0x17, 10 }, { 0x16, 10 },
+ { 0x15, 10 }, { 0x28, 10 }, { 0x26, 10 }, { 0x25, 10 },
+ { 0x22, 10 }, { 0x21, 10 }, { 0x18, 10 }, { 0x14, 10 },
+ { 0x29, 10 }, { 0x12, 10 }, { 0xD, 10 }, { 0xE, 10 },
+ { 0xF, 10 }, { 0x10, 10 }, { 0x11, 10 }, { 0x1A, 10 },
+ { 0x1B, 10 }, { 0x1C, 10 }, { 0x1D, 10 }, { 0x1E, 10 },
+ { 0x1F, 10 }, { 0x20, 10 }, { 0x13, 10 }, { 0x23, 10 },
+ { 0x24, 10 }, { 0x9, 11 }, { 0x8, 11 }, { 0x7, 11 },
+ { 0x27, 10 }, { 0x5, 11 }, { 0xB, 11 }, { 0x6, 11 },
+ { 0x4, 11 }, { 0x3, 11 }, { 0x2, 11 }, { 0x1, 11 },
+ { 0xA, 11 }, { 0x16, 11 }, { 0x19, 11 }, { 0x17, 11 },
+ { 0xD, 11 }, { 0xE, 11 }, { 0xF, 11 }, { 0x10, 11 },
+ { 0x11, 11 }, { 0x12, 11 }, { 0x13, 11 }, { 0x1, 14 }
+};
+
+/* values in this table range from -256..255; adjust retrieved value by -256 */
+static const uint16_t svq1_inter_mean_vlc[512][2] = {
+ /* { code, length } */
+ { 0x5A, 22 }, { 0xD4, 22 }, { 0xD5, 22 }, { 0xD6, 22 },
+ { 0xD7, 22 }, { 0xD8, 22 }, { 0xD9, 22 }, { 0xDA, 22 },
+ { 0xDB, 22 }, { 0xDC, 22 }, { 0xDD, 22 }, { 0xDE, 22 },
+ { 0xDF, 22 }, { 0xE0, 22 }, { 0xE1, 22 }, { 0xE2, 22 },
+ { 0xE3, 22 }, { 0xE4, 22 }, { 0xE5, 22 }, { 0xE6, 22 },
+ { 0xE8, 22 }, { 0xCB, 22 }, { 0xE9, 22 }, { 0xEA, 22 },
+ { 0xE7, 22 }, { 0xEC, 22 }, { 0xED, 22 }, { 0xEE, 22 },
+ { 0xEF, 22 }, { 0xF0, 22 }, { 0xF1, 22 }, { 0xF2, 22 },
+ { 0xF3, 22 }, { 0xF4, 22 }, { 0xF5, 22 }, { 0xF6, 22 },
+ { 0xF7, 22 }, { 0xF8, 22 }, { 0x102, 22 }, { 0xEB, 22 },
+ { 0xF9, 22 }, { 0xFC, 22 }, { 0xFD, 22 }, { 0xFE, 22 },
+ { 0x100, 22 }, { 0x5C, 22 }, { 0x60, 22 }, { 0x101, 22 },
+ { 0x71, 22 }, { 0x104, 22 }, { 0x105, 22 }, { 0xFB, 22 },
+ { 0xFF, 22 }, { 0x86, 21 }, { 0xFA, 22 }, { 0x7C, 22 },
+ { 0x75, 22 }, { 0x103, 22 }, { 0x78, 22 }, { 0xD3, 22 },
+ { 0x7B, 22 }, { 0x82, 22 }, { 0xD2, 22 }, { 0xD1, 22 },
+ { 0xD0, 22 }, { 0xCF, 22 }, { 0xCE, 22 }, { 0xCD, 22 },
+ { 0xCC, 22 }, { 0xC3, 22 }, { 0xCA, 22 }, { 0xC9, 22 },
+ { 0xC8, 22 }, { 0xC7, 22 }, { 0xC6, 22 }, { 0xC5, 22 },
+ { 0x8B, 22 }, { 0xC4, 22 }, { 0xC2, 22 }, { 0xC1, 22 },
+ { 0xC0, 22 }, { 0xBF, 22 }, { 0xBE, 22 }, { 0xBD, 22 },
+ { 0xBC, 22 }, { 0xBB, 22 }, { 0xBA, 22 }, { 0xB9, 22 },
+ { 0x61, 22 }, { 0x84, 22 }, { 0x85, 22 }, { 0x86, 22 },
+ { 0x87, 22 }, { 0x88, 22 }, { 0x89, 22 }, { 0x8A, 22 },
+ { 0x8C, 22 }, { 0x8D, 22 }, { 0x8E, 22 }, { 0x8F, 22 },
+ { 0x90, 22 }, { 0x91, 22 }, { 0x92, 22 }, { 0x93, 22 },
+ { 0x94, 22 }, { 0x95, 22 }, { 0x96, 22 }, { 0x97, 22 },
+ { 0x98, 22 }, { 0x99, 22 }, { 0x9A, 22 }, { 0x9B, 22 },
+ { 0x9C, 22 }, { 0x9D, 22 }, { 0x9E, 22 }, { 0x9F, 22 },
+ { 0xA0, 22 }, { 0xA1, 22 }, { 0xA2, 22 }, { 0xA3, 22 },
+ { 0xA4, 22 }, { 0xA5, 22 }, { 0xA6, 22 }, { 0xA7, 22 },
+ { 0xA8, 22 }, { 0xA9, 22 }, { 0xAA, 22 }, { 0xAB, 22 },
+ { 0x7F, 22 }, { 0x8F, 21 }, { 0xAC, 22 }, { 0xAD, 22 },
+ { 0xAE, 22 }, { 0xAF, 22 }, { 0xB0, 22 }, { 0xB1, 22 },
+ { 0x53, 20 }, { 0x90, 21 }, { 0xB2, 22 }, { 0x91, 21 },
+ { 0xB3, 22 }, { 0xB4, 22 }, { 0x54, 20 }, { 0xB5, 22 },
+ { 0xB6, 22 }, { 0x8C, 21 }, { 0x34, 19 }, { 0x3D, 18 },
+ { 0x55, 20 }, { 0xB7, 22 }, { 0xB8, 22 }, { 0x8B, 21 },
+ { 0x56, 20 }, { 0x3D, 19 }, { 0x57, 20 }, { 0x58, 20 },
+ { 0x40, 19 }, { 0x43, 19 }, { 0x47, 19 }, { 0x2A, 18 },
+ { 0x2E, 19 }, { 0x2C, 18 }, { 0x46, 19 }, { 0x59, 20 },
+ { 0x49, 19 }, { 0x2D, 19 }, { 0x38, 18 }, { 0x36, 18 },
+ { 0x39, 18 }, { 0x45, 19 }, { 0x28, 18 }, { 0x30, 18 },
+ { 0x35, 18 }, { 0x20, 17 }, { 0x44, 19 }, { 0x32, 18 },
+ { 0x31, 18 }, { 0x1F, 17 }, { 0x2F, 18 }, { 0x2E, 18 },
+ { 0x2D, 18 }, { 0x21, 17 }, { 0x22, 17 }, { 0x23, 17 },
+ { 0x24, 17 }, { 0x27, 16 }, { 0x23, 16 }, { 0x20, 16 },
+ { 0x1D, 16 }, { 0x25, 16 }, { 0x1E, 16 }, { 0x24, 16 },
+ { 0x2A, 16 }, { 0x26, 16 }, { 0x21, 15 }, { 0x29, 16 },
+ { 0x22, 15 }, { 0x23, 15 }, { 0x24, 15 }, { 0x1B, 15 },
+ { 0x1A, 15 }, { 0x1D, 15 }, { 0x1F, 15 }, { 0x27, 15 },
+ { 0x17, 14 }, { 0x18, 14 }, { 0x19, 14 }, { 0x1B, 14 },
+ { 0x1C, 14 }, { 0x1E, 14 }, { 0x25, 14 }, { 0x20, 14 },
+ { 0x21, 14 }, { 0x13, 13 }, { 0x14, 13 }, { 0x15, 13 },
+ { 0x16, 13 }, { 0x17, 13 }, { 0x18, 13 }, { 0x19, 13 },
+ { 0x1A, 13 }, { 0x18, 12 }, { 0x17, 12 }, { 0x15, 12 },
+ { 0x14, 12 }, { 0x13, 12 }, { 0x12, 12 }, { 0xF, 11 },
+ { 0x10, 11 }, { 0x12, 11 }, { 0x13, 11 }, { 0x1B, 11 },
+ { 0x1A, 11 }, { 0xE, 10 }, { 0x13, 10 }, { 0xF, 10 },
+ { 0x10, 10 }, { 0x11, 10 }, { 0x12, 10 }, { 0xD, 9 },
+ { 0x14, 9 }, { 0x15, 9 }, { 0xC, 9 }, { 0x13, 9 },
+ { 0xF, 8 }, { 0xE, 8 }, { 0x10, 8 }, { 0x11, 8 },
+ { 0xC, 7 }, { 0x9, 7 }, { 0xA, 7 }, { 0x8, 6 },
+ { 0x9, 6 }, { 0x9, 5 }, { 0x8, 5 }, { 0x5, 4 },
+ { 0x1, 1 }, { 0x3, 3 }, { 0x7, 5 }, { 0x6, 5 },
+ { 0xB, 6 }, { 0xA, 6 }, { 0xE, 7 }, { 0xF, 7 },
+ { 0xB, 7 }, { 0xD, 7 }, { 0xB, 8 }, { 0xD, 8 },
+ { 0xC, 8 }, { 0xF, 9 }, { 0x10, 9 }, { 0x11, 9 },
+ { 0xE, 9 }, { 0x12, 9 }, { 0x17, 10 }, { 0x14, 10 },
+ { 0x16, 10 }, { 0x15, 10 }, { 0x19, 11 }, { 0x18, 11 },
+ { 0x17, 11 }, { 0x16, 11 }, { 0x15, 11 }, { 0x14, 11 },
+ { 0x11, 11 }, { 0x19, 12 }, { 0x1A, 12 }, { 0x16, 12 },
+ { 0x1D, 12 }, { 0x1B, 12 }, { 0x1C, 12 }, { 0x20, 13 },
+ { 0x1C, 13 }, { 0x23, 13 }, { 0x22, 13 }, { 0x21, 13 },
+ { 0x1F, 13 }, { 0x1E, 13 }, { 0x1B, 13 }, { 0x1D, 13 },
+ { 0x24, 14 }, { 0x16, 14 }, { 0x1A, 14 }, { 0x22, 14 },
+ { 0x1D, 14 }, { 0x1F, 14 }, { 0x15, 14 }, { 0x23, 14 },
+ { 0x18, 15 }, { 0x20, 15 }, { 0x29, 15 }, { 0x28, 15 },
+ { 0x26, 15 }, { 0x25, 15 }, { 0x19, 15 }, { 0x1C, 15 },
+ { 0x1E, 15 }, { 0x17, 15 }, { 0x2C, 16 }, { 0x2B, 16 },
+ { 0x1C, 16 }, { 0x21, 16 }, { 0x2D, 16 }, { 0x28, 16 },
+ { 0x1F, 16 }, { 0x1B, 16 }, { 0x1A, 16 }, { 0x22, 16 },
+ { 0x2D, 17 }, { 0x32, 17 }, { 0x2C, 17 }, { 0x27, 17 },
+ { 0x31, 17 }, { 0x33, 17 }, { 0x2F, 17 }, { 0x2B, 17 },
+ { 0x37, 18 }, { 0x2A, 17 }, { 0x2E, 17 }, { 0x30, 17 },
+ { 0x29, 17 }, { 0x28, 17 }, { 0x26, 17 }, { 0x25, 17 },
+ { 0x2F, 19 }, { 0x33, 18 }, { 0x34, 18 }, { 0x30, 19 },
+ { 0x3A, 18 }, { 0x3B, 18 }, { 0x31, 19 }, { 0x3C, 18 },
+ { 0x2B, 18 }, { 0x29, 18 }, { 0x48, 19 }, { 0x27, 18 },
+ { 0x42, 19 }, { 0x41, 19 }, { 0x26, 18 }, { 0x52, 20 },
+ { 0x51, 20 }, { 0x3F, 19 }, { 0x3E, 19 }, { 0x39, 19 },
+ { 0x3C, 19 }, { 0x3B, 19 }, { 0x3A, 19 }, { 0x25, 18 },
+ { 0x38, 19 }, { 0x50, 20 }, { 0x37, 19 }, { 0x36, 19 },
+ { 0x87, 21 }, { 0x4F, 20 }, { 0x35, 19 }, { 0x4E, 20 },
+ { 0x33, 19 }, { 0x32, 19 }, { 0x4D, 20 }, { 0x4C, 20 },
+ { 0x83, 22 }, { 0x4B, 20 }, { 0x81, 22 }, { 0x80, 22 },
+ { 0x8E, 21 }, { 0x7E, 22 }, { 0x7D, 22 }, { 0x84, 21 },
+ { 0x8D, 21 }, { 0x7A, 22 }, { 0x79, 22 }, { 0x4A, 20 },
+ { 0x77, 22 }, { 0x76, 22 }, { 0x89, 21 }, { 0x74, 22 },
+ { 0x73, 22 }, { 0x72, 22 }, { 0x49, 20 }, { 0x70, 22 },
+ { 0x6F, 22 }, { 0x6E, 22 }, { 0x6D, 22 }, { 0x6C, 22 },
+ { 0x6B, 22 }, { 0x6A, 22 }, { 0x69, 22 }, { 0x68, 22 },
+ { 0x67, 22 }, { 0x66, 22 }, { 0x65, 22 }, { 0x64, 22 },
+ { 0x63, 22 }, { 0x62, 22 }, { 0x8A, 21 }, { 0x88, 21 },
+ { 0x5F, 22 }, { 0x5E, 22 }, { 0x5D, 22 }, { 0x85, 21 },
+ { 0x5B, 22 }, { 0x83, 21 }, { 0x59, 22 }, { 0x58, 22 },
+ { 0x57, 22 }, { 0x56, 22 }, { 0x55, 22 }, { 0x54, 22 },
+ { 0x53, 22 }, { 0x52, 22 }, { 0x51, 22 }, { 0x50, 22 },
+ { 0x4F, 22 }, { 0x4E, 22 }, { 0x4D, 22 }, { 0x4C, 22 },
+ { 0x4B, 22 }, { 0x4A, 22 }, { 0x49, 22 }, { 0x48, 22 },
+ { 0x47, 22 }, { 0x46, 22 }, { 0x45, 22 }, { 0x44, 22 },
+ { 0x43, 22 }, { 0x42, 22 }, { 0x41, 22 }, { 0x40, 22 },
+ { 0x3F, 22 }, { 0x3E, 22 }, { 0x3D, 22 }, { 0x3C, 22 },
+ { 0x3B, 22 }, { 0x3A, 22 }, { 0x39, 22 }, { 0x38, 22 },
+ { 0x37, 22 }, { 0x36, 22 }, { 0x35, 22 }, { 0x34, 22 },
+ { 0x33, 22 }, { 0x32, 22 }, { 0x31, 22 }, { 0x30, 22 },
+ { 0x2F, 22 }, { 0x2E, 22 }, { 0x2D, 22 }, { 0x2C, 22 },
+ { 0x2B, 22 }, { 0x2A, 22 }, { 0x29, 22 }, { 0x28, 22 },
+ { 0x27, 22 }, { 0x26, 22 }, { 0x25, 22 }, { 0x24, 22 },
+ { 0x23, 22 }, { 0x22, 22 }, { 0x21, 22 }, { 0x20, 22 },
+ { 0x1F, 22 }, { 0x1E, 22 }, { 0x1D, 22 }, { 0x1C, 22 },
+ { 0x1B, 22 }, { 0x1A, 22 }, { 0x19, 22 }, { 0x18, 22 },
+ { 0x17, 22 }, { 0x16, 22 }, { 0x15, 22 }, { 0x14, 22 },
+ { 0x13, 22 }, { 0x12, 22 }, { 0x11, 22 }, { 0x10, 22 },
+ { 0xF, 22 }, { 0xE, 22 }, { 0xD, 22 }, { 0xC, 22 },
+ { 0xB, 22 }, { 0xA, 22 }, { 0x9, 22 }, { 0x8, 22 },
+ { 0x7, 22 }, { 0x6, 22 }, { 0x5, 22 }, { 0x4, 22 },
+ { 0x3, 22 }, { 0x2, 22 }, { 0x1, 22 }, { 0x0, 22 }
+};
+
+#endif
diff --git a/src/libffmpeg/libavcodec/svq3.c b/src/libffmpeg/libavcodec/svq3.c
index 0cd927956..e565bd0a8 100644
--- a/src/libffmpeg/libavcodec/svq3.c
+++ b/src/libffmpeg/libavcodec/svq3.c
@@ -43,6 +43,19 @@
* svq3 decoder.
*/
+#define FULLPEL_MODE 1
+#define HALFPEL_MODE 2
+#define THIRDPEL_MODE 3
+
+/* dual scan (from some older h264 draft)
+ o-->o-->o o
+ | /|
+ o o o / o
+ | / | |/ |
+ o o o o
+ /
+ o-->o-->o-->o
+*/
static const uint8_t svq3_scan[16]={
0+0*4, 1+0*4, 2+0*4, 2+1*4,
2+2*4, 3+0*4, 3+1*4, 3+2*4,
@@ -186,7 +199,7 @@ static void pred4x4_down_left_svq3_c(uint8_t *src, uint8_t *topright, int stride
src[3+2*stride]=
src[2+3*stride]=
src[3+3*stride]=(l3 + t3)>>1;
-};
+}
static void pred16x16_plane_svq3_c(uint8_t *src, int stride){
pred16x16_plane_compat_c(src, stride, 1);
@@ -249,171 +262,64 @@ static inline int svq3_decode_block (GetBitContext *gb, DCTELEM *block,
return 0;
}
-static void sixpel_mc_put (MpegEncContext *s,
- uint8_t *src, uint8_t *dst, int stride,
- int dxy, int width, int height) {
- int i, j;
-
- switch (dxy) {
- case 6*0+0:
- for (i=0; i < height; i++) {
- memcpy (dst, src, width);
- src += stride;
- dst += stride;
- }
- break;
- case 6*0+2:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*0+3:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (src[j] + src[j+1] + 1) >> 1;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*0+4:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*2+0:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*2+2:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*2+4:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*3+0:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (src[j] + src[j+stride]+1) >> 1;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*3+3:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (src[j] + src[j+1] + src[j+stride] + src[j+stride+1] + 2) >> 2;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*4+0:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*4+2:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
- break;
- case 6*4+4:
- for (i=0; i < height; i++) {
- for (j=0; j < width; j++) {
- dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
- }
- src += stride;
- dst += stride;
- }
- break;
- }
-}
+static inline void svq3_mc_dir_part (MpegEncContext *s,
+ int x, int y, int width, int height,
+ int mx, int my, int dxy,
+ int thirdpel, int dir, int avg) {
-static inline void svq3_mc_dir_part (MpegEncContext *s, int x, int y,
- int width, int height, int mx, int my) {
+ const Picture *pic = (dir == 0) ? &s->last_picture : &s->next_picture;
uint8_t *src, *dest;
int i, emu = 0;
- const int sx = ((unsigned) (mx + 0x7FFFFFFE)) % 6;
- const int sy = ((unsigned) (my + 0x7FFFFFFE)) % 6;
- const int dxy= 6*sy + sx;
-
- /* decode and clip motion vector to frame border (+16) */
- mx = x + (mx - sx) / 6;
- my = y + (my - sy) / 6;
+ int blocksize= 2 - (width>>3); //16->0, 8->1, 4->2
- if (mx < 0 || mx >= (s->width - width - 1) ||
- my < 0 || my >= (s->height - height - 1)) {
+ mx += x;
+ my += y;
+
+ if (mx < 0 || mx >= (s->h_edge_pos - width - 1) ||
+ my < 0 || my >= (s->v_edge_pos - height - 1)) {
if ((s->flags & CODEC_FLAG_EMU_EDGE)) {
emu = 1;
}
- mx = clip (mx, -16, (s->width - width + 15));
- my = clip (my, -16, (s->height - height + 15));
+ mx = clip (mx, -16, (s->h_edge_pos - width + 15));
+ my = clip (my, -16, (s->v_edge_pos - height + 15));
}
/* form component predictions */
dest = s->current_picture.data[0] + x + y*s->linesize;
- src = s->last_picture.data[0] + mx + my*s->linesize;
+ src = pic->data[0] + mx + my*s->linesize;
if (emu) {
ff_emulated_edge_mc (s, src, s->linesize, (width + 1), (height + 1),
- mx, my, s->width, s->height);
+ mx, my, s->h_edge_pos, s->v_edge_pos);
src = s->edge_emu_buffer;
}
- sixpel_mc_put (s, src, dest, s->linesize, dxy, width, height);
+ if(thirdpel)
+ (avg ? s->dsp.avg_tpel_pixels_tab : s->dsp.put_tpel_pixels_tab)[dxy](dest, src, s->linesize, width, height);
+ else
+ (avg ? s->dsp.avg_pixels_tab : s->dsp.put_pixels_tab)[blocksize][dxy](dest, src, s->linesize, height);
if (!(s->flags & CODEC_FLAG_GRAY)) {
mx = (mx + (mx < (int) x)) >> 1;
my = (my + (my < (int) y)) >> 1;
width = (width >> 1);
height = (height >> 1);
+ blocksize++;
for (i=1; i < 3; i++) {
dest = s->current_picture.data[i] + (x >> 1) + (y >> 1)*s->uvlinesize;
- src = s->last_picture.data[i] + mx + my*s->uvlinesize;
+ src = pic->data[i] + mx + my*s->uvlinesize;
if (emu) {
ff_emulated_edge_mc (s, src, s->uvlinesize, (width + 1), (height + 1),
- mx, my, (s->width >> 1), (s->height >> 1));
+ mx, my, (s->h_edge_pos >> 1), (s->v_edge_pos >> 1));
src = s->edge_emu_buffer;
}
- sixpel_mc_put (s, src, dest, s->uvlinesize, dxy, width, height);
+ if(thirdpel)
+ (avg ? s->dsp.avg_tpel_pixels_tab : s->dsp.put_tpel_pixels_tab)[dxy](dest, src, s->uvlinesize, width, height);
+ else
+ (avg ? s->dsp.avg_pixels_tab : s->dsp.put_pixels_tab)[blocksize][dxy](dest, src, s->uvlinesize, height);
}
}
}
@@ -432,62 +338,130 @@ static int svq3_decode_mb (H264Context *h, unsigned int mb_type) {
h->topright_samples_available = 0xFFFF;
if (mb_type == 0) { /* SKIP */
- svq3_mc_dir_part (s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0);
+ if (s->pict_type == P_TYPE) {
+ svq3_mc_dir_part (s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0);
- cbp = 0;
- mb_type = MB_TYPE_SKIP;
+ cbp = 0;
+ mb_type = MB_TYPE_SKIP;
+ } else {
+ for (dir=0; dir < 2; dir++) {
+ for (i=0; i < 4; i++) {
+ for (j=0; j < 4; j++) {
+ int dxy;
+ x = 16*s->mb_x + 4*j;
+ y = 16*s->mb_y + 4*i;
+
+ mx = 2*s->next_picture.motion_val[0][b_xy + j + i*h->b_stride][0];
+ my = 2*s->next_picture.motion_val[0][b_xy + j + i*h->b_stride][1];
+
+ if (dir == 0) {
+ mx = (mx * h->frame_num_offset) / h->prev_frame_num_offset;
+ my = (my * h->frame_num_offset) / h->prev_frame_num_offset;
+ } else {
+ mx = (mx * (h->frame_num_offset - h->prev_frame_num_offset)) / h->prev_frame_num_offset;
+ my = (my * (h->frame_num_offset - h->prev_frame_num_offset)) / h->prev_frame_num_offset;
+ }
+
+ mx = ((unsigned)(mx + 3 + 0x6000))/6 - 0x1000;
+ my = ((unsigned)(my + 3 + 0x6000))/6 - 0x1000;
+ dxy= (mx&1) + 2*(my&1);
+
+ /* update mv_cache */
+ s->current_picture.motion_val[dir][b_xy + j + i*h->b_stride][0] = 3*mx;
+ s->current_picture.motion_val[dir][b_xy + j + i*h->b_stride][1] = 3*my;
+
+ svq3_mc_dir_part (s, x, y, 4, 4, mx>>1, my>>1, dxy, 0, dir, (dir == 1));
+ }
+ }
+ }
+
+ if ((vlc = svq3_get_ue_golomb (&s->gb)) >= 48)
+ return -1;
+
+ cbp = golomb_to_inter_cbp[vlc];
+ mb_type = MB_TYPE_16x16;
+ }
} else if (mb_type < 8) { /* INTER */
+ int dir0, dir1;
+
if (h->thirdpel_flag && h->halfpel_flag == !get_bits (&s->gb, 1)) {
- mode = 3; /* thirdpel */
+ mode = THIRDPEL_MODE;
} else if (h->halfpel_flag && h->thirdpel_flag == !get_bits (&s->gb, 1)) {
- mode = 2; /* halfpel */
+ mode = HALFPEL_MODE;
} else {
- mode = 1; /* fullpel */
+ mode = FULLPEL_MODE;
}
/* fill caches */
- memset (h->ref_cache[0], PART_NOT_AVAILABLE, 8*5*sizeof(int8_t));
-
- if (s->mb_x > 0) {
- for (i=0; i < 4; i++) {
- *(uint32_t *) h->mv_cache[0][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[0][b_xy - 1 + i*h->b_stride];
- h->ref_cache[0][scan8[0] - 1 + i*8] = 1;
- }
- } else {
- for (i=0; i < 4; i++) {
- *(uint32_t *) h->mv_cache[0][scan8[0] - 1 + i*8] = 0;
- h->ref_cache[0][scan8[0] - 1 + i*8] = 1;
- }
- }
- if (s->mb_y > 0) {
- memcpy (h->mv_cache[0][scan8[0] - 1*8], s->current_picture.motion_val[0][b_xy - h->b_stride], 4*2*sizeof(int16_t));
- memset (&h->ref_cache[0][scan8[0] - 1*8], 1, 4);
-
- if (s->mb_x < (s->mb_width - 1)) {
- *(uint32_t *) h->mv_cache[0][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[0][b_xy - h->b_stride + 4];
- h->ref_cache[0][scan8[0] + 4 - 1*8] = 1;
- }
- if (s->mb_x > 0) {
- *(uint32_t *) h->mv_cache[0][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[0][b_xy - h->b_stride - 1];
- h->ref_cache[0][scan8[0] - 1 - 1*8] = 1;
+ /* note ref_cache should contain here:
+ ????????
+ ???11111
+ N??11111
+ N??11111
+ N??11111
+ N
+ */
+
+ for (m=0; m < 2; m++) {
+ if (s->mb_x > 0 && h->intra4x4_pred_mode[mb_xy - 1][0] != -1) {
+ for (i=0; i < 4; i++) {
+ *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride];
+ }
+ } else {
+ for (i=0; i < 4; i++) {
+ *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0;
+ }
}
+ if (s->mb_y > 0) {
+ memcpy (h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));
+ memset (&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[mb_xy - s->mb_stride][4] == -1) ? PART_NOT_AVAILABLE : 1, 4);
+
+ if (s->mb_x < (s->mb_width - 1)) {
+ *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4];
+ h->ref_cache[m][scan8[0] + 4 - 1*8] =
+ (h->intra4x4_pred_mode[mb_xy - s->mb_stride + 1][0] == -1 ||
+ h->intra4x4_pred_mode[mb_xy - s->mb_stride][4] == -1) ? PART_NOT_AVAILABLE : 1;
+ }else
+ h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
+ if (s->mb_x > 0) {
+ *(uint32_t *) h->mv_cache[0][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1];
+ h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[mb_xy - s->mb_stride - 1][3] == -1) ? PART_NOT_AVAILABLE : 1;
+ }else
+ h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;
+ }else
+ memset (&h->ref_cache[m][scan8[0] - 1*8 - 1], PART_NOT_AVAILABLE, 8);
+
+ if (s->pict_type != B_TYPE)
+ break;
}
/* decode motion vector(s) and form prediction(s) */
- part_width = ((mb_type & 5) == 5) ? 4 : 8 << (mb_type & 1);
- part_height = 16 >> ((unsigned) mb_type / 3);
-
+ if (s->pict_type == P_TYPE) {
+ part_width = ((mb_type & 5) == 5) ? 4 : 8 << (mb_type & 1);
+ part_height = 16 >> ((unsigned) mb_type / 3);
+ dir0 = 0;
+ dir1 = 0;
+ } else { /* B_TYPE */
+ part_width = 16;
+ part_height = 16;
+ dir0 = (mb_type == 2) ? 1 : 0;
+ dir1 = (mb_type == 1) ? 0 : 1;
+ }
+
+ for (dir=dir0; dir <= dir1; dir++) {
for (i=0; i < 16; i+=part_height) {
for (j=0; j < 16; j+=part_width) {
+ int avg=(dir == 1 && dir0 != dir1);
+ int dxy;
x = 16*s->mb_x + j;
y = 16*s->mb_y + i;
k = ((j>>2)&1) + ((i>>1)&2) + ((j>>1)&4) + (i&8);
- pred_motion (h, k, (part_width >> 2), 0, 1, &mx, &my);
+ pred_motion (h, k, (part_width >> 2), dir, 1, &mx, &my);
/* clip motion vector prediction to frame border */
- mx = clip (mx, -6*x, 6*(s->width - part_width - x));
- my = clip (my, -6*y, 6*(s->height - part_height - y));
+ mx = clip (mx, -6*x, 6*(s->h_edge_pos - part_width - x));
+ my = clip (my, -6*y, 6*(s->v_edge_pos - part_height - y));
/* get motion vector differential */
dy = svq3_get_se_golomb (&s->gb);
@@ -496,35 +470,62 @@ static int svq3_decode_mb (H264Context *h, unsigned int mb_type) {
if (dx == INVALID_VLC || dy == INVALID_VLC) {
return -1;
}
-
/* compute motion vector */
- if (mode == 3) {
- mx = ((mx + 1) & ~0x1) + 2*dx;
- my = ((my + 1) & ~0x1) + 2*dy;
- } else if (mode == 2) {
- mx = (mx + 1) - ((unsigned) (0x7FFFFFFF + mx) % 3) + 3*dx;
- my = (my + 1) - ((unsigned) (0x7FFFFFFF + my) % 3) + 3*dy;
- } else if (mode == 1) {
- mx = (mx + 3) - ((unsigned) (0x7FFFFFFB + mx) % 6) + 6*dx;
- my = (my + 3) - ((unsigned) (0x7FFFFFFB + my) % 6) + 6*dy;
- }
+ if (mode == THIRDPEL_MODE) {
+ int fx, fy;
+ mx = ((mx + 1)>>1) + dx;
+ my = ((my + 1)>>1) + dy;
+ fx= ((unsigned)(mx + 0x3000))/3 - 0x1000;
+ fy= ((unsigned)(my + 0x3000))/3 - 0x1000;
+ dxy= (mx - 3*fx) + 4*(my - 3*fy);
+
+ svq3_mc_dir_part (s, x, y, part_width, part_height, fx, fy, dxy, 1, dir, avg);
+ mx += mx;
+ my += my;
+ } else if (mode == HALFPEL_MODE) {
+ mx = ((unsigned)(mx + 1 + 0x3000))/3 + dx - 0x1000;
+ my = ((unsigned)(my + 1 + 0x3000))/3 + dy - 0x1000;
+ dxy= (mx&1) + 2*(my&1);
+
+ svq3_mc_dir_part (s, x, y, part_width, part_height, mx>>1, my>>1, dxy, 0, dir, avg);
+ mx *= 3;
+ my *= 3;
+ } else {
+ assert(mode == FULLPEL_MODE);
+ mx = ((unsigned)(mx + 3 + 0x6000))/6 + dx - 0x1000;
+ my = ((unsigned)(my + 3 + 0x6000))/6 + dy - 0x1000;
- /* update mv_cache */
- for (l=0; l < part_height; l+=4) {
- for (m=0; m < part_width; m+=4) {
- k = scan8[0] + ((m + j) >> 2) + ((l + i) << 1);
- h->mv_cache [0][k][0] = mx;
- h->mv_cache [0][k][1] = my;
- h->ref_cache[0][k] = 1;
- }
+ svq3_mc_dir_part (s, x, y, part_width, part_height, mx, my, 0, 0, dir, avg);
+ mx *= 6;
+ my *= 6;
}
- svq3_mc_dir_part (s, x, y, part_width, part_height, mx, my);
+ /* update mv_cache */
+ fill_rectangle(h->mv_cache[dir][scan8[k]], part_width>>2, part_height>>2, 8, pack16to32(mx,my), 4);
}
}
+ }
- for (i=0; i < 4; i++) {
- memcpy (s->current_picture.motion_val[0][b_xy + i*h->b_stride], h->mv_cache[0][scan8[0] + 8*i], 4*2*sizeof(int16_t));
+ /* write back or clear motion vectors */
+ if (s->pict_type == P_TYPE || mb_type != 2) {
+ for (i=0; i < 4; i++) {
+ memcpy (s->current_picture.motion_val[0][b_xy + i*h->b_stride], h->mv_cache[0][scan8[0] + 8*i], 4*2*sizeof(int16_t));
+ }
+ } else {
+ for (i=0; i < 4; i++) {
+ memset (s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
+ }
+ }
+ if (s->pict_type == B_TYPE) {
+ if (mb_type != 1) {
+ for (i=0; i < 4; i++) {
+ memcpy (s->current_picture.motion_val[1][b_xy + i*h->b_stride], h->mv_cache[1][scan8[0] + 8*i], 4*2*sizeof(int16_t));
+ }
+ } else {
+ for (i=0; i < 4; i++) {
+ memset (s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
+ }
+ }
}
if ((vlc = svq3_get_ue_golomb (&s->gb)) >= 48)
@@ -532,40 +533,67 @@ static int svq3_decode_mb (H264Context *h, unsigned int mb_type) {
cbp = golomb_to_inter_cbp[vlc];
mb_type = MB_TYPE_16x16;
- } else if (mb_type == 8) { /* INTRA4x4 */
+ } else if (mb_type == 8 || mb_type == 33) { /* INTRA4x4 */
memset (h->intra4x4_pred_mode_cache, -1, 8*5*sizeof(int8_t));
- if (s->mb_x > 0) {
- for (i=0; i < 4; i++) {
- h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[mb_xy - 1][i];
+ if (mb_type == 8) {
+ if (s->mb_x > 0) {
+ for (i=0; i < 4; i++) {
+ h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[mb_xy - 1][i];
+ }
+ if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) {
+ h->left_samples_available = 0x5F5F;
+ }
+ }
+ if (s->mb_y > 0) {
+ h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][4];
+ h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][5];
+ h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][6];
+ h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][3];
+
+ if (h->intra4x4_pred_mode_cache[4+8*0] == -1) {
+ h->top_samples_available = 0x33FF;
+ }
}
- }
- if (s->mb_y > 0) {
- h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][4];
- h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][5];
- h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][6];
- h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[mb_xy - s->mb_stride][3];
- }
- /* decode prediction codes for luma blocks */
- for (i=0; i < 16; i+=2) {
- vlc = svq3_get_ue_golomb (&s->gb);
+ /* decode prediction codes for luma blocks */
+ for (i=0; i < 16; i+=2) {
+ vlc = svq3_get_ue_golomb (&s->gb);
- if (vlc >= 25)
- return -1;
+ if (vlc >= 25)
+ return -1;
- left = &h->intra4x4_pred_mode_cache[scan8[i] - 1];
- top = &h->intra4x4_pred_mode_cache[scan8[i] - 8];
+ left = &h->intra4x4_pred_mode_cache[scan8[i] - 1];
+ top = &h->intra4x4_pred_mode_cache[scan8[i] - 8];
- left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];
- left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];
+ left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];
+ left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];
- if (left[1] == -1 || left[2] == -1)
- return -1;
+ if (left[1] == -1 || left[2] == -1)
+ return -1;
+ }
+ } else {
+ /* DC_128_PRED block type */
+ for (i=0; i < 4; i++) {
+ memset (&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_PRED, 4);
+ }
}
write_back_intra_pred_mode (h);
- check_intra4x4_pred_mode (h);
+
+ if (mb_type == 8) {
+ check_intra4x4_pred_mode (h);
+
+ h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
+ h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
+ } else {
+ for (i=0; i < 4; i++) {
+ memset (&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_128_PRED, 4);
+ }
+
+ h->top_samples_available = 0x33FF;
+ h->left_samples_available = 0x5F5F;
+ }
if ((vlc = svq3_get_ue_golomb (&s->gb)) >= 48)
return -1;
@@ -587,13 +615,18 @@ static int svq3_decode_mb (H264Context *h, unsigned int mb_type) {
for (i=0; i < 4; i++) {
memset (s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
}
+ if (s->pict_type == B_TYPE) {
+ for (i=0; i < 4; i++) {
+ memset (s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));
+ }
+ }
}
if (!IS_INTRA4x4(mb_type)) {
memset (h->intra4x4_pred_mode[mb_xy], DC_PRED, 8);
}
if (!IS_SKIP(mb_type)) {
- memset (h->mb, 0, 24*16*sizeof(DCTELEM));
- memset (h->non_zero_count_cache, 0, 8*6*sizeof(uint8_t));
+ memset (h->non_zero_count_cache + 8, 0, 4*9*sizeof(uint8_t));
+ s->dsp.clear_blocks(h->mb);
}
if (IS_INTRA16x16(mb_type) || (s->pict_type != I_TYPE && s->adaptive_quant && cbp)) {
@@ -649,101 +682,245 @@ static int svq3_decode_mb (H264Context *h, unsigned int mb_type) {
return 0;
}
+static int svq3_decode_slice_header (H264Context *h) {
+ MpegEncContext *const s = (MpegEncContext *) h;
+ const int mb_xy = s->mb_x + s->mb_y*s->mb_stride;
+ int i, header;
+
+ header = get_bits (&s->gb, 8);
+
+ if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) {
+ /* TODO: what? */
+ fprintf (stderr, "unsupported slice header (%02X)\n", header);
+ return -1;
+ } else {
+ int length = (header >> 5) & 3;
+
+ h->next_slice_index = s->gb.index + 8*show_bits (&s->gb, 8*length) + 8*length;
+
+ if (h->next_slice_index > s->gb.size_in_bits)
+ return -1;
+
+ s->gb.size_in_bits = h->next_slice_index - 8*(length - 1);
+ s->gb.index += 8;
+
+ if (length > 0) {
+ memcpy ((uint8_t *) &s->gb.buffer[s->gb.index >> 3],
+ &s->gb.buffer[s->gb.size_in_bits >> 3], (length - 1));
+ }
+ }
+
+ if ((i = svq3_get_ue_golomb (&s->gb)) == INVALID_VLC || i >= 3)
+ return -1;
+
+ h->slice_type = golomb_to_pict_type[i];
+
+ if ((header & 0x9F) == 2) {
+ i = (s->mb_num < 64) ? 6 : (1 + av_log2 (s->mb_num - 1));
+ s->mb_skip_run = get_bits (&s->gb, i) - (s->mb_x + (s->mb_y * s->mb_width));
+ } else {
+ get_bits1 (&s->gb);
+ s->mb_skip_run = 0;
+ }
+
+ h->slice_num = get_bits (&s->gb, 8);
+ s->qscale = get_bits (&s->gb, 5);
+ s->adaptive_quant = get_bits1 (&s->gb);
+
+ /* unknown fields */
+ get_bits1 (&s->gb);
+
+ if (h->unknown_svq3_flag) {
+ get_bits1 (&s->gb);
+ }
+
+ get_bits1 (&s->gb);
+ get_bits (&s->gb, 2);
+
+ while (get_bits1 (&s->gb)) {
+ get_bits (&s->gb, 8);
+ }
+
+ /* reset intra predictors and invalidate motion vector references */
+ if (s->mb_x > 0) {
+ memset (h->intra4x4_pred_mode[mb_xy - 1], -1, 4*sizeof(int8_t));
+ memset (h->intra4x4_pred_mode[mb_xy - s->mb_x], -1, 8*sizeof(int8_t)*s->mb_x);
+ }
+ if (s->mb_y > 0) {
+ memset (h->intra4x4_pred_mode[mb_xy - s->mb_stride], -1, 8*sizeof(int8_t)*(s->mb_width - s->mb_x));
+
+ if (s->mb_x > 0) {
+ h->intra4x4_pred_mode[mb_xy - s->mb_stride - 1][3] = -1;
+ }
+ }
+
+ return 0;
+}
+
static int svq3_decode_frame (AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size) {
MpegEncContext *const s = avctx->priv_data;
H264Context *const h = avctx->priv_data;
- int i;
+ int m, mb_type;
- s->flags = avctx->flags;
+ *data_size = 0;
+ s->flags = avctx->flags;
+
if (!s->context_initialized) {
- s->width = (avctx->width + 15) & ~15;
- s->height = (avctx->height + 15) & ~15;
- h->b_stride = (s->width >> 2);
+ s->width = avctx->width;
+ s->height = avctx->height;
h->pred4x4[DIAG_DOWN_LEFT_PRED] = pred4x4_down_left_svq3_c;
h->pred16x16[PLANE_PRED8x8] = pred16x16_plane_svq3_c;
h->halfpel_flag = 1;
h->thirdpel_flag = 1;
+ h->unknown_svq3_flag = 0;
h->chroma_qp = 4;
if (MPV_common_init (s) < 0)
return -1;
+ h->b_stride = 4*s->mb_width;
+
alloc_tables (h);
- }
- if (avctx->extradata && avctx->extradata_size >= 0x63
- && !memcmp (avctx->extradata, "SVQ3", 4)) {
- uint8_t *stsd = (uint8_t *) avctx->extradata + 0x62;
+ if (avctx->extradata && avctx->extradata_size >= 0x64
+ && !memcmp (avctx->extradata, "SVQ3", 4)) {
+
+ GetBitContext gb;
- if ((*stsd >> 5) != 7 || avctx->extradata_size >= 0x66) {
+ init_get_bits (&gb, (uint8_t *) avctx->extradata + 0x62,
+ 8*(avctx->extradata_size - 0x62));
- if ((*stsd >> 5) == 7) {
- stsd += 3; /* skip width, height (12 bits each) */
+ /* 'frame size code' and optional 'width, height' */
+ if (get_bits (&gb, 3) == 7) {
+ get_bits (&gb, 12);
+ get_bits (&gb, 12);
}
- h->halfpel_flag = (*stsd >> 4) & 1;
- h->thirdpel_flag = (*stsd >> 3) & 1;
- }
- }
+ h->halfpel_flag = get_bits1 (&gb);
+ h->thirdpel_flag = get_bits1 (&gb);
- if ((buf[0] & 0x9F) != 1) {
- /* TODO: what? */
- fprintf (stderr, "unsupported header (%02X)\n", buf[0]);
- return -1;
- } else {
- int length = (buf[0] >> 5) & 3;
- int offset = 0;
+ /* unknown fields */
+ get_bits1 (&gb);
+ get_bits1 (&gb);
+ get_bits1 (&gb);
+ get_bits1 (&gb);
- for (i=0; i < length; i++) {
- offset = (offset << 8) | buf[i + 1];
- }
+ s->low_delay = get_bits1 (&gb);
- if (buf_size < (offset + length + 1) || length == 0)
- return -1;
+ /* unknown field */
+ get_bits1 (&gb);
- memcpy (&buf[2], &buf[offset + 2], (length - 1));
- }
+ while (get_bits1 (&gb)) {
+ get_bits (&gb, 8);
+ }
- init_get_bits (&s->gb, &buf[2], 8*(buf_size - 2));
+ h->unknown_svq3_flag = get_bits1 (&gb);
+ avctx->has_b_frames = !s->low_delay;
+ }
+ }
- if ((i = svq3_get_ue_golomb (&s->gb)) == INVALID_VLC || i >= 3)
- return -1;
+ /* special case for last picture */
+ if (buf_size == 0) {
+ if (s->next_picture_ptr && !s->low_delay) {
+ *(AVFrame *) data = *(AVFrame *) &s->next_picture;
+ *data_size = sizeof(AVFrame);
+ }
+ return 0;
+ }
- s->pict_type = golomb_to_pict_type[i];
+ init_get_bits (&s->gb, buf, 8*buf_size);
- /* unknown fields */
- get_bits (&s->gb, 1);
- get_bits (&s->gb, 8);
+ s->mb_x = s->mb_y = 0;
- s->qscale = get_bits (&s->gb, 5);
- s->adaptive_quant = get_bits (&s->gb, 1);
+ if (svq3_decode_slice_header (h))
+ return -1;
- /* unknown fields */
- get_bits (&s->gb, 1);
- get_bits (&s->gb, 1);
- get_bits (&s->gb, 2);
+ s->pict_type = h->slice_type;
+ s->picture_number = h->slice_num;
- while (get_bits (&s->gb, 1)) {
- get_bits (&s->gb, 8);
+ if(avctx->debug&FF_DEBUG_PICT_INFO){
+ printf("%c hpel:%d, tpel:%d aqp:%d qp:%d\n",
+ av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,
+ s->adaptive_quant, s->qscale
+ );
}
- /* B-frames are not supported */
- if (s->pict_type == B_TYPE/* && avctx->hurry_up*/)
- return buf_size;
+ /* for hurry_up==5 */
+ s->current_picture.pict_type = s->pict_type;
+ s->current_picture.key_frame = (s->pict_type == I_TYPE);
+
+ /* skip b frames if we dont have reference frames */
+ if (s->last_picture_ptr == NULL && s->pict_type == B_TYPE) return 0;
+ /* skip b frames if we are in a hurry */
+ if (avctx->hurry_up && s->pict_type == B_TYPE) return 0;
+ /* skip everything if we are in a hurry >= 5 */
+ if (avctx->hurry_up >= 5) return 0;
+
+ if (s->next_p_frame_damaged) {
+ if (s->pict_type == B_TYPE)
+ return 0;
+ else
+ s->next_p_frame_damaged = 0;
+ }
frame_start (h);
+ if (s->pict_type == B_TYPE) {
+ h->frame_num_offset = (h->slice_num - h->prev_frame_num);
+
+ if (h->frame_num_offset < 0) {
+ h->frame_num_offset += 256;
+ }
+ if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {
+ printf ("error in B-frame picture id\n");
+ return -1;
+ }
+ } else {
+ h->prev_frame_num = h->frame_num;
+ h->frame_num = h->slice_num;
+ h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);
+
+ if (h->prev_frame_num_offset < 0) {
+ h->prev_frame_num_offset += 256;
+ }
+ }
+
+ for(m=0; m<2; m++){
+ int i;
+ for(i=0; i<4; i++){
+ int j;
+ for(j=-1; j<4; j++)
+ h->ref_cache[m][scan8[0] + 8*i + j]= 1;
+ h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE;
+ }
+ }
+
for (s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) {
for (s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) {
- int mb_type = svq3_get_ue_golomb (&s->gb);
+
+ if ( (s->gb.index + 7) >= s->gb.size_in_bits &&
+ ((s->gb.index & 7) == 0 || show_bits (&s->gb, (-s->gb.index & 7)) == 0)) {
+
+ s->gb.index = h->next_slice_index;
+ s->gb.size_in_bits = 8*buf_size;
+
+ if (svq3_decode_slice_header (h))
+ return -1;
+
+ /* TODO: support s->mb_skip_run */
+ }
+
+ mb_type = svq3_get_ue_golomb (&s->gb);
if (s->pict_type == I_TYPE) {
mb_type += 8;
+ } else if (s->pict_type == B_TYPE && mb_type >= 4) {
+ mb_type += 4;
}
- if (mb_type > 32 || svq3_decode_mb (h, mb_type)) {
+ if (mb_type > 33 || svq3_decode_mb (h, mb_type)) {
fprintf (stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
return -1;
}
@@ -752,13 +929,25 @@ static int svq3_decode_frame (AVCodecContext *avctx,
hl_decode_mb (h);
}
}
- }
- *(AVFrame *) data = *(AVFrame *) &s->current_picture;
- *data_size = sizeof(AVFrame);
+ ff_draw_horiz_band(s, 16*s->mb_y, 16);
+ }
MPV_frame_end(s);
-
+
+ if (s->pict_type == B_TYPE || s->low_delay) {
+ *(AVFrame *) data = *(AVFrame *) &s->current_picture;
+ } else {
+ *(AVFrame *) data = *(AVFrame *) &s->last_picture;
+ }
+
+ avctx->frame_number = s->picture_number - 1;
+
+ /* dont output the last pic after seeking */
+ if (s->last_picture_ptr || s->low_delay) {
+ *data_size = sizeof(AVFrame);
+ }
+
return buf_size;
}
@@ -772,5 +961,5 @@ AVCodec svq3_decoder = {
NULL,
decode_end,
svq3_decode_frame,
- CODEC_CAP_DR1,
+ CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
};
diff --git a/src/libffmpeg/libavcodec/utils.c b/src/libffmpeg/libavcodec/utils.c
index a422cf282..3a30e734e 100644
--- a/src/libffmpeg/libavcodec/utils.c
+++ b/src/libffmpeg/libavcodec/utils.c
@@ -84,7 +84,7 @@ void *__av_mallocz_static(void** location, unsigned int size)
return ptr;
}
/* free all static arrays and reset pointers to 0 */
-void av_free_static()
+void av_free_static(void)
{
if (array_static)
{
@@ -157,8 +157,9 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int w, h, pixel_size;
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
-
switch(s->pix_fmt){
+ case PIX_FMT_RGB555:
+ case PIX_FMT_RGB565:
case PIX_FMT_YUV422:
pixel_size=2;
break;
@@ -343,9 +344,15 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
return ret;
}
-/* decode a frame. return -1 if error, otherwise return the number of
- bytes used. If no frame could be decompressed, *got_picture_ptr is
- zero. Otherwise, it is non zero */
+/**
+ * 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)
@@ -634,6 +641,18 @@ void avcodec_default_free_buffers(AVCodecContext *s){
s->internal_buffer_count=0;
}
+char av_get_pict_type_char(int pict_type){
+ switch(pict_type){
+ case I_TYPE: return 'I';
+ case P_TYPE: return 'P';
+ case B_TYPE: return 'B';
+ case S_TYPE: return 'S';
+ case SI_TYPE:return 'i';
+ case SP_TYPE:return 'p';
+ default: return '?';
+ }
+}
+
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
int exact=1, sign=0;
int64_t gcd, larger;
diff --git a/src/libffmpeg/libavcodec/vp3.c b/src/libffmpeg/libavcodec/vp3.c
new file mode 100644
index 000000000..1f87086c2
--- /dev/null
+++ b/src/libffmpeg/libavcodec/vp3.c
@@ -0,0 +1,2553 @@
+/*
+ *
+ * Copyright (C) 2003 the ffmpeg project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * VP3 Video Decoder by Mike Melanson (melanson@pcisys.net)
+ *
+ */
+
+/**
+ * @file vp3.c
+ * On2 VP3 Video Decoder
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "avcodec.h"
+#include "dsputil.h"
+#include "mpegvideo.h"
+#include "dsputil.h"
+
+#include "vp3data.h"
+
+#define FRAGMENT_PIXELS 8
+
+/*
+ * Debugging Variables
+ *
+ * Define one or more of the following compile-time variables to 1 to obtain
+ * elaborate information about certain aspects of the decoding process.
+ *
+ * KEYFRAMES_ONLY: set this to 1 to only see keyframes (VP3 slideshow mode)
+ * DEBUG_VP3: high-level decoding flow
+ * DEBUG_INIT: initialization parameters
+ * DEBUG_DEQUANTIZERS: display how the dequanization tables are built
+ * DEBUG_BLOCK_CODING: unpacking the superblock/macroblock/fragment coding
+ * DEBUG_MODES: unpacking the coding modes for individual fragments
+ * DEBUG_VECTORS: display the motion vectors
+ * DEBUG_TOKEN: display exhaustive information about each DCT token
+ * DEBUG_VLC: display the VLCs as they are extracted from the stream
+ * DEBUG_DC_PRED: display the process of reversing DC prediction
+ * DEBUG_IDCT: show every detail of the IDCT process
+ */
+
+#define KEYFRAMES_ONLY 0
+
+#define DEBUG_VP3 0
+#define DEBUG_INIT 0
+#define DEBUG_DEQUANTIZERS 0
+#define DEBUG_BLOCK_CODING 0
+#define DEBUG_MODES 0
+#define DEBUG_VECTORS 0
+#define DEBUG_TOKEN 0
+#define DEBUG_VLC 0
+#define DEBUG_DC_PRED 0
+#define DEBUG_IDCT 0
+
+#if DEBUG_VP3
+#define debug_vp3 printf
+#else
+static inline void debug_vp3(const char *format, ...) { }
+#endif
+
+#if DEBUG_INIT
+#define debug_init printf
+#else
+static inline void debug_init(const char *format, ...) { }
+#endif
+
+#if DEBUG_DEQUANTIZERS
+#define debug_dequantizers printf
+#else
+static inline void debug_dequantizers(const char *format, ...) { }
+#endif
+
+#if DEBUG_BLOCK_CODING
+#define debug_block_coding printf
+#else
+static inline void debug_block_coding(const char *format, ...) { }
+#endif
+
+#if DEBUG_MODES
+#define debug_modes printf
+#else
+static inline void debug_modes(const char *format, ...) { }
+#endif
+
+#if DEBUG_VECTORS
+#define debug_vectors printf
+#else
+static inline void debug_vectors(const char *format, ...) { }
+#endif
+
+#if DEBUG_TOKEN
+#define debug_token printf
+#else
+static inline void debug_token(const char *format, ...) { }
+#endif
+
+#if DEBUG_VLC
+#define debug_vlc printf
+#else
+static inline void debug_vlc(const char *format, ...) { }
+#endif
+
+#if DEBUG_DC_PRED
+#define debug_dc_pred printf
+#else
+static inline void debug_dc_pred(const char *format, ...) { }
+#endif
+
+#if DEBUG_IDCT
+#define debug_idct printf
+#else
+static inline void debug_idct(const char *format, ...) { }
+#endif
+
+typedef struct Vp3Fragment {
+ DCTELEM coeffs[64];
+ int coding_method;
+ int coeff_count;
+ int last_coeff;
+ int motion_x;
+ int motion_y;
+ /* address of first pixel taking into account which plane the fragment
+ * lives on as well as the plane stride */
+ int first_pixel;
+ /* this is the macroblock that the fragment belongs to */
+ int macroblock;
+} Vp3Fragment;
+
+#define SB_NOT_CODED 0
+#define SB_PARTIALLY_CODED 1
+#define SB_FULLY_CODED 2
+
+#define MODE_INTER_NO_MV 0
+#define MODE_INTRA 1
+#define MODE_INTER_PLUS_MV 2
+#define MODE_INTER_LAST_MV 3
+#define MODE_INTER_PRIOR_LAST 4
+#define MODE_USING_GOLDEN 5
+#define MODE_GOLDEN_MV 6
+#define MODE_INTER_FOURMV 7
+#define CODING_MODE_COUNT 8
+
+/* special internal mode */
+#define MODE_COPY 8
+
+/* There are 6 preset schemes, plus a free-form scheme */
+static int ModeAlphabet[7][CODING_MODE_COUNT] =
+{
+ /* this is the custom scheme */
+ { 0, 0, 0, 0, 0, 0, 0, 0 },
+
+ /* scheme 1: Last motion vector dominates */
+ { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTER_PLUS_MV, MODE_INTER_NO_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+
+ /* scheme 2 */
+ { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTER_NO_MV, MODE_INTER_PLUS_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+
+ /* scheme 3 */
+ { MODE_INTER_LAST_MV, MODE_INTER_PLUS_MV,
+ MODE_INTER_PRIOR_LAST, MODE_INTER_NO_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+
+ /* scheme 4 */
+ { MODE_INTER_LAST_MV, MODE_INTER_PLUS_MV,
+ MODE_INTER_NO_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+
+ /* scheme 5: No motion vector dominates */
+ { MODE_INTER_NO_MV, MODE_INTER_LAST_MV,
+ MODE_INTER_PRIOR_LAST, MODE_INTER_PLUS_MV,
+ MODE_INTRA, MODE_USING_GOLDEN,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+
+ /* scheme 6 */
+ { MODE_INTER_NO_MV, MODE_USING_GOLDEN,
+ MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST,
+ MODE_INTER_PLUS_MV, MODE_INTRA,
+ MODE_GOLDEN_MV, MODE_INTER_FOURMV },
+
+};
+
+#define MIN_DEQUANT_VAL 2
+
+typedef struct Vp3DecodeContext {
+ AVCodecContext *avctx;
+ int width, height;
+ AVFrame golden_frame;
+ AVFrame last_frame;
+ AVFrame current_frame;
+ int keyframe;
+ DSPContext dsp;
+
+ int quality_index;
+ int last_quality_index;
+
+ int superblock_count;
+ int superblock_width;
+ int superblock_height;
+ int y_superblock_width;
+ int y_superblock_height;
+ int c_superblock_width;
+ int c_superblock_height;
+ int u_superblock_start;
+ int v_superblock_start;
+ unsigned char *superblock_coding;
+
+ int macroblock_count;
+ int macroblock_width;
+ int macroblock_height;
+
+ int fragment_count;
+ int fragment_width;
+ int fragment_height;
+
+ Vp3Fragment *all_fragments;
+ int u_fragment_start;
+ int v_fragment_start;
+
+ /* this is a list of indices into the all_fragments array indicating
+ * which of the fragments are coded */
+ int *coded_fragment_list;
+ int coded_fragment_list_index;
+ int pixel_addresses_inited;
+
+ VLC dc_vlc[16];
+ VLC ac_vlc_1[16];
+ VLC ac_vlc_2[16];
+ VLC ac_vlc_3[16];
+ VLC ac_vlc_4[16];
+
+ int16_t intra_y_dequant[64];
+ int16_t intra_c_dequant[64];
+ int16_t inter_dequant[64];
+
+ /* This table contains superblock_count * 16 entries. Each set of 16
+ * numbers corresponds to the fragment indices 0..15 of the superblock.
+ * An entry will be -1 to indicate that no entry corresponds to that
+ * index. */
+ int *superblock_fragments;
+
+ /* This table contains superblock_count * 4 entries. Each set of 4
+ * numbers corresponds to the macroblock indices 0..3 of the superblock.
+ * An entry will be -1 to indicate that no entry corresponds to that
+ * index. */
+ int *superblock_macroblocks;
+
+ /* This table contains macroblock_count * 6 entries. Each set of 6
+ * numbers corresponds to the fragment indices 0..5 which comprise
+ * the macroblock (4 Y fragments and 2 C fragments). */
+ int *macroblock_fragments;
+ /* This is an array that indicates how a particular macroblock
+ * is coded. */
+ unsigned char *macroblock_coding;
+
+ int first_coded_y_fragment;
+ int first_coded_c_fragment;
+ int last_coded_y_fragment;
+ int last_coded_c_fragment;
+
+} Vp3DecodeContext;
+
+/************************************************************************
+ * VP3 specific functions
+ ************************************************************************/
+
+/*
+ * This function sets up all of the various blocks mappings:
+ * superblocks <-> fragments, macroblocks <-> fragments,
+ * superblocks <-> macroblocks
+ *
+ * Returns 0 is successful; returns 1 if *anything* went wrong.
+ */
+static int init_block_mapping(Vp3DecodeContext *s)
+{
+ int i, j;
+ signed int hilbert_walk_y[16];
+ signed int hilbert_walk_c[16];
+ signed int hilbert_walk_mb[4];
+
+ int current_fragment = 0;
+ int current_width = 0;
+ int current_height = 0;
+ int right_edge = 0;
+ int bottom_edge = 0;
+ int superblock_row_inc = 0;
+ int *hilbert = NULL;
+ int mapping_index = 0;
+
+ int current_macroblock;
+ int c_fragment;
+
+ signed char travel_width[16] = {
+ 1, 1, 0, -1,
+ 0, 0, 1, 0,
+ 1, 0, 1, 0,
+ 0, -1, 0, 1
+ };
+
+ signed char travel_height[16] = {
+ 0, 0, 1, 0,
+ 1, 1, 0, -1,
+ 0, 1, 0, -1,
+ -1, 0, -1, 0
+ };
+
+ signed char travel_width_mb[4] = {
+ 1, 0, 1, 0
+ };
+
+ signed char travel_height_mb[4] = {
+ 0, 1, 0, -1
+ };
+
+ debug_vp3(" vp3: initialize block mapping tables\n");
+
+ /* figure out hilbert pattern per these frame dimensions */
+ hilbert_walk_y[0] = 1;
+ hilbert_walk_y[1] = 1;
+ hilbert_walk_y[2] = s->fragment_width;
+ hilbert_walk_y[3] = -1;
+ hilbert_walk_y[4] = s->fragment_width;
+ hilbert_walk_y[5] = s->fragment_width;
+ hilbert_walk_y[6] = 1;
+ hilbert_walk_y[7] = -s->fragment_width;
+ hilbert_walk_y[8] = 1;
+ hilbert_walk_y[9] = s->fragment_width;
+ hilbert_walk_y[10] = 1;
+ hilbert_walk_y[11] = -s->fragment_width;
+ hilbert_walk_y[12] = -s->fragment_width;
+ hilbert_walk_y[13] = -1;
+ hilbert_walk_y[14] = -s->fragment_width;
+ hilbert_walk_y[15] = 1;
+
+ hilbert_walk_c[0] = 1;
+ hilbert_walk_c[1] = 1;
+ hilbert_walk_c[2] = s->fragment_width / 2;
+ hilbert_walk_c[3] = -1;
+ hilbert_walk_c[4] = s->fragment_width / 2;
+ hilbert_walk_c[5] = s->fragment_width / 2;
+ hilbert_walk_c[6] = 1;
+ hilbert_walk_c[7] = -s->fragment_width / 2;
+ hilbert_walk_c[8] = 1;
+ hilbert_walk_c[9] = s->fragment_width / 2;
+ hilbert_walk_c[10] = 1;
+ hilbert_walk_c[11] = -s->fragment_width / 2;
+ hilbert_walk_c[12] = -s->fragment_width / 2;
+ hilbert_walk_c[13] = -1;
+ hilbert_walk_c[14] = -s->fragment_width / 2;
+ hilbert_walk_c[15] = 1;
+
+ hilbert_walk_mb[0] = 1;
+ hilbert_walk_mb[1] = s->macroblock_width;
+ hilbert_walk_mb[2] = 1;
+ hilbert_walk_mb[3] = -s->macroblock_width;
+
+ /* iterate through each superblock (all planes) and map the fragments */
+ for (i = 0; i < s->superblock_count; i++) {
+ debug_init(" superblock %d (u starts @ %d, v starts @ %d)\n",
+ i, s->u_superblock_start, s->v_superblock_start);
+
+ /* time to re-assign the limits? */
+ if (i == 0) {
+
+ /* start of Y superblocks */
+ right_edge = s->fragment_width;
+ bottom_edge = s->fragment_height;
+ current_width = -1;
+ current_height = 0;
+ superblock_row_inc = 3 * s->fragment_width -
+ (s->y_superblock_width * 4 - s->fragment_width);
+ hilbert = hilbert_walk_y;
+
+ /* the first operation for this variable is to advance by 1 */
+ current_fragment = -1;
+
+ } else if (i == s->u_superblock_start) {
+
+ /* start of U superblocks */
+ right_edge = s->fragment_width / 2;
+ bottom_edge = s->fragment_height / 2;
+ current_width = -1;
+ current_height = 0;
+ superblock_row_inc = 3 * (s->fragment_width / 2) -
+ (s->c_superblock_width * 4 - s->fragment_width / 2);
+ hilbert = hilbert_walk_c;
+
+ /* the first operation for this variable is to advance by 1 */
+ current_fragment = s->u_fragment_start - 1;
+
+ } else if (i == s->v_superblock_start) {
+
+ /* start of V superblocks */
+ right_edge = s->fragment_width / 2;
+ bottom_edge = s->fragment_height / 2;
+ current_width = -1;
+ current_height = 0;
+ superblock_row_inc = 3 * (s->fragment_width / 2) -
+ (s->c_superblock_width * 4 - s->fragment_width / 2);
+ hilbert = hilbert_walk_c;
+
+ /* the first operation for this variable is to advance by 1 */
+ current_fragment = s->v_fragment_start - 1;
+
+ }
+
+ if (current_width >= right_edge - 1) {
+ /* reset width and move to next superblock row */
+ current_width = -1;
+ current_height += 4;
+
+ /* fragment is now at the start of a new superblock row */
+ current_fragment += superblock_row_inc;
+ }
+
+ /* iterate through all 16 fragments in a superblock */
+ for (j = 0; j < 16; j++) {
+ current_fragment += hilbert[j];
+ current_width += travel_width[j];
+ current_height += travel_height[j];
+
+ /* check if the fragment is in bounds */
+ if ((current_width < right_edge) &&
+ (current_height < bottom_edge)) {
+ s->superblock_fragments[mapping_index] = current_fragment;
+ debug_init(" mapping fragment %d to superblock %d, position %d (%d/%d x %d/%d)\n",
+ s->superblock_fragments[mapping_index], i, j,
+ current_width, right_edge, current_height, bottom_edge);
+ } else {
+ s->superblock_fragments[mapping_index] = -1;
+ debug_init(" superblock %d, position %d has no fragment (%d/%d x %d/%d)\n",
+ i, j,
+ current_width, right_edge, current_height, bottom_edge);
+ }
+
+ mapping_index++;
+ }
+ }
+
+ /* initialize the superblock <-> macroblock mapping; iterate through
+ * all of the Y plane superblocks to build this mapping */
+ right_edge = s->macroblock_width;
+ bottom_edge = s->macroblock_height;
+ current_width = -1;
+ current_height = 0;
+ superblock_row_inc = s->macroblock_width -
+ (s->y_superblock_width * 2 - s->macroblock_width);;
+ hilbert = hilbert_walk_mb;
+ mapping_index = 0;
+ current_macroblock = -1;
+ for (i = 0; i < s->u_superblock_start; i++) {
+
+ if (current_width >= right_edge - 1) {
+ /* reset width and move to next superblock row */
+ current_width = -1;
+ current_height += 2;
+
+ /* macroblock is now at the start of a new superblock row */
+ current_macroblock += superblock_row_inc;
+ }
+
+ /* iterate through each potential macroblock in the superblock */
+ for (j = 0; j < 4; j++) {
+ current_macroblock += hilbert_walk_mb[j];
+ current_width += travel_width_mb[j];
+ current_height += travel_height_mb[j];
+
+ /* check if the macroblock is in bounds */
+ if ((current_width < right_edge) &&
+ (current_height < bottom_edge)) {
+ s->superblock_macroblocks[mapping_index] = current_macroblock;
+ debug_init(" mapping macroblock %d to superblock %d, position %d (%d/%d x %d/%d)\n",
+ s->superblock_macroblocks[mapping_index], i, j,
+ current_width, right_edge, current_height, bottom_edge);
+ } else {
+ s->superblock_macroblocks[mapping_index] = -1;
+ debug_init(" superblock %d, position %d has no macroblock (%d/%d x %d/%d)\n",
+ i, j,
+ current_width, right_edge, current_height, bottom_edge);
+ }
+
+ mapping_index++;
+ }
+ }
+
+ /* initialize the macroblock <-> fragment mapping */
+ current_fragment = 0;
+ current_macroblock = 0;
+ mapping_index = 0;
+ for (i = 0; i < s->fragment_height; i += 2) {
+
+ for (j = 0; j < s->fragment_width; j += 2) {
+
+ debug_init(" macroblock %d contains fragments: ", current_macroblock);
+ s->all_fragments[current_fragment].macroblock = current_macroblock;
+ s->macroblock_fragments[mapping_index++] = current_fragment;
+ debug_init("%d ", current_fragment);
+
+ if (j + 1 < s->fragment_width) {
+ s->all_fragments[current_fragment + 1].macroblock = current_macroblock;
+ s->macroblock_fragments[mapping_index++] = current_fragment + 1;
+ debug_init("%d ", current_fragment + 1);
+ } else
+ s->macroblock_fragments[mapping_index++] = -1;
+
+ if (i + 1 < s->fragment_height) {
+ s->all_fragments[current_fragment + s->fragment_width].macroblock =
+ current_macroblock;
+ s->macroblock_fragments[mapping_index++] =
+ current_fragment + s->fragment_width;
+ debug_init("%d ", current_fragment + s->fragment_width);
+ } else
+ s->macroblock_fragments[mapping_index++] = -1;
+
+ if ((j + 1 < s->fragment_width) && (i + 1 < s->fragment_height)) {
+ s->all_fragments[current_fragment + s->fragment_width + 1].macroblock =
+ current_macroblock;
+ s->macroblock_fragments[mapping_index++] =
+ current_fragment + s->fragment_width + 1;
+ debug_init("%d ", current_fragment + s->fragment_width + 1);
+ } else
+ s->macroblock_fragments[mapping_index++] = -1;
+
+ /* C planes */
+ c_fragment = s->u_fragment_start +
+ (i * s->fragment_width / 4) + (j / 2);
+ s->all_fragments[c_fragment].macroblock = s->macroblock_count;
+ s->macroblock_fragments[mapping_index++] = c_fragment;
+ debug_init("%d ", c_fragment);
+
+ c_fragment = s->v_fragment_start +
+ (i * s->fragment_width / 4) + (j / 2);
+ s->all_fragments[c_fragment].macroblock = s->macroblock_count;
+ s->macroblock_fragments[mapping_index++] = c_fragment;
+ debug_init("%d ", c_fragment);
+
+ debug_init("\n");
+
+ if (j + 2 <= s->fragment_width)
+ current_fragment += 2;
+ else
+ current_fragment++;
+ current_macroblock++;
+ }
+
+ current_fragment += s->fragment_width;
+ }
+
+ return 0; /* successful path out */
+}
+
+/*
+ * This function unpacks a single token (which should be in the range 0..31)
+ * and returns a zero run (number of zero coefficients in current DCT matrix
+ * before next non-zero coefficient), the next DCT coefficient, and the
+ * number of consecutive, non-EOB'd DCT blocks to EOB.
+ */
+static void unpack_token(GetBitContext *gb, int token, int *zero_run,
+ DCTELEM *coeff, int *eob_run)
+{
+ int sign;
+
+ *zero_run = 0;
+ *eob_run = 0;
+ *coeff = 0;
+
+ debug_token(" vp3 token %d: ", token);
+ switch (token) {
+
+ case 0:
+ debug_token("DCT_EOB_TOKEN, EOB next block\n");
+ *eob_run = 1;
+ break;
+
+ case 1:
+ debug_token("DCT_EOB_PAIR_TOKEN, EOB next 2 blocks\n");
+ *eob_run = 2;
+ break;
+
+ case 2:
+ debug_token("DCT_EOB_TRIPLE_TOKEN, EOB next 3 blocks\n");
+ *eob_run = 3;
+ break;
+
+ case 3:
+ debug_token("DCT_REPEAT_RUN_TOKEN, ");
+ *eob_run = get_bits(gb, 2) + 4;
+ debug_token("EOB the next %d blocks\n", *eob_run);
+ break;
+
+ case 4:
+ debug_token("DCT_REPEAT_RUN2_TOKEN, ");
+ *eob_run = get_bits(gb, 3) + 8;
+ debug_token("EOB the next %d blocks\n", *eob_run);
+ break;
+
+ case 5:
+ debug_token("DCT_REPEAT_RUN3_TOKEN, ");
+ *eob_run = get_bits(gb, 4) + 16;
+ debug_token("EOB the next %d blocks\n", *eob_run);
+ break;
+
+ case 6:
+ debug_token("DCT_REPEAT_RUN4_TOKEN, ");
+ *eob_run = get_bits(gb, 12);
+ debug_token("EOB the next %d blocks\n", *eob_run);
+ break;
+
+ case 7:
+ debug_token("DCT_SHORT_ZRL_TOKEN, ");
+ /* note that this token actually indicates that (3 extra bits) + 1 0s
+ * should be output; this case specifies a run of (3 EBs) 0s and a
+ * coefficient of 0. */
+ *zero_run = get_bits(gb, 3);
+ *coeff = 0;
+ debug_token("skip the next %d positions in output matrix\n", *zero_run + 1);
+ break;
+
+ case 8:
+ debug_token("DCT_ZRL_TOKEN, ");
+ /* note that this token actually indicates that (6 extra bits) + 1 0s
+ * should be output; this case specifies a run of (6 EBs) 0s and a
+ * coefficient of 0. */
+ *zero_run = get_bits(gb, 6);
+ *coeff = 0;
+ debug_token("skip the next %d positions in output matrix\n", *zero_run + 1);
+ break;
+
+ case 9:
+ debug_token("ONE_TOKEN, output 1\n");
+ *coeff = 1;
+ break;
+
+ case 10:
+ debug_token("MINUS_ONE_TOKEN, output -1\n");
+ *coeff = -1;
+ break;
+
+ case 11:
+ debug_token("TWO_TOKEN, output 2\n");
+ *coeff = 2;
+ break;
+
+ case 12:
+ debug_token("MINUS_TWO_TOKEN, output -2\n");
+ *coeff = -2;
+ break;
+
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ debug_token("LOW_VAL_TOKENS, ");
+ if (get_bits(gb, 1))
+ *coeff = -(3 + (token - 13));
+ else
+ *coeff = 3 + (token - 13);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 17:
+ debug_token("DCT_VAL_CATEGORY3, ");
+ sign = get_bits(gb, 1);
+ *coeff = 7 + get_bits(gb, 1);
+ if (sign)
+ *coeff = -(*coeff);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 18:
+ debug_token("DCT_VAL_CATEGORY4, ");
+ sign = get_bits(gb, 1);
+ *coeff = 9 + get_bits(gb, 2);
+ if (sign)
+ *coeff = -(*coeff);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 19:
+ debug_token("DCT_VAL_CATEGORY5, ");
+ sign = get_bits(gb, 1);
+ *coeff = 13 + get_bits(gb, 3);
+ if (sign)
+ *coeff = -(*coeff);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 20:
+ debug_token("DCT_VAL_CATEGORY6, ");
+ sign = get_bits(gb, 1);
+ *coeff = 21 + get_bits(gb, 4);
+ if (sign)
+ *coeff = -(*coeff);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 21:
+ debug_token("DCT_VAL_CATEGORY7, ");
+ sign = get_bits(gb, 1);
+ *coeff = 37 + get_bits(gb, 5);
+ if (sign)
+ *coeff = -(*coeff);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 22:
+ debug_token("DCT_VAL_CATEGORY8, ");
+ sign = get_bits(gb, 1);
+ *coeff = 69 + get_bits(gb, 9);
+ if (sign)
+ *coeff = -(*coeff);
+ debug_token("output %d\n", *coeff);
+ break;
+
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ debug_token("DCT_RUN_CATEGORY1, ");
+ *zero_run = token - 22;
+ if (get_bits(gb, 1))
+ *coeff = -1;
+ else
+ *coeff = 1;
+ debug_token("output %d 0s, then %d\n", *zero_run, *coeff);
+ break;
+
+ case 28:
+ debug_token("DCT_RUN_CATEGORY1B, ");
+ if (get_bits(gb, 1))
+ *coeff = -1;
+ else
+ *coeff = 1;
+ *zero_run = 6 + get_bits(gb, 2);
+ debug_token("output %d 0s, then %d\n", *zero_run, *coeff);
+ break;
+
+ case 29:
+ debug_token("DCT_RUN_CATEGORY1C, ");
+ if (get_bits(gb, 1))
+ *coeff = -1;
+ else
+ *coeff = 1;
+ *zero_run = 10 + get_bits(gb, 3);
+ debug_token("output %d 0s, then %d\n", *zero_run, *coeff);
+ break;
+
+ case 30:
+ debug_token("DCT_RUN_CATEGORY2, ");
+ sign = get_bits(gb, 1);
+ *coeff = 2 + get_bits(gb, 1);
+ if (sign)
+ *coeff = -(*coeff);
+ *zero_run = 1;
+ debug_token("output %d 0s, then %d\n", *zero_run, *coeff);
+ break;
+
+ case 31:
+ debug_token("DCT_RUN_CATEGORY2, ");
+ sign = get_bits(gb, 1);
+ *coeff = 2 + get_bits(gb, 1);
+ if (sign)
+ *coeff = -(*coeff);
+ *zero_run = 2 + get_bits(gb, 1);
+ debug_token("output %d 0s, then %d\n", *zero_run, *coeff);
+ break;
+
+ default:
+ printf (" vp3: help! Got a bad token: %d > 31\n", token);
+ break;
+
+ }
+}
+
+/*
+ * This function wipes out all of the fragment data.
+ */
+static void init_frame(Vp3DecodeContext *s, GetBitContext *gb)
+{
+ int i;
+
+ /* zero out all of the fragment information */
+ s->coded_fragment_list_index = 0;
+ for (i = 0; i < s->fragment_count; i++) {
+ memset(s->all_fragments[i].coeffs, 0, 64 * sizeof(DCTELEM));
+ s->all_fragments[i].coeff_count = 0;
+ s->all_fragments[i].last_coeff = 0;
+s->all_fragments[i].motion_x = 0xbeef;
+s->all_fragments[i].motion_y = 0xbeef;
+ }
+}
+
+/*
+ * This function sets of the dequantization tables used for a particular
+ * frame.
+ */
+static void init_dequantizer(Vp3DecodeContext *s)
+{
+
+ int quality_scale = vp31_quality_threshold[s->quality_index];
+ int dc_scale_factor = vp31_dc_scale_factor[s->quality_index];
+ int i, j;
+
+ debug_vp3(" vp3: initializing dequantization tables\n");
+
+ /*
+ * Scale dequantizers:
+ *
+ * quantizer * sf
+ * --------------
+ * 100
+ *
+ * where sf = dc_scale_factor for DC quantizer
+ * or quality_scale for AC quantizer
+ *
+ * Then, saturate the result to a lower limit of MIN_DEQUANT_VAL.
+ */
+#define SCALER 1
+
+ /* scale DC quantizers */
+ s->intra_y_dequant[0] = vp31_intra_y_dequant[0] * dc_scale_factor / 100;
+ if (s->intra_y_dequant[0] < MIN_DEQUANT_VAL * 2)
+ s->intra_y_dequant[0] = MIN_DEQUANT_VAL * 2;
+ s->intra_y_dequant[0] *= SCALER;
+
+ s->intra_c_dequant[0] = vp31_intra_c_dequant[0] * dc_scale_factor / 100;
+ if (s->intra_c_dequant[0] < MIN_DEQUANT_VAL * 2)
+ s->intra_c_dequant[0] = MIN_DEQUANT_VAL * 2;
+ s->intra_c_dequant[0] *= SCALER;
+
+ s->inter_dequant[0] = vp31_inter_dequant[0] * dc_scale_factor / 100;
+ if (s->inter_dequant[0] < MIN_DEQUANT_VAL * 4)
+ s->inter_dequant[0] = MIN_DEQUANT_VAL * 4;
+ s->inter_dequant[0] *= SCALER;
+
+ /* scale AC quantizers, zigzag at the same time in preparation for
+ * the dequantization phase */
+ for (i = 1; i < 64; i++) {
+
+ j = zigzag_index[i];
+
+ s->intra_y_dequant[j] = vp31_intra_y_dequant[i] * quality_scale / 100;
+ if (s->intra_y_dequant[j] < MIN_DEQUANT_VAL)
+ s->intra_y_dequant[j] = MIN_DEQUANT_VAL;
+ s->intra_y_dequant[j] *= SCALER;
+
+ s->intra_c_dequant[j] = vp31_intra_c_dequant[i] * quality_scale / 100;
+ if (s->intra_c_dequant[j] < MIN_DEQUANT_VAL)
+ s->intra_c_dequant[j] = MIN_DEQUANT_VAL;
+ s->intra_c_dequant[j] *= SCALER;
+
+ s->inter_dequant[j] = vp31_inter_dequant[i] * quality_scale / 100;
+ if (s->inter_dequant[j] < MIN_DEQUANT_VAL * 2)
+ s->inter_dequant[j] = MIN_DEQUANT_VAL * 2;
+ s->inter_dequant[j] *= SCALER;
+ }
+
+ /* print debug information as requested */
+ debug_dequantizers("intra Y dequantizers:\n");
+ for (i = 0; i < 8; i++) {
+ for (j = i * 8; j < i * 8 + 8; j++) {
+ debug_dequantizers(" %4d,", s->intra_y_dequant[j]);
+ }
+ debug_dequantizers("\n");
+ }
+ debug_dequantizers("\n");
+
+ debug_dequantizers("intra C dequantizers:\n");
+ for (i = 0; i < 8; i++) {
+ for (j = i * 8; j < i * 8 + 8; j++) {
+ debug_dequantizers(" %4d,", s->intra_c_dequant[j]);
+ }
+ debug_dequantizers("\n");
+ }
+ debug_dequantizers("\n");
+
+ debug_dequantizers("interframe dequantizers:\n");
+ for (i = 0; i < 8; i++) {
+ for (j = i * 8; j < i * 8 + 8; j++) {
+ debug_dequantizers(" %4d,", s->inter_dequant[j]);
+ }
+ debug_dequantizers("\n");
+ }
+ debug_dequantizers("\n");
+}
+
+/*
+ * This function is used to fetch runs of 1s or 0s from the bitstream for
+ * use in determining which superblocks are fully and partially coded.
+ *
+ * Codeword RunLength
+ * 0 1
+ * 10x 2-3
+ * 110x 4-5
+ * 1110xx 6-9
+ * 11110xxx 10-17
+ * 111110xxxx 18-33
+ * 111111xxxxxxxxxxxx 34-4129
+ */
+static int get_superblock_run_length(GetBitContext *gb)
+{
+
+ if (get_bits(gb, 1) == 0)
+ return 1;
+
+ else if (get_bits(gb, 1) == 0)
+ return (2 + get_bits(gb, 1));
+
+ else if (get_bits(gb, 1) == 0)
+ return (4 + get_bits(gb, 1));
+
+ else if (get_bits(gb, 1) == 0)
+ return (6 + get_bits(gb, 2));
+
+ else if (get_bits(gb, 1) == 0)
+ return (10 + get_bits(gb, 3));
+
+ else if (get_bits(gb, 1) == 0)
+ return (18 + get_bits(gb, 4));
+
+ else
+ return (34 + get_bits(gb, 12));
+
+}
+
+/*
+ * This function is used to fetch runs of 1s or 0s from the bitstream for
+ * use in determining which particular fragments are coded.
+ *
+ * Codeword RunLength
+ * 0x 1-2
+ * 10x 3-4
+ * 110x 5-6
+ * 1110xx 7-10
+ * 11110xx 11-14
+ * 11111xxxx 15-30
+ */
+static int get_fragment_run_length(GetBitContext *gb)
+{
+
+ if (get_bits(gb, 1) == 0)
+ return (1 + get_bits(gb, 1));
+
+ else if (get_bits(gb, 1) == 0)
+ return (3 + get_bits(gb, 1));
+
+ else if (get_bits(gb, 1) == 0)
+ return (5 + get_bits(gb, 1));
+
+ else if (get_bits(gb, 1) == 0)
+ return (7 + get_bits(gb, 2));
+
+ else if (get_bits(gb, 1) == 0)
+ return (11 + get_bits(gb, 2));
+
+ else
+ return (15 + get_bits(gb, 4));
+
+}
+
+/*
+ * This function decodes a VLC from the bitstream and returns a number
+ * that ranges from 0..7. The number indicates which of the 8 coding
+ * modes to use.
+ *
+ * VLC Number
+ * 0 0
+ * 10 1
+ * 110 2
+ * 1110 3
+ * 11110 4
+ * 111110 5
+ * 1111110 6
+ * 1111111 7
+ *
+ */
+static int get_mode_code(GetBitContext *gb)
+{
+
+ if (get_bits(gb, 1) == 0)
+ return 0;
+
+ else if (get_bits(gb, 1) == 0)
+ return 1;
+
+ else if (get_bits(gb, 1) == 0)
+ return 2;
+
+ else if (get_bits(gb, 1) == 0)
+ return 3;
+
+ else if (get_bits(gb, 1) == 0)
+ return 4;
+
+ else if (get_bits(gb, 1) == 0)
+ return 5;
+
+ else if (get_bits(gb, 1) == 0)
+ return 6;
+
+ else
+ return 7;
+
+}
+
+/*
+ * This function extracts a motion vector from the bitstream using a VLC
+ * scheme. 3 bits are fetched from the bitstream and 1 of 8 actions is
+ * taken depending on the value on those 3 bits:
+ *
+ * 0: return 0
+ * 1: return 1
+ * 2: return -1
+ * 3: if (next bit is 1) return -2, else return 2
+ * 4: if (next bit is 1) return -3, else return 3
+ * 5: return 4 + (next 2 bits), next bit is sign
+ * 6: return 8 + (next 3 bits), next bit is sign
+ * 7: return 16 + (next 4 bits), next bit is sign
+ */
+static int get_motion_vector_vlc(GetBitContext *gb)
+{
+ int bits;
+
+ bits = get_bits(gb, 3);
+
+ switch(bits) {
+
+ case 0:
+ bits = 0;
+ break;
+
+ case 1:
+ bits = 1;
+ break;
+
+ case 2:
+ bits = -1;
+ break;
+
+ case 3:
+ if (get_bits(gb, 1) == 0)
+ bits = 2;
+ else
+ bits = -2;
+ break;
+
+ case 4:
+ if (get_bits(gb, 1) == 0)
+ bits = 3;
+ else
+ bits = -3;
+ break;
+
+ case 5:
+ bits = 4 + get_bits(gb, 2);
+ if (get_bits(gb, 1) == 1)
+ bits = -bits;
+ break;
+
+ case 6:
+ bits = 8 + get_bits(gb, 3);
+ if (get_bits(gb, 1) == 1)
+ bits = -bits;
+ break;
+
+ case 7:
+ bits = 16 + get_bits(gb, 4);
+ if (get_bits(gb, 1) == 1)
+ bits = -bits;
+ break;
+
+ }
+
+ return bits;
+}
+
+/*
+ * This function fetches a 5-bit number from the stream followed by
+ * a sign and calls it a motion vector.
+ */
+static int get_motion_vector_fixed(GetBitContext *gb)
+{
+
+ int bits;
+
+ bits = get_bits(gb, 5);
+
+ if (get_bits(gb, 1) == 1)
+ bits = -bits;
+
+ return bits;
+}
+
+/*
+ * This function unpacks all of the superblock/macroblock/fragment coding
+ * information from the bitstream.
+ */
+static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
+{
+ int bit = 0;
+ int current_superblock = 0;
+ int current_run = 0;
+ int decode_fully_flags = 0;
+ int decode_partial_blocks = 0;
+ int first_c_fragment_seen;
+
+ int i, j;
+ int current_fragment;
+
+ debug_vp3(" vp3: unpacking superblock coding\n");
+
+ if (s->keyframe) {
+
+ debug_vp3(" keyframe-- all superblocks are fully coded\n");
+ memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count);
+
+ } else {
+
+ /* unpack the list of partially-coded superblocks */
+ bit = get_bits(gb, 1);
+ /* toggle the bit because as soon as the first run length is
+ * fetched the bit will be toggled again */
+ bit ^= 1;
+ while (current_superblock < s->superblock_count) {
+ if (current_run == 0) {
+ bit ^= 1;
+ current_run = get_superblock_run_length(gb);
+ debug_block_coding(" setting superblocks %d..%d to %s\n",
+ current_superblock,
+ current_superblock + current_run - 1,
+ (bit) ? "partially coded" : "not coded");
+
+ /* if any of the superblocks are not partially coded, flag
+ * a boolean to decode the list of fully-coded superblocks */
+ if (bit == 0) {
+ decode_fully_flags = 1;
+ } else {
+
+ /* make a note of the fact that there are partially coded
+ * superblocks */
+ decode_partial_blocks = 1;
+ }
+ }
+ s->superblock_coding[current_superblock++] =
+ (bit) ? SB_PARTIALLY_CODED : SB_NOT_CODED;
+ current_run--;
+ }
+
+ /* unpack the list of fully coded superblocks if any of the blocks were
+ * not marked as partially coded in the previous step */
+ if (decode_fully_flags) {
+
+ current_superblock = 0;
+ current_run = 0;
+ bit = get_bits(gb, 1);
+ /* toggle the bit because as soon as the first run length is
+ * fetched the bit will be toggled again */
+ bit ^= 1;
+ while (current_superblock < s->superblock_count) {
+
+ /* skip any superblocks already marked as partially coded */
+ if (s->superblock_coding[current_superblock] == SB_NOT_CODED) {
+
+ if (current_run == 0) {
+ bit ^= 1;
+ current_run = get_superblock_run_length(gb);
+ }
+
+ debug_block_coding(" setting superblock %d to %s\n",
+ current_superblock,
+ (bit) ? "fully coded" : "not coded");
+ s->superblock_coding[current_superblock] =
+ (bit) ? SB_FULLY_CODED : SB_NOT_CODED;
+ current_run--;
+ }
+ current_superblock++;
+ }
+ }
+
+ /* if there were partial blocks, initialize bitstream for
+ * unpacking fragment codings */
+ if (decode_partial_blocks) {
+
+ current_run = 0;
+ bit = get_bits(gb, 1);
+ /* toggle the bit because as soon as the first run length is
+ * fetched the bit will be toggled again */
+ bit ^= 1;
+ }
+ }
+
+ /* figure out which fragments are coded; iterate through each
+ * superblock (all planes) */
+ s->coded_fragment_list_index = 0;
+ s->first_coded_y_fragment = s->first_coded_c_fragment = 0;
+ s->last_coded_y_fragment = s->last_coded_c_fragment = -1;
+ first_c_fragment_seen = 0;
+ memset(s->macroblock_coding, MODE_COPY, s->macroblock_count);
+ for (i = 0; i < s->superblock_count; i++) {
+
+ /* iterate through all 16 fragments in a superblock */
+ for (j = 0; j < 16; j++) {
+
+ /* if the fragment is in bounds, check its coding status */
+ current_fragment = s->superblock_fragments[i * 16 + j];
+ if (current_fragment >= s->fragment_count) {
+ printf (" vp3:unpack_superblocks(): bad fragment number (%d >= %d)\n",
+ current_fragment, s->fragment_count);
+ return 1;
+ }
+ if (current_fragment != -1) {
+ if (s->superblock_coding[i] == SB_NOT_CODED) {
+
+ /* copy all the fragments from the prior frame */
+ s->all_fragments[current_fragment].coding_method =
+ MODE_COPY;
+
+ } else if (s->superblock_coding[i] == SB_PARTIALLY_CODED) {
+
+ /* fragment may or may not be coded; this is the case
+ * that cares about the fragment coding runs */
+ if (current_run == 0) {
+ bit ^= 1;
+ current_run = get_fragment_run_length(gb);
+ }
+
+ if (bit) {
+ /* default mode; actual mode will be decoded in
+ * the next phase */
+ s->all_fragments[current_fragment].coding_method =
+ MODE_INTER_NO_MV;
+ s->coded_fragment_list[s->coded_fragment_list_index] =
+ current_fragment;
+ if ((current_fragment >= s->u_fragment_start) &&
+ (s->last_coded_y_fragment == -1) &&
+ (!first_c_fragment_seen)) {
+ s->first_coded_c_fragment = s->coded_fragment_list_index;
+ s->last_coded_y_fragment = s->first_coded_c_fragment - 1;
+ first_c_fragment_seen = 1;
+ }
+ s->coded_fragment_list_index++;
+ s->macroblock_coding[s->all_fragments[current_fragment].macroblock] = MODE_INTER_NO_MV;
+ debug_block_coding(" superblock %d is partially coded, fragment %d is coded\n",
+ i, current_fragment);
+ } else {
+ /* not coded; copy this fragment from the prior frame */
+ s->all_fragments[current_fragment].coding_method =
+ MODE_COPY;
+ debug_block_coding(" superblock %d is partially coded, fragment %d is not coded\n",
+ i, current_fragment);
+ }
+
+ current_run--;
+
+ } else {
+
+ /* fragments are fully coded in this superblock; actual
+ * coding will be determined in next step */
+ s->all_fragments[current_fragment].coding_method =
+ MODE_INTER_NO_MV;
+ s->coded_fragment_list[s->coded_fragment_list_index] =
+ current_fragment;
+ if ((current_fragment >= s->u_fragment_start) &&
+ (s->last_coded_y_fragment == -1) &&
+ (!first_c_fragment_seen)) {
+ s->first_coded_c_fragment = s->coded_fragment_list_index;
+ s->last_coded_y_fragment = s->first_coded_c_fragment - 1;
+ first_c_fragment_seen = 1;
+ }
+ s->coded_fragment_list_index++;
+ s->macroblock_coding[s->all_fragments[current_fragment].macroblock] = MODE_INTER_NO_MV;
+ debug_block_coding(" superblock %d is fully coded, fragment %d is coded\n",
+ i, current_fragment);
+ }
+ }
+ }
+ }
+
+ if (!first_c_fragment_seen)
+ /* only Y fragments coded in this frame */
+ s->last_coded_y_fragment = s->coded_fragment_list_index - 1;
+ else
+ /* end the list of coded C fragments */
+ s->last_coded_c_fragment = s->coded_fragment_list_index - 1;
+
+ debug_block_coding(" %d total coded fragments, y: %d -> %d, c: %d -> %d\n",
+ s->coded_fragment_list_index,
+ s->first_coded_y_fragment,
+ s->last_coded_y_fragment,
+ s->first_coded_c_fragment,
+ s->last_coded_c_fragment);
+
+ return 0;
+}
+
+/*
+ * This function unpacks all the coding mode data for individual macroblocks
+ * from the bitstream.
+ */
+static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
+{
+ int i, j, k;
+ int scheme;
+ int current_macroblock;
+ int current_fragment;
+ int coding_mode;
+
+ debug_vp3(" vp3: unpacking encoding modes\n");
+
+ if (s->keyframe) {
+ debug_vp3(" keyframe-- all blocks are coded as INTRA\n");
+
+ for (i = 0; i < s->fragment_count; i++)
+ s->all_fragments[i].coding_method = MODE_INTRA;
+
+ } else {
+
+ /* fetch the mode coding scheme for this frame */
+ scheme = get_bits(gb, 3);
+ debug_modes(" using mode alphabet %d\n", scheme);
+
+ /* is it a custom coding scheme? */
+ if (scheme == 0) {
+ debug_modes(" custom mode alphabet ahead:\n");
+ for (i = 0; i < 8; i++)
+ ModeAlphabet[scheme][get_bits(gb, 3)] = i;
+ }
+
+ for (i = 0; i < 8; i++)
+ debug_modes(" mode[%d][%d] = %d\n", scheme, i,
+ ModeAlphabet[scheme][i]);
+
+ /* iterate through all of the macroblocks that contain 1 or more
+ * coded fragments */
+ for (i = 0; i < s->u_superblock_start; i++) {
+
+ for (j = 0; j < 4; j++) {
+ current_macroblock = s->superblock_macroblocks[i * 4 + j];
+ if ((current_macroblock == -1) ||
+ (s->macroblock_coding[current_macroblock] == MODE_COPY))
+ continue;
+ if (current_macroblock >= s->macroblock_count) {
+ printf (" vp3:unpack_modes(): bad macroblock number (%d >= %d)\n",
+ current_macroblock, s->macroblock_count);
+ return 1;
+ }
+
+ /* mode 7 means get 3 bits for each coding mode */
+ if (scheme == 7)
+ coding_mode = get_bits(gb, 3);
+ else
+ coding_mode = ModeAlphabet[scheme][get_mode_code(gb)];
+
+ s->macroblock_coding[current_macroblock] = coding_mode;
+ for (k = 0; k < 6; k++) {
+ current_fragment =
+ s->macroblock_fragments[current_macroblock * 6 + k];
+ if (current_fragment == -1)
+ continue;
+ if (current_fragment >= s->fragment_count) {
+ printf (" vp3:unpack_modes(): bad fragment number (%d >= %d)\n",
+ current_fragment, s->fragment_count);
+ return 1;
+ }
+ if (s->all_fragments[current_fragment].coding_method !=
+ MODE_COPY)
+ s->all_fragments[current_fragment].coding_method =
+ coding_mode;
+ }
+
+ debug_modes(" coding method for macroblock starting @ fragment %d = %d\n",
+ s->macroblock_fragments[current_macroblock * 6], coding_mode);
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * This function unpacks all the motion vectors for the individual
+ * macroblocks from the bitstream.
+ */
+static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
+{
+ int i, j, k;
+ int coding_mode;
+ int motion_x[6];
+ int motion_y[6];
+ int last_motion_x = 0;
+ int last_motion_y = 0;
+ int prior_last_motion_x = 0;
+ int prior_last_motion_y = 0;
+ int current_macroblock;
+ int current_fragment;
+
+ debug_vp3(" vp3: unpacking motion vectors\n");
+ if (s->keyframe) {
+
+ debug_vp3(" keyframe-- there are no motion vectors\n");
+
+ } else {
+
+ memset(motion_x, 0, 6 * sizeof(int));
+ memset(motion_y, 0, 6 * sizeof(int));
+
+ /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */
+ coding_mode = get_bits(gb, 1);
+ debug_vectors(" using %s scheme for unpacking motion vectors\n",
+ (coding_mode == 0) ? "VLC" : "fixed-length");
+
+ /* iterate through all of the macroblocks that contain 1 or more
+ * coded fragments */
+ for (i = 0; i < s->u_superblock_start; i++) {
+
+ for (j = 0; j < 4; j++) {
+ current_macroblock = s->superblock_macroblocks[i * 4 + j];
+ if ((current_macroblock == -1) ||
+ (s->macroblock_coding[current_macroblock] == MODE_COPY))
+ continue;
+ if (current_macroblock >= s->macroblock_count) {
+ printf (" vp3:unpack_vectors(): bad macroblock number (%d >= %d)\n",
+ current_macroblock, s->macroblock_count);
+ return 1;
+ }
+
+ current_fragment = s->macroblock_fragments[current_macroblock * 6];
+ if (current_fragment >= s->fragment_count) {
+ printf (" vp3:unpack_vectors(): bad fragment number (%d >= %d\n",
+ current_fragment, s->fragment_count);
+ return 1;
+ }
+ switch (s->macroblock_coding[current_macroblock]) {
+
+ case MODE_INTER_PLUS_MV:
+ case MODE_GOLDEN_MV:
+ /* all 6 fragments use the same motion vector */
+ if (coding_mode == 0) {
+ motion_x[0] = get_motion_vector_vlc(gb);
+ motion_y[0] = get_motion_vector_vlc(gb);
+ } else {
+ motion_x[0] = get_motion_vector_fixed(gb);
+ motion_y[0] = get_motion_vector_fixed(gb);
+ }
+ for (k = 1; k < 6; k++) {
+ motion_x[k] = motion_x[0];
+ motion_y[k] = motion_y[0];
+ }
+
+ /* vector maintenance, only on MODE_INTER_PLUS_MV */
+ if (s->macroblock_coding[current_macroblock] ==
+ MODE_INTER_PLUS_MV) {
+ prior_last_motion_x = last_motion_x;
+ prior_last_motion_y = last_motion_y;
+ last_motion_x = motion_x[0];
+ last_motion_y = motion_y[0];
+ }
+ break;
+
+ case MODE_INTER_FOURMV:
+ /* fetch 4 vectors from the bitstream, one for each
+ * Y fragment, then average for the C fragment vectors */
+ motion_x[4] = motion_y[4] = 0;
+ for (k = 0; k < 4; k++) {
+ if (coding_mode == 0) {
+ motion_x[k] = get_motion_vector_vlc(gb);
+ motion_y[k] = get_motion_vector_vlc(gb);
+ } else {
+ motion_x[k] = get_motion_vector_fixed(gb);
+ motion_y[k] = get_motion_vector_fixed(gb);
+ }
+ motion_x[4] += motion_x[k];
+ motion_y[4] += motion_y[k];
+ }
+
+ if (motion_x[4] >= 0)
+ motion_x[4] = (motion_x[4] + 2) / 4;
+ else
+ motion_x[4] = (motion_x[4] - 2) / 4;
+ motion_x[5] = motion_x[4];
+
+ if (motion_y[4] >= 0)
+ motion_y[4] = (motion_y[4] + 2) / 4;
+ else
+ motion_y[4] = (motion_y[4] - 2) / 4;
+ motion_y[5] = motion_y[4];
+
+ /* vector maintenance; vector[3] is treated as the
+ * last vector in this case */
+ prior_last_motion_x = last_motion_x;
+ prior_last_motion_y = last_motion_y;
+ last_motion_x = motion_x[3];
+ last_motion_y = motion_y[3];
+ break;
+
+ case MODE_INTER_LAST_MV:
+ /* all 6 fragments use the last motion vector */
+ motion_x[0] = last_motion_x;
+ motion_y[0] = last_motion_y;
+ for (k = 1; k < 6; k++) {
+ motion_x[k] = motion_x[0];
+ motion_y[k] = motion_y[0];
+ }
+
+ /* no vector maintenance (last vector remains the
+ * last vector) */
+ break;
+
+ case MODE_INTER_PRIOR_LAST:
+ /* all 6 fragments use the motion vector prior to the
+ * last motion vector */
+ motion_x[0] = prior_last_motion_x;
+ motion_y[0] = prior_last_motion_y;
+ for (k = 1; k < 6; k++) {
+ motion_x[k] = motion_x[0];
+ motion_y[k] = motion_y[0];
+ }
+
+ /* vector maintenance */
+ prior_last_motion_x = last_motion_x;
+ prior_last_motion_y = last_motion_y;
+ last_motion_x = motion_x[0];
+ last_motion_y = motion_y[0];
+ break;
+
+ default:
+ /* covers intra, inter without MV, golden without MV */
+ memset(motion_x, 0, 6 * sizeof(int));
+ memset(motion_y, 0, 6 * sizeof(int));
+
+ /* no vector maintenance */
+ break;
+ }
+
+ /* assign the motion vectors to the correct fragments */
+ debug_vectors(" vectors for macroblock starting @ fragment %d (coding method %d):\n",
+ current_fragment,
+ s->macroblock_coding[current_macroblock]);
+ for (k = 0; k < 6; k++) {
+ current_fragment =
+ s->macroblock_fragments[current_macroblock * 6 + k];
+ if (current_fragment == -1)
+ continue;
+ if (current_fragment >= s->fragment_count) {
+ printf (" vp3:unpack_vectors(): bad fragment number (%d >= %d)\n",
+ current_fragment, s->fragment_count);
+ return 1;
+ }
+ s->all_fragments[current_fragment].motion_x = motion_x[k];
+ s->all_fragments[current_fragment].motion_y = motion_y[k];
+ debug_vectors(" vector %d: fragment %d = (%d, %d)\n",
+ k, current_fragment, motion_x[k], motion_y[k]);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * This function is called by unpack_dct_coeffs() to extract the VLCs from
+ * the bitstream. The VLCs encode tokens which are used to unpack DCT
+ * data. This function unpacks all the VLCs for either the Y plane or both
+ * C planes, and is called for DC coefficients or different AC coefficient
+ * levels (since different coefficient types require different VLC tables.
+ *
+ * This function returns a residual eob run. E.g, if a particular token gave
+ * instructions to EOB the next 5 fragments and there were only 2 fragments
+ * left in the current fragment range, 3 would be returned so that it could
+ * be passed into the next call to this same function.
+ */
+static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+ VLC *table, int coeff_index,
+ int first_fragment, int last_fragment,
+ int eob_run)
+{
+ int i;
+ int token;
+ int zero_run;
+ DCTELEM coeff;
+ Vp3Fragment *fragment;
+
+ if ((first_fragment >= s->fragment_count) ||
+ (last_fragment >= s->fragment_count)) {
+
+ printf (" vp3:unpack_vlcs(): bad fragment number (%d -> %d ?)\n",
+ first_fragment, last_fragment);
+ return 0;
+ }
+
+ for (i = first_fragment; i <= last_fragment; i++) {
+
+ fragment = &s->all_fragments[s->coded_fragment_list[i]];
+ if (fragment->coeff_count > coeff_index)
+ continue;
+
+ if (!eob_run) {
+ /* decode a VLC into a token */
+ token = get_vlc2(gb, table->table, 5, 3);
+ debug_vlc(" token = %2d, ", token);
+ /* use the token to get a zero run, a coefficient, and an eob run */
+ unpack_token(gb, token, &zero_run, &coeff, &eob_run);
+ }
+
+ if (!eob_run) {
+ fragment->coeff_count += zero_run;
+ if (fragment->coeff_count < 64)
+ fragment->coeffs[fragment->coeff_count++] = coeff;
+ debug_vlc(" fragment %d coeff = %d\n",
+ s->coded_fragment_list[i], fragment->coeffs[coeff_index]);
+ } else {
+ fragment->last_coeff = fragment->coeff_count;
+ fragment->coeff_count = 64;
+ debug_vlc(" fragment %d eob with %d coefficients\n",
+ s->coded_fragment_list[i], fragment->last_coeff);
+ eob_run--;
+ }
+ }
+
+ return eob_run;
+}
+
+/*
+ * This function unpacks all of the DCT coefficient data from the
+ * bitstream.
+ */
+static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+{
+ int i;
+ int dc_y_table;
+ int dc_c_table;
+ int ac_y_table;
+ int ac_c_table;
+ int residual_eob_run = 0;
+
+ /* fetch the DC table indices */
+ dc_y_table = get_bits(gb, 4);
+ dc_c_table = get_bits(gb, 4);
+
+ /* unpack the Y plane DC coefficients */
+ debug_vp3(" vp3: unpacking Y plane DC coefficients using table %d\n",
+ dc_y_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
+ s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
+
+ /* unpack the C plane DC coefficients */
+ debug_vp3(" vp3: unpacking C plane DC coefficients using table %d\n",
+ dc_c_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
+ s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
+
+ /* fetch the AC table indices */
+ ac_y_table = get_bits(gb, 4);
+ ac_c_table = get_bits(gb, 4);
+
+ /* unpack the group 1 AC coefficients (coeffs 1-5) */
+ for (i = 1; i <= 5; i++) {
+
+ debug_vp3(" vp3: unpacking level %d Y plane AC coefficients using table %d\n",
+ i, ac_y_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_y_table], i,
+ s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
+
+ debug_vp3(" vp3: unpacking level %d C plane AC coefficients using table %d\n",
+ i, ac_c_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_c_table], i,
+ s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
+ }
+
+ /* unpack the group 2 AC coefficients (coeffs 6-14) */
+ for (i = 6; i <= 14; i++) {
+
+ debug_vp3(" vp3: unpacking level %d Y plane AC coefficients using table %d\n",
+ i, ac_y_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_y_table], i,
+ s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
+
+ debug_vp3(" vp3: unpacking level %d C plane AC coefficients using table %d\n",
+ i, ac_c_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_c_table], i,
+ s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
+ }
+
+ /* unpack the group 3 AC coefficients (coeffs 15-27) */
+ for (i = 15; i <= 27; i++) {
+
+ debug_vp3(" vp3: unpacking level %d Y plane AC coefficients using table %d\n",
+ i, ac_y_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_y_table], i,
+ s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
+
+ debug_vp3(" vp3: unpacking level %d C plane AC coefficients using table %d\n",
+ i, ac_c_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_c_table], i,
+ s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
+ }
+
+ /* unpack the group 4 AC coefficients (coeffs 28-63) */
+ for (i = 28; i <= 63; i++) {
+
+ debug_vp3(" vp3: unpacking level %d Y plane AC coefficients using table %d\n",
+ i, ac_y_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_y_table], i,
+ s->first_coded_y_fragment, s->last_coded_y_fragment, residual_eob_run);
+
+ debug_vp3(" vp3: unpacking level %d C plane AC coefficients using table %d\n",
+ i, ac_c_table);
+ residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_c_table], i,
+ s->first_coded_c_fragment, s->last_coded_c_fragment, residual_eob_run);
+ }
+
+ return 0;
+}
+
+/*
+ * This function reverses the DC prediction for each coded fragment in
+ * the frame. Much of this function is adapted directly from the original
+ * VP3 source code.
+ */
+#define COMPATIBLE_FRAME(x) \
+ (compatible_frame[s->all_fragments[x].coding_method] == current_frame_type)
+#define FRAME_CODED(x) (s->all_fragments[x].coding_method != MODE_COPY)
+static inline int iabs (int x) { return ((x < 0) ? -x : x); }
+
+static void reverse_dc_prediction(Vp3DecodeContext *s,
+ int first_fragment,
+ int fragment_width,
+ int fragment_height)
+{
+
+#define PUL 8
+#define PU 4
+#define PUR 2
+#define PL 1
+
+ int x, y;
+ int i = first_fragment;
+
+ /*
+ * Fragment prediction groups:
+ *
+ * 32222222226
+ * 10000000004
+ * 10000000004
+ * 10000000004
+ * 10000000004
+ *
+ * Note: Groups 5 and 7 do not exist as it would mean that the
+ * fragment's x coordinate is both 0 and (width - 1) at the same time.
+ */
+ int predictor_group;
+ short predicted_dc;
+
+ /* validity flags for the left, up-left, up, and up-right fragments */
+ int fl, ful, fu, fur;
+
+ /* DC values for the left, up-left, up, and up-right fragments */
+ int vl, vul, vu, vur;
+
+ /* indices for the left, up-left, up, and up-right fragments */
+ int l, ul, u, ur;
+
+ /*
+ * The 6 fields mean:
+ * 0: up-left multiplier
+ * 1: up multiplier
+ * 2: up-right multiplier
+ * 3: left multiplier
+ * 4: mask
+ * 5: right bit shift divisor (e.g., 7 means >>=7, a.k.a. div by 128)
+ */
+ int predictor_transform[16][6] = {
+ { 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 1, 0, 0 }, // PL
+ { 0, 0, 1, 0, 0, 0 }, // PUR
+ { 0, 0, 53, 75, 127, 7 }, // PUR|PL
+ { 0, 1, 0, 0, 0, 0 }, // PU
+ { 0, 1, 0, 1, 1, 1 }, // PU|PL
+ { 0, 1, 0, 0, 0, 0 }, // PU|PUR
+ { 0, 0, 53, 75, 127, 7 }, // PU|PUR|PL
+ { 1, 0, 0, 0, 0, 0 }, // PUL
+ { 0, 0, 0, 1, 0, 0 }, // PUL|PL
+ { 1, 0, 1, 0, 1, 1 }, // PUL|PUR
+ { 0, 0, 53, 75, 127, 7 }, // PUL|PUR|PL
+ { 0, 1, 0, 0, 0, 0 }, // PUL|PU
+ {-26, 29, 0, 29, 31, 5 }, // PUL|PU|PL
+ { 3, 10, 3, 0, 15, 4 }, // PUL|PU|PUR
+ {-26, 29, 0, 29, 31, 5 } // PUL|PU|PUR|PL
+ };
+
+ /* This table shows which types of blocks can use other blocks for
+ * prediction. For example, INTRA is the only mode in this table to
+ * have a frame number of 0. That means INTRA blocks can only predict
+ * from other INTRA blocks. There are 2 golden frame coding types;
+ * blocks encoding in these modes can only predict from other blocks
+ * that were encoded with these 1 of these 2 modes. */
+ unsigned char compatible_frame[8] = {
+ 1, /* MODE_INTER_NO_MV */
+ 0, /* MODE_INTRA */
+ 1, /* MODE_INTER_PLUS_MV */
+ 1, /* MODE_INTER_LAST_MV */
+ 1, /* MODE_INTER_PRIOR_MV */
+ 2, /* MODE_USING_GOLDEN */
+ 2, /* MODE_GOLDEN_MV */
+ 1 /* MODE_INTER_FOUR_MV */
+ };
+ int current_frame_type;
+
+ /* there is a last DC predictor for each of the 3 frame types */
+ short last_dc[3];
+
+ int transform = 0;
+
+ debug_vp3(" vp3: reversing DC prediction\n");
+
+ vul = vu = vur = vl = 0;
+ last_dc[0] = last_dc[1] = last_dc[2] = 0;
+
+ /* for each fragment row... */
+ for (y = 0; y < fragment_height; y++) {
+
+ /* for each fragment in a row... */
+ for (x = 0; x < fragment_width; x++, i++) {
+
+ /* reverse prediction if this block was coded */
+ if (s->all_fragments[i].coding_method != MODE_COPY) {
+
+ current_frame_type =
+ compatible_frame[s->all_fragments[i].coding_method];
+ predictor_group = (x == 0) + ((y == 0) << 1) +
+ ((x + 1 == fragment_width) << 2);
+ debug_dc_pred(" frag %d: group %d, orig DC = %d, ",
+ i, predictor_group, s->all_fragments[i].coeffs[0]);
+
+ switch (predictor_group) {
+
+ case 0:
+ /* main body of fragments; consider all 4 possible
+ * fragments for prediction */
+
+ /* calculate the indices of the predicting fragments */
+ ul = i - fragment_width - 1;
+ u = i - fragment_width;
+ ur = i - fragment_width + 1;
+ l = i - 1;
+
+ /* fetch the DC values for the predicting fragments */
+ vul = s->all_fragments[ul].coeffs[0];
+ vu = s->all_fragments[u].coeffs[0];
+ vur = s->all_fragments[ur].coeffs[0];
+ vl = s->all_fragments[l].coeffs[0];
+
+ /* figure out which fragments are valid */
+ ful = FRAME_CODED(ul) && COMPATIBLE_FRAME(ul);
+ fu = FRAME_CODED(u) && COMPATIBLE_FRAME(u);
+ fur = FRAME_CODED(ur) && COMPATIBLE_FRAME(ur);
+ fl = FRAME_CODED(l) && COMPATIBLE_FRAME(l);
+
+ /* decide which predictor transform to use */
+ transform = (fl*PL) | (fu*PU) | (ful*PUL) | (fur*PUR);
+
+ break;
+
+ case 1:
+ /* left column of fragments, not including top corner;
+ * only consider up and up-right fragments */
+
+ /* calculate the indices of the predicting fragments */
+ u = i - fragment_width;
+ ur = i - fragment_width + 1;
+
+ /* fetch the DC values for the predicting fragments */
+ vu = s->all_fragments[u].coeffs[0];
+ vur = s->all_fragments[ur].coeffs[0];
+
+ /* figure out which fragments are valid */
+ fur = FRAME_CODED(ur) && COMPATIBLE_FRAME(ur);
+ fu = FRAME_CODED(u) && COMPATIBLE_FRAME(u);
+
+ /* decide which predictor transform to use */
+ transform = (fu*PU) | (fur*PUR);
+
+ break;
+
+ case 2:
+ case 6:
+ /* top row of fragments, not including top-left frag;
+ * only consider the left fragment for prediction */
+
+ /* calculate the indices of the predicting fragments */
+ l = i - 1;
+
+ /* fetch the DC values for the predicting fragments */
+ vl = s->all_fragments[l].coeffs[0];
+
+ /* figure out which fragments are valid */
+ fl = FRAME_CODED(l) && COMPATIBLE_FRAME(l);
+
+ /* decide which predictor transform to use */
+ transform = (fl*PL);
+
+ break;
+
+ case 3:
+ /* top-left fragment */
+
+ /* nothing to predict from in this case */
+ transform = 0;
+
+ break;
+
+ case 4:
+ /* right column of fragments, not including top corner;
+ * consider up-left, up, and left fragments for
+ * prediction */
+
+ /* calculate the indices of the predicting fragments */
+ ul = i - fragment_width - 1;
+ u = i - fragment_width;
+ l = i - 1;
+
+ /* fetch the DC values for the predicting fragments */
+ vul = s->all_fragments[ul].coeffs[0];
+ vu = s->all_fragments[u].coeffs[0];
+ vl = s->all_fragments[l].coeffs[0];
+
+ /* figure out which fragments are valid */
+ ful = FRAME_CODED(ul) && COMPATIBLE_FRAME(ul);
+ fu = FRAME_CODED(u) && COMPATIBLE_FRAME(u);
+ fl = FRAME_CODED(l) && COMPATIBLE_FRAME(l);
+
+ /* decide which predictor transform to use */
+ transform = (fl*PL) | (fu*PU) | (ful*PUL);
+
+ break;
+
+ }
+
+ debug_dc_pred("transform = %d, ", transform);
+
+ if (transform == 0) {
+
+ /* if there were no fragments to predict from, use last
+ * DC saved */
+ s->all_fragments[i].coeffs[0] += last_dc[current_frame_type];
+ debug_dc_pred("from last DC (%d) = %d\n",
+ current_frame_type, s->all_fragments[i].coeffs[0]);
+
+ } else {
+
+ /* apply the appropriate predictor transform */
+ predicted_dc =
+ (predictor_transform[transform][0] * vul) +
+ (predictor_transform[transform][1] * vu) +
+ (predictor_transform[transform][2] * vur) +
+ (predictor_transform[transform][3] * vl);
+
+ /* if there is a shift value in the transform, add
+ * the sign bit before the shift */
+ if (predictor_transform[transform][5] != 0) {
+ predicted_dc += ((predicted_dc >> 15) &
+ predictor_transform[transform][4]);
+ predicted_dc >>= predictor_transform[transform][5];
+ }
+
+ /* check for outranging on the [ul u l] and
+ * [ul u ur l] predictors */
+ if ((transform == 13) || (transform == 15)) {
+ if (iabs(predicted_dc - vu) > 128)
+ predicted_dc = vu;
+ else if (iabs(predicted_dc - vl) > 128)
+ predicted_dc = vl;
+ else if (iabs(predicted_dc - vul) > 128)
+ predicted_dc = vul;
+ }
+
+ /* at long last, apply the predictor */
+ s->all_fragments[i].coeffs[0] += predicted_dc;
+ debug_dc_pred("from pred DC = %d\n",
+ s->all_fragments[i].coeffs[0]);
+ }
+
+ /* save the DC */
+ last_dc[current_frame_type] = s->all_fragments[i].coeffs[0];
+ }
+ }
+ }
+}
+
+/*
+ * This function performs the final rendering of each fragment's data
+ * onto the output frame.
+ */
+static void render_fragments(Vp3DecodeContext *s,
+ int first_fragment,
+ int width,
+ int height,
+ int plane /* 0 = Y, 1 = U, 2 = V */)
+{
+ int x, y;
+ int m, n;
+ int i = first_fragment;
+ int j;
+ int16_t *dequantizer;
+ DCTELEM dequant_block[64];
+ DCTELEM dequant_block_permuted[64];
+ unsigned char *output_plane;
+ unsigned char *last_plane;
+ unsigned char *golden_plane;
+ int stride;
+ int motion_x, motion_y;
+ int upper_motion_limit, lower_motion_limit;
+ int motion_halfpel_index;
+ unsigned int motion_source;
+
+ debug_vp3(" vp3: rendering final fragments for %s\n",
+ (plane == 0) ? "Y plane" : (plane == 1) ? "U plane" : "V plane");
+
+ /* set up plane-specific parameters */
+ if (plane == 0) {
+ dequantizer = s->intra_y_dequant;
+ output_plane = s->current_frame.data[0];
+ last_plane = s->last_frame.data[0];
+ golden_plane = s->golden_frame.data[0];
+ stride = -s->current_frame.linesize[0];
+ upper_motion_limit = 7 * s->current_frame.linesize[0];
+ lower_motion_limit = height * s->current_frame.linesize[0] + width - 8;
+ } else if (plane == 1) {
+ dequantizer = s->intra_c_dequant;
+ output_plane = s->current_frame.data[1];
+ last_plane = s->last_frame.data[1];
+ golden_plane = s->golden_frame.data[1];
+ stride = -s->current_frame.linesize[1];
+ upper_motion_limit = 7 * s->current_frame.linesize[1];
+ lower_motion_limit = height * s->current_frame.linesize[1] + width - 8;
+ } else {
+ dequantizer = s->intra_c_dequant;
+ output_plane = s->current_frame.data[2];
+ last_plane = s->last_frame.data[2];
+ golden_plane = s->golden_frame.data[2];
+ stride = -s->current_frame.linesize[2];
+ upper_motion_limit = 7 * s->current_frame.linesize[2];
+ lower_motion_limit = height * s->current_frame.linesize[2] + width - 8;
+ }
+
+ /* for each fragment row... */
+ for (y = 0; y < height; y += 8) {
+
+ /* for each fragment in a row... */
+ for (x = 0; x < width; x += 8, i++) {
+
+ if ((i < 0) || (i >= s->fragment_count)) {
+ printf (" vp3:render_fragments(): bad fragment number (%d)\n", i);
+ return;
+ }
+
+ /* transform if this block was coded */
+ if (s->all_fragments[i].coding_method != MODE_COPY) {
+
+ motion_source = s->all_fragments[i].first_pixel;
+ motion_halfpel_index = 0;
+
+ /* sort out the motion vector if this fragment is coded
+ * using a motion vector method */
+ if ((s->all_fragments[i].coding_method > MODE_INTRA) &&
+ (s->all_fragments[i].coding_method != MODE_USING_GOLDEN)) {
+ motion_x = s->all_fragments[i].motion_x;
+ motion_y = s->all_fragments[i].motion_y;
+if ((motion_x == 0xbeef) || (motion_y == 0xbeef))
+printf (" help! got beefy vector! (%X, %X)\n", motion_x, motion_y);
+
+ if (motion_x >= 0) {
+ motion_halfpel_index = motion_x & 0x01;
+ motion_source += (motion_x >> 1);
+ } else {
+ motion_x = -motion_x;
+ motion_halfpel_index = motion_x & 0x01;
+ motion_source -= ((motion_x + 1) >> 1);
+ }
+
+// motion_y = -motion_y;
+ if (motion_y >= 0) {
+ motion_halfpel_index |= (motion_y & 0x01) << 1;
+ motion_source += ((motion_y >> 1) * stride);
+ } else {
+ motion_y = -motion_y;
+ motion_halfpel_index |= (motion_y & 0x01) << 1;
+ motion_source -= (((motion_y + 1) >> 1) * stride);
+ }
+
+ /* if the are any problems with a motion vector, refuse
+ * to render the block */
+ if ((motion_source < upper_motion_limit) ||
+ (motion_source > lower_motion_limit)) {
+ printf (" vp3: help! motion source (%d) out of range (%d..%d), fragment %d\n",
+ motion_source, upper_motion_limit, lower_motion_limit, i);
+ continue;
+ }
+ }
+
+ /* first, take care of copying a block from either the
+ * previous or the golden frame */
+ if ((s->all_fragments[i].coding_method == MODE_USING_GOLDEN) ||
+ (s->all_fragments[i].coding_method == MODE_GOLDEN_MV)) {
+
+ s->dsp.put_pixels_tab[1][motion_halfpel_index](
+ output_plane + s->all_fragments[i].first_pixel,
+ golden_plane + motion_source,
+ stride, 8);
+
+ } else
+ if (s->all_fragments[i].coding_method != MODE_INTRA) {
+
+ s->dsp.put_pixels_tab[1][motion_halfpel_index](
+ output_plane + s->all_fragments[i].first_pixel,
+ last_plane + motion_source,
+ stride, 8);
+ }
+
+ /* dequantize the DCT coefficients */
+ debug_idct("fragment %d, coding mode %d, DC = %d, dequant = %d:\n",
+ i, s->all_fragments[i].coding_method,
+ s->all_fragments[i].coeffs[0], dequantizer[0]);
+ for (j = 0; j < 64; j++)
+ dequant_block[dezigzag_index[j]] =
+ s->all_fragments[i].coeffs[j] *
+ dequantizer[j];
+ for (j = 0; j < 64; j++)
+ dequant_block_permuted[s->dsp.idct_permutation[j]] =
+ dequant_block[j];
+
+ debug_idct("dequantized block:\n");
+ for (m = 0; m < 8; m++) {
+ for (n = 0; n < 8; n++) {
+ debug_idct(" %5d", dequant_block[m * 8 + n]);
+ }
+ debug_idct("\n");
+ }
+ debug_idct("\n");
+
+ /* invert DCT and place (or add) in final output */
+
+ if (s->all_fragments[i].coding_method == MODE_INTRA) {
+ dequant_block_permuted[0] += 1024;
+ s->dsp.idct_put(
+ output_plane + s->all_fragments[i].first_pixel,
+ stride, dequant_block_permuted);
+ } else {
+ s->dsp.idct_add(
+ output_plane + s->all_fragments[i].first_pixel,
+ stride, dequant_block_permuted);
+ }
+
+ debug_idct("block after idct_%s():\n",
+ (s->all_fragments[i].coding_method == MODE_INTRA)?
+ "put" : "add");
+ for (m = 0; m < 8; m++) {
+ for (n = 0; n < 8; n++) {
+ debug_idct(" %3d", *(output_plane +
+ s->all_fragments[i].first_pixel + (m * stride + n)));
+ }
+ debug_idct("\n");
+ }
+ debug_idct("\n");
+
+ } else {
+
+ /* copy directly from the previous frame */
+ s->dsp.put_pixels_tab[1][0](
+ output_plane + s->all_fragments[i].first_pixel,
+ last_plane + s->all_fragments[i].first_pixel,
+ stride, 8);
+
+ }
+ }
+ }
+
+ emms_c();
+
+}
+
+/*
+ * This function computes the first pixel addresses for each fragment.
+ * This function needs to be invoked after the first frame is allocated
+ * so that it has access to the plane strides.
+ */
+static void vp3_calculate_pixel_addresses(Vp3DecodeContext *s)
+{
+
+ int i, x, y;
+
+ /* figure out the first pixel addresses for each of the fragments */
+ /* Y plane */
+ i = 0;
+ for (y = s->fragment_height; y > 0; y--) {
+ for (x = 0; x < s->fragment_width; x++) {
+ s->all_fragments[i++].first_pixel =
+ s->golden_frame.linesize[0] * y * FRAGMENT_PIXELS -
+ s->golden_frame.linesize[0] +
+ x * FRAGMENT_PIXELS;
+ debug_init(" fragment %d, first pixel @ %d\n",
+ i-1, s->all_fragments[i-1].first_pixel);
+ }
+ }
+
+ /* U plane */
+ i = s->u_fragment_start;
+ for (y = s->fragment_height / 2; y > 0; y--) {
+ for (x = 0; x < s->fragment_width / 2; x++) {
+ s->all_fragments[i++].first_pixel =
+ s->golden_frame.linesize[1] * y * FRAGMENT_PIXELS -
+ s->golden_frame.linesize[1] +
+ x * FRAGMENT_PIXELS;
+ debug_init(" fragment %d, first pixel @ %d\n",
+ i-1, s->all_fragments[i-1].first_pixel);
+ }
+ }
+
+ /* V plane */
+ i = s->v_fragment_start;
+ for (y = s->fragment_height / 2; y > 0; y--) {
+ for (x = 0; x < s->fragment_width / 2; x++) {
+ s->all_fragments[i++].first_pixel =
+ s->golden_frame.linesize[2] * y * FRAGMENT_PIXELS -
+ s->golden_frame.linesize[2] +
+ x * FRAGMENT_PIXELS;
+ debug_init(" fragment %d, first pixel @ %d\n",
+ i-1, s->all_fragments[i-1].first_pixel);
+ }
+ }
+}
+
+/*
+ * This is the ffmpeg/libavcodec API init function.
+ */
+static int vp3_decode_init(AVCodecContext *avctx)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+ int i;
+ int c_width;
+ int c_height;
+ int y_superblock_count;
+ int c_superblock_count;
+
+ s->avctx = avctx;
+#if 0
+ s->width = avctx->width;
+ s->height = avctx->height;
+#else
+ s->width = (avctx->width + 15) & 0xFFFFFFF0;
+ s->height = (avctx->height + 15) & 0xFFFFFFF0;
+#endif
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+ avctx->has_b_frames = 0;
+ dsputil_init(&s->dsp, avctx);
+
+ /* initialize to an impossible value which will force a recalculation
+ * in the first frame decode */
+ s->quality_index = -1;
+
+ s->y_superblock_width = (s->width + 31) / 32;
+ s->y_superblock_height = (s->height + 31) / 32;
+ y_superblock_count = s->y_superblock_width * s->y_superblock_height;
+
+ /* work out the dimensions for the C planes */
+ c_width = s->width / 2;
+ c_height = s->height / 2;
+ s->c_superblock_width = (c_width + 31) / 32;
+ s->c_superblock_height = (c_height + 31) / 32;
+ c_superblock_count = s->c_superblock_width * s->c_superblock_height;
+
+ s->superblock_count = y_superblock_count + (c_superblock_count * 2);
+ s->u_superblock_start = y_superblock_count;
+ s->v_superblock_start = s->u_superblock_start + c_superblock_count;
+ s->superblock_coding = av_malloc(s->superblock_count);
+
+ s->macroblock_width = (s->width + 15) / 16;
+ s->macroblock_height = (s->height + 15) / 16;
+ s->macroblock_count = s->macroblock_width * s->macroblock_height;
+
+ s->fragment_width = s->width / FRAGMENT_PIXELS;
+ s->fragment_height = s->height / FRAGMENT_PIXELS;
+
+ /* fragment count covers all 8x8 blocks for all 3 planes */
+ s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2;
+ s->u_fragment_start = s->fragment_width * s->fragment_height;
+ s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4;
+
+ debug_init(" Y plane: %d x %d\n", s->width, s->height);
+ debug_init(" C plane: %d x %d\n", c_width, c_height);
+ debug_init(" Y superblocks: %d x %d, %d total\n",
+ s->y_superblock_width, s->y_superblock_height, y_superblock_count);
+ debug_init(" C superblocks: %d x %d, %d total\n",
+ s->c_superblock_width, s->c_superblock_height, c_superblock_count);
+ debug_init(" total superblocks = %d, U starts @ %d, V starts @ %d\n",
+ s->superblock_count, s->u_superblock_start, s->v_superblock_start);
+ debug_init(" macroblocks: %d x %d, %d total\n",
+ s->macroblock_width, s->macroblock_height, s->macroblock_count);
+ debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n",
+ s->fragment_count,
+ s->fragment_width,
+ s->fragment_height,
+ s->u_fragment_start,
+ s->v_fragment_start);
+
+ s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
+ s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int));
+ s->pixel_addresses_inited = 0;
+
+ /* init VLC tables */
+ for (i = 0; i < 16; i++) {
+
+ /* DC histograms */
+ init_vlc(&s->dc_vlc[i], 5, 32,
+ &dc_bias[i][0][1], 4, 2,
+ &dc_bias[i][0][0], 4, 2);
+
+ /* group 1 AC histograms */
+ init_vlc(&s->ac_vlc_1[i], 5, 32,
+ &ac_bias_0[i][0][1], 4, 2,
+ &ac_bias_0[i][0][0], 4, 2);
+
+ /* group 2 AC histograms */
+ init_vlc(&s->ac_vlc_2[i], 5, 32,
+ &ac_bias_1[i][0][1], 4, 2,
+ &ac_bias_1[i][0][0], 4, 2);
+
+ /* group 3 AC histograms */
+ init_vlc(&s->ac_vlc_3[i], 5, 32,
+ &ac_bias_2[i][0][1], 4, 2,
+ &ac_bias_2[i][0][0], 4, 2);
+
+ /* group 4 AC histograms */
+ init_vlc(&s->ac_vlc_4[i], 5, 32,
+ &ac_bias_3[i][0][1], 4, 2,
+ &ac_bias_3[i][0][0], 4, 2);
+ }
+
+ /* build quantization zigzag table */
+ for (i = 0; i < 64; i++)
+ zigzag_index[dezigzag_index[i]] = i;
+
+ /* work out the block mapping tables */
+ s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
+ s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int));
+ s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int));
+ s->macroblock_coding = av_malloc(s->macroblock_count + 1);
+ init_block_mapping(s);
+
+ for (i = 0; i < 3; i++) {
+ s->current_frame.data[i] = NULL;
+ s->last_frame.data[i] = NULL;
+ s->golden_frame.data[i] = NULL;
+ }
+
+avctx->flags |= CODEC_FLAG_GRAY;
+
+ return 0;
+}
+
+/*
+ * This is the ffmpeg/libavcodec API frame decode function.
+ */
+static int vp3_decode_frame(AVCodecContext *avctx,
+ void *data, int *data_size,
+ uint8_t *buf, int buf_size)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+ GetBitContext gb;
+ static int counter = 0;
+
+ *data_size = 0;
+
+ init_get_bits(&gb, buf, buf_size * 8);
+
+ s->keyframe = get_bits(&gb, 1);
+ s->keyframe ^= 1;
+ skip_bits(&gb, 1);
+ s->last_quality_index = s->quality_index;
+ s->quality_index = get_bits(&gb, 6);
+
+ debug_vp3(" VP3 frame #%d: Q index = %d", counter, s->quality_index);
+printf (" frame #%d\n", counter);
+ counter++;
+
+ if (s->quality_index != s->last_quality_index)
+ init_dequantizer(s);
+
+ if (s->keyframe) {
+
+ debug_vp3(", keyframe\n");
+ /* skip the other 2 header bytes for now */
+ skip_bits(&gb, 16);
+
+ if (s->last_frame.data[0] == s->golden_frame.data[0]) {
+ if (s->golden_frame.data[0])
+ avctx->release_buffer(avctx, &s->golden_frame);
+ } else {
+ if (s->golden_frame.data[0])
+ avctx->release_buffer(avctx, &s->golden_frame);
+ if (s->last_frame.data[0])
+ avctx->release_buffer(avctx, &s->last_frame);
+ }
+
+ s->golden_frame.reference = 0;
+ if(avctx->get_buffer(avctx, &s->golden_frame) < 0) {
+ printf("vp3: get_buffer() failed\n");
+ return -1;
+ }
+
+ /* golden frame is also the current frame */
+ memcpy(&s->current_frame, &s->golden_frame, sizeof(AVFrame));
+
+ /* time to figure out pixel addresses? */
+ if (!s->pixel_addresses_inited)
+ vp3_calculate_pixel_addresses(s);
+
+ } else {
+
+ debug_vp3("\n");
+
+ /* allocate a new current frame */
+ s->current_frame.reference = 0;
+ if(avctx->get_buffer(avctx, &s->current_frame) < 0) {
+ printf("vp3: get_buffer() failed\n");
+ return -1;
+ }
+ }
+
+ init_frame(s, &gb);
+
+#if KEYFRAMES_ONLY
+if (!s->keyframe) {
+
+ memcpy(s->current_frame.data[0], s->golden_frame.data[0],
+ s->current_frame.linesize[0] * s->height);
+ memcpy(s->current_frame.data[1], s->golden_frame.data[1],
+ s->current_frame.linesize[1] * s->height / 2);
+ memcpy(s->current_frame.data[2], s->golden_frame.data[2],
+ s->current_frame.linesize[2] * s->height / 2);
+
+} else {
+#endif
+
+ if (unpack_superblocks(s, &gb) ||
+ unpack_modes(s, &gb) ||
+ unpack_vectors(s, &gb) ||
+ unpack_dct_coeffs(s, &gb)) {
+
+ printf(" vp3: could not decode frame\n");
+ return -1;
+ }
+
+ reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height);
+ render_fragments(s, 0, s->width, s->height, 0);
+
+ if ((avctx->flags & CODEC_FLAG_GRAY) == 0) {
+ reverse_dc_prediction(s, s->u_fragment_start,
+ s->fragment_width / 2, s->fragment_height / 2);
+ reverse_dc_prediction(s, s->v_fragment_start,
+ s->fragment_width / 2, s->fragment_height / 2);
+ render_fragments(s, s->u_fragment_start, s->width / 2, s->height / 2, 1);
+ render_fragments(s, s->v_fragment_start, s->width / 2, s->height / 2, 2);
+ } else {
+ memset(s->current_frame.data[1], 0x80, s->width * s->height / 4);
+ memset(s->current_frame.data[2], 0x80, s->width * s->height / 4);
+ }
+
+#if KEYFRAMES_ONLY
+}
+#endif
+
+ *data_size=sizeof(AVFrame);
+ *(AVFrame*)data= s->current_frame;
+
+ /* release the last frame, if it is allocated and if it is not the
+ * golden frame */
+ if ((s->last_frame.data[0]) &&
+ (s->last_frame.data[0] != s->golden_frame.data[0]))
+ avctx->release_buffer(avctx, &s->last_frame);
+
+ /* shuffle frames (last = current) */
+ memcpy(&s->last_frame, &s->current_frame, sizeof(AVFrame));
+
+ return buf_size;
+}
+
+/*
+ * This is the ffmpeg/libavcodec API module cleanup function.
+ */
+static int vp3_decode_end(AVCodecContext *avctx)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+
+ av_free(s->all_fragments);
+ av_free(s->coded_fragment_list);
+ av_free(s->superblock_fragments);
+ av_free(s->superblock_macroblocks);
+ av_free(s->macroblock_fragments);
+ av_free(s->macroblock_coding);
+
+ /* release all frames */
+ if (s->golden_frame.data[0])
+ avctx->release_buffer(avctx, &s->golden_frame);
+ if (s->last_frame.data[0])
+ avctx->release_buffer(avctx, &s->last_frame);
+ /* no need to release the current_frame since it will always be pointing
+ * to the same frame as either the golden or last frame */
+
+ return 0;
+}
+
+AVCodec vp3_decoder = {
+ "vp3",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_VP3,
+ sizeof(Vp3DecodeContext),
+ vp3_decode_init,
+ NULL,
+ vp3_decode_end,
+ vp3_decode_frame,
+ 0,
+ NULL
+};
diff --git a/src/libffmpeg/libavcodec/vp3data.h b/src/libffmpeg/libavcodec/vp3data.h
new file mode 100644
index 000000000..0021049fc
--- /dev/null
+++ b/src/libffmpeg/libavcodec/vp3data.h
@@ -0,0 +1,2812 @@
+#ifndef VP3DATA_H
+#define VP3DATA_H
+
+/* these coefficients dequantize intraframe Y plane coefficients */
+static int16_t vp31_intra_y_dequant[64] =
+{ 16, 11, 10, 16, 24, 40, 51, 61,
+ 12, 12, 14, 19, 26, 58, 60, 55,
+ 14, 13, 16, 24, 40, 57, 69, 56,
+ 14, 17, 22, 29, 51, 87, 80, 62,
+ 18, 22, 37, 58, 68, 109, 103, 77,
+ 24, 35, 55, 64, 81, 104, 113, 92,
+ 49, 64, 78, 87, 103, 121, 120, 101,
+ 72, 92, 95, 98, 112, 100, 103, 99
+};
+
+/* these coefficients dequantize intraframe C plane coefficients */
+static int16_t vp31_intra_c_dequant[64] =
+{ 17, 18, 24, 47, 99, 99, 99, 99,
+ 18, 21, 26, 66, 99, 99, 99, 99,
+ 24, 26, 56, 99, 99, 99, 99, 99,
+ 47, 66, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99
+};
+
+/* these coefficients dequantize interframe coefficients (all planes) */
+static int16_t vp31_inter_dequant[64] =
+{ 16, 16, 16, 20, 24, 28, 32, 40,
+ 16, 16, 20, 24, 28, 32, 40, 48,
+ 16, 20, 24, 28, 32, 40, 48, 64,
+ 20, 24, 28, 32, 40, 48, 64, 64,
+ 24, 28, 32, 40, 48, 64, 64, 64,
+ 28, 32, 40, 48, 64, 64, 64, 96,
+ 32, 40, 48, 64, 64, 64, 96, 128,
+ 40, 48, 64, 64, 64, 96, 128, 128
+};
+
+static int16_t vp31_dc_scale_factor[64] =
+{ 220, 200, 190, 180, 170, 170, 160, 160,
+ 150, 150, 140, 140, 130, 130, 120, 120,
+ 110, 110, 100, 100, 90, 90, 90, 80,
+ 80, 80, 70, 70, 70, 60, 60, 60,
+ 60, 50, 50, 50, 50, 40, 40, 40,
+ 40, 40, 30, 30, 30, 30, 30, 30,
+ 30, 20, 20, 20, 20, 20, 20, 20,
+ 20, 10, 10, 10, 10, 10, 10, 10
+};
+
+static uint32_t vp31_quality_threshold[64] =
+{ 500, 450, 400, 370, 340, 310, 285, 265,
+ 245, 225, 210, 195, 185, 180, 170, 160,
+ 150, 145, 135, 130, 125, 115, 110, 107,
+ 100, 96, 93, 89, 85, 82, 75, 74,
+ 70, 68, 64, 60, 57, 56, 52, 50,
+ 49, 45, 44, 43, 40, 38, 37, 35,
+ 33, 32, 30, 29, 28, 25, 24, 22,
+ 21, 19, 18, 17, 15, 13, 12, 10
+};
+
+/* table used to convert natural order <-> zigzag order */
+static const int dezigzag_index[64] =
+{ 0, 1, 8, 16, 9, 2, 3, 10,
+ 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34,
+ 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36,
+ 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46,
+ 53, 60, 61, 54, 47, 55, 62, 63
+};
+
+/* inverse of dezigzag index */
+static int zigzag_index[64];
+
+static const uint16_t dc_bias[16][32][2] = {
+ { /* DC bias table 0 */
+ { 0x2D, 6 },
+ { 0x26, 7 },
+ { 0x166, 9 },
+ { 0x4E, 8 },
+ { 0x2CE, 10 },
+ { 0x59E, 11 },
+ { 0x27D, 11 },
+ { 0x8, 5 },
+ { 0x4F9, 12 },
+ { 0xF, 4 },
+ { 0xE, 4 },
+ { 0x1B, 5 },
+ { 0x6, 4 },
+ { 0x8, 4 },
+ { 0x5, 4 },
+ { 0x1A, 5 },
+ { 0x15, 5 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x17, 5 },
+ { 0x29, 6 },
+ { 0x28, 6 },
+ { 0xB2, 8 },
+ { 0x4F8, 12 },
+ { 0x59F, 11 },
+ { 0x9E, 9 },
+ { 0x13F, 10 },
+ { 0x12, 6 },
+ { 0x58, 7 }
+ },
+ { /* DC bias table 1 */
+ { 0x10, 5 },
+ { 0x47, 7 },
+ { 0x1FF, 9 },
+ { 0x8C, 8 },
+ { 0x3FC, 10 },
+ { 0x46A, 11 },
+ { 0x469, 11 },
+ { 0x22, 6 },
+ { 0x11A1, 13 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0x4, 4 },
+ { 0x5, 4 },
+ { 0x9, 4 },
+ { 0x6, 4 },
+ { 0x1E, 5 },
+ { 0x16, 5 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xA, 4 },
+ { 0x17, 5 },
+ { 0x7D, 7 },
+ { 0x7E, 7 },
+ { 0x11B, 9 },
+ { 0x8D1, 12 },
+ { 0x3FD, 10 },
+ { 0x46B, 11 },
+ { 0x11A0, 13 },
+ { 0x7C, 7 },
+ { 0xFE, 8 }
+ },
+ { /* DC bias table 2 */
+ { 0x16, 5 },
+ { 0x20, 6 },
+ { 0x86, 8 },
+ { 0x87, 8 },
+ { 0x367, 10 },
+ { 0x6CC, 11 },
+ { 0x6CB, 11 },
+ { 0x6E, 7 },
+ { 0x366D, 14 },
+ { 0xF, 4 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0x5, 4 },
+ { 0xA, 4 },
+ { 0x6, 4 },
+ { 0x1A, 5 },
+ { 0x11, 5 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x17, 5 },
+ { 0x6F, 7 },
+ { 0x6D, 7 },
+ { 0x364, 10 },
+ { 0xD9A, 12 },
+ { 0x6CA, 11 },
+ { 0x1B37, 13 },
+ { 0x366C, 14 },
+ { 0x42, 7 },
+ { 0xD8, 8 }
+ },
+ { /* DC bias table 3 */
+ { 0x0, 4 },
+ { 0x2D, 6 },
+ { 0xF7, 8 },
+ { 0x58, 7 },
+ { 0x167, 9 },
+ { 0x2CB, 10 },
+ { 0x2CA, 10 },
+ { 0xE, 6 },
+ { 0x1661, 13 },
+ { 0x3, 3 },
+ { 0x2, 3 },
+ { 0x8, 4 },
+ { 0x9, 4 },
+ { 0xD, 4 },
+ { 0x2, 4 },
+ { 0x1F, 5 },
+ { 0x17, 5 },
+ { 0x1, 4 },
+ { 0xC, 4 },
+ { 0xE, 4 },
+ { 0xA, 4 },
+ { 0x6, 5 },
+ { 0x78, 7 },
+ { 0xF, 6 },
+ { 0x7A, 7 },
+ { 0x164, 9 },
+ { 0x599, 11 },
+ { 0x2CD, 10 },
+ { 0xB31, 12 },
+ { 0x1660, 13 },
+ { 0x79, 7 },
+ { 0xF6, 8 }
+ },
+ { /* DC bias table 4 */
+ { 0x3, 4 },
+ { 0x3C, 6 },
+ { 0xF, 7 },
+ { 0x7A, 7 },
+ { 0x1D, 8 },
+ { 0x20, 9 },
+ { 0x72, 10 },
+ { 0x6, 6 },
+ { 0x399, 13 },
+ { 0x4, 3 },
+ { 0x5, 3 },
+ { 0x5, 4 },
+ { 0x6, 4 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0x0, 4 },
+ { 0x19, 5 },
+ { 0x2, 4 },
+ { 0xD, 4 },
+ { 0x7, 4 },
+ { 0x1F, 5 },
+ { 0x30, 6 },
+ { 0x11, 8 },
+ { 0x31, 6 },
+ { 0x5, 6 },
+ { 0x21, 9 },
+ { 0xE7, 11 },
+ { 0x38, 9 },
+ { 0x1CD, 12 },
+ { 0x398, 13 },
+ { 0x7B, 7 },
+ { 0x9, 7 }
+ },
+ { /* DC bias table 5 */
+ { 0x9, 4 },
+ { 0x2, 5 },
+ { 0x74, 7 },
+ { 0x7, 6 },
+ { 0xEC, 8 },
+ { 0xD1, 9 },
+ { 0x1A6, 10 },
+ { 0x6, 6 },
+ { 0xD21, 13 },
+ { 0x5, 3 },
+ { 0x6, 3 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0xF, 4 },
+ { 0x4, 4 },
+ { 0x0, 4 },
+ { 0x1C, 5 },
+ { 0x2, 4 },
+ { 0x5, 4 },
+ { 0x3, 4 },
+ { 0xC, 5 },
+ { 0x35, 7 },
+ { 0x1A7, 10 },
+ { 0x1B, 6 },
+ { 0x77, 7 },
+ { 0x1A5, 10 },
+ { 0x349, 11 },
+ { 0xD0, 9 },
+ { 0x691, 12 },
+ { 0xD20, 13 },
+ { 0x75, 7 },
+ { 0xED, 8 }
+ },
+ { /* DC bias table 6 */
+ { 0xA, 4 },
+ { 0xC, 5 },
+ { 0x12, 6 },
+ { 0x1B, 6 },
+ { 0xB7, 8 },
+ { 0x16C, 9 },
+ { 0x99, 9 },
+ { 0x5A, 7 },
+ { 0x16D8, 13 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x0, 3 },
+ { 0x5, 4 },
+ { 0x17, 5 },
+ { 0xE, 5 },
+ { 0x2, 4 },
+ { 0x3, 4 },
+ { 0xF, 5 },
+ { 0x1A, 6 },
+ { 0x4D, 8 },
+ { 0x2DB3, 14 },
+ { 0x2C, 6 },
+ { 0x11, 6 },
+ { 0x2DA, 10 },
+ { 0x5B7, 11 },
+ { 0x98, 9 },
+ { 0xB6D, 12 },
+ { 0x2DB2, 14 },
+ { 0x10, 6 },
+ { 0x27, 7 }
+ },
+ { /* DC bias table 7 */
+ { 0xD, 4 },
+ { 0xF, 5 },
+ { 0x1D, 6 },
+ { 0x8, 5 },
+ { 0x51, 7 },
+ { 0x56, 8 },
+ { 0xAF, 9 },
+ { 0x2A, 7 },
+ { 0x148A, 13 },
+ { 0x7, 3 },
+ { 0x0, 2 },
+ { 0x8, 4 },
+ { 0x9, 4 },
+ { 0xC, 4 },
+ { 0x6, 4 },
+ { 0x17, 5 },
+ { 0xB, 5 },
+ { 0x16, 5 },
+ { 0x15, 5 },
+ { 0x9, 5 },
+ { 0x50, 7 },
+ { 0xAE, 9 },
+ { 0x2917, 14 },
+ { 0x1C, 6 },
+ { 0x14, 6 },
+ { 0x290, 10 },
+ { 0x523, 11 },
+ { 0x149, 9 },
+ { 0xA44, 12 },
+ { 0x2916, 14 },
+ { 0x53, 7 },
+ { 0xA5, 8 }
+ },
+ { /* DC bias table 8 */
+ { 0x1, 4 },
+ { 0x1D, 6 },
+ { 0xF5, 8 },
+ { 0xF4, 8 },
+ { 0x24D, 10 },
+ { 0x499, 11 },
+ { 0x498, 11 },
+ { 0x1, 5 },
+ { 0x21, 6 },
+ { 0x6, 3 },
+ { 0x5, 3 },
+ { 0x6, 4 },
+ { 0x5, 4 },
+ { 0x2, 4 },
+ { 0x7, 5 },
+ { 0x25, 6 },
+ { 0x7B, 7 },
+ { 0x1C, 6 },
+ { 0x20, 6 },
+ { 0xD, 6 },
+ { 0x48, 7 },
+ { 0x92, 8 },
+ { 0x127, 9 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0x11, 5 },
+ { 0xC, 6 },
+ { 0x3C, 6 },
+ { 0xF, 5 },
+ { 0x0, 5 },
+ { 0x1F, 5 },
+ { 0x13, 5 }
+ },
+ { /* DC bias table 9 */
+ { 0x5, 4 },
+ { 0x3C, 6 },
+ { 0x40, 7 },
+ { 0xD, 7 },
+ { 0x31, 9 },
+ { 0x61, 10 },
+ { 0x60, 10 },
+ { 0x2, 5 },
+ { 0xF5, 8 },
+ { 0x6, 3 },
+ { 0x5, 3 },
+ { 0x7, 4 },
+ { 0x6, 4 },
+ { 0x2, 4 },
+ { 0x9, 5 },
+ { 0x25, 6 },
+ { 0x7, 6 },
+ { 0x21, 6 },
+ { 0x24, 6 },
+ { 0x10, 6 },
+ { 0x41, 7 },
+ { 0xF4, 8 },
+ { 0x19, 8 },
+ { 0xE, 4 },
+ { 0x3, 4 },
+ { 0x11, 5 },
+ { 0x11, 6 },
+ { 0x3F, 6 },
+ { 0x3E, 6 },
+ { 0x7B, 7 },
+ { 0x0, 4 },
+ { 0x13, 5 }
+ },
+ { /* DC bias table 10 */
+ { 0xA, 4 },
+ { 0x7, 5 },
+ { 0x1, 6 },
+ { 0x9, 6 },
+ { 0x131, 9 },
+ { 0x261, 10 },
+ { 0x260, 10 },
+ { 0x15, 6 },
+ { 0x1, 7 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0x6, 4 },
+ { 0x12, 5 },
+ { 0x2F, 6 },
+ { 0x14, 6 },
+ { 0x27, 6 },
+ { 0x2D, 6 },
+ { 0x16, 6 },
+ { 0x4D, 7 },
+ { 0x99, 8 },
+ { 0x0, 7 },
+ { 0x4, 4 },
+ { 0x1, 4 },
+ { 0x5, 5 },
+ { 0x17, 6 },
+ { 0x2E, 6 },
+ { 0x2C, 6 },
+ { 0x8, 6 },
+ { 0x6, 5 },
+ { 0x1, 5 }
+ },
+ { /* DC bias table 11 */
+ { 0x0, 3 },
+ { 0xE, 5 },
+ { 0x17, 6 },
+ { 0x2A, 6 },
+ { 0x10, 7 },
+ { 0xF9, 10 },
+ { 0xF8, 10 },
+ { 0x1E, 7 },
+ { 0x3F, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x6, 4 },
+ { 0xF, 5 },
+ { 0x5, 5 },
+ { 0x16, 6 },
+ { 0x29, 6 },
+ { 0x2B, 6 },
+ { 0x15, 6 },
+ { 0x50, 7 },
+ { 0x11, 7 },
+ { 0x7D, 9 },
+ { 0x4, 4 },
+ { 0x17, 5 },
+ { 0x6, 5 },
+ { 0x14, 6 },
+ { 0x2C, 6 },
+ { 0x2D, 6 },
+ { 0xE, 6 },
+ { 0x9, 6 },
+ { 0x51, 7 }
+ },
+ { /* DC bias table 12 */
+ { 0x2, 3 },
+ { 0x18, 5 },
+ { 0x2F, 6 },
+ { 0xD, 5 },
+ { 0x53, 7 },
+ { 0x295, 10 },
+ { 0x294, 10 },
+ { 0xA4, 8 },
+ { 0x7C, 8 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x1B, 5 },
+ { 0xC, 5 },
+ { 0x28, 6 },
+ { 0x6A, 7 },
+ { 0x1E, 6 },
+ { 0x1D, 6 },
+ { 0x69, 7 },
+ { 0xD7, 8 },
+ { 0x7D, 8 },
+ { 0x14B, 9 },
+ { 0x19, 5 },
+ { 0x16, 5 },
+ { 0x2E, 6 },
+ { 0x1C, 6 },
+ { 0x2B, 6 },
+ { 0x2A, 6 },
+ { 0x68, 7 },
+ { 0x3F, 7 },
+ { 0xD6, 8 }
+ },
+ { /* DC bias table 13 */
+ { 0x2, 3 },
+ { 0x1B, 5 },
+ { 0xC, 5 },
+ { 0x18, 5 },
+ { 0x29, 6 },
+ { 0x7F, 8 },
+ { 0x2F0, 10 },
+ { 0x198, 9 },
+ { 0x179, 9 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x1A, 5 },
+ { 0xD, 5 },
+ { 0x2A, 6 },
+ { 0x64, 7 },
+ { 0x1E, 6 },
+ { 0x67, 7 },
+ { 0x5F, 7 },
+ { 0xCD, 8 },
+ { 0x7E, 8 },
+ { 0x2F1, 10 },
+ { 0x16, 5 },
+ { 0xE, 5 },
+ { 0x2E, 6 },
+ { 0x65, 7 },
+ { 0x2B, 6 },
+ { 0x28, 6 },
+ { 0x3E, 7 },
+ { 0xBD, 8 },
+ { 0x199, 9 }
+ },
+ { /* DC bias table 14 */
+ { 0x2, 3 },
+ { 0x7, 4 },
+ { 0x16, 5 },
+ { 0x6, 4 },
+ { 0x36, 6 },
+ { 0x5C, 7 },
+ { 0x15D, 9 },
+ { 0x15C, 9 },
+ { 0x2BF, 10 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x18, 5 },
+ { 0x34, 6 },
+ { 0x2A, 6 },
+ { 0x5E, 7 },
+ { 0x6A, 7 },
+ { 0x64, 7 },
+ { 0x5D, 7 },
+ { 0xCB, 8 },
+ { 0xAD, 8 },
+ { 0x2BE, 10 },
+ { 0x14, 5 },
+ { 0x33, 6 },
+ { 0x6E, 7 },
+ { 0x5F, 7 },
+ { 0x6F, 7 },
+ { 0x6B, 7 },
+ { 0xCA, 8 },
+ { 0xAC, 8 },
+ { 0x15E, 9 }
+ },
+ { /* DC bias table 15 */
+ { 0xF, 4 },
+ { 0x1D, 5 },
+ { 0x18, 5 },
+ { 0xB, 4 },
+ { 0x19, 5 },
+ { 0x29, 6 },
+ { 0xD6, 8 },
+ { 0x551, 11 },
+ { 0xAA1, 12 },
+ { 0x1, 2 },
+ { 0x0, 2 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x1B, 5 },
+ { 0x38, 6 },
+ { 0x28, 6 },
+ { 0x57, 7 },
+ { 0x6A, 7 },
+ { 0x68, 7 },
+ { 0x56, 7 },
+ { 0xE5, 8 },
+ { 0x155, 9 },
+ { 0xAA0, 12 },
+ { 0x73, 7 },
+ { 0x69, 7 },
+ { 0xD7, 8 },
+ { 0xAB, 8 },
+ { 0xE4, 8 },
+ { 0xA9, 8 },
+ { 0x151, 9 },
+ { 0x150, 9 },
+ { 0x2A9, 10 }
+ }
+};
+
+static const uint16_t ac_bias_0[16][32][2] = {
+ { /* AC bias group 1, table 0 */
+ { 0x8, 5 },
+ { 0x25, 7 },
+ { 0x17A, 9 },
+ { 0x2F7, 10 },
+ { 0xBDB, 12 },
+ { 0x17B4, 13 },
+ { 0x2F6B, 14 },
+ { 0x1D, 5 },
+ { 0x2F6A, 14 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0x1, 4 },
+ { 0x2, 4 },
+ { 0xA, 4 },
+ { 0x6, 4 },
+ { 0x0, 4 },
+ { 0x1C, 5 },
+ { 0x9, 4 },
+ { 0xD, 4 },
+ { 0xF, 4 },
+ { 0xC, 4 },
+ { 0x3, 4 },
+ { 0xA, 5 },
+ { 0x16, 5 },
+ { 0x13, 6 },
+ { 0x5D, 7 },
+ { 0x24, 7 },
+ { 0xBC, 8 },
+ { 0x5C, 7 },
+ { 0x5EC, 11 },
+ { 0xB, 5 },
+ { 0x5F, 7 }
+ },
+ { /* AC bias group 1, table 1 */
+ { 0xF, 5 },
+ { 0x10, 6 },
+ { 0x4B, 8 },
+ { 0xC6, 8 },
+ { 0x31D, 10 },
+ { 0xC71, 12 },
+ { 0xC70, 12 },
+ { 0x1, 4 },
+ { 0xC73, 12 },
+ { 0x8, 4 },
+ { 0x9, 4 },
+ { 0x2, 4 },
+ { 0x3, 4 },
+ { 0xB, 4 },
+ { 0x6, 4 },
+ { 0x0, 4 },
+ { 0x1C, 5 },
+ { 0x5, 4 },
+ { 0xD, 4 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0x19, 5 },
+ { 0x13, 6 },
+ { 0x1D, 5 },
+ { 0x30, 6 },
+ { 0x62, 7 },
+ { 0x24, 7 },
+ { 0x4A, 8 },
+ { 0x18F, 9 },
+ { 0xC72, 12 },
+ { 0xE, 5 },
+ { 0x11, 6 }
+ },
+ { /* AC bias group 1, table 2 */
+ { 0x1B, 5 },
+ { 0x3, 6 },
+ { 0x8D, 8 },
+ { 0x40, 7 },
+ { 0x239, 10 },
+ { 0x471, 11 },
+ { 0x8E0, 12 },
+ { 0x3, 4 },
+ { 0x11C3, 13 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0x4, 4 },
+ { 0x5, 4 },
+ { 0xE, 4 },
+ { 0x7, 4 },
+ { 0x1, 4 },
+ { 0x1E, 5 },
+ { 0x6, 4 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x2, 4 },
+ { 0x0, 5 },
+ { 0x41, 7 },
+ { 0x1F, 5 },
+ { 0x22, 6 },
+ { 0x2, 6 },
+ { 0x8F, 8 },
+ { 0x8C, 8 },
+ { 0x11D, 9 },
+ { 0x11C2, 13 },
+ { 0x1A, 5 },
+ { 0x21, 6 }
+ },
+ { /* AC bias group 1, table 3 */
+ { 0x1F, 5 },
+ { 0x3, 6 },
+ { 0x3, 7 },
+ { 0x43, 7 },
+ { 0xB, 9 },
+ { 0x15, 10 },
+ { 0x51, 12 },
+ { 0x3, 4 },
+ { 0x50, 12 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x4, 4 },
+ { 0x6, 4 },
+ { 0xE, 4 },
+ { 0xA, 4 },
+ { 0x1, 4 },
+ { 0x1E, 5 },
+ { 0x5, 4 },
+ { 0x9, 4 },
+ { 0x7, 4 },
+ { 0x11, 5 },
+ { 0x2, 6 },
+ { 0x4, 8 },
+ { 0x2, 4 },
+ { 0x2D, 6 },
+ { 0x20, 6 },
+ { 0x42, 7 },
+ { 0x1, 7 },
+ { 0x0, 7 },
+ { 0x29, 11 },
+ { 0x17, 5 },
+ { 0x2C, 6 }
+ },
+ { /* AC bias group 1, table 4 */
+ { 0x3, 4 },
+ { 0x1F, 6 },
+ { 0x3A, 7 },
+ { 0x5D, 7 },
+ { 0x173, 9 },
+ { 0x2E4, 10 },
+ { 0x172D, 13 },
+ { 0x4, 4 },
+ { 0x172C, 13 },
+ { 0xF, 4 },
+ { 0xE, 4 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0xC, 4 },
+ { 0xA, 4 },
+ { 0x1, 4 },
+ { 0x16, 5 },
+ { 0x2, 4 },
+ { 0x5, 4 },
+ { 0x1A, 5 },
+ { 0x2F, 6 },
+ { 0x38, 7 },
+ { 0x5CA, 11 },
+ { 0x6, 4 },
+ { 0x37, 6 },
+ { 0x1E, 6 },
+ { 0x3B, 7 },
+ { 0x39, 7 },
+ { 0xB8, 8 },
+ { 0xB97, 12 },
+ { 0x0, 4 },
+ { 0x36, 6 }
+ },
+ { /* AC bias group 1, table 5 */
+ { 0x6, 4 },
+ { 0x37, 6 },
+ { 0x5D, 7 },
+ { 0xC, 6 },
+ { 0xB9, 8 },
+ { 0x2E3, 10 },
+ { 0x5C4, 11 },
+ { 0x4, 4 },
+ { 0x1715, 13 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0x8, 4 },
+ { 0x7, 4 },
+ { 0xC, 4 },
+ { 0x9, 4 },
+ { 0x1D, 5 },
+ { 0x16, 5 },
+ { 0x1C, 5 },
+ { 0x1A, 5 },
+ { 0xB, 5 },
+ { 0x5E, 7 },
+ { 0x170, 9 },
+ { 0x1714, 13 },
+ { 0xA, 4 },
+ { 0xA, 5 },
+ { 0x36, 6 },
+ { 0x5F, 7 },
+ { 0x1B, 7 },
+ { 0x1A, 7 },
+ { 0xB8B, 12 },
+ { 0x2, 4 },
+ { 0x7, 5 }
+ },
+ { /* AC bias group 1, table 6 */
+ { 0xC, 4 },
+ { 0xB, 5 },
+ { 0x79, 7 },
+ { 0x22, 6 },
+ { 0xF0, 8 },
+ { 0x119, 9 },
+ { 0x230, 10 },
+ { 0x1D, 5 },
+ { 0x8C4, 12 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0xB, 4 },
+ { 0x7, 4 },
+ { 0x1C, 5 },
+ { 0x3D, 6 },
+ { 0xD, 5 },
+ { 0x8, 5 },
+ { 0x15, 6 },
+ { 0x8D, 8 },
+ { 0x118B, 13 },
+ { 0x118A, 13 },
+ { 0xD, 4 },
+ { 0x10, 5 },
+ { 0x9, 5 },
+ { 0x14, 6 },
+ { 0x47, 7 },
+ { 0xF1, 8 },
+ { 0x463, 11 },
+ { 0x1F, 5 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 1, table 7 */
+ { 0x0, 3 },
+ { 0x1A, 5 },
+ { 0x33, 6 },
+ { 0xC, 5 },
+ { 0x46, 7 },
+ { 0x1E3, 9 },
+ { 0x3C5, 10 },
+ { 0x17, 5 },
+ { 0x1E21, 13 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x9, 4 },
+ { 0xA, 4 },
+ { 0x7, 4 },
+ { 0x1B, 5 },
+ { 0x3D, 6 },
+ { 0x1B, 6 },
+ { 0x22, 6 },
+ { 0x79, 7 },
+ { 0xF0, 8 },
+ { 0x1E20, 13 },
+ { 0x1E23, 13 },
+ { 0x1E22, 13 },
+ { 0xE, 4 },
+ { 0x16, 5 },
+ { 0x18, 5 },
+ { 0x32, 6 },
+ { 0x1A, 6 },
+ { 0x47, 7 },
+ { 0x789, 11 },
+ { 0x1F, 5 },
+ { 0x10, 5 }
+ },
+ { /* AC bias group 1, table 8 */
+ { 0x1D, 5 },
+ { 0x61, 7 },
+ { 0x4E, 8 },
+ { 0x9E, 9 },
+ { 0x27C, 11 },
+ { 0x9F5, 13 },
+ { 0x9F4, 13 },
+ { 0x3, 4 },
+ { 0x60, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0x5, 4 },
+ { 0xD, 5 },
+ { 0x31, 6 },
+ { 0x8, 5 },
+ { 0x38, 6 },
+ { 0x12, 6 },
+ { 0x26, 7 },
+ { 0x13F, 10 },
+ { 0x4FB, 12 },
+ { 0xD, 4 },
+ { 0x2, 4 },
+ { 0xC, 5 },
+ { 0x39, 6 },
+ { 0x1C, 6 },
+ { 0xF, 5 },
+ { 0x1D, 6 },
+ { 0x8, 4 },
+ { 0x19, 5 }
+ },
+ { /* AC bias group 1, table 9 */
+ { 0x7, 4 },
+ { 0x19, 6 },
+ { 0xAB, 8 },
+ { 0xAA, 8 },
+ { 0x119, 10 },
+ { 0x461, 12 },
+ { 0x460, 12 },
+ { 0x1B, 5 },
+ { 0x47, 8 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x9, 4 },
+ { 0x5, 4 },
+ { 0xD, 5 },
+ { 0x35, 6 },
+ { 0x3D, 6 },
+ { 0x3C, 6 },
+ { 0x18, 6 },
+ { 0x22, 7 },
+ { 0x8D, 9 },
+ { 0x231, 11 },
+ { 0xE, 4 },
+ { 0x1F, 5 },
+ { 0x9, 5 },
+ { 0x2B, 6 },
+ { 0x10, 6 },
+ { 0x34, 6 },
+ { 0x54, 7 },
+ { 0x8, 4 },
+ { 0x14, 5 }
+ },
+ { /* AC bias group 1, table 10 */
+ { 0xC, 4 },
+ { 0x5, 5 },
+ { 0x8, 6 },
+ { 0x5B, 7 },
+ { 0x4D, 9 },
+ { 0x131, 11 },
+ { 0x261, 12 },
+ { 0x1A, 5 },
+ { 0x12, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0x9, 4 },
+ { 0x6, 4 },
+ { 0x1B, 5 },
+ { 0x6, 5 },
+ { 0x1C, 6 },
+ { 0x2C, 6 },
+ { 0x15, 6 },
+ { 0x5A, 7 },
+ { 0x27, 8 },
+ { 0x99, 10 },
+ { 0x260, 12 },
+ { 0xE, 4 },
+ { 0x4, 4 },
+ { 0xF, 5 },
+ { 0x7, 5 },
+ { 0x1D, 6 },
+ { 0xB, 5 },
+ { 0x14, 6 },
+ { 0x8, 4 },
+ { 0x17, 5 }
+ },
+ { /* AC bias group 1, table 11 */
+ { 0xF, 4 },
+ { 0x13, 5 },
+ { 0x75, 7 },
+ { 0x24, 6 },
+ { 0x95, 8 },
+ { 0x251, 10 },
+ { 0x4A0, 11 },
+ { 0x10, 5 },
+ { 0xC8, 8 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x1, 4 },
+ { 0x0, 4 },
+ { 0x1A, 5 },
+ { 0x11, 5 },
+ { 0x2C, 6 },
+ { 0x65, 7 },
+ { 0x74, 7 },
+ { 0x4B, 7 },
+ { 0xC9, 8 },
+ { 0x129, 9 },
+ { 0x943, 12 },
+ { 0x942, 12 },
+ { 0x3, 3 },
+ { 0xA, 4 },
+ { 0x1C, 5 },
+ { 0x18, 5 },
+ { 0x33, 6 },
+ { 0x17, 5 },
+ { 0x2D, 6 },
+ { 0x1B, 5 },
+ { 0x3B, 6 }
+ },
+ { /* AC bias group 1, table 12 */
+ { 0x3, 3 },
+ { 0x1A, 5 },
+ { 0x2D, 6 },
+ { 0x38, 6 },
+ { 0x28, 7 },
+ { 0x395, 10 },
+ { 0xE51, 12 },
+ { 0x37, 6 },
+ { 0xE4, 8 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x1F, 5 },
+ { 0x1E, 5 },
+ { 0x17, 5 },
+ { 0x3A, 6 },
+ { 0x73, 7 },
+ { 0x2A, 7 },
+ { 0x2B, 7 },
+ { 0x29, 7 },
+ { 0x1CB, 9 },
+ { 0x729, 11 },
+ { 0x1CA1, 13 },
+ { 0x1CA0, 13 },
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x4, 4 },
+ { 0x18, 5 },
+ { 0x36, 6 },
+ { 0xB, 5 },
+ { 0x2C, 6 },
+ { 0x19, 5 },
+ { 0x3B, 6 }
+ },
+ { /* AC bias group 1, table 13 */
+ { 0x4, 3 },
+ { 0x4, 4 },
+ { 0x3F, 6 },
+ { 0x17, 5 },
+ { 0x75, 7 },
+ { 0x1F5, 9 },
+ { 0x7D1, 11 },
+ { 0x17, 6 },
+ { 0x1F6, 9 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x1B, 5 },
+ { 0x1A, 5 },
+ { 0xA, 5 },
+ { 0x32, 6 },
+ { 0x74, 7 },
+ { 0xF8, 8 },
+ { 0xF9, 8 },
+ { 0x1F7, 9 },
+ { 0x3E9, 10 },
+ { 0xFA0, 12 },
+ { 0x1F43, 13 },
+ { 0x1F42, 13 },
+ { 0x3, 3 },
+ { 0xA, 4 },
+ { 0x1E, 5 },
+ { 0x1C, 5 },
+ { 0x3B, 6 },
+ { 0x18, 5 },
+ { 0x16, 6 },
+ { 0x16, 5 },
+ { 0x33, 6 }
+ },
+ { /* AC bias group 1, table 14 */
+ { 0x4, 3 },
+ { 0x7, 4 },
+ { 0x18, 5 },
+ { 0x1E, 5 },
+ { 0x36, 6 },
+ { 0x31, 7 },
+ { 0x177, 9 },
+ { 0x77, 7 },
+ { 0x176, 9 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0x1A, 5 },
+ { 0x19, 5 },
+ { 0x3A, 6 },
+ { 0x19, 6 },
+ { 0x5C, 7 },
+ { 0xBA, 8 },
+ { 0x61, 8 },
+ { 0xC1, 9 },
+ { 0x180, 10 },
+ { 0x302, 11 },
+ { 0x607, 12 },
+ { 0x606, 12 },
+ { 0x2, 3 },
+ { 0xA, 4 },
+ { 0x1F, 5 },
+ { 0x1C, 5 },
+ { 0x37, 6 },
+ { 0x16, 5 },
+ { 0x76, 7 },
+ { 0xD, 5 },
+ { 0x2F, 6 }
+ },
+ { /* AC bias group 1, table 15 */
+ { 0x0, 3 },
+ { 0xA, 4 },
+ { 0x1A, 5 },
+ { 0xC, 4 },
+ { 0x1D, 5 },
+ { 0x39, 6 },
+ { 0x78, 7 },
+ { 0x5E, 7 },
+ { 0x393, 11 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x16, 5 },
+ { 0xF, 5 },
+ { 0x2E, 6 },
+ { 0x5F, 7 },
+ { 0x73, 8 },
+ { 0xE5, 9 },
+ { 0x1C8, 10 },
+ { 0xE4A, 13 },
+ { 0x1C97, 14 },
+ { 0x1C96, 14 },
+ { 0xE49, 13 },
+ { 0xE48, 13 },
+ { 0x4, 3 },
+ { 0x6, 4 },
+ { 0x1F, 5 },
+ { 0x1B, 5 },
+ { 0x1D, 6 },
+ { 0x38, 6 },
+ { 0x38, 7 },
+ { 0x3D, 6 },
+ { 0x79, 7 }
+ }
+};
+
+static const uint16_t ac_bias_1[16][32][2] = {
+ { /* AC bias group 2, table 0 */
+ { 0xB, 5 },
+ { 0x2B, 7 },
+ { 0x54, 8 },
+ { 0x1B7, 9 },
+ { 0x6D9, 11 },
+ { 0xDB1, 12 },
+ { 0xDB0, 12 },
+ { 0x2, 4 },
+ { 0xAB, 9 },
+ { 0x9, 4 },
+ { 0xA, 4 },
+ { 0x7, 4 },
+ { 0x8, 4 },
+ { 0xF, 4 },
+ { 0xC, 4 },
+ { 0x3, 4 },
+ { 0x1D, 5 },
+ { 0x4, 4 },
+ { 0xB, 4 },
+ { 0x6, 4 },
+ { 0x1A, 5 },
+ { 0x3, 6 },
+ { 0xAA, 9 },
+ { 0x1, 4 },
+ { 0x0, 5 },
+ { 0x14, 6 },
+ { 0x6C, 7 },
+ { 0xDA, 8 },
+ { 0x2, 6 },
+ { 0x36D, 10 },
+ { 0x1C, 5 },
+ { 0x37, 6 }
+ },
+ { /* AC bias group 2, table 1 */
+ { 0x1D, 5 },
+ { 0x4, 6 },
+ { 0xB6, 8 },
+ { 0x6A, 8 },
+ { 0x5B9, 11 },
+ { 0x16E1, 13 },
+ { 0x16E0, 13 },
+ { 0x7, 4 },
+ { 0x16F, 9 },
+ { 0xC, 4 },
+ { 0xD, 4 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0x3, 4 },
+ { 0x17, 5 },
+ { 0x2, 4 },
+ { 0x4, 4 },
+ { 0x1C, 5 },
+ { 0x2C, 6 },
+ { 0x6B, 8 },
+ { 0xB71, 12 },
+ { 0x5, 4 },
+ { 0x3, 5 },
+ { 0x1B, 6 },
+ { 0x5A, 7 },
+ { 0x34, 7 },
+ { 0x5, 6 },
+ { 0x2DD, 10 },
+ { 0x0, 4 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 2, table 2 */
+ { 0x3, 4 },
+ { 0x7F, 7 },
+ { 0xA1, 8 },
+ { 0xA0, 8 },
+ { 0x20C, 10 },
+ { 0x834, 12 },
+ { 0x106B, 13 },
+ { 0x7, 4 },
+ { 0x82, 8 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x2, 4 },
+ { 0x11, 5 },
+ { 0x1E, 5 },
+ { 0x15, 5 },
+ { 0x3E, 6 },
+ { 0x40, 7 },
+ { 0x41B, 11 },
+ { 0x106A, 13 },
+ { 0x6, 4 },
+ { 0xA, 5 },
+ { 0x29, 6 },
+ { 0x7E, 7 },
+ { 0x51, 7 },
+ { 0x21, 6 },
+ { 0x107, 9 },
+ { 0x4, 4 },
+ { 0xB, 5 }
+ },
+ { /* AC bias group 2, table 3 */
+ { 0x7, 4 },
+ { 0x1B, 6 },
+ { 0xF6, 8 },
+ { 0xE9, 8 },
+ { 0x3A1, 10 },
+ { 0x740, 11 },
+ { 0xE82, 12 },
+ { 0x1F, 5 },
+ { 0x1EF, 9 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0xD, 4 },
+ { 0x8, 4 },
+ { 0x1C, 5 },
+ { 0x3, 5 },
+ { 0x12, 5 },
+ { 0x2, 5 },
+ { 0x75, 7 },
+ { 0x1D1, 9 },
+ { 0x1D07, 13 },
+ { 0x1D06, 13 },
+ { 0xA, 4 },
+ { 0x13, 5 },
+ { 0x3B, 6 },
+ { 0x1A, 6 },
+ { 0x7A, 7 },
+ { 0x3C, 6 },
+ { 0x1EE, 9 },
+ { 0x0, 4 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 2, table 4 */
+ { 0xD, 4 },
+ { 0x3D, 6 },
+ { 0x42, 7 },
+ { 0x37, 7 },
+ { 0xD9, 9 },
+ { 0x362, 11 },
+ { 0x6C6, 12 },
+ { 0x1F, 5 },
+ { 0x86, 8 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0x1, 4 },
+ { 0xF, 5 },
+ { 0x25, 6 },
+ { 0x3C, 6 },
+ { 0x1A, 6 },
+ { 0x87, 8 },
+ { 0x1B0, 10 },
+ { 0xD8F, 13 },
+ { 0xD8E, 13 },
+ { 0xE, 4 },
+ { 0x13, 5 },
+ { 0xC, 5 },
+ { 0x24, 6 },
+ { 0x20, 6 },
+ { 0x11, 5 },
+ { 0x6D, 8 },
+ { 0x0, 4 },
+ { 0xE, 5 }
+ },
+ { /* AC bias group 2, table 5 */
+ { 0x0, 3 },
+ { 0x12, 5 },
+ { 0x76, 7 },
+ { 0x77, 7 },
+ { 0x14D, 9 },
+ { 0x533, 11 },
+ { 0x14C9, 13 },
+ { 0x13, 5 },
+ { 0xA5, 8 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x8, 4 },
+ { 0x1A, 5 },
+ { 0x2B, 6 },
+ { 0x75, 7 },
+ { 0x74, 7 },
+ { 0xA7, 8 },
+ { 0x298, 10 },
+ { 0x14C8, 13 },
+ { 0x14CB, 13 },
+ { 0x14CA, 13 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0x7, 5 },
+ { 0x2A, 6 },
+ { 0x28, 6 },
+ { 0x1B, 5 },
+ { 0xA4, 8 },
+ { 0x2, 4 },
+ { 0x6, 5 }
+ },
+ { /* AC bias group 2, table 6 */
+ { 0x2, 3 },
+ { 0x1A, 5 },
+ { 0x2B, 6 },
+ { 0x3A, 6 },
+ { 0xED, 8 },
+ { 0x283, 10 },
+ { 0xA0A, 12 },
+ { 0x4, 5 },
+ { 0xA1, 8 },
+ { 0x4, 3 },
+ { 0x3, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x1F, 5 },
+ { 0x6, 5 },
+ { 0x77, 7 },
+ { 0xA3, 8 },
+ { 0xA2, 8 },
+ { 0x140, 9 },
+ { 0x1417, 13 },
+ { 0x1416, 13 },
+ { 0xA09, 12 },
+ { 0xA08, 12 },
+ { 0x0, 3 },
+ { 0x1E, 5 },
+ { 0x7, 5 },
+ { 0x2A, 6 },
+ { 0x29, 6 },
+ { 0x1C, 5 },
+ { 0xEC, 8 },
+ { 0x1B, 5 },
+ { 0x5, 5 }
+ },
+ { /* AC bias group 2, table 7 */
+ { 0x2, 3 },
+ { 0x2, 4 },
+ { 0x18, 5 },
+ { 0x1D, 5 },
+ { 0x35, 6 },
+ { 0xE4, 8 },
+ { 0x1CF, 11 },
+ { 0x1D, 7 },
+ { 0x72, 9 },
+ { 0x4, 3 },
+ { 0x5, 3 },
+ { 0x6, 4 },
+ { 0x7, 4 },
+ { 0x6, 5 },
+ { 0x73, 7 },
+ { 0x38, 8 },
+ { 0x1CE, 11 },
+ { 0x39B, 12 },
+ { 0x398, 12 },
+ { 0x733, 13 },
+ { 0x732, 13 },
+ { 0x735, 13 },
+ { 0x734, 13 },
+ { 0x0, 3 },
+ { 0x1F, 5 },
+ { 0x1B, 5 },
+ { 0x34, 6 },
+ { 0xF, 6 },
+ { 0x1E, 5 },
+ { 0xE5, 8 },
+ { 0x19, 5 },
+ { 0x38, 6 }
+ },
+ { /* AC bias group 2, table 8 */
+ { 0x16, 5 },
+ { 0x50, 7 },
+ { 0x172, 9 },
+ { 0x2E7, 10 },
+ { 0x1732, 13 },
+ { 0x2E67, 14 },
+ { 0x2E66, 14 },
+ { 0x6, 4 },
+ { 0x51, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x9, 4 },
+ { 0x1C, 5 },
+ { 0x9, 5 },
+ { 0x1C, 6 },
+ { 0x1D, 6 },
+ { 0x5D, 7 },
+ { 0xB8, 8 },
+ { 0x5CD, 11 },
+ { 0x1731, 13 },
+ { 0x1730, 13 },
+ { 0xF, 4 },
+ { 0x5, 4 },
+ { 0xF, 5 },
+ { 0x8, 5 },
+ { 0x29, 6 },
+ { 0x1D, 5 },
+ { 0x2F, 6 },
+ { 0x8, 4 },
+ { 0x15, 5 }
+ },
+ { /* AC bias group 2, table 9 */
+ { 0x9, 4 },
+ { 0x21, 6 },
+ { 0x40, 7 },
+ { 0xAD, 8 },
+ { 0x2B0, 10 },
+ { 0x1589, 13 },
+ { 0x1588, 13 },
+ { 0x1C, 5 },
+ { 0x5F, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x6, 4 },
+ { 0x11, 5 },
+ { 0x2A, 6 },
+ { 0x57, 7 },
+ { 0x5E, 7 },
+ { 0x41, 7 },
+ { 0x159, 9 },
+ { 0x563, 11 },
+ { 0x158B, 13 },
+ { 0x158A, 13 },
+ { 0x1, 3 },
+ { 0x5, 4 },
+ { 0x14, 5 },
+ { 0x3B, 6 },
+ { 0x2E, 6 },
+ { 0x4, 4 },
+ { 0x3A, 6 },
+ { 0x7, 4 },
+ { 0x16, 5 }
+ },
+ { /* AC bias group 2, table 10 */
+ { 0xE, 4 },
+ { 0x7, 5 },
+ { 0x46, 7 },
+ { 0x45, 7 },
+ { 0x64, 9 },
+ { 0x32A, 12 },
+ { 0x657, 13 },
+ { 0x18, 5 },
+ { 0xD, 6 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xA, 4 },
+ { 0xB, 4 },
+ { 0x1A, 5 },
+ { 0x36, 6 },
+ { 0x47, 7 },
+ { 0x44, 7 },
+ { 0x18, 7 },
+ { 0x33, 8 },
+ { 0xCB, 10 },
+ { 0x656, 13 },
+ { 0x329, 12 },
+ { 0x328, 12 },
+ { 0x2, 3 },
+ { 0x6, 4 },
+ { 0x19, 5 },
+ { 0xE, 5 },
+ { 0x37, 6 },
+ { 0x9, 4 },
+ { 0xF, 5 },
+ { 0x2, 4 },
+ { 0x10, 5 }
+ },
+ { /* AC bias group 2, table 11 */
+ { 0x3, 3 },
+ { 0x18, 5 },
+ { 0x23, 6 },
+ { 0x77, 7 },
+ { 0x194, 9 },
+ { 0x1956, 13 },
+ { 0x32AF, 14 },
+ { 0x3A, 6 },
+ { 0x76, 7 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x1F, 5 },
+ { 0x1E, 5 },
+ { 0x14, 5 },
+ { 0x22, 6 },
+ { 0x64, 7 },
+ { 0x197, 9 },
+ { 0x196, 9 },
+ { 0x32B, 10 },
+ { 0x654, 11 },
+ { 0x32AE, 14 },
+ { 0x1955, 13 },
+ { 0x1954, 13 },
+ { 0x0, 3 },
+ { 0x9, 4 },
+ { 0x1C, 5 },
+ { 0x15, 5 },
+ { 0x10, 5 },
+ { 0xD, 4 },
+ { 0x17, 5 },
+ { 0x16, 5 },
+ { 0x33, 6 }
+ },
+ { /* AC bias group 2, table 12 */
+ { 0x5, 3 },
+ { 0x6, 4 },
+ { 0x3E, 6 },
+ { 0x10, 5 },
+ { 0x48, 7 },
+ { 0x93F, 12 },
+ { 0x24FA, 14 },
+ { 0x32, 6 },
+ { 0x67, 7 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x1B, 5 },
+ { 0x1E, 5 },
+ { 0x34, 6 },
+ { 0x66, 7 },
+ { 0x92, 8 },
+ { 0x126, 9 },
+ { 0x24E, 10 },
+ { 0x49E, 11 },
+ { 0x49F7, 15 },
+ { 0x49F6, 15 },
+ { 0x24F9, 14 },
+ { 0x24F8, 14 },
+ { 0x0, 3 },
+ { 0x7, 4 },
+ { 0x18, 5 },
+ { 0x11, 5 },
+ { 0x3F, 6 },
+ { 0xE, 4 },
+ { 0x13, 5 },
+ { 0x35, 6 },
+ { 0x25, 6 }
+ },
+ { /* AC bias group 2, table 13 */
+ { 0x5, 3 },
+ { 0x8, 4 },
+ { 0x12, 5 },
+ { 0x1C, 5 },
+ { 0x1C, 6 },
+ { 0xEA, 9 },
+ { 0x1D75, 14 },
+ { 0x1E, 6 },
+ { 0x66, 7 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0x1B, 5 },
+ { 0x1A, 5 },
+ { 0x1F, 6 },
+ { 0x3B, 7 },
+ { 0x74, 8 },
+ { 0x1D6, 10 },
+ { 0x3AF, 11 },
+ { 0x1D74, 14 },
+ { 0x1D77, 14 },
+ { 0x1D76, 14 },
+ { 0xEB9, 13 },
+ { 0xEB8, 13 },
+ { 0xF, 4 },
+ { 0x6, 4 },
+ { 0x13, 5 },
+ { 0x3B, 6 },
+ { 0x3A, 6 },
+ { 0x0, 3 },
+ { 0x18, 5 },
+ { 0x32, 6 },
+ { 0x67, 7 }
+ },
+ { /* AC bias group 2, table 14 */
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x1B, 5 },
+ { 0xC, 4 },
+ { 0xD, 5 },
+ { 0xE6, 8 },
+ { 0x684, 11 },
+ { 0x72, 7 },
+ { 0xE7, 8 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x17, 5 },
+ { 0x16, 5 },
+ { 0x18, 6 },
+ { 0xD1, 8 },
+ { 0x1A0, 9 },
+ { 0x686, 11 },
+ { 0xD0F, 12 },
+ { 0xD0A, 12 },
+ { 0x1A17, 13 },
+ { 0x1A16, 13 },
+ { 0x1A1D, 13 },
+ { 0x1A1C, 13 },
+ { 0xF, 4 },
+ { 0x1D, 5 },
+ { 0xE, 5 },
+ { 0x35, 6 },
+ { 0x38, 6 },
+ { 0x0, 3 },
+ { 0xF, 5 },
+ { 0x19, 6 },
+ { 0x69, 7 }
+ },
+ { /* AC bias group 2, table 15 */
+ { 0x3, 3 },
+ { 0xC, 4 },
+ { 0x1B, 5 },
+ { 0x0, 3 },
+ { 0x3, 4 },
+ { 0x2E, 6 },
+ { 0x51, 9 },
+ { 0xBC, 8 },
+ { 0x53, 9 },
+ { 0x4, 3 },
+ { 0x2, 3 },
+ { 0x16, 5 },
+ { 0x15, 5 },
+ { 0x15, 7 },
+ { 0x50, 9 },
+ { 0xA4, 10 },
+ { 0x294, 12 },
+ { 0x52B, 13 },
+ { 0x52A, 13 },
+ { 0x52D, 13 },
+ { 0x52C, 13 },
+ { 0x52F, 13 },
+ { 0x52E, 13 },
+ { 0xE, 4 },
+ { 0x1A, 5 },
+ { 0x4, 5 },
+ { 0x28, 6 },
+ { 0x29, 6 },
+ { 0xF, 4 },
+ { 0xB, 6 },
+ { 0x5F, 7 },
+ { 0xBD, 8 }
+ }
+};
+
+static const uint16_t ac_bias_2[16][32][2] = {
+ { /* AC bias group 3, table 0 */
+ { 0x3, 4 },
+ { 0x9, 6 },
+ { 0xD0, 8 },
+ { 0x1A3, 9 },
+ { 0x344, 10 },
+ { 0xD14, 12 },
+ { 0x1A2B, 13 },
+ { 0x4, 4 },
+ { 0x15, 7 },
+ { 0x0, 3 },
+ { 0xF, 4 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0xE, 4 },
+ { 0x9, 4 },
+ { 0x1B, 5 },
+ { 0xA, 5 },
+ { 0x14, 5 },
+ { 0xD, 5 },
+ { 0x2A, 6 },
+ { 0x14, 7 },
+ { 0x68B, 11 },
+ { 0x1A2A, 13 },
+ { 0x8, 4 },
+ { 0xB, 5 },
+ { 0x2B, 6 },
+ { 0xB, 6 },
+ { 0x69, 7 },
+ { 0x35, 6 },
+ { 0x8, 6 },
+ { 0x7, 4 },
+ { 0xC, 5 }
+ },
+ { /* AC bias group 3, table 1 */
+ { 0xA, 4 },
+ { 0x3C, 6 },
+ { 0x32, 7 },
+ { 0x30, 7 },
+ { 0xC5, 9 },
+ { 0x621, 12 },
+ { 0x620, 12 },
+ { 0x1F, 5 },
+ { 0x33, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x4, 4 },
+ { 0xD, 5 },
+ { 0x26, 6 },
+ { 0x27, 6 },
+ { 0x14, 6 },
+ { 0x63, 8 },
+ { 0x189, 10 },
+ { 0x623, 12 },
+ { 0x622, 12 },
+ { 0xB, 4 },
+ { 0x12, 5 },
+ { 0x3D, 6 },
+ { 0x22, 6 },
+ { 0x15, 6 },
+ { 0xB, 5 },
+ { 0x23, 6 },
+ { 0x7, 4 },
+ { 0x10, 5 }
+ },
+ { /* AC bias group 3, table 2 */
+ { 0xF, 4 },
+ { 0xC, 5 },
+ { 0x43, 7 },
+ { 0x10, 6 },
+ { 0x44, 8 },
+ { 0x114, 10 },
+ { 0x455, 12 },
+ { 0x18, 5 },
+ { 0x23, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0x9, 4 },
+ { 0x19, 5 },
+ { 0x9, 5 },
+ { 0x17, 6 },
+ { 0x16, 6 },
+ { 0x42, 7 },
+ { 0x8B, 9 },
+ { 0x454, 12 },
+ { 0x457, 12 },
+ { 0x456, 12 },
+ { 0xB, 4 },
+ { 0x15, 5 },
+ { 0xA, 5 },
+ { 0x29, 6 },
+ { 0x20, 6 },
+ { 0xD, 5 },
+ { 0x28, 6 },
+ { 0x7, 4 },
+ { 0x11, 5 }
+ },
+ { /* AC bias group 3, table 3 */
+ { 0x1, 3 },
+ { 0x1A, 5 },
+ { 0x29, 6 },
+ { 0x2A, 6 },
+ { 0xA0, 8 },
+ { 0x285, 10 },
+ { 0x1425, 13 },
+ { 0x2, 5 },
+ { 0x0, 7 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x8, 4 },
+ { 0x12, 5 },
+ { 0x1, 6 },
+ { 0x51, 7 },
+ { 0x1, 7 },
+ { 0x143, 9 },
+ { 0x508, 11 },
+ { 0x1424, 13 },
+ { 0x1427, 13 },
+ { 0x1426, 13 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0x3, 5 },
+ { 0x37, 6 },
+ { 0x2B, 6 },
+ { 0x13, 5 },
+ { 0x36, 6 },
+ { 0x1D, 5 },
+ { 0x1, 5 }
+ },
+ { /* AC bias group 3, table 4 */
+ { 0x4, 3 },
+ { 0x1F, 5 },
+ { 0x3D, 6 },
+ { 0x6, 5 },
+ { 0x16, 7 },
+ { 0x53, 9 },
+ { 0x14A, 11 },
+ { 0x34, 6 },
+ { 0x2A, 8 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xB, 4 },
+ { 0xC, 4 },
+ { 0x1C, 5 },
+ { 0x37, 6 },
+ { 0x17, 7 },
+ { 0x2B, 8 },
+ { 0x28, 8 },
+ { 0xA4, 10 },
+ { 0x52D, 13 },
+ { 0x52C, 13 },
+ { 0x52F, 13 },
+ { 0x52E, 13 },
+ { 0x0, 3 },
+ { 0x1D, 5 },
+ { 0x7, 5 },
+ { 0x4, 5 },
+ { 0x35, 6 },
+ { 0x14, 5 },
+ { 0x36, 6 },
+ { 0x15, 5 },
+ { 0x3C, 6 }
+ },
+ { /* AC bias group 3, table 5 */
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x7, 5 },
+ { 0x1D, 5 },
+ { 0x9, 6 },
+ { 0x1F3, 9 },
+ { 0x7C7, 11 },
+ { 0x8, 6 },
+ { 0x1F0, 9 },
+ { 0x3, 3 },
+ { 0x2, 3 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x17, 5 },
+ { 0x7D, 7 },
+ { 0x1F2, 9 },
+ { 0x7C6, 11 },
+ { 0x7C5, 11 },
+ { 0x1F12, 13 },
+ { 0x3E27, 14 },
+ { 0x3E26, 14 },
+ { 0x1F11, 13 },
+ { 0x1F10, 13 },
+ { 0x0, 3 },
+ { 0x1E, 5 },
+ { 0x6, 5 },
+ { 0x39, 6 },
+ { 0x38, 6 },
+ { 0x3F, 6 },
+ { 0x2C, 6 },
+ { 0x5, 5 },
+ { 0x2D, 6 }
+ },
+ { /* AC bias group 3, table 6 */
+ { 0x2, 3 },
+ { 0x7, 4 },
+ { 0x18, 5 },
+ { 0x3, 4 },
+ { 0x5, 5 },
+ { 0x35, 7 },
+ { 0x4F, 9 },
+ { 0x12, 7 },
+ { 0x4E5, 13 },
+ { 0x5, 3 },
+ { 0x4, 3 },
+ { 0xD, 4 },
+ { 0xE, 4 },
+ { 0x33, 6 },
+ { 0x26, 8 },
+ { 0x9D, 10 },
+ { 0x4E4, 13 },
+ { 0x4E7, 13 },
+ { 0x4E6, 13 },
+ { 0x4E1, 13 },
+ { 0x4E0, 13 },
+ { 0x4E3, 13 },
+ { 0x4E2, 13 },
+ { 0x0, 3 },
+ { 0x1F, 5 },
+ { 0xC, 5 },
+ { 0x3D, 6 },
+ { 0x3C, 6 },
+ { 0x32, 6 },
+ { 0x34, 7 },
+ { 0x1B, 6 },
+ { 0x8, 6 }
+ },
+ { /* AC bias group 3, table 7 */
+ { 0x0, 3 },
+ { 0x4, 4 },
+ { 0x1C, 5 },
+ { 0xF, 4 },
+ { 0x2, 4 },
+ { 0x7, 5 },
+ { 0x75, 7 },
+ { 0xE8, 8 },
+ { 0x1D2A, 13 },
+ { 0x5, 3 },
+ { 0x4, 3 },
+ { 0xD, 4 },
+ { 0xC, 4 },
+ { 0x77, 7 },
+ { 0xE96, 12 },
+ { 0x3A57, 14 },
+ { 0x3A56, 14 },
+ { 0x3A5D, 14 },
+ { 0x3A5C, 14 },
+ { 0x3A5F, 14 },
+ { 0x3A5E, 14 },
+ { 0x1D29, 13 },
+ { 0x1D28, 13 },
+ { 0x3, 3 },
+ { 0x6, 5 },
+ { 0xA, 5 },
+ { 0x2C, 7 },
+ { 0x17, 6 },
+ { 0x76, 7 },
+ { 0x1D3, 9 },
+ { 0x3A4, 10 },
+ { 0x2D, 7 }
+ },
+ { /* AC bias group 3, table 8 */
+ { 0xA, 4 },
+ { 0x24, 6 },
+ { 0xBF, 8 },
+ { 0x85, 8 },
+ { 0x211, 10 },
+ { 0x842, 12 },
+ { 0x1087, 13 },
+ { 0x18, 5 },
+ { 0x20, 6 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0x7, 4 },
+ { 0x13, 5 },
+ { 0x25, 6 },
+ { 0x5E, 7 },
+ { 0x43, 7 },
+ { 0xBE, 8 },
+ { 0x109, 9 },
+ { 0x1086, 13 },
+ { 0x841, 12 },
+ { 0x840, 12 },
+ { 0xF, 4 },
+ { 0x1, 4 },
+ { 0x11, 5 },
+ { 0x0, 5 },
+ { 0x2E, 6 },
+ { 0x19, 5 },
+ { 0x1, 5 },
+ { 0x6, 4 },
+ { 0x16, 5 }
+ },
+ { /* AC bias group 3, table 9 */
+ { 0x2, 3 },
+ { 0xF, 5 },
+ { 0x6F, 7 },
+ { 0x61, 7 },
+ { 0x374, 10 },
+ { 0x1BA8, 13 },
+ { 0x3753, 14 },
+ { 0x12, 5 },
+ { 0x36, 6 },
+ { 0x0, 3 },
+ { 0x1, 3 },
+ { 0xA, 4 },
+ { 0xB, 4 },
+ { 0x1A, 5 },
+ { 0x31, 6 },
+ { 0x60, 7 },
+ { 0xDC, 8 },
+ { 0x1BB, 9 },
+ { 0x6EB, 11 },
+ { 0x1BAB, 13 },
+ { 0x3752, 14 },
+ { 0x3755, 14 },
+ { 0x3754, 14 },
+ { 0xE, 4 },
+ { 0x6, 4 },
+ { 0x13, 5 },
+ { 0xE, 5 },
+ { 0x3E, 6 },
+ { 0x8, 4 },
+ { 0x1E, 5 },
+ { 0x19, 5 },
+ { 0x3F, 6 }
+ },
+ { /* AC bias group 3, table 10 */
+ { 0x3, 3 },
+ { 0x1C, 5 },
+ { 0x25, 6 },
+ { 0x24, 6 },
+ { 0x1DA, 9 },
+ { 0x1DBD, 13 },
+ { 0x3B7C, 14 },
+ { 0x3C, 6 },
+ { 0x3D, 6 },
+ { 0x0, 3 },
+ { 0x1, 3 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0xB, 5 },
+ { 0x77, 7 },
+ { 0xEC, 8 },
+ { 0x3B6, 10 },
+ { 0x76E, 11 },
+ { 0x1DBF, 13 },
+ { 0x76FB, 15 },
+ { 0x76FA, 15 },
+ { 0x3B79, 14 },
+ { 0x3B78, 14 },
+ { 0xD, 4 },
+ { 0x1F, 5 },
+ { 0x13, 5 },
+ { 0xA, 5 },
+ { 0x8, 5 },
+ { 0xC, 4 },
+ { 0x8, 4 },
+ { 0x9, 5 },
+ { 0x3A, 6 }
+ },
+ { /* AC bias group 3, table 11 */
+ { 0x5, 3 },
+ { 0x3, 4 },
+ { 0x4, 5 },
+ { 0x10, 5 },
+ { 0x8F, 8 },
+ { 0x475, 11 },
+ { 0x11D1, 13 },
+ { 0x79, 7 },
+ { 0x27, 6 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0x1, 4 },
+ { 0x0, 4 },
+ { 0x26, 6 },
+ { 0x46, 7 },
+ { 0x11C, 9 },
+ { 0x477, 11 },
+ { 0x8ED, 12 },
+ { 0x11D0, 13 },
+ { 0x11D3, 13 },
+ { 0x11D2, 13 },
+ { 0x11D9, 13 },
+ { 0x11D8, 13 },
+ { 0xD, 4 },
+ { 0x1F, 5 },
+ { 0x12, 5 },
+ { 0x5, 5 },
+ { 0x3D, 6 },
+ { 0xC, 4 },
+ { 0xE, 4 },
+ { 0x22, 6 },
+ { 0x78, 7 }
+ },
+ { /* AC bias group 3, table 12 */
+ { 0x5, 3 },
+ { 0xC, 4 },
+ { 0x1B, 5 },
+ { 0x0, 4 },
+ { 0x6, 6 },
+ { 0x3E2, 10 },
+ { 0x3E3D, 14 },
+ { 0xF, 7 },
+ { 0x34, 6 },
+ { 0x3, 3 },
+ { 0x2, 3 },
+ { 0x1E, 5 },
+ { 0x1D, 5 },
+ { 0x7D, 7 },
+ { 0x1F0, 9 },
+ { 0x7C6, 11 },
+ { 0x3E3C, 14 },
+ { 0x3E3F, 14 },
+ { 0x3E3E, 14 },
+ { 0x3E39, 14 },
+ { 0x3E38, 14 },
+ { 0x3E3B, 14 },
+ { 0x3E3A, 14 },
+ { 0x8, 4 },
+ { 0x1C, 5 },
+ { 0x2, 5 },
+ { 0x3F, 6 },
+ { 0x35, 6 },
+ { 0x9, 4 },
+ { 0x1, 3 },
+ { 0xE, 7 },
+ { 0xF9, 8 }
+ },
+ { /* AC bias group 3, table 13 */
+ { 0x4, 3 },
+ { 0xB, 4 },
+ { 0x1, 4 },
+ { 0xA, 4 },
+ { 0x1E, 6 },
+ { 0xE0, 9 },
+ { 0xE1E, 13 },
+ { 0x71, 8 },
+ { 0x39, 7 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0xD, 5 },
+ { 0xC, 5 },
+ { 0x20, 7 },
+ { 0x1C2, 10 },
+ { 0x1C3F, 14 },
+ { 0x1C3E, 14 },
+ { 0xE19, 13 },
+ { 0xE18, 13 },
+ { 0xE1B, 13 },
+ { 0xE1A, 13 },
+ { 0xE1D, 13 },
+ { 0xE1C, 13 },
+ { 0x0, 4 },
+ { 0x9, 5 },
+ { 0x1D, 6 },
+ { 0x1F, 6 },
+ { 0x11, 6 },
+ { 0x5, 4 },
+ { 0x1, 3 },
+ { 0x43, 8 },
+ { 0x42, 8 }
+ },
+ { /* AC bias group 3, table 14 */
+ { 0x4, 3 },
+ { 0xD, 4 },
+ { 0x7, 4 },
+ { 0x2, 3 },
+ { 0x14, 5 },
+ { 0x16C, 9 },
+ { 0x16D1, 13 },
+ { 0x2DF, 10 },
+ { 0x16E, 9 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x2C, 6 },
+ { 0x2B, 6 },
+ { 0x2DE, 10 },
+ { 0x16D0, 13 },
+ { 0x16D3, 13 },
+ { 0x16D2, 13 },
+ { 0x2DB5, 14 },
+ { 0x2DB4, 14 },
+ { 0x2DB7, 14 },
+ { 0x2DB6, 14 },
+ { 0x16D9, 13 },
+ { 0x16D8, 13 },
+ { 0xC, 5 },
+ { 0x2A, 6 },
+ { 0x5A, 7 },
+ { 0x1B, 6 },
+ { 0x1A, 6 },
+ { 0x17, 5 },
+ { 0xC, 4 },
+ { 0x5B7, 11 },
+ { 0x5B5, 11 }
+ },
+ { /* AC bias group 3, table 15 */
+ { 0x2, 2 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0xC, 4 },
+ { 0x3B, 6 },
+ { 0x1AC, 9 },
+ { 0x1AD8, 13 },
+ { 0x35B3, 14 },
+ { 0x35B2, 14 },
+ { 0x1, 2 },
+ { 0x0, 2 },
+ { 0x69, 7 },
+ { 0x68, 7 },
+ { 0x35BD, 14 },
+ { 0x35BC, 14 },
+ { 0x35BF, 14 },
+ { 0x35BE, 14 },
+ { 0x35B9, 14 },
+ { 0x35B8, 14 },
+ { 0x35BB, 14 },
+ { 0x35BA, 14 },
+ { 0x35B5, 14 },
+ { 0x35B4, 14 },
+ { 0x1A9, 9 },
+ { 0x1A8, 9 },
+ { 0x35A, 10 },
+ { 0xD7, 8 },
+ { 0xD5, 8 },
+ { 0x3A, 6 },
+ { 0x1B, 5 },
+ { 0x35B7, 14 },
+ { 0x35B6, 14 }
+ }
+};
+
+static const uint16_t ac_bias_3[16][32][2] = {
+ { /* AC bias group 4, table 0 */
+ { 0x0, 3 },
+ { 0x10, 5 },
+ { 0x72, 7 },
+ { 0x71, 7 },
+ { 0x154, 9 },
+ { 0xAAB, 12 },
+ { 0xAA8, 12 },
+ { 0x14, 5 },
+ { 0x70, 7 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0xC, 4 },
+ { 0xB, 4 },
+ { 0x3, 4 },
+ { 0x11, 5 },
+ { 0x73, 7 },
+ { 0x54, 7 },
+ { 0xAB, 8 },
+ { 0x2AB, 10 },
+ { 0x1553, 13 },
+ { 0x1552, 13 },
+ { 0x1555, 13 },
+ { 0x1554, 13 },
+ { 0xD, 4 },
+ { 0x1E, 5 },
+ { 0x12, 5 },
+ { 0x3E, 6 },
+ { 0x2B, 6 },
+ { 0x2, 4 },
+ { 0x3F, 6 },
+ { 0x1D, 5 },
+ { 0x13, 5 }
+ },
+ { /* AC bias group 4, table 1 */
+ { 0x3, 3 },
+ { 0x1F, 5 },
+ { 0x29, 6 },
+ { 0x3D, 6 },
+ { 0xC, 7 },
+ { 0x69, 10 },
+ { 0x345, 13 },
+ { 0x2, 5 },
+ { 0x28, 6 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0xE, 4 },
+ { 0xC, 4 },
+ { 0x15, 5 },
+ { 0x7, 6 },
+ { 0x1B, 8 },
+ { 0x6B, 10 },
+ { 0x6A, 10 },
+ { 0x344, 13 },
+ { 0x347, 13 },
+ { 0x346, 13 },
+ { 0x1A1, 12 },
+ { 0x1A0, 12 },
+ { 0xB, 4 },
+ { 0x1A, 5 },
+ { 0x12, 5 },
+ { 0x0, 5 },
+ { 0x3C, 6 },
+ { 0x8, 4 },
+ { 0x1B, 5 },
+ { 0x13, 5 },
+ { 0x1, 5 }
+ },
+ { /* AC bias group 4, table 2 */
+ { 0x4, 3 },
+ { 0x4, 4 },
+ { 0x3F, 6 },
+ { 0x14, 5 },
+ { 0x56, 7 },
+ { 0x15C, 9 },
+ { 0x15D5, 13 },
+ { 0x3C, 6 },
+ { 0x2A, 6 },
+ { 0x0, 3 },
+ { 0x1, 3 },
+ { 0xE, 4 },
+ { 0xD, 4 },
+ { 0xC, 5 },
+ { 0xAF, 8 },
+ { 0x2BB, 10 },
+ { 0x15D4, 13 },
+ { 0x15D7, 13 },
+ { 0x15D6, 13 },
+ { 0x15D1, 13 },
+ { 0x15D0, 13 },
+ { 0x15D3, 13 },
+ { 0x15D2, 13 },
+ { 0xB, 4 },
+ { 0x19, 5 },
+ { 0xD, 5 },
+ { 0x3E, 6 },
+ { 0x31, 6 },
+ { 0x7, 4 },
+ { 0x5, 4 },
+ { 0x3D, 6 },
+ { 0x30, 6 }
+ },
+ { /* AC bias group 4, table 3 */
+ { 0x5, 3 },
+ { 0x8, 4 },
+ { 0x1A, 5 },
+ { 0x0, 4 },
+ { 0x36, 6 },
+ { 0x11, 8 },
+ { 0x106, 12 },
+ { 0xA, 7 },
+ { 0x6E, 7 },
+ { 0x2, 3 },
+ { 0x3, 3 },
+ { 0x3, 4 },
+ { 0x2, 4 },
+ { 0x6F, 7 },
+ { 0x21, 9 },
+ { 0x20F, 13 },
+ { 0x20E, 13 },
+ { 0x101, 12 },
+ { 0x100, 12 },
+ { 0x103, 12 },
+ { 0x102, 12 },
+ { 0x105, 12 },
+ { 0x104, 12 },
+ { 0xC, 4 },
+ { 0x1E, 5 },
+ { 0x3, 5 },
+ { 0x3E, 6 },
+ { 0x3F, 6 },
+ { 0x9, 4 },
+ { 0xE, 4 },
+ { 0xB, 7 },
+ { 0x9, 7 }
+ },
+ { /* AC bias group 4, table 4 */
+ { 0x2, 3 },
+ { 0xE, 4 },
+ { 0x1E, 5 },
+ { 0xC, 4 },
+ { 0x1F, 5 },
+ { 0x6E, 7 },
+ { 0xAD, 10 },
+ { 0xAF, 10 },
+ { 0x14, 7 },
+ { 0x4, 3 },
+ { 0x3, 3 },
+ { 0x1A, 5 },
+ { 0x17, 5 },
+ { 0x2A, 8 },
+ { 0x576, 13 },
+ { 0xAEF, 14 },
+ { 0xAEE, 14 },
+ { 0x571, 13 },
+ { 0x570, 13 },
+ { 0x573, 13 },
+ { 0x572, 13 },
+ { 0x575, 13 },
+ { 0x574, 13 },
+ { 0x3, 4 },
+ { 0x16, 5 },
+ { 0x4, 5 },
+ { 0x36, 6 },
+ { 0xB, 6 },
+ { 0xA, 4 },
+ { 0x0, 3 },
+ { 0x6F, 7 },
+ { 0xAC, 10 }
+ },
+ { /* AC bias group 4, table 5 */
+ { 0x4, 3 },
+ { 0x5, 4 },
+ { 0x3, 3 },
+ { 0x1, 3 },
+ { 0x4, 4 },
+ { 0x2F, 6 },
+ { 0x526, 11 },
+ { 0x1495, 13 },
+ { 0xA6, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x2D, 6 },
+ { 0x2C, 6 },
+ { 0x1494, 13 },
+ { 0x1497, 13 },
+ { 0x1496, 13 },
+ { 0x1491, 13 },
+ { 0x1490, 13 },
+ { 0x1493, 13 },
+ { 0x1492, 13 },
+ { 0x293D, 14 },
+ { 0x293C, 14 },
+ { 0x293F, 14 },
+ { 0x0, 3 },
+ { 0x28, 6 },
+ { 0xA5, 8 },
+ { 0x148, 9 },
+ { 0xA7, 8 },
+ { 0x2E, 6 },
+ { 0x15, 5 },
+ { 0xA4E, 12 },
+ { 0x293E, 14 }
+ },
+ { /* AC bias group 4, table 6 */
+ { 0x4, 3 },
+ { 0x5, 4 },
+ { 0x3, 3 },
+ { 0x1, 3 },
+ { 0x4, 4 },
+ { 0x2F, 6 },
+ { 0x526, 11 },
+ { 0x1495, 13 },
+ { 0xA6, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x2D, 6 },
+ { 0x2C, 6 },
+ { 0x1494, 13 },
+ { 0x1497, 13 },
+ { 0x1496, 13 },
+ { 0x1491, 13 },
+ { 0x1490, 13 },
+ { 0x1493, 13 },
+ { 0x1492, 13 },
+ { 0x293D, 14 },
+ { 0x293C, 14 },
+ { 0x293F, 14 },
+ { 0x0, 3 },
+ { 0x28, 6 },
+ { 0xA5, 8 },
+ { 0x148, 9 },
+ { 0xA7, 8 },
+ { 0x2E, 6 },
+ { 0x15, 5 },
+ { 0xA4E, 12 },
+ { 0x293E, 14 }
+ },
+ { /* AC bias group 4, table 7 */
+ { 0x4, 3 },
+ { 0x5, 4 },
+ { 0x3, 3 },
+ { 0x1, 3 },
+ { 0x4, 4 },
+ { 0x2F, 6 },
+ { 0x526, 11 },
+ { 0x1495, 13 },
+ { 0xA6, 8 },
+ { 0x7, 3 },
+ { 0x6, 3 },
+ { 0x2D, 6 },
+ { 0x2C, 6 },
+ { 0x1494, 13 },
+ { 0x1497, 13 },
+ { 0x1496, 13 },
+ { 0x1491, 13 },
+ { 0x1490, 13 },
+ { 0x1493, 13 },
+ { 0x1492, 13 },
+ { 0x293D, 14 },
+ { 0x293C, 14 },
+ { 0x293F, 14 },
+ { 0x0, 3 },
+ { 0x28, 6 },
+ { 0xA5, 8 },
+ { 0x148, 9 },
+ { 0xA7, 8 },
+ { 0x2E, 6 },
+ { 0x15, 5 },
+ { 0xA4E, 12 },
+ { 0x293E, 14 }
+ },
+ { /* AC bias group 4, table 8 */
+ { 0x3, 3 },
+ { 0x11, 5 },
+ { 0x20, 6 },
+ { 0x74, 7 },
+ { 0x10D, 9 },
+ { 0x863, 12 },
+ { 0x860, 12 },
+ { 0xA, 5 },
+ { 0x75, 7 },
+ { 0x1, 3 },
+ { 0x0, 3 },
+ { 0xB, 4 },
+ { 0xA, 4 },
+ { 0x18, 5 },
+ { 0x38, 6 },
+ { 0x42, 7 },
+ { 0x10F, 9 },
+ { 0x10E, 9 },
+ { 0x219, 10 },
+ { 0x10C3, 13 },
+ { 0x10C2, 13 },
+ { 0x10C5, 13 },
+ { 0x10C4, 13 },
+ { 0xF, 4 },
+ { 0x4, 4 },
+ { 0x19, 5 },
+ { 0xB, 5 },
+ { 0x39, 6 },
+ { 0x9, 4 },
+ { 0x1B, 5 },
+ { 0x1A, 5 },
+ { 0x3B, 6 }
+ },
+ { /* AC bias group 4, table 9 */
+ { 0x5, 3 },
+ { 0x1, 4 },
+ { 0x3E, 6 },
+ { 0x1, 5 },
+ { 0xE2, 8 },
+ { 0x1C6F, 13 },
+ { 0x38D9, 14 },
+ { 0x39, 6 },
+ { 0x1F, 6 },
+ { 0x2, 3 },
+ { 0x1, 3 },
+ { 0x9, 4 },
+ { 0x8, 4 },
+ { 0x0, 5 },
+ { 0x70, 7 },
+ { 0x1C7, 9 },
+ { 0x38C, 10 },
+ { 0x71A, 11 },
+ { 0x38D8, 14 },
+ { 0x38DB, 14 },
+ { 0x38DA, 14 },
+ { 0x38DD, 14 },
+ { 0x38DC, 14 },
+ { 0xD, 4 },
+ { 0x1D, 5 },
+ { 0xE, 5 },
+ { 0x3F, 6 },
+ { 0x3C, 6 },
+ { 0xC, 4 },
+ { 0x6, 4 },
+ { 0x3D, 6 },
+ { 0x1E, 6 }
+ },
+ { /* AC bias group 4, table 10 */
+ { 0x6, 3 },
+ { 0xB, 4 },
+ { 0x11, 5 },
+ { 0x1E, 5 },
+ { 0x74, 7 },
+ { 0x3AA, 10 },
+ { 0x1D5C, 13 },
+ { 0x1, 6 },
+ { 0x21, 6 },
+ { 0x1, 3 },
+ { 0x2, 3 },
+ { 0x7, 4 },
+ { 0x6, 4 },
+ { 0x3E, 6 },
+ { 0xEB, 8 },
+ { 0x1D4, 9 },
+ { 0xEAF, 12 },
+ { 0x3ABB, 14 },
+ { 0x3ABA, 14 },
+ { 0x1D59, 13 },
+ { 0x1D58, 13 },
+ { 0x1D5B, 13 },
+ { 0x1D5A, 13 },
+ { 0xA, 4 },
+ { 0x1C, 5 },
+ { 0x1, 5 },
+ { 0x3F, 6 },
+ { 0x3B, 6 },
+ { 0x1, 4 },
+ { 0x9, 4 },
+ { 0x20, 6 },
+ { 0x0, 6 }
+ },
+ { /* AC bias group 4, table 11 */
+ { 0x4, 3 },
+ { 0xA, 4 },
+ { 0x17, 5 },
+ { 0x4, 4 },
+ { 0x16, 6 },
+ { 0x16A, 9 },
+ { 0x16B1, 13 },
+ { 0x17, 7 },
+ { 0x5B, 7 },
+ { 0x6, 3 },
+ { 0x7, 3 },
+ { 0x1, 4 },
+ { 0x0, 4 },
+ { 0xA, 6 },
+ { 0x2D7, 10 },
+ { 0xB5A, 12 },
+ { 0x16B0, 13 },
+ { 0x16B3, 13 },
+ { 0x16B2, 13 },
+ { 0x2D6D, 14 },
+ { 0x2D6C, 14 },
+ { 0x2D6F, 14 },
+ { 0x2D6E, 14 },
+ { 0x6, 4 },
+ { 0xA, 5 },
+ { 0x4, 5 },
+ { 0x2C, 6 },
+ { 0x17, 6 },
+ { 0x3, 4 },
+ { 0x7, 4 },
+ { 0x16, 7 },
+ { 0xB4, 8 }
+ },
+ { /* AC bias group 4, table 12 */
+ { 0x5, 3 },
+ { 0xD, 4 },
+ { 0x5, 4 },
+ { 0x9, 4 },
+ { 0x33, 6 },
+ { 0x193, 9 },
+ { 0x192C, 13 },
+ { 0x61, 8 },
+ { 0x31, 7 },
+ { 0x0, 2 },
+ { 0x7, 3 },
+ { 0x10, 5 },
+ { 0x11, 5 },
+ { 0xC8, 8 },
+ { 0x192F, 13 },
+ { 0x325B, 14 },
+ { 0x325A, 14 },
+ { 0x1929, 13 },
+ { 0x1928, 13 },
+ { 0x192B, 13 },
+ { 0x192A, 13 },
+ { 0x325D, 14 },
+ { 0x325C, 14 },
+ { 0x18, 5 },
+ { 0x1A, 6 },
+ { 0x1B, 6 },
+ { 0x65, 7 },
+ { 0x19, 6 },
+ { 0x4, 4 },
+ { 0x7, 4 },
+ { 0x60, 8 },
+ { 0x324, 10 }
+ },
+ { /* AC bias group 4, table 13 */
+ { 0x6, 3 },
+ { 0x0, 3 },
+ { 0x2, 4 },
+ { 0xF, 4 },
+ { 0x39, 6 },
+ { 0x1D9, 9 },
+ { 0x1D82, 13 },
+ { 0x761, 11 },
+ { 0x3BE, 10 },
+ { 0x1, 2 },
+ { 0x2, 2 },
+ { 0xF, 6 },
+ { 0xE, 6 },
+ { 0x762, 11 },
+ { 0x3B07, 14 },
+ { 0x3B06, 14 },
+ { 0x3B1D, 14 },
+ { 0x3B1C, 14 },
+ { 0x3B1F, 14 },
+ { 0x3B1E, 14 },
+ { 0x3B19, 14 },
+ { 0x3B18, 14 },
+ { 0x3B1B, 14 },
+ { 0x38, 6 },
+ { 0x1DE, 9 },
+ { 0xED, 8 },
+ { 0x3BF, 10 },
+ { 0xEE, 8 },
+ { 0x3A, 6 },
+ { 0x6, 5 },
+ { 0xEC0, 12 },
+ { 0x3B1A, 14 }
+ },
+ { /* AC bias group 4, table 14 */
+ { 0x0, 2 },
+ { 0x2, 3 },
+ { 0xF, 5 },
+ { 0x6, 4 },
+ { 0x1C, 6 },
+ { 0x1D0, 10 },
+ { 0xE8C, 13 },
+ { 0x1D1B, 14 },
+ { 0x1D1A, 14 },
+ { 0x3, 2 },
+ { 0x2, 2 },
+ { 0xEA, 9 },
+ { 0xE9, 9 },
+ { 0xE89, 13 },
+ { 0xE88, 13 },
+ { 0xE8B, 13 },
+ { 0xE8A, 13 },
+ { 0x1D65, 14 },
+ { 0x1D64, 14 },
+ { 0x1D67, 14 },
+ { 0x1D66, 14 },
+ { 0x1D61, 14 },
+ { 0x1D60, 14 },
+ { 0x3AD, 11 },
+ { 0x1D63, 14 },
+ { 0x1D62, 14 },
+ { 0x1D1D, 14 },
+ { 0x1D1C, 14 },
+ { 0x3B, 7 },
+ { 0x1D7, 10 },
+ { 0x1D1F, 14 },
+ { 0x1D1E, 14 }
+ },
+ { /* AC bias group 4, table 15 */
+ { 0x2, 2 },
+ { 0xF, 4 },
+ { 0x1C, 5 },
+ { 0xC, 4 },
+ { 0x3B, 6 },
+ { 0x1AC, 9 },
+ { 0x1AD8, 13 },
+ { 0x35B3, 14 },
+ { 0x35B2, 14 },
+ { 0x1, 2 },
+ { 0x0, 2 },
+ { 0x69, 7 },
+ { 0x68, 7 },
+ { 0x35BD, 14 },
+ { 0x35BC, 14 },
+ { 0x35BF, 14 },
+ { 0x35BE, 14 },
+ { 0x35B9, 14 },
+ { 0x35B8, 14 },
+ { 0x35BB, 14 },
+ { 0x35BA, 14 },
+ { 0x35B5, 14 },
+ { 0x35B4, 14 },
+ { 0x1A9, 9 },
+ { 0x1A8, 9 },
+ { 0x35A, 10 },
+ { 0xD7, 8 },
+ { 0xD5, 8 },
+ { 0x3A, 6 },
+ { 0x1B, 5 },
+ { 0x35B7, 14 },
+ { 0x35B6, 14 }
+ }
+};
+
+#endif /* VP3DATA_H */
diff --git a/src/libffmpeg/libavcodec/wmadec.c b/src/libffmpeg/libavcodec/wmadec.c
index ab02feb72..8d3763213 100644
--- a/src/libffmpeg/libavcodec/wmadec.c
+++ b/src/libffmpeg/libavcodec/wmadec.c
@@ -199,7 +199,7 @@ static void dump_floats(const char *name, int prec, const float *tab, int n)
#else
-#define trace(fmt, ...)
+#define trace(fmt, args...)
#endif
diff --git a/src/libffmpeg/libavcodec/wmv2.c b/src/libffmpeg/libavcodec/wmv2.c
index 30812198c..ccac9fe77 100644
--- a/src/libffmpeg/libavcodec/wmv2.c
+++ b/src/libffmpeg/libavcodec/wmv2.c
@@ -55,8 +55,8 @@ typedef struct Wmv2Context{
static void wmv2_common_init(Wmv2Context * w){
MpegEncContext * const s= &w->s;
- ff_init_scantable(s, &w->abt_scantable[0], wmv2_scantableA);
- ff_init_scantable(s, &w->abt_scantable[1], wmv2_scantableB);
+ ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[0], wmv2_scantableA);
+ ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1], wmv2_scantableB);
}
static int encode_ext_header(Wmv2Context *w){
diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c
index 8e9d8c51c..d898614a7 100644
--- a/src/libffmpeg/xine_decoder.c
+++ b/src/libffmpeg/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.126 2003/06/12 21:33:33 jstembridge Exp $
+ * $Id: xine_decoder.c,v 1.127 2003/06/19 00:47:19 tmmm Exp $
*
* xine decoder plugin using ffmpeg
*
@@ -759,6 +759,16 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
= strdup ("HuffYUV (ffmpeg)");
break;
+ case BUF_VIDEO_VP31:
+ this->codec = avcodec_find_decoder (CODEC_ID_VP3);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("On2 VP3.1 (ffmpeg)");
+ break;
+ case BUF_VIDEO_4XM:
+ this->codec = avcodec_find_decoder (CODEC_ID_4XM);
+ this->stream->meta_info[XINE_META_INFO_VIDEOCODEC]
+ = strdup ("4XM (ffmpeg)");
+ break;
default:
printf ("ffmpeg: unknown video format (buftype: 0x%08X)\n",
buf->type & 0xFFFF0000);
@@ -1057,6 +1067,10 @@ void avcodec_register_all(void)
register_avcodec(&huffyuv_decoder);
register_avcodec(&cyuv_decoder);
register_avcodec(&h264_decoder);
+ register_avcodec(&vp3_decoder);
+ register_avcodec(&fourxm_decoder);
+ register_avcodec(&ra_144_decoder);
+ register_avcodec(&ra_288_decoder);
}
static void ff_dispose (video_decoder_t *this_gen) {
@@ -1224,6 +1238,16 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
= strdup ("DV Audio (ffmpeg)");
break;
+ case BUF_AUDIO_14_4:
+ this->codec = avcodec_find_decoder (CODEC_ID_RA_144);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("Real 14.4 (ffmpeg)");
+ break;
+ case BUF_AUDIO_28_8:
+ this->codec = avcodec_find_decoder (CODEC_ID_RA_288);
+ this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
+ = strdup ("Real 28.8 (ffmpeg)");
+ break;
case BUF_AUDIO_MPEG:
this->codec = avcodec_find_decoder (CODEC_ID_MP3LAME);
this->stream->meta_info[XINE_META_INFO_AUDIOCODEC]
@@ -1477,6 +1501,8 @@ static uint32_t supported_video_types[] = {
BUF_VIDEO_MPEG,
BUF_VIDEO_DV,
BUF_VIDEO_HUFFYUV,
+/* BUF_VIDEO_VP31,*/
+ BUF_VIDEO_4XM,
0
};
@@ -1489,6 +1515,8 @@ static uint32_t supported_audio_types[] = {
BUF_AUDIO_WMAV1,
BUF_AUDIO_WMAV2,
BUF_AUDIO_DV,
+ BUF_AUDIO_14_4,
+ BUF_AUDIO_28_8,
/* BUF_AUDIO_MPEG, */
0
};